Example #1
0
 /**
  * @param array $headers
  * @param array $values
  * @param FormattingOptions $oOptions
  */
 protected function outputRecord($headers, $values, FormattingOptions $oOptions)
 {
     if ($oOptions->answerFormat == 'short') {
         //No headers at all, only output values.
         $this->output .= implode($this->separator, $values) . PHP_EOL;
     } elseif ($oOptions->answerFormat == 'long') {
         //Output each record, one per page, with a header preceding every value.
         if ($this->isBeginning) {
             $this->isBeginning = false;
         } else {
             $this->output .= "<br clear='all' style='page-break-before:always'>";
         }
         $this->output .= "<table><tr><th colspan='2'>" . gT("Survey response") . "</td></tr>" . PHP_EOL;
         $counter = 0;
         foreach ($headers as $header) {
             //if cell empty, output a space instead, otherwise the cell will be in 2pt font
             $value = "&nbsp;";
             if ($values[$counter] != "") {
                 $value = $values[$counter];
             }
             $this->output .= "<tr><td>" . $header . "</td><td>" . $value . "</td></tr>" . PHP_EOL;
             $counter++;
         }
         $this->output .= "</table>" . PHP_EOL;
     } else {
         safeDie('An invalid answer format was selected.  Only \'short\' and \'long\' are valid.');
     }
     if ($oOptions->output == 'display') {
         echo $this->output;
         $this->output = '';
     } elseif ($oOptions->output == 'file') {
         fwrite($this->file, $this->output);
         $this->output = '';
     }
 }
Example #2
0
 function index()
 {
     $aData = array();
     $needpermission = false;
     $aData['surveyid'] = $surveyid = sanitize_int(Yii::app()->request->getQuery('sid'));
     $aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index'));
     if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) {
         $needpermission = true;
     }
     if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         App()->getClientScript()->registerPackage('jquery-superfish');
         $message['title'] = gT('Access denied!');
         $message['message'] = gT('You do not have sufficient rights to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     } else {
         App()->getClientScript()->registerPackage('jqueryui');
         App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
         App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js");
         App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css");
         $this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'));
         $aData['pagetitle'] = "ExpressionManager:  {$aData['sa']}";
         //header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding
         if (isset($_GET['sa'])) {
             $this->test($aData['sa'], $aData);
         } else {
             $this->_renderWrappedTemplate('expressions', 'test_view', $aData);
         }
     }
 }
Example #3
0
function dirReport($dir, $write)
{
    $error = 0;

    if ($dir == "Found")
    {
       $a = gT("Found");
    } else
    {
       $error = 1;
       $a = gT("Not found");
    }

    if ($write == "Writable")
    {
       $b = gT("Writable");
    } else
    {
       $error = 1;
       $b = gT("Unwritable");
    }

    if ($error)
    {
       return '<font color="red">'.$a.' &amp; '.$b.'</font>';
    }
    else
    {
       return $a.' &amp; '.$b;
    }
}
function ShowDBUpgradeNotice()
{
    $message = '
        <div class="jumbotron message-box">
            <h2 class="">' . gT('Database upgrade') . '</h2>
            <p class="lead">' . gT('Please verify the following information before continuing with the database upgrade:') . '</p>
            <p>
                <ul class="list-unstyled">
                    <li><b>' . gT('Database type') . ':</b> ' . Yii::app()->db->getDriverName() . '</li>
                    <li><b>' . gT('Database name') . ':</b> ' . getDBConnectionStringProperty('dbname') . '</li>
                    <li><b>' . gT('Table prefix') . ':</b> ' . Yii::app()->db->tablePrefix . '</li>
                    <li><b>' . gT('Site name') . ':</b> ' . Yii::app()->getConfig("sitename") . '</li>
                    <li><b>' . gT('Root URL') . ':</b> ' . Yii::app()->getController()->createUrl('') . '</li>
                </ul>
            </p>

            <p>
                <a class="btn btn-lg btn-success" href="' . Yii::app()->getController()->createUrl("admin/databaseupdate/sa/db/continue/yes") . '" role="button">
                    ' . gT('Click here to continue') . '
                </a>
            </p>

        </div>
    ';
    return $message;
}
Example #5
0
 public function outputRecord($headers, $values, FormattingOptions $oOptions)
 {
     $this->rowCounter++;
     if ($oOptions->answerFormat == 'short') {
         $pdfstring = '';
         foreach ($values as $value) {
             $pdfstring .= $value . ' | ';
         }
         $this->pdf->intopdf($pdfstring);
     } elseif ($oOptions->answerFormat == 'long') {
         if ($this->rowCounter != 1) {
             $this->pdf->AddPage();
         }
         $this->pdf->addTitle(sprintf(gT("Survey response %d"), $this->rowCounter));
         foreach ($this->aGroupMap as $gid => $questions) {
             if ($gid != 0) {
                 $this->pdf->addGidAnswer($questions[0]['group_name']);
             }
             foreach ($questions as $question) {
                 if (isset($values[$question['index']]) && isset($headers[$question['index']])) {
                     $this->pdf->addAnswer($headers[$question['index']], $values[$question['index']], false);
                 }
             }
         }
     } else {
         safeDie('An invalid answer format was encountered: ' . $oOptions->answerFormat);
     }
 }
