/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exists 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 all data for the item we want to edit $this->getData(); // load drafts $this->loadDrafts(); // load the datagrid with revisions $this->loadRevisions(); // load the form $this->loadForm(); // validate the form $this->validateForm(); // parse the datagrid $this->parse(); // display the page $this->display(); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Execute the action */ public function execute() { parent::execute(); // current status $from = \SpoonFilter::getGetValue('from', array('subscribed', 'moderation'), 'subscribed'); // action to execute $action = \SpoonFilter::getGetValue('action', array('subscribed', 'moderation', 'delete'), 'moderation'); // no id's provided if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('subscriptions') . '&error=no-subscriptions-selected'); } // redefine id's $ids = (array) $_GET['id']; // delete comment(s) if ($action == 'delete') { BackendAgendaModel::deleteSubscriptions($ids); } else { // set new status BackendAgendaModel::updateSubscriptionStatuses($ids, $action); } // define report $report = count($ids) > 1 ? 'subscriptions-' : 'subscription-'; // init var if ($action == 'subscribed') { $report .= 'moved-subscribed'; } if ($action == 'moderation') { $report .= 'moved-moderation'; } if ($action == 'delete') { $report .= 'deleted'; } // redirect $this->redirect(BackendModel::createURLForAction('subscriptions') . '&report=' . $report . '#tab' . \SpoonFilter::ucfirst($from)); }
/** * The user is allowed on this page * * @return bool */ private function isUserAllowed() { // catch the key and e-mail address from GET $this->email = urldecode(\SpoonFilter::getGetValue('email', null, '')); $this->key = \SpoonFilter::getGetValue('key', null, ''); // if the email or the key aren't set, redirect the user if ($this->email !== '' && $this->key !== '') { // fetch the user $userId = BackendUsersModel::getIdByEmail($this->email); $this->user = new BackendUser($userId); $requestTime = $this->user->getSetting('reset_password_timestamp'); // check if the request was made within 24 hours if (time() - $requestTime > 86400) { // remove the reset_password_key and reset_password_timestamp usersettings BackendUsersModel::deleteResetPasswordSettings($userId); // redirect to the login form, with a timeout error $this->redirect(BackendModel::createURLForAction('Index', null, null, array('reset' => 'timeout'))); } // check if the provided key matches the one in the user record if ($this->key === $this->user->getSetting('reset_password_key')) { return true; } } // if we made it here the user is not allowed to access this page return false; }
/** * 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 $term = SpoonFilter::getGetValue('term', null, ''); // validate if ($term == '') { $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.'); } // previous search result $previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : ''; SpoonSession::set('searchTerm', ''); // save this term? if ($previousTerm != $term) { // format data $this->statistics = array(); $this->statistics['term'] = $term; $this->statistics['language'] = FRONTEND_LANGUAGE; $this->statistics['time'] = FrontendModel::getUTCDate(); $this->statistics['data'] = serialize(array('server' => $_SERVER)); $this->statistics['num_results'] = FrontendSearchModel::getTotal($term); // save data FrontendSearchModel::save($this->statistics); } // save current search term in cookie SpoonSession::set('searchTerm', $term); // output $this->output(self::OK); }
/** * Execute the action * * @return void */ public function execute() { // set force compile on because we're using multiple forms on 1 page $this->tpl->setForceCompile(true); // get parameters $this->id = $this->getParameter('id', 'int'); // get the step $this->stepId = SpoonFilter::getGetValue('step', array(1, 2, 3, 4), 1, '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(); // load jquery tiny $this->header->addJS('tiny_mce/jquery.tinymce.js', 'core'); // get all data for the item we want to edit $this->getData(); // load the wizard steps $this->loadWizardSteps(); // load the appropriate step $this->{'loadStep' . $this->stepId}(); // parse $this->parse(); // display the page $this->display(); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * 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'); } }
public function __construct() { // if the application wasn't defined before we will define it if (!defined('NAMED_APPLICATION')) { define('NAMED_APPLICATION', 'frontend'); } // set the module $this->setModule(SpoonFilter::getGetValue('module', null, '')); // set the requested file $this->setFile(SpoonFilter::getGetValue('file', null, '')); // set the language $this->setLanguage(SpoonFilter::getGetValue('language', FrontendLanguage::getActiveLanguages(), SITE_DEFAULT_LANGUAGE)); // create a new template instance (this will handle all stuff for us) $tpl = new FrontendTemplate(); // enable addslashes on each locale $tpl->setAddSlashes(true); // set correct headers SpoonHTTP::setHeaders('content-type: application/javascript'); // fetch the template path if ($this->module == 'core') { $file = FRONTEND_CORE_PATH . '/js/' . $this->getFile(); } else { $file = FRONTEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile(); } // output the template $tpl->display(FrontendTheme::getPath($file), true); }
public function __construct() { // define the Named Application if (!defined('NAMED_APPLICATION')) { define('NAMED_APPLICATION', 'backend'); } // set the module $this->setModule(SpoonFilter::getGetValue('module', null, '')); // set the requested file $this->setFile(SpoonFilter::getGetValue('file', null, '')); // set the language $this->setLanguage(SpoonFilter::getGetValue('language', array_keys(BackendLanguage::getWorkingLanguages()), SITE_DEFAULT_LANGUAGE)); // build the path if ($this->module == 'core') { $path = BACKEND_CORE_PATH . '/js/' . $this->getFile(); } else { $path = BACKEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile(); } // set correct headers SpoonHTTP::setHeaders('content-type: application/javascript'); // create a new template instance (this will handle all stuff for us) $tpl = new BackendTemplate(); // enable addslashes on each locale $tpl->setAddSlashes(true); // display $tpl->display($path, true); }
/** * Execute the action */ public function execute() { parent::execute(); $this->addJS('https://maps.googleapis.com/maps/api/js?sensor=false', true, false); $this->addJS('/src/Frontend/Modules/Addresses/Js/markerclusterer.js', true, false); $this->addJS('/src/Frontend/Modules/Addresses/Js/bootstrap.min.js', true, false); $this->addJS('/src/Frontend/Modules/Addresses/Js/bootstrap-multiselect.js', true, false); $this->addCSS('/src/Frontend/Modules/Addresses/Layout/Css/bootstrap-multiselect.css', true, false); $this->addCSS('/src/Frontend/Modules/Addresses/Layout/Css/Addresses.css', true, false); //--Get search $this->search = urldecode(\SpoonFilter::getGetValue("search", null, "")); if ($this->search != "") { $this->lat = urldecode(\SpoonFilter::getGetValue("lat", null, "")); $this->lng = urldecode(\SpoonFilter::getGetValue("lng", null, "")); } $this->addJSData('search', $this->search); $this->addJSData('lat', $this->lat); $this->addJSData('lng', $this->lng); $this->searchGroups = \SpoonFilter::getGetValue("groups", null, array(), 'array'); //$this ->searchTopGroups = (\SpoonFilter::getGetValue("topgroups", null, array(),'array')); $this->loadTemplate(); $this->loadData(); $this->loadForm(); $this->parse(); }
/** * Load the form */ private function loadForm() { $this->imageIsAllowed = BackendModel::getModuleSetting($this->URL->getModule(), 'show_image_form', true); $this->frm = new BackendForm('add'); // set hidden values $rbtHiddenValues[] = array('label' => BL::lbl('Hidden', $this->URL->getModule()), 'value' => 'Y'); $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N'); // get categories $categories = BackendBlogModel::getCategories(); $categories['new_category'] = SpoonFilter::ucfirst(BL::getLabel('AddCategory')); // create elements $this->frm->addText('title', null, null, 'inputText title', 'inputTextError title'); $this->frm->addEditor('text'); $this->frm->addEditor('introduction'); $this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N'); $this->frm->addCheckbox('allow_comments', BackendModel::getModuleSetting($this->getModule(), 'allow_comments', false)); $this->frm->addDropdown('category_id', $categories, SpoonFilter::getGetValue('category', null, null, 'int')); if (count($categories) != 2) { $this->frm->getField('category_id')->setDefaultElement(''); } $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), BackendAuthentication::getUser()->getUserId()); $this->frm->addText('tags', null, null, 'inputText tagBox', 'inputTextError tagBox'); $this->frm->addDate('publish_on_date'); $this->frm->addTime('publish_on_time'); if ($this->imageIsAllowed) { $this->frm->addImage('image'); } // meta $this->meta = new BackendMeta($this->frm, null, 'title', true); }
/** * 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']); }
/** * Execute the action * * @return void */ public function execute() { // 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; } else { // get category $this->category = BackendBlogModel::getCategory($this->categoryId); // reset if (empty($this->category)) { // reset GET to trick Spoon $_GET['category'] = null; // reset $this->categoryId = null; } } // load datagrid $this->loadDataGrids(); // parse page $this->parse(); // display the page $this->display(); }
/** * Default constructor * * @return void */ public function __construct() { // set the module $this->setModule(SpoonFilter::getGetValue('module', null, '')); // set the action $this->setAction(SpoonFilter::getGetValue('action', null, '')); // set the language $this->setLanguage(SpoonFilter::getGetValue('language', null, '')); // create a new action $action = new FrontendAJAXAction($this->getAction(), $this->getModule()); // attempt to execute this action try { // execute the action $action->execute(); } catch (Exception $e) { // if we are debugging, we obviously want to see the exception if (SPOON_DEBUG) { throw $e; } // create fake action $fakeAction = new FrontendBaseAJAXAction('', ''); // output the exceptions-message as an error $fakeAction->output(FrontendBaseAJAXAction::ERROR, null, $e->getMessage()); } }
/** * Default constructor * * @return void */ public function __construct() { // check if the user is logged in $this->validateLogin(); // named application if (!defined('NAMED_APPLICATION')) { define('NAMED_APPLICATION', 'backend_ajax'); } // set the module $this->setModule(SpoonFilter::getGetValue('module', null, '')); // set the action $this->setAction(SpoonFilter::getGetValue('action', null, '')); // set the language $this->setLanguage(SpoonFilter::getGetValue('language', null, '')); // create a new action $action = new BackendAJAXAction($this->getAction(), $this->getModule()); // try to execute try { // execute the action $action->execute(); } catch (Exception $e) { // set correct headers SpoonHTTP::setHeadersByCode(500); // if we are debugging we should see the exceptions if (SPOON_DEBUG) { throw $e; } // output $fakeAction = new BackendBaseAJAXAction('', ''); $fakeAction->output(BackendBaseAJAXAction::ERROR, null, $e->getMessage()); } }
/** * 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; } } }
/** * 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 == '') { // no action provided $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-action-selected'); } elseif (!BackendFormBuilderModel::exists($formId)) { // valid form id $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); } }
/** * 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 */ public function execute() { parent::execute(); // action to execute $action = SpoonFilter::getGetValue('action', array('deleteImages', 'deleteFiles', 'deleteVideos'), 'delete'); if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('index') . '&error=no-selection'); } else { // redefine id's $aIds = (array) $_GET['id']; $agendaID = (int) $_GET['agenda_id']; // delete media if ($action == 'deleteImages') { BackendAgendaModel::deleteImage($aIds); } else { if ($action == 'deleteFiles') { BackendAgendaModel::deleteFile($aIds); } else { if ($action == 'deleteVideos') { BackendAgendaModel::deleteVideo($aIds); } } } } $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $agendaID . '&report=deleted'); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the id $id = \SpoonFilter::getGetValue('id', null, 0); //--Export users BackendMailengineModel::exportUsers($id); }
/** * Execute the action */ public function execute() { parent::execute(); $this->groupId = SpoonFilter::getGetValue('group_id', null, 0, 'int'); $this->downloadExampleFile(); $this->loadForm(); $this->validateForm(); $this->parse(); $this->display(); }
/** * Execute the extra */ public function execute() { // check if an email was given $this->group = SpoonFilter::getGetValue('group', null, ''); $this->email = urldecode(SpoonFilter::getGetValue('email', null, '')); $this->loadTemplate(); $this->loadForm(); $this->validateForm(); $this->parse(); }
/** * Check if the token is ok */ public function checkToken() { $fromSession = \SpoonSession::exists('csrf_token') ? \SpoonSession::get('csrf_token') : ''; $fromGet = \SpoonFilter::getGetValue('token', null, ''); if ($fromSession != '' && $fromGet != '' && $fromSession == $fromGet) { return; } // clear the token \SpoonSession::set('csrf_token', ''); $this->redirect(BackendModel::createURLForAction('Index', null, null, array('error' => 'csrf'))); }
/** * Gets data related to custom fields */ private function getData() { // get passed group ID $id = \SpoonFilter::getGetValue('group_id', null, 0, 'int'); // fetch group record $this->group = BackendMailmotorModel::getGroup($id); // group doesn't exist if (empty($this->group)) { $this->redirect(BackendModel::createURLForAction('Groups') . '&error=non-existing'); } }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init vars $this->cachePath = BACKEND_CACHE_PATH . '/analytics'; // get parameters $page = trim(SpoonFilter::getGetValue('page', null, '')); $pageId = trim(SpoonFilter::getGetValue('page_id', null, '')); $identifier = trim(SpoonFilter::getGetValue('identifier', null, '')); $startTimestamp = (int) trim(SpoonFilter::getGetValue('start_date', null, '')); $endTimestamp = (int) trim(SpoonFilter::getGetValue('end_date', null, '')); $force = trim(SpoonFilter::getGetValue('force', array('Y', 'N'), 'N')) == 'Y'; $filename = null; // no parameters given? cronjob called if ($page == '' && $identifier == '' && $startTimestamp === 0 && $endTimestamp === 0) { // is everything still set? if (BackendAnalyticsHelper::getStatus() != 'UNAUTHORIZED') { // get interval $interval = BackendModel::getModuleSetting('analytics', 'interval', 'week'); if ($interval == 'week') { $interval .= ' -2 days'; } // redefine vars $page = 'all'; $startTimestamp = strtotime('-1' . $interval); $endTimestamp = time(); } } elseif ($page != '' && $identifier != '' && $startTimestamp !== 0 && $endTimestamp !== 0) { // init vars $filename = $this->cachePath . '/' . $page . ($pageId != '' ? '_' . $pageId : '') . '_' . $identifier . '.txt'; // is everything still set? if (BackendAnalyticsHelper::getStatus() != 'UNAUTHORIZED') { // create temporary file to indicate we're getting data SpoonFile::setContent($filename, 'busy1'); } else { // set status in cache SpoonFile::setContent($filename, 'unauthorized'); // stop here return; } } else { throw new SpoonException('Some parameters are missing.'); } // get dashboard data $this->getDashboardData(); // get data $this->getData($startTimestamp, $endTimestamp, $force, $page, $pageId, $filename); // cleanup cache $this->cleanupCache(); // cleanup database $this->cleanupDatabase(); }
public function testGetGetValue() { // setup $_GET['id'] = '1337'; $_GET['type'] = 'web'; $_GET['animal'] = 'donkey'; // perform tests $this->assertEquals(0, SpoonFilter::getGetValue('category_id', null, 0, 'int')); $this->assertEquals(1337, SpoonFilter::getGetValue('id', null, 0, 'int')); $this->assertEquals('web', SpoonFilter::getGetValue('type', array('web', 'print'), 'print')); $this->assertEquals('whale', SpoonFilter::getGetValue('animal', array('whale', 'horse'), 'whale')); $this->assertEquals('donkey', SpoonFilter::getGetValue('animal', null, 'whale')); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the id $this->id = \SpoonFilter::getGetValue('id', null, 0, 'int'); //--Check if mailing exist if (!FrontendMailengineModel::extistSend($this->id)) { $this->redirect(FrontendNavigation::getURL(404)); } $this->loadTemplate(); $this->loadData(); $this->parse(); }
/** * Execute the action */ public function execute() { parent::execute(); // action to execute $id = SpoonFilter::getGetValue('id', null, 0); // no id's provided if (!BackendMailmotorModel::existsMailing($id)) { $this->redirect(BackendModel::createURLForAction('index') . '&error=mailing-does-not-exist'); } else { BackendMailmotorModel::exportStatistics($id); } // redirect $this->redirect(BackendModel::createURLForAction('groups') . '&report=export-failed'); }
/** * 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 $term = SpoonFilter::getGetValue('term', null, ''); // validate if ($term == '') { $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.'); } // get tags $tags = BackendTagsModel::getStartsWith($term); // output $this->output(self::OK, $tags); }
/** * Execute the action */ public function execute() { parent::execute(); // action to execute $id = \SpoonFilter::getGetValue('id', null, 0); // no id's provided if (!BackendMailmotorModel::existsCampaign($id)) { $this->redirect(BackendModel::createURLForAction('Campaigns') . '&error=campaign-does-not-exist'); } else { // at least one id BackendMailmotorModel::exportStatisticsByCampaignID($id); } // redirect $this->redirect(BackendModel::createURLForAction('Groups') . '&report=export-failed'); }
/** * 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 $id = SpoonFilter::getGetValue('id', null, 0); // no id's provided if (!BackendMailmotorModel::existsCampaign($id)) { $this->redirect(BackendModel::createURLForAction('campaigns') . '&error=campaign-does-not-exist'); } else { BackendMailmotorModel::exportStatisticsByCampaignID($id); } // redirect $this->redirect(BackendModel::createURLForAction('groups') . '&report=export-failed'); }