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


PHP X2Model::model方法代码示例

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


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

示例1: renderLink

 public function renderLink($field, array $htmlOptions = array())
 {
     $fieldName = $field->fieldName;
     $linkId = '';
     $name = '';
     $linkSource = null;
     // TODO: move this code and duplicate code in X2Model::renderModelInput into a helper
     // method. Might be able to use X2Model::getLinkedModel.
     if (class_exists($field->linkType)) {
         if (!empty($this->owner->{$fieldName})) {
             list($name, $linkId) = Fields::nameAndId($this->owner->{$fieldName});
             $linkModel = X2Model::getLinkedModelMock($field->linkType, $name, $linkId, true);
         } else {
             $linkModel = X2Model::model($field->linkType);
         }
         if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
             $linkSource = Yii::app()->controller->createAbsoluteUrl($linkModel->autoCompleteSource);
             $linkId = $linkModel->id;
             $oldLinkFieldVal = $this->owner->{$fieldName};
             $this->owner->{$fieldName} = $name;
         }
     }
     $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array());
     $input .= CHtml::activeTextField($this->owner, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'data-x2-link-source' => $linkSource, 'class' => 'x2-mobile-autocomplete', 'autocomplete' => 'off'), $htmlOptions));
     return $input;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:26,代码来源:MobileFieldInputRenderer.php

