예제 #1
0
 public function getJSClassParams()
 {
     if (!isset($this->_JSClassParams)) {
         $title = X2Model::getModelTitle(get_class($this->model), true);
         $targetClass = $this->targetClass;
         $behavior = $this->model->asa('X2ModelConversionBehavior');
         $conversionFailed = $behavior->conversionFailed && $behavior->errorModel !== null && get_class($behavior->errorModel) === $this->targetClass;
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('buttonSelector' => $this->buttonSelector, 'translations' => array('conversionError' => Yii::t('app', '{model} conversion failed.', array('{model}' => $title)), 'conversionWarning' => Yii::t('app', '{model} Conversion Warning', array('{model}' => $title)), 'convertAnyway' => Yii::t('app', 'Convert Anyway'), 'Cancel' => Yii::t('app', 'Cancel')), 'targetClass' => $this->targetClass, 'modelId' => $this->model->id, 'conversionFailed' => $conversionFailed, 'conversionIncompatibilityWarnings' => $this->model->getConversionIncompatibilityWarnings($this->targetClass), 'errorSummary' => $conversionFailed ? "<div class='form'>" . CHtml::errorSummary($this->model->asa('X2ModelConversionBehavior')->errorModel, Yii::t('app', '{model} conversion failed.', array('{model}' => $title))) . "</div>" : ''));
     }
     return $this->_JSClassParams;
 }
예제 #2
0
 public function execute(&$params)
 {
     $campaign = CActiveRecord::model('Campaign')->findByPk($this->config['options']['campaign']);
     if ($campaign === null || $campaign->launchDate != 0 && $campaign->launchDate < time() || empty($campaign->subject)) {
         return false;
     }
     if (!isset($campaign->list) || $campaign->list->type == 'dynamic' && X2Model::model($campaign->list->modelName)->count($campaign->list->queryCriteria()) < 1) {
         return false;
     }
     // check if there's a template, and load that into the content field
     if ($campaign->template != 0) {
         $template = X2Model::model('Docs')->findByPk($campaign->template);
         if (isset($template)) {
             $campaign->content = $template->text;
         }
     }
     //Duplicate the list for campaign tracking, leave original untouched
     //only if the list is not already a campaign list
     if ($campaign->list->type != 'campaign') {
         $newList = $campaign->list->staticDuplicate();
         if (!isset($newList)) {
             return false;
         }
         $newList->type = 'campaign';
         if (!$newList->save()) {
             return false;
         }
         $campaign->list = $newList;
         $campaign->listId = $newList->id;
     }
     $campaign->launchDate = time();
     return $campaign->save();
 }
예제 #3
0
 public function execute(&$params)
 {
     // make sure this is a valid model type
     if (!is_subclass_of($this->config['modelClass'], 'X2Model')) {
         return array(false, "");
     }
     if (!isset($this->config['attributes']) || empty($this->config['attributes'])) {
         return array(false, "");
     }
     // verify that if create relationship option was set, that a relationship can be made
     if ($this->parseOption('createRelationship', $params)) {
         $acceptedModelTypes = X2Model::getModelTypesWhichSupportRelationships();
         if (!in_array($this->config['modelClass'], $acceptedModelTypes)) {
             return array(false, Yii::t('x2flow', 'Relationships cannot be made with records ' . 'of type {type}.', array('{type}' => $this->config['modelClass'])));
         }
         if (!isset($params['model'])) {
             // no model passed to trigger
             return array(false, '');
         }
         if (!in_array(get_class($params['model']), $acceptedModelTypes)) {
             return array(false, Yii::t('x2flow', 'Relationships cannot be made with records ' . 'of type {type}.', array('{type}' => get_class($params['model']))));
         }
     }
     $model = new $this->config['modelClass']();
     $model->setScenario('X2FlowCreateAction');
     if ($this->setModelAttributes($model, $this->config['attributes'], $params) && $model->save()) {
         if ($this->parseOption('createRelationship', $params)) {
             Relationships::create(get_class($params['model']), $params['model']->id, get_class($model), $model->id);
         }
         return array(true, Yii::t('studio', 'View created record: ') . $model->getLink());
     } else {
         $errors = $model->getErrors();
         return array(false, array_shift($errors));
     }
 }
