本文整理汇总了PHP中AuxLib::bindArray方法的典型用法代码示例。如果您正苦于以下问题:PHP AuxLib::bindArray方法的具体用法?PHP AuxLib::bindArray怎么用?PHP AuxLib::bindArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuxLib
的用法示例。
在下文中一共展示了AuxLib::bindArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true);
$params = array();
if (count($hiddenTags) > 0) {
$tagParams = AuxLib::bindArray($hiddenTags);
$params = array_merge($params, $tagParams);
$str1 = " AND tag NOT IN (" . implode(',', array_keys($tagParams)) . ")";
} else {
$str1 = "";
}
$myTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->where('taggedBy=:user AND tag IS NOT NULL' . $str1, array_merge($params, array(':user' => Yii::app()->user->getName())))->group('tag')->order('count DESC')->limit(20)->queryAll();
$allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL' . $str1, $params)->order('count DESC')->limit(20)->queryAll();
// $myTags=Tags::model()->findAllBySql("SELECT *, COUNT(*) as num FROM x2_tags WHERE taggedBy='".Yii::app()->user->getName()."' GROUP BY tag ORDER BY num DESC LIMIT 20");
// $allTags=Tags::model()->findAllBySql("SELECT *, COUNT(*) as num FROM x2_tags GROUP BY tag ORDER BY num DESC LIMIT 20");
$this->render('tagCloud', array('myTags' => $myTags, 'allTags' => $allTags, 'showAllUsers' => Yii::app()->params->profile->tagsShowAllUsers));
}
示例2: getEditableFieldNames
/**
* Returns an array of field names that the user has permission to edit
* @param boolean if false, get attribute labels as well as field names
* @return mixed if $suppressAttributeLabels is true, an array of field names is returned,
* otherwise an associative array is returned (fieldName => attributeLabel)
*/
public function getEditableFieldNames($suppressAttributeLabels = true)
{
$class = get_class($this);
if (!isset(self::$_editableFieldNames[$class])) {
$editableFields = array_keys(array_filter($this->fieldPermissions, function ($p) {
return $p >= 2;
}));
if (sizeof($editableFields)) {
$params = AuxLib::bindArray($editableFields);
$in = AuxLib::arrToStrList(array_keys($params));
self::$_editableFieldNames[$class] = Yii::app()->db->createCommand()->select('fieldName, attributeLabel')->from('x2_fields')->where('readOnly!=1 AND modelName="' . get_class($this) . '" ' . 'AND fieldName IN ' . $in, $params)->queryAll();
} else {
self::$_editableFieldNames[$class] = array();
}
}
$editableFieldNames = array();
if (!$suppressAttributeLabels) {
foreach (self::$_editableFieldNames[$class] as $fieldInfo) {
$editableFieldNames[$fieldInfo['fieldName']] = $fieldInfo['attributeLabel'];
}
} else {
foreach (self::$_editableFieldNames[$class] as $fieldInfo) {
$editableFieldNames[] = $fieldInfo['fieldName'];
}
}
return $editableFieldNames;
}
示例3: 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];
}
示例4: 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();
}
}
}
示例5: parseFilters
private static function parseFilters($filters, &$params)
{
unset($filters['filters']);
$visibility = $filters['visibility'];
$visibility = str_replace('Public', '1', $visibility);
$visibility = str_replace('Private', '0', $visibility);
$visibilityFilter = explode(",", $visibility);
if ($visibility != "") {
$visibilityParams = AuxLib::bindArray($visibilityFilter, 'visibility');
$params = array_merge($params, $visibilityParams);
$visibilityCondition = " AND visibility NOT IN (" . implode(',', array_keys($visibilityParams)) . ")";
} else {
$visibilityCondition = "";
$visibilityFilter = array();
}
$users = $filters['users'];
if ($users != "") {
$users = explode(",", $users);
$users[] = '';
$users[] = 'api';
$userFilter = $users;
if (sizeof($users)) {
$usersParams = AuxLib::bindArray($users, 'users');
$params = array_merge($params, $usersParams);
$userCondition = " AND (user NOT IN (" . implode(',', array_keys($usersParams)) . ")";
} else {
$userCondition = "(";
}
if (!in_array('Anyone', $users)) {
$userCondition .= " OR user IS NULL)";
} else {
$userCondition .= ")";
}
} else {
$userCondition = "";
$userFilter = array();
}
$types = $filters['types'];
if ($types != "") {
$types = explode(",", $types);
$typeFilter = $types;
$typesParams = AuxLib::bindArray($types, 'types');
$params = array_merge($params, $typesParams);
$typeCondition = " AND (type NOT IN (" . implode(',', array_keys($typesParams)) . ") OR important=1)";
} else {
$typeCondition = "";
$typeFilter = array();
}
$subtypes = $filters['subtypes'];
if (is_array($types) && $subtypes != "") {
$subtypes = explode(",", $subtypes);
$subtypeFilter = $subtypes;
if (sizeof($subtypes)) {
$subtypeParams = AuxLib::bindArray($subtypes, 'subtypes');
$params = array_merge($params, $subtypeParams);
$subtypeCondition = " AND (\n type!='feed' OR subtype NOT IN (" . implode(',', array_keys($subtypeParams)) . ") OR important=1)";
} else {
$subtypeCondition = "";
}
} else {
$subtypeCondition = "";
$subtypeFilter = array();
}
$ret = array('filters' => array('visibility' => $visibilityFilter, 'users' => $userFilter, 'types' => $typeFilter, 'subtypes' => $subtypeFilter), 'conditions' => array('visibility' => $visibilityCondition, 'users' => $userCondition, 'types' => $typeCondition, 'subtypes' => $subtypeCondition), 'params' => $params);
return $ret;
}
示例6: executeMassPermissionsInsertUpdateQuery
private function executeMassPermissionsInsertUpdateQuery($permissions)
{
$sql = "REPLACE INTO x2_role_to_permission (`roleId`, `fieldId`, `permission`) VALUES ";
$editBindParams = AuxLib::bindArray($permissions['edit'], 'edit_');
foreach (array_keys($editBindParams) as $bind) {
$sql .= "\n ({$this->id}, {$bind}, 2),";
}
$viewBindParams = AuxLib::bindArray($permissions['view'], 'view_');
foreach (array_keys($viewBindParams) as $bind) {
$sql .= "\n ({$this->id}, {$bind}, 1),";
}
$noneBindParams = AuxLib::bindArray($permissions['none'], 'none_');
foreach (array_keys($noneBindParams) as $bind) {
$sql .= "\n ({$this->id}, {$bind}, 0),";
}
$sql = substr($sql, 0, -1) . ';';
$cmd = Yii::app()->db->createCommand()->setText($sql);
$cmd->execute(array_merge($editBindParams, $viewBindParams, $noneBindParams));
}
示例7: actionSettings
/**
* Display/set user profile settings.
*/
public function actionSettings()
{
$model = $this->loadModel(Yii::app()->user->getId());
if (isset($_POST['Profile']) || isset($_POST['preferences'])) {
if (isset($_POST['Profile'])) {
$model->attributes = $_POST['Profile'];
if (isset($_POST['preferences']['loginSound'])) {
$pieces = explode(',', $_POST['preferences']['loginSound']);
$model->loginSound = $pieces[0];
unset($_POST['preferences']['loginSound']);
}
if (isset($_POST['preferences']['notificationSound'])) {
$pieces = explode(',', $_POST['preferences']['notificationSound']);
$model->notificationSound = $pieces[0];
unset($_POST['preferences']['notificationSound']);
}
$model->save();
}
if (isset($_POST['preferences']['themeName'])) {
ThemeGenerator::clearCache();
Yii::import('application.components.ThemeGenerator.LoginThemeHelper');
LoginThemeHelper::saveProfileTheme($_POST['preferences']['themeName']);
$model->theme = array_merge(array_diff_key($model->theme, array_flip(ThemeGenerator::getProfileKeys())), ThemeGenerator::loadDefault($_POST['preferences']['themeName'], false), array_diff_key($_POST['preferences'], array_flip(ThemeGenerator::getProfileKeys())));
$model->save();
}
$this->refresh();
}
$modules = Modules::model()->findAllByAttributes(array('visible' => 1));
$menuItems = array();
foreach ($modules as $module) {
if ($module->name == 'document') {
$menuItems[$module->title] = $module->title;
} else {
$menuItems[$module->name] = Yii::t('app', $module->title);
}
}
$menuItems = array('' => Yii::t('app', 'Activity Feed')) + $menuItems;
$languages = $model->getLanguageOptions();
$times = $this->getTimeZones();
$myThemeProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "((private = 1 AND uploadedBy = '" . Yii::app()->user->name . "') OR private = 0) AND associationType = 'theme'", 'order' => 'createDate DESC'), 'pagination' => false));
$myBackgroundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType = 'bg-private' AND associationId = '" . Yii::app()->user->getId() . "') OR associationType = 'bg'", 'order' => 'createDate DESC'), 'pagination' => false));
$myLoginSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='loginSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false));
$myNotificationSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='notificationSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false));
$hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true);
if (empty($hiddenTags)) {
$hiddenTags = array();
}
if (sizeof($hiddenTags)) {
$tagParams = AuxLib::bindArray($hiddenTags);
$allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL AND tag IN (' . implode(',', array_keys($tagParams)) . ')', $tagParams)->order('tag ASC')->limit(20)->queryAll();
} else {
$allTags = array();
}
$admin = Yii::app()->settings;
$this->render('settings', array('model' => $model, 'languages' => $languages, 'times' => $times, 'myThemes' => $myThemeProvider, 'myBackgrounds' => $myBackgroundProvider, 'myLoginSounds' => $myLoginSoundProvider, 'myNotificationSounds' => $myNotificationSoundProvider, 'menuItems' => $menuItems, 'allTags' => $allTags));
}
示例8: 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));
}
示例9: 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);
}
示例10: 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) {
//.........这里部分代码省略.........
示例11: actionSettings
/**
* Display/set user profile settings.
*/
public function actionSettings()
{
$model = $this->loadModel(Yii::app()->user->getId());
if (isset($_POST['Profile']) || isset($_POST['preferences'])) {
if (isset($_POST['Profile'])) {
$model->attributes = $_POST['Profile'];
if ($model->save()) {
//$this->redirect(array('view','id'=>$model->id));
}
}
if (isset($_POST['preferences'])) {
$model->theme = ThemeGenerator::generatePalette($_POST['preferences']);
if ($model->save()) {
Yii::import('application.components.ThemeGenerator.LoginThemeHelper');
LoginThemeHelper::saveProfileTheme($_POST['preferences']['themeName']);
}
}
$this->refresh();
}
$modules = Modules::model()->findAllByAttributes(array('visible' => 1));
$menuItems = array();
foreach ($modules as $module) {
if ($module->name == 'document') {
$menuItems[$module->title] = $module->title;
} else {
$menuItems[$module->name] = Yii::t('app', $module->title);
}
}
$menuItems = array('' => Yii::t('app', 'Activity Feed')) + $menuItems;
$languageDirs = scandir('./protected/messages');
// scan for installed language folders
$languages = array('en' => 'English');
foreach ($languageDirs as $code) {
// look for langauges name
$name = $this->getLanguageName($code, $languageDirs);
// in each item in $languageDirs
if ($name !== false) {
$languages[$code] = $name;
}
// add to $languages if name is found
}
$times = $this->getTimeZones();
$myThemeProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "((private = 1 AND uploadedBy = '" . Yii::app()->user->name . "') OR private = 0) AND associationType = 'theme'", 'order' => 'createDate DESC'), 'pagination' => false));
$myBackgroundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType = 'bg-private' AND associationId = '" . Yii::app()->user->getId() . "') OR associationType = 'bg'", 'order' => 'createDate DESC'), 'pagination' => false));
$myLoginSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='loginSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false));
$myNotificationSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='notificationSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false));
$hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true);
if (empty($hiddenTags)) {
$hiddenTags = array();
}
if (sizeof($hiddenTags)) {
$tagParams = AuxLib::bindArray($hiddenTags);
$allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL AND tag IN (' . implode(',', array_keys($tagParams)) . ')', $tagParams)->order('tag ASC')->limit(20)->queryAll();
} else {
$allTags = array();
}
$admin = Yii::app()->settings;
$this->render('settings', array('model' => $model, 'languages' => $languages, 'times' => $times, 'myThemes' => $myThemeProvider, 'myBackgrounds' => $myBackgroundProvider, 'myLoginSounds' => $myLoginSoundProvider, 'myNotificationSounds' => $myNotificationSoundProvider, 'menuItems' => $menuItems, 'allTags' => $allTags));
}