Author: Tijs Verkoyen (tijs@sumocoders.be)
Esempio n. 1
0
 /**
  * Loads the settings form
  */
 private function loadForm()
 {
     // init settings form
     $this->frm = new BackendForm('settings');
     $settings = BackendModel::get('fork.settings')->getForModule('Agenda');
     $this->frm->addText('width1', $settings['width1']);
     $this->frm->addText('height1', $settings['height1']);
     $this->frm->addCheckbox('allow_enlargment1', $settings['allow_enlargment1']);
     $this->frm->addCheckbox('force_aspect_ratio1', $settings['force_aspect_ratio1']);
     $this->frm->addText('width1', $settings['width2']);
     $this->frm->addText('height1', $settings['height2']);
     $this->frm->addCheckbox('allow_enlargment2', $settings['allow_enlargment2']);
     $this->frm->addCheckbox('force_aspect_ratio2', $settings['force_aspect_ratio2']);
     $this->frm->addText('width3', $settings['width3']);
     $this->frm->addText('height3', $settings['height3']);
     $this->frm->addCheckbox('allow_enlargment3', $settings['allow_enlargment3']);
     $this->frm->addCheckbox('force_aspect_ratio3', $settings['force_aspect_ratio3']);
     $this->frm->addCheckbox('allow_subscriptions', $settings['allow_subscriptions']);
     $this->frm->addCheckbox('moderation', $settings['moderation']);
     $this->frm->addCheckbox('notify_by_email_on_new_subscription_to_moderate', $settings['notify_by_email_on_new_subscription_to_moderate']);
     $this->frm->addCheckbox('notify_by_email_on_new_subscription', $settings['notify_by_email_on_new_subscription']);
     $this->frm->addText('cache_timeout', $settings['cache_timeout']);
     $this->frm->addDropdown('zoom_level', array_combine(array_merge(array('auto'), range(3, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(3, 18))), $this->get('fork.settings')->get($this->URL->getModule(), 'zoom_level_widget', 13));
     $this->frm->addText('width', $this->get('fork.settings')->get($this->URL->getModule(), 'width'));
     $this->frm->addText('height', $this->get('fork.settings')->get($this->URL->getModule(), 'height'));
     $this->frm->addDropdown('map_type', array('ROADMAP' => BL::lbl('Roadmap', $this->getModule()), 'SATELLITE' => BL::lbl('Satellite', $this->getModule()), 'HYBRID' => BL::lbl('Hybrid', $this->getModule()), 'TERRAIN' => BL::lbl('Terrain', $this->getModule())), $this->get('fork.settings')->get($this->URL->getModule(), 'map_type_widget', 'roadmap'));
 }
Esempio n. 2
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['language'] = BL::getWorkingLanguage();
             $item['publish_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             $item['hidden'] = $this->frm->getField('hidden')->getValue();
             // get the highest sequence available
             $item['sequence'] = BackendGalleryModel::getMaximumCategorySequence() + 1;
             // insert the item
             $item['id'] = BackendGalleryModel::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']);
         }
     }
 }
