/application/helpers/common_helper.php
PHP | 7805 lines | 5987 code | 653 blank | 1165 comment | 802 complexity | 2fde1a8307d9f2f0ae23a5fd34b74f49 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause, GPL-3.0, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- /*
- * LimeSurvey
- * Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
- * All rights reserved.
- * License: GNU/GPL License v2 or later, see LICENSE.php
- * LimeSurvey is free software. This version may have been modified pursuant
- * to the GNU General Public License, and as distributed it includes or
- * is derivative of works licensed under the GNU General Public License or
- * other free or open source software licenses.
- * See COPYRIGHT.php for copyright notices and details.
- */
- Yii::import('application.helpers.sanitize_helper', true);
- /**
- * Simple function to sort the permissions by title
- *
- * @param mixed $aPermissionA Permission A to compare
- * @param mixed $aPermissionB Permission B to compare
- */
- function comparePermission($aPermissionA,$aPermissionB)
- {
- if($aPermissionA['title'] >$aPermissionB['title']) {
- return 1;
- }
- else {
- return -1;
- }
- }
- /**
- * getQuestionTypeList() Returns list of question types available in LimeSurvey. Edit this if you are adding a new
- * question type
- *
- * @param string $SelectedCode Value of the Question Type (defaults to "T")
- * @param string $ReturnType Type of output from this function (defaults to selector)
- *
- * @return depending on $ReturnType param, returns a straight "array" of question types, or an <option></option> list
- *
- * Explanation of questiontype array:
- *
- * description : Question description
- * subquestions : 0= Does not support subquestions x=Number of subquestion scales
- * answerscales : 0= Does not need answers x=Number of answer scales (usually 1, but e.g. for dual scale question set to 2)
- * assessable : 0=Does not support assessment values when editing answerd 1=Support assessment values
- */
- function getQuestionTypeList($SelectedCode = "T", $ReturnType = "selector")
- {
- $publicurl = Yii::app()->getConfig('publicurl');
- $clang = Yii::app()->lang;
- $group['Arrays'] = $clang->gT('Arrays');
- $group['MaskQuestions'] = $clang->gT("Mask questions");
- $group['SinChoiceQues'] = $clang->gT("Single choice questions");
- $group['MulChoiceQues'] = $clang->gT("Multiple choice questions");
- $group['TextQuestions'] = $clang->gT("Text questions");
- $qtypes = array(
- "1" => array('description' => $clang->gT("Array dual scale"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'assessable' => 1,
- 'hasdefaultvalues' => 0,
- 'answerscales' => 2),
- "5" => array('description' => $clang->gT("5 Point Choice"),
- 'group' => $group['SinChoiceQues'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "A" => array('description' => $clang->gT("Array (5 Point Choice)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 0),
- "B" => array('description' => $clang->gT("Array (10 Point Choice)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 0),
- "C" => array('description' => $clang->gT("Array (Yes/No/Uncertain)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 0),
- "D" => array('description' => $clang->gT("Date/Time"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "E" => array('description' => $clang->gT("Array (Increase/Same/Decrease)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 0),
- "F" => array('description' => $clang->gT("Array"),
- 'group' => $group['Arrays'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 1),
- "G" => array('description' => $clang->gT("Gender"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "H" => array('description' => $clang->gT("Array by column"),
- 'group' => $group['Arrays'],
- 'hasdefaultvalues' => 0,
- 'subquestions' => 1,
- 'assessable' => 1,
- 'answerscales' => 1),
- "I" => array('description' => $clang->gT("Language Switch"),
- 'group' => $group['MaskQuestions'],
- 'hasdefaultvalues' => 0,
- 'subquestions' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "K" => array('description' => $clang->gT("Multiple Numerical Input"),
- 'group' => $group['MaskQuestions'],
- 'hasdefaultvalues' => 1,
- 'subquestions' => 1,
- 'assessable' => 1,
- 'answerscales' => 0),
- "L" => array('description' => $clang->gT("List (Radio)"),
- 'group' => $group['SinChoiceQues'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 1,
- 'answerscales' => 1),
- "M" => array('description' => $clang->gT("Multiple choice"),
- 'group' => $group['MulChoiceQues'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 1,
- 'assessable' => 1,
- 'answerscales' => 0),
- "N" => array('description' => $clang->gT("Numerical Input"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "O" => array('description' => $clang->gT("List with comment"),
- 'group' => $group['SinChoiceQues'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 1,
- 'answerscales' => 1),
- "P" => array('description' => $clang->gT("Multiple choice with comments"),
- 'group' => $group['MulChoiceQues'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 1,
- 'assessable' => 1,
- 'answerscales' => 0),
- "Q" => array('description' => $clang->gT("Multiple Short Text"),
- 'group' => $group['TextQuestions'],
- 'subquestions' => 1,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "R" => array('description' => $clang->gT("Ranking"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 1),
- "S" => array('description' => $clang->gT("Short Free Text"),
- 'group' => $group['TextQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "T" => array('description' => $clang->gT("Long Free Text"),
- 'group' => $group['TextQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "U" => array('description' => $clang->gT("Huge Free Text"),
- 'group' => $group['TextQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 0,
- 'answerscales' => 0),
- "X" => array('description' => $clang->gT("Text display"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "Y" => array('description' => $clang->gT("Yes/No"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "!" => array('description' => $clang->gT("List (Dropdown)"),
- 'group' => $group['SinChoiceQues'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 1,
- 'assessable' => 1,
- 'answerscales' => 1),
- ":" => array('description' => $clang->gT("Array (Numbers)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 2,
- 'hasdefaultvalues' => 0,
- 'assessable' => 1,
- 'answerscales' => 0),
- ";" => array('description' => $clang->gT("Array (Texts)"),
- 'group' => $group['Arrays'],
- 'subquestions' => 2,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "|" => array('description' => $clang->gT("File upload"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- "*" => array('description' => $clang->gT("Equation"),
- 'group' => $group['MaskQuestions'],
- 'subquestions' => 0,
- 'hasdefaultvalues' => 0,
- 'assessable' => 0,
- 'answerscales' => 0),
- );
- asort($qtypes);
- if ($ReturnType == "array")
- return $qtypes;
- if ($ReturnType == "group")
- {
- foreach ($qtypes as $qkey => $qtype)
- {
- $newqType[$qtype['group']][$qkey] = $qtype;
- }
- $qtypeselecter = "";
- foreach ($newqType as $group => $members)
- {
- $qtypeselecter .= '<optgroup label="' . $group . '">';
- foreach ($members as $TypeCode => $TypeProperties)
- {
- $qtypeselecter .= "<option value='$TypeCode'";
- if ($SelectedCode == $TypeCode)
- {
- $qtypeselecter .= " selected='selected'";
- }
- $qtypeselecter .= ">{$TypeProperties['description']}</option>\n";
- }
- $qtypeselecter .= '</optgroup>';
- }
- return $qtypeselecter;
- };
- $qtypeselecter = "";
- foreach ($qtypes as $TypeCode => $TypeProperties)
- {
- $qtypeselecter .= "<option value='$TypeCode'";
- if ($SelectedCode == $TypeCode)
- {
- $qtypeselecter .= " selected='selected'";
- }
- $qtypeselecter .= ">{$TypeProperties['description']}</option>\n";
- }
- return $qtypeselecter;
- }
- /**
- * isStandardTemplate returns true if a template is a standard template
- * This function does not check if a template actually exists
- *
- * @param mixed $sTemplateName template name to look for
- * @return bool True if standard template, otherwise false
- */
- function isStandardTemplate($sTemplateName)
- {
- return in_array($sTemplateName,array('basic',
- 'bluengrey',
- 'business_grey',
- 'citronade',
- 'clear_logo',
- 'default',
- 'eirenicon',
- 'limespired',
- 'mint_idea',
- 'sherpa',
- 'vallendar'));
- }
- /**
- * getSurveyList() Queries the database (survey table) for a list of existing surveys
- *
- * @param boolean $returnarray if set to true an array instead of an HTML option list is given back
- * @return string This string is returned containing <option></option> formatted list of existing surveys
- *
- */
- function getSurveyList($returnarray=false, $surveyid=false)
- {
- static $cached = null;
- $timeadjust = getGlobalSetting('timeadjust');
- $clang = new Limesurvey_lang(Yii::app()->session['adminlang']);
- if(is_null($cached)) {
- if (!hasGlobalPermission('USER_RIGHT_SUPERADMIN'))
- $surveyidresult = Survey::model()->permission(Yii::app()->user->getId())->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findAll();
- else
- $surveyidresult = Survey::model()->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findAll();
- $surveynames = array();
- foreach ($surveyidresult as $result)
- {
- $surveynames[] = array_merge($result->attributes, $result->languagesettings[0]->attributes);
- }
- $cached = $surveynames;
- } else {
- $surveynames = $cached;
- }
- $surveyselecter = "";
- if ($returnarray===true) return $surveynames;
- $activesurveys='';
- $inactivesurveys='';
- $expiredsurveys='';
- if ($surveynames)
- {
- foreach($surveynames as $sv)
- {
- $surveylstitle=flattenText($sv['surveyls_title']);
- if (strlen($surveylstitle)>45)
- {
- $surveylstitle = htmlspecialchars(mb_strcut(html_entity_decode($surveylstitle,ENT_QUOTES,'UTF-8'), 0, 45, 'UTF-8'))."...";
- }
- if($sv['active']!='Y')
- {
- $inactivesurveys .= "<option ";
- if(Yii::app()->user->getId() == $sv['owner_id'])
- {
- $inactivesurveys .= " style=\"font-weight: bold;\"";
- }
- if ($sv['sid'] == $surveyid)
- {
- $inactivesurveys .= " selected='selected'"; $svexist = 1;
- }
- $inactivesurveys .=" value='{$sv['sid']}'>{$surveylstitle}</option>\n";
- } elseif($sv['expires']!='' && $sv['expires'] < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust))
- {
- $expiredsurveys .="<option ";
- if (Yii::app()->user->getId() == $sv['owner_id'])
- {
- $expiredsurveys .= " style=\"font-weight: bold;\"";
- }
- if ($sv['sid'] == $surveyid)
- {
- $expiredsurveys .= " selected='selected'"; $svexist = 1;
- }
- $expiredsurveys .=" value='{$sv['sid']}'>{$surveylstitle}</option>\n";
- } else
- {
- $activesurveys .= "<option ";
- if(Yii::app()->user->getId() == $sv['owner_id'])
- {
- $activesurveys .= " style=\"font-weight: bold;\"";
- }
- if ($sv['sid'] == $surveyid)
- {
- $activesurveys .= " selected='selected'"; $svexist = 1;
- }
- $activesurveys .=" value='{$sv['sid']}'>{$surveylstitle}</option>\n";
- }
- } // End Foreach
- }
-
- //Only show each activesurvey group if there are some
- if ($activesurveys!='')
- {
- $surveyselecter .= "<optgroup label='".$clang->gT("Active")."' class='activesurveyselect'>\n";
- $surveyselecter .= $activesurveys . "</optgroup>";
- }
- if ($expiredsurveys!='')
- {
- $surveyselecter .= "<optgroup label='".$clang->gT("Expired")."' class='expiredsurveyselect'>\n";
- $surveyselecter .= $expiredsurveys . "</optgroup>";
- }
- if ($inactivesurveys!='')
- {
- $surveyselecter .= "<optgroup label='".$clang->gT("Inactive")."' class='inactivesurveyselect'>\n";
- $surveyselecter .= $inactivesurveys . "</optgroup>";
- }
- if (!isset($svexist))
- {
- $surveyselecter = "<option selected='selected' value=''>".$clang->gT("Please choose...")."</option>\n".$surveyselecter;
- } else
- {
- $surveyselecter = "<option value=''>".$clang->gT("None")."</option>\n".$surveyselecter;
- }
- return $surveyselecter;
- }
- /**
- * Returns true if a user has permissions in the particular survey
- *
- * @param $iSID The survey ID
- * @param $sPermission
- * @param $sCRUD
- * @param $iUID User ID - if not given the one of the current user is used
- * @return bool
- */
- function hasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null)
- {
- if (!in_array($sCRUD,array('create','read','update','delete','import','export'))) return false;
- $sCRUD=$sCRUD.'_p';
- $thissurvey=getSurveyInfo($iSID);
- if (!$thissurvey) return false;
- $aSurveyPermissionCache = Yii::app()->getConfig("aSurveyPermissionCache");
- if (is_null($iUID))
- {
- if (!Yii::app()->user->getIsGuest()) $iUID = Yii::app()->session['loginID'];
- else return false;
- // Some user have acces to whole survey settings
- if (Yii::app()->session['USER_RIGHT_SUPERADMIN']==1) return true;
- if ($thissurvey && $iUID==$thissurvey['owner_id']) return true;
- }
- if (!isset($aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD]))
- {
- $query = Survey_permissions::model()->findByAttributes(array("sid"=> $iSID,"uid"=> $iUID,"permission"=>$sPermission));
- $bPermission = is_null($query) ? array() : $query->attributes;
- if (!isset($bPermission[$sCRUD]) || $bPermission[$sCRUD]==0)
- {
- $bPermission=false;
- }
- else
- {
- $bPermission=true;
- }
- $aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD]=$bPermission;
- }
- Yii::app()->setConfig("aSurveyPermissionCache", $aSurveyPermissionCache);
- return $aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD];
- }
- /**
- * Returns true if a user has global permission for a certain action. Available permissions are
- *
- * USER_RIGHT_CREATE_SURVEY
- * USER_RIGHT_CONFIGURATOR
- * USER_RIGHT_CREATE_USER
- * USER_RIGHT_DELETE_USER
- * USER_RIGHT_SUPERADMIN
- * USER_RIGHT_MANAGE_TEMPLATE
- * USER_RIGHT_MANAGE_LABEL
- *
- * @param $sPermission
- * @return bool
- */
- function hasGlobalPermission($sPermission)
- {
- if (!Yii::app()->user->getIsGuest()) $iUID = !Yii::app()->user->getId();
- else return false;
- if (Yii::app()->session['USER_RIGHT_SUPERADMIN']==1) return true; //Superadmin has access to all
- if (Yii::app()->session[$sPermission]==1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function getTemplateList()
- {
- $usertemplaterootdir=Yii::app()->getConfig("usertemplaterootdir");
- $standardtemplaterootdir=Yii::app()->getConfig("standardtemplaterootdir");
- if (!$usertemplaterootdir) {die("getTemplateList() no template directory");}
- if ($handle = opendir($standardtemplaterootdir))
- {
- while (false !== ($file = readdir($handle)))
- {
- if (!is_file("$standardtemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn" && isStandardTemplate($file))
- {
- $list_of_files[$file] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$file;
- }
- }
- closedir($handle);
- }
- if ($handle = opendir($usertemplaterootdir))
- {
- while (false !== ($file = readdir($handle)))
- {
- if (!is_file("$usertemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn")
- {
- $list_of_files[$file] = $usertemplaterootdir.DIRECTORY_SEPARATOR.$file;
- }
- }
- closedir($handle);
- }
- ksort($list_of_files);
- return $list_of_files;
- }
- function getAdminThemeList()
- {
- // $usertemplaterootdir=Yii::app()->getConfig("usertemplaterootdir");
- $standardtemplaterootdir=Yii::app()->getConfig("styledir");
- // if (!$usertemplaterootdir) {die("getTemplateList() no template directory");}
- if ($handle = opendir($standardtemplaterootdir))
- {
- while (false !== ($file = readdir($handle)))
- {
- if (!is_file("$standardtemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn")
- {
- $list_of_files[$file] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$file;
- }
- }
- closedir($handle);
- }
- /* if ($handle = opendir($usertemplaterootdir))
- {
- while (false !== ($file = readdir($handle)))
- {
- if (!is_file("$usertemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn")
- {
- $list_of_files[$file] = $usertemplaterootdir.DIRECTORY_SEPARATOR.$file;
- }
- }
- closedir($handle);
- } */
- ksort($list_of_files);
- return $list_of_files;
- }
- /**
- * getQuestions() queries the database for an list of all questions matching the current survey and group id
- *
- * @return This string is returned containing <option></option> formatted list of questions in the current survey and group
- */
- function getQuestions($surveyid,$gid,$selectedqid)
- {
- $clang = Yii::app()->lang;
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $qrows = Questions::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $s_lang, 'parent_qid' => 0),array('order'=>'question_order'));
- if (!isset($sQuestionselecter)) {$sQuestionselecter="";}
- foreach ($qrows as $qrow)
- {
- $qrow = $qrow->attributes;
- $qrow['title'] = strip_tags($qrow['title']);
- $link = Yii::app()->getController()->createUrl("/admin/survey/sa/view/surveyid/".$surveyid."/gid/".$gid."/qid/".$qrow['qid']);
- $sQuestionselecter .= "<option value='{$link}'";
- if ($selectedqid == $qrow['qid'])
- {
- $sQuestionselecter .= " selected='selected'";
- $qexists=true;
- }
- $sQuestionselecter .=">{$qrow['title']}:";
- $sQuestionselecter .= " ";
- $question=flattenText($qrow['question']);
- if (strlen($question)<35)
- {
- $sQuestionselecter .= $question;
- }
- else
- {
- $sQuestionselecter .= htmlspecialchars(mb_strcut(html_entity_decode($question,ENT_QUOTES,'UTF-8'), 0, 35, 'UTF-8'))."...";
- }
- $sQuestionselecter .= "</option>\n";
- }
- if (!isset($qexists))
- {
- $sQuestionselecter = "<option selected='selected'>".$clang->gT("Please choose...")."</option>\n".$sQuestionselecter;
- }
- else
- {
- $link = Yii::app()->getController()->createUrl("/admin/survey/sa/view/surveyid/".$surveyid."/gid/".$gid);
- $sQuestionselecter = "<option value='{$link}'>".$clang->gT("None")."</option>\n".$sQuestionselecter;
- }
- return $sQuestionselecter;
- }
- /**
- * getGidPrevious() returns the Gid of the group prior to the current active group
- *
- * @param string $surveyid
- * @param string $gid
- *
- * @return The Gid of the previous group
- */
- function getGidPrevious($surveyid, $gid)
- {
- $clang = Yii::app()->lang;
- if (!$surveyid) {$surveyid=returnGlobal('sid');}
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $qresult = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'language' => $s_lang), array('order'=>'group_order'));
- $i = 0;
- $iPrev = -1;
- foreach ($qresult as $qrow)
- {
- $qrow = $qrow->attributes;
- if ($gid == $qrow['gid']) {$iPrev = $i - 1;}
- $i += 1;
- }
- if ($iPrev >= 0) {$GidPrev = $qresult[$iPrev]->gid;}
- else {$GidPrev = "";}
- return $GidPrev;
- }
- /**
- * getQidPrevious() returns the Qid of the question prior to the current active question
- *
- * @param string $surveyid
- * @param string $gid
- * @param string $qid
- *
- * @return This Qid of the previous question
- */
- function getQidPrevious($surveyid, $gid, $qid)
- {
- $clang = Yii::app()->lang;
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $qrows = Questions::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => $s_lang, 'parent_qid'=>0),array('order'=>'question_order'));
- $i = 0;
- $iPrev = -1;
- if (count($qrows) > 0)
- {
- foreach ($qrows as $qrow)
- {
- $qrow = $qrow->attributes;
- if ($qid == $qrow['qid']) {$iPrev = $i - 1;}
- $i += 1;
- }
- }
- if ($iPrev >= 0) {$QidPrev = $qrows[$iPrev]->qid;}
- else {$QidPrev = "";}
- return $QidPrev;
- }
- /**
- * getGidNext() returns the Gid of the group next to the current active group
- *
- * @param string $surveyid
- * @param string $gid
- *
- * @return The Gid of the next group
- */
- function getGidNext($surveyid, $gid)
- {
- $clang = Yii::app()->lang;
- if (!$surveyid) {$surveyid=returnGlobal('sid');}
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- //$gquery = "SELECT gid FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order";
- $qresult = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'language' => $s_lang), array('order'=>'group_order'));
- $GidNext="";
- $i = 0;
- $iNext = 1;
- foreach ($qresult as $qrow)
- {
- $qrow = $qrow->attributes;
- if ($gid == $qrow['gid']) {$iNext = $i + 1;}
- $i += 1;
- }
- if ($iNext < count($qresult)) {$GidNext = $qresult[$iNext]->gid;}
- else {$GidNext = "";}
- return $GidNext;
- }
- /**
- * getQidNext() returns the Qid of the question prior to the current active question
- *
- * @param string $surveyid
- * @param string $gid
- * @param string $qid
- *
- * @return This Qid of the previous question
- */
- function getQidNext($surveyid, $gid, $qid)
- {
- $clang = Yii::app()->lang;
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $qrows = Questions::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => $s_lang, 'parent_qid' => 0), array('order'=>'question_order'));
- $i = 0;
- $iNext = 1;
- if (count($qrows) > 0)
- {
- foreach ($qrows as $qrow)
- {
- if ($qid == $qrow->qid) {$iNext = $i + 1;}
- $i += 1;
- }
- }
- if ($iNext < count($qrows)) {$QidNext = $qrows[$iNext]->qid;}
- else {$QidNext = "";}
- return $QidNext;
- }
- function convertGETtoPOST($url)
- {
- $url = preg_replace('/&/i','&',$url);
- $stack = explode('?',$url);
- $calledscript = array_shift($stack);
- $query = array_shift($stack);
- $aqueryitems = explode('&',$query);
- $arrayParam = Array();
- $arrayVal = Array();
- foreach ($aqueryitems as $queryitem)
- {
- $stack = explode ('=', $queryitem);
- $paramname = array_shift($stack);
- $value = array_shift($stack);
- $arrayParam[] = "'".$paramname."'";
- $arrayVal[] = substr($value, 0, 9) != "document." ? "'".$value."'" : $value;
- }
- // $Paramlist = "[" . implode(",",$arrayParam) . "]";
- // $Valuelist = "[" . implode(",",$arrayVal) . "]";
- $Paramlist = "new Array(" . implode(",",$arrayParam) . ")";
- $Valuelist = "new Array(" . implode(",",$arrayVal) . ")";
- $callscript = "sendPost('$calledscript','',$Paramlist,$Valuelist);";
- return $callscript;
- }
- /**
- * This function calculates how much space is actually used by all files uploaded
- * using the File Upload question type
- *
- * @returns integer Actual space used in MB
- */
- function calculateTotalFileUploadUsage(){
- global $uploaddir;
- $sQuery='select sid from {{surveys}}';
- $oResult = dbExecuteAssoc($sQuery); //checked
- $aRows = $oResult->readAll();
- $iTotalSize=0.0;
- foreach ($aRows as $aRow)
- {
- $sFilesPath=$uploaddir.'/surveys/'.$aRow['sid'].'/files';
- if (file_exists($sFilesPath))
- {
- $iTotalSize+=(float)getDirectorySize($sFilesPath);
- }
- }
- return (float)$iTotalSize/1024/1024;
- }
- function getDirectorySize($directory) {
- $size = 0;
- foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
- $size+=$file->getSize();
- }
- return $size;
- }
- /**
- * Gets number of groups inside a particular survey
- *
- * @param string $surveyid
- * @param mixed $lang
- */
- function getGroupSum($surveyid, $lang)
- {
- //$condn = "WHERE sid=".$surveyid." AND language='".$lang."'"; //Getting a count of questions for this survey
- $condn = array('sid'=>$surveyid,'language'=>$lang);
- $sumresult3 = count(Groups::model()->findAllByAttributes($condn)); //Checked)
- return $sumresult3 ;
- }
- /**
- * getMaxGroupOrder($surveyid) queries the database for the maximum sortorder of a group and returns the next higher one.
- *
- * @param mixed $surveyid
- */
- function getMaxGroupOrder($surveyid)
- {
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- //$max_sql = "SELECT max( group_order ) AS max FROM ".db_table_name('groups')." WHERE sid =$surveyid AND language='{$s_lang}'" ;
- $query = Groups::model()->find(array('order' => 'group_order desc'));
- $current_max = !is_null($query) ? $query->group_order : '';
- if($current_max!="")
- {
- return ++$current_max ;
- }
- else return "0" ;
- }
- /**
- * getGroupOrder($surveyid,$gid) queries the database for the sortorder of a group.
- *
- * @param mixed $surveyid
- * @param mixed $gid
- * @return mixed
- */
- function getGroupOrder($surveyid,$gid)
- {
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- //$grporder_sql = "SELECT group_order FROM ".db_table_name('groups')." WHERE sid =$surveyid AND language='{$s_lang}' AND gid=$gid" ;
- $grporder_result = Groups::model()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $s_lang)); //Checked
- $grporder_row = $grporder_result->attributes ;
- $group_order = $grporder_row['group_order'];
- if($group_order=="")
- {
- return "0" ;
- }
- else return $group_order ;
- }
- /**
- * getMaxQuestionOrder($gid) queries the database for the maximum sortorder of a question.
- *
- */
- function getMaxQuestionOrder($gid,$surveyid)
- {
- $gid=sanitize_int($gid);
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $max_sql = "SELECT max( question_order ) AS max FROM {{questions}} WHERE gid='$gid' AND language='$s_lang'";
- $max_result = Yii::app()->db->createCommand($max_sql)->query(); //Checked
- $maxrow = $max_result->read() ;
- $current_max = $maxrow['max'];
- if($current_max=="")
- {
- return "0" ;
- }
- else return $current_max ;
- }
- /**
- * getQuestionClass() returns a class name for a given question type to allow custom styling for each question type.
- *
- * @param string $input containing unique character representing each question type.
- * @return string containing the class name for a given question type.
- */
- function getQuestionClass($input)
- {
- switch($input)
- { // I think this is a bad solution to adding classes to question
- // DIVs but I can't think of a better solution. (eric_t_cruiser)
- case 'X': return 'boilerplate'; // BOILERPLATE QUESTION
- case '5': return 'choice-5-pt-radio'; // 5 POINT CHOICE radio-buttons
- case 'D': return 'date'; // DATE
- case 'Z': return 'list-radio-flexible'; // LIST Flexible radio-button
- case 'L': return 'list-radio'; // LIST radio-button
- case 'W': return 'list-dropdown-flexible'; // LIST drop-down (flexible label)
- case '!': return 'list-dropdown'; // List - dropdown
- case 'O': return 'list-with-comment'; // LIST radio-button + textarea
- case 'R': return 'ranking'; // RANKING STYLE
- case 'M': return 'multiple-opt'; // Multiple choice checkbox
- case 'I': return 'language'; // Language Question
- case 'P': return 'multiple-opt-comments'; // Multiple choice with comments checkbox + text
- case 'Q': return 'multiple-short-txt'; // TEXT
- case 'K': return 'numeric-multi'; // MULTIPLE NUMERICAL QUESTION
- case 'N': return 'numeric'; // NUMERICAL QUESTION TYPE
- case 'S': return 'text-short'; // SHORT FREE TEXT
- case 'T': return 'text-long'; // LONG FREE TEXT
- case 'U': return 'text-huge'; // HUGE FREE TEXT
- case 'Y': return 'yes-no'; // YES/NO radio-buttons
- case 'G': return 'gender'; // GENDER drop-down list
- case 'A': return 'array-5-pt'; // ARRAY (5 POINT CHOICE) radio-buttons
- case 'B': return 'array-10-pt'; // ARRAY (10 POINT CHOICE) radio-buttons
- case 'C': return 'array-yes-uncertain-no'; // ARRAY (YES/UNCERTAIN/NO) radio-buttons
- case 'E': return 'array-increase-same-decrease'; // ARRAY (Increase/Same/Decrease) radio-buttons
- case 'F': return 'array-flexible-row'; // ARRAY (Flexible) - Row Format
- case 'H': return 'array-flexible-column'; // ARRAY (Flexible) - Column Format
- // case '^': return 'slider'; // SLIDER CONTROL
- case ':': return 'array-multi-flexi'; // ARRAY (Multi Flexi) 1 to 10
- case ";": return 'array-multi-flexi-text';
- case "1": return 'array-flexible-duel-scale'; // Array dual scale
- case "*": return 'equation'; // Equation
- default: return 'generic_question'; // Should have a default fallback
- };
- };
- /**
- * setupColumns() defines all the html tags to be wrapped around
- * various list type answers.
- *
- * @param integer $columns - the number of columns, usually supplied by $dcols
- * @param integer $answer_count - the number of answers to a question, usually supplied by $anscount
- * @param string $wrapperclass - a global class for the wrapper
- * @param string $itemclass - a class for the item
- * @return array with all the various opening and closing tags to generate a set of columns.
- *
- * It returns an array with the following items:
- * $wrapper['whole-start'] = Opening wrapper for the whole list
- * $wrapper['whole-end'] = closing wrapper for the whole list
- * $wrapper['col-devide'] = normal column devider
- * $wrapper['col-devide-last'] = the last column devider (to allow
- * for different styling of the last
- * column
- * $wrapper['item-start'] = opening wrapper tag for individual
- * option
- * $wrapper['item-start-other'] = opening wrapper tag for other
- * option
- * $wrapper['item-start-noanswer'] = opening wrapper tag for no answer
- * option
- * $wrapper['item-end'] = closing wrapper tag for individual
- * option
- * $wrapper['maxrows'] = maximum number of rows in each
- * column
- * $wrapper['cols'] = Number of columns to be inserted
- * (and checked against)
- *
- *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- * Columns are a problem.
- * Really there is no perfect solution to columns at the moment.
- *
- * - Using Tables is problematic semanticly.
- * - Using inline or float to create columns, causes the answers
- * flows horizontally, not vertically which is not ideal visually.
- * - Using CSS3 columns is also a problem because of browser support
- * and also because if you have answeres split across two or more
- * lines, and those answeres happen to fall at the bottom of a
- * column, the answer might be split across columns as well as
- * lines.
- * - Using nested unordered list with the first level of <LI>s
- * floated is the same as using tables and so is bad semantically
- * for the same reason tables are bad.
- * - Breaking the unordered lists into consecutive floated unordered
- * lists is not great semantically but probably not as bad as
- * using tables.
- *
- * Because I haven't been able to decide which option is the least
- * bad, I have handed over that responsibility to the admin who sets
- * LimeSurvey up on their server.
- *
- * There are four options:
- * 'css' using one of the various CSS only methods for
- * rendering columns.
- * (Check the CSS file for your chosen template to see
- * how columns are defined.)
- * 'ul' using multiple floated unordered lists. (DEFAULT)
- * 'table' using conventional tables based layout.
- * NULL blocks the use of columns
- *
- * 'ul' is the default because it's the best possible compromise
- * between semantic markup and visual layout.
- */
- function setupColumns($columns, $answer_count,$wrapperclass="",$itemclass="")
- {
- $column_style = Yii::app()->getConfig('column_style');
- if ( !in_array($column_style,array('css','ul','table')) && !is_null($column_style) )
- {
- $column_style = 'ul';
- };
- if($columns < 2)
- {
- $column_style = null;
- $columns = 1;
- }
- if(($columns > $answer_count) && $answer_count>0)
- {
- $columns = $answer_count;
- };
- $class_first = ' class="'.$wrapperclass.'"';
- if($columns > 1 && !is_null($column_style))
- {
- if($column_style == 'ul')
- {
- $ul = '-ul';
- }
- else
- {
- $ul = '';
- }
- $class_first = ' class="'.$wrapperclass.' cols-'.$columns . $ul.' first"';
- $class = ' class="'.$wrapperclass.' cols-'.$columns . $ul.'"';
- $class_last_ul = ' class="'.$wrapperclass.' cols-'.$columns . $ul.' last"';
- $class_last_table = ' class="'.$wrapperclass.' cols-'.$columns.' last"';
- }
- else
- {
- $class = ' class="'.$wrapperclass.'"';
- $class_last_ul = ' class="'.$wrapperclass.'"';
- $class_last_table = ' class="'.$wrapperclass.'"';
- };
- $wrapper = array(
- 'whole-start' => "\n<ul$class_first>\n"
- ,'whole-end' => "</ul>\n"
- ,'col-devide' => ''
- ,'col-devide-last' => ''
- ,'item-start' => "\t<li class=\"{$itemclass}\">\n"
- ,'item-start-other' => "\t<li class=\"{$itemclass} other other-item\">\n"
- ,'item-start-noanswer' => "\t<li class=\"{$itemclass} noanswer-item\">\n"
- ,'item-end' => "\t</li>\n"
- ,'maxrows' => ceil($answer_count/$columns) //Always rounds up to nearest whole number
- ,'cols' => $columns
- );
- switch($column_style)
- {
- case 'ul': if($columns > 1)
- {
- $wrapper['col-devide'] = "\n</ul>\n\n<ul$class>\n";
- $wrapper['col-devide-last'] = "\n</ul>\n\n<ul$class_last_ul>\n";
- }
- break;
- case 'table': $table_cols = '';
- for($cols = $columns ; $cols > 0 ; --$cols)
- {
- switch($cols)
- {
- case $columns: $table_cols .= "\t<col$class_first />\n";
- break;
- case 1: $table_cols .= "\t<col$class_last_table />\n";
- break;
- default: $table_cols .= "\t<col$class />\n";
- };
- };
- if($columns > 1)
- {
- $wrapper['col-devide'] = "\t</ul>\n</td>\n\n<td>\n\t<ul>\n";
- $wrapper['col-devide-last'] = "\t</ul>\n</td>\n\n<td class=\"last\">\n\t<ul>\n";
- };
- $wrapper['whole-start'] = "\n<table$class>\n$table_cols\n\t<tbody>\n<tr>\n<td>\n\t<ul>\n";
- $wrapper['whole-end'] = "\t</ul>\n</td>\n</tr>\n\t</tbody>\n</table>\n";
- $wrapper['item-start'] = "<li class=\"{$itemclass}\">\n";
- $wrapper['item-end'] = "</li class=\"{$itemclass}\">\n";
- };
- return $wrapper;
- };
- function alternation($alternate = '' , $type = 'col')
- {
- /**
- * alternation() Returns a class identifyer for alternating between
- * two options. Used to style alternate elements differently. creates
- * or alternates between the odd string and the even string used in
- * as column and row classes for array type questions.
- *
- * @param string $alternate = '' (empty) (default) , 'array2' , 'array1' , 'odd' , 'even'
- * @param string $type = 'col' (default) or 'row'
- *
- * @return string representing either the first alternation or the opposite alternation to the one supplied..
- */
- /*
- // The following allows type to be left blank for row in subsequent
- // function calls.
- // It has been left out because 'row' must be defined the first time
- // alternation() is called. Since it is only ever written once for each
- // while statement within a function, 'row' is always defined.
- if(!empty($alternate) && $type != 'row')
- { if($alternate == ('array2' || 'array1'))
- {
- $type = 'row';
- };
- };
- // It has been left in case it becomes useful but probably should be
- // removed.
- */
- if($type == 'row')
- {
- $odd = 'array2'; // should be row_odd
- $even = 'array1'; // should be row_even
- }
- else
- {
- $odd = 'odd'; // should be col_odd
- $even = 'even'; // should be col_even
- };
- if($alternate == $odd)
- {
- $alternate = $even;
- }
- else
- {
- $alternate = $odd;
- };
- return $alternate;
- }
- /**
- * longestString() returns the length of the longest string past to it.
- * @peram string $new_string
- * @peram integer $longest_length length of the (previously) longest string passed to it.
- * @return integer representing the length of the longest string passed (updated if $new_string was longer than $longest_length)
- *
- * usage should look like this: $longest_length = longestString( $new_string , $longest_length );
- *
- */
- function longestString( $new_string , $longest_length )
- {
- if($longest_length < strlen(trim(strip_tags($new_string))))
- {
- $longest_length = strlen(trim(strip_tags($new_string)));
- };
- return $longest_length;
- };
- /**
- * getNotificationList() returns different options for notifications
- *
- * @param string $notificationcode - the currently selected one
- *
- * @return This string is returned containing <option></option> formatted list of notification methods for current survey
- */
- function getNotificationList($notificationcode)
- {
- $clang = Yii::app()->lang;
- $ntypes = array(
- "0"=>$clang->gT("No email notification"),
- "1"=>$clang->gT("Basic email notification"),
- "2"=>$clang->gT("Detailed email notification with result codes")
- );
- if (!isset($ntypeselector)) {$ntypeselector="";}
- foreach($ntypes as $ntcode=>$ntdescription)
- {
- $ntypeselector .= "<option value='$ntcode'";
- if ($notificationcode == $ntcode) {$ntypeselector .= " selected='selected'";}
- $ntypeselector .= ">$ntdescription</option>\n";
- }
- return $ntypeselector;
- }
- /**
- * getGroupList() queries the database for a list of all groups matching the current survey sid
- *
- *
- * @param string $gid - the currently selected gid/group
- *
- * @return This string is returned containing <option></option> formatted list of groups to current survey
- */
- function getGroupList($gid,$surveyid)
- {
- $clang = Yii::app()->lang;
- $groupselecter="";
- $gid=sanitize_int($gid);
- $surveyid=sanitize_int($surveyid);
- if (!$surveyid) {$surveyid=returnGlobal('sid');}
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- $gidquery = "SELECT gid, group_name FROM {{groups}} WHERE sid='{$surveyid}' AND language='{$s_lang}' ORDER BY group_order";
- $gidresult = Yii::app()->db->createCommand($gidquery)->query(); //Checked
- foreach ($gidresult->readAll() as $gv)
- {
- $groupselecter .= "<option";
- if ($gv['gid'] == $gid) {$groupselecter .= " selected='selected'"; $gvexist = 1;}
- $groupselecter .= " value='".Yii::app()->getConfig('scriptname')."?sid=$surveyid&gid=".$gv['gid']."'>".htmlspecialchars($gv['group_name'])."</option>\n";
- }
- if ($groupselecter)
- {
- if (!isset($gvexist)) {$groupselecter = "<option selected='selected'>".$clang->gT("Please choose...")."</option>\n".$groupselecter;}
- else {$groupselecter .= "<option value='".Yii::app()->getConfig('scriptname')."?sid=$surveyid&gid='>".$clang->gT("None")."</option>\n";}
- }
- return $groupselecter;
- }
- function getGroupList3($gid,$surveyid)
- {
- //$clang = Yii::app()->lang;
- $gid=sanitize_int($gid);
- $surveyid=sanitize_int($surveyid);
- if (!$surveyid) {$surveyid=returnGlobal('sid');}
- $groupselecter = "";
- $s_lang = Survey::model()->findByPk($surveyid)->language;
- //$gidquery = "SELECT gid, group_name FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order";
- $gidresult = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'language' => $s_lang), array('order'=>'group_order'));
- foreach ($gidresult as $gv)
- {
- $gv = $gv->attributes;
- $groupselecter .= "<option";
- if ($gv['gid'] == $gid) {$groupselecter .= " selected='selected'"; }
- $groupselecter .= " value='".$gv['gid']."'>".htmlspecialchars($gv['group_name'])."</option>\n";
- }
- return $groupselecter;
- }
- /**
- * put your comment there...
- *
- * @param mixed $gid
- * @param mixed $language
- */
- function getGroupListLang($gid, $language, $surveyid)
- {
- $clang = Yii::app()->lang;
- $groupselecter="";
- if (!$surveyid) {$surveyid=returnGlobal('sid');}
- $gidresult = Groups::model()->findAll(array('condition'=>'sid=:surveyid AND language=:language',
- 'order'=>'group_order',
- 'params'=>array(':surveyid'=>$surveyid,':language'=>$language))); //Checked)
- foreach ($gidresult as $gv)
- {
- $gv = $gv->attributes;
- $groupselecter .= "<option";
- if ($gv['gid'] == $gid) {$groupselecter .= " selected='selected'"; $gvexist = 1;}
- $link = Yii::app()->getController()->createUrl("/admin/survey/sa/view/surveyid/".$surveyid."/gid/".$gv['gid']);
- $groupselecter .= " value='{$link}'>";
- if (strip_tags($gv['group_name']))
- {
- $groupselecter .= htmlspecialchars(strip_tags($gv['group_name']));
- } else {
- $groupselecter .= htmlspecialchars($gv['group_name']);
- }
- $groupselecter .= "</option>\n";
- }
- if ($groupselecter)
- {
- $link = Yii::app()->getController()->createUrl("/admin/survey/sa/view/surveyid/".$surveyid);
- if (!isset($gvexist)) {$groupselecter = "<option selected='selected'>".$clang->gT("Please choose...")."</option>\n".$groupselecter;}
- else {$groupselecter .= "<option value='{$link}'>".$clang->gT("None")."</option>\n";}
- }
- return $groupselecter;
- }
- function getUserList($outputformat='fullinfoarray')
- {
- $clang = Yii::app()->lang;
- if (!empty(Yii::app()->session['loginID']))
- {
- $myuid=sanitize_int(Yii::app()->session['loginID']);
- }
- $usercontrolSameGroupPolicy = Yii::app()->getConfig('usercontrolSameGroupPolicy');
- if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1 && isset($usercontrolSameGroupPolicy) &&
- $usercontrolSameGroupPolicy == true)
- {
- if (isset($myuid))
- {
- $sDatabaseType = Yii::app()->db->getDriverName();
- if ($sDatabaseType=='mssql' || $sDatabaseType=="sqlsrv")
- {
- $sSelectFields = 'users_name,uid,email,full_name,parent_id,create_survey,participant_panel,configurator,create_user,delete_user,superadmin,manage_template,manage_label,CAST(password as varchar) as password';
- }
- else
- {
- $sSelectFields = 'users_name,uid,email,full_name,parent_id,create_survey,participant_panel,configurator,create_user,delete_user,superadmin,manage_template,manage_label,password';
- }
- // List users from same group as me + all my childs
- // a subselect is used here because MSSQL does not like to group by text
- // also Postgres does like this one better
- $uquery = " SELECT {$sSelectFields} from {{users}} where uid in (
- SELECT uid from {{user_in_groups}} where ugid in (
- SELECT ugid from {{user_in_groups}} where uid={$myuid}
- )
- )
- UNION
- SELECT {$sSelectFields} from {{users}} v where v.parent_id={$myuid}
- UNION
- SELECT {$sSelectFields} from {{users}} v where uid={$myuid}";
-
- }
- else
- {
- return array(); // Or die maybe
- }
-
- }
- else
- {
- $uquery = "SELECT * FROM {{users}} ORDER BY uid";
- }
- $uresult = Yii::app()->db->createCommand($uquery)->query()->readAll(); //Checked
- if (count($uresult)==0)
- //user is not in a group and usercontrolSameGroupPolicy is activated - at least show his own userinfo
- {
- $uquery = "SELECT u.* FROM {{users}} AS u WHERE u.uid=".$myuid;
- $uresult = Yii::app()->db->createCommand($uquery)->query()->readAll();//Checked
- }
- $userlist = array();
- $userlist[0] = "Reserved for logged in user";
- //while ($srow = $uresult->readAll())
- foreach ($uresult as $srow)
- {
- if ($outputformat != 'onlyuidarray')
- {
- if ($srow['uid'] != Yii::app()->session['loginID'])
- {
- $userlist[] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'], "participant_panel"=>$srow['participant_panel'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']); //added by Dennis modified by Moses
- }
- else
- {
- $userlist[0] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'],"participant_panel"=>$srow['participant_panel'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']);
- }
- }
- else
- {
- if ($srow['uid'] != Yii::app()->session['loginID'])
- {
- $userlist[] = $srow['uid'];
- }
- else
- {
- $userlist[0] = $srow['uid'];
- }
- }
- }
- return $userlist;
- }
- /**
- * Gets all survey infos in one big array including the language specific settings
- *
- * @param string $surveyid The survey ID
- * @param string $languagecode The language code - if not given the base language of the particular survey is used
- * @return array Returns array with survey info or false, if survey does not exist
- */
- function getSurveyInfo($surveyid, $languagecode='')
- {
- static $staticSurveyInfo = array();// Use some static
- $surveyid=sanitize_int($surveyid);
- $languagecode=sanitize_languagecode($languagecode);
- $thissurvey=false;
- // Do job only if this survey exist
- if(!Survey::model()->findByPk($surveyid))
- {
- return false;
- }
- // if no language code is set then get the base language one
- if ((!isset($languagecode) || $languagecode==''))
- {
- $languagecode=Survey::model()->findByPk($surveyid)->language;
- }
- if(isset($staticSurveyInfo[$surveyid][$languagecode]) )
- {
- $thissurvey=$staticSurveyInfo[$surveyid][$languagecode];
- }
- else
- {
- $result = Surveys_languagesettings::model()->with('survey')->findByPk(array('surveyls_survey_id' => $surveyid, 'surveyls_language' => $languagecode));
- if (is_null($result)) {
- // When additional language was added, but not saved it does not exists
- // We should revert to the bas…
Large files files are truncated, but you can click here to view the full file