/** * 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() { parent::execute(); BackendAuthentication::logout(); // redirect to login-screen $this->redirect(BackendModel::createUrlForAction('index', $this->getModule())); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired')); $this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired')); $this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['meta_id'] = $this->meta->save(); $item['category_id'] = $this->frm->getField('category_id')->getValue(); $item['user_id'] = BackendAuthentication::getUser()->getUserId(); $item['language'] = BL::getWorkingLanguage(); $item['question'] = $this->frm->getField('title')->getValue(); $item['answer'] = $this->frm->getField('answer')->getValue(true); $item['created_on'] = BackendModel::getUTCDate(); $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1; // save the data $item['id'] = BackendFaqModel::insert($item); BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // add search index BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer'])); $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']); } } }
/** * 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 settings form */ private function loadForm() { $this->isGod = BackendAuthentication::getUser()->isGod(); $this->frm = new BackendForm('settings'); // add fields for pagination $this->frm->addDropdown('overview_number_of_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'overview_num_items', 10)); $this->frm->addDropdown('recent_articles_full_number_of_items', array_combine(range(1, 10), range(1, 10)), BackendModel::getModuleSetting($this->URL->getModule(), 'recent_articles_full_num_items', 5)); $this->frm->addDropdown('recent_articles_list_number_of_items', array_combine(range(1, 10), range(1, 10)), BackendModel::getModuleSetting($this->URL->getModule(), 'recent_articles_list_num_items', 5)); // add fields for spam $this->frm->addCheckbox('spamfilter', BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false)); // no Akismet-key, so we can't enable spam-filter if (BackendModel::getModuleSetting('core', 'akismet_key') == '') { $this->frm->getField('spamfilter')->setAttribute('disabled', 'disabled'); $this->tpl->assign('noAkismetKey', true); } // add fields for comments $this->frm->addCheckbox('allow_comments', BackendModel::getModuleSetting($this->URL->getModule(), 'allow_comments', false)); $this->frm->addCheckbox('moderation', BackendModel::getModuleSetting($this->URL->getModule(), 'moderation', false)); // add fields for notifications $this->frm->addCheckbox('notify_by_email_on_new_comment_to_moderate', BackendModel::getModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', false)); $this->frm->addCheckbox('notify_by_email_on_new_comment', BackendModel::getModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment', false)); // add fields for SEO $this->frm->addCheckbox('ping_services', BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false)); // add fields for RSS $this->frm->addCheckbox('rss_meta', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), true)); $this->frm->addText('rss_title', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage())); $this->frm->addTextarea('rss_description', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage())); $this->frm->addText('feedburner_url', BackendModel::getModuleSetting($this->URL->getModule(), 'feedburner_url_' . BL::getWorkingLanguage())); // god user? if ($this->isGod) { $this->frm->addCheckbox('show_image_form', BackendModel::getModuleSetting($this->URL->getModule(), 'show_image_form', true)); } }
/** * 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); }
/** * Output a CSV-file as a download * * @param string $filename The name of the file. * @param array $array The array to convert. * @param array[optional] $columns The column names you want to use. * @param array[optional] $excludeColumns The columns you want to exclude. */ public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null) { // get settings $splitCharacter = BackendAuthentication::getUser()->getSetting('csv_split_character'); $lineEnding = BackendAuthentication::getUser()->getSetting('csv_line_ending'); // reformat if ($lineEnding == '\\n') { $lineEnding = "\n"; } if ($lineEnding == '\\r\\n') { $lineEnding = "\r\n"; } // convert into CSV $csv = SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding); // set headers for download $headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET; $headers[] = 'Content-Disposition: attachment; filename="' . $filename; $headers[] = 'Content-Length: ' . strlen($csv); $headers[] = 'Pragma: no-cache'; // overwrite the headers SpoonHTTP::setHeaders($headers); // ouput the CSV echo $csv; exit; }
/** * 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 form */ private function loadForm() { $this->isGod = BackendAuthentication::getUser()->isGod(); $this->frm = new BackendForm('settingsEmail'); // email settings $mailerFrom = BackendModel::getModuleSetting('core', 'mailer_from'); $this->frm->addText('mailer_from_name', isset($mailerFrom['name']) ? $mailerFrom['name'] : ''); $this->frm->addText('mailer_from_email', isset($mailerFrom['email']) ? $mailerFrom['email'] : ''); $mailerTo = BackendModel::getModuleSetting('core', 'mailer_to'); $this->frm->addText('mailer_to_name', isset($mailerTo['name']) ? $mailerTo['name'] : ''); $this->frm->addText('mailer_to_email', isset($mailerTo['email']) ? $mailerTo['email'] : ''); $mailerReplyTo = BackendModel::getModuleSetting('core', 'mailer_reply_to'); $this->frm->addText('mailer_reply_to_name', isset($mailerReplyTo['name']) ? $mailerReplyTo['name'] : ''); $this->frm->addText('mailer_reply_to_email', isset($mailerReplyTo['email']) ? $mailerReplyTo['email'] : ''); if ($this->isGod) { $mailerType = BackendModel::getModuleSetting('core', 'mailer_type', 'mail'); $this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType); // smtp settings $this->frm->addText('smtp_server', BackendModel::getModuleSetting('core', 'smtp_server', '')); $this->frm->addText('smtp_port', BackendModel::getModuleSetting('core', 'smtp_port', 25)); $this->frm->addText('smtp_username', BackendModel::getModuleSetting('core', 'smtp_username', '')); $this->frm->addPassword('smtp_password', BackendModel::getModuleSetting('core', 'smtp_password', '')); } $this->tpl->assign('isGod', $this->isGod); }
/** * Parse into template */ private function parse() { // get the logged in user $authenticatedUser = BackendAuthentication::getUser(); // check if we need to show the password strength and parse the label $this->tpl->assign('showPasswordStrength', $authenticatedUser->getSetting('password_strength') !== 'strong'); $this->tpl->assign('passwordStrengthLabel', BL::lbl($authenticatedUser->getSetting('password_strength'))); }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // log out the current user BackendAuthentication::logout(); // redirect to login-screen $this->redirect(BackendModel::createUrlForAction('index', $this->getModule())); }
/** * 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 $newSequence = SpoonFilter::getPostValue('new_sequence', null, ''); // validate if ($newSequence == '') { $this->output(self::BAD_REQUEST, null, 'no new_sequence provided'); } // convert into array $json = @json_decode($newSequence, true); // validate if ($json === false) { $this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided'); } // initialize $userSequence = array(); $hiddenItems = array(); // loop columns foreach ($json as $column => $widgets) { $columnValue = 'left'; if ($column == 1) { $columnValue = 'middle'; } if ($column == 2) { $columnValue = 'right'; } // loop widgets foreach ($widgets as $sequence => $widget) { // store position $userSequence[$widget['module']][$widget['widget']] = array('column' => $columnValue, 'position' => $sequence, 'hidden' => $widget['hidden'], 'present' => $widget['present']); // add to array if ($widget['hidden']) { $hiddenItems[] = $widget['module'] . '_' . $widget['widget']; } } } // get previous setting $currentSetting = BackendAuthentication::getUser()->getSetting('dashboard_sequence'); $data['reload'] = false; // any settings? if ($currentSetting !== null) { // loop modules foreach ($currentSetting as $module => $widgets) { foreach ($widgets as $widget => $values) { if ($values['hidden'] && isset($userSequence[$module][$widget]['hidden']) && !$userSequence[$module][$widget]['hidden']) { $data['reload'] = true; } } } } // store BackendAuthentication::getUser()->setSetting('dashboard_sequence', $userSequence); // output $this->output(self::OK, $data, BL::msg('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(); // user is god? $isGod = BackendAuthentication::getUser()->isGod(); // get possible languages if ($isGod) { $possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages())); } else { $possibleLanguages = BL::getWorkingLanguages(); } // get parameters $language = SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string'); $module = SpoonFilter::getPostValue('module', BackendModel::getModules(false), null, 'string'); $name = SpoonFilter::getPostValue('name', null, null, 'string'); $type = SpoonFilter::getPostValue('type', BackendModel::getDB()->getEnumValues('locale', 'type'), null, 'string'); $application = SpoonFilter::getPostValue('application', array('backend', 'frontend'), null, 'string'); $value = SpoonFilter::getPostValue('value', null, null, 'string'); // validate values if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'frontend' && $module != 'core') { $error = BL::err('InvalidValue'); } // in case this is a 'act' type, there are special rules concerning possible values if ($type == 'act' && !isset($error)) { if (!SpoonFilter::isValidAgainstRegexp('|^([a-z0-9\\-\\_])+$|', $value)) { $error = BL::err('InvalidActionValue', $this->getModule()); } } // no error? if (!isset($error)) { // build item $item['language'] = $language; $item['module'] = $module; $item['name'] = $name; $item['type'] = $type; $item['application'] = $application; $item['value'] = $value; $item['edited_on'] = BackendModel::getUTCDate(); $item['user_id'] = BackendAuthentication::getUser()->getUserId(); // does the translation exist? if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) { // add the id to the item $item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application); // update in db BackendLocaleModel::update($item); } else { // insert in db BackendLocaleModel::insert($item); } // output OK $this->output(self::OK); } else { $this->output(self::ERROR, null, $error); } }
/** * 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 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]'); } }
/** * 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(); // shorten the fields $txtName = $this->frm->getField('name'); $txtEmail = $this->frm->getField('email'); $ddmMethod = $this->frm->getField('method'); $txtSuccessMessage = $this->frm->getField('success_message'); $txtIdentifier = $this->frm->getField('identifier'); // validate fields $txtName->isFilled(BL::getError('NameIsRequired')); $txtSuccessMessage->isFilled(BL::getError('SuccessMessageIsRequired')); if ($ddmMethod->isFilled(BL::getError('NameIsRequired')) && $ddmMethod->getValue() == 'database_email') { $txtEmail->isEmail(BL::getError('EmailIsRequired')); } // identifier if ($txtIdentifier->isFilled()) { // invalid characters if (!SpoonFilter::isValidAgainstRegexp('/^[a-zA-Z0-9\\.\\_\\-]+$/', $txtIdentifier->getValue())) { $txtIdentifier->setError(BL::getError('InvalidIdentifier')); } elseif (BackendFormBuilderModel::existsIdentifier($txtIdentifier->getValue())) { $txtIdentifier->setError(BL::getError('UniqueIdentifier')); } } // no errors? if ($this->frm->isCorrect()) { // build array $values['language'] = BL::getWorkingLanguage(); $values['user_id'] = BackendAuthentication::getUser()->getUserId(); $values['name'] = $txtName->getValue(); $values['method'] = $ddmMethod->getValue(); $values['email'] = $values['method'] == 'database_email' ? $txtEmail->getValue() : null; $values['success_message'] = $txtSuccessMessage->getValue(true); $values['identifier'] = $txtIdentifier->isFilled() ? $txtIdentifier->getValue() : BackendFormBuilderModel::createIdentifier(); $values['created_on'] = BackendModel::getUTCDate(); $values['edited_on'] = BackendModel::getUTCDate(); // insert the item $id = BackendFormBuilderModel::insert($values); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $values)); // set frontend locale FL::setLocale(BL::getWorkingLanguage()); // create submit button $field['form_id'] = $id; $field['type'] = 'submit'; $field['settings'] = serialize(array('values' => ucfirst(FL::getLabel('Send')))); BackendFormBuilderModel::insertField($field); // everything is saved, so redirect to the editform $this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $id . '&report=added&var=' . urlencode($values['name']) . '#tabFields'); } } }
/** * 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')); }
/** * 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 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; }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // is the user a GodUser? $this->isGod = BackendAuthentication::getUser()->isGod(); // set filter $this->setFilter(); // load form $this->loadForm(); // load datagrids $this->loadDataGrid(); // parse page $this->parse(); // display the page $this->display(); }
/** * 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')); } }
/** * Load the datagird with the drafts * * @return void */ private function loadDataGridDrafts() { // create datagrid $this->dgDrafts = new BackendDataGridDB(BackendPagesModel::QRY_DATAGRID_BROWSE_DRAFTS, array('draft', BackendAuthentication::getUser()->getUserId(), BL::getWorkingLanguage())); // hide columns $this->dgDrafts->setColumnsHidden(array('revision_id')); // disable paging $this->dgDrafts->setPaging(false); // set colum URLs $this->dgDrafts->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]&draft=[revision_id]'); // set column functions $this->dgDrafts->setColumnFunction(array('BackendDataGridFunctions', 'getUser'), array('[user_id]'), 'user_id', true); $this->dgDrafts->setColumnFunction(array('BackendDataGridFunctions', 'getLongDate'), array('[edited_on]'), 'edited_on'); // add edit column $this->dgDrafts->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]&draft=[revision_id]', BL::lbl('Edit')); // set headers $this->dgDrafts->setHeaderLabels(array('user_id' => ucfirst(BL::lbl('By')), 'edited_on' => ucfirst(BL::lbl('LastEdited')))); }
/** * 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); }