예제 #4
0
 public function paramRules()
 {
     $notifTypes = array('auto' => 'Auto', 'custom' => 'Custom');
     $assignmentOptions = array('{assignedTo}' => '{' . Yii::t('studio', 'Owner of Record') . '}', '{user.username}' => '{' . Yii::t('studio', 'Current User') . '}') + X2Model::getAssignmentOptions(false, false);
     // '{assignedTo}', no groups, no 'anyone'
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'options' => array(array('name' => 'user', 'label' => Yii::t('studio', 'User'), 'type' => 'assignment', 'options' => $assignmentOptions), array('name' => 'text', 'label' => Yii::t('studio', 'Message'), 'optional' => 1))));
 }
 public function getAssociationType()
 {
     if (!isset($this->_associationType)) {
         $this->_associationType = X2Model::getAssociationType(get_class($this->model));
     }
     return $this->_associationType;
 }
 /**
  * Called by the MultiTypeAutocomplete widget to render autocomplete input
  * @param string $modelType
  */
 public function run($modelType, $name = null)
 {
     $htmlOptions = array();
     if ($name) {
         $htmlOptions['name'] = $name;
     }
     X2Model::renderModelAutocomplete($modelType, true, $htmlOptions);
 }
예제 #7
0
 public function getId()
 {
     if ($this->model === 'more') {
         return 'more';
     } else {
         return lcfirst(X2Model::getModuleName(get_class($this->model)));
     }
 }
예제 #8
0
 public function afterFind()
 {
     if ($this->id != $this->name) {
         $this->name = $this->id;
         $this->update(array('name'));
     }
     return parent::afterFind();
 }
예제 #9
0
파일: X2Leads.php 프로젝트: keyeMyria/CRM
 public static function getX2LeadsLinks($accountId)
 {
     $allX2Leads = X2Model::model('X2Leads')->findAllByAttributes(array('accountName' => $accountId));
     $links = array();
     foreach ($allX2Leads as $model) {
         $links[] = CHtml::link($model->name, array('/x2Leads/x2Leads/view', 'id' => $model->id));
     }
     return implode(', ', $links);
 }
예제 #10
0
 public function paramRules()
 {
     $visOptions = array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private'));
     $priorityOptions = array('1' => Yii::t('actions', 'Low'), '2' => Yii::t('actions', 'Medium'), '3' => Yii::t('actions', 'High'));
     // $assignmentOptions = array('{assignedTo}'=>'{'.Yii::t('studio','Owner of Record').'}') + X2Model::getAssignmentOptions(false,true);	// '{assignedTo}', groups, no 'anyone'
     $assignmentOptions = array('{assignedTo}' => '{' . Yii::t('studio', 'Owner of Record') . '}') + X2Model::getAssignmentOptions(false, true);
     // '{assignedTo}', groups, no 'anyone'
     return array('title' => Yii::t('studio', $this->title), 'options' => array(array('name' => 'dueDate', 'label' => Yii::t('actions', 'Due Date'), 'type' => 'dateTime', 'optional' => 1), array('name' => 'subject', 'label' => Yii::t('actions', 'Subject'), 'optional' => 1), array('name' => 'description', 'label' => Yii::t('actions', 'Description'), 'type' => 'text'), array('name' => 'assignedTo', 'label' => Yii::t('actions', 'Assigned To'), 'type' => 'dropdown', 'options' => $assignmentOptions), array('name' => 'priority', 'label' => Yii::t('actions', 'Priority'), 'type' => 'dropdown', 'options' => $priorityOptions), array('name' => 'visibility', 'label' => Yii::t('actions', 'Visibility'), 'type' => 'dropdown', 'options' => $visOptions)));
 }
