Example #1
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()));
             }
         }
     }
 }
Example #2
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']);
         }
     }
 }
Example #3
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=' . rawurlencode($values['name']) . '&highlight=row-' . $id);
         }
     }
 }
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         if ($this->frm->isCorrect()) {
             // set mode setting
             $this->get('fork.settings')->set($this->URL->getModule(), 'settings_per_slide', (string) $this->frm->getField('settings_per_slide')->getChecked() ? 'true' : '');
             // set main settings
             $this->get('fork.settings')->set($this->URL->getModule(), 'animation', (string) $this->frm->getField('animation_type')->getValue());
             $this->get('fork.settings')->set($this->URL->getModule(), 'direction', (string) $this->frm->getField('direction')->getValue());
             $this->get('fork.settings')->set($this->URL->getModule(), 'slideshow_speed', (int) $this->frm->getField('slideshow_speed')->getValue());
             $this->get('fork.settings')->set($this->URL->getModule(), 'animation_speed', (int) $this->frm->getField('animation_speed')->getValue());
             // set optional settings
             $this->get('fork.settings')->set($this->URL->getModule(), 'direction_navigation', (string) $this->frm->getField('direction_navigation')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'control_navigation', (string) $this->frm->getField('control_navigation')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'thumbnail_navigation', (string) $this->frm->getField('thumbnail_navigation')->getChecked() ? 'true' : '');
             $this->get('fork.settings')->set($this->URL->getModule(), 'keyboard', (string) $this->frm->getField('keyboard')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'mousewheel', (string) $this->frm->getField('mousewheel')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'touch', (string) $this->frm->getField('touch')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'randomize', (string) $this->frm->getField('randomize')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'auto_animate', (string) $this->frm->getField('auto_animate')->getChecked() ? 'true' : 'false');
             $this->get('fork.settings')->set($this->URL->getModule(), 'animation_loop', (string) $this->frm->getField('animation_loop')->getChecked() ? 'true' : 'false');
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved');
         }
     }
 }
 /**
  * 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']);
         }
     }
 }
Example #6
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']);
         }
     }
 }
Example #7
0
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         if ($this->frm->isCorrect()) {
             // set the base values
             $width = (int) $this->frm->getField('width_widget')->getValue();
             $height = (int) $this->frm->getField('height_widget')->getValue();
             if ($width > 800) {
                 $width = 800;
             } elseif ($width < 300) {
                 $width = $this->get('fork.settings')->get('Location', 'width_widget');
             }
             if ($height < 150) {
                 $height = $this->get('fork.settings')->get('Location', 'height_widget');
             }
             // set our settings (widgets)
             $this->get('fork.settings')->set($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue());
             $this->get('fork.settings')->set($this->URL->getModule(), 'width_widget', $width);
             $this->get('fork.settings')->set($this->URL->getModule(), 'height_widget', $height);
             $this->get('fork.settings')->set($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved');
         }
     }
 }
Example #8
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendExtensionsModel::existsTemplate($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // init var
         $success = false;
         // get template (we need the title)
         $item = BackendExtensionsModel::getTemplate($this->id);
         // valid template?
         if (!empty($item)) {
             // delete the page
             $success = BackendExtensionsModel::deleteTemplate($this->id);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_delete_template', array('id' => $this->id));
         }
         // page is deleted, so redirect to the overview
         if ($success) {
             $this->redirect(BackendModel::createURLForAction('ThemeTemplates') . '&theme=' . $item['theme'] . '&report=deleted-template&var=' . urlencode($item['label']));
         } else {
             $this->redirect(BackendModel::createURLForAction('ThemeTemplates') . '&error=non-existing');
         }
     } else {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('ThemeTemplates') . '&error=non-existing');
     }
 }
Example #9
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']);
         }
     }
 }
Example #10
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendBlogModel::exists($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // set category id
         $this->categoryId = \SpoonFilter::getGetValue('category', null, null, 'int');
         if ($this->categoryId == 0) {
             $this->categoryId = null;
         }
         // get data
         $this->record = (array) BackendBlogModel::get($this->id);
         // delete item
         BackendBlogModel::delete($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // delete search indexes
         BackendSearchModel::removeIndex($this->getModule(), $this->id);
         // build redirect URL
         $redirectUrl = BackendModel::createURLForAction('Index') . '&report=deleted&var=' . urlencode($this->record['title']);
         // append to redirect URL
         if ($this->categoryId != null) {
             $redirectUrl .= '&category=' . $this->categoryId;
         }
         // item was deleted, so redirect
         $this->redirect($redirectUrl);
     } else {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
Example #11
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);
         }
     }
 }
Example #12
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=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
         }
     }
 }
Example #13
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']);
         }
     }
 }
Example #14
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']);
         }
     }
 }
 /**
  * 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()) {
             // Build the item
             $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');
             }
             // Insert it
             $item['id'] = BackendInstagramModel::insert($item);
             Model::triggerEvent($this->getModule(), 'after_add', $item);
             $this->redirect(Model::createURLForAction('Index') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }
Example #16
0
 /**
  * Execute the action.
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendProfilesModel::exists($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get item
         $profile = BackendProfilesModel::get($this->id);
         // already blocked? Prolly want to unblock then
         if ($profile['status'] === 'blocked') {
             // set profile status to active
             BackendProfilesModel::update($this->id, array('status' => 'active'));
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_unblock', array('id' => $this->id));
             // redirect
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=profile-unblocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
         } else {
             // delete profile session that may be active
             BackendProfilesModel::deleteSession($this->id);
             // set profile status to blocked
             BackendProfilesModel::update($this->id, array('status' => 'blocked'));
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_block', array('id' => $this->id));
             // redirect
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=profile-blocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
Example #17
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendBlogModel::existsCategory($this->id)) {
         // get data
         $this->record = (array) BackendBlogModel::getCategory($this->id);
         // allowed to delete the category?
         if (BackendBlogModel::deleteCategoryAllowed($this->id)) {
             // call parent, this will probably add some general CSS/JS or other required files
             parent::execute();
             // delete item
             BackendBlogModel::deleteCategory($this->id);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id));
             // category was deleted, so redirect
             $this->redirect(BackendModel::createURLForAction('Categories') . '&report=deleted-category&var=' . rawurlencode($this->record['title']));
         } else {
             $this->redirect(BackendModel::createURLForAction('Categories') . '&error=delete-category-not-allowed&var=' . rawurlencode($this->record['title']));
         }
     } else {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('Categories') . '&error=non-existing');
     }
 }
Example #18
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // action to execute
     $id = \SpoonFilter::getGetValue('id', null, 0);
     // no id's provided
     if (empty($id) || !BackendMailmotorModel::existsMailing($id)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=mailing-does-not-exist');
     } else {
         // get the mailing and reset some fields
         $mailing = BackendMailmotorModel::getMailing($id);
         $mailing['status'] = 'concept';
         $mailing['send_on'] = null;
         $mailing['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
         $mailing['edited_on'] = $mailing['created_on'];
         unset($mailing['recipients'], $mailing['id'], $mailing['cm_id'], $mailing['send_on_raw']);
         // set groups
         $groups = $mailing['groups'];
         unset($mailing['groups']);
         // create a new mailing based on the old one
         $newId = BackendMailmotorModel::insertMailing($mailing);
         // update groups for this mailing
         BackendMailmotorModel::updateGroupsForMailing($newId, $groups);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_copy_mailing', array('item' => $mailing));
     }
     // redirect
     $this->redirect(BackendModel::createURLForAction('Index') . '&report=mailing-copied&var=' . $mailing['name']);
 }
Example #19
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendGalleryModel::existsAlbum($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get album
         $this->album = BackendGalleryModel::getAlbumFromId($this->id);
         // is this album allowed to be deleted?
         if (!BackendGalleryModel::deleteAlbumAllowed($this->id)) {
             $this->redirect(BackendModel::createURLForAction('albums') . '&error=album-not-deletable');
         } else {
             // delete the item
             BackendGalleryModel::deleteAlbumById($this->id);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_delete_album', array('id' => $this->id));
             // item was deleted, so redirect
             $this->redirect(BackendModel::createURLForAction('albums') . '&report=album-deleted&var=' . urlencode($this->album['title']));
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('albums') . '&error=non-existing');
     }
 }
Example #20
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $url = \SpoonFilter::getPostValue('url', null, '');
     $username = \SpoonFilter::getPostValue('username', null, '');
     $password = \SpoonFilter::getPostValue('password', null, '');
     // filter out the 'http://' from the URL
     if (strpos($url, 'http://') !== false) {
         $url = str_replace('http://', '', $url);
     }
     if (strpos($url, 'https://') !== false) {
         $url = str_replace('https://', '', $url);
     }
     // init validation
     $errors = array();
     // validate input
     if (empty($url)) {
         $errors['url'] = BL::err('NoCMAccountCredentials');
     }
     if (empty($username)) {
         $errors['username'] = BL::err('NoCMAccountCredentials');
     }
     if (empty($password)) {
         $errors['password'] = BL::err('NoCMAccountCredentials');
     }
     // got errors
     if (!empty($errors)) {
         $this->output(self::OK, array('errors' => $errors), 'form contains errors');
     } else {
         try {
             // check if the CampaignMonitor class exists
             if (!is_file(PATH_LIBRARY . '/external/campaignmonitor.php')) {
                 throw new \Exception(BL::err('ClassDoesNotExist'));
             }
             // require CampaignMonitor class
             require_once PATH_LIBRARY . '/external/campaignmonitor.php';
             // init CampaignMonitor object
             new \CampaignMonitor($url, $username, $password, 10);
             // save the new data
             $this->get('fork.settings')->set($this->getModule(), 'cm_url', $url);
             $this->get('fork.settings')->set($this->getModule(), 'cm_username', $username);
             $this->get('fork.settings')->set($this->getModule(), 'cm_password', $password);
             // account was linked
             $this->get('fork.settings')->set($this->getModule(), 'cm_account', true);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_account_linked');
             // CM was successfully initialized
             $this->output(self::OK, array('message' => 'account-linked'), BL::msg('AccountLinked', $this->getModule()));
         } catch (\Exception $e) {
             // timeout occurred
             if ($e->getMessage() == 'Error Fetching http headers') {
                 $this->output(self::BAD_REQUEST, null, BL::err('CmTimeout', $this->getModule()));
             }
             // other error
             $this->output(self::ERROR, array('field' => 'url'), sprintf(BL::err('CampaignMonitorError', $this->getModule()), $e->getMessage()));
         }
     }
 }
Example #21
0
 /**
  * Build the cache
  *
  * @param string $language The language to build the cache for, if not passed we use the working language.
  */
 public static function buildCache($language = null)
 {
     // redefine
     $language = $language === null ? BL::getWorkingLanguage() : (string) $language;
     $cacheBuilder = static::getCacheBuilder();
     $cacheBuilder->buildCache($language);
     // trigger an event
     BackendModel::triggerEvent('Pages', 'after_recreated_cache');
 }
