diff --git a/application/models/Survey.php b/application/models/Survey.php index 5a20c9623ae..bc177d6945f 100644 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -20,46 +20,48 @@ /** * Class Survey * - * @property integer $sid primary key + * @property integer $sid Survey ID * @property integer $owner_id - * @property string $admin - * @property string $active - * @property string $expires Expiry date - * @property string $startdate - * @property string $adminemail - * @property string $anonymized + * @property string $admin Survey Admin's full name + * @property string $active Whether survey is acive or not (Y/N) + * @property string $expires Expiry date (YYYY-MM-DD hh:mm:ss) + * @property string $startdate Survey Start date (YYYY-MM-DD hh:mm:ss) + * @property string $adminemail Survey administrator email address + * @property string $anonymized Whether survey is anonymized or not (Y/N) * @property string $faxto - * @property string $savetimings + * @property string $format A : All in one, G : Group by group, Q : question by question + * @property string $savetimings Whether survey timings are saved (Y/N) * @property string $template Template name - * @property string $language - * @property string $additional_languages - * @property string $datestamp - * @property string $usecookie - * @property string $allowsave + * @property string $language Survey base language + * @property string $additional_languages Survey additional languages delimited by space ' ' + * @property string $datestamp Whether respondents' datestamps will be saved (Y/N) + * @property string $usecookie Are cookies used to prevent repeated participation (Y/N) + * @property string $allowsave Is participant allowed save and resume later (Y/N) * @property integer $autonumber_start - * @property integer $tokenlength - * @property string $autoredirect - * @property string $allowprev - * @property string $printanswers - * @property string $ipaddr - * @property string $refurl - * @property string $datecreated - * @property string $publicstatistics - * @property string $publicgraphs - * @property string $listpublic - * @property string $sendconfirmation - * @property string $tokenanswerspersistence - * @property string $assessments + * @property integer $tokenlength Token length: MIN:5 MAX:36 + * @property string $autoredirect Automatically load URL when survey complete: (Y/N) + * @property string $allowprev Allow backwards navigation (Y/N) + * @property string $printanswers Participants may print answers: (Y/N) + * @property string $ipaddr Whether Participants IP address will be saved: (Y/N) + * @property string $refurl Save referrer URL: (Y/N) + * @property string $datecreated Date survey was created (YYYY-MM-DD hh:mm:ss) + * @property string $publicstatistics Public statistics: (Y/N) + * @property string $publicgraphs Show graphs in public statistics: (Y/N) + * @property string $listpublic List survey publicly: (Y/N) + * @property string $htmlemail Use HTML format for token emails: (Y/N) + * @property string $sendconfirmation Send confirmation emails:(Y/N) + * @property string $tokenanswerspersistence Enable token-based response persistence: (Y/N) + * @property string $assessments Enable assessment mode: (Y/N) * @property string $usecaptcha * @property string $usetokens - * @property string $bounce_email + * @property string $bounce_email Bounce email address * @property string $attributedescriptions - * @property string $emailresponseto - * @property integer $emailnotificationto - * @property string $showxquestions - * @property string $showgroupinfo - * @property string $shownoanswer - * @property string $showqnumcode + * @property string $emailresponseto e-mail address to send detailed admin notification email to + * @property integer $emailnotificationto Email address to send basic admin notification email to + * @property string $showxquestions Show "There are X questions in this survey": (Y/N) + * @property string $showgroupinfo Show group name and/or group description: (Y/N) + * @property string $shownoanswer Show "No answer": (Y/N) + * @property string $showqnumcode Show question number and/or code: (Y/N) * @property integer $bouncetime * @property string $bounceprocessing * @property string $bounceaccounttype @@ -67,14 +69,14 @@ * @property string $bounceaccountpass * @property string $bounceaccountencryption * @property string $bounceaccountuser - * @property string $showwelcome - * @property string $showprogress - * @property integer $questionindex - * @property integer $navigationdelay - * @property string $nokeyboard - * @property string $alloweditaftercompletion - * @property string $googleanalyticsstyle - * @property string $googleanalyticsapikey + * @property string $showwelcome Show welcome screen: (Y/N) + * @property string $showprogress how progress bar: (Y/N) + * @property integer $questionindex Show question index / allow jumping (0: diabled; 1: Incremental; 2: Full) + * @property integer $navigationdelay Navigation delay (seconds) + * @property string $nokeyboard Show on-screen keyboard: (Y/N) + * @property string $alloweditaftercompletion Allow multiple responses or update responses with one token: (Y/N) + * @property string $googleanalyticsstyle Google Analytics style: (0: off; 1:Default; 2:Survey-SID/Group) + * @property string $googleanalyticsapikey Google Analytics Tracking ID * * @property Permission[] $permissions * @property SurveyLanguageSetting[] $languagesettings @@ -104,12 +106,7 @@ class Survey extends LSActiveRecord */ protected $findByPkCache = array(); - /** @var string A : All in one, G : Group by group, Q : question by question */ - public $format = 'G'; - /** - * @property string $htmlemail Y mean all email related to this survey use HTML format - */ - public $htmlemail='Y'; + // TODO unused?? /** @var null $full_answers_account */ @@ -134,6 +131,12 @@ class Survey extends LSActiveRecord public function init() { /** @inheritdoc */ + + // Set the default values + $this->htmlemail = 'Y'; + $this->format = 'G'; + + $this->template = Template::templateNameFilter(Yii::app()->getConfig('defaulttemplate')); $validator= new LSYii_Validators; $this->language = $validator->languageFilter(Yii::app()->getConfig('defaultlang')); @@ -195,9 +198,9 @@ public function primaryKey() } /** - * @inheritdoc - * @return Survey - */ + * @inheritdoc + * @return Survey + */ public static function model($class = __CLASS__) { return parent::model($class); @@ -226,7 +229,7 @@ public function scopes() 'open' => array('condition' => '(startdate <= :now1 OR startdate IS NULL) AND (expires >= :now2 OR expires IS NULL)', 'params' => array( ':now1' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust")), ':now2' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust")) - ) + ) ), 'public' => array('condition' => "listpublic = 'Y'"), 'registration' => array('condition' => "allowregister = 'Y' AND startdate > :now3 AND (expires < :now4 OR expires IS NULL)", 'params' => array( @@ -301,10 +304,10 @@ public function rules() /** - * fixSurveyAttribute to fix and/or add some survey attribute - * - Fix template name to be sure template exist + * fixSurveyAttribute to fix and/or add some survey attribute + * - Fix template name to be sure template exist * //FIXME $event input parameter is overridden always remove from implementations - */ + */ public function fixSurveyAttribute($event) { $event = new PluginEvent('afterFindSurvey'); @@ -344,14 +347,14 @@ public function filterTemplateSave($sTemplateName) } /** - * permission scope for this model - * Actually only test if user have minimal access to survey (read) - * @access public - * @param int $loginID - * @return CActiveRecord - * - * TODO: replace this by a correct relation - */ + * permission scope for this model + * Actually only test if user have minimal access to survey (read) + * @access public + * @param int $loginID + * @return CActiveRecord + * + * TODO: replace this by a correct relation + */ public function permission($loginID) { $loginID = (int) $loginID; @@ -372,11 +375,11 @@ public function permission($loginID) /** - * Returns additional languages formatted into a string - * - * @access public - * @return array - */ + * Returns additional languages formatted into a string + * + * @access public + * @return array + */ public function getAdditionalLanguages() { $sLanguages = trim($this->additional_languages); @@ -387,11 +390,11 @@ public function getAdditionalLanguages() } /** - * Returns all languages array - * - * @access public - * @return array - */ + * Returns all languages array + * + * @access public + * @return array + */ public function getAllLanguages() { $sLanguages = self::getAdditionalLanguages(); @@ -400,11 +403,11 @@ public function getAllLanguages() } /** - * Returns the additional token attributes - * - * @access public - * @return array - */ + * Returns the additional token attributes + * + * @access public + * @return array + */ public function getTokenAttributes() { $attdescriptiondata = decodeTokenAttributes($this->attributedescriptions); @@ -431,10 +434,10 @@ public function getTokenAttributes() $fieldname = substr($attdescription, 0, strpos($attdescription, '=')); $desc = substr($attdescription, strpos($attdescription, '=') + 1); $fields[$fieldname] = array( - 'description' => $desc, - 'mandatory' => 'N', - 'show_register' => 'N', - 'cpdbmap' =>'' + 'description' => $desc, + 'mandatory' => 'N', + 'show_register' => 'N', + 'cpdbmap' =>'' ); $languagesettings[$fieldname] = $desc; } @@ -449,12 +452,12 @@ public function getTokenAttributes() foreach ($attdescriptiondata as $sKey=>$aValues) { if (!is_array($aValues)) $aValues=array(); if(preg_match("/^attribute_[0-9]{1,}$/",$sKey)) { - $aCompleteData[$sKey]= array_merge(array( - 'description' => '', - 'mandatory' => 'N', - 'show_register' => 'N', - 'cpdbmap' =>'' - ),$aValues); + $aCompleteData[$sKey]= array_merge(array( + 'description' => '', + 'mandatory' => 'N', + 'show_register' => 'N', + 'cpdbmap' =>'' + ),$aValues); } } return $aCompleteData; @@ -499,7 +502,7 @@ public function getHasTokens() } } - /** + /** * Returns the value for the SurveyEdit GoogleAnalytics API-Key UseGlobal Setting * @return string */ @@ -520,13 +523,13 @@ public function setGoogleanalyticsapikeysetting($value){ if($value == "G") { $this->googleanalyticsapikey = "9999useGlobal9999"; } else if($value == "N") { - $this->googleanalyticsapikey = ""; + $this->googleanalyticsapikey = ""; } } - /** + /** * Returns the value for the SurveyEdit GoogleAnalytics API-Key UseGlobal Setting - * @return string + * @return string */ public function getGoogleanalyticsapikey(){ if($this->googleanalyticsapikey === "9999useGlobal9999") { @@ -599,11 +602,11 @@ public function getSurveyMenus(){ } /** - * Creates a new survey - does some basic checks of the suppplied data - * - * @param array $aData Array with fieldname=>fieldcontents data - * @return integer The new survey id - */ + * Creates a new survey - does some basic checks of the suppplied data + * + * @param array $aData Array with fieldname=>fieldcontents data + * @return integer The new survey id + */ public function insertNewSurvey($aData) { do { @@ -634,13 +637,13 @@ public function insertNewSurvey($aData) } /** - * Deletes a survey and all its data - * - * @access public - * @param int $iSurveyID - * @param bool @recursive - * @return boolean - */ + * Deletes a survey and all its data + * + * @access public + * @param int $iSurveyID + * @param bool @recursive + * @return boolean + */ public function deleteSurvey($iSurveyID, $recursive=true) { @@ -771,9 +774,9 @@ public function getSurveyinfo() 'condition' => 'surveyls_language = language' ) ))->find( - 'sid = :surveyid', - array(':surveyid' => $iSurveyID) - ); //$sumquery1, 1) ; //Checked + 'sid = :surveyid', + array(':surveyid' => $iSurveyID) + ); //$sumquery1, 1) ; //Checked if (is_null($sumresult1)) { Yii::app()->session['flashmessage'] = gT("Invalid survey ID"); @@ -923,7 +926,7 @@ public function getRunning() $sIconRunning = ''.sprintf(gT('End: %s'),$sStop).''; $sIconExpired = ''.sprintf(gT('Expired: %s'),$sStop).''; $sIconFuture = ''.sprintf(gT('Start: %s'),$sStart).''; - + // Icon parsing if ( $bExpired || $bWillRun ) { // Expire prior to will start @@ -1093,34 +1096,34 @@ public function search() $sort = new CSort(); $sort->attributes = array( - 'survey_id'=>array( - 'asc'=>'t.sid asc', - 'desc'=>'t.sid desc', - ), - 'title'=>array( - 'asc'=>'correct_relation_defaultlanguage.surveyls_title asc', - 'desc'=>'correct_relation_defaultlanguage.surveyls_title desc', - ), - - 'creation_date'=>array( - 'asc'=>'t.datecreated asc', - 'desc'=>'t.datecreated desc', - ), - - 'owner'=>array( - 'asc'=>'owner.users_name asc', - 'desc'=>'owner.users_name desc', - ), - - 'anonymized_responses'=>array( - 'asc'=>'t.anonymized asc', - 'desc'=>'t.anonymized desc', - ), - - 'running'=>array( - 'asc'=>'t.active asc, t.expires asc', - 'desc'=>'t.active desc, t.expires desc', - ), + 'survey_id'=>array( + 'asc'=>'t.sid asc', + 'desc'=>'t.sid desc', + ), + 'title'=>array( + 'asc'=>'correct_relation_defaultlanguage.surveyls_title asc', + 'desc'=>'correct_relation_defaultlanguage.surveyls_title desc', + ), + + 'creation_date'=>array( + 'asc'=>'t.datecreated asc', + 'desc'=>'t.datecreated desc', + ), + + 'owner'=>array( + 'asc'=>'owner.users_name asc', + 'desc'=>'owner.users_name desc', + ), + + 'anonymized_responses'=>array( + 'asc'=>'t.anonymized asc', + 'desc'=>'t.anonymized desc', + ), + + 'running'=>array( + 'asc'=>'t.active asc, t.expires asc', + 'desc'=>'t.active desc, t.expires desc', + ), ); $sort->defaultOrder = array('creation_date' => CSort::SORT_DESC); @@ -1242,10 +1245,10 @@ public static function transcribeCaptchaOptions() { /** - * Method to make an approximation on how long a survey will last - * Approx is 3 questions each minute. - * @return double - */ + * Method to make an approximation on how long a survey will last + * Approx is 3 questions each minute. + * @return double + */ public function calculateEstimatedTime () { //@TODO make the time_per_question variable user configureable