本文整理汇总了PHP中Survey::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Survey::model方法的具体用法?PHP Survey::model怎么用?PHP Survey::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Survey
的用法示例。
在下文中一共展示了Survey::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage($lang);
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
if ($oTemplate->cssFramework == 'bootstrap') {
// We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
// Then instead of using the composer dependency system for templates
// We can use the package dependency system
Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
App()->bootstrap->registerAllScripts();
}
$aData = array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll());
$htmlOut = $this->render('publicSurveyList', $aData, true);
$event = new PluginEvent('beforeSurveysStartpageRender', $this);
$event->set('aData', $aData);
App()->getPluginManager()->dispatchEvent($event);
if ($event->get('result')) {
$htmlFromEvent = $event->get('result');
$htmlOut = $htmlFromEvent['html'];
}
echo $htmlOut;
}
示例2: run
public function run()
{
App()->loadHelper('surveytranslator');
$aData['issuperadmin'] = false;
if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$aData['issuperadmin'] = true;
}
// We get the last survey visited by user
$setting_entry = 'last_survey_' . Yii::app()->user->getId();
$lastsurvey = getGlobalSetting($setting_entry);
$survey = Survey::model()->findByPk($lastsurvey);
if ($lastsurvey != null && $survey) {
$aData['showLastSurvey'] = true;
$iSurveyID = $lastsurvey;
$surveyinfo = $survey->surveyinfo;
$aData['surveyTitle'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['surveyUrl'] = $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}");
} else {
$aData['showLastSurvey'] = false;
}
// We get the last question visited by user
$setting_entry = 'last_question_' . Yii::app()->user->getId();
$lastquestion = getGlobalSetting($setting_entry);
// the question group of this question
$setting_entry = 'last_question_gid_' . Yii::app()->user->getId();
$lastquestiongroup = getGlobalSetting($setting_entry);
// the sid of this question : last_question_sid_1
$setting_entry = 'last_question_sid_' . Yii::app()->user->getId();
$lastquestionsid = getGlobalSetting($setting_entry);
$survey = Survey::model()->findByPk($lastquestionsid);
if ($lastquestion && $lastquestiongroup && $survey) {
$baselang = $survey->language;
$aData['showLastQuestion'] = true;
$qid = $lastquestion;
$gid = $lastquestiongroup;
$sid = $lastquestionsid;
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $sid, 'language' => $baselang));
if ($qrrow) {
$aData['last_question_name'] = $qrrow['title'];
if ($qrrow['question']) {
$aData['last_question_name'] .= ' : ' . $qrrow['question'];
}
$aData['last_question_link'] = $this->getController()->createUrl("admin/questions/sa/view/surveyid/{$sid}/gid/{$gid}/qid/{$qid}");
} else {
$aData['showLastQuestion'] = false;
}
} else {
$aData['showLastQuestion'] = false;
}
$aData['countSurveyList'] = count(getSurveyList(true));
// We get the home page display setting
$aData['bShowSurveyList'] = getGlobalSetting('show_survey_list') == "show";
$aData['bShowSurveyListSearch'] = getGlobalSetting('show_survey_list_search') == "show";
$aData['bShowLogo'] = getGlobalSetting('show_logo') == "show";
$aData['oSurveySearch'] = new Survey('search');
$aData['bShowLastSurveyAndQuestion'] = getGlobalSetting('show_last_survey_and_question') == "show";
$aData['iBoxesByRow'] = (int) getGlobalSetting('boxes_by_row');
$aData['sBoxesOffSet'] = (string) getGlobalSetting('boxes_offset');
$this->_renderWrappedTemplate('super', 'welcome', $aData);
}
示例3: actionPublicList
public function actionPublicList($sLanguage = null)
{
if (isset($sLanguage)) {
App()->setLanguage($sLanguage);
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}
示例4: index
/**
* Routes to the correct sub-action
*
* @access public
* @param int $iSurveyID
* @return void
*/
public function index($iSurveyID)
{
$iSurveyID = sanitize_int($iSurveyID);
$sAction = Yii::app()->request->getPost('action');
$languages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$surveyLanguage = Survey::model()->findByPk($iSurveyID)->language;
Yii::app()->session['FileManagerContext'] = "edit:assessments:{$iSurveyID}";
array_unshift($languages, $surveyLanguage);
// makes an array with ALL the languages supported by the survey -> $assessmentlangs
Yii::app()->setConfig("baselang", $surveyLanguage);
Yii::app()->setConfig("assessmentlangs", $languages);
if ($sAction == "assessmentadd") {
$this->_add($iSurveyID);
}
if ($sAction == "assessmentupdate") {
$this->_update($iSurveyID);
}
if ($sAction == "assessmentdelete") {
$this->_delete($iSurveyID, $_POST['id']);
}
if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'read')) {
if ($iSurveyID == '') {
show_error(gT("No SID Provided"));
die;
}
$this->_showAssessments($iSurveyID, $sAction, $surveyLanguage);
}
}
示例5: quota
/**
* Check the Expression in quota
* @param integer $iSurveyId : the survey id : can be sid/surveyid url GET parameters
* @param integer $quota : the quota id
* @param string $lang : the survey language, optional : if not set get all language of survey
*
* @author Denis Chenu
* @version 1.0
*/
public function quota($iSurveyId, $quota, $lang = null)
{
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'read')) {
throw new CHttpException(401, "401 Unauthorized");
}
$iQuotaId = $quota;
if (is_string($lang)) {
$oValidator = new LSYii_Validators();
$aLangs = array($oValidator->languageFilter($lang));
} else {
$aLangs = Survey::model()->findByPk($iSurveyId)->getAllLanguages();
}
$aExpressions = array();
$this->iSurveyId = $iSurveyId;
foreach ($aLangs as $sLang) {
$oQuotaLanguageSetting = QuotaLanguageSetting::model()->find("quotals_quota_id =:quota_id and quotals_language=:language", array(':quota_id' => $iQuotaId, ':language' => $sLang));
// We don't need to go to step since new feature #8823, maybe need to be fixed ?
if ($oQuotaLanguageSetting) {
$this->sLang = $sLang;
$aExpressions['name_' . $sLang] = array('title' => sprintf("Quota name (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_name, array(), __METHOD__));
$aExpressions['message_' . $sLang] = array('title' => sprintf("Quota message (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_message, array(), __METHOD__));
$aExpressions['url_' . $sLang] = array('title' => sprintf("URL (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_url, array(), __METHOD__));
$aExpressions['urldescrip_' . $sLang] = array('title' => sprintf("URL description (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_urldescrip, array(), __METHOD__));
}
}
$aData = array('aExpressions' => $aExpressions);
$this->getController()->layout = $this->layout;
$this->getController()->pageTitle = gt("Validate quota");
$this->getController()->render("/admin/expressions/validationList", $aData);
}
示例6: actionPublicList
public function actionPublicList($lang = null)
{
$this->sessioncontrol();
if (isset($lang)) {
App()->setLang(new Limesurvey_lang($lang));
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}
示例7: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage(sanitize_languagecode($lang));
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}
示例8: actionLocal
function actionLocal($surveyid, $token, $langcode = '')
{
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;
$iSurveyID = $surveyid;
$sToken = $token;
$sToken = sanitize_token($sToken);
if (!$iSurveyID) {
$this->redirect($this->getController()->createUrl('/'));
}
$iSurveyID = (int) $iSurveyID;
//Check that there is a SID
// Get passed language from form, so that we dont loose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
$baselang = Survey::model()->findByPk($iSurveyID)->language;
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($baselang);
} else {
$sLanguageCode = sanitize_languagecode($sLanguageCode);
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($sLanguageCode);
$baselang = $sLanguageCode;
}
Yii::app()->lang = $clang;
$thissurvey = getSurveyInfo($iSurveyID, $baselang);
if ($thissurvey == false || Yii::app()->db->schema->getTable("{{tokens_{$iSurveyID}}}") == null) {
$html = $clang->gT('This survey does not seem to exist.');
} else {
$row = Tokens_dynamic::getEmailStatus($iSurveyID, $sToken);
if ($row == false) {
$html = $clang->gT('You are not a participant in this survey.');
} else {
$usresult = $row['emailstatus'];
if ($usresult == 'OptOut') {
$usresult = Tokens_dynamic::updateEmailStatus($iSurveyID, $sToken, 'OK');
$html = $clang->gT('You have been successfully added back to this survey.');
} else {
if ($usresult == 'OK') {
$html = $clang->gT('You are already a part of this survey.');
} else {
$html = $clang->gT('You have been already removed from this survey.');
}
}
}
}
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir']) {
$thistpl = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
} else {
$thistpl = getTemplatePath($thissurvey['templatedir']);
}
$this->_renderHtml($html, $thistpl, $clang);
}
示例9: _getData
private function _getData($params)
{
if (is_numeric($params)) {
$iSurveyId = $params;
} elseif (is_array($params)) {
extract($params);
}
$aData = array();
// Set the variables in an array
$aData['surveyid'] = $aData['iSurveyId'] = (int) $iSurveyId;
if (!empty($iId)) {
$aData['iId'] = (int) $iId;
}
$aData['clang'] = $clang = $this->getController()->lang;
$aData['imageurl'] = Yii::app()->getConfig('imageurl');
$aData['action'] = Yii::app()->request->getParam('action');
$aData['all'] = Yii::app()->request->getParam('all');
$oCriteria = new CDbCriteria();
$oCriteria->select = 'sid, active';
$oCriteria->join = 'INNER JOIN {{surveys_languagesettings}} as b on (b.surveyls_survey_id=sid and b.surveyls_language=language)';
$oCriteria->condition = 'sid=:survey';
$oCriteria->params = array('survey' => $iSurveyId);
$actresult = Survey::model()->findAll($oCriteria);
if (count($actresult) > 0) {
foreach ($actresult as $actrow) {
if ($actrow['active'] == 'N') {
Yii::app()->session['flashmessage'] = $clang->gT("This survey has not been activated. There are no results to browse.");
$this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
}
} else {
Yii::app()->session['flashmessage'] = $clang->gT("Invalid survey ID");
$this->getController()->redirect($this->getController()->createUrl("admin/index"));
}
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
$aData['surveyinfo'] = getSurveyInfo($iSurveyId);
if (isset($browselang) && $browselang != '') {
Yii::app()->session['browselang'] = $browselang;
$aData['language'] = Yii::app()->session['browselang'];
} elseif (isset(Yii::app()->session['browselang'])) {
$aData['language'] = Yii::app()->session['browselang'];
$aData['languagelist'] = $languagelist = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
$aData['languagelist'][] = Survey::model()->findByPk($iSurveyId)->language;
if (!in_array($aData['language'], $languagelist)) {
$aData['language'] = Survey::model()->findByPk($iSurveyId)->language;
}
} else {
$aData['language'] = Survey::model()->findByPk($iSurveyId)->language;
}
$aData['qulanguage'] = Survey::model()->findByPk($iSurveyId)->language;
$aData['surveyoptions'] = '';
$aData['browseoutput'] = '';
return $aData;
}
示例10: _renderWrappedTemplate
/**
* Renders template(s) wrapped in header and footer
*
* @param string $sAction Current action, the folder to fetch views from
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
protected function _renderWrappedTemplate($sAction = 'assessments', $aViewUrls = array(), $aData = array())
{
$aData['sidebar']['state'] = "close";
$iSurveyID = $aData['surveyid'];
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['surveybar']['savebutton']['form'] = true;
$aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $iSurveyID;
$aData['gid'] = null;
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'assessments.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
示例11: _renderWrappedTemplate
/**
* Renders template(s) wrapped in header and footer
*
* @param string $sAction Current action, the folder to fetch views from
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
protected function _renderWrappedTemplate($sAction = 'saved', $aViewUrls = array(), $aData = array())
{
$aData['display']['menu_bars']['browse'] = gT('Browse responses');
// browse is independent of the above
$aData['surveyid'] = $iSurveyId = $aData['iSurveyId'];
$surveyinfo = Survey::model()->findByPk($iSurveyId)->surveyinfo;
$aData["surveyinfo"] = $surveyinfo;
$aData['title_bar']['title'] = gT('Browse responses') . ': ' . $surveyinfo['surveyls_title'];
$aData['menu']['close'] = true;
$aData['menu']['edition'] = false;
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
示例12: actiontokens
function actiontokens($surveyid, $token, $langcode = '')
{
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;
$iSurveyID = $surveyid;
$sToken = $token;
$sToken = sanitize_token($sToken);
if (!$iSurveyID) {
$this->redirect(array('/'));
}
$iSurveyID = (int) $iSurveyID;
//Check that there is a SID
// Get passed language from form, so that we dont loose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($sBaseLanguage);
} else {
$sLanguageCode = sanitize_languagecode($sLanguageCode);
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($sLanguageCode);
$sBaseLanguage = $sLanguageCode;
}
Yii::app()->lang = $clang;
$aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
$sMessage = $clang->gT('This survey does not seem to exist.');
} else {
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
if (!isset($oToken)) {
$sMessage = $clang->gT('You are not a participant in this survey.');
} else {
if ($oToken->emailstatus == 'OptOut') {
$oToken->emailstatus = 'OK';
$oToken->save();
$sMessage = $clang->gT('You have been successfully added back to this survey.');
} elseif ($oToken->emailstatus == 'OK') {
$sMessage = $clang->gT('You are already a part of this survey.');
} else {
$sMessage = $clang->gT('You have been already removed from this survey.');
}
}
}
//PRINT COMPLETED PAGE
if (!$aSurveyInfo['templatedir']) {
$sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
} else {
$sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
}
$this->_renderHtml($sMessage, $sTemplate, $clang, $aSurveyInfo);
}
示例13: lsdefault
/**
* Defines the customs validation rule lsdefault
*
* @param mixed $attribute
* @param mixed $params
*/
public function lsdefault($attribute, $params)
{
$oSurvey = Survey::model()->findByPk($this->surveyls_survey_id);
$sEmailFormat = $oSurvey->htmlemail == 'Y' ? 'html' : '';
$aDefaultTexts = templateDefaultTexts($this->surveyls_language, 'unescaped', $sEmailFormat);
$aDefaultTextData = array('surveyls_email_invite_subj' => $aDefaultTexts['invitation_subject'], 'surveyls_email_invite' => $aDefaultTexts['invitation'], 'surveyls_email_remind_subj' => $aDefaultTexts['reminder_subject'], 'surveyls_email_remind' => $aDefaultTexts['reminder'], 'surveyls_email_confirm_subj' => $aDefaultTexts['confirmation_subject'], 'surveyls_email_confirm' => $aDefaultTexts['confirmation'], 'surveyls_email_register_subj' => $aDefaultTexts['registration_subject'], 'surveyls_email_register' => $aDefaultTexts['registration'], 'email_admin_notification_subj' => $aDefaultTexts['admin_notification_subject'], 'email_admin_notification' => $aDefaultTexts['admin_notification'], 'email_admin_responses_subj' => $aDefaultTexts['admin_detailed_notification_subject'], 'email_admin_responses' => $aDefaultTexts['admin_detailed_notification']);
if ($sEmailFormat == "html") {
$aDefaultTextData['admin_detailed_notification'] = $aDefaultTexts['admin_detailed_notification_css'] . $aDefaultTexts['admin_detailed_notification'];
}
if (empty($this->{$attribute})) {
$this->{$attribute} = $aDefaultTextData[$attribute];
}
}
示例14: _renderWrappedTemplate
/**
* Renders template(s) wrapped in header and footer
*
* @param string $sAction Current action, the folder to fetch views from
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
protected function _renderWrappedTemplate($sAction = 'assessments', $aViewUrls = array(), $aData = array())
{
$aData['sidemenu']['state'] = false;
$iSurveyID = $aData['surveyid'];
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $iSurveyID;
// Close button
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['surveybar']['savebutton']['form'] = TRUE;
$aData['gid'] = null;
App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . 'assessments.js'));
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
示例15: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage($lang);
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
if ($oTemplate->cssFramework == 'bootstrap') {
App()->bootstrap->register();
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}