Esempio n. 1
1
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Product'));
     foreach ($fields as $field) {
         if ($field->type == 'link') {
             $fieldName = $field->fieldName;
             $type = ucfirst($field->linkType);
             if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) {
                 eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");");
                 if (isset($lookupModel)) {
                     $model->{$fieldName} = $lookupModel->name;
                 }
             }
         }
     }
     if (isset($_POST['Product'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['Product']);
         // generate history
         $action = new Actions();
         $action->associationType = 'product';
         $action->associationId = $model->id;
         $action->associationName = $model->name;
         $action->assignedTo = Yii::app()->user->getName();
         $action->completedBy = Yii::app()->user->getName();
         $action->dueDate = time();
         $action->completeDate = time();
         $action->visibility = 1;
         $action->complete = 'Yes';
         $action->actionDescription = "Update: {$model->name}\n            Type: {$model->type}\n            Price: {$model->price}\n            Currency: {$model->currency}\n            Inventory: {$model->inventory}";
         $action->save();
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
Esempio n. 2
0
 public function actionView($id)
 {
     if ($id == 0) {
         $this->redirect(array('index'));
     } else {
         $model = X2Calendar::model()->findByPk($id);
         parent::view($model, 'calendar');
     }
 }
Esempio n. 3
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     if (!$this->checkPermissions($model, 'view')) {
         $this->denied();
     }
     // add service case to user's recent item list
     User::addRecentItem('s', $id, Yii::app()->user->getId());
     parent::view($model, 'services');
 }
Esempio n. 4
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  * @param null|Opportunity Set by actionConvertLead in the case that conversion fails
  */
 public function actionView($id, $opportunity = null)
 {
     $type = 'x2Leads';
     $model = $this->loadModel($id);
     if ($this->checkPermissions($model, 'view')) {
         // add opportunity to user's recent item list
         User::addRecentItem('l', $id, Yii::app()->user->getId());
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Esempio n. 5
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'opportunities';
     $model = $this->loadModel($id);
     $model->associatedContacts = Contacts::getContactLinks($model->associatedContacts);
     if ($this->checkPermissions($model, 'view')) {
         // add opportunity to user's recent item list
         User::addRecentItem('o', $id, Yii::app()->user->getId());
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Esempio n. 6
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'quotes';
     $model = $this->getModel($id);
     if (!$this->checkPermissions($model, 'view')) {
         $this->denied();
     }
     $quoteProducts = $model->lineItems;
     // add quote to user's recent item list
     User::addRecentItem('q', $id, Yii::app()->user->getId());
     $contactNameId = Fields::nameAndId($model->associatedContacts);
     $contactId = $contactNameId[1];
     parent::view($model, $type, array('orders' => $quoteProducts, 'contactId' => $contactId));
 }
Esempio n. 7
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     if (!parent::checkPermissions($model, 'view')) {
         $this->denied();
     }
     // add account to user's recent item list
     User::addRecentItem('a', $id, Yii::app()->user->getId());
     if ($model->checkForDuplicates()) {
         $this->redirect($this->createUrl('/site/duplicateCheck', array('moduleName' => 'accounts', 'modelName' => 'Accounts', 'id' => $id, 'ref' => 'view')));
     } else {
         $model->duplicateChecked();
         parent::view($model, 'accounts');
     }
 }
Esempio n. 8
0
 public function run()
 {
     x2base::cleanUpSessions();
     // $criteria = new CDbCriteria(array('condition'=>'','distinct'=>true)
     // $sessions = Session::model()->findAll($criteria);
     // $str = "";
     // foreach($sessions as $session) {
     // if(time()-$session->lastUpdated<(15*60)) {
     // $str.=$session->user.", ";
     // }
     // }
     // if($str!="") {
     // $str=substr($str,0,-2);
     // }
     $onlineUsers = User::getUserLinks(Session::getOnlineUsers());
     $this->render('onlineUsers', array('users' => $onlineUsers));
     //array(
 }
Esempio n. 9
0
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 * 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".
 *****************************************************************************************/
$menuItems = array(array('label' => Yii::t('app', 'Main Menu'), 'url' => array('/mobile/site/home')));
$this->widget('MenuList', array('id' => 'main-menu', 'items' => $menuItems));
?>
<br />
<?php 
echo x2base::convertUrls($model->text);
Esempio n. 10
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;
 }
Esempio n. 11
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), array('ImportExportBehavior' => array('class' => 'ImportExportBehavior')));
 }