Esempio n. 3
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['language'] = BL::getWorkingLanguage();
             $item['meta_id'] = $this->meta->save();
             $item['sequence'] = BackendCatalogModel::getMaximumSpecificationSequence() + 1;
             // save the data
             $item['id'] = BackendCatalogModel::insertSpecification($item);
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 BackendCatalogModel::insertSpecificationLanguage($itemLanguage);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_specification', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('specifications') . '&report=added-specification&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 4
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $frmFields = $this->frm->getFields();
         // validate form
         if ($frmFields['twitter']->isChecked()) {
             // we need fields when search is ticked
             $frmFields['twitter_name']->isFilled(Language::err('FieldIsRequired'));
         }
         if ($this->frm->isCorrect()) {
             // if this field is checked, let's add a boolean searchable true to the chosen fields
             if ($frmFields['twitter']->isChecked()) {
                 $this->record['twitter'] = $frmFields['twitter_name']->getValue();
             } else {
                 if (array_key_exists('twitter', $this->record)) {
                     unset($this->record['twitter']);
                 }
             }
             // save the object in our session
             \SpoonSession::set('module', $this->record);
             $this->redirect(Model::createURLForAction('Generate'));
         }
     }
 }
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['username']->isFilled(Language::err('FieldIsRequired'));
         if ($this->frm->isCorrect()) {
             $item['id'] = $this->id;
             $item['username'] = $fields['username']->getValue();
             // lookup user id
             $userObj = Helper::searchUser($item['username']);
             if (isset($userObj->data)) {
                 $userId = $userObj->data[0]->id;
                 $item['user_id'] = $userId;
             } else {
                 $this->redirect(Model::createURLForAction('Index') . '&error=api_error');
             }
             BackendInstagramModel::update($item);
             $item['id'] = $this->id;
             Model::triggerEvent($this->getModule(), 'after_edit', $item);
             $this->redirect(Model::createURLForAction('Index') . '&report=edited&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 6
0
 /**
  * Load the datagrid for statistics
  */
 private function loadStatistics()
 {
     // fetch the latest mailing
     $mailing = BackendMailmotorModel::getSentMailings(1);
     // check if a mailing was found
     if (empty($mailing)) {
         return false;
     }
     // check if a mailing was set
     if (!isset($mailing[0])) {
         return false;
     }
     // show the sent mailings block
     $this->tpl->assign('oSentMailings', true);
     // fetch the statistics for this mailing
     $stats = BackendMailmotorCMHelper::getStatistics($mailing[0]['id'], true);
     // reformat the send date
     $mailing[0]['sent'] = \SpoonDate::getDate('d-m-Y', $mailing[0]['sent']) . ' ' . BL::lbl('At') . ' ' . \SpoonDate::getDate('H:i', $mailing);
     // get results
     $results[] = array('label' => BL::lbl('MailmotorLatestMailing'), 'value' => $mailing[0]['name']);
     $results[] = array('label' => BL::lbl('MailmotorSendDate'), 'value' => $mailing[0]['sent']);
     $results[] = array('label' => BL::lbl('MailmotorSent'), 'value' => $stats['recipients'] . ' (' . $stats['recipients_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorOpened'), 'value' => $stats['unique_opens'] . ' (' . $stats['unique_opens_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorClicks'), 'value' => $stats['clicks_total'] . ' (' . $stats['clicks_percentage'] . ')');
     // there are some results
     if (!empty($results)) {
         // get the datagrid
         $dataGrid = new BackendDataGridArray($results);
         // no pagination
         $dataGrid->setPaging(false);
         // parse the datagrid
         $this->tpl->assign('dgMailmotorStatistics', $dataGrid->getContent());
     }
 }
Esempio n. 7
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         //--Clean form
         $this->frm->cleanupFields();
         //--Get fields
         $fields = $this->frm->getFields();
         //--Field required
         $fields['csv']->isFilled(BL::err('CSVIsRequired'));
         //--Check if form is correct
         if ($fields['csv']->isFilled()) {
             // convert the CSV file to an array
             $csv = BackendCSV::fileToArray($fields['csv']->getTempFileName(), array("email", "name"), null, ';');
             //--check if the csv is correct
             if ($csv === false || empty($csv) || !isset($csv[0])) {
                 $fields['csv']->addError(BL::err('InvalidCSV'));
             }
             //--Get all the groups
             $groups = $fields["groups"]->getValue();
             $language = $fields["languages"]->getValue();
             //--Process CSV
             $return = $this->processCsv($csv, $groups, $language);
             if (is_array($return)) {
                 $this->tpl->assign('hideForm', true);
                 $this->tpl->assign('return', $return);
             }
         }
     }
 }
