Exemple #1
0
 public static function getSortLinks($order = null)
 {
     $ret = X2Html::link(Yii::t('topics', 'Sorting'), '#', array('id' => 'topics-sort-toggle', 'class' => 'x2-button', 'style' => 'vertical-align:top;'));
     $links = array(X2Html::link(Yii::t('topics', 'Most Recent'), Yii::app()->controller->createUrl('/topics/topics/index', array('order' => 'mostRecent')), array('class' => 'x2-button' . ($order == 'mostRecent' || is_null($order) ? ' disabled disabled-link' : ''), 'style' => 'vertical-align:top;')), X2Html::link(Yii::t('topics', 'Alphabetical'), Yii::app()->controller->createUrl('/topics/topics/index', array('order' => 'alphabetical')), array('class' => 'x2-button' . ($order == 'alphabetical' ? ' disabled disabled-link' : ''), 'style' => 'vertical-align:top;')), X2Html::link(Yii::t('topics', 'Create Date'), Yii::app()->controller->createUrl('/topics/topics/index', array('order' => 'firstCreated')), array('class' => 'x2-button' . ($order == 'firstCreated' ? ' disabled disabled-link' : ''), 'style' => 'vertical-align:top;')), X2Html::link(Yii::t('topics', 'Most Popular'), Yii::app()->controller->createUrl('/topics/topics/index', array('order' => 'mostPopular')), array('class' => 'x2-button' . ($order == 'mostPopular' ? ' disabled disabled-link' : ''), 'style' => 'vertical-align:top;')));
     $ret .= X2Html::tag('div', array('id' => 'topics-sort-buttons', 'style' => 'display:none;'), implode(' ', $links));
     return $ret;
 }
Exemple #2
0
 public function getLink()
 {
     if ($this->type === 'folder') {
         return X2Html::link($this->name, '#', array('class' => 'folder-link pseudo-link', 'data-id' => $this->objId));
     } else {
         return X2Html::link($this->name, Yii::app()->controller->createUrl('/docs/view', array('id' => $this->objId)));
     }
 }
Exemple #3
0
 public function renderButtons()
 {
     $stickyButton = '';
     if (Yii::app()->user->checkAccess('TopicsPinUnpinTopic')) {
         $stickyButton = X2Html::link($this->model->sticky ? Yii::t('topics', 'Unpin Topic') : Yii::t('topics', 'Pin Topic'), '#', array('id' => 'sticky-topic', 'data-id' => $this->model->id, 'class' => 'x2-button', 'style' => 'vertical-align:top;'));
         Yii::app()->clientScript->registerScript('pin-topic', '
             $(document).on("click","#sticky-topic",function(){
                 $.ajax({
                     url:"' . Yii::app()->controller->createUrl('/topics/topics/pinUnpinTopic') . '",
                     data:{id:$(this).attr("data-id")},
                     beforeSend:function(){
                         x2.forms.inputLoading($("#sticky-topic"));
                     },
                     success:function(data){
                         $("#sticky-topic").html(data);
                         x2.forms.inputLoadingStop($("#sticky-topic"));
                     }
                 });
                 return false;
             });
         ', CClientScript::POS_READY);
     }
     echo "<span class='list-view-title-bar-buttons'>\n                {$stickyButton}\n                <div id='show-topics-relationships-button' class='x2-button'>Relationships</div>\n                <div id='show-topics-tags-button' class='x2-button'>Tags</div>\n            </span>";
 }
    echo "<div id='inline-relationships-autocomplete-container'>";
    X2Model::renderModelAutocomplete('Contacts');
    echo CHtml::hiddenField('RelationshipModelId');
    echo "</div>";
    echo CHtml::textField('myName', $model->name, array('disabled' => 'disabled'));
    ?>
        <!-- <input type="hidden" id='RelationshipModelId' name="RelationshipModelId"> -->
    </div>

    <div class='row'>
        <?php 
    echo X2Html::label(Yii::t('app', 'Label:'), 'RelationshipLabelButton');
    echo X2Html::textField('secondLabel');
    echo X2Html::textField('firstLabel', '', array('title' => Yii::t('app', 'Create a different label for ') . $model->name));
    echo X2Html::hiddenField('mutual', 'true');
    echo X2Html::link('', '', array('id' => 'RelationshipLabelButton', 'class' => 'pseudo-link fa fa-long-arrow-right', 'title' => Yii::t('app', 'Create a different label for ') . $model->name));
    ?>
    </div>
    
    <?php 
    echo X2Html::csrfToken();
    echo CHtml::button(Yii::t('app', 'Create Relationship'), array('id' => 'add-relationship-button', 'class' => 'x2-button'));
    ?>
    
</form>

<?php 
}
?>