示例2: getCriteria

 public static function getCriteria($associationId, $associationType, $relationships, $historyType)
 {
     // Based on our filter, we need a particular additional criteria
     $historyCriteria = array('all' => '', 'action' => ' AND type IS NULL', 'overdueActions' => ' AND type IS NULL AND complete="NO" AND dueDate <= ' . time(), 'incompleteActions' => ' AND type IS NULL AND complete="NO"', 'call' => ' AND type="call"', 'note' => ' AND type="note"', 'attachments' => ' AND type="attachment"', 'event' => ' AND type="event"', 'email' => ' AND type IN ("email","email_staged",' . '"email_opened","email_clicked","email_unsubscribed")', 'marketing' => ' AND type IN ("email","webactivity","weblead","email_staged",' . '"email_opened","email_clicked","email_unsubscribed","event")', 'quotes' => 'AND type like "quotes%"', 'time' => ' AND type="time"', 'webactivity' => 'AND type IN ("weblead","webactivity")', 'workflow' => ' AND type="workflow"');
     $multiAssociationIds = array($associationId);
     if ($relationships) {
         // Add association conditions for our relationships
         $type = $associationType;
         $model = X2Model::model($type)->findByPk($associationId);
         if (count($model->relatedX2Models) > 0) {
             $associationCondition = "((associationId={$associationId} AND " . "associationType='{$associationType}')";
             // Loop through related models and add an association type OR for each
             foreach ($model->relatedX2Models as $relatedModel) {
                 if ($relatedModel instanceof X2Model) {
                     $multiAssociationIds[] = $relatedModel->id;
                     $associationCondition .= " OR (associationId={$relatedModel->id} AND " . "associationType='{$relatedModel->myModelName}')";
                 }
             }
             $associationCondition .= ")";
         } else {
             $associationCondition = 'associationId=' . $associationId . ' AND ' . 'associationType="' . $associationType . '"';
         }
     } else {
         $associationCondition = 'associationId=' . $associationId . ' AND ' . 'associationType="' . $associationType . '"';
     }
     /* Fudge replacing Opportunity and Quote because they're stored as plural in the actions 
        table */
     $associationCondition = str_replace('Opportunity', 'opportunities', $associationCondition);
     $associationCondition = str_replace('Quote', 'quotes', $associationCondition);
     $visibilityCondition = '';
     $module = isset(Yii::app()->controller->module) ? Yii::app()->controller->module->getId() : Yii::app()->controller->getId();
     // Apply history privacy settings so that only allowed actions are viewable.
     if (!Yii::app()->user->checkAccess(ucfirst($module) . 'Admin')) {
         if (Yii::app()->settings->historyPrivacy == 'user') {
             $visibilityCondition = ' AND (assignedTo="' . Yii::app()->user->getName() . '")';
         } elseif (Yii::app()->settings->historyPrivacy == 'group') {
             $visibilityCondition = ' AND (
                     t.assignedTo IN (
                         SELECT DISTINCT b.username 
                         FROM x2_group_to_user a 
                         INNER JOIN x2_group_to_user b ON a.groupId=b.groupId 
                         WHERE a.username="' . Yii::app()->user->getName() . '") OR 
                         (t.assignedTo="' . Yii::app()->user->getName() . '"))';
         } else {
             $visibilityCondition = ' AND (visibility="1" OR assignedTo="' . Yii::app()->user->getName() . '")';
         }
     }
     $orderStr = 'IF(complete="No", GREATEST(createDate, IFNULL(dueDate,0), ' . 'IFNULL(lastUpdated,0)), GREATEST(createDate, ' . 'IFNULL(completeDate,0), IFNULL(lastUpdated,0))) DESC';
     $mainCountCmd = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions t')->where($associationCondition . $visibilityCondition . $historyCriteria[$historyType]);
     $mainCmd = Yii::app()->db->createCommand()->select('*')->from('x2_actions t')->where($associationCondition . $visibilityCondition . $historyCriteria[$historyType])->order($orderStr);
     $multiAssociationIdParams = AuxLib::bindArray($multiAssociationIds);
     $associationCondition = '((' . $associationCondition . ') OR ' . 'x2_action_to_record.recordId in ' . AuxLib::arrToStrList(array_keys($multiAssociationIdParams)) . ')';
     $associationCondition = 'x2_action_to_record.recordId in ' . AuxLib::arrToStrList(array_keys($multiAssociationIdParams));
     $joinCountCmd = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions t')->join('x2_action_to_record', 'actionId=t.id')->where($associationCondition . $visibilityCondition . $historyCriteria[$historyType] . ' AND 
             x2_action_to_record.recordType=:recordType');
     $joinCmd = Yii::app()->db->createCommand()->select('t.*')->from('x2_actions t')->join('x2_action_to_record', 'actionId=t.id')->where($associationCondition . $visibilityCondition . $historyCriteria[$historyType] . ' AND 
             x2_action_to_record.recordType=:recordType');
     $count = $mainCountCmd->union($joinCountCmd->getText())->queryScalar(array_merge(array(':recordType' => X2Model::getModelName($associationType)), $multiAssociationIdParams));
     return array('cmd' => $mainCmd->union($joinCmd->getText()), 'count' => $count, 'params' => array_merge(array(':recordType' => X2Model::getModelName($associationType)), $multiAssociationIdParams));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:60,代码来源:History.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: renderContactFields

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

示例11: deleteOldNotifications

 /**
  * Deletes duplicate notifications. Meant to be called before the creation of new notifications
  * @param string $notificationUsers assignee of the newly created notifications
  * TODO: unit test
  */
 private function deleteOldNotifications($notificationUsers)
 {
     $notifCount = (int) X2Model::model('Notification')->countByAttributes(array('modelType' => 'Actions', 'modelId' => $this->id, 'type' => 'action_reminder'));
     if ($notifCount === 0) {
         return;
     }
     $notifications = X2Model::model('Notification')->findAllByAttributes(array('modelType' => 'Actions', 'modelId' => $this->id, 'type' => 'action_reminder'));
     foreach ($notifications as $notification) {
         if ($this->isAssignedTo($notification->user, true) && ($notificationUsers == 'assigned' || $notificationUsers == 'both')) {
             $notification->delete();
         } elseif ($notification->user == Yii::app()->user->getName() && ($notificationUsers == 'me' || $notificationUsers == 'both')) {
             $notification->delete();
         }
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:20,代码来源:Actions.php

示例12: attachmentActionText

 /**
  * Generates a description message with a link and optional preview image
  * for media items.
  *
  * @param string $actionDescription
  * @param boolean $makeLink
  * @param boolean $makeImage
  * @return string
  */
 public static function attachmentActionText($actionDescription, $makeLink = false, $makeImage = false)
 {
     $data = explode(':', $actionDescription);
     $media = null;
     if (count($data) == 2 && is_numeric($data[1])) {
         // ensure data is formatted properly
         $media = X2Model::model('Media')->findByPK($data[1]);
     }
     // look for an entry in the media table
     if ($media) {
         // did we find an entry in the media table?
         if ($media->drive) {
             $str = Yii::t('media', 'Google Drive:') . ' ';
         } else {
             $str = Yii::t('media', 'File:') . ' ';
         }
         $fileExists = $media->fileExists();
         if ($fileExists == false) {
             return $str . $data[0] . ' ' . Yii::t('media', '(deleted)');
         }
         if ($makeLink) {
             $str .= $media->getMediaLink();
             if (!$media->drive) {
                 $str .= " | " . CHtml::link('[Download]', array('/media/media/download', 'id' => $media->id));
             }
         } else {
             $str .= $data[0];
         }
         if ($makeImage && $media->isImage()) {
             // to render an image, first check file extension
             $str .= $media->getImage();
         }
         return $str;
     } else {
         return $actionDescription;
     }
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:46,代码来源:Media.php

示例13: itemDisplayName

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

示例14: model

 /**
  * Returns the static model of the specified AR class.
  * @return Groups the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:8,代码来源:Groups.php

示例15: getItems

 /**
  * Get autocomplete options 
  * @param string $term
  */
 public static function getItems($term)
 {
     $model = X2Model::model(Yii::app()->controller->modelClass);
     if (isset($model)) {
         $tableName = $model->tableName();
         $sql = 'SELECT id, name as value 
              FROM ' . $tableName . ' WHERE name LIKE :qterm ORDER BY name ASC';
         $command = Yii::app()->db->createCommand($sql);
         $qterm = $term . '%';
         $command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
         $result = $command->queryAll();
         echo CJSON::encode($result);
     }
     Yii::app()->end();
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:19,代码来源:X2LinkableBehavior.php


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