Esempio n. 8
0
 /**
  * Execute the action
  */
 public function execute()
 {
     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');
     } else {
         // get existing id
         $existingId = BackendMailmotorModel::getCampaignId($name);
         // validate
         if ($existingId !== 0 && $id !== $existingId) {
             $this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
         } else {
             // 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()));
             }
         }
     }
 }
 /**
  * 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 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();
             $item['sequence'] = BackendSlideshowModel::getMaximumCategorySequence() + 1;
             // insert the item
             $item['id'] = BackendSlideshowModel::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=' . $item['id']);
         }
     }
 }
Esempio n. 10
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(Language::err('TitleIsRequired'));
         $fields['description']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_name']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_url']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_email']->isFilled(Language::err('FieldIsRequired'));
         // cleanup the modulename
         $title = preg_replace('/[^A-Za-z ]/', '', $fields['title']->getValue());
         // check if there is already a module with this name
         if (BackendExtensionsModel::existsModule($title)) {
             $fields['title']->addError(Language::err('DuplicateModuleName'));
         }
         if ($this->frm->isCorrect()) {
             $this->record['title'] = $title;
             $this->record['description'] = trim($fields['description']->getValue());
             $this->record['author_name'] = $fields['author_name']->getValue();
             $this->record['author_url'] = $fields['author_url']->getValue();
             $this->record['author_email'] = $fields['author_email']->getValue();
             $this->record['camel_case_name'] = BackendModuleMakerHelper::buildCamelCasedName($title);
             $this->record['underscored_name'] = BackendModuleMakerHelper::buildUnderscoredName($title);
             \SpoonSession::set('module', $this->record);
             $this->redirect(Model::createURLForAction('AddStep2'));
         }
     }
 }
Esempio n. 11
0
 /**
  * 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']);
         }
     }
 }
Esempio n. 12
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(BL::err('FieldIsRequired'));
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             $item['meta_id'] = $this->meta->save();
             $item['title'] = $fields['title']->getValue();
             $item['parent_id'] = $fields['group']->getValue() != 0 ? $fields['group']->getValue() : null;
             $item['id'] = BackendAddressesModel::insertGroup($item);
             if (isset($fields["addresses"])) {
                 //--Get all the users
                 $addresses = $fields["addresses"]->getValue();
                 foreach ($addresses as $value) {
                     $userGroup = array();
                     $userGroup["group_id"] = $item['id'];
                     $userGroup["address_id"] = $value;
                     //--Add user to the group
                     BackendAddressesModel::insertAddressToGroup($userGroup);
                 }
             }
             BackendModel::triggerEvent($this->getModule(), 'after_add_group', $item);
             $this->redirect(BackendModel::createURLForAction('groups') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 13
0
 /**
  * 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') . '&amp;id=[id]');
             $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;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));
 }
Esempio n. 14
0
 /**
  * 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
         /** @var $txtName \SpoonFormText */
         $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);
         }
     }
 }
Esempio n. 15
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $fields = $this->frm->getFields();
         // validate fields
         $fields['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 ? $fields['template']->getValue() : $this->templates[0];
             $item['language'] = BL::getWorkingLanguage();
             $item['title'] = $fields['title']->getValue();
             $item['text'] = $fields['text']->getValue();
             $item['hidden'] = $fields['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']);
         }
     }
 }