Example #6
0
function ShowDBUpgradeNotice()
{
    $message = '
        <div class="jumbotron message-box">
            <h2 class="">' . gT('Database upgrade') . '</h2>
            <p class="lead">' . gT('Please verify the following information before continuing with the database upgrade:') . '</p>
            <div class="row">
            <div class="col-md-offset-4 col-md-4">
                <table class="table table-striped">
                    <tr><th>' . gT('Database type:') . '</th><td>' . Yii::app()->db->getDriverName() . '</td></tr>
                    <tr><th>' . gT('Database name:') . '</th><td>' . getDBConnectionStringProperty('dbname') . '</td></tr>
                    <tr><th>' . gT('Table prefix:') . '</th><td>' . Yii::app()->db->tablePrefix . '</td></tr>
                    <tr><th>' . gT('Site name:') . '</th><td>' . Yii::app()->getConfig("sitename") . '</td></tr>
                    <tr><th>' . gT('Root URL:') . '</th><td>' . Yii::app()->getController()->createUrl('') . '</td></tr>
                    <tr><th>' . gT('Current database version:') . '</th><td>' . GetGlobalSetting('DBVersion') . '</td></tr>
                    <tr><th>' . gT('Target database version:') . '</th><td>' . Yii::app()->getConfig('dbversionnumber') . '</td></tr>
                </table>
            </div>
            </div>

            <p>
                <a class="btn btn-lg btn-success" href="' . Yii::app()->getController()->createUrl("admin/databaseupdate/sa/db/continue/yes") . '" role="button">
                    ' . gT('Click here to continue') . '
                </a>
            </p>

        </div>
    ';
    return $message;
}
 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  * @throws CException if invalid operator is used
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = strtolower($object->{$attribute});
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     if ($this->compareValue !== null) {
         $compareTo = $this->compareValue;
         $compareValue = strtolower($compareTo);
     } else {
         throw new CException('compareValue must be set when using LSYii_CompareInsensitiveValidator');
     }
     switch ($this->operator) {
         case '=':
         case '==':
             if ($value != $compareValue) {
                 $message = $this->message !== null ? $this->message : sprintf(gT('%s must be case-insensitive equal to %s'), $attribute, $compareTo);
             }
             break;
         case '!=':
             if ($value == $compareValue) {
                 $message = $this->message !== null ? $this->message : sprintf(gT('%s must not be case-insensitive equal to %s'), $attribute, $compareTo);
             }
             break;
         default:
             throw new CException(Yii::t('yii', 'Invalid operator "{operator}".', array('{operator}' => $this->operator)));
     }
     if (!empty($message)) {
         $this->addError($object, $attribute, $message, array('{compareAttribute}' => $compareTo, '{compareValue}' => $compareValue));
     }
 }
