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


PHP AuxLib::arrToStrList方法代码示例

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


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

示例1: getFieldPermissions

 /**
  * Getter for {@link fieldPermissions}
  * @return type
  */
 public function getFieldPermissions()
 {
     $class = get_class($this);
     if (!isset(self::$_fieldPermissions[$class])) {
         $roles = Roles::getUserRoles(Yii::app()->getSuId());
         if (!$this->isExemptFromFieldLevelPermissions) {
             $permRecords = Yii::app()->db->createCommand()->select("f.fieldName,MAX(rtp.permission),f.readOnly")->from(RoleToPermission::model()->tableName() . ' rtp')->join(Fields::model()->tableName() . ' f', 'rtp.fieldId=f.id ' . 'AND rtp.roleId IN ' . AuxLib::arrToStrList($roles) . ' ' . 'AND f.modelName=:class', array(':class' => $class))->group('f.fieldName')->queryAll(false);
         } else {
             $permRecords = Yii::app()->db->createCommand()->select("fieldName,CAST(2 AS UNSIGNED INTEGER),readOnly")->from(Fields::model()->tableName() . ' f')->where('modelName=:class', array(':class' => $class))->queryAll(false);
         }
         $fieldPerms = array();
         foreach ($permRecords as $record) {
             // If the permissions of the user on the field are "2" (write),
             // subtract the readOnly field
             $fieldPerms[$record[0]] = $record[1] - (int) ((int) $record[1] === 2 ? $record[2] : 0);
         }
         self::$_fieldPermissions[$class] = $fieldPerms;
     }
     return self::$_fieldPermissions[$class];
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:24,代码来源:X2Model.php

示例2: getGroupmates

 /**
  * Gets a list of names of all users having a group in common with a user.
  *
  * @param integer $userId User's ID
  * @param boolean $cache Whether to cache or not
  * @return array 
  */
 public static function getGroupmates($userId, $cache = true)
 {
     if ($cache === true && ($groupmates = Yii::app()->cache->get('user_groupmates')) !== false) {
         if (isset($groupmates[$userId])) {
             return $groupmates[$userId];
         }
     } else {
         $groupmates = array();
     }
     $userGroups = self::getUserGroups($userId, $cache);
     $groupmates[$userId] = array();
     if (!empty($userGroups)) {
         $groupParam = AuxLib::bindArray($userGroups, 'gid_');
         $inGroup = AuxLib::arrToStrList(array_keys($groupParam));
         $groupmates[$userId] = Yii::app()->db->createCommand()->select('DISTINCT(gtu.username)')->from(GroupToUser::model()->tableName() . ' gtu')->join(User::model()->tableName() . ' u', 'gtu.userId=u.id AND gtu.groupId IN ' . $inGroup, $groupParam)->queryColumn();
     }
     if ($cache === true) {
         Yii::app()->cache->set('user_groupmates', $groupmates, 259200);
     }
     return $groupmates[$userId];
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:28,代码来源:Groups.php

示例3: processCriteria

 /**
  * Save associated criterion objects for a dynamic list
  *
  * Takes data from the dynamic list criteria designer form and turns them
  * into {@link X2ListCriterion} records.
  */
 public function processCriteria()
 {
     X2ListCriterion::model()->deleteAllByAttributes(array('listId' => $this->id));
     // delete old criteria
     foreach (array('attribute', 'comparison', 'value') as $property) {
         // My lazy refactor: bring properties into the current scope as
         // temporary variables with their names pluralized
         ${"{$property}s"} = $this->criteriaInput[$property];
     }
     $comparisonList = self::getComparisonList();
     $contactModel = Contacts::model();
     $fields = $contactModel->getFields(true);
     for ($i = 0; $i < count($attributes); $i++) {
         // create new criteria
         if ((array_key_exists($attributes[$i], $contactModel->attributeLabels()) || $attributes[$i] == 'tags') && array_key_exists($comparisons[$i], $comparisonList)) {
             $fieldRef = isset($fields[$attributes[$i]]) ? $fields[$attributes[$i]] : null;
             if ($fieldRef instanceof Fields && $fieldRef->type == 'link') {
                 $nameList = explode(',', $values[$i]);
                 $namesParams = AuxLib::bindArray($nameList);
                 $namesIn = AuxLib::arrToStrList(array_keys($namesParams));
                 $lookupModel = X2Model::model(ucfirst($fieldRef->linkType));
                 $lookupModels = $lookupModel->findAllBySql('SELECT * FROM `' . $lookupModel->tableName() . '` ' . 'WHERE `name` IN ' . $namesIn, $namesParams);
                 if (!empty($lookupModels)) {
                     $values[$i] = implode(',', array_map(function ($m) {
                         return $m->nameId;
                     }, $lookupModels));
                     //$lookup->nameId;
                 }
             }
             $criterion = new X2ListCriterion();
             $criterion->listId = $this->id;
             $criterion->type = 'attribute';
             $criterion->attribute = $attributes[$i];
             $criterion->comparison = $comparisons[$i];
             $criterion->value = $values[$i];
             $criterion->save();
         }
     }
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:45,代码来源:X2List.php

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

示例5: getAssignees

 /**
  * Determines all users to whom a record is assigned.
  * 
  * @param bool $getUsernamesFromGroups If true, usernames of all users in groups whose ids
  *  are in the assignedTo string will also be returned
  * @return array assignees of this action
  */
 public function getAssignees($getUsernamesFromGroups = false)
 {
     $assignment = $this->owner->getAttribute($this->getAssignmentAttr());
     $assignees = !is_array($assignment) ? explode(', ', $assignment) : $assignment;
     $assigneesNames = array();
     if ($getUsernamesFromGroups) {
         // Obtain usernames from the groups assignment table
         $groupIds = array_filter($assignees, 'ctype_digit');
         if (!empty($groupIds)) {
             $groupIdParam = AuxLib::bindArray($groupIds);
             $groupUsers = Yii::app()->db->createCommand()->select('username')->from('x2_group_to_user')->where('groupId IN ' . AuxLib::arrToStrList(array_keys($groupIdParam)), $groupIdParam)->queryColumn();
             foreach ($groupUsers as $username) {
                 $assigneesNames[] = $username;
             }
         }
     }
     foreach ($assignees as $assignee) {
         if ($assignee === 'Anyone') {
             continue;
         } else {
             if (!ctype_digit($assignee)) {
                 // Not a group ID but a username
                 if (CActiveRecord::model('Profile')->exists('username=:u', array(':u' => $assignee))) {
                     $assigneesNames[] = $assignee;
                 }
             }
         }
     }
     return array_unique($assigneesNames);
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:37,代码来源:X2PermissionsBehavior.php

示例6: getDataProvider

 /**
  * Creates a {@link CActiveDataProvider} object for search queries.
  *
  * @param string $modelClass Optional, class of {@link CActiveRecord}. If
  *  unspecified, the class of {@link staticModel} will be used.
  * @param CDbCriteria $extraCriteria Criteria to merge with the automatically
  *  created criteria.
  * @param string $combineOp How to combine the custom/extra criteria
  */
 public function getDataProvider($modelClass = null, $extraCriteria = null, $combineOp = 'AND')
 {
     // Check for model
     $class = $modelClass == null && isset($_GET['_class']) ? get_class($this->staticModel) : $modelClass;
     if (empty($class) || !class_exists($class)) {
         $this->send(500, 'Method getDataProvider called without specifying ' . 'a valid model class, in action "' . $this->action->id . '".');
     }
     $staticModel = CActiveRecord::model($class);
     $model = new $class('search');
     // Compose attributes in the query parameters for the comparison:
     $searchAttributes = array_intersect_key($_GET, $staticModel->attributes);
     // Get search option parameters
     $optionParams = array_fill_keys($this->reservedParams['search'], 0);
     $searchOptions = array_intersect_key($_GET, $optionParams);
     // Configure the CDbCriteria object
     $criteria = new CDbCriteria();
     $criteria->alias = 't';
     if ($model instanceof X2Model) {
         // Special handling of X2Model subclasses:
         if ($model->asa('permissions') && $model->asa('permissions')->enabled) {
             // Working with an X2Model instance having its permissions behavior
             // enabled. Include access/permissions criteria.
             $criteria->mergeWith($model->getAccessCriteria());
         }
         if (isset($searchOptions['_tags'])) {
             // Add tag search criteria
             $criteria->distinct = true;
             $tags = array_map(function ($t) {
                 return '#' . $t;
             }, explode(',', $_GET['_tags']));
             $tagTable = Tags::model()->tableName();
             if (empty($searchOptions['_tagOr']) || !(bool) (int) $searchOptions['_tagOr']) {
                 // Perform an "and" tag search (must have all tags)
                 $i_tag = 0;
                 $joins = array();
                 foreach ($tags as $tag) {
                     $tagParam = ":apiSearchTag{$i_tag}";
                     $classParam = ":apiTagItemClass{$i_tag}";
                     $joinAlias = "tag{$i_tag}";
                     $joins[] = "INNER JOIN `{$tagTable}` `{$joinAlias}` " . "ON `{$joinAlias}`.`type`= {$classParam} " . "AND `{$joinAlias}`.`itemId`=`{$criteria->alias}`.`id` " . "AND `{$joinAlias}`.`tag`={$tagParam}";
                     $criteria->params[$tagParam] = $tag;
                     $criteria->params[$classParam] = get_class($model);
                     $i_tag++;
                 }
                 $criteria->join .= implode(' ', $joins);
             } else {
                 // Perform an "or" tag search (could have any one of the
                 // tags in the list)
                 $tagParam = AuxLib::bindArray($tags, 'apiSearchTag');
                 $tagIn = AuxLib::arrToStrList(array_keys($tagParam));
                 $criteria->join .= "INNER JOIN `{$tagTable}` `tag`" . "ON `tag`.`type`=:apiTagItemClass " . "AND `tag`.`itemId`=`{$criteria->alias}`.`id` " . "AND `tag`.`tag` IN {$tagIn}";
                 $tagParam[":apiTagItemClass"] = get_class($model);
                 foreach ($tagParam as $param => $value) {
                     $criteria->params[$param] = $value;
                 }
             }
         }
         // Special "codes" in comparison values.
         //
         // Not intended for more advanced formulae parsing but for basic
         // stuff, i.e. dynamic points in time like "yesterday"
         $now = time();
         $yesterday = $now - 86400;
         $tomorrow = $now + 86400;
         $codes = array('date' => compact('now', 'yesterday', 'tomorrow'), 'dateTime' => compact('now', 'yesterday', 'tomorrow'));
         $fields = $model->getFields();
         foreach ($fields as $field) {
             if (isset($searchAttributes[$field->fieldName])) {
                 if (isset($codes[$field->type])) {
                     foreach ($codes[$field->type] as $name => $value) {
                         $searchAttributes[$field->fieldName] = preg_replace('/' . $name . '$/', $value, $searchAttributes[$field->fieldName]);
                     }
                 }
             }
         }
     }
     // Search options:
     //
     // Send with parameter _partial=1 to enable partial match in searches
     $partialMatch = isset($searchOptions['_partial']) ? (bool) (int) $searchOptions['_partial'] : false;
     // Send with parameter _or=1 to enable the "OR" operator in the search
     $operator = isset($searchOptions['_or']) && (bool) (int) $searchOptions['_or'] ? 'OR' : 'AND';
     // Send with parameter _escape=0 to enable searching with MySQL wildcards
     $escape = isset($searchOptions['_escape']) ? (bool) (int) $searchOptions['_escape'] : true;
     // If searching for Actions, perform additional stuff first:
     if ($class === 'Actions') {
         $this->kludgesForSearchingActions($searchAttributes, $criteria);
     }
     // Run comparisons:
     $searchCriteria = new CDbCriteria();
     foreach ($searchAttributes as $column => $value) {
//.........这里部分代码省略.........
开发者ID:tymiles003,项目名称:X2CRM,代码行数:101,代码来源:Api2Controller.php


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