Beispiel #1
0
 /**
  * Displays workflow table/funnel diagram or the pipeline
  * @param int $id id of the workflow record
  */
 public function actionView($id)
 {
     // check for optional GET param, if it's not set, use the profile settings
     if (!isset($_GET['perStageWorkflowView'])) {
         $perStageWorkflowView = Yii::app()->params->profile->miscLayoutSettings['perStageWorkflowView'];
     } else {
         $perStageWorkflowView = $_GET['perStageWorkflowView'];
         if ($perStageWorkflowView !== Yii::app()->params->profile->miscLayoutSettings['perStageWorkflowView']) {
             $perStageWorkflowView = $perStageWorkflowView === 'true' ? true : false;
             Profile::setMiscLayoutSetting('perStageWorkflowView', $perStageWorkflowView, true);
         }
     }
     $users = isset($_GET['users']) ? $_GET['users'] : '';
     if (isset($_GET['stage']) && is_numeric($_GET['stage'])) {
         $viewStage = $_GET['stage'];
     } else {
         $viewStage = null;
     }
     // add workflow to user's recent item list
     User::addRecentItem('w', $id, Yii::app()->user->getId());
     //AuxLib::debugLogR ('actionView');
     //$params = ($this->getPerStageViewParams ($id, $viewStage, $users));
     //AuxLib::debugLogR ($params['expectedCloseDateDateRange']);
     $workflows = Workflow::getList(false);
     // no "none" options
     $this->render('view', array_merge(array('perStageWorkflowView' => $perStageWorkflowView, 'workflows' => $workflows), $perStageWorkflowView ? $this->getPerStageViewParams($id, $viewStage, $users) : $this->getDragAndDropViewParams($id, $users)));
 }
Beispiel #2
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');
 }
Beispiel #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 media object to user's recent item list
     User::addRecentItem('m', $id, Yii::app()->user->getId());
     $this->render('view', array('model' => $model));
 }