Example #8
0
 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);
 }
Example #9
0
 public function afterAdminMenuLoaded()
 {
     $event = $this->event;
     $menu = $event->get('menu', array());
     $menu['left'][] = array('href' => "http://docs.limesurvey.org", 'alt' => gT('LimeSurvey online manual'), 'image' => 'showhelp.png');
     $event->set('menu', $menu);
 }
Example #10
0
 /**
  * getPdfLanguageSettings
  *
  * Usage: getPdfLanguageSettings($language)
  *
  * @return array ('pdffont','pdffontsize','lg'=>array('a_meta_charset','a_meta_dir','a_meta_language','w_page')
  * @param string $language : language code for the PDF
  */
 public static function getPdfLanguageSettings($language)
 {
     Yii::import('application.libraries.admin.pdf', true);
     Yii::import('application.helpers.surveytranslator_helper', true);
     $pdffont = Yii::app()->getConfig('pdfdefaultfont');
     if ($pdffont == 'auto') {
         $pdffont = PDF_FONT_NAME_DATA;
     }
     $pdfcorefont = array("freesans", "dejavusans", "courier", "helvetica", "freemono", "symbol", "times", "zapfdingbats");
     if (in_array($pdffont, $pdfcorefont)) {
         $alternatepdffontfile = Yii::app()->getConfig('alternatepdffontfile');
         if (array_key_exists($language, $alternatepdffontfile)) {
             $pdffont = $alternatepdffontfile[$language];
             // Actually use only core font
         }
     }
     $pdffontsize = Yii::app()->getConfig('pdffontsize');
     if ($pdffontsize == 'auto') {
         $pdffontsize = PDF_FONT_SIZE_MAIN;
     }
     $lg = array();
     $lg['a_meta_charset'] = 'UTF-8';
     if (getLanguageRTL($language)) {
         $lg['a_meta_dir'] = 'rtl';
     } else {
         $lg['a_meta_dir'] = 'ltr';
     }
     $lg['a_meta_language'] = $language;
     $lg['w_page'] = gT("page");
     return array('pdffont' => $pdffont, 'pdffontsize' => $pdffontsize, 'lg' => $lg);
 }
Example #11
0
 public function attributeLabels()
 {
     $labels = array('tid' => gT('Token ID'), 'partcipant' => gT('Participant ID'), 'firstname' => gT('First name'), 'lastname' => gT('Last name'), 'email' => gT('Email address'), 'emailstatus' => gT('Email status'), 'token' => gT('Token'), 'language' => gT('Language code'), 'blacklisted' => gT('Blacklisted'), 'sent' => gT('Invitation sent date'), 'remindersent' => gT('Last reminder sent date'), 'remindercount' => gT('Total numbers of sent reminders'), 'completed' => gT('Completed'), 'usesleft' => gT('Uses left'), 'validfrom' => gT('Valid from'), 'validuntil' => gT('Valid until'));
     foreach (decodeTokenAttributes($this->survey->attributedescriptions) as $key => $info) {
         $labels[$key] = $info['description'];
     }
     return $labels;
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function delete($id)
 {
     $this->loadModel($id)->delete();
     Yii::app()->user->setFlash('success', gT('Box deleted'));
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->getController()->redirect(array('admin/homepagesettings'));
     }
 }