예제 #11
0
 public function paramRules()
 {
     $workflows = Workflow::getList(false);
     // no "none" options
     $workflowIds = array_keys($workflows);
     $stages = count($workflowIds) ? Workflow::getStagesByNumber($workflowIds[0]) : array('---');
     $stages = array('' => Yii::t('app', 'Any')) + $stages;
     return array('title' => Yii::t('studio', $this->title), 'modelClass' => 'modelClass', 'options' => array(array('name' => 'workflowId', 'label' => Yii::t('studio', 'Process'), 'type' => 'dropdown', 'options' => $workflows), array('name' => 'stageNumber', 'label' => Yii::t('studio', 'Stage'), 'type' => 'dependentDropdown', 'dependency' => 'workflowId', 'options' => $stages, 'optional' => true, 'optionsSource' => Yii::app()->createUrl('/workflow/workflow/getStageNames')), array('name' => 'modelClass', 'label' => Yii::t('studio', 'Associated Record Type'), 'type' => 'dropdown', 'options' => X2Model::getModelTypesWhichSupportWorkflow(true))));
 }
예제 #12
0
 protected function renderLink($field, $makeLinks, $textOnly, $encode)
 {
     $fieldName = $field->fieldName;
     $linkedModel = $this->owner->getLinkedModel($fieldName, false);
     if ($linkedModel === null) {
         return $this->render($this->owner->{$fieldName}, $encode);
     } else {
         return $makeLinks ? $linkedModel->getLink() : $linkedModel->name;
     }
 }
예제 #13
0
 public function validateModelName($attr)
 {
     $value = $this->{$attr};
     $modules = MobileModule::supportedModules(new CDbCriteria(array('condition' => 'editable')));
     $validNames = array_map(function ($module) {
         return X2Model::getModelName($module->name);
     }, $modules);
     if (!in_array($value, $validNames)) {
         $this->addError($attr, Yii::t('app', 'Invalid model name'));
     }
 }
예제 #14
0
 public static function getModelsWhichSupportQuickView($includeActions = false)
 {
     if (!isset(self::$_modelsWhichSupportQuickView)) {
         self::$_modelsWhichSupportQuickView = array_diff(array_keys(X2Model::getModelNames()), array('Docs', 'Groups', 'Campaign', 'Media', 'BugReports'));
         self::$_modelsWhichSupportQuickView[] = 'Actions';
     }
     $modelNames = self::$_modelsWhichSupportQuickView;
     if (!$includeActions) {
         array_pop($modelNames);
     }
     return $modelNames;
 }
 /**
  * Validates type of model that triggered the flow
  */
 public function validate(&$params = array(), $flowId = null)
 {
     $model = $params['model'];
     $modelName = get_class($model);
     // ensure that model can be associated with workflows
     if (!$model instanceof X2Model) {
         return array(false, Yii::t('studio', "Processes are not associated with records of this type"));
     } elseif (!$model->supportsWorkflow) {
         return array(false, Yii::t('studio', "{recordName} are not associated with processes", array('{recordName}' => ucfirst(X2Model::getRecordName($modelName)))));
     }
     return parent::validate($params, $flowId);
 }