Example #22
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $feedbackId = $this->getParameter('id', 'int');
     $feedback = BackendFaqModel::getFeedback($feedbackId);
     BackendModel::triggerEvent($this->getModule(), 'after_delete_feedback', array('item' => $feedback));
     // there is no feedback data, so redirect
     if (empty($feedback)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
     BackendFaqModel::deleteFeedback($feedbackId);
     $this->redirect(BackendModel::createURLForAction('Edit') . '&amp;id=' . $feedback['question_id'] . '&report=deleted#tabFeedback');
 }
Example #23
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         if ($this->frm->isCorrect()) {
             BackendModel::setModuleSetting($this->URL->getModule(), 'default_group', (string) $this->frm->getField('default_group')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
Example #24
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendAgendaModel::exists($this->id)) {
         parent::execute();
         $this->record = (array) BackendAgendaModel::get($this->id);
         BackendAgendaModel::delete($this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']));
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
Example #25
0
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings
             $this->get('fork.settings')->set($this->getModule(), 'meta_navigation', (bool) $this->frm->getField('meta_navigation')->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved');
         }
     }
 }
Example #26
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id == null || !BackendBlocksModel::existsCategory($this->id)) {
         $this->redirect(Model::createURLForAction('categories') . '&error=non-existing');
     }
     // fetch the category
     $this->record = (array) BackendBlocksModel::getCategory($this->id);
     // delete item
     BackendBlocksModel::deleteCategory($this->id);
     Model::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record));
     // category was deleted, so redirect
     $this->redirect(Model::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title']));
 }
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         if ($this->frm->isCorrect()) {
             // get the settings
             $settings = array();
             $settings['activeList'] = $this->frm->getField('list')->getValue();
             // save the new settings
             BackendModel::setModuleSetting($this->getModule(), 'activeList', $settings['activeList']);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
Example #28
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id == null || !BackendCatalogModel::existsBrand($this->id)) {
         $this->redirect(BackendModel::createURLForAction('brands') . '&error=non-existing');
     }
     // fetch the brand
     $this->record = (array) BackendCatalogModel::getBrand($this->id);
     // delete item
     BackendCatalogModel::deleteBrand($this->id);
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_delete_brand', array('item' => $this->record));
     // brand was deleted, so redirect
     $this->redirect(BackendModel::createURLForAction('brands') . '&report=deleted-brand&var=' . urlencode($this->record['title']));
 }
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if (!$this->frm->isSubmitted()) {
         return false;
     }
     if ($this->frm->existsField('num_recent_items')) {
         $this->get('fork.settings')->set($this->URL->getModule(), 'num_recent_items', (int) $this->frm->getField('num_recent_items')->getValue());
         // Trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
         // Redirect to the settings page
         $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved');
     }
     if ($this->frm->existsField('client_id') && $this->frm->existsField('client_secret')) {
         return $this->validateAuthConfigForm();
     }
 }