Example #13
0
 function __construct($controller, $id)
 {
     parent::__construct($controller, $id);
     if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
         die;
     }
     if (!in_array(Yii::app()->db->getDriverName(), array('mysql', 'mysqli')) || Yii::app()->getConfig('demoMode') == true) {
         die(gT('This feature is only available for MySQL databases.'));
     }
 }
 /**
  * Runs after Admin Menu Loads. Used to display New Icon that will link to
  * the Community Action Data report page.
  **/
 public function afterAdminMenuLoad()
 {
     //Check for if current user is authenticated as a superadmin
     if ($this->isSuperAdmin()) {
         $event = $this->event;
         $menu = $event->get('menu', array());
         $menu['items']['left'][] = array('href' => "plugins/direct?plugin=Report&function=managePrograms", 'alt' => gT('CA Report'), 'image' => 'chart_bar.png');
         $event->set('menu', $menu);
     }
 }
Example #15
0
 /**
  * Returns the global permissions including description and title
  *
  * @access public
  * @static
  * @return array
  */
 public static function getGlobalBasePermissions()
 {
     $defaults = array('create' => true, 'read' => true, 'update' => true, 'delete' => true, 'import' => true, 'export' => true);
     $aPermissions = array('surveys' => array('import' => false, 'title' => gT("Surveys"), 'description' => gT("Permission to create surveys (for which all permissions are automatically given) and view, update and delete surveys from other users"), 'img' => 'survey'), 'users' => array('import' => false, 'export' => false, 'title' => gT("Users"), 'description' => gT("Permission to create, view, update and delete users"), 'img' => 'security'), 'usergroups' => array('import' => false, 'export' => false, 'title' => gT("User groups"), 'description' => gT("Permission to create, view, update and delete user groups"), 'img' => 'usergroup'), 'templates' => array('title' => gT("Templates"), 'description' => gT("Permission to create, view, update, delete, export and import templates"), 'img' => 'templates'), 'labelsets' => array('title' => gT("Label sets"), 'description' => gT("Permission to create, view, update, delete, export and import label sets/labels"), 'img' => 'labels'), 'settings' => array('create' => false, 'delete' => false, 'export' => false, 'title' => gT("Settings & Plugins"), 'description' => gT("Permission to view and update global settings & plugins and to delete and import plugins"), 'img' => 'global'), 'participantpanel' => array('import' => false, 'title' => gT("Participant panel"), 'description' => gT("Permission to create your own participants in the central participants database (for which all permissions are automatically given) and view, update and delete participants from other users"), 'img' => 'cpdb'));
     uasort($aPermissions, array(__CLASS__, "comparePermissionTitle"));
     $aPermissions['superadmin'] = array('create' => false, 'update' => false, 'delete' => false, 'import' => false, 'export' => false, 'title' => gT("Superadministrator"), 'description' => gT("Unlimited administration permissions"), 'img' => 'superadmin');
     foreach ($aPermissions as &$permission) {
         $permission = array_merge($defaults, $permission);
     }
     return $aPermissions;
 }