예제 #16
0
 public function execute(array $gvSelection)
 {
     if (Yii::app()->controller->modelClass !== 'Contacts' || !isset($_POST['listName']) || $_POST['listName'] === '') {
         throw new CHttpException(400, Yii::t('app', 'Bad Request'));
     }
     if (!Yii::app()->params->isAdmin && !Yii::app()->user->checkAccess('ContactsCreateListFromSelection')) {
         return -1;
     }
     $listName = $_POST['listName'];
     foreach ($gvSelection as &$contactId) {
         if (!ctype_digit((string) $contactId)) {
             throw new CHttpException(400, Yii::t('app', 'Invalid selection.'));
         }
     }
     $list = new X2List();
     $list->name = $_POST['listName'];
     $list->modelName = 'Contacts';
     $list->type = 'static';
     $list->assignedTo = Yii::app()->user->getName();
     $list->visibility = 1;
     $list->createDate = time();
     $list->lastUpdated = time();
     $itemModel = X2Model::model('Contacts');
     $success = true;
     if ($list->save()) {
         // if the list is valid save it so we can get the ID
         $count = 0;
         foreach ($gvSelection as &$itemId) {
             if ($itemModel->exists('id="' . $itemId . '"')) {
                 // check if contact exists
                 $item = new X2ListItem();
                 $item->contactId = $itemId;
                 $item->listId = $list->id;
                 if ($item->save()) {
                     // add all the things!
                     $count++;
                 }
             }
         }
         $list->count = $count;
         $this->listId = $list->id;
         if ($list->save()) {
             self::$successFlashes[] = Yii::t('app', '{count} record' . ($count === 1 ? '' : 's') . ' added to new list "{list}"', array('{count}' => $count, '{list}' => $list->name));
         } else {
             self::$errorFlashes[] = Yii::t('app', 'List created but records could not be added to it');
         }
     } else {
         $success = false;
         self::$errorFlashes[] = Yii::t('app', 'List could not be created');
     }
     return $success ? $count : -1;
 }
예제 #17
0
 public function run()
 {
     $actionParams = Yii::app()->controller->getActionParams();
     $twitter = null;
     if (isset(Yii::app()->controller->module) && Yii::app()->controller->module instanceof ContactsModule && Yii::app()->controller->action->id == 'view' && isset($actionParams['id'])) {
         // must have an actual ID value
         $currentRecord = X2Model::model('Contacts')->findByPk($actionParams['id']);
         if (!empty($currentRecord->twitter)) {
             $twitter = $currentRecord->twitter;
         }
     }
     $this->render('twitterFeed', array('twitter' => $twitter));
 }
예제 #18
0
 protected function validateValue(CModel $object, $value, $attribute)
 {
     // exception added for case where validator is added to AmorphousModel
     if (!$object instanceof X2Model) {
         return;
     }
     $field = $object->getField($attribute);
     $linkType = $field->linkType;
     $model = X2Model::model($linkType);
     if (!$model || !$model->findByPk($value)) {
         $this->error(Yii::t('admin', 'Invalid {fieldName}', array('{fieldName}' => $field->attributeLabel)));
         return false;
     }
 }
예제 #19
0
 public function actionIndex()
 {
     $user = User::model()->findByPk(Yii::app()->user->getId());
     $topList = $user->topContacts;
     $pieces = explode(',', $topList);
     $contacts = array();
     foreach ($pieces as $piece) {
         $contact = X2Model::model('Contacts')->findByPk($piece);
         if (isset($contact)) {
             $contacts[] = $contact;
         }
     }
     $dataProvider = new CActiveDataProvider('Contacts');
     $dataProvider->setData($contacts);
     $this->render('index', array('dataProvider' => $dataProvider));
 }
