/** * Parse the form */ protected function parse() { parent::parse(); // assign the data $this->tpl->assign('item', $this->record); $this->tpl->assign('showDeleteCategory', BackendFaqModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('delete_category')); }
/** * 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)); }
/** * Load the datagrid */ public function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendGroupsModel::QRY_BROWSE); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('edit') . '&id=[id]'); $this->dataGrid->setColumnURL('num_users', BackendModel::createURLForAction('edit') . '&id=[id]#tabUsers'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]'); } }
/** * Load the datagrids */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendContentBlocksModel::QRY_BROWSE, array('active', BL::getWorkingLanguage())); $this->dataGrid->setSortingColumns(array('title')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Parse into template */ private function parse() { // check if this action is allowed if (BackendAuthentication::isAllowedAction('settings', 'analytics')) { // parse redirect link $this->tpl->assign('settingsUrl', BackendModel::createURLForAction('settings', 'analytics')); } $this->parseKeywords(); $this->parseReferrers(); }
/** * Load the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendExtensionsModel::QRY_BROWSE_TEMPLATES, array($this->selectedTheme)); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit_theme_template')) { // set colum URLs $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_theme_template') . '&id=[id]'); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_theme_template') . '&id=[id]', BL::lbl('Edit')); } }
/** * Load the datagrid. */ private function loadDataGrid() { // create datagrid with an overview of all active and undeleted users $this->dataGrid = new BackendDataGridDB(BackendUsersModel::QRY_BROWSE, array('N')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { // add column $this->dataGrid->addColumn('nickname', SpoonFilter::ucfirst(BL::lbl('Nickname')), null, BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]'); } // show the user's nickname $this->dataGrid->setColumnFunction(array('BackendUser', 'getSettingByUserId'), array('[id]', 'nickname'), 'nickname', false); }
/** * Checks the settings and optionally returns an array with warnings * * @return array */ public static function checkSettings() { $warnings = array(); // check if this action is allowed if (BackendAuthentication::isAllowedAction('settings', 'mailmotor')) { // analytics session token if (BackendModel::getModuleSetting('mailmotor', 'cm_account') == false) { $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMAccount', 'mailmotor'), BackendModel::createURLForAction('settings', 'mailmotor'))); } elseif (BackendModel::getModuleSetting('mailmotor', 'cm_client_id') == '') { // add warning $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMClientID', 'mailmotor'), BackendModel::createURLForAction('settings', 'mailmtor'))); } } return $warnings; }
/** * Load the data grid for installed modules. */ private function loadDataGridInstalled() { // create datagrid $this->dataGridInstalledModules = new BackendDataGridArray($this->installedModules); $this->dataGridInstalledModules->setSortingColumns(array('name')); $this->dataGridInstalledModules->setColumnsHidden(array('installed', 'raw_name', 'cronjobs_active')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('detail_module')) { $this->dataGridInstalledModules->setColumnURL('name', BackendModel::createURLForAction('detail_module') . '&module=[raw_name]'); $this->dataGridInstalledModules->addColumn('details', null, BL::lbl('Details'), BackendModel::createURLForAction('detail_module') . '&module=[raw_name]', BL::lbl('Details')); } // add the greyed out option to modules that have warnings $this->dataGridInstalledModules->addColumn('hidden'); $this->dataGridInstalledModules->setColumnFunction(array('BackendExtensionsModel', 'hasModuleWarnings'), array('[raw_name]'), array('hidden')); }
/** * Checks the settings and optionally returns an array with warnings * * @return array */ public static function checkSettings() { $warnings = array(); // check if this action is allowed if (BackendAuthentication::isAllowedAction('settings', 'blog')) { // rss title if (BackendModel::getModuleSetting('blog', 'rss_title_' . BL::getWorkingLanguage(), null) == '') { $warnings[] = array('message' => sprintf(BL::err('RSSTitle', 'blog'), BackendModel::createURLForAction('settings', 'blog'))); } // rss description if (BackendModel::getModuleSetting('blog', 'rss_description_' . BL::getWorkingLanguage(), null) == '') { $warnings[] = array('message' => sprintf(BL::err('RSSDescription', 'blog'), BackendModel::createURLForAction('settings', 'blog'))); } } return $warnings; }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_SYNONYMS, BL::getWorkingLanguage()); // sorting columns $this->dataGrid->setSortingColumns(array('term'), 'term'); // column function $this->dataGrid->setColumnFunction('str_replace', array(',', ', ', '[synonym]'), 'synonym', true); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit_synonym')) { // set colum URLs $this->dataGrid->setColumnURL('term', BackendModel::createURLForAction('edit_synonym') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_synonym') . '&id=[id]', BL::lbl('Edit')); } }
/** * Checks the settings and optionally returns an array with warnings * * @return array */ public static function checkSettings() { $warnings = array(); // check if debug-mode is active if (SPOON_DEBUG) { $warnings[] = array('message' => BL::err('DebugModeIsActive')); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('index', 'settings')) { // check if the fork API keys are available if (self::getModuleSetting('core', 'fork_api_private_key') == '' || self::getModuleSetting('core', 'fork_api_public_key') == '') { $warnings[] = array('message' => sprintf(BL::err('ForkAPIKeys'), BackendModel::createURLForAction('index', 'settings'))); } } // check for extensions warnings $warnings = array_merge($warnings, BackendExtensionsModel::checkSettings()); return $warnings; }
/** * Loads the dataGrid */ private function loadDataGrid() { // create dataGrid $this->dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage()); $this->dataGrid->setHeaderLabels(array('num_items' => SpoonFilter::ucfirst(BL::lbl('Amount')))); $this->dataGrid->enableSequenceByDragAndDrop(); $this->dataGrid->setRowAttributes(array('id' => '[id]')); $this->dataGrid->setPaging(false); // check if this action is allowed if (BackendAuthentication::isAllowedAction('index')) { $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('index') . '&category=[id]'), 'num_items', true); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit_category')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_category') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit')); } }
/** * You have to specify the action and module so we know what to do with this instance * * @param string $action The action to load. * @param string $module The module to load. */ public function __construct($action, $module) { $this->setModule($module); $this->setAction($action); $this->loadConfig(); $allowed = false; // is this an allowed action if (BackendAuthentication::isAllowedAction($action, $this->getModule())) { $allowed = true; } // is this an allowed AJAX-action? if (!$allowed) { // set correct headers SpoonHTTP::setHeadersByCode(403); // output $fakeAction = new BackendBaseAJAXAction('', ''); $fakeAction->output(BackendBaseAJAXAction::FORBIDDEN, null, 'Not logged in.'); } }
/** * Parse amount of forms sent for the datagrid * * @param int $formId Id of the form. * @param int $sentForms Amount of sent forms. * @return string */ public static function parseNumForms($formId, $sentForms) { // redefine $formId = (int) $formId; $sentForms = (int) $sentForms; // one form sent if ($sentForms == 1) { $output = BL::getMessage('OneSentForm'); } elseif ($sentForms > 1) { $output = sprintf(BL::getMessage('SentForms'), $sentForms); } else { $output = sprintf(BL::getMessage('SentForms'), $sentForms); } // check if data action is allowed if (BackendAuthentication::isAllowedAction('data', 'form_builder')) { // output $output = '<a href="' . BackendModel::createURLForAction('data') . '&id=' . $formId . '" title="' . $output . '">' . $output . '</a>'; } return $output; }
/** * Parse this page */ protected function parse() { parent::parse(); $results = BackendAnalyticsModel::getLandingPages($this->startTimestamp, $this->endTimestamp); if (!empty($results)) { $dataGrid = new BackendDataGridArray($results); $dataGrid->setColumnsHidden('start_date', 'end_date', 'updated_on', 'page_encoded'); $dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('detail_page', $this->getModule())) { $dataGrid->setColumnURL('page_path', BackendModel::createURLForAction('detail_page') . '&page=[page_encoded]'); } // set headers $dataGrid->setHeaderLabels(array('page_path' => SpoonFilter::ucfirst(BL::lbl('Page')))); // 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()); } }
/** * Loads the datagrid with the groups */ 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'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('addresses')) { // 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); // check if this action is allowed if (BackendAuthentication::isAllowedAction('custom_fields')) { $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')); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('export_addresses')) { $this->dataGrid->addColumnAction('export', null, BL::lbl('Export'), BackendModel::createURLForAction('export_addresses') . '&id=[id]', BL::lbl('Export'), array('class' => 'button icon iconExport linkButton')); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit_group')) { $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); }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_CATEGORIES, array('active', BL::getWorkingLanguage())); // set headers $this->dataGrid->setHeaderLabels(array('num_items' => SpoonFilter::ucfirst(BL::lbl('Amount')))); // sorting columns $this->dataGrid->setSortingColumns(array('title', 'num_items'), 'title'); // convert the count into a readable and clickable one $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('index') . '&category=[id]'), 'num_items', true); // disable paging $this->dataGrid->setPaging(false); // add attributes, so the inline editing has all the needed data $this->dataGrid->setColumnAttributes('title', array('data-id' => '{id:[id]}')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit_category')) { // set column URLs $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_category') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit')); } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendTagsModel::QRY_DATAGRID_BROWSE, BL::getWorkingLanguage()); // header labels $this->dataGrid->setHeaderLabels(array('tag' => SpoonFilter::ucfirst(BL::lbl('Name')), 'num_tags' => SpoonFilter::ucfirst(BL::lbl('Amount')))); // sorting columns $this->dataGrid->setSortingColumns(array('tag', 'num_tags'), 'num_tags'); $this->dataGrid->setSortParameter('desc'); // add the multicheckbox column $this->dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // add mass action dropdown $ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete'); $ddmMassAction->setOptionAttributes('delete', array('message-id' => 'confirmDelete')); $this->dataGrid->setMassAction($ddmMassAction); // add attributes, so the inline editing has all the needed data $this->dataGrid->setColumnAttributes('tag', array('data-id' => '{id:[id]}')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Load the record */ private function loadData() { // get record $this->id = $this->getParameter('id', 'int'); // validate id if ($this->id === null || !BackendExtensionsModel::existsTemplate($this->id)) { $this->redirect(BackendModel::createURLForAction('theme_templates') . '&error=non-existing'); } // get the record $this->record = BackendExtensionsModel::getTemplate($this->id); // unserialize $this->record['data'] = unserialize($this->record['data']); $this->names = $this->record['data']['names']; if (isset($this->record['data']['default_extras_' . BL::getWorkingLanguage()])) { $this->extras = $this->record['data']['default_extras_' . BL::getWorkingLanguage()]; } elseif (isset($this->record['data']['default_extras'])) { $this->extras = $this->record['data']['default_extras']; } // assign $this->tpl->assign('template', $this->record); // is the template being used $inUse = BackendExtensionsModel::isTemplateInUse($this->id); // determine if deleting is allowed $deleteAllowed = true; if ($this->record['id'] == BackendModel::getModuleSetting('pages', 'default_template')) { $deleteAllowed = false; } elseif (count(BackendExtensionsModel::getTemplates()) == 1) { $deleteAllowed = false; } elseif ($inUse) { $deleteAllowed = false; } elseif (!BackendAuthentication::isAllowedAction('delete_theme_template')) { $deleteAllowed = false; } // assign $this->tpl->assign('inUse', $inUse); $this->tpl->assign('showExtensionsDeleteThemeTemplate', $deleteAllowed); }
/** * Loads the datagrid with the campaigns */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendMailmotorModel::QRY_DATAGRID_BROWSE_CAMPAIGNS); // set headers values $headers['name'] = SpoonFilter::ucfirst(BL::lbl('Title')); $headers['created_on'] = SpoonFilter::ucfirst(BL::lbl('Created')); // set headers $this->dataGrid->setHeaderLabels($headers); // sorting columns $this->dataGrid->setSortingColumns(array('name', 'created_on'), 'name'); $this->dataGrid->setSortParameter('desc'); // add the multicheckbox column $this->dataGrid->addColumn('checkbox', '<span class="checkboxHolder"><input type="checkbox" name="toggleChecks" value="toggleChecks" /></span>', '<span><input type="checkbox" name="id[]" value="[id]" class="inputCheckbox" /></span>'); $this->dataGrid->setColumnsSequence('checkbox'); // 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 statistics column $this->dataGrid->addColumn('statistics'); $this->dataGrid->setColumnAttributes('statistics', array('class' => 'action actionStatistics', 'width' => '10%')); $this->dataGrid->setColumnFunction(array(__CLASS__, 'setStatisticsLink'), array('[id]'), 'statistics', true); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_campaign') . '&id=[id]', BL::lbl('Edit')); // add styles $this->dataGrid->setColumnAttributes('name', array('class' => 'title')); // set paging limit $this->dataGrid->setPagingLimit(self::PAGING_LIMIT); // check if this action is allowed if (BackendAuthentication::isAllowedAction('index')) { // set column URLs $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('index') . '&campaign=[id]'); } }
/** * Parse. */ protected function parse() { parent::parse(); // assign theme data $this->tpl->assign('name', $this->currentTheme); $this->tpl->assign('warnings', $this->warnings); $this->tpl->assign('information', $this->information); $this->tpl->assign('showExtensionsInstallTheme', !BackendExtensionsModel::isThemeInstalled($this->currentTheme) && BackendAuthentication::isAllowedAction('install_theme')); // data grids $this->tpl->assign('dataGridTemplates', isset($this->dataGridTemplates) && $this->dataGridTemplates->getNumResults() > 0 ? $this->dataGridTemplates->getContent() : false); }
/** * Load the datagrid */ private function loadDataGrid() { // init vars $langWidth = 80 / count($this->filter['language']); // get all the translations for the selected languages $translations = BackendLocaleModel::getTranslations($this->filter['application'], $this->filter['module'], $this->filter['type'], $this->filter['language'], $this->filter['name'], $this->filter['value']); // create datagrids $this->dgLabels = new BackendDataGridArray(isset($translations['lbl']) ? $translations['lbl'] : array()); $this->dgMessages = new BackendDataGridArray(isset($translations['msg']) ? $translations['msg'] : array()); $this->dgErrors = new BackendDataGridArray(isset($translations['err']) ? $translations['err'] : array()); $this->dgActions = new BackendDataGridArray(isset($translations['act']) ? $translations['act'] : array()); // put the datagrids (references) in an array so we can loop them $dataGrids = array('lbl' => &$this->dgLabels, 'msg' => &$this->dgMessages, 'err' => &$this->dgErrors, 'act' => &$this->dgActions); // loop the datagrids (as references) foreach ($dataGrids as $type => &$dataGrid) { // set sorting $dataGrid->setSortingColumns(array('module', 'name'), 'name'); // disable paging $dataGrid->setPaging(false); // set column attributes for each language foreach ($this->filter['language'] as $lang) { // add a class for the inline edit $dataGrid->setColumnAttributes($lang, array('class' => 'translationValue')); // add attributes, so the inline editing has all the needed data $dataGrid->setColumnAttributes($lang, array('data-id' => '{language: \'' . $lang . '\', application: \'' . $this->filter['application'] . '\', module: \'[module]\', name: \'[name]\', type: \'' . $type . '\'}')); // escape the double quotes $dataGrid->setColumnFunction(array('SpoonFilter', 'htmlentities'), array('[' . $lang . ']', null, ENT_QUOTES), $lang, true); if ($type == 'act') { $dataGrid->setColumnFunction('urldecode', array('[' . $lang . ']'), $lang, true); } // set header labels $dataGrid->setHeaderLabels(array($lang => SpoonFilter::ucfirst(BL::getMessage(strtoupper($lang))))); // set column attributes $dataGrid->setColumnAttributes($lang, array('style' => 'width: ' . $langWidth . '%')); // hide translation_id column (only if only one language is selected because the key doesn't exist if more than 1 language is selected) if (count($this->filter['language']) == 1) { $dataGrid->setColumnHidden('translation_id'); } // only 1 language selected? if (count($this->filter['language']) == 1) { // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { // add edit button $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit', null, null, null) . '&id=[translation_id]' . $this->filterQuery); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('add')) { // add copy button $dataGrid->addColumnAction('copy', null, BL::lbl('Copy'), BackendModel::createURLForAction('add', null, null) . '&id=[translation_id]' . $this->filterQuery, array('class' => 'button icon iconCopy linkButton')); } } } } }
/** * Load the datagrids */ private function loadDataGrid() { list($query, $parameters) = $this->buildQuery(); // create datagrid $this->dataGrid = new BackendDataGridDB($query, $parameters); // overrule default URL $this->dataGrid->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]', 'start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date']), false) . '&id=' . $this->id); // sorting columns $this->dataGrid->setSortingColumns(array('sent_on'), 'sent_on'); $this->dataGrid->setSortParameter('desc'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('data_details')) { // set colum URLs $this->dataGrid->setColumnURL('sent_on', BackendModel::createURLForAction('data_details', null, null, array('start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date']), false) . '&id=[id]'); // add edit column $this->dataGrid->addColumn('details', null, BL::getLabel('Details'), BackendModel::createURLForAction('data_details', null, null, array('start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date'])) . '&id=[id]', BL::getLabel('Details')); } // date $this->dataGrid->setColumnFunction(array('BackendFormBuilderModel', 'calculateTimeAgo'), '[sent_on]', 'sent_on', false); $this->dataGrid->setColumnFunction('ucfirst', '[sent_on]', 'sent_on', false); // add the multicheckbox column $this->dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // mass action $ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::getLabel('Delete')), 'delete'); $ddmMassAction->setOptionAttributes('delete', array('data-message-id' => 'confirmDelete')); $this->dataGrid->setMassAction($ddmMassAction); }
/** * Redirect to the loading page after checking for infinite loops. * * @param string $action The action to check for infinite loops. * @param array[optional] $extraParameters The extra parameters to append to the redirect url. */ public static function redirectToLoadingPage($action, array $extraParameters = array()) { // get loop counter $counter = SpoonSession::exists($action . 'Loop') ? SpoonSession::get($action . 'Loop') : 0; // loop has run too long - throw exception if ($counter > 2) { throw new BackendException('An infinite loop has been detected while getting data from cache for the action "' . $action . '".'); } // set new counter SpoonSession::set($action . 'Loop', ++$counter); // put parameters into a string $extraParameters = empty($extraParameters) ? '' : '&' . http_build_query($extraParameters); // check if this action is allowed if (BackendAuthentication::isAllowedAction('loading', 'analytics')) { // redirect to loading page which will get the needed data based on the current action SpoonHTTP::redirect(BackendModel::createURLForAction('loading') . '&redirect_action=' . $action . $extraParameters); } }
/** * Load the datagrid with the recently edited items */ private function loadDataGridRecentlyEdited() { // create dgRecentlyEdited $this->dgRecentlyEdited = new BackendDataGridDB(BackendPagesModel::QRY_BROWSE_RECENT, array('active', BL::getWorkingLanguage(), 7)); // disable paging $this->dgRecentlyEdited->setPaging(false); // hide columns $this->dgRecentlyEdited->setColumnsHidden(array('id')); // set functions $this->dgRecentlyEdited->setColumnFunction(array('BackendDataGridFunctions', 'getUser'), array('[user_id]'), 'user_id'); $this->dgRecentlyEdited->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[edited_on]'), 'edited_on'); // set headers $this->dgRecentlyEdited->setHeaderLabels(array('user_id' => SpoonFilter::ucfirst(BL::lbl('By')), 'edited_on' => SpoonFilter::ucfirst(BL::lbl('LastEdited')))); // check if allowed to edit if (BackendAuthentication::isAllowedAction('edit', $this->getModule())) { // set column URL $this->dgRecentlyEdited->setColumnUrl('title', BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); // add column $this->dgRecentlyEdited->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Parse */ protected function parse() { parent::parse(); // set $this->record['url'] = $this->meta->getURL(); if ($this->id == 1) { $this->record['url'] = ''; } // parse some variables $this->tpl->assign('item', $this->record); $this->tpl->assign('isGod', $this->isGod); $this->tpl->assign('templates', $this->templates); $this->tpl->assign('positions', $this->positions); $this->tpl->assign('extrasData', json_encode(BackendExtensionsModel::getExtrasData())); $this->tpl->assign('extrasById', json_encode(BackendExtensionsModel::getExtras())); $this->tpl->assign('prefixURL', rtrim(BackendPagesModel::getFullURL($this->record['parent_id']), '/')); $this->tpl->assign('formErrors', (string) $this->frm->getErrors()); // init var $showDelete = true; // has children? if (BackendPagesModel::getFirstChildId($this->record['id']) !== false) { $showDelete = false; } if (!$this->record['delete_allowed']) { $showDelete = false; } // allowed? if (!BackendAuthentication::isAllowedAction('delete', $this->getModule())) { $showDelete = false; } // show delete button $this->tpl->assign('showPagesDelete', $showDelete); // assign template $this->tpl->assignArray($this->templates[$this->record['template_id']], 'template'); // parse datagrids $this->tpl->assign('revisions', $this->dgRevisions->getNumResults() != 0 ? $this->dgRevisions->getContent() : false); $this->tpl->assign('drafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false); // parse the tree $this->tpl->assign('tree', BackendPagesModel::getTreeHTML()); }
/** * Parse the form */ protected function parse() { parent::parse(); // reset avatar URL if ($this->record['settings']['avatar'] != '') { $this->record['settings']['avatar'] .= '?time=' . time(); } // only allow deletion of other users $this->tpl->assign('showUsersDelete', BackendAuthentication::getUser()->getUserId() != $this->id && BackendAuthentication::isAllowedAction('delete')); // assign $this->tpl->assign('record', $this->record); $this->tpl->assign('id', $this->id); // assign that we're god or the same user $this->tpl->assign('allowPasswordEdit', BackendAuthentication::getUser()->getUserId() == $this->id || BackendAuthentication::getUser()->isGod()); }
/** * Parse the settings for the authenticated user */ private function parseAuthenticatedUser() { // check if the current user is authenticated if (BackendAuthentication::getUser()->isAuthenticated()) { // show stuff that only should be visible if authenticated $this->assign('isAuthenticated', true); // get authenticated user-settings $settings = (array) BackendAuthentication::getUser()->getSettings(); foreach ($settings as $key => $setting) { // redefine setting $setting = $setting === null ? '' : $setting; // assign setting $this->assign('authenticatedUser' . SpoonFilter::toCamelCase($key), $setting); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit', 'users')) { // assign special vars $this->assign('authenticatedUserEditUrl', BackendModel::createURLForAction('edit', 'users', null, array('id' => BackendAuthentication::getUser()->getUserId()))); } } }
/** * Is this widget allowed for this user? * * @return bool */ public function isAllowed() { // loop all rights foreach ($this->rights as $rights) { // define vars list($module, $action) = explode('/', $rights); // not exactly 2 vars if (isset($module) && isset($action)) { if (!BackendAuthentication::isAllowedAction($action, $module)) { return false; } } } // everything turned out just fine return true; }