Example #30
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $id = \SpoonFilter::getPostValue('id', null, '', 'int');
     // validate
     if ($id == '' || !BackendMailmotorModel::existsMailing($id)) {
         $this->output(self::BAD_REQUEST, null, 'No mailing found.');
     } else {
         // get mailing record
         $mailing = BackendMailmotorModel::getMailing($id);
         /*
             mailing was already sent
             We use a custom status code 900 because we want to do more with JS than triggering an error
         */
         if ($mailing['status'] == 'sent') {
             $this->output(500, null, BL::err('MailingAlreadySent', $this->getModule()));
         } else {
             // make a regular date out of the send_on timestamp
             $mailing['delivery_date'] = date('Y-m-d H:i:s', $mailing['send_on']);
             // send the mailing
             try {
                 // only update the mailing if it was queued
                 if ($mailing['status'] == 'queued') {
                     BackendMailmotorCMHelper::updateMailing($mailing);
                 } else {
                     // send the mailing if it wasn't queued
                     BackendMailmotorCMHelper::sendMailing($mailing);
                 }
             } catch (\Exception $e) {
                 // stop the script and show our error
                 $this->output(500, null, $e->getMessage());
                 return;
             }
             // set status to 'sent'
             $item['id'] = $id;
             $item['status'] = $mailing['send_on'] > time() ? 'queued' : 'sent';
             // update the mailing record
             BackendMailmotorModel::updateMailing($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_mailing_status_' . $item['status'], array('item' => $item));
             // we made it \o/
             $this->output(self::OK, array('mailing_id' => $item['id']), BL::msg('MailingSent', $this->getModule()));
         }
     }
 }