예제 #20
0
 public function execute(&$params)
 {
     $workflowId = $this->parseOption('workflowId', $params);
     $stageNumber = $this->parseOption('stageNumber', $params);
     $model = $params['model'];
     $type = lcfirst(X2Model::getModuleName(get_class($model)));
     $modelId = $model->id;
     $workflowStatus = Workflow::getWorkflowStatus($workflowId, $modelId, $type);
     $message = '';
     if (Workflow::validateAction('start', $workflowStatus, $stageNumber, '', $message)) {
         list($started, $workflowStatus) = Workflow::startStage($workflowId, $stageNumber, $model, $workflowStatus);
         assert($started);
         return array(true, Yii::t('studio', 'Stage "{stageName}" started for {recordName}', array('{stageName}' => $workflowStatus['stages'][$stageNumber]['name'], '{recordName}' => $model->getLink())));
     } else {
         return array(false, $message);
     }
 }
 /**
  * Extension of a base Yii function, this method is run before every action
  * in a controller. If true is returned, it procedes as normal, otherwise
  * it will redirect to the login page or generate a 403 error.
  * @param string $action The name of the action being executed.
  * @return boolean True if the user can procede with the requested action
  */
 public function beforeAction($action = null)
 {
     if (is_int(Yii::app()->locked) && !Yii::app()->user->checkAccess('GeneralAdminSettingsTask')) {
         $this->owner->appLockout();
     }
     $auth = Yii::app()->authManager;
     $params = array();
     if (empty($action)) {
         $action = $this->owner->getAction()->getId();
     } elseif (is_string($action)) {
         $action = $this->owner->createAction($action);
     }
     $actionId = $action->getId();
     // These actions all have a model provided with them but its assignment
     // should not be checked for an exception. They either have permission
     // for this action or they do not.
     $exceptions = array('updateStageDetails', 'deleteList', 'updateList', 'userCalendarPermissions', 'exportList', 'updateLocation');
     if (($this->owner->hasProperty('modelClass') || property_exists($this->owner, 'modelClass')) && class_exists($this->owner->modelClass)) {
         $staticModel = X2Model::model($this->owner->modelClass);
     }
     if (isset($_GET['id']) && !in_array($actionId, $exceptions) && !Yii::app()->user->isGuest && isset($staticModel)) {
         // Check assignment fields in the current model
         $retrieved = true;
         $model = $staticModel->findByPk($_GET['id']);
         if ($model instanceof X2Model) {
             $params['X2Model'] = $model;
         }
     }
     // Generate the proper name for the auth item
     $actionAccess = ucfirst($this->owner->getId()) . ucfirst($actionId);
     $authItem = $auth->getAuthItem($actionAccess);
     // Return true if the user is explicitly allowed to do it, or if there is no permission
     // item, or if they are an admin
     if (Yii::app()->params->isAdmin || (!Yii::app()->user->isGuest || Yii::app()->controller instanceof ApiController || Yii::app()->controller instanceof Api2Controller) && !$authItem instanceof CAuthItem || Yii::app()->user->checkAccess($actionAccess, $params)) {
         return true;
     } elseif (Yii::app()->user->isGuest) {
         Yii::app()->user->returnUrl = Yii::app()->request->url;
         if (Yii::app()->params->isMobileApp) {
             $this->owner->redirect($this->owner->createAbsoluteUrl('/mobile/login'));
         } else {
             $this->owner->redirect($this->owner->createUrl('/site/login'));
         }
     } else {
         $this->owner->denied();
     }
 }
예제 #22
0
 public function assertActionCreated($type, $message = null)
 {
     $action = Actions::model()->findBySql("SELECT * FROM x2_actions WHERE type='{$type}' ORDER BY createDate DESC,id DESC LIMIT 1");
     $this->assertTrue((bool) $action, "Failed asserting that an action was created. {$type}");
     $associatedModel = X2Model::getAssociationModel($action->associationType, $action->associationId);
     // Test that the models are identical:
     $this->eml->targetModel->refresh();
     foreach (array('myModelName', 'id', 'name', 'lastUpdated', 'createDate', 'assignedTo', 'status') as $property) {
         if ($this->eml->targetModel->hasProperty($property) && $associatedModel->hasProperty($property)) {
             $this->assertEquals($this->eml->targetModel->{$property}, $associatedModel->{$property}, "Failed asserting that an action's associated model record was the same, property: {$property}. {$message}");
         }
     }
     // Assert that the username fields are set properly:
     foreach (array('assignedTo', 'completedBy') as $attr) {
         $this->assertEquals('testuser', $action->assignedTo, "Failed asserting that {$attr} was set properly on the action record. {$message}");
     }
 }