Example #16
0
 public function run()
 {
     if (Yii::app()->session['just_logged_in']) {
         $aViewUrls = array('message' => array('title' => gT("Logged in"), 'message' => Yii::app()->session['loginsummary']));
         unset(Yii::app()->session['just_logged_in'], Yii::app()->session['loginsummary']);
         $this->_renderWrappedTemplate('super', $aViewUrls);
     } elseif (count(getSurveyList(true)) == 0) {
         $this->_renderWrappedTemplate('super', 'firststeps');
     } else {
         $this->getController()->redirect(array('admin/survey/sa/index'));
     }
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
 /**
  * @param iPlugin $plugin The plugin to which this question belongs.
  * @param int $questionId
  * @param int $responseId Pass a response id to load results.
  */
 public function __construct(iPlugin $plugin, LimesurveyApi $api, $questionId = null, $responseId = null)
 {
     $this->plugin = $plugin;
     $this->api = $api;
     $this->responseId = $responseId;
     $this->questionId = $questionId;
     if (isset($questionId)) {
         $this->loadSubQuestions($questionId);
     }
     $this->defaultAttributes = array('questiontype' => array('type' => 'select', 'localized' => false, 'advanced' => false, 'label' => gT('Question type:'), 'options' => CHtml::listData(App()->getPluginManager()->loadQuestionObjects(), 'guid', 'name')), 'code' => array('type' => 'string', 'localized' => false, 'advanced' => false, 'label' => gT('Question code:')), 'gid' => array('type' => 'select', 'localized' => false, 'advanced' => false, 'label' => gT('Question group:'), 'options' => function ($this) {
         return $this->api->getGroupList($this->get('sid'));
     }), 'relevance' => array('type' => 'relevance', 'localized' => false, 'advanced' => false, 'label' => gT('Relevance equation:')), 'randomization' => array('type' => 'string', 'localized' => false, 'advanced' => false, 'label' => gT("Randomization group:")));
 }
 /**
  * Logout user
  */
 public function logout()
 {
     // Fetch the current user
     $plugin = App()->user->getState('plugin', null);
     // Save for afterLogout, current user will be destroyed by then
     /* Adding beforeLogout event */
     $beforeLogout = new PluginEvent('beforeLogout');
     App()->getPluginManager()->dispatchEvent($beforeLogout, array($plugin));
     App()->user->logout();
     App()->user->setFlash('loginmessage', gT('Logout successful.'));
     /* Adding afterLogout event */
     $event = new PluginEvent('afterLogout');
     App()->getPluginManager()->dispatchEvent($event, array($plugin));
     $this->getController()->redirect(array('/pl/authentication/sa/login'));
 }
Example #20
0
 public function run()
 {
     App()->loadHelper('surveytranslator');
     App()->getClientScript()->registerPackage('panel-clickable');
     App()->getClientScript()->registerPackage('panels-animation');
     $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);
     if ($lastsurvey != null) {
         $aData['showLastSurvey'] = true;
         $iSurveyID = $lastsurvey;
         $surveyinfo = Survey::model()->findByPk($iSurveyID)->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);
     if ($lastquestion != null && $lastquestiongroup != null) {
         $baselang = Survey::model()->findByPk($iSurveyID)->language;
         $aData['showLastQuestion'] = true;
         $qid = $lastquestion;
         $gid = $lastquestiongroup;
         $sid = $lastquestionsid;
         $qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $sid, 'language' => $baselang));
         $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/{$iSurveyID}/gid/{$gid}/qid/{$qid}");
     } else {
         $aData['showLastQuestion'] = false;
     }
     $aData['countSurveyList'] = count(getSurveyList(true));
     $this->_renderWrappedTemplate('super', 'welcome', $aData);
 }
 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;
     } else {
         $sBaseLanguage = sanitize_languagecode($sLanguageCode);
     }
     Yii::app()->setLanguage($sBaseLanguage);
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
     if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         throw new CHttpException(404, "This survey does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
     } else {
         LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $token, false);
         $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
         if (!isset($oToken)) {
             $sMessage = gT('You are not a participant in this survey.');
         } else {
             if ($oToken->emailstatus == 'OptOut') {
                 $oToken->emailstatus = 'OK';
                 $oToken->save();
                 $sMessage = gT('You have been successfully added back to this survey.');
             } elseif ($oToken->emailstatus == 'OK') {
                 $sMessage = gT('You are already a part of this survey.');
             } else {
                 $sMessage = 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, $aSurveyInfo);
 }
