public function formatActionToEvent($action, $id) { if (!($action->visibility >= 1 || $action->assignedTo == Yii::app()->user->name || Yii::app()->params->isAdmin)) { // admin sees all return false; } $linked = !empty($action->associationType) && strtolower($action->associationType) != 'none' && class_exists(X2Model::getModelName($action->associationType)); if ($linked) { $associatedModel = X2Model::getMOdelOfTypeWithId(X2Model::getModelName($action->associationType), $action->associationId); if ($associatedModel) { $associationUrl = $associatedModel->getUrl(); } else { $associationUrl = ''; } } $title = $action->shortActionText; //Email formatting $title = preg_replace('/<b>/', '', $title); $title = preg_replace('/<\\/b>/', '', $title); $title = preg_replace('/\\n\\n/', "\n", $title); $title = preg_replace('/<!--EndSig-->/', '', $title); $title = preg_replace('/<!--BeginOpenedEmail-->/', '', $title); $title = preg_replace('/<!--BeginSignature-->/', '', $title); if (in_array($action->type, array('email', 'emailFrom', 'email_quote', 'email_invoice', 'emailOpened', 'emailOpened_quote', 'emailOpened_invoice'))) { $title = 'Email: ' . $title; } $event = array('title' => $title, 'description' => $title, 'start' => date('Y-m-d H:i', $action->dueDate), 'id' => $action->id, 'complete' => $action->complete, 'calendarAssignment' => $id, 'allDay' => false); if ($action->allDay) { $event['allDay'] = $action->allDay; } if ($action->color) { $event['color'] = $action->color; } else { $event['color'] = '#6389de'; // old default color //$event['color'] = '#3a87ad'; } static $brightnesses = array(); if (!isset($brightnesses[$event['color']])) { $brightnesses[$event['color']] = X2Color::getColorBrightness($event['color']); } if ($brightnesses[$event['color']] < 115) { $event['textColor'] = 'white'; } if ($action->type == 'event') { if ($action->completeDate) { $event['end'] = date('Y-m-d H:i', $action->completeDate); } $event['type'] = 'event'; $event['associationType'] = $action->associationType; } $event['linked'] = $linked; if ($linked) { $event['associationType'] = $action->associationType; $event['associationUrl'] = $associationUrl; $event['associationName'] = $action->associationName; } $editable = X2CalendarPermissions::getEditableUserCalendarNames(); // If it is a group id, we don't need to check this $userEditable = !is_int($id) && isset($editable[$id]); $event['editable'] = $userEditable && Yii::app()->user->checkAccess('ActionsUpdate', array('X2Model' => $action)); return $event; }
* California 95067, USA. or at email address contact@x2engine.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ $user = X2Model::model('User')->findByPk(Yii::app()->user->getId()); $showCalendars = json_decode($user->showCalendars, true); // list of user calendars current user can edit $editableUserCalendars = X2CalendarPermissions::getEditableUserCalendarNames(); // User Calendars if (isset($this->calendarUsers) && $this->calendarUsers !== null) { // actionTogglePortletVisible is defined in calendar controller $toggleUserCalendarsVisibleUrl = $this->createUrl('togglePortletVisible', array('portlet' => 'userCalendars')); $visible = Yii::app()->params->profile->userCalendarsVisible; $this->beginWidget('LeftWidget', array('widgetLabel' => Yii::t('calendar', 'User {calendars}', array('{calendars}' => Modules::displayName() . "s")), 'widgetName' => 'UserCalendars', 'id' => 'user-calendars')); $showUserCalendars = $showCalendars['userCalendars']; echo '<ul style="font-size: 0.8em; font-weight: bold; color: black;">'; foreach ($this->calendarUsers as $userName => $user) { if ($user == 'Anyone') { $user = Yii::t('app', $user); } // check if current user has permission to edit calendar if (isset($editableUserCalendars[$userName])) { $editable = 'true';