Beispiel #4
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 doc to user's recent item list
     User::addRecentItem('d', $id, Yii::app()->user->getId());
     X2Flow::trigger('RecordViewTrigger', array('model' => $model));
     $this->render('view', array('model' => $model));
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     User::addRecentItem('BugReports', $id);
     $type = 'BugReports';
     $model = $this->loadModel($id);
     if ($this->checkPermissions($model, 'view')) {
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Beispiel #6
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');
     }
 }
 /**
  * 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');
     }
 }
Beispiel #8
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));
 }
Beispiel #9
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');
     }
 }
Beispiel #10
0
 public function run($id)
 {
     parent::beforeRun();
     $model = $this->getModel($id);
     $this->controller->pageClass = $this->pageClass;
     $this->controller->dataUrl = $model->getUrl();
     $this->controller->pageId .= '-' . $model->id;
     if ($this->controller->checkPermissions($model, 'view')) {
         User::addRecentItem(get_class($model), $id);
         //if (!($model instanceof X2Model))
         $model->setFormatter($this->pathAliasBase . 'components.formatters.MobileFieldFormatter');
         $this->controller->render($this->pathAliasBase . 'views.mobile.recordView', array('model' => $model));
     } else {
         $this->controller->denied();
     }
 }
Beispiel #11
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $userLinks = GroupToUser::model()->findAllByAttributes(array('groupId' => $id));
     $str = "";
     foreach ($userLinks as $userLink) {
         $user = X2Model::model('User')->findByPk($userLink->userId);
         if (isset($user)) {
             $str .= $user->username . ", ";
         }
     }
     $str = substr($str, 0, -2);
     $users = User::getUserLinks($str);
     // add group to user's recent item list
     User::addRecentItem('g', $id, Yii::app()->user->getId());
     $this->render('view', array('model' => $this->loadModel($id), 'users' => $users));
 }
Beispiel #12
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $action = CActiveRecord::model('Actions')->findByPk($id);
     if ($action === null) {
         $this->redirect('index');
     }
     $users = User::getNames();
     $association = $this->getAssociation($action->associationType, $action->associationId);
     if ($this->checkPermissions($action, 'view')) {
         X2Flow::trigger('RecordViewTrigger', array('model' => $action));
         User::addRecentItem('t', $id, Yii::app()->user->getId());
         //add action to user's recent item list
         $this->render('view', array('model' => $this->loadModel($id), 'associationModel' => $association, 'users' => $users));
     } else {
         $this->redirect('index');
     }
 }
 public function run($id)
 {
     parent::beforeRun();
     $model = $this->getModel($id);
     $reply = new TopicReplies();
     if (isset($_POST['TopicReplies'])) {
         if (!$this->controller->checkPermissions($model, 'view')) {
             $this->controller->denied();
         }
         $reply->text = $_POST['TopicReplies']['text'];
         $reply->topicId = $model->id;
         $this->controller->setFileFields($reply, true);
         if ($reply->save()) {
             if (isset($_FILES['TopicReplies'])) {
                 Yii::app()->end();
             }
             $reply = new TopicReplies();
         } else {
             if (isset($_FILES['TopicReplies'])) {
                 throw new CHttpException(400, Yii::t('app', 'Upload failed'));
             }
         }
     }
     $this->controller->pageClass = $this->pageClass;
     $this->controller->dataUrl = $model->getUrl();
     //       AuxLib::debugLogR ('$_GET = ');
     //        AuxLib::debugLogR ($_GET);
     //
     //        if (isset ($_GET['topic-replies_page'])) {
     //            AuxLib::debugLogR ('merging');
     //            $this->controller->dataUrl .= '/topic-replies_page/' . $_GET['topic-replies_page'];
     //           AuxLib::debugLogR ('$this->controller->dataUrl = ');
     //            AuxLib::debugLogR ($this->controller->dataUrl);
     //
     //
     //        }
     $this->controller->pageId .= '-' . $model->id;
     $this->controller->headerTitle = $model->name;
     User::addRecentItem(get_class($model), $id);
     $dataProvider = new CArrayDataProvider($model->replies, array('id' => 'topic-replies', 'pagination' => array('pageSize' => Topics::PAGE_SIZE)));
     $dataProvider->getPagination()->setItemCount($dataProvider->getTotalItemCount());
     $this->controller->render($this->pathAliasBase . 'views.mobile.topicsView', array('model' => $model, 'reply' => $reply, 'dataProvider' => $dataProvider));
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $action = Actions::model()->findByPk($id);
     if ($action != null) {
         $users = User::getNames();
         $association = $this->getAssociation($action->associationType, $action->associationId);
         // if($association != null)
         // $associationName = $association->name;
         //else
         //$associationName = Yii::t('app','None');
         if ($action->assignedTo == Yii::app()->user->getName() || $action->visibility == 1 || $action->assignedTo == 'Anyone') {
             User::addRecentItem('t', $id, Yii::app()->user->getId());
             //add action to user's recent item list
             $this->render('view', array('model' => $this->loadModel($id), 'associationModel' => $association, 'users' => $users));
         } else {
             $this->redirect('index');
         }
     } else {
         $this->redirect('index');
     }
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     // $this->layout = '//layouts/column3';
     $contact = $this->loadModel($id);
     $viewPermissions = $contact->assignedTo == Yii::app()->user->getName() || $contact->visibility == 1 || Yii::app()->user->getName() == 'admin';
     /* x2temp */
     $groups = GroupToUser::model()->findAllByAttributes(array('userId' => Yii::app()->user->getId()));
     $temp = array();
     foreach ($groups as $group) {
         $temp[] = $group->groupId;
     }
     if (array_search($contact->assignedTo, $temp) !== false) {
         $viewPermissions = true;
     }
     if ($contact->visibility == '2') {
         $user = User::model()->findByAttributes(array('username' => $contact->assignedTo));
         $groups = GroupToUser::model()->findAllByAttributes(array('userId' => $user->id));
         $tempOne = array();
         foreach ($groups as $group) {
             $tempOne[] = $group->groupId;
         }
         $userGroups = GroupToUser::model()->findAllByAttributes(array('userId' => Yii::app()->user->getId()));
         $tempTwo = array();
         foreach ($userGroups as $userGroup) {
             $tempTwo[] = $userGroup->groupId;
         }
         if (count(array_intersect($tempOne, $tempTwo)) > 0) {
             $viewPermissions = true;
         }
     }
     if (is_numeric($contact->assignedTo)) {
         $contact->assignedTo = Groups::model()->findByPk($contact->assignedTo)->name;
     }
     /* end x2temp */
     if ($viewPermissions) {
         User::addRecentItem('c', $id, Yii::app()->user->getId());
         ////add contact to user's recent item list
         parent::view($contact, 'contacts');
     } else {
         $this->redirect('index');
     }
 }
Beispiel #16
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');
     }
 }
Beispiel #17
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = CActiveRecord::model('Docs')->findByPk($id);
     if (!$this->checkPermissions($model, 'view')) {
         $this->denied();
     }
     if (isset($model)) {
         $permissions = explode(", ", $model->editPermissions);
         if (in_array(Yii::app()->user->getName(), $permissions)) {
             $editFlag = true;
         } else {
             $editFlag = false;
         }
     }
     if (!isset($model) || $model->visibility == 0 && $model->createdBy != Yii::app()->user->getName() && !Yii::app()->params->isAdmin && !$editFlag) {
         $this->redirect(array('/docs/docs/index'));
     }
     // add doc to user's recent item list
     User::addRecentItem('d', $id, Yii::app()->user->getId());
     X2Flow::trigger('RecordViewTrigger', array('model' => $model));
     $this->render('view', array('model' => $model));
 }
Beispiel #18
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();
     }
     if (!isset($model)) {
         Yii::app()->user->setFlash('error', Yii::t('app', 'The requested page does not exist.'));
         $this->redirect(array('index'));
     }
     if (isset($model->list)) {
         //set this as the list we are viewing, for use by vcr controls
         Yii::app()->user->setState('contacts-list', $model->list->id);
     }
     // add campaign to user's recent item list
     User::addRecentItem('p', $id, Yii::app()->user->getId());
     $this->view($model, 'marketing', array('contactList' => $model->list));
 }