Example #22
0
 public function newUserSession()
 {
     // Do nothing if this user is not Authwebserver type
     $identity = $this->getEvent()->get('identity');
     if ($identity->plugin != 'Authwebserver') {
         return;
     }
     /* @var $identity LSUserIdentity */
     $sUser = $this->getUserName();
     $oUser = $this->api->getUserByName($sUser);
     if (is_null($oUser)) {
         if (function_exists("hook_get_auth_webserver_profile")) {
             // If defined this function returns an array
             // describing the default profile for this user
             $aUserProfile = hook_get_auth_webserver_profile($sUser);
         } elseif ($this->api->getConfigKey('auth_webserver_autocreate_user')) {
             $aUserProfile = $this->api->getConfigKey('auth_webserver_autocreate_profile');
         }
     } else {
         if (Permission::model()->hasGlobalPermission('auth_webserver', 'read', $oUser->uid)) {
             $this->setAuthSuccess($oUser);
             return;
         } else {
             $this->setAuthFailure(self::ERROR_AUTH_METHOD_INVALID, gT('Web server authentication method is not allowed for this user'));
             return;
         }
     }
     if ($this->api->getConfigKey('auth_webserver_autocreate_user') && isset($aUserProfile) && is_null($oUser)) {
         // user doesn't exist but auto-create user is set
         $oUser = new User();
         $oUser->users_name = $sUser;
         $oUser->password = hash('sha256', createPassword());
         $oUser->full_name = $aUserProfile['full_name'];
         $oUser->parent_id = 1;
         $oUser->lang = $aUserProfile['lang'];
         $oUser->email = $aUserProfile['email'];
         if ($oUser->save()) {
             $permission = new Permission();
             $permission->setPermissions($oUser->uid, 0, 'global', $this->api->getConfigKey('auth_webserver_autocreate_permissions'), true);
             Permission::model()->setGlobalPermission($oUser->uid, 'auth_webserver');
             // read again user from newly created entry
             $this->setAuthSuccess($oUser);
             return;
         } else {
             $this->setAuthFailure(self::ERROR_USERNAME_INVALID);
         }
     }
 }
