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); } } }
static function handle_shortcode($atts) { self::$add_script = true; extract(shortcode_atts(array('header' => false, 'type' => false, 'source' => false, 'class' => false, 'amount' => 8, 'show' => 3, 'layout' => 'slick'), $atts, 'boxes')); global $post; $boxes = new stdClass(); $boxes->cache = new stdClass(); $boxes->objects = false; $boxes->site_url = site_url(); $boxes->links_type = 'normal'; $boxes->post = $post; foreach ($atts as $key => $value) { $boxes->{$key} = $value; } //Convert Shortcode attributes to object values if (empty($boxes->layout)) { $boxes->layout = 'slick'; } $parsed_classes = explode(' ', $class); $boxes->child_classes = ''; if ($boxes->layout === 'masonry') { $col_width = 6; if ($boxes->show < 5) { $col_width = 12 / $boxes->show; } array_push($parsed_classes, 'thin-padding'); $boxes->child_classes = 'col-sm-6 col-md-' . $col_width; $boxes->srcType = 'src'; $boxes->amount = $boxes->show; } $boxes->class = implode(' ', $parsed_classes); $props = array(); foreach ($parsed_classes as $prop) { $props[$prop] = true; } $boxes->props = $props; //$debug = $boxes->props; //Feed Type switch ($type) { case 'instagram': $boxes->objects = boxesInstagram($boxes); $target = '_blank'; break; case 'twitter': $boxes->objects = new stdClass(); //boxesInstagram($boxes); $boxes->id = "live"; $target = '_blank'; break; case 'vimeo': $vid_url = parse_url($boxes->source); $boxes->source = $vid_url['path']; $boxes->id = preg_replace('/[^\\da-z]/i', '', $vid_url['path']); $boxes->cache->function_name = 'boxesVimeo'; $boxes->cache->cache_name = 'vimeo'; //$boxes->cache->json = true; $boxes->objects = cacheHandler($boxes); if ($boxes->post->post_name === 'watch') { $boxes->links_type = 'hash'; } $target = '_self'; break; case 'events': $boxes->id = $source; $boxes->cache->function_name = 'boxesEvents'; $boxes->cache->cache_name = 'events'; $boxes->objects = cacheHandler($boxes); break; case 'category': $boxes->id = $source; $boxes->cache->function_name = 'boxesCategory'; $boxes->cache->cache_name = 'category'; $boxes->objects = cacheHandler($boxes); break; case 'youtube': echo $source; break; case 'acf': echo $source; break; default: echo 'Nothing here'; } ob_start(); ?> <?php if (isset($props['double-stacked'])) { $boxes->show = $boxes->show * 2; } $i = 0; ?> <div id="boxes-<?php echo $type; ?> -<?php echo $boxes->id; ?> " class="box-boxes boxes-<?php echo $type; ?> <?php echo 'boxes-' . $boxes->layout; ?> <?php echo $boxes->class; ?> " data-source="<?php echo $boxes->source; ?> " > <?php if (!empty($boxes->header)) { ?> <div class="boxes-header"> <h3 class="spaced"><?php echo $boxes->header; ?> </h3> <hr> </div> <?php } ?> <div class="frame container-fluid" data-show="<?php echo $boxes->show; ?> "> <ul class="easecubic row"> <?php if ($boxes->objects) { foreach ($boxes->objects as $key => $box) { ?> <?php //Reset $boxes->child_class to prevent stacking $boxes->child_class = $boxes->child_classes; if (isset($props['date-format-human'])) { $normal_date = $box->date_unix; if (strtotime($box->title)) { $normal_date = strtotime($box->title); } $box->title = ago($normal_date); } //Hash Links if ($boxes->links_type === 'hash') { $box->link = '#' . $box->id; } if (empty($boxes->srcType)) { $box->srcType = 'src="' . get_template_directory_uri() . '/assets/img/blank.gif" data-lazy'; } else { $box->srcType = $boxes->srcType; } //if( $key < $boxes->show ) $box->srcType = "src";//if is showing don't lazyload if ($boxes->layout === 'masonry' && $box->index >= $boxes->amount) { $boxes->child_class = $boxes->child_class . ' box-lazyload ease-opacity'; $box->srcType = 'src="' . get_template_directory_uri() . '/assets/img/blank.gif" data-src'; } ?> <?php if (!isset($props['double-stacked']) || $box->index % 2 != 0 || !$box->index) { ?> <li class="<?php echo $boxes->child_class; ?> " ><?php } ?> <div id="box-<?php echo $type; ?> -<?php echo $box->id; ?> " class="box-box box-<?php echo $box->type; ?> easecubic" style="<?php //BG Color Overlay if (isset($box->color)) { ?> background: <?php echo $box->color; ?> ; <?php //#000000 } ?> "> <a href="<?php echo $box->link; ?> " target="<?php echo $target; ?> " > <div class="box-image"> <img class="easecubic" <?php echo $box->srcType; ?> ="<?php echo $box->image_url; ?> " alt="<?php echo $box->title . ' - ' . $box->date; ?> " > </div> <div class="box-header easecubic" style=""> <div class="box-header-content"> <h3><?php echo parse_title($box->title); ?> </h3> <div class="box-date easecubic"><?php echo $box->date; ?> </div> </div> </div> <div class="box-caption easecubic"><p><?php echo parse_title($box->desc); ?> </p></div> </a> </div> <?php if (!isset($props['double-stacked']) || $box->index % 2 === 0 || !$box->index) { ?> </li><?php } ?> <?php } /* foreach($boxes->objects) */ } /* if( $boxes->objects ) */ ?> </ul> </div> </div> <?php $content = ob_get_clean(); //debug( $debug ); return $content; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id, $boxId = null, $quantity = null) { $model = $this->loadModel($id); $Boxes = new Boxes('search'); $Boxes->unsetAttributes(); // clear any default values if (isset($_GET['Boxes'])) { $Boxes->attributes = $_GET['Boxes']; } if ($quantity) { $model->quantity = $quantity; } if ($boxId) { $items = new CActiveDataProvider('BoxItem', array('criteria' => array('condition' => 'box_id=' . (int) $boxId))); $SelectedBox = Box::model()->findByPk($boxId); $model->box_id = $boxId; } else { $items = new CActiveDataProvider('BoxItem', array('criteria' => array('condition' => 'box_id=' . $model->box_id))); $SelectedBox = $model->Box; } if (isset($_POST['UserBox'])) { $model->attributes = $_POST['UserBox']; $model->delivery_cost = $model->total_delivery_price; if ($model->save()) { $this->redirect(array('admin', 'id' => $model->user_box_id)); } } $this->render('update', array('model' => $model, 'Boxes' => $Boxes, 'items' => $items, 'SelectedBox' => $SelectedBox)); }