예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 /**
  * init to set default
  *
  */
 public function init()
 {
     $this->template = Template::templateNameFilter(Yii::app()->getConfig('defaulttemplate'));
     $validator = new LSYii_Validators();
     $this->language = $validator->languageFilter(Yii::app()->getConfig('defaultlang'));
     $this->attachEventHandler("onAfterFind", array($this, 'fixSurveyAttribute'));
 }