Example #23
0
 public function listExportOptions()
 {
     $event = $this->getEvent();
     $type = $event->get('type');
     switch ($type) {
         case 'stataxml':
             $event->set('label', gT("STATA (.xml)"));
             $event->set('onclick', 'document.getElementById("ansabbrev").checked=true;
                     document.getElementById("ansfull").disabled=true;document.getElementById("convertyto1").checked=true;document.getElementById("convertnto2").checked=true;
                     document.getElementById("convertnto").value=0;document.getElementById("convertyto").value=1;
                     document.getElementById("headcodes").disabled=true;document.getElementById("headabbreviated").disabled=true;document.getElementById("headfull").checked=true;');
             break;
         default:
             break;
     }
 }
Example #24
0
 /**
  * Helper function to let a plugin put content
  * into the side-body easily.
  * 
  * @param int $surveyId
  * @param string $plugin Name of the plugin class
  * @param string $method Name of the plugin method
  * @return void
  */
 public function sidebody($surveyId, $plugin, $method)
 {
     $aData = array();
     $surveyId = sanitize_int($surveyId);
     $surveyinfo = getSurveyInfo($surveyId);
     $aData['surveyid'] = $surveyId;
     $aData['surveybar']['buttons']['view'] = true;
     $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $surveyId . ")";
     $content = $this->getContent($surveyId, $plugin, $method);
     $aData['sidemenu'] = array();
     $aData['sidemenu']['state'] = false;
     $aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour');
     $aData['content'] = $content;
     $aData['activated'] = $surveyinfo['active'];
     $this->_renderWrappedTemplate(null, array('super/sidebody'), $aData);
 }
 protected function setValuesFromDb()
 {
     $box = Boxes::model()->find(array('condition' => 'position=:positionId', 'params' => array(':positionId' => $this->dbPosition)));
     if ($box) {
         $this->position = $box->position;
         $this->url = $box->url;
         $this->title = $box->title;
         $this->ico = $box->ico;
         $this->description = $box->desc;
         $this->usergroup = $box->usergroup;
     } else {
         $this->position = '1';
         $this->url = '';
         $this->title = gT('Error');
         $this->description = gT('Unknown box ID!');
     }
 }
 public function validateAttribute($object, $attribute)
 {
     if ($object->{$attribute} == '' && $this->allowEmpty) {
         return;
     }
     if ($this->allowMultiple) {
         $aEmailAdresses = explode(';', $object->{$attribute});
     } else {
         $aEmailAdresses = array($object->{$attribute});
     }
     foreach ($aEmailAdresses as $sEmailAddress) {
         if (!validateEmailAddress($sEmailAddress)) {
             $this->addError($object, $attribute, gT('Invalid email address.'));
             return;
         }
     }
     return;
 }
Example #27
0
 public function run()
 {
     //If user is not logged in, don't print the version number information in the footer.
     if (empty(Yii::app()->session['loginID'])) {
         $versionnumber = "";
         $versiontitle = "";
         $buildtext = "";
     } else {
         $versionnumber = Yii::app()->getConfig("versionnumber");
         $versiontitle = gT('Version');
         $buildtext = "";
         if (Yii::app()->getConfig("buildnumber") != "") {
             $buildtext = "Build " . Yii::app()->getConfig("buildnumber");
         }
     }
     $aData = array('versionnumber' => $versionnumber, 'versiontitle' => $versiontitle, 'buildtext' => $buildtext);
     $this->render('footer', $aData);
 }
Example #28
0
 function index()
 {
     $aData = array();
     $needpermission = false;
     $aData['surveyid'] = $surveyid = $iSurveyID = sanitize_int(Yii::app()->request->getQuery('sid'));
     $aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index'));
     $aData['fullpagebar']['closebutton']['url'] = 'admin/';
     if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) {
         $needpermission = true;
     }
     if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         $message['title'] = gT('Access denied!');
         $message['message'] = gT('You do not have sufficient rights to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     } else {
         App()->getClientScript()->registerPackage('jqueryui');
         App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
         App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js");
         //App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css" );
         $this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'));
         $aData['pagetitle'] = "ExpressionManager:  {$aData['sa']}";
         if (isset($iSurveyID)) {
             $aData['sidebar']['state'] = "close";
             $surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
             $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
             if (Yii::app()->request->getQuery('gid') != '') {
                 $aData['questiongroupbar']['closebutton']['url'] = 'admin/questiongroups/sa/view/surveyid/' . $aData['surveyid'] . '/gid/' . sanitize_int(Yii::app()->request->getQuery('gid'));
             } else {
                 $aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $aData['surveyid'];
             }
             if (Yii::app()->request->getQuery('qid') != '') {
                 $aData['questiongroupbar']['closebutton']['url'] = 'admin/questions/sa/view/surveyid/' . $aData['surveyid'] . '/gid/' . sanitize_int(Yii::app()->request->getQuery('gid')) . '/qid/' . sanitize_int(Yii::app()->request->getQuery('qid'));
                 $aData['gid'] = sanitize_int(Yii::app()->request->getQuery('gid'));
             }
         }
         //header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding
         if (isset($_GET['sa'])) {
             $this->test($aData['sa'], $aData);
         } else {
             $this->_renderWrappedTemplate('expressions', 'test_view', $aData);
         }
     }
 }
 public function validateAttribute($object, $attribute)
 {
     if ($this->type == 'upper') {
         if (strtoupper($object->{$attribute}) == $object->{$attribute}) {
             return;
         } else {
             $this->addError($object, $attribute, gT('Text needs to be uppercase.'));
             return;
         }
     } else {
         if (strtolower($object->{$attribute}) == $object->{$attribute}) {
             return;
         } else {
             $this->addError($object, $attribute, gT('Text needs to be lowercase.'));
             return;
         }
     }
     return;
 }
Example #30
0
function dirReport($dir, $write)
{
    $error = 0;
    if ($dir == "Found") {
        $a = gT("Found");
    } else {
        $error = 1;
        $a = gT("Not found");
    }
    if ($write == "Writable") {
        $b = gT("Writable");
    } else {
        $error = 1;
        $b = gT("Unwritable");
    }
    if ($error) {
        return '<h3 class="label label-danger" style="font-size: 100%;">' . $a . ' &amp; ' . $b . '</h3>';
    } else {
        return $a . ' &amp; ' . $b;
    }
}