예제 #23
0
 public function renderContactFields($model)
 {
     $defaultFields = X2Model::model('Fields')->findAllByAttributes(array('modelName' => 'Contacts'), array('condition' => "fieldName IN ('firstName', 'lastName', 'email', 'phone')"));
     $requiredFields = X2Model::model('Fields')->findAllByAttributes(array('modelName' => 'Contacts', 'required' => 1), array('condition' => "fieldName NOT IN ('firstName', 'lastName', 'phone', 'email', 'visibility')"));
     $i = 0;
     $fields = array_merge($requiredFields, $defaultFields);
     foreach ($fields as $field) {
         if ($field->type === 'boolean') {
             $class = "";
             echo "<div>";
         } else {
             $class = $field->fieldName === 'firstName' || $field->fieldName === 'lastName' ? 'quick-contact-narrow' : 'quick-contact-wide';
         }
         $htmlAttr = array('class' => $class, 'tabindex' => 100 + $i, 'title' => $field->attributeLabel, 'id' => 'quick_create_' . $field->modelName . '_' . $field->fieldName);
         if ($field->type === 'boolean') {
             echo CHtml::label($field->attributeLabel, $htmlAttr['id']);
         }
         echo X2Model::renderModelInput($model, $field, $htmlAttr);
         if ($field->type === 'boolean') {
             echo "</div>";
         }
         ++$i;
     }
 }
예제 #24
0
 /**
  * Echo a list of model attributes as a dropdown.
  *
  * This method is called via AJAX as a part of creating notification criteria.
  * It takes the model or module name as POST data and returns a list of dropdown
  * options consisting of the fields available to that model.
  */
 public function actionGetAttributes()
 {
     $data = array();
     $type = null;
     if (isset($_POST['Criteria']['modelType'])) {
         $type = ucfirst($_POST['Criteria']['modelType']);
     }
     if (isset($_POST['Fields']['modelName'])) {
         $type = $_POST['Fields']['modelName'];
     }
     if (isset($type)) {
         if ($type == 'Marketing') {
             $type = 'Campaign';
         } elseif ($type == 'Quotes') {
             $type = 'Quote';
         } elseif ($type == 'Products') {
             $type = 'Product';
         } elseif ($type == 'Opportunities') {
             $type = 'Opportunity';
         }
         foreach (X2Model::model('Fields')->findAllByAttributes(array('modelName' => $type)) as $field) {
             if ($field->fieldName != 'id') {
                 if (isset($_POST['Criteria'])) {
                     $data[$field->fieldName] = $field->attributeLabel;
                 } else {
                     $data[$field->id] = $field->attributeLabel;
                 }
             }
         }
     }
     asort($data);
     $data = array('' => '-') + $data;
     $htmlOptions = array();
     echo CHtml::listOptions('', $data, $htmlOptions);
 }
예제 #25
0
 public function getTemplate()
 {
     $model = $this->getModel();
     $moduleName = strtolower(X2Model::getModuleName(get_class($model)));
     return "<div class='submenu-title-bar widget-title-bar {$moduleName}'>{widgetLabel}{closeButton}{minimizeButton}{settingsMenu}</div>{widgetContents}";
 }
