本文整理汇总了PHP中X2Model类的典型用法代码示例。如果您正苦于以下问题:PHP X2Model类的具体用法?PHP X2Model怎么用?PHP X2Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了X2Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: validateValue
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;
}
}
开发者ID:dsyman2,项目名称:X2CRM,代码行数:14,代码来源:X2ModelForeignKeyValidator.php
示例17: actionIndex
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));
}
开发者ID:keyeMyria,项目名称:CRM,代码行数:16,代码来源:ContactsController.php
示例18: execute
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);
}
}
开发者ID:dsyman2,项目名称:X2CRM,代码行数:17,代码来源:X2FlowWorkflowStartStage.php
示例19: beforeAction
/**
* 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();
}
}
开发者ID:dsyman2,项目名称:X2CRM,代码行数:53,代码来源:X2ControllerPermissionsBehavior.php
示例20: assertActionCreated
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}");
}
}
开发者ID:shuvro35,项目名称:X2CRM,代码行数:17,代码来源:InlineEmailTest.php
注:本文中的X2Model类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论