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


PHP Groups::model方法代码示例

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


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

示例1: _checkintegrity

 /**
  * This function checks the LimeSurvey database for logical consistency and returns an according array
  * containing all issues in the particular tables.
  * @returns Array with all found issues.
  */
 protected function _checkintegrity()
 {
     $clang = Yii::app()->lang;
     /*** Plainly delete survey permissions if the survey or user does not exist ***/
     $users = User::model()->findAll();
     $uids = array();
     foreach ($users as $user) {
         $uids[] = $user['uid'];
     }
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('uid', $uids, 'OR');
     $surveys = Survey::model()->findAll();
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $criteria->addNotInCondition('sid', $sids, 'OR');
     Survey_permissions::model()->deleteAll($criteria);
     // Deactivate surveys that have a missing response table
     foreach ($surveys as $survey) {
         if ($survey['active'] == 'Y' && !tableExists("{{survey_{$survey['sid']}}}")) {
             Survey::model()->updateByPk($survey['sid'], array('active' => 'N'));
         }
     }
     // Fix subquestions
     fixSubquestions();
     /*** Check for active survey tables with missing survey entry and rename them ***/
     $sDBPrefix = Yii::app()->db->tablePrefix;
     $sQuery = dbSelectTablesLike('{{survey}}\\_%');
     $aResult = dbQueryOrFalse($sQuery) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         if ($sTableName == 'survey_permissions' || $sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') {
             continue;
         }
         $aTableName = explode('_', $sTableName);
         if (isset($aTableName[1]) && ctype_digit($aTableName[1])) {
             $iSurveyID = $aTableName[1];
             if (!in_array($iSurveyID, $sids)) {
                 $sDate = date('YmdHis') . rand(1, 1000);
                 $sOldTable = "survey_{$iSurveyID}";
                 $sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
                 try {
                     $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
                 } catch (CDbException $e) {
                     die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
                 }
             }
         }
     }
     /*** Check for active token tables with missing survey entry ***/
     $aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\\_%')) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         $iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1);
         if (!in_array($iSurveyID, $sids)) {
             $sDate = date('YmdHis') . rand(1, 1000);
             $sOldTable = "tokens_{$iSurveyID}";
             $sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
             try {
                 $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
             } catch (CDbException $e) {
                 die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
             }
         }
     }
     /**********************************************************************/
     /*     Check conditions                                               */
     /**********************************************************************/
     // TMSW Conditions->Relevance:  Replace this with analysis of relevance
     $conditions = Conditions::model()->findAll();
     if (Conditions::model()->hasErrors()) {
         safeDie(Conditions::model()->getError());
     }
     $okQuestion = array();
     foreach ($conditions as $condition) {
         if ($condition['cqid'] != 0) {
             // skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
             if (!array_key_exists($condition['cqid'], $okQuestion)) {
                 $iRowCount = Questions::model()->countByAttributes(array('qid' => $condition['cqid']));
                 if (Questions::model()->hasErrors()) {
                     safeDie(Questions::model()->getError());
                 }
                 if (!$iRowCount) {
                     $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
                 } else {
                     $okQuestion[$condition['cqid']] = $condition['cqid'];
                 }
             }
         }
         if ($condition['cfieldname']) {
             if (preg_match('/^\\+{0,1}[0-9]+X[0-9]+X*$/', $condition['cfieldname'])) {
                 // only if cfieldname isn't Tag such as {TOKEN:EMAIL} or any other token
                 list($surveyid, $gid, $rest) = explode('X', $condition['cfieldname']);
                 $iRowCount = count(Groups::model()->findAllByAttributes(array('gid' => $gid)));
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:checkintegrity.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new X2Leads();
     $users = User::getNames();
     foreach (Groups::model()->findAll() as $group) {
         $users[$group->id] = $group->name;
     }
     unset($users['admin']);
     unset($users['']);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['X2Leads'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['X2Leads']);
         if (isset($_POST['x2ajax'])) {
             $ajaxErrors = $this->quickCreate($model);
         } else {
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     if (isset($_POST['x2ajax'])) {
         $this->renderInlineCreateForm($model, isset($ajaxErrors) ? $ajaxErrors : false);
     } else {
         $this->render('create', array('model' => $model, 'users' => $users));
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:32,代码来源:X2LeadsController.php

示例3: getNextAssignee

 /**
  * Picks the next asignee based on the routing type
  * 
  * @return string Username that should be assigned the next lead
  */
 public function getNextAssignee()
 {
     $admin =& Yii::app()->settings;
     $type = $admin->serviceDistribution;
     if ($type == "") {
         return "Anyone";
     } elseif ($type == "evenDistro") {
         return $this->evenDistro();
     } elseif ($type == "trueRoundRobin") {
         return $this->roundRobin();
     } elseif ($type == 'singleUser') {
         $user = User::model()->findByPk($admin->srrId);
         if (isset($user)) {
             return $user->username;
         } else {
             return "Anyone";
         }
     } elseif ($type == 'singleGroup') {
         $group = Groups::model()->findByPk($admin->sgrrId);
         if (isset($group)) {
             return $group->id;
         } else {
             return "Anyone";
         }
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:31,代码来源:ServiceRoutingBehavior.php

示例4: actionProgress

 public function actionProgress($id, $trackid)
 {
     $progress = array();
     // получаем список пользователей
     // получаем задания по пользователю, сразу же с решениями
     $track = Tracks::model()->findByPk($trackid);
     $group = Groups::model()->with("Students")->findByPk($id);
     // пройдемся по всем студентам в группе
     foreach ($group->Students as $student) {
         // получим теперь таски и солюшны этого студента
         $students[$student->id] = $student;
         $tasks = Tasks::model()->with(array('Solutions' => array('on' => 'Solutions.student=' . $student->id)))->findAllByAttributes(array("track" => $trackid), array('order' => 't.order'));
         // продемся по всем задачам
         foreach ($tasks as $task) {
             if (isset($task->Solutions[0])) {
                 // если у таска есть солюшн – возьмем
                 $progress[$student->id][$task->id] = $task->Solutions[0]->status;
             } else {
                 // если нет – запишем нейтральный статус
                 $progress[$student->id][$task->id] = "undefined";
             }
         }
     }
     $this->render('progress', array("group" => $group, "track" => $track, "students" => $students, "progress" => $progress));
 }
开发者ID:Kapodastr,项目名称:grow,代码行数:25,代码来源:TracksController.php

示例5: afterDelete

 public function afterDelete()
 {
     // Roles have been updated, clear the cached roles for the corresponding
     // user (or for all group members, if a group)
     if ($this->type == 'user') {
         Roles::clearCachedUserRoles($this->userId);
     } elseif ($this->type == 'group') {
         // Clear the role cache for all users who were in the group
         $group = Groups::model()->findByPk($this->userId);
         if (!empty($group)) {
             if (count($group->users) > 0) {
                 foreach ($group->users as $user) {
                     Roles::clearCachedUserRoles($user->id);
                 }
             }
         }
     }
     parent::afterSave();
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:19,代码来源:RoleToUser.php

示例6: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $groups = array();
     foreach (Groups::model()->findAll() as $group) {
         $groups[$group->id] = CHtml::encode($group->name);
     }
     $selectedGroups = array();
     foreach (GroupToUser::model()->findAllByAttributes(array('userId' => $model->id)) as $link) {
         $selectedGroups[] = $link->groupId;
     }
     $roles = array();
     foreach (Roles::model()->findAll() as $role) {
         $roles[$role->id] = CHtml::encode($role->name);
     }
     $selectedRoles = array();
     foreach (RoleToUser::model()->findAllByAttributes(array('userId' => $model->id)) as $link) {
         $selectedRoles[] = $link->roleId;
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (!isset($model->userAlias)) {
         $model->userAlias = $model->username;
     }
     if (isset($_POST['User'])) {
         $old = $model->attributes;
         $temp = $model->password;
         $model->attributes = $_POST['User'];
         if ($model->password != "") {
             $model->password = PasswordUtil::createHash($model->password);
         } else {
             $model->password = $temp;
         }
         if (empty($model->userKey)) {
             $model->userKey = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 32)), 0, 32);
         }
         if ($model->save()) {
             $profile = $model->profile;
             if (!empty($profile)) {
                 $profile->emailAddress = $model->emailAddress;
                 $profile->fullName = $model->firstName . ' ' . $model->lastName;
                 $profile->save();
             }
             if ($old['username'] != $model->username) {
                 $fieldRecords = Fields::model()->findAllByAttributes(array('fieldName' => 'assignedTo'));
                 $modelList = array();
                 foreach ($fieldRecords as $record) {
                     $modelList[$record->modelName] = $record->linkType;
                 }
                 foreach ($modelList as $modelName => $type) {
                     if ($modelName == 'Quotes') {
                         $modelName = "Quote";
                     }
                     if ($modelName == 'Products') {
                         $modelName = 'Product';
                     }
                     if (empty($type)) {
                         $list = X2Model::model($modelName)->findAllByAttributes(array('assignedTo' => $old['username']));
                         foreach ($list as $item) {
                             $item->assignedTo = $model->username;
                             $item->save();
                         }
                     } else {
                         $list = X2Model::model($modelName)->findAllBySql("SELECT * FROM " . X2Model::model($modelName)->tableName() . " WHERE assignedTo LIKE '%" . $old['username'] . "%'");
                         foreach ($list as $item) {
                             $assignedTo = explode(", ", $item->assignedTo);
                             $key = array_search($old['username'], $assignedTo);
                             if ($key >= 0) {
                                 $assignedTo[$key] = $model->username;
                             }
                             $item->assignedTo = implode(", ", $assignedTo);
                             $item->save();
                         }
                     }
                 }
                 $profile = Profile::model()->findByAttributes(array('username' => $old['username']));
                 if (isset($profile)) {
                     $profile->username = $model->username;
                     $profile->save();
                 }
             }
             foreach (RoleToUser::model()->findAllByAttributes(array('userId' => $model->id)) as $link) {
                 $link->delete();
             }
             foreach (GroupToUser::model()->findAllByAttributes(array('userId' => $model->id)) as $link) {
                 $link->delete();
             }
             if (isset($_POST['roles'])) {
                 $roles = $_POST['roles'];
                 foreach ($roles as $role) {
                     $link = new RoleToUser();
                     $link->roleId = $role;
                     $link->type = "user";
                     $link->userId = $model->id;
                     $link->save();
//.........这里部分代码省略.........
开发者ID:dsyman2,项目名称:X2CRM,代码行数:101,代码来源:UsersController.php

示例7: deleteSurvey

 /**
  * Deletes a survey and all its data
  *
  * @access public
  * @param int $iSurveyID
  * @param bool @recursive
  * @return void
  */
 public function deleteSurvey($iSurveyID, $recursive = true)
 {
     Survey::model()->deleteByPk($iSurveyID);
     if ($recursive == true) {
         if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
         }
         if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
         }
         if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
         }
         $oResult = Questions::model()->findAllByAttributes(array('sid' => $iSurveyID));
         foreach ($oResult as $aRow) {
             Answers::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Conditions::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Question_attributes::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Defaultvalues::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
         }
         Questions::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Groups::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Surveys_languagesettings::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
         Survey_permissions::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Saved_control::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Survey_url_parameters::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
     }
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:38,代码来源:Survey.php

示例8: actionGetRole

 /**
  * Echo out a series of inputs for a role editor page.
  *
  * This method is called via AJAX from the "Edit Role" portion of the "Manage Roles"
  * page.  Upon selection of a role in the dropdown on that page, this method
  * finds all relevant information about the role and echoes it back as a form
  * to allow for editing of the role.
  */
 public function actionGetRole()
 {
     if (isset($_POST['Roles'])) {
         $id = $_POST['Roles']['name'];
         $role = Roles::model()->findByAttributes(array('name' => $id));
         if (!$role) {
             echo "";
             exit;
         }
         $id = $role->id;
         $roles = RoleToUser::model()->findAllByAttributes(array('roleId' => $id));
         $users = array();
         foreach ($roles as $link) {
             if ($link->type == 'user') {
                 $user = User::model()->findByPk($link->userId);
                 if (isset($user)) {
                     $users[] = $user->username;
                 }
             } else {
                 $group = Groups::model()->findByPk($link->userId);
                 if (isset($group)) {
                     $users[] = $group->id;
                 }
             }
             /* end x2temp */
         }
         $allUsers = User::model()->findAll('status="1"');
         $selected = array();
         $unselected = array();
         foreach ($users as $user) {
             $selected[] = $user;
         }
         foreach ($allUsers as $user) {
             $unselected[CHtml::encode($user->username)] = CHtml::encode($user->firstName . " " . $user->lastName);
         }
         /* x2temp */
         $groups = Groups::model()->findAll();
         foreach ($groups as $group) {
             $unselected[$group->id] = CHtml::encode($group->name);
         }
         /* end x2temp */
         unset($unselected['admin']);
         $sliderId = 'editTimeoutSlider';
         $textfieldId = 'editTimeout';
         if (isset($_GET['mode']) && in_array($_GET['mode'], array('edit', 'exception'))) {
             // Handle whether this was called from editRole or roleException, they
             // need different IDs to work on the same page.
             $sliderId .= "-" . $_GET['mode'];
             $textfieldId .= "-" . $_GET['mode'];
         }
         $timeoutSet = $role->timeout !== null;
         echo "\n                <div class='row' id='set-session-timeout-row'>\n                <input id='set-session-timeout' type='checkbox' class='left' " . ($timeoutSet ? 'checked="checked"' : '') . ">\n                <label>" . Yii::t('admin', 'Enable Session Timeout') . "</label>\n                </div>\n            ";
         echo "<div id='timeout-row' class='row' " . ($timeoutSet ? '' : "style='display: none;'") . ">";
         echo Yii::t('admin', 'Set role session expiration time (in minutes).');
         echo "<br />";
         $this->widget('zii.widgets.jui.CJuiSlider', array('value' => $role->timeout / 60, 'options' => array('min' => 5, 'max' => 1440, 'step' => 5, 'change' => "js:function(event,ui) {\n                                    \$('#" . $textfieldId . "').val(ui.value);\n                                    \$('#save-button').addClass('highlight');\n                                }", 'slide' => "js:function(event,ui) {\n                                    \$('#" . $textfieldId . "').val(ui.value);\n                                }"), 'htmlOptions' => array('style' => 'width:340px;margin:10px 9px;', 'id' => $sliderId)));
         echo CHtml::activeTextField($role, 'timeout', array('id' => $textfieldId, 'disabled' => $role->timeout !== null ? '' : 'disabled'));
         echo "</div>";
         Yii::app()->clientScript->registerScript('timeoutScript', "\n                \$('#set-session-timeout').change (function () {\n                    if (\$(this).is (':checked')) {\n                        \$('#timeout-row').slideDown ();\n                        \$('#" . $textfieldId . "').removeAttr ('disabled');\n                    } else {\n                        \$('#timeout-row').slideUp ();\n                        \$('#" . $textfieldId . "').attr ('disabled', 'disabled');\n                    }\n                });\n                \$('#" . $textfieldId . "').val( \$('#" . $sliderId . "').slider('value') );\n            ", CClientScript::POS_READY);
         echo "<script>";
         Yii::app()->clientScript->echoScripts();
         echo "</script>";
         echo "<div id='users'><label>Users</label>";
         echo CHtml::dropDownList('users[]', $selected, $unselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
         echo "</div>";
         $fields = Fields::model()->findAllBySql("SELECT * FROM x2_fields ORDER BY modelName ASC");
         $viewSelected = array();
         $editSelected = array();
         $fieldUnselected = array();
         $fieldPerms = RoleToPermission::model()->findAllByAttributes(array('roleId' => $role->id));
         foreach ($fieldPerms as $perm) {
             if ($perm->permission == 2) {
                 $viewSelected[] = $perm->fieldId;
                 $editSelected[] = $perm->fieldId;
             } else {
                 if ($perm->permission == 1) {
                     $viewSelected[] = $perm->fieldId;
                 }
             }
         }
         foreach ($fields as $field) {
             $fieldUnselected[$field->id] = X2Model::getModelTitle($field->modelName) . " - " . $field->attributeLabel;
         }
         echo "<br /><label>View Permissions</label>";
         echo CHtml::dropDownList('viewPermissions[]', $viewSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
         echo "<br /><label>Edit Permissions</label>";
         echo CHtml::dropDownList('editPermissions[]', $editSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
     }
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:97,代码来源:AdminController.php

示例9: update

 /**
  * Provides an interface for updating a group
  *
  * @access public
  * @param int $gid
  * @return void
  */
 public function update($gid)
 {
     $gid = (int) $gid;
     $group = Groups::model()->findByAttributes(array('gid' => $gid));
     $surveyid = $group->sid;
     if (hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
         Yii::app()->loadHelper('surveytranslator');
         $grplangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         array_push($grplangs, $baselang);
         foreach ($grplangs as $grplang) {
             if (isset($grplang) && $grplang != "") {
                 $group_name = $_POST['group_name_' . $grplang];
                 $group_description = $_POST['description_' . $grplang];
                 $group_name = html_entity_decode($group_name, ENT_QUOTES, "UTF-8");
                 $group_description = html_entity_decode($group_description, ENT_QUOTES, "UTF-8");
                 // Fix bug with FCKEditor saving strange BR types
                 $group_name = fixCKeditorText($group_name);
                 $group_description = fixCKeditorText($group_description);
                 $aData = array('group_name' => $group_name, 'description' => $group_description, 'randomization_group' => $_POST['randomization_group'], 'grelevance' => $_POST['grelevance']);
                 $condition = array('gid' => $gid, 'sid' => $surveyid, 'language' => $grplang);
                 $group = Groups::model()->findByAttributes($condition);
                 foreach ($aData as $k => $v) {
                     $group->{$k} = $v;
                 }
                 $ugresult = $group->save();
                 if ($ugresult) {
                     $groupsummary = getGroupList($gid, $surveyid);
                 }
             }
         }
         Yii::app()->session['flashmessage'] = Yii::app()->lang->gT("Question group successfully saved.");
         $this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $surveyid . '/gid/' . $gid));
     }
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:42,代码来源:questiongroup.php

示例10: actionAddContact

 public function actionAddContact($id)
 {
     $users = User::getNames();
     unset($users['admin']);
     unset($users['']);
     foreach (Groups::model()->findAll() as $group) {
         $users[$group->id] = $group->name;
     }
     $contacts = Contacts::getAllNames();
     unset($contacts['0']);
     $model = $this->loadModel($id);
     $contacts = Sales::editContactArray($contacts, $model);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Sales'])) {
         $temp = $model->associatedContacts;
         $tempArr = $model->attributes;
         $model->attributes = $_POST['Sales'];
         $arr = $_POST['Sales']['associatedContacts'];
         foreach ($arr as $contactId) {
             $rel = new Relationships();
             $rel->firstType = 'Contacts';
             $rel->firstId = $contactId;
             $rel->secondType = 'Sales';
             $rel->secondId = $model->id;
             $rel->save();
         }
         $model->associatedContacts = Sales::parseContacts($arr);
         $temp .= " " . $model->associatedContacts;
         $model->associatedContacts = $temp;
         $changes = $this->calculateChanges($tempArr, $model->attributes);
         $model = $this->updateChangelog($model, $changes);
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('addContact', array('model' => $model, 'users' => $users, 'contacts' => $contacts, 'action' => 'Add'));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:38,代码来源:DefaultController.php

示例11: translateInsertansTags

/**
* This function replaces the old insertans tags with new ones across a survey
*
* @param string $newsid  Old SID
* @param string $oldsid  New SID
* @param mixed $fieldnames Array  array('oldfieldname'=>'newfieldname')
*/
function translateInsertansTags($newsid, $oldsid, $fieldnames)
{
    uksort($fieldnames, create_function('$a,$b', 'return strlen($a) < strlen($b);'));
    Yii::app()->loadHelper('database');
    $newsid = sanitize_int($newsid);
    $oldsid = sanitize_int($oldsid);
    # translate 'surveyls_urldescription' and 'surveyls_url' INSERTANS tags in surveyls
    $sql = "SELECT surveyls_survey_id, surveyls_language, surveyls_urldescription, surveyls_url from {{surveys_languagesettings}}\n    WHERE surveyls_survey_id=" . $newsid . " AND (surveyls_urldescription LIKE '%{$oldsid}X%' OR surveyls_url LIKE '%{$oldsid}X%')";
    $result = dbExecuteAssoc($sql) or show_error("Can't read groups table in transInsertAns ");
    // Checked
    //while ($qentry = $res->FetchRow())
    foreach ($result->readAll() as $qentry) {
        $urldescription = $qentry['surveyls_urldescription'];
        $endurl = $qentry['surveyls_url'];
        $language = $qentry['surveyls_language'];
        foreach ($fieldnames as $sOldFieldname => $sNewFieldname) {
            $pattern = $sOldFieldname;
            $replacement = $sNewFieldname;
            $urldescription = preg_replace('/' . $pattern . '/', $replacement, $urldescription);
            $endurl = preg_replace('/' . $pattern . '/', $replacement, $endurl);
        }
        if (strcmp($urldescription, $qentry['surveyls_urldescription']) != 0 || strcmp($endurl, $qentry['surveyls_url']) != 0) {
            // Update Field
            $data = array('surveyls_urldescription' => $urldescription, 'surveyls_url' => $endurl);
            $where = array('surveyls_survey_id' => $newsid, 'surveyls_language' => $language);
            Surveys_languagesettings::update($data, $where);
        }
        // Enf if modified
    }
    // end while qentry
    # translate 'quotals_urldescrip' and 'quotals_url' INSERTANS tags in quota_languagesettings
    $sql = "SELECT quotals_id, quotals_urldescrip, quotals_url from {{quota_languagesettings}} qls, {{quota}} q\n    WHERE sid=" . $newsid . " AND q.id=qls.quotals_quota_id AND (quotals_urldescrip LIKE '%{$oldsid}X%' OR quotals_url LIKE '%{$oldsid}X%')";
    $result = dbExecuteAssoc($sql) or safeDie("Can't read quota table in transInsertAns");
    // Checked
    foreach ($result->readAll() as $qentry) {
        $urldescription = $qentry['quotals_urldescrip'];
        $endurl = $qentry['quotals_url'];
        foreach ($fieldnames as $sOldFieldname => $sNewFieldname) {
            $pattern = $sOldFieldname;
            $replacement = $sNewFieldname;
            $urldescription = preg_replace('/' . $pattern . '/', $replacement, $urldescription);
            $endurl = preg_replace('/' . $pattern . '/', $replacement, $endurl);
        }
        if (strcmp($urldescription, $qentry['quotals_urldescrip']) != 0 || strcmp($endurl, $qentry['quotals_url']) != 0) {
            // Update Field
            $sqlupdate = "UPDATE {{quota_languagesettings}} SET quotals_urldescrip='" . $urldescription . "', quotals_url='" . $endurl . "' WHERE quotals_id={$qentry['quotals_id']}";
            $updateres = dbExecuteAssoc($sqlupdate) or safeDie("Couldn't update INSERTANS in quota_languagesettings<br />{$sqlupdate}<br />");
            //Checked
        }
        // Enf if modified
    }
    // end while qentry
    # translate 'description' INSERTANS tags in groups
    $sql = "SELECT gid, language, group_name, description from {{groups}}\n    WHERE sid=" . $newsid . " AND description LIKE '%{$oldsid}X%' OR group_name LIKE '%{$oldsid}X%'";
    $res = dbExecuteAssoc($sql) or show_error("Can't read groups table in transInsertAns");
    // Checked
    //while ($qentry = $res->FetchRow())
    foreach ($res->readAll() as $qentry) {
        $gpname = $qentry['group_name'];
        $description = $qentry['description'];
        $gid = $qentry['gid'];
        $language = $qentry['language'];
        foreach ($fieldnames as $sOldFieldname => $sNewFieldname) {
            $pattern = $sOldFieldname;
            $replacement = $sNewFieldname;
            $gpname = preg_replace('/' . $pattern . '/', $replacement, $gpname);
            $description = preg_replace('/' . $pattern . '/', $replacement, $description);
        }
        if (strcmp($description, $qentry['description']) != 0 || strcmp($gpname, $qentry['group_name']) != 0) {
            // Update Fields
            $data = array('description' => $description, 'group_name' => $gpname);
            $where = array('gid' => $gid, 'language' => $language);
            Groups::model()->update($data, $where);
        }
        // Enf if modified
    }
    // end while qentry
    # translate 'question' and 'help' INSERTANS tags in questions
    $sql = "SELECT qid, language, question, help from {{questions}}\n    WHERE sid=" . $newsid . " AND (question LIKE '%{$oldsid}X%' OR help LIKE '%{$oldsid}X%')";
    $result = dbExecuteAssoc($sql) or die("Can't read question table in transInsertAns ");
    // Checked
    //while ($qentry = $res->FetchRow())
    $aResultData = $result->readAll();
    foreach ($aResultData as $qentry) {
        $question = $qentry['question'];
        $help = $qentry['help'];
        $qid = $qentry['qid'];
        $language = $qentry['language'];
        foreach ($fieldnames as $sOldFieldname => $sNewFieldname) {
            $pattern = $sOldFieldname;
            $replacement = $sNewFieldname;
            $question = preg_replace('/' . $pattern . '/', $replacement, $question);
            $help = preg_replace('/' . $pattern . '/', $replacement, $help);
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:common_helper.php

示例12: getUserLinks

 public static function getUserLinks($users)
 {
     if (!is_array($users)) {
         /* x2temp */
         if (is_numeric($users)) {
             $group = Groups::model()->findByPk($users);
             if (isset($group)) {
                 $link = CHtml::link($group->name, array('/groups/default/view', 'id' => $group->id));
             } else {
                 $link = "";
             }
             return $link;
         }
         /* end x2temp */
         if ($users == '' || $users == "Anyone") {
             return Yii::t('app', 'Anyone');
         }
         $users = explode(', ', $users);
     }
     $links = '';
     foreach ($users as $user) {
         if ($user == 'Anyone' || $user == 'Email') {
             $link = '';
         } else {
             if (is_numeric($user)) {
                 $group = Groups::model()->findByPk($users);
                 if (isset($group)) {
                     $link = CHtml::link($group->name, array('/groups/default/view', 'id' => $group->id));
                 } else {
                     $link = '';
                 }
                 $links .= $link . ", ";
             } else {
                 $model = CActiveRecord::model('User')->findByAttributes(array('username' => $user));
                 if (isset($model)) {
                     $link = CHtml::link($model->name, array('/profile/view', 'id' => $model->id));
                 } else {
                     $link = '';
                 }
                 $links .= $link . ', ';
             }
         }
     }
     $links = substr($links, 0, strlen($links) - 2);
     return $links;
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:46,代码来源:User.php

示例13: getAssigneeNames

 /**
  * Generates a display-friendly list of assignees
  * 
  * @param mixed $value If specified, use as the assignment instead of the
  *  current model's assignment field.
  */
 public function getAssigneeNames($value = false)
 {
     $assignment = !$value ? $this->owner->getAttribute($this->getAssignmentAttr()) : $value;
     $assignees = !is_array($assignment) ? explode(', ', $assignment) : $assignment;
     $groupIds = array_filter($assignees, 'ctype_digit');
     $userNames = array_diff($assignees, $groupIds);
     $userNameParam = AuxLib::bindArray($userNames);
     $userFullNames = !empty($userNames) ? array_map(function ($u) {
         return Formatter::fullName($u['firstName'], $u['lastName']);
     }, Yii::app()->db->createCommand()->select('firstName,lastName')->from(User::model()->tableName())->where('username IN ' . AuxLib::arrToStrList(array_keys($userNameParam)), $userNameParam)->queryAll()) : array();
     $groupIdParam = AuxLib::bindArray($groupIds);
     $groupNames = !empty($groupIds) ? Yii::app()->db->createCommand()->select('name')->from(Groups::model()->tableName())->where('id IN ' . AuxLib::arrToStrList(array_keys($groupIdParam)), $groupIdParam)->queryColumn() : array();
     return array_merge($userFullNames, $groupNames);
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:20,代码来源:X2PermissionsBehavior.php

示例14: group_export

function group_export($action, $iSurveyID, $gid)
{
    $fn = "limesurvey_group_{$gid}.lsg";
    $xml = getXMLWriter();
    header("Content-Type: text/html/force-download");
    header("Content-Disposition: attachment; filename={$fn}");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: cache");
    // HTTP/1.0
    $xml->openUri('php://output');
    $xml->setIndent(true);
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('document');
    $xml->writeElement('LimeSurveyDocType', 'Group');
    $xml->writeElement('DBVersion', getGlobalSetting("DBVersion"));
    $xml->startElement('languages');
    $lresult = Groups::model()->findAllByAttributes(array('gid' => $gid), array('select' => 'language', 'group' => 'language'));
    foreach ($lresult as $row) {
        $xml->writeElement('language', $row->language);
    }
    $xml->endElement();
    groupGetXMLStructure($xml, $gid);
    $xml->endElement();
    // close columns
    $xml->endDocument();
}
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:29,代码来源:export_helper.php

示例15: array

echo $form->labelEx($model, 'userID');
?>
		<?php 
echo CHtml::activeDropDownList($model, 'userID', CHtml::listData(Users::model()->findAll(), 'userID', 'userName'), array('empty' => 'Select User'));
?>
		<?php 
echo $form->error($model, 'userID');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'groupID');
?>
		<?php 
echo CHtml::activeDropDownList($model, 'groupID', CHtml::listData(Groups::model()->findAll(), 'groupID', 'groupName'), array('empty' => 'Select a Group'));
?>
		<?php 
echo $form->error($model, 'groupID');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'active');
?>
		<?php 
echo $form->textField($model, 'active');
?>
		<?php 
echo $form->error($model, 'active');
开发者ID:reubsc,项目名称:sds,代码行数:31,代码来源:_form.php


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