/** * Execute the action */ public function execute() { parent::execute(); BackendAuthentication::logout(); // redirect to login-screen $this->redirect(BackendModel::createUrlForAction('index', $this->getModule())); }
/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlogModel::exists($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // set category id $this->categoryId = SpoonFilter::getGetValue('category', null, null, 'int'); if ($this->categoryId == 0) { $this->categoryId = null; } // get data $this->record = (array) BackendBlogModel::get($this->id); // delete item BackendBlogModel::delete($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); // delete search indexes if (is_callable(array('BackendSearchModel', 'removeIndex'))) { BackendSearchModel::removeIndex($this->getModule(), $this->id); } // build redirect URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']); // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // item was deleted, so redirect $this->redirect($redirectUrl); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Validates the settings form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); if ($this->frm->isCorrect()) { // set the base values $width = (int) $this->frm->getField('width_widget')->getValue(); $height = (int) $this->frm->getField('height_widget')->getValue(); if ($width > 800) { $width = 800; } elseif ($width < 300) { $width = BackendModel::getModuleSetting('location', 'width_widget'); } if ($height < 150) { $height = BackendModel::getModuleSetting('location', 'height_widget'); } // set our settings (widgets) BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'width_widget', $width); BackendModel::setModuleSetting($this->URL->getModule(), 'height_widget', $height); BackendModel::setModuleSetting($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue()); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_saved_settings'); // redirect to the settings page $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved'); } } }
/** * Validate the form. */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // get field $txtName = $this->frm->getField('name'); // name filled in? if ($txtName->isFilled(BL::getError('NameIsRequired'))) { // name exists? if (BackendProfilesModel::existsGroupName($txtName->getValue())) { // set error $txtName->addError(BL::getError('GroupNameExists')); } } // no errors? if ($this->frm->isCorrect()) { // build item $values['name'] = $txtName->getValue(); // insert values $id = BackendProfilesModel::insertGroup($values); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $values)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('groups') . '&report=group-added&var=' . urlencode($values['name']) . '&highlight=row-' . $id); } } }
/** * Execute the action */ public function execute() { parent::execute(); // action to execute $action = SpoonFilter::getGetValue('action', array('delete', 'export'), ''); $this->groupId = SpoonFilter::getGetValue('group_id', null, ''); // no id's provided if (!$action) { $this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-action-selected'); } if (!isset($_GET['emails'])) { $this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-items-selected'); } else { // redefine id's $this->emails = (array) $_GET['emails']; // evaluate $action, see what action was triggered switch ($action) { case 'delete': $this->deleteAddresses(); break; case 'export': $this->exportAddresses(); break; } } }
/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlogModel::existsCategory($this->id)) { // get data $this->record = (array) BackendBlogModel::getCategory($this->id); // allowed to delete the category? if (BackendBlogModel::deleteCategoryAllowed($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // delete item BackendBlogModel::deleteCategory($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id)); // category was deleted, so redirect $this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title'])); } } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing'); } }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int'); $sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y')); $sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i')); $messageDate = $sendOnDate; // validate mailing ID if ($mailingId == '') { $this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID'); } if ($sendOnDate == '' || $sendOnTime == '') { $this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided'); } // record is empty if (!BackendMailmotorModel::existsMailing($mailingId)) { $this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor')); } // reverse the date and make it a proper $explodedDate = explode('/', $sendOnDate); $sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0]; // calc full send timestamp $sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime); // build data $item['id'] = $mailingId; $item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp); $item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); // update mailing BackendMailmotorModel::updateMailing($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item)); // output $this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime)); }
/** * Loads the dataGrids */ private function loadDatagrids() { // load all categories $categories = BackendFaqModel::getCategories(true); // loop categories and create a dataGrid for each one foreach ($categories as $categoryId => $categoryTitle) { $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId)); $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop')); $dataGrid->setColumnsHidden(array('category_id', 'sequence')); $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>'); $dataGrid->setColumnsSequence('dragAndDropHandle'); $dataGrid->setColumnAttributes('question', array('class' => 'title')); $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle')); $dataGrid->setRowAttributes(array('id' => '[id]')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { $dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]'); $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); } // add dataGrid to list $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent()); } // set empty datagrid $this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => ''))); $this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid')); $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null)); }
/** * Execute the action. */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendProfilesModel::exists($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get item $profile = BackendProfilesModel::get($this->id); // already blocked? Prolly want to unblock then if ($profile['status'] === 'blocked') { // set profile status to active BackendProfilesModel::update($this->id, array('status' => 'active')); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_unblock', array('id' => $this->id)); // redirect $this->redirect(BackendModel::createURLForAction('index') . '&report=profile-unblocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id); } else { // delete profile session that may be active BackendProfilesModel::deleteSession($this->id); // set profile status to blocked BackendProfilesModel::update($this->id, array('status' => 'blocked')); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_block', array('id' => $this->id)); // redirect $this->redirect(BackendModel::createURLForAction('index') . '&report=profile-blocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id); } } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
public function __construct() { parent::__construct(); $this->uid = $this->session->userdata('uid'); $this->lang->load('vars', 'romanian'); $this->load->model('admin_model'); }
/** * Execute the widget * * @return void */ public function execute() { // analytics session token and analytics table id if (BackendModel::getModuleSetting('analytics', 'session_token', null) == '') { return; } if (BackendModel::getModuleSetting('analytics', 'table_id', null) == '') { return; } // settings are ok, set option $this->tpl->assign('analyticsValidSettings', true); // set column $this->setColumn('right'); // set position $this->setPosition(0); // add css $this->header->addCSS('widgets.css', 'analytics'); // add highchart javascript $this->header->addJS('highcharts.js', 'analytics'); $this->header->addJS('analytics.js', 'analytics'); // parse $this->parse(); // display $this->display(); }
/** * Loads the datagrid with the groups * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendMailmotorModel::QRY_DATAGRID_BROWSE_GROUPS); $this->dataGrid->setColumnsHidden(array('language', 'is_default')); // sorting columns $this->dataGrid->setSortingColumns(array('name', 'created_on'), 'created_on'); $this->dataGrid->setSortParameter('desc'); // set colum URLs $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('addresses') . '&group_id=[id]'); // set the datagrid ID so we don't run into trouble with multiple datagrids that use mass actions $this->dataGrid->setAttributes(array('id' => 'dgGroups')); // add the multicheckbox column $this->dataGrid->setMassActionCheckboxes('checkbox', '[id]', BackendMailmotorModel::getDefaultGroupIds()); $this->dataGrid->setColumnsSequence('checkbox', 'name', 'created_on', 'language'); // add mass action dropdown $ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete'); $this->dataGrid->setMassAction($ddmMassAction); // set column functions $this->dataGrid->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[created_on]'), 'created_on', true); // add delete column $this->dataGrid->addColumnAction('custom_fields', null, BL::lbl('CustomFields'), BackendModel::createURLForAction('custom_fields') . '&group_id=[id]', BL::lbl('CustomFields'), array('class' => 'button icon iconEdit linkButton')); $this->dataGrid->addColumnAction('export', null, BL::lbl('Export'), BackendModel::createURLForAction('export_addresses') . '&id=[id]', BL::lbl('Export'), array('class' => 'button icon iconExport linkButton')); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_group') . '&id=[id]', BL::lbl('Edit')); // add styles $this->dataGrid->setColumnAttributes('name', array('class' => 'title')); // set paging limit $this->dataGrid->setPagingLimit(self::PAGING_LIMIT); }
/** * Execute the action */ public function execute() { parent::execute(); BackendBlogModel::deleteSpamComments(); // item was deleted, so redirect $this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam'); }
/** * Execute the action */ public function execute() { // get parameters $this->id = $this->getParameter('mailing_id', 'int'); // does the item exist if (BackendMailmotorModel::existsMailing($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // fetch the mailing $mailing = BackendMailmotorModel::getMailing($this->id); // get all data for the user we want to edit $records = (array) BackendMailmotorCMHelper::getCM()->getCampaignBounces($mailing['cm_id']); // reset some data if (!empty($records)) { // loop the records foreach ($records as $record) { // only remove the hard bounces if ($record['bounce_type'] == 'Hard') { // remove the address BackendMailmotorModel::deleteAddresses($record['email']); } } } // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_bounces'); // user was deleted, so redirect $this->redirect(BackendModel::createURLForAction('statistics') . '&id=' . $mailing['id'] . '&report=deleted-bounces'); } else { $this->redirect(BackendModel::createURLForAction('statistics') . '&error=no-bounces'); } }
/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init vars $templates = array(); $theme = BackendModel::getModuleSetting('core', 'theme'); $files[] = BACKEND_PATH . '/core/layout/editor_templates/templates.js'; $themePath = FRONTEND_PATH . '/themes/' . $theme . '/core/layout/editor_templates/templates.js'; if (SpoonFile::exists($themePath)) { $files[] = $themePath; } // loop all files foreach ($files as $file) { // process file $templates = array_merge($templates, $this->processFile($file)); } // set headers SpoonHTTP::setHeaders('Content-type: text/javascript'); // output the templates if (!empty($templates)) { echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n"; echo json_encode($templates) . "\n"; echo '});'; } exit; }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // shorten fields $txtName = $this->frm->getField('name'); $rbtDefaultForLanguage = $this->frm->getField('default'); // validate fields if ($txtName->isFilled(BL::err('NameIsRequired'))) { // check if the group exists by name if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) { $txtName->addError(BL::err('GroupAlreadyExists')); } } // no errors? if ($this->frm->isCorrect()) { // build item $item['name'] = $txtName->getValue(); $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); $item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue(); $item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N'; // insert the item $item['id'] = BackendMailmotorCMHelper::insertGroup($item); // check if all default groups were set BackendMailmotorModel::checkDefaultGroups(); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']); } } }
/** * Execute the action */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendExtensionsModel::existsTemplate($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init var $success = false; // get template (we need the title) $item = BackendExtensionsModel::getTemplate($this->id); // valid template? if (!empty($item)) { // delete the page $success = BackendExtensionsModel::deleteTemplate($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_template', array('id' => $this->id)); } // page is deleted, so redirect to the overview if ($success) { $this->redirect(BackendModel::createURLForAction('theme_templates') . '&theme=' . $item['theme'] . '&report=deleted-template&var=' . urlencode($item['label'])); } else { $this->redirect(BackendModel::createURLForAction('theme_templates') . '&error=non-existing'); } } else { $this->redirect(BackendModel::createURLForAction('theme_templates') . '&error=non-existing'); } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate field $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired')); $this->frm->getField('term')->isFilled(BL::err('TermIsRequired')); if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) { $this->frm->getField('term')->addError(BL::err('TermExists')); } // no errors? if ($this->frm->isCorrect()) { // build item $item = array(); $item['term'] = $this->frm->getField('term')->getValue(); $item['synonym'] = $this->frm->getField('synonym')->getValue(); $item['language'] = BL::getWorkingLanguage(); // insert the item $id = BackendSearchModel::insertSynonym($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('synonyms') . '&report=added-synonym&var=' . urlencode($item['term']) . '&highlight=row-' . $id); } } }
/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // action to execute $id = SpoonFilter::getGetValue('id', null, 0); // no id's provided if (empty($id) || !BackendMailmotorModel::existsMailing($id)) { $this->redirect(BackendModel::createURLForAction('index') . '&error=mailing-does-not-exist'); } else { // get the mailing and reset some fields $mailing = BackendMailmotorModel::getMailing($id); $mailing['status'] = 'concept'; $mailing['send_on'] = null; $mailing['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); $mailing['edited_on'] = $mailing['created_on']; $mailing['data'] = serialize($mailing['data']); unset($mailing['recipients'], $mailing['id'], $mailing['cm_id'], $mailing['send_on_raw']); // set groups $groups = $mailing['groups']; unset($mailing['groups']); // create a new mailing based on the old one $newId = BackendMailmotorModel::insertMailing($mailing); // update groups for this mailing BackendMailmotorModel::updateGroupsForMailing($newId, $groups); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_copy_mailing', array('item' => $mailing)); } // redirect $this->redirect(BackendModel::createURLForAction('index') . '&report=mailing-copied&var=' . $mailing['name']); }
/** * Get User Permissions * * Obtiene los permisos de un usario, si es la primera vez que se ejecuta, * consulta a la base de datos, si no, obtiene el contenido de la variable * estáticamente protegida. * * @author Adrián Méndez <*****@*****.**> * @Version 1.0 */ public function getUserPermissions() { if (is_null(self::$permissions)) { self::$permissions = $this->getAllRows(array('from' => 'permisos')); } return self::$permissions; }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get parameters $id = SpoonFilter::getPostValue('id', null, '', 'int'); $name = trim(SpoonFilter::getPostValue('value', null, '', 'string')); // validate if ($name == '') { $this->output(self::BAD_REQUEST, null, 'no name provided'); } // get existing id $existingId = BackendMailmotorModel::getCampaignId($name); // existing campaign if ($existingId !== 0 && $id !== $existingId) { $this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule())); } // build array $item = array(); $item['id'] = $id; $item['name'] = $name; $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); // get page $rows = BackendMailmotorModel::updateCampaign($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item)); // output if ($rows !== 0) { $this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule())); } else { $this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule())); } }
/** * Get warnings for active modules * * @return array */ public static function getWarnings() { // init vars $warnings = array(); $activeModules = BackendModel::getModules(true); // add warnings $warnings = array_merge($warnings, BackendModel::checkSettings()); // loop active modules foreach ($activeModules as $module) { // model class $class = 'Backend' . SpoonFilter::toCamelCase($module) . 'Model'; // model file exists if (SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php')) { // require class require_once BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php'; } // method exists if (is_callable(array($class, 'checkSettings'))) { // add possible warnings $warnings = array_merge($warnings, call_user_func(array($class, 'checkSettings'))); } } // return return (array) $warnings; }
/** * Validates the settings form * * @return void */ private function validateForm() { // form is submitted if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // form is validated if ($this->frm->isCorrect()) { // set our settings (overview map) BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level', (string) $this->frm->getField('zoom_level')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'width', (int) $this->frm->getField('width')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'height', (int) $this->frm->getField('height')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'map_type', (string) $this->frm->getField('map_type')->getValue()); // set our settings (widgets) BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'width_widget', (int) $this->frm->getField('width_widget')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'height_widget', (int) $this->frm->getField('height_widget')->getValue()); BackendModel::setModuleSetting($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue()); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_saved_settings'); // redirect to the settings page $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved'); } } }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // action to execute $action = SpoonFilter::getGetValue('action', array('delete'), ''); // get passed group ID $id = SpoonFilter::getGetValue('group_id', null, 0, 'int'); // fetch group record $this->group = BackendMailmotorModel::getGroup($id); // set redirect URL $redirectURL = BackendModel::createURLForAction('custom_fields') . '&group_id=' . $this->group['id']; // no id's provided if (!$action) { $this->redirect($redirectURL . '&error=no-action-selected'); } if (!isset($_GET['fields'])) { $this->redirect($redirectURL . '&error=no-items-selected'); } if (empty($this->group)) { $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing'); } else { // redefine id's $this->fields = (array) $_GET['fields']; // evaluate $action, see what action was triggered switch ($action) { case 'delete': $this->deleteCustomFields(); break; } } }
/** * Parse this page * * @return void */ protected function parse() { // call parent parse parent::parse(); // get results $results = BackendAnalyticsModel::getLandingPages($this->startTimestamp, $this->endTimestamp); // there are some results if (!empty($results)) { // get the datagrid $dataGrid = new BackendDataGridArray($results); // hide columns $dataGrid->setColumnsHidden('start_date', 'end_date', 'updated_on', 'page_encoded'); // set headers values $headers['page_path'] = ucfirst(BL::lbl('Page')); // set headers $dataGrid->setHeaderLabels($headers); // set url $dataGrid->setColumnURL('page_path', BackendModel::createURLForAction('detail_page') . '&page=[page_encoded]'); // add the multicheckbox column $dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // add mass action dropdown $ddmMassAction = new SpoonFormDropdown('action', array('delete_landing_page' => BL::lbl('Delete')), 'delete'); $dataGrid->setMassAction($ddmMassAction); // parse the datagrid $this->tpl->assign('dgPages', $dataGrid->getContent()); } }
/** * Execute the action */ public function execute() { parent::execute(); // action to execute $action = SpoonFilter::getGetValue('action', array('delete'), ''); // form id $formId = SpoonFilter::getGetValue('form_id', null, '', 'int'); // no id's provided if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('index') . '&error=no-items-selected'); } elseif ($action == '') { $this->redirect(BackendModel::createURLForAction('index') . '&error=no-action-selected'); } elseif (!BackendFormBuilderModel::exists($formId)) { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } else { // redefine id's $ids = (array) $_GET['id']; // delete comment(s) if ($action == 'delete') { BackendFormBuilderModel::deleteData($ids); } // define report $report = count($ids) > 1 ? 'items-' : 'item-'; // init var if ($action == 'delete') { $report .= 'deleted'; } // redirect $this->redirect(BackendModel::createURLForAction('data') . '&id=' . $formId . '&report=' . $report); } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // redefine fields $fileFile = $this->frm->getField('file'); $chkOverwrite = $this->frm->getField('overwrite'); // name checks if ($fileFile->isFilled(BL::err('FieldIsRequired'))) { // only xml files allowed if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) { // load xml $xml = @simplexml_load_file($fileFile->getTempFileName()); // invalid xml if ($xml === false) { $fileFile->addError(BL::getError('InvalidXML')); } } } if ($this->frm->isCorrect()) { // import $statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue()); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics)); // everything is imported, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery); } } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); if ($this->frm->isCorrect()) { // build item $item['id'] = BackendContentBlocksModel::getMaximumId() + 1; $item['user_id'] = BackendAuthentication::getUser()->getUserId(); $item['template'] = count($this->templates) > 1 ? $this->frm->getField('template')->getValue() : $this->templates[0]; $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['hidden'] = $this->frm->getField('hidden')->getValue() ? 'N' : 'Y'; $item['status'] = 'active'; $item['created_on'] = BackendModel::getUTCDate(); $item['edited_on'] = BackendModel::getUTCDate(); // insert the item $item['revision_id'] = BackendContentBlocksModel::insert($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Load the datagrids * * @return void */ private function loadDataGrids() { // load all categories $categories = BackendFaqModel::getCategories(); // run over categories and create datagrid for each one foreach ($categories as $category) { // create datagrid $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $category['id'])); // set attributes $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop')); // disable paging $dataGrid->setPaging(false); // set colum URLs $dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]'); // set colums hidden $dataGrid->setColumnsHidden(array('category_id', 'sequence')); // add edit column $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); // add a column for the handle, so users have something to hold while draging $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>'); // make sure the column with the handler is the first one $dataGrid->setColumnsSequence('dragAndDropHandle'); // add a class on the handler column, so JS knows this is just a handler $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle')); // our JS needs to know an id, so we can send the new order $dataGrid->setRowAttributes(array('id' => '[id]')); // add datagrid to list $this->dataGrids[] = array('id' => $category['id'], 'name' => $category['name'], 'content' => $dataGrid->getContent()); } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // set callback for generating an unique URL $this->meta->setURLCallback('BackendBlogModel', 'getURLForCategory'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['meta_id'] = $this->meta->save(); // insert the item $item['id'] = BackendBlogModel::insertCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }