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


PHP QuestionGroup::save方法代码示例

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


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

示例1: edit

 /**
  * questiongroup::edit()
  * Load editing of a question group screen.
  *
  * @access public
  * @param int $surveyid
  * @param int $gid
  * @return void
  */
 public function edit($surveyid, $gid)
 {
     $surveyid = sanitize_int($surveyid);
     $gid = sanitize_int($gid);
     $aViewUrls = $aData = array();
     if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         Yii::app()->session['FileManagerContext'] = "edit:group:{$surveyid}";
         Yii::app()->loadHelper('admin/htmleditor');
         Yii::app()->loadHelper('surveytranslator');
         $aAdditionalLanguages = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $aBaseLanguage = Survey::model()->findByPk($surveyid)->language;
         $aLanguages = array_merge(array($aBaseLanguage), $aAdditionalLanguages);
         $grplangs = array_flip($aLanguages);
         // Check out the intgrity of the language versions of this group
         $egresult = QuestionGroup::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid));
         foreach ($egresult as $esrow) {
             $esrow = $esrow->attributes;
             // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE
             if (!in_array($esrow['language'], $aLanguages)) {
                 QuestionGroup::model()->deleteAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $esrow['language']));
             } else {
                 $grplangs[$esrow['language']] = 'exists';
             }
             if ($esrow['language'] == $aBaseLanguage) {
                 $basesettings = $esrow;
             }
         }
         // Create groups in missing languages
         while (list($key, $value) = each($grplangs)) {
             if ($value != 'exists') {
                 $basesettings['language'] = $key;
                 $group = new QuestionGroup();
                 foreach ($basesettings as $k => $v) {
                     $group->{$k} = $v;
                 }
                 switchMSSQLIdentityInsert('groups', true);
                 $group->save();
                 switchMSSQLIdentityInsert('groups', false);
             }
         }
         $first = true;
         foreach ($aLanguages as $sLanguage) {
             $oResult = QuestionGroup::model()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $sLanguage));
             $aData['aGroupData'][$sLanguage] = $oResult->attributes;
             $aTabTitles[$sLanguage] = getLanguageNameFromCode($sLanguage, false);
             if ($first) {
                 $aTabTitles[$sLanguage] .= ' (' . gT("Base language") . ')';
                 $first = false;
             }
         }
         $aData['action'] = $aData['display']['menu_bars']['gid_action'] = 'editgroup';
         $aData['surveyid'] = $surveyid;
         $aData['gid'] = $gid;
         $aData['tabtitles'] = $aTabTitles;
         $aData['aBaseLanguage'] = $aBaseLanguage;
         $this->_renderWrappedTemplate('survey/QuestionGroups', 'editGroup_view', $aData);
     }
 }
开发者ID:venurasasanka,项目名称:LimeSurvey,代码行数:67,代码来源:questiongroups.php

示例2: add_group

 /**
  * RPC Routine to add an empty group with minimum details.
  * Used as a placeholder for importing questions.
  * Returns the groupid of the created group.
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iSurveyID Dd of the Survey to add the group
  * @param string $sGroupTitle Name of the group
  * @param string $sGroupDescription     Optional description of the group
  * @return array|int The id of the new group - Or status
  */
 public function add_group($sSessionKey, $iSurveyID, $sGroupTitle, $sGroupDescription = '')
 {
     if ($this->_checkSessionKey($sSessionKey)) {
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'update')) {
             $oSurvey = Survey::model()->findByPk($iSurveyID);
             if (!isset($oSurvey)) {
                 return array('status' => 'Error: Invalid survey ID');
             }
             if ($oSurvey['active'] == 'Y') {
                 return array('status' => 'Error:Survey is active and not editable');
             }
             $oGroup = new QuestionGroup();
             $oGroup->sid = $iSurveyID;
             $oGroup->group_name = $sGroupTitle;
             $oGroup->description = $sGroupDescription;
             $oGroup->group_order = getMaxGroupOrder($iSurveyID);
             $oGroup->language = Survey::model()->findByPk($iSurveyID)->language;
             if ($oGroup->save()) {
                 return (int) $oGroup->gid;
             } else {
                 return array('status' => 'Creation Failed');
             }
         } else {
             return array('status' => 'No permission');
         }
     } else {
         return array('status' => 'Invalid Session Key');
     }
 }