Esempio n. 12
0
			echo CHtml::link('[x]',array('deletePost','id'=>$data->id,'redirect'=>Yii::app()->controller->action->id)); //,array('class'=>'x2-button') ?>
	</div>
	<?php echo CHtml::link(Yii::t('profile','Reply'),'#',array('onclick'=>"$('#addReply-".$data->id."').toggle();",'class'=>'x2-button float')); ?>

	<?php
	if($authorRecord->id != $data->associationId && $data->associationId != 0) {
		$temp=Profile::model()->findByPk($data->associationId);
		$recipient=$temp->fullName;
		$modifier=' &raquo; ';
	} else {
		$recipient='';
		$modifier='';
	}
	?>
	<?php echo CHtml::link($author,array('profile/view','id'=>$authorRecord->id)).$modifier.CHtml::link($recipient,$data->associationId); ?> <span class="comment-age"><?php echo x2base::timestampAge(date("Y-m-d H:i:s",$data->timestamp)); ?></span><br />
	<?php echo x2base::convertLineBreaks($this->convertUrls($data->data)); ?><br />
	<?php 
	if(count($commentDataProvider->getData())>0){
		$this->widget('zii.widgets.CListView', array(
		'dataProvider'=>$commentDataProvider,
		'itemView'=>'../social/_view',
		'template'=>'{items}'
	));
	}
	
	echo CHtml::beginForm(
		'addComment',
		'get',
		array(
			'style'=>'display:none;',
			'id'=>'addReply-'.$data->id,
Esempio n. 13
0
 /**
  * This is a prototype function designed to re-build a record from the changelog.
  *
  * This method is largely a work in progress though it is functional right
  * now as is, it could just use some refactoring and improvements. On the
  * "View Changelog" page in the Admin tab there's a link on each Contact
  * changelog entry to view the record at that point in the history. Clicking
  * that link brings you here.
  * @param int $id The ID of the Contact to be viewed
  * @param int $timestamp The timestamp to view the Contact at... this should probably be refactored to changelog ID
  */
 public function actionRevisions($id, $timestamp)
 {
     $contact = $this->loadModel($id);
     // Find all the changelog entries associated with this Contact after the given
     // timestamp. Realistically, this would be more accurate if Changelog ID
     // was used instead of the timestamp.
     $changes = X2Model::model('Changelog')->findAll('type="Contacts" AND itemId="' . $contact->id . '" AND timestamp > ' . $timestamp . ' ORDER BY timestamp DESC');
     // Loop through the changes and apply each one retroactively to the Contact record.
     foreach ($changes as $change) {
         $fieldName = $change->fieldName;
         if ($contact->hasAttribute($fieldName) && $fieldName != 'id') {
             $contact->{$fieldName} = $change->oldValue;
         }
     }
     // Set our widget info
     if (isset($this->portlets['TimeZone'])) {
         $this->portlets['TimeZone']['params']['model'] =& $contact;
     }
     if ($this->checkPermissions($contact, 'view')) {
         if (isset($_COOKIE['vcr-list'])) {
             Yii::app()->user->setState('vcr-list', $_COOKIE['vcr-list']);
         }
         User::addRecentItem('c', $id, Yii::app()->user->getId());
         ////add contact to user's recent item list
         // View the Contact with the data modified to this point
         parent::view($contact, 'contacts');
     } else {
         $this->redirect('index');
     }
 }
Esempio n. 14
0
?>
<div class="view">
	<div class="deleteButton">
		<?php 
$parent = Social::model()->findByPk($data->associationId);
if ($data->user == Yii::app()->user->getName() || $parent->associationId == Yii::app()->user->getId()) {
    echo CHtml::link('[x]', array('deletePost', 'id' => $data->id, 'redirect' => Yii::app()->controller->action->id));
}
//,array('class'=>'x2-button')
?>
	</div>
	<?php 
echo CHtml::link($author, array('profile/view', 'id' => $authorRecord->id));
?>
 <span class="comment-age"><?php 
echo x2base::timestampAge(date("Y-m-d H:i:s", $data->timestamp));
?>
</span><br />
	<?php 
echo $this->convertUrls(CHtml::encode($data->data));
?>
</div>


<?php 
/*
<div class="view">
	<div class="deleteButton">
		<?php echo CHtml::link('[x]',array('deleteNote','id'=>$data->id)); //,array('class'=>'x2-button') ?>
		<?php //echo CHtml::link("<img src='".Yii::app()->request->baseUrl."/images/deleteButton.png' />",array("deleteNote","id"=>$data->id)); ?>
	</div>
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Product('search');
     $name = 'Product';
     parent::admin($model, $name);
 }
Esempio n. 16
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), array('LeadRoutingBehavior' => array('class' => 'LeadRoutingBehavior'), 'responds' => array('class' => 'application.components.ResponseBehavior', 'isConsole' => false, 'exitNonFatal' => false, 'longErrorTrace' => false), 'CommonControllerBehavior' => array('class' => 'application.components.CommonControllerBehavior', 'redirectOnNullModel' => false, 'throwOnNullModel' => false)));
 }
 public function actionAdmin()
 {
     $model = new Actions('search');
     $name = 'Actions';
     parent::admin($model, $name);
 }
Esempio n. 18
0
 /**
  * @param string $str
  * @param boolean $makeLink
  * @param boolean $makeImage
  * @return string
  */
 public static function attachmentSocialText($str, $makeLink = false, $makeImage = false)
 {
     // $a = '<a href="/x2merge/index.php/media/16">footer.png</a>';
     // echo ,preg_match('/^<a href=".+(media\/[0-9]+)" target="_blank">.+<\/a>$/i',$description
     $matches = array();
     // die(CHtml::encode($description));
     if (preg_match('/^<a href=".+media\\/view\\/([0-9]+)">.+<\\/a>$/i', $str, $matches)) {
         if (count($matches) == 2 && is_numeric($matches[1])) {
             $media = X2Model::model('Media')->findByPk($matches[1]);
             if (isset($media)) {
                 $str = Yii::t('media', 'File:') . ' ';
                 return self::getImageText($str, $makeLink, $makeImage, $media);
             }
         }
     } elseif (preg_match('/^<a target="_blank" href="https:\\/\\/drive.google.com\\/file\\/d\\/(.+)">.+<\\/a>$/i', $str, $matches)) {
         if (count($matches) == 2) {
             $media = X2Model::model('Media')->findByAttributes(array('fileName' => $matches[1]));
             if (isset($media)) {
                 $str = Yii::t('media', 'Google Drive:') . ' ';
                 return self::getImageText($str, $makeLink, $makeImage, $media);
             }
         }
     }
     return x2base::convertUrls($str);
 }
Esempio n. 19
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), array('QuickCreateRelationshipBehavior' => array('class' => 'QuickCreateRelationshipBehavior')));
 }