예제 #26
0
파일: Modules.php 프로젝트: xl602/X2CRM
 /**
  * Retrieves the item name for the specified Module
  * @param string $module Module to retrieve item name for, or the current module if null
  */
 public static function itemDisplayName($moduleName = null)
 {
     if (is_null($moduleName)) {
         $moduleName = Yii::app()->controller->module->name;
     }
     $module = X2Model::model('Modules')->findByAttributes(array('name' => $moduleName));
     $itemName = $moduleName;
     if (!empty($module->itemName)) {
         $itemName = $module->itemName;
     } else {
         // Attempt to load item name from legacy module options file
         $moduleDir = implode(DIRECTORY_SEPARATOR, array('protected', 'modules', $moduleName));
         $configFile = implode(DIRECTORY_SEPARATOR, array($moduleDir, lcfirst($moduleName) . "Config.php"));
         if (is_dir($moduleDir) && file_exists($configFile)) {
             $file = Yii::app()->file->set($configFile);
             $contents = $file->getContents();
             if (preg_match("/.*'recordName'.*/", $contents, $matches)) {
                 $itemNameLine = $matches[0];
                 $itemNameRegex = "/.*'recordName'=>'([\\w\\s]*?)'.*/";
                 $itemName = preg_replace($itemNameRegex, "\$1", $itemNameLine);
                 if (!empty($itemName)) {
                     // Save this name in the database for the future
                     $module->itemName = $itemName;
                     $module->save();
                 }
             }
         }
     }
     return $itemName;
 }
예제 #27
0
 public function getInsertableAttributeTokens()
 {
     X2Model::$getInsertableAttributeTokensDepth++;
     $tokens = array();
     if (X2Model::$getInsertableAttributeTokensDepth > 2) {
         return $tokens;
     }
     // simple tokens
     $tokens = array_merge($tokens, array_map(function ($elem) {
         return '{' . $elem . '}';
     }, $this->attributeNames()));
     // assignment tokens
     if (X2Model::$getInsertableAttributeTokensDepth < 2) {
         $assignmentFields = array_filter($this->fields, function ($elem) {
             return $elem->type === 'assignment';
         });
         foreach ($assignmentFields as $field) {
             $assignmentModel = X2Model::model('Profile');
             $tokens = array_merge($tokens, array_map(function ($elem) use($field) {
                 return '{' . $field->fieldName . '.' . $elem . '}';
             }, $assignmentModel->attributeNames()));
         }
     }
     // link tokens
     if (X2Model::$getInsertableAttributeTokensDepth < 2) {
         $linkFields = array_filter($this->fields, function ($elem) {
             return $elem->type === 'link';
         });
         foreach ($linkFields as $field) {
             $linkModelName = $field->linkType;
             $linkModel = $linkModelName::model();
             $tokens = array_merge($tokens, array_map(function ($elem) use($field) {
                 return '{' . $field->fieldName . '.' . preg_replace('/\\{|\\}/', '', $elem) . '}';
             }, $linkModel->getInsertableAttributeTokens()));
         }
     }
     X2Model::$getInsertableAttributeTokensDepth--;
     return $tokens;
 }
예제 #28
0
 public function recordEmailOpen()
 {
     if ($this->opened === null) {
         $openedAction = $this->createEmailOpenedAction();
         $event = $this->createEmailOpenedEvent();
         if ($openedAction->save() && $event->save()) {
             $this->opened = time();
             $this->update();
             $model = X2Model::getAssociationModel($openedAction->associationType, $openedAction->associationId);
             X2Flow::trigger('EmailOpenTrigger', array('model' => $model));
         }
     }
 }
예제 #29
0
파일: Groups.php 프로젝트: dsyman2/X2CRM
 /**
  * Delete associated group to user records 
  */
 public function afterDelete()
 {
     GroupToUser::model()->deleteAll(array('condition' => 'groupId=' . $this->id));
     parent::afterDelete();
 }
예제 #30
0
 public function actionDeleteAction()
 {
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
         $action = Actions::model()->findByPk($id);
         $profile = Profile::model()->findByAttributes(array('username' => $action->assignedTo));
         if (isset($profile)) {
             $profile->deleteGoogleCalendarEvent($action);
         }
         // update action in Google Calendar if user has a Google Calendar
         X2Model::model('Events')->deleteAllByAttributes(array('associationType' => 'Actions', 'type' => 'calendar_event', 'associationId' => $action->id));
         $action->delete();
     }
 }