当前位置: 首页>>代码示例>>PHP>>正文


PHP X2Model类代码示例

本文整理汇总了PHP中X2Model的典型用法代码示例。如果您正苦于以下问题:PHP X2Model类的具体用法?PHP X2Model怎么用?PHP X2Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了X2Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getJSClassParams

 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;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:11,代码来源:X2ModelConversionWidget.php

示例2: execute

 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();
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:33,代码来源:X2FlowCampaignLaunch.php

示例3: execute

 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));
     }
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:35,代码来源:X2FlowRecordCreate.php

示例4: paramRules

 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))));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:7,代码来源:X2FlowCreateNotif.php

示例5: getAssociationType

 public function getAssociationType()
 {
     if (!isset($this->_associationType)) {
         $this->_associationType = X2Model::getAssociationType(get_class($this->model));
     }
     return $this->_associationType;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:7,代码来源:WorkflowStageDetailsWidget.php

示例6: run

 /**
  * 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);
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:12,代码来源:AjaxGetModelAutocompleteAction.php

示例7: getId

 public function getId()
 {
     if ($this->model === 'more') {
         return 'more';
     } else {
         return lcfirst(X2Model::getModuleName(get_class($this->model)));
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:8,代码来源:RecentItemPanelItem.php

示例8: getX2LeadsLinks

 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);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:9,代码来源:X2Leads.php

示例9: paramRules

 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)));
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:9,代码来源:X2FlowCreateAction.php

示例10: paramRules

 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))));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:9,代码来源:BaseWorkflowStageTrigger.php

示例11: validateModelName

 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'));
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:11,代码来源:EditMobileFormsFormModel.php

示例12: getModelsWhichSupportQuickView

 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;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:12,代码来源:QuickCRUDBehavior.php

示例13: validate

 /**
  * 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);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:15,代码来源:BaseX2FlowWorkflowStageAction.php

示例14: execute

 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;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:52,代码来源:NewListFromSelection.php

示例15: run

 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));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:13,代码来源:TwitterFeed.php


注:本文中的X2Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。