Exemple #5
0
 public function getImage($link = false)
 {
     if (!$this->fileExists() || !$this->isImage()) {
         return '';
     }
     if ($this->drive) {
         return $this->googlePreview;
     }
     $img = CHtml::image($this->getPublicUrl(), '', array('class' => 'attachment-img'));
     if (!$link) {
         return $img;
     }
     return X2Html::link($img, $this->getPublicUrl());
 }
Exemple #6
0
 public function getText(array $params = array(), array $htmlOptions = array())
 {
     $truncated = array_key_exists('truncated', $params) ? $params['truncated'] : false;
     $requireAbsoluteUrl = array_key_exists('requireAbsoluteUrl', $params) ? $params['requireAbsoluteUrl'] : false;
     $text = "";
     $authorText = "";
     if (Yii::app()->user->getName() == $this->user) {
         $authorText = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions);
     } else {
         $authorText = User::getUserLinks($this->user);
     }
     if (!empty($authorText)) {
         $authorText .= " ";
     }
     switch ($this->type) {
         case 'notif':
             $parent = X2Model::model('Notification')->findByPk($this->associationId);
             if (isset($parent)) {
                 $text = $parent->getMessage();
             } else {
                 $text = Yii::t('app', "Notification not found");
             }
             break;
         case 'record_create':
             $actionFlag = false;
             if (class_exists($this->associationType)) {
                 if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                     if ($this->associationType == 'Actions') {
                         $action = X2Model::model('Actions')->findByPk($this->associationId);
                         if (isset($action) && (strcasecmp($action->associationType, 'contacts') === 0 || in_array($action->type, array('call', 'note', 'time')))) {
                             // Special considerations for publisher-created actions, i.e. call,
                             // note, time, and anything associated with a contact
                             $actionFlag = true;
                             // Retrieve the assigned user from the related action
                             $relatedAction = Actions::model()->findByPk($this->associationId);
                             if ($authorText) {
                                 $authorText = User::getUserLinks($relatedAction->assignedTo);
                             }
                         }
                     }
                     if ($actionFlag) {
                         $authorText = empty($authorText) ? Yii::t('app', 'Someone') : $authorText;
                         switch ($action->type) {
                             case 'call':
                                 $text = Yii::t('app', '{authorText} logged a call ({duration}) with {modelLink}: "{logAbbrev}"', array('{authorText}' => $authorText, '{duration}' => empty($action->dueDate) || empty($action->completeDate) ? Yii::t('app', 'duration unknown') : Formatter::formatTimeInterval($action->dueDate, $action->completeDate, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{logAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             case 'note':
                                 $text = Yii::t('app', '{authorText} posted a comment on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             case 'time':
                                 $text = Yii::t('app', '{authorText} logged {time} on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{time}' => Formatter::formatTimeInterval($action->dueDate, $action->dueDate + $action->timeSpent, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType)), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             default:
                                 if (!empty($authorText)) {
                                     $text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been assigned to " . $authorText, array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
                                 } else {
                                     $text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been created.", array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
                                 }
                         }
                     } else {
                         if (!empty($authorText)) {
                             $modelLink = X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl);
                             if (isset($action) && $this->user !== $action->assignedTo) {
                                 // Include the assignee if this is for an action assigned to someone other than the creator
                                 $translateText = "created a new {modelName} for {assignee}, {modelLink}";
                             } elseif ($modelLink !== '') {
                                 $translateText = "created a new {modelName}, {modelLink}";
                             } else {
                                 $translateText = "created a new {modelName}";
                             }
                             $text = $authorText . Yii::t('app', $translateText, array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => $modelLink, '{assignee}' => isset($action) ? User::getUserLinks($action->assignedTo) : null));
                         } else {
                             $text = Yii::t('app', "A new {modelName}, {modelLink}, has been created.", array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl)));
                         }
                     }
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     if (isset($deletionEvent)) {
                         if (!empty($authorText)) {
                             $text = $authorText . Yii::t('app', "created a new {modelName}, {deletionText}. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
                         } else {
                             $text = Yii::t('app', "A {modelName}, {deletionText}, was created. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
                         }
                     } else {
                         if (!empty($authorText)) {
                             $text = $authorText . Yii::t('app', "created a new {modelName}, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
                         } else {
                             $text = Yii::t('app', "A {modelName} was created, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
                         }
                     }
                 }
             }
             break;
         case 'weblead_create':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = Yii::t('app', "A new web lead has come in: {modelLink}", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                 if (isset($deletionEvent)) {
                     $text = Yii::t('app', "A new web lead has come in: {deletionText}. It has been deleted.", array('{deletionText}' => $deletionEvent->text));
                 } else {
                     $text = Yii::t('app', "A new web lead has come in, but it could not be found.");
                 }
             }
             break;
         case 'record_deleted':
             if (class_exists($this->associationType)) {
                 if (Yii::app()->params->profile !== null && Yii::app()->params->profile->language != 'en' && !empty(Yii::app()->params->profile->language) || Yii::app()->params->profile === null && Yii::app()->language !== 'en' || strpos($this->associationType, 'A') !== 0 && strpos($this->associationType, 'E') !== 0 && strpos($this->associationType, 'I') !== 0 && strpos($this->associationType, 'O') !== 0 && strpos($this->associationType, 'U') !== 0) {
                     if (!empty($authorText)) {
                         $text = $authorText . Yii::t('app', "deleted a {modelType}, {text}", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     } else {
                         $text = Yii::t('app', "A {modelType}, {text}, was deleted", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     }
                 } else {
                     if (!empty($authorText)) {
                         $text = $authorText . Yii::t('app', "deleted an {modelType}, {text}.", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     } else {
                         $text = Yii::t('app', "An {modelType}, {text}, was deleted.", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     }
                 }
             }
             break;
         case 'workflow_start':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     if (isset($stages[$action->stageNumber - 1])) {
                         $text = $authorText . Yii::t('app', 'started the process stage "{stage}" for the {modelName} {modelLink}', array('{stage}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "started a process stage for the {modelName} {modelLink}, but the process stage could not be found.", array('{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     }
                 } else {
                     $text = $authorText . Yii::t('app', "started a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "started a process stage, but the process record could not be found.");
             }
             break;
         case 'workflow_complete':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     if (isset($stages[$action->stageNumber - 1])) {
                         $text = $authorText . Yii::t('app', 'completed the process stage "{stageName}" for the {modelName} {modelLink}', array('{stageName}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "completed a process stage for the {modelName} {modelLink}, but the process stage could not be found.", array('{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     }
                 } else {
                     $text = $authorText . Yii::t('app', "completed a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "completed a process stage, but the process record could not be found.");
             }
             break;
         case 'workflow_revert':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     $text = $authorText . Yii::t('app', 'reverted the process stage "{stageName}" for the {modelName} {modelLink}', array('{stageName}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                 } else {
                     $text = $authorText . Yii::t('app', "reverted a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "reverted a process stage, but the process record could not be found.");
             }
             break;
         case 'feed':
             if (Yii::app()->user->getName() == $this->user) {
                 $author = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions) . " ";
             } else {
                 $author = User::getUserLinks($this->user);
             }
             $recipUser = Yii::app()->db->createCommand()->select('username')->from('x2_users')->where('id=:id', array(':id' => $this->associationId))->queryScalar();
             $modifier = '';
             $recipient = '';
             if ($this->user != $recipUser && $this->associationId != 0) {
                 if (Yii::app()->user->getId() == $this->associationId) {
                     $recipient = Yii::t('app', 'You');
                 } else {
                     $recipient = User::getUserLinks($recipUser);
                 }
                 if (!empty($recipient)) {
                     $modifier = ' &raquo; ';
                 }
             }
             $text = $author . $modifier . $recipient . ": " . ($truncated ? strip_tags(Formatter::convertLineBreaks(x2base::convertUrls($this->text), true, true), '<a></a>') : $this->text);
             break;
         case 'email_sent':
             if (class_exists($this->associationType)) {
                 $model = X2Model::model($this->associationType)->findByPk($this->associationId);
                 if (!empty($model)) {
                     switch ($this->subtype) {
                         case 'quote':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'quote'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         case 'invoice':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'invoice'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         default:
                             $text = $authorText . Yii::t('app', "sent an email to the {transModelName} {modelLink}", array('{transModelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                     }
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     switch ($this->subtype) {
                         case 'quote':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record could not be found.");
                             }
                             break;
                         case 'invoice':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record could not be found.");
                             }
                             break;
                         default:
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "sent an email to a {transModelName}, but that record has been deleted.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                             } else {
                                 $text = $authorText . Yii::t('app', "sent an email to a {transModelName}, but that record could not be found.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                             }
                             break;
                     }
                 }
             }
             break;
         case 'email_opened':
             switch ($this->subtype) {
                 case 'quote':
                     $emailType = Yii::t('app', 'a quote email');
                     break;
                 case 'invoice':
                     $emailType = Yii::t('app', 'an invoice email');
                     break;
                 default:
                     $emailType = Yii::t('app', 'an email');
                     break;
             }
             if (X2Model::getModelName($this->associationType) && count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = X2Model::getModelLink($this->associationId, $this->associationType) . Yii::t('app', ' has opened {emailType}!', array('{emailType}' => $emailType, '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $text = Yii::t('app', "A contact has opened {emailType}, but that contact cannot be found.", array('{emailType}' => $emailType));
             }
             break;
         case 'email_clicked':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = X2Model::getModelLink($this->associationId, $this->associationType) . Yii::t('app', ' opened a link in an email campaign and is visiting your website!', array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $text = Yii::t('app', "A contact has opened a link in an email campaign, but that contact cannot be found.");
             }
             break;
         case 'web_activity':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = "";
                 $text .= X2Model::getModelLink($this->associationId, $this->associationType) . " " . Yii::t('app', "is currently on your website!");
             } else {
                 $text = Yii::t('app', "A contact was on your website, but that contact cannot be found.");
             }
             break;
         case 'case_escalated':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $case = X2Model::model($this->associationType)->findByPk($this->associationId);
                 $text = $authorText . Yii::t('app', "escalated service case {modelLink} to {userLink}", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType), '{userLink}' => User::getUserLinks($case->escalatedTo)));
             } else {
                 $text = $authorText . Yii::t('app', "escalated a service case but that case could not be found.");
             }
             break;
         case 'calendar_event':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = Yii::t('app', "{calendarText} event: {actionDescription}", array('{calendarText}' => CHtml::link(Yii::t('calendar', 'Calendar'), Yii::app()->controller->createAbsoluteUrl('/calendar/calendar/index'), $htmlOptions), '{actionDescription}' => CHtml::encode($action->actionDescription)));
             } else {
                 $text = Yii::t('app', "{calendarText} event: event not found.", array('{calendarText}' => CHtml::link(Yii::t('calendar', 'Calendar'), Yii::app()->controller->createAbsoluteUrl('/calendar/calendar/index'), $htmlOptions)));
             }
             break;
         case 'action_reminder':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = Yii::t('app', "Reminder! The following {action} is due now: {transModelLink}", array('{transModelLink}' => X2Model::getModelLink($this->associationId, $this->associationType), '{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             } else {
                 $text = Yii::t('app', "An {action} is due now, but the record could not be found.", array('{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             }
             break;
         case 'action_complete':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = $authorText . Yii::t('app', "completed the following {action}: {actionDescription}", array('{actionDescription}' => X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl), '{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             } else {
                 $text = $authorText . Yii::t('app', "completed an {action}, but the record could not be found.", array('{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             }
             break;
         case 'doc_update':
             $text = $authorText . Yii::t('app', 'updated a document, {docLink}', array('{docLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             break;
         case 'email_from':
             if (class_exists($this->associationType)) {
                 if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                     $text = $authorText . Yii::t('app', "received an email from a {transModelName}, {modelLink}", array('{transModelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     if (isset($deletionEvent)) {
                         $text = $authorText . Yii::t('app', "received an email from a {transModelName}, but that record has been deleted.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "received an email from a {transModelName}, but that record could not be found.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                     }
                 }
             }
             break;
         case 'voip_call':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = Yii::t('app', "{modelLink} called.", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                 if (isset($deletionEvent)) {
                     $text = $authorText . Yii::t('app', "A contact called, but the contact record has been deleted.");
                 } else {
                     $text = $authorText . Yii::t('app', "Call from a contact whose record could not be found.");
                 }
             }
             break;
         case 'media':
             $media = X2Model::model('Media')->findByPk($this->associationId);
             $text = substr($authorText, 0, -1) . ": " . $this->text;
             if (isset($media)) {
                 if (!$truncated) {
                     $text .= "<br>" . Media::attachmentSocialText($media->getMediaLink(), true, true);
                 } else {
                     $text .= "<br>" . Media::attachmentSocialText($media->getMediaLink(), true, false);
                 }
             } else {
                 $text .= "<br>Media file not found.";
             }
             break;
         case 'topic_reply':
             $reply = TopicReplies::model()->findByPk($this->associationId);
             if (isset($reply)) {
                 $topicLink = X2Html::link($reply->topic->name, Yii::app()->controller->createUrl('/topics/topics/view', array('id' => $reply->topic->id, 'replyId' => $reply->id)));
                 $text = Yii::t('topics', '{poster} posted a new reply to {topic}.', array('{poster}' => $authorText, '{topic}' => $topicLink));
             } else {
                 $text = Yii::t('topics', '{poster} posted a new reply to a topic, but that reply has been deleted.', array('{poster}' => $authorText));
             }
             break;
         default:
             $text = $authorText . CHtml::encode($this->text);
             break;
     }
     if ($truncated && mb_strlen($text, 'UTF-8') > 250) {
         $text = mb_substr($text, 0, 250, 'UTF-8') . "...";
     }
     return $text;
 }
Exemple #7
0
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
?>

<div id='profile-badge'>
	<span id='profile-avatar'>
	<?php 
echo Profile::renderFullSizeAvatar($this->model->id, 45);
?>
	</span>

	<span id='info'>
	<div id='profile-name'>
		<?php 
echo X2Html::link($this->model->fullName, Yii::app()->controller->createUrl('view', array('id' => $this->model->id, 'publicProfile' => true)));
?>
	</div>

	<!--div id='profile-edit'>
		<!?php echo X2Html::link(
			Yii::t('profile','Edit Profile'),
			Yii::app()->controller->createUrl('update', array(
					'id' => $this->model->id 
				))
			);
		?!>
	</div-->
	</span>
	<div class='clear'></div>
</div>
Exemple #8
0
 /**
  * Renders a section header
  * @param  array $section  Section Options
  */
 public function renderSectionHeader($section)
 {
     $html = X2Html::openTag('div', array('class' => 'formSectionHeader'));
     // Add the collapse Icon
     if ($section['collapsible']) {
         $html .= X2Html::link(X2Html::fa('fa-caret-down'), 'javascript:void(0)', array('class' => 'formSectionHide'));
         $html .= X2Html::link(X2Html::fa('fa-caret-right'), 'javascript:void(0)', array('class' => 'formSectionShow'));
     }
     $html .= X2Html::tag('span', array('class' => 'sectionTitle', 'title' => addslashes($section['title'])), Yii::t(strtolower(Yii::app()->controller->id), $section['title']));
     $html .= '</div>';
     return $html;
 }
Exemple #9
0
        <div class="reply-post-number">
            <?php 
echo X2Html::link("#" . ($page * Topics::PAGE_SIZE + ($index + 1)), Yii::app()->controller->createUrl('/topics/topics/view', array('id' => $data->topicId, 'replyId' => $data->id)));
?>
        </div>
        <div class="reply-delete-button">
            <?php 
if ($data->isDeletable()) {
    echo X2Html::ajaxLink(X2Html::fa('close'), Yii::app()->controller->createUrl('/topics/topics/deleteReply', array('id' => $data->id)), array('method' => 'POST', 'data' => array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken), 'success' => 'function() { window.location = window.location }'), array('class' => 'x2-button right', 'confirm' => Yii::t('topics', 'Are you sure you want to delete this post?')));
}
?>
        </div>
        <div class="reply-edit-button">
            <?php 
if ($data->isEditable()) {
    echo X2Html::link('', Yii::app()->controller->createUrl('/topics/topics/updateReply', array('id' => $data->id)), array('class' => 'x2-button icon edit right'));
}
?>
        </div>
        <div class="clear-fix"></div><br>
    </div>
    <div class="topic-content clear-fix">
        <div class="reply-user-info">
            <div class="reply-username">
                <?php 
echo User::getUserLinks($data->assignedTo);
?>
            </div>
            <div class="img-box user-avatar">
                <?php 
echo Profile::renderFullSizeAvatar($data->getAuthorId(), 45);
Exemple #10
0
 * "Powered by X2Engine".
 *****************************************************************************************/
/**
* This file renders the SmallCalendar widget
* The code, is messy as most is taken from the calendar module, 
* Both could use a refactoring, for there is code duplication.
**/
Yii::app()->clientScript->registerScript("smallCalendarJS", "\n\n\n// Put the function in this scope\nfunction giveSaveButtonFocus() {\n    return x2.calendarManager.giveSaveButtonFocus();\n}\n\n\$(function(){\n\n    var justMe;\n    var urls;\n    var myurl; \n    var indicator;\n    var savedForm;\n    var savedTab;\n\n    function initialize(){\n        x2.calendarManager.calendar = '#small-calendar';\n        x2.calendarManager.widgetSettingUrl = '{$widgetSettingUrl}';\n        justMe = {$justMe};\n\n\n        // Initialize the calendar, ensure that only one is present\n        if(\$('#small-calendar .fc-content').length > 0)\n            return;\n\n        // Initialize calendar sources \n        // By fetching the checked user calendars\n        var calendars = {$showCalendars};\n        urls = [];\n        myurl = '{$urls['jsonFeed']}?user={$user}';\n\n        for (var i in calendars.userCalendars){\n            urls.push('{$urls['jsonFeed']}?user='******'{$urls['jsonFeedGroup']}?groupId='+calendars.groupCalendars[i]);\n        }\n\n        indicatorClass();\n        initCalendar();\n        applyHeader();\n        justMeButton();\n        miscModifications();\n        \$('#small-calendar .fc-button').click(responsiveBehavior);\n        responsiveBehavior();\n\n\n    }\n\n    function indicatorClass(){\n        // Singleton class to render the inidcators on the calendar\n        indicator = {\n\n            dayIndicators: [],\n\n            /**\n            *  Adds an event indicator to the calendar\n            *  @param event event full calendar event to be added\n            *  @param view view the full calendar current view\n            */\n            addEvent: function(event, view){\n                if (view.name !== 'month')\n                    return;\n\n                var eventStart = new Date(event.start.valueOf());\n\n                // This is to only show indicators for the current month +/- a margin\n                var viewStart = new Date(view.start);\n                var viewEnd = new Date(view.end);\n                viewStart.setDate( viewStart.getDate() - 7 )\n                viewEnd.setDate( viewEnd.getDate() + 14 )\n\n                // If event starts before the view, move it up.\n                if( event.start.valueOf() < viewStart.valueOf() ){\n                    eventStart = viewStart;\n                }\n\n                // put this function in the scope for readability\n                yyyymmdd = x2.calendarManager.yyyymmdd; \n\n                // Add array of dates and colors for the indicators\n                var dates = [yyyymmdd(eventStart)];\n\n                //Handing if an event spans more than One day\n                if(event.end){\n                    var eventEnd = new Date(event.end.valueOf() - 1000);\n\n                    if( event.end.valueOf() > viewEnd.valueOf() ){\n                        eventEnd = viewEnd;\n                    }\n\n                    var dateEnd = yyyymmdd(eventEnd);\n\n                    //If the event start is after then end, just display one blip at the end\n                    if( eventStart.valueOf() > eventEnd.valueOf() ){\n                        dates = [dateEnd]\n                    } else {\n                        // For every day in the event, \n                        // add the next day to the dates array\n                        var newDate = new Date(eventStart);\n                        for(var i = 0; i < 42; i++){\n                            if(dates[ dates.length - 1 ] == dateEnd)\n                                break;\n\n\n                            newDate.setDate( newDate.getDate() + 1 );\n\n                            dates.push( yyyymmdd(newDate) );\n\n                        }\n                    }\n                }\n\n                \n                var indicator_count = {};\n                // For each date in the array create an event indicator\n                for(var i in dates){\n                    \n                    // If it is already in the array, do not add it again\n                    var contained = false;\n                    for( var j in this.dayIndicators ){\n                        if (this.dayIndicators[j].date === dates[i]) {\n                            //otherwise \n                            if (this.dayIndicators[j].color == event.color){\n                                contained = true;\n                                this.dayIndicators[j].count++;\n                                break;\n                            } \n                        }\n                    }\n\n                    if(!contained)\n                        this.dayIndicators.push({date: dates[i], color: event.color, count: 1});\n\n                }\n            },\n\n            render: function(){\n                //Remove previous indicators\n                \$('#small-calendar .fc-day .fc-indicator-container').children().remove();\n                // \$('#small-calendar .fc-day .fc-day-content').append('<div class=\"fc-indicator-container\"></div>');\n\n                for(var i in this.dayIndicators){\n                    // if (i>5) continue;\n\n                    var event = this.dayIndicators[i];\n\n                    var dayContainer = '#small-calendar .fc-day[data-date=\"'+event.date+'\"] .fc-indicator-container';\n\n                    \$('<div></div>').appendTo( \$(dayContainer) ).\n                    addClass('fc-event-indicator').\n                    css('background-color', event.color).\n                    attr('event-color', event.color).\n                    attr('title', event.count+' event'+ (event.count > 1 ? 's' : '' ));\n                }\n            }\n\n        };\n    }\n\n    function initCalendar(){\n        \$('#small-calendar').fullCalendar({\n\n            // height: 500,\n            theme: true,\n            header: {\n                left: 'title',\n                center: '',\n                right: 'month agendaDay prev,next'\n            },\n            eventSources: justMe ? [myurl] : urls,\n            eventRender: function(event, element, view) {\n                indicator.addEvent(event, view);\n            },\n\n            windowResize: responsiveBehavior,\n\n            dayClick: function(date, allDay, jsEvent, view) {\n\n                    if( view.name == 'month') {\n                        \$('#small-calendar .fc-button-agendaDay').addClass('disabled-link');\n                        \$('#small-calendar .fc-button-month').removeClass('disabled-link');\n                        \$('#small-calendar').fullCalendar ('gotoDate', date);\n                        \$('#small-calendar').fullCalendar ('changeView', 'agendaDay');\n                    } \n                // if (\$(jsEvent.target).hasClass ('day-number-link')) {\n                    // }\n            },\n\n            viewRender: function(view){\n                indicator.dayIndicators = [];\n\n\n            },\n\n            eventAfterAllRender: function(view){\n                indicator.render();\n\n            },\n\n            eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc) { \n                \$.post('{$urls['moveAction']}', {\n                        id: event.id, dayChange: dayDelta, minuteChange: minuteDelta, isAllDay: allDay\n                    });\n            },\n            eventResize: function(event, dayDelta, minuteDelta, revertFunc) {\n                \$.post('{$urls['resizeAction']}', {\n                   id: event.id, dayChange: dayDelta, minuteChange: minuteDelta});\n            },\n            eventClick: function(event){\n                eventClickHandler(event);\n            },\n            editable: true,\n            // translate (if local not set to english)\n            buttonText:     " . X2Calendar::translationArray('buttonText') . ",\n            monthNames:     " . X2Calendar::translationArray('monthNames') . ",\n            monthNamesShort:" . X2Calendar::translationArray('monthNamesShort') . ",\n            dayNames:       " . X2Calendar::translationArray('dayNames') . ",\n            dayNamesShort:  " . X2Calendar::translationArray('dayNamesShort') . ",\n\n\n        });\n    }\n    \n\n    \n    function eventClickHandler(event){\n        if (\$('[id=\"dialog-content_' + event.id + '\"]').length != 0) { \n            return;\n        }\n\n        var boxButtons = [ // buttons on bottom of dialog\n            {\n                text: '" . CHtml::encode(Yii::t('app', 'Close')) . "',\n                click: function() {\n                    \$(this).dialog('close');\n                }\n            }\n        ];\n        \n        var viewAction = \$('<div></div>', {id: 'dialog-content' + '_' + event.id}); \n\n        if(event.editable){\n            var boxTitle = '" . Yii::t('calendar', 'Edit Calendar Event') . "';\n            boxButtons.unshift({\n                        text: '" . CHtml::encode(Yii::t('app', 'Save')) . "', // delete event\n                        click: function() {\n                            // delete event from database\n                            \$.post(\n                                '{$urls['saveAction']}?id=' + event.id, \n                                \$(viewAction).find('form').serialize(),\n                                function() {\n                                    \$('#small-calendar').fullCalendar('refetchEvents');\n                                }\n                            ); \n                            \$(this).dialog('close');\n                        }\n                    });\n            boxButtons.unshift({\n                text: '" . CHtml::encode(Yii::t('app', 'Delete')) . "', // delete event\n                click: function() {\n                    if(confirm('" . Yii::t("calendar", "Are you sure you want to delete this event?") . "')) {\n                        // delete event from database\n                        \$.post('{$urls['deleteAction']}', {id: event.id}); \n                        \$('#small-calendar').fullCalendar('removeEvents', event.id);\n                        \$(this).dialog('close');\n                    }\n                }\n            });\n            \$.post(\n                '{$urls['editAction']}', {\n                    'ActionId': event.id, 'IsEvent': event.type=='event'\n                }, function(data) {\n                    \$(viewAction).append(data);\n                    //open dialog after its filled with action/event\n                    viewAction.dialog('open'); \n                }\n            );\n        } else {\n            var boxTitle = '" . Yii::t('calendar', 'View Calendar Event') . "';\n            \$.post(\n                '{$urls['viewAction']}', {\n                    'ActionId': event.id, \n                    'IsEvent': event.type=='event'\n                }, function(data) {\n                    \$(viewAction).append(data);\n                    //open dialog after its filled with action/event\n                    viewAction.dialog('open'); \n                }\n            );\n        }\n\n\n        // Dialog box that pops up when \n        // an event is clicked. \n        viewAction.dialog({\n            title: boxTitle,\n            dialogClass: 'calendarViewEventDialog',\n            autoOpen: false,\n            resizable: true,\n            height: 'auto',\n            width: 500,\n            position: {my: 'right-12', at: 'left bottom', of: '#small-calendar'}, \n            show: 'fade',\n            hide: 'fade',\n            buttons: boxButtons,\n            open: function() {\n                \$('.ui-dialog-buttonpane').find('button:contains(\"" . Yii::t('app', 'Close') . "\")')\n                    .addClass('highlight')\n                    .focus();\n                \$('.ui-dialog-buttonpane').find('button').css('font-size', '0.85em');\n                \$('.ui-dialog-title').css('font-size', '0.8em');\n                \$('.ui-dialog-titlebar').css('padding', '0.2em 0.4em');\n                \$('.ui-dialog-titlebar-close').css({\n                    'height': '18px',\n                    'width': '18px'\n                    });\n                \$(viewAction).css('font-size', '0.75em');\n            },\n            close: function () {\n                \$(this).dialog ('destroy');\n                  //\$('[id=\"dialog-content_' + event.id + '\"]').remove ();\n                // cleanUpDialog ();\n            },\n            resizeStart: function () {\n            },\n            resize: function (event, ui) {\n            }\n        });\n    }\n\n\n    // Make header a link to the full calendar \n    // \$('#small-calendar .fc-header-title h2').wrap('<a href=\"{$urls['index']}\"></a>').\n    // attr('title', 'Go to full calendar');\n     \n\n    function justMeButton(){\n\n        var meButton = \$('#small-calendar-container #me-button');\n        meButton.click(function(evt){\n            if( !meButton.hasClass('pressed') ){\n                \$('#small-calendar').fullCalendar('removeEventSources');\n                \$('#small-calendar').fullCalendar('addEventSource', myurl);\n                meButton.addClass('pressed');\n                x2.calendarManager.updateWidgetSetting('justMe', true);\n            } else {\n                \$('#small-calendar').fullCalendar('removeEventSources');\n                for(var i in urls){\n                    \$('#small-calendar').fullCalendar('addEventSource', urls[i]);\n                }\n                meButton.removeClass('pressed');            \n                x2.calendarManager.updateWidgetSetting('justMe', false);\n            }\n            \n        });\n        \n    }\n\n    function applyHeader(){\n        var headerRight = \$('#small-calendar .fc-header-right').hide();\n        var headerLeft = \$('#small-calendar .fc-header-left').append(\$('<div class=\"x2-button-group\" ></div>'));\n        \n        headerLeft.find('.x2-button-group').append(headerRight.children());\n        \$('#small-calendar #add-button').appendTo(headerLeft).show();\n        \$('#small-calendar #me-button').appendTo(headerLeft).show();\n        \n\n        \$('#small-calendar .page-title').removeClass('page-title');\n\n    }\n\n    function miscModifications(){\n        // remove the hash that scrolls to teh top of the page\n        \$('#small-calendar .day-number-link').attr('href','javascript:;');\n\n\n        // Re render after the portlet is maximized / minimized\n        \$('#widget_SmallCalendar .portlet-minimize-button').bind('click', function() {\n            window.setTimeout(function() { \$('#small-calendar').fullCalendar('render'); }, 1000) ;\n        });\n    }\n\n    function responsiveBehavior(){\n        var width = \$('#small-calendar .fc-day').width();\n        \$('#small-calendar .day-number-link').css('font-size', width/3*1.25);\n        \$('#small-calendar .fc-day-number').css('padding-top', width/3/1.25);\n\n        if(\$('.fc-header-left').height()> 50){\n            \$('#me-button, #add-button').css('float', 'left');\n        }\n        else {\n            \$('#me-button, #add-button').css('float', 'right');\n        }\n\n        var title = \$('#widget_SmallCalendar #widget-dropdown');\n\n        var minimizeElement = \$('#widget_SmallCalendar #widget-dropdown .portlet-minimize');\n\n        var view = \$('#small-calendar').fullCalendar('getView');\n        if (typeof view.title === 'undefined') {\n            return;\n        }\n\n        title.html('');\n        title.append('<div id=\"header-title\">'+view.title+'</div>');\n        title.append(minimizeElement);\n\n        \$('#small-calendar .x2-button').removeClass('disabled-link');\n        \$('#small-calendar .fc-button-'+view.name).addClass('disabled-link');\n\n\n        if(view.name == 'month'){\n            \$('#small-calendar-container').height('auto');\n        }\n\n        if(view.name == 'agendaDay'){\n            \$('#small-calendar').fullCalendar('option', 'height', 350);\n        }\n    }\n\n\n    initialize();    \n});\n\n", CClientScript::POS_HEAD);
?>

<div id='small-calendar-container'>
    <div id='small-calendar'>

            <?php 
// Be aware these buttons are added dynamically with JS
echo X2Html::link(Yii::t('calendar', 'Full Calendar'), Yii::app()->createUrl('/calendar'), array('style' => 'display:none;', 'class' => "x2-button fc-button", 'id' => "add-button", 'type' => 'button'));
?>
                

            <span title='<?php 
echo Yii::t('calendar', 'Show just my events');
?>
'
            style='display:none;' class="x2-button fc-button <?php 
if ($justMe == 'true') {
    echo 'pressed';
}
?>
" id="me-button" type='button'><?php 
echo Yii::t('calendar', 'Just Me');
?>