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!'); } }
protected function setValuesFromDb() { $box = Boxes::model()->find(array('condition' => 'position=:positionId', 'params' => array(':positionId' => $this->dbPosition))); if ($box) { $this->position = $box->position; if (!preg_match("/^(http|https)/", $box->url)) { $this->url = Yii::app()->createUrl($box->url); } else { $this->url = $box->url; $this->external = true; } $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!'); } }
function upgradeSurveyTables251() { Yii::app()->db->createCommand()->addColumn('{{boxes}}', 'ico', 'string'); // add $box = Boxes::model()->findByPk('1'); $box->ico = 'add'; $box->title = 'Create survey'; $box->save(); // list $box = Boxes::model()->findByPk('2'); $box->ico = 'list'; $box->save(); //settings $box = Boxes::model()->findByPk('3'); $box->ico = 'settings'; $box->save(); //shield $box = Boxes::model()->findByPk('4'); $box->ico = 'shield'; $box->save(); //label $box = Boxes::model()->findByPk('5'); $box->ico = 'label'; $box->save(); //templates $box = Boxes::model()->findByPk('6'); $box->ico = 'templates'; $box->save(); }
function upgradeSurveyTables255() { // We delete all the old boxes, and reinsert new ones Boxes::model()->deleteAll(); // Then we recreate them $oDB = Yii::app()->db; $oDB->createCommand()->insert('{{boxes}}', array('position' => '1', 'url' => 'admin/survey/sa/newsurvey', 'title' => 'Create survey', 'ico' => 'add', 'desc' => 'Create a new survey', 'page' => 'welcome', 'usergroup' => '-2')); $oDB->createCommand()->insert('{{boxes}}', array('position' => '2', 'url' => 'admin/survey/sa/listsurveys', 'title' => 'List surveys', 'ico' => 'list', 'desc' => 'List available surveys', 'page' => 'welcome', 'usergroup' => '-1')); $oDB->createCommand()->insert('{{boxes}}', array('position' => '3', 'url' => 'admin/globalsettings', 'title' => 'Global settings', 'ico' => 'global', 'desc' => 'Edit global settings', 'page' => 'welcome', 'usergroup' => '-2')); $oDB->createCommand()->insert('{{boxes}}', array('position' => '4', 'url' => 'admin/update', 'title' => 'ComfortUpdate', 'ico' => 'shield', 'desc' => 'Stay safe and up to date', 'page' => 'welcome', 'usergroup' => '-2')); $oDB->createCommand()->insert('{{boxes}}', array('position' => '5', 'url' => 'admin/labels/sa/view', 'title' => 'Label sets', 'ico' => 'labels', 'desc' => 'Edit label sets', 'page' => 'welcome', 'usergroup' => '-2')); $oDB->createCommand()->insert('{{boxes}}', array('position' => '6', 'url' => 'admin/templates/sa/view', 'title' => 'Template editor', 'ico' => 'templates', 'desc' => 'Edit LimeSurvey templates', 'page' => 'welcome', 'usergroup' => '-2')); }
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/customerbox/_form.js', CClientScript::POS_END); ?> <div class="form"> <?php $form = $this->beginWidget('application.widgets.SnapActiveForm', array('id' => 'customer-box-form', 'enableAjaxValidation' => false)); ?> <?php echo $form->errorSummary($model); ?> <?php $this->widget('bootstrap.widgets.BsGridView', array('id' => 'box-sizes-grid', 'dataProvider' => $Boxes->search(), 'filter' => $Boxes, 'summaryText' => '', 'selectionChanged' => 'selectBox', 'enablePagination' => false, 'enableSorting' => false, 'columns' => array(array('name' => 'size_id', 'value' => '$data->BoxSize->box_size_name', 'filter' => CHtml::listData(BoxSize::model()->findAll(), 'id', 'box_size_name')), array('name' => 'box_price', 'filter' => CHtml::listData(Boxes::model()->findAll(array('order' => 'box_price')), 'box_price', 'box_price')), array('name' => 'delivery_date_id', 'value' => 'Yii::app()->dateFormatter->format("EEE, MMM d",$data->DeliveryDate->date)', 'filter' => CHtml::listData(DeliveryDate::model()->findAll(array('order' => 'date')), 'id', 'date'))))); ?> <div class="row quantity"> <?php echo $form->labelEx($model, 'quantity'); ?> <?php echo $form->textField($model, 'quantity', array('class' => 'number')); ?> <?php echo $form->error($model, 'quantity'); ?> </div> <div id="selected-box"> <?php
private function _saveSettings() { if ($_POST['action'] !== "globalsettingssave") { return; } if (!Permission::model()->hasGlobalPermission('settings', 'update')) { $this->getController()->redirect(array('/admin')); } Yii::app()->loadHelper('surveytranslator'); $iPDFFontSize = sanitize_int($_POST['pdffontsize']); if ($iPDFFontSize < 1) { $iPDFFontSize = 9; } $iPDFLogoWidth = sanitize_int($_POST['pdflogowidth']); if ($iPDFLogoWidth < 1) { $iPDFLogoWidth = 50; } $maxemails = $_POST['maxemails']; if (sanitize_int($_POST['maxemails']) < 1) { $maxemails = 1; } $defaultlang = sanitize_languagecode($_POST['defaultlang']); $aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages'])); if (!in_array($defaultlang, $aRestrictToLanguages)) { // Force default language in restrictToLanguages $aRestrictToLanguages[] = $defaultlang; } if (count(array_diff(array_keys(getLanguageData(false, Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) { $aRestrictToLanguages = ''; } else { $aRestrictToLanguages = implode(' ', $aRestrictToLanguages); } setGlobalSetting('defaultlang', $defaultlang); setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages)); setGlobalSetting('sitename', strip_tags($_POST['sitename'])); setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode'])); setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode'])); setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode'])); if (!Yii::app()->getConfig('demoMode')) { $sTemplate = Yii::app()->getRequest()->getPost("defaulttemplate"); if (array_key_exists($sTemplate, getTemplateList())) { setGlobalSetting('defaulttemplate', $sTemplate); } } // we set the admin theme $sAdmintheme = sanitize_paranoid_string($_POST['admintheme']); setGlobalSetting('admintheme', $sAdmintheme); // we check if it's a user theme $usertemplatethemerootdir = Yii::app()->getConfig("uploaddir") . '/admintheme/' . $sAdmintheme; if ($usertemplatethemerootdir && file_exists($usertemplatethemerootdir) && is_dir($usertemplatethemerootdir)) { $adminimagebaseurl = Yii::app()->getBaseUrl(true) . "/upload/admintheme/{$sAdmintheme}/images/"; setGlobalSetting('adminimagebaseurl', $adminimagebaseurl); setGlobalSetting('adminimageurl', $adminimagebaseurl . 'images/14/'); } else { $adminimagebaseurl = Yii::app()->getBaseUrl(true) . "/styles/{$sAdmintheme}/images/"; setGlobalSetting('adminimagebaseurl', $adminimagebaseurl); setGlobalSetting('adminimageurl', $adminimagebaseurl . '/14/'); } //setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir").DIRECTORY_SEPARATOR.sanitize_paranoid_string($_POST['admintheme']).DIRECTORY_SEPARATOR.'iconsize'))); setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod'])); setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost'))); if (returnGlobal('emailsmtppassword') != 'somepassword') { setGlobalSetting('emailsmtppassword', strip_tags(returnGlobal('emailsmtppassword'))); } setGlobalSetting('bounceaccounthost', strip_tags(returnGlobal('bounceaccounthost'))); setGlobalSetting('bounceaccounttype', strip_tags(returnGlobal('bounceaccounttype'))); setGlobalSetting('bounceencryption', strip_tags(returnGlobal('bounceencryption'))); setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser'))); if (returnGlobal('bounceaccountpass') != 'enteredpassword') { setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass'))); } setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl', ''))); setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug', '0'))); setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser'))); setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml'])); $warning = ''; // make sure emails are valid before saving them if (Yii::app()->request->getPost('siteadminbounce', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminbounce'))) { setGlobalSetting('siteadminbounce', strip_tags(Yii::app()->request->getPost('siteadminbounce'))); } else { $warning .= gT("Warning! Admin bounce email was not saved because it was not valid.") . '<br/>'; } if (Yii::app()->request->getPost('siteadminemail', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminemail'))) { setGlobalSetting('siteadminemail', strip_tags(Yii::app()->request->getPost('siteadminemail'))); } else { $warning .= gT("Warning! Admin email was not saved because it was not valid.") . '<br/>'; } setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname'])); setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer'])); setGlobalSetting('showxquestions', $_POST['showxquestions']); setGlobalSetting('showgroupinfo', $_POST['showgroupinfo']); setGlobalSetting('showqnumcode', $_POST['showqnumcode']); $repeatheadingstemp = (int) $_POST['repeatheadings']; if ($repeatheadingstemp == 0) { $repeatheadingstemp = 25; } setGlobalSetting('repeatheadings', $repeatheadingstemp); setGlobalSetting('maxemails', sanitize_int($maxemails)); $iSessionExpirationTime = (int) $_POST['iSessionExpirationTime']; if ($iSessionExpirationTime == 0) { $iSessionExpirationTime = 7200; } setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime); setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']); setGlobalSetting('pdffontsize', $iPDFFontSize); setGlobalSetting('pdfshowheader', $_POST['pdfshowheader']); setGlobalSetting('pdflogowidth', $iPDFLogoWidth); setGlobalSetting('pdfheadertitle', $_POST['pdfheadertitle']); setGlobalSetting('pdfheaderstring', $_POST['pdfheaderstring']); setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']); setGlobalSetting('googleanalyticsapikey', $_POST['googleanalyticsapikey']); setGlobalSetting('googletranslateapikey', $_POST['googletranslateapikey']); setGlobalSetting('force_ssl', $_POST['force_ssl']); setGlobalSetting('surveyPreview_require_Auth', $_POST['surveyPreview_require_Auth']); setGlobalSetting('RPCInterface', $_POST['RPCInterface']); setGlobalSetting('rpc_publish_api', (bool) $_POST['rpc_publish_api']); $savetime = (double) $_POST['timeadjust'] * 60 . ' minutes'; //makes sure it is a number, at least 0 if (substr($savetime, 0, 1) != '-' && substr($savetime, 0, 1) != '+') { $savetime = '+' . $savetime; } setGlobalSetting('timeadjust', $savetime); setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy'])); // Boxes for ($i = 1; $i < 7; $i++) { $box = Boxes::model()->find(array('condition' => 'position=:positionId', 'params' => array(':positionId' => $i))); $box->url = sanitize_html_string($_POST['box-url-' . $i]); $box->title = sanitize_html_string($_POST['box-title-' . $i]); $box->ico = sanitize_html_string($_POST['box-ico-' . $i]); $box->desc = sanitize_html_string($_POST['box-desc-' . $i]); $box->save(); } Yii::app()->session['flashmessage'] = $warning . gT("Global settings were saved."); // Redirect if user clicked save-and-close-button if (isset($_POST['saveandclose'])) { $url = htmlspecialchars_decode(Yii::app()->session['refurl']); if ($url) { Yii::app()->getController()->redirect($url); } else { $url = Yii::app()->createUrl('admin'); Yii::app()->getController()->redirect($url); } } }