Esempio n. 16
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->isCorrect()) {
             $item['title'] = $fields['title']->getValue();
             $item['id'] = BackendMailengineModel::insertGroup($item);
             //--Check if there are users
             if (isset($fields["users"])) {
                 //--Get all the users
                 $users = $fields["users"]->getValue();
                 foreach ($users as $key => $value) {
                     $userGroup = array();
                     $userGroup["group_id"] = $item['id'];
                     $userGroup["user_id"] = $value;
                     //--Add user to the group
                     BackendMailengineModel::insertUserToGroup($userGroup);
                 }
             }
             BackendModel::triggerEvent($this->getModule(), 'after_add_group', $item);
             $this->redirect(BackendModel::createURLForAction('groups') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 17
0
 /**
  * Retrieve the unique URL for an teamMember
  *
  * @param string $url
  * @param int $id The id of the teamMember to ignore.
  * @return string
  */
 public static function getUrl($url, $id = null)
 {
     $url = CommonUri::getUrl((string) $url);
     $database = BackendModel::get('database');
     if ($id === null) {
         $urlExists = (bool) $database->getVar('SELECT 1
                FROM team_members AS i
                     INNER JOIN meta AS m
                     ON i.meta_id = m.id
               WHERE i.language = ? AND m.url = ?
               LIMIT 1', [Language::getWorkingLanguage(), $url]);
     } else {
         $urlExists = (bool) $database->getVar('SELECT 1
                FROM team_members AS i
                     INNER JOIN meta AS m
                     ON i.meta_id = m.id
               WHERE i.language = ? AND m.url = ? AND i.id != ?
               LIMIT 1', [Language::getWorkingLanguage(), $url, $id]);
     }
     if ($urlExists) {
         $url = Model::addNumber($url);
         return self::getUrl($url, $id);
     }
     return $url;
 }
Esempio n. 18
0
 /**
  * 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();
         // 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);
         }
     }
 }
Esempio n. 19
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['name']->isFilled(BL::err('FieldIsRequired'));
         $fields['email']->isFilled(BL::err('FieldIsRequired'));
         $fields['email']->isEmail(BL::err('EmailIsInvalid'));
         if ($this->frm->isCorrect()) {
             $item['name'] = $fields['name']->getValue();
             $item['email'] = $fields['email']->getValue();
             $item['language'] = BL::getWorkingLanguage();
             $item['id'] = BackendMailengineModel::insertUser($item);
             //--Check if there are groups
             if (isset($fields['groups'])) {
                 //--Get all the groups
                 $groups = $fields["groups"]->getValue();
                 foreach ($groups as $key => $value) {
                     $groupUser = array();
                     $groupUser["user_id"] = $item['id'];
                     $groupUser["group_id"] = $value;
                     //--Add user to the group
                     BackendMailengineModel::insertUserToGroup($groupUser);
                 }
             }
             BackendModel::triggerEvent($this->getModule(), 'after_add_user', $item);
             $this->redirect(BackendModel::createURLForAction('users') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 20
0
 private function validateForm()
 {
     if ($this->form->isSubmitted()) {
         $fields = $this->form->getFields();
         if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
             return;
         }
         if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
             return;
         }
         $newStartDate = Model::getUTCTimestamp($fields['start_date']);
         $newEndDate = Model::getUTCTimestamp($fields['end_date']);
         // startdate cannot be before 2005 (earliest valid google startdate)
         if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         // enddate cannot be in the future
         if ($newEndDate > time()) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         // enddate cannot be before the startdate
         if ($newStartDate > $newEndDate) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         if ($this->form->isCorrect()) {
             $this->startDate = $newStartDate;
             $this->endDate = $newEndDate;
         }
     }
 }
Esempio n. 21
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 public function execute()
 {
     $this->loadConfig();
     // is the requested action possible? If not we throw an exception.
     // We don't redirect because that could trigger a redirect loop
     if (!in_array($this->getAction(), $this->config->getPossibleActions())) {
         throw new Exception('This is an invalid action (' . $this->getAction() . ').');
     }
     // build action-class
     $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction();
     if ($this->getModule() == 'Core') {
         $actionClass = 'Backend\\Core\\Actions\\' . $this->getAction();
     }
     if (!class_exists($actionClass)) {
         throw new Exception('The class ' . $actionClass . ' could not be found.');
     }
     // get working languages
     $languages = Language::getWorkingLanguages();
     $workingLanguages = array();
     // loop languages and build an array that we can assign
     foreach ($languages as $abbreviation => $label) {
         $workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == Language::getWorkingLanguage());
     }
     // assign the languages
     $this->tpl->assign('workingLanguages', $workingLanguages);
     // create action-object
     /** @var $object BackendBaseAction */
     $object = new $actionClass($this->getKernel());
     $this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'.");
     $object->execute();
     return $object->getContent();
 }
Esempio n. 22
0
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(BL::err('TitleIsRequired'));
         if ($this->frm->isCorrect()) {
             $item = [];
             $item['title'] = $fields['title']->getValue();
             $item['capacity'] = $fields['capacity']->getValue();
             $item['price'] = $fields['price']->getValue();
             $item['count'] = $fields['count']->getValue();
             $item['image'] = null;
             $item['hotel_id'] = $this->id;
             if ($fields['image']->isFilled()) {
                 // the image path
                 $imagePath = FRONTEND_FILES_PATH . '/rooms/images';
                 // create folders if needed
                 $fs = new Filesystem();
                 $fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128'));
                 $item['image'] = $fields['image']->getFileName(false) . '.' . $fields['image']->getExtension();
                 $i = 2;
                 while ($fs->exists($imagePath . '/source/' . $item['image'])) {
                     $item['image'] = $fields['image']->getFileName(false) . '(' . $i . ')' . '.' . $fields['image']->getExtension();
                     $i++;
                 }
                 // upload the image & generate thumbnails
                 $fields['image']->generateThumbnails($imagePath, $item['image']);
             }
             $item['id'] = BackendHotelsModel::insertRecord('hotels_rooms', $item);
             $this->redirect(BackendModel::createURLForAction('Rooms') . '&id=' . $this->id . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Esempio n. 23
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $id = \SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate id
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     } else {
         // validate tag name
         if ($tag === '') {
             $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
         } else {
             // check if tag exists
             if (BackendTagsModel::existsTag($tag)) {
                 $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
             } else {
                 $item['id'] = $id;
                 $item['tag'] = \SpoonFilter::htmlspecialchars($tag);
                 $item['url'] = BackendTagsModel::getURL(CommonUri::getUrl(\SpoonFilter::htmlspecialcharsDecode($item['tag'])), $id);
                 BackendTagsModel::update($item);
                 $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
             }
         }
     }
 }
Esempio n. 24
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // redefine fields
         /** @var $fileFile \SpoonFormFile */
         $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);
         }
     }
 }