开发者ID:kasutori,项目名称:LimeSurvey,代码行数:41,代码来源:remotecontrol_handle.php

示例3: edit

 /**
  * questiongroup::edit()
  * Load editing of a question group screen.
  *
  * @access public
  * @param int $surveyid
  * @param int $gid
  * @return void
  */
 public function edit($surveyid, $gid)
 {
     $surveyid = $iSurveyID = sanitize_int($surveyid);
     $gid = sanitize_int($gid);
     $aViewUrls = $aData = array();
     if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
         Yii::app()->session['FileManagerContext'] = "edit:group:{$surveyid}";
         Yii::app()->loadHelper('admin/htmleditor');
         Yii::app()->loadHelper('surveytranslator');
         $aAdditionalLanguages = Survey::model()->findByPk($surveyid)->additionalLanguages;
         // TODO: This is not an array, but a string "en"
         $aBaseLanguage = Survey::model()->findByPk($surveyid)->language;
         $aLanguages = array_merge(array($aBaseLanguage), $aAdditionalLanguages);
         $grplangs = array_flip($aLanguages);
         // Check out the intgrity of the language versions of this group
         $egresult = QuestionGroup::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid));
         foreach ($egresult as $esrow) {
             $esrow = $esrow->attributes;
             // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE
             if (!in_array($esrow['language'], $aLanguages)) {
                 QuestionGroup::model()->deleteAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $esrow['language']));
             } else {
                 $grplangs[$esrow['language']] = 'exists';
             }
             if ($esrow['language'] == $aBaseLanguage) {
                 $basesettings = $esrow;
             }
         }
         // Create groups in missing languages
         while (list($key, $value) = each($grplangs)) {
             if ($value != 'exists') {
                 $basesettings['language'] = $key;
                 $group = new QuestionGroup();
                 foreach ($basesettings as $k => $v) {
                     $group->{$k} = $v;
                 }
                 switchMSSQLIdentityInsert('groups', true);
                 $group->save();
                 switchMSSQLIdentityInsert('groups', false);
             }
         }
         $first = true;
         foreach ($aLanguages as $sLanguage) {
             $oResult = $oQuestionGroup = QuestionGroup::model()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $sLanguage));
             $aData['aGroupData'][$sLanguage] = $oResult->attributes;
             $aTabTitles[$sLanguage] = getLanguageNameFromCode($sLanguage, false);
             if ($first) {
                 $aTabTitles[$sLanguage] .= ' (' . gT("Base language") . ')';
                 $first = false;
             }
         }
         $aData['oQuestionGroup'] = $oQuestionGroup;
         $aData['sidemenu']['questiongroups'] = true;
         $aData['questiongroupbar']['buttonspreview'] = true;
         $aData['questiongroupbar']['savebutton']['form'] = true;
         $aData['questiongroupbar']['saveandclosebutton']['form'] = true;
         $aData['questiongroupbar']['closebutton']['url'] = 'admin/questiongroups/sa/view/surveyid/' . $surveyid . '/gid/' . $gid;
         // Close button
         $aData['action'] = $aData['display']['menu_bars']['gid_action'] = 'editgroup';
         $aData['surveyid'] = $surveyid;
         $aData['gid'] = $gid;
         $aData['tabtitles'] = $aTabTitles;
         $aData['aBaseLanguage'] = $aBaseLanguage;
         $surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
         $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
         ///////////
         // sidemenu
         $aData['sidemenu']['state'] = false;
         $aData['sidemenu']['explorer']['state'] = true;
         $aData['sidemenu']['explorer']['gid'] = isset($gid) ? $gid : false;
         $aData['sidemenu']['explorer']['qid'] = false;
         $this->_renderWrappedTemplate('survey/QuestionGroups', 'editGroup_view', $aData);
     } else {
         Yii::app()->user->setFlash('error', gT("Access denied"));
         $this->getController()->redirect(Yii::app()->request->urlReferrer);
     }
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:86,代码来源:questiongroups.php


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