Esempio n. 20
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id) {
		if ($id==Yii::app()->user->getId()) {
			$model=$this->loadModel($id);
			$name="ProfileChild";
			parent::actionUpdate($model, $name);
		} else {
			$this->redirect('view/'.$model->id);
		}
	}
Esempio n. 21
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), array('X2MobileControllerBehavior' => array('class' => 'application.modules.mobile.components.behaviors.X2MobileControllerBehavior')));
 }
Esempio n. 22
0
	/**
	 * Manages all models.
	 */
	public function actionAdmin()
	{
		$model=new DocChild('search');
		$name='DocChild';
		parent::actionAdmin($model,$name);
	}
Esempio n. 23
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     if (isset($_POST['Templates'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['Templates']);
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
Esempio n. 24
0
 public function update($model, $oldAttributes, $api)
 {
     // now in Actions::beforeSave()
     /* $model->dueDate = Formatter::parseDateTime($model->dueDate);
     
               if($model->completeDate)
               $model->completeDate = Formatter::parseDateTime($model->completeDate);
     
               $association = $this->getAssociation($model->associationType,$model->associationId);
     
               if($association != null) {
               $model->associationName = $association->name;
               } else {
               $model->associationName = 'None';
               $model->associationId = 0;
               } */
     // now in Actions::synchGoogleCalendar()
     /* if( !is_numeric($model->assignedTo)) { // assigned to user
        $profile = Profile::model()->findByAttributes(array('username'=>$model->assignedTo));
        if(isset($profile)) // prevent error for actions assigned to 'Anyone'
        $profile->updateGoogleCalendarEvent($model); // update action in Google Calendar if user has a Google Calendar
        } else { // Assigned to group
        $groups = Yii::app()->db->createCommand()->select('userId')->from('x2_group_to_user')->where("groupId={$model->assignedTo}")->queryAll();
        foreach($groups as $group) {
        $profile = Profile::model()->findByPk($group['userId']);
        if(isset($profile)) // prevent error for actions assigned to 'Anyone'
        $profile->updateGoogleCalendarEvent($model);
        }
        } */
     if ($api == 0) {
         parent::update($model, $oldAttributes, $api);
     } else {
         return parent::update($model, $oldAttributes, $api);
     }
 }
Esempio n. 25
0
	public static function convertUrls($text, $convertLineBreaks = true) {
		$text = preg_replace(
			array(
				'/(?(?=<a[^>]*>.+<\/a>)(?:<a[^>]*>.+<\/a>)|([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+))/iex',
				'/<a([^>]*)target="?[^"\']+"?/i',
				'/<a([^>]+)>/i',
				'/(^|\s|>)(www.[^<> \n\r]+)/iex',
				'/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex'
			),
			array(
				"stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))",
				'<a\\1',
				'<a\\1 target="_blank">',
				"stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))",
				"stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
			),
			$text
		);
		// $urlRegex = '/(https?|ftp)://[^\s/$.?#].[^\s]*/iSu';
		// $matches = array();
		// preg_match_all($urlRegex, $text, $matches);
		// $usedPatterns = array();
		// foreach($matches as $pattern) {
			// if(!array_key_exists($pattern, $usedPatterns)) {
				// $usedPatterns[$pattern]=true;
				// $text = mb_ereg_replace($pattern, '<a href="$1">$1</a>', $text);
			// }
		// }
		$template="<a href=".Yii::app()->getBaseUrl().'/index.php/search/search?term=%23\\2'."> #\\2</a>";
		$text = mb_ereg_replace('(^|\s)#(\w\w+)',$template,$text);
                $text = mb_ereg_replace('(>)#(\w\w+)',">".$template,$text);
		if($convertLineBreaks)
			return x2base::convertLineBreaks($text,true,false);
		else
			return $text;
	}
Esempio n. 26
0
 public function actions()
 {
     return array_merge(parent::actions(), array('webleadForm' => array('class' => 'CreateWebFormAction'), 'inlineEmail' => array('class' => 'application.modules.marketing.components.actions.TestEmailAction')));
 }
Esempio n. 27
0
 public function filters()
 {
     return array_merge(parent::filters(), array('accessControl'));
 }
Esempio n. 28
0
 public function actions()
 {
     return array_merge(parent::actions(), array('webleadForm' => array('class' => 'CreateWebFormAction'), 'inlineEmail' => array('class' => 'InlineEmailAction')));
 }
Esempio n. 29
0
	/**
	 * Manages all models.
	 */
	public function actionAdmin() {
		$model=new Templates('search');
		$name='Templates';
		parent::actionAdmin($model, $name);
	}
Esempio n. 30
0
        <div class='stacked-icon'></div>
    </div>
    <div class="event-text-box">
        <div class="deleteButton">
            <?php 
if ($data->type == 'feed' && ($data->user == Yii::app()->user->getName() || Yii::app()->params->isAdmin)) {
    echo CHtml::link('', array('/profile/updatePost', 'id' => $data->id, 'profileId' => $profileId), array('class' => 'fa fa-edit')) . " ";
}
if (($data->user == Yii::app()->user->getName() || $data->associationId == Yii::app()->user->getId()) && $data->type == 'feed' || Yii::app()->params->isAdmin) {
    echo CHtml::link('', '#', array('class' => 'fa fa-close delete-link', 'id' => $data->id . '-delete'));
}
?>
        </div>
        <span class="event-text">
            <?php 
echo Formatter::convertLineBreaks(x2base::convertUrls($data->getText()));
?>
        </span>
        <div class='event-bottom-row'>
            <span class="comment-age x2-hint" id="<?php 
echo $data->id . "-" . $data->timestamp;
?>
" 
                  style="<?php 
echo $style;
?>
"
                  title="<?php 
echo Formatter::formatFeedTimestamp($data->timestamp);
?>
">