Esempio n. 25
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // get fields
         $ddmGroup = $this->frm->getField('group');
         $fileFile = $this->frm->getField('file');
         $csv = array();
         // validate input
         $ddmGroup->isFilled(BL::getError('FieldIsRequired'));
         if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
             if ($fileFile->isAllowedExtension(array('csv'), sprintf(BL::getError('ExtensionNotAllowed'), 'csv'))) {
                 $csv = Csv::fileToArray($fileFile->getTempFileName());
                 if ($csv === false) {
                     $fileFile->addError(BL::getError('InvalidCSV'));
                 }
             }
         }
         if ($this->frm->isCorrect()) {
             // import the profiles
             $overwrite = $this->frm->getField('overwrite_existing')->isChecked();
             $statistics = BackendProfilesModel::importCsv($csv, $ddmGroup->getValue(), $overwrite);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
             // build redirect url with the right message
             $redirectUrl = BackendModel::createURLForAction('index') . '&report=';
             $redirectUrl .= $overwrite ? 'profiles-imported-and-updated' : 'profiles-imported';
             $redirectUrl .= '&var[]=' . $statistics['count']['inserted'];
             $redirectUrl .= '&var[]=' . $statistics['count']['exists'];
             // everything is saved, so redirect to the overview
             $this->redirect($redirectUrl);
         }
     }
 }
Esempio n. 26
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired'));
         $this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->getField('website')->isFilled()) {
             $this->frm->getField('website')->isURL(BL::err('InvalidURL'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['status'] = $this->record['status'];
             $item['author'] = $this->frm->getField('author')->getValue();
             $item['email'] = $this->frm->getField('email')->getValue();
             $item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null;
             $item['text'] = $this->frm->getField('text')->getValue();
             // insert the item
             BackendBlogModel::updateComment($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . \SpoonFilter::toCamelCase($item['status']));
         }
     }
 }
