. * * This file is a part of iCalcreator. */ namespace Kigkonsult\Icalcreator\Traits; use Kigkonsult\Icalcreator\Util\Util; use Kigkonsult\Icalcreator\Util\UtilAttendee; /** * ORGANIZER property functions * * @author Kjell-Inge Gustafsson, kigkonsult * @since 2.22.23 - 2017-04-03 */ trait ORGANIZERtrait { /** * @var array component property ORGANIZER value * @access protected */ protected $organizer = null; /** * Return formatted output for calendar component property organizer * * @return string */ public function createOrganizer() { if( empty( $this->organizer )) { return null; } if( empty( $this->organizer[Util::$LCvalue] )) { return ( $this->getConfig( Util::$ALLOWEMPTY )) ? Util::createElement( Util::$ORGANIZER ) : null; } return Util::createElement( Util::$ORGANIZER, Util::createParams( $this->organizer[Util::$LCparams], [ Util::$CN, Util::$DIR, Util::$SENT_BY, Util::$LANGUAGE, ], $this->getConfig( Util::$LANGUAGE ) ), $this->organizer[Util::$LCvalue] ); } /** * Set calendar component property organizer * * @param string $value * @param array $params * @return bool */ public function setOrganizer( $value, $params = null ) { if( empty( $value )) { if( $this->getConfig( Util::$ALLOWEMPTY )) { $value = Util::$SP0; } else { return false; } } $value = UtilAttendee::calAddressCheck( $value, false ); $this->organizer = [ Util::$LCvalue => $value, Util::$LCparams => Util::setParams( $params ), ]; if( isset( $this->organizer[Util::$LCparams][Util::$SENT_BY] )) { $this->organizer[Util::$LCparams][Util::$SENT_BY] = UtilAttendee::calAddressCheck( $this->organizer[Util::$LCparams][Util::$SENT_BY], false ); } return true; } }