Esempio n. 27
0
 /**
  * Parse the correct messages into the template
  */
 protected function parse()
 {
     parent::parse();
     // grab the error-type from the parameters
     $errorType = $this->getParameter('type');
     // set correct headers
     switch ($errorType) {
         case 'module-not-allowed':
         case 'action-not-allowed':
             header('HTTP/1.1 403 Forbidden');
             break;
         case 'not-found':
             header('HTTP/1.1 404 Not Found');
             break;
     }
     // querystring provided?
     if ($this->getParameter('querystring') !== null) {
         // split into file and parameters
         $chunks = explode('?', $this->getParameter('querystring'));
         // get extension
         $extension = pathinfo($chunks[0], PATHINFO_EXTENSION);
         // if the file has an extension it is a non-existing-file
         if ($extension != '' && $extension != $chunks[0]) {
             // set correct headers
             header('HTTP/1.1 404 Not Found');
             // give a nice error, so we can detect which file is missing
             echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
             // stop script execution
             exit;
         }
     }
     // assign the correct message into the template
     $this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
 }
Esempio n. 28
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($categoryTitle === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
     } else {
         // get the data
         // build array
         $item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
         $item['language'] = BL::getWorkingLanguage();
         $meta['keywords'] = $item['title'];
         $meta['keywords_overwrite'] = 'N';
         $meta['description'] = $item['title'];
         $meta['description_overwrite'] = 'N';
         $meta['title'] = $item['title'];
         $meta['title_overwrite'] = 'N';
         $meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
         // update
         $item['id'] = BackendBlogModel::insertCategory($item, $meta);
         // output
         $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
     }
 }
 /**
  * Load the datagrids
  *
  * @return  void
  */
 private function loadDataGrids()
 {
     // load all categories that are in use
     $categories = BackendSlideshowModel::getActiveCategories(true);
     // run over categories and create datagrid for each one
     foreach ($categories as $categoryId => $categoryTitle) {
         // create datagrid
         $dataGrid = new BackendDataGridDB(BackendSlideshowModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
         // disable paging
         $dataGrid->setPaging(false);
         // set colum URLs
         $dataGrid->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
         // set column functions
         $dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[publish_on]'), 'publish_on', true);
         $dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id', true);
         // set headers
         $dataGrid->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('Author')), 'publish_on' => \SpoonFilter::ucfirst(BL::lbl('PublishedOn'))));
         // enable drag and drop
         $dataGrid->enableSequenceByDragAndDrop();
         // our JS needs to know an id, so we can send the new order
         $dataGrid->setRowAttributes(array('id' => '[id]'));
         $dataGrid->setAttributes(array('data-action' => "GallerySequence"));
         // create a column #images
         $dataGrid->addColumn('images', ucfirst(BL::lbl('Images')));
         $dataGrid->setColumnFunction(array('Backend\\Modules\\Slideshow\\Engine\\Model', 'getImagesByGallery'), array('[id]', true), 'images', true);
         // hide columns
         $dataGrid->setColumnsHidden(array('category_id', 'sequence', 'filename'));
         // add edit column
         $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]', BL::lbl('Edit'));
         // set column order
         $dataGrid->setColumnsSequence('dragAndDropHandle', 'title', 'images', 'user_id', 'publish_on', 'edit');
         // add dataGrid to list
         $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
     }
 }
Esempio n. 30
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $fields = $this->frm->getFields();
         $fields['email']->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->isCorrect()) {
             //--Get the mail
             $mailing = BackendMailengineModel::get($this->id);
             //--Get the template
             $template = BackendMailengineModel::getTemplate($mailing['template_id']);
             //--Create basic mail
             $text = BackendMailengineModel::createMail($mailing, $template);
             $mailing['from_email'] = $template['from_email'];
             $mailing['from_name'] = html_entity_decode($template['from_name']);
             $mailing['reply_email'] = $template['reply_email'];
             $mailing['reply_name'] = html_entity_decode($template['reply_name']);
             $emails = explode(',', $fields['email']->getValue());
             if (!empty($emails)) {
                 foreach ($emails as $email) {
                     $email = trim($email);
                     if (\SpoonFilter::isEmail($email)) {
                         //--Send test mailing
                         BackendMailengineModel::sendMail(html_entity_decode($mailing['subject']), $text, $email, 'Test Recepient', $mailing);
                     }
                 }
             }
             //--Redirect
             \SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&report=TestEmailSend");
         }
     }
     $this->frm->parse($this->tpl);
 }