Example #1
0
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent
     parent::execute();
     // get parameters
     $id = SpoonFilter::getPostValue('id', null, 0, 'int');
     $droppedOn = SpoonFilter::getPostValue('dropped_on', null, -1, 'int');
     $typeOfDrop = SpoonFilter::getPostValue('type', null, '');
     // validate
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     if ($droppedOn === -1) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     if ($typeOfDrop == '') {
         $this->output(self::BAD_REQUEST, null, 'no type provided');
     }
     // get page
     $success = BackendPagesModel::move($id, $droppedOn, $typeOfDrop);
     // build cache
     BackendPagesModel::buildCache(BL::getWorkingLanguage());
     // output
     if ($success) {
         $this->output(self::OK, BackendPagesModel::get($id), 'page moved');
     } else {
         $this->output(self::ERROR, null, 'page not moved');
     }
 }
Example #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = \SpoonFilter::getPostValue('form_id', null, '', 'int');
     $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     } else {
         // list id
         $ids = (array) explode('|', rtrim($newIdSequence, '|'));
         // loop id's and set new sequence
         foreach ($ids as $i => $id) {
             $id = (int) $id;
             // get field
             $field = BackendFormBuilderModel::getField($id);
             // from this form and not a submit button
             if (!empty($field) && $field['form_id'] == $formId && $field['type'] != 'submit') {
                 BackendFormBuilderModel::updateField($id, array('sequence' => $i + 1));
             }
         }
         $this->output(self::OK, null, 'sequence updated');
     }
 }
Example #3
0
 /**
  * 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
     $formId = SpoonFilter::getPostValue('form_id', null, '', 'int');
     $newIdSequence = trim(SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     }
     // list id
     $ids = (array) explode(',', rtrim($newIdSequence, ','));
     // loop id's and set new sequence
     foreach ($ids as $i => $id) {
         // redefine
         $id = (int) $id;
         // get field
         $field = BackendFormBuilderModel::getField($id);
         // from this form and not a submit button
         if (!empty($field) && $field['form_id'] == $formId && $field['type'] != 'submit') {
             BackendFormBuilderModel::updateField($id, array('sequence' => $i + 1));
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Example #4
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'])));
     }
 }
Example #5
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the ids as array
     $ids = \SpoonFilter::getPostValue('ids', null, '', 'array');
     //--Set module
     $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string');
     //--Set action
     $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string');
     //--Set the id
     $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int');
     //--Set the type
     $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string');
     //--Create media object
     $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type);
     //--Check if the ids is not empty
     if (!empty($ids)) {
         foreach ($ids as $id) {
             //--Link mediaitem with id to item
             $media->linkMediaToModule($id);
         }
     }
     // success output
     $this->output(self::OK, null, 'files added');
 }
Example #6
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate search term
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // previous search result
         $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
         \SpoonSession::set('searchTerm', '');
         // save this term?
         if ($previousTerm != $term) {
             // format data
             $this->statistics = array();
             $this->statistics['term'] = $term;
             $this->statistics['language'] = LANGUAGE;
             $this->statistics['time'] = FrontendModel::getUTCDate();
             $this->statistics['data'] = serialize(array('server' => $_SERVER));
             $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
             // save data
             FrontendSearchModel::save($this->statistics);
         }
         // save current search term in cookie
         \SpoonSession::set('searchTerm', $term);
         // output
         $this->output(self::OK);
     }
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
     $sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
     $sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
     $messageDate = $sendOnDate;
     // validate mailing ID
     if ($mailingId == '') {
         $this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
     }
     if ($sendOnDate == '' || $sendOnTime == '') {
         $this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
     }
     // record is empty
     if (!BackendMailmotorModel::existsMailing($mailingId)) {
         $this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor'));
     }
     // reverse the date and make it a proper
     $explodedDate = explode('/', $sendOnDate);
     $sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
     // calc full send timestamp
     $sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
     // build data
     $item['id'] = $mailingId;
     $item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
     $item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
     // update mailing
     BackendMailmotorModel::updateMailing($item);
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
     // output
     $this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
 }
Example #8
0
 /**
  * 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
     $formId = trim(SpoonFilter::getPostValue('form_id', null, '', 'int'));
     $fieldId = trim(SpoonFilter::getPostValue('field_id', null, '', 'int'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     }
     // invalid fieldId
     if (!BackendFormBuilderModel::existsField($fieldId, $formId)) {
         $this->output(self::BAD_REQUEST, null, 'field does not exist');
     }
     // get field
     $field = BackendFormBuilderModel::getField($fieldId);
     // submit button cannot be deleted
     if ($field['type'] == 'submit') {
         $this->output(self::BAD_REQUEST, null, 'submit button cannot be deleted');
     } else {
         // delete field
         BackendFormBuilderModel::deleteField($fieldId);
         // success output
         $this->output(self::OK, null, 'field deleted');
     }
 }
Example #9
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $term = SpoonFilter::getPostValue('term', null, '');
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // previous search result
     $previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
     SpoonSession::set('searchTerm', '');
     // save this term?
     if ($previousTerm != $term) {
         // format data
         $this->statistics = array();
         $this->statistics['term'] = $term;
         $this->statistics['language'] = FRONTEND_LANGUAGE;
         $this->statistics['time'] = FrontendModel::getUTCDate();
         $this->statistics['data'] = serialize(array('server' => $_SERVER));
         $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
         // save data
         FrontendSearchModel::save($this->statistics);
     }
     // save current search term in cookie
     SpoonSession::set('searchTerm', $term);
     // output
     $this->output(self::OK);
 }
Example #10
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     $limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // get matches
         $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
         // get search url
         $url = FrontendNavigation::getURLForBlock('Search');
         // loop items and set search url
         foreach ($matches as &$match) {
             $match['url'] = $url . '?form=search&q=' . $match['term'];
         }
         // output
         $this->output(self::OK, $matches);
     }
 }
Example #11
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'])));
             }
         }
     }
 }
Example #12
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = trim(\SpoonFilter::getPostValue('form_id', null, '', 'int'));
     $fieldId = trim(\SpoonFilter::getPostValue('field_id', null, '', 'int'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     } else {
         // invalid fieldId
         if (!BackendFormBuilderModel::existsField($fieldId, $formId)) {
             $this->output(self::BAD_REQUEST, null, 'field does not exist');
         } else {
             // get field
             $field = BackendFormBuilderModel::getField($fieldId);
             if ($field['type'] == 'radiobutton') {
                 $values = array();
                 foreach ($field['settings']['values'] as $value) {
                     $values[] = $value['label'];
                 }
                 $field['settings']['values'] = $values;
             }
             // success output
             $this->output(self::OK, array('field' => $field));
         }
     }
 }
Example #13
0
 /**
  * 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
     $id = SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     if ($tag === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
     }
     // check if tag exists
     if (BackendTagsModel::existsTag($tag)) {
         $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
     }
     // build array
     $item['id'] = $id;
     $item['tag'] = SpoonFilter::htmlspecialchars($tag);
     $item['url'] = BackendTagsModel::getURL($item['tag'], $id);
     // update
     BackendTagsModel::update($item);
     // output
     $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
 }
Example #14
0
 /**
  * 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
     $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');
     }
     // get existing id
     $existingId = BackendMailmotorModel::getCampaignId($name);
     // existing campaign
     if ($existingId !== 0 && $id !== $existingId) {
         $this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
     }
     // 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 #15
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // create bogus form
     $frm = new BackendForm('meta');
     // get parameters
     $URL = \SpoonFilter::getPostValue('url', null, '', 'string');
     $metaId = \SpoonFilter::getPostValue('meta_id', null, null);
     $baseFieldName = \SpoonFilter::getPostValue('baseFieldName', null, '', 'string');
     $custom = \SpoonFilter::getPostValue('custom', null, false, 'bool');
     $className = \SpoonFilter::getPostValue('className', null, '', 'string');
     $methodName = \SpoonFilter::getPostValue('methodName', null, '', 'string');
     $parameters = \SpoonFilter::getPostValue('parameters', null, '', 'string');
     // cleanup values
     $metaId = $metaId ? (int) $metaId : null;
     $parameters = @unserialize($parameters);
     // meta object
     $this->meta = new BackendMeta($frm, $metaId, $baseFieldName, $custom);
     // set callback for generating an unique URL
     $this->meta->setUrlCallback($className, $methodName, $parameters);
     // fetch generated meta url
     $URL = urldecode($this->meta->generateURL($URL));
     // output
     $this->output(self::OK, $URL);
 }
Example #16
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 #17
0
 public function execute()
 {
     parent::execute();
     //--Get the video info
     //$video_type = \SpoonFilter::getPostValue('video_type', null, '', 'int');
     $video_url = \SpoonFilter::getPostValue('video', null, '', 'string');
     if (preg_match('%youtube|youtu\\.be%i', $video_url)) {
         $video_type = 0;
         $video_id = self::getYoutubeId($video_url);
     } elseif (preg_match('%vimeo%i', $video_url)) {
         $video_type = 1;
         $video_id = self::getVimeoId($video_url);
     } elseif (preg_match('%vine%i', $video_url)) {
         $video_type = 2;
         $video_id = preg_replace('/^.*\\//', '', $video_url);
     }
     if (isset($video_id)) {
         //--Set module
         $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string');
         //--Set action
         $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string');
         //--Set the id
         $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int');
         //--Set the type
         $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string');
         //--Create media object
         $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type);
         //--Validate media -> add video
         $media->addVideo($video_type, $video_id);
         $tpl = new Template();
         $media->item['txtText'] = $media->frm->addTextarea("text-" . $media->item["id"], $media->item['text'])->setAttribute('style', 'resize: none;')->parse();
         switch ($media->item['extension']) {
             //youtube
             case 0:
                 $media->item['video_html'] = '<iframe id="ytplayer" type="text/html" width="100%" src="http://www.youtube.com/embed/' . $media->item['filename'] . '?autoplay=0" frameborder="0"></iframe>';
                 break;
                 //vimeo
             //vimeo
             case 1:
                 $media->item['video_html'] = '<iframe src="//player.vimeo.com/video/' . $media->item['filename'] . '" width="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
                 break;
                 //vine
             //vine
             case 2:
                 $media->item['video_html'] = '<iframe src="https://vine.co/v/' . $media->item['filename'] . '/embed/postcard" width="100%" frameborder="0"></iframe><script src="https://platform.vine.co/static/scripts/embed.js"></script>';
                 break;
             default:
                 $media->item['video_html'] = "";
                 break;
         }
         $tpl->assign('mediaItems', array('videos' => array($media->item)));
         $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Video.tpl');
         $this->output(self::OK, array($media->item['filetype'], $html), FrontendLanguage::msg('Success'));
     } else {
         $this->output(self::OK, null, 'video not added');
     }
     // success output
 }
Example #18
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $newSequence = \SpoonFilter::getPostValue('new_sequence', null, '');
     // validate
     if ($newSequence == '') {
         $this->output(self::BAD_REQUEST, null, 'no new_sequence provided');
     } else {
         // convert into array
         $json = @json_decode($newSequence, true);
         // validate
         if ($json === false) {
             $this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided');
         } else {
             // initialize
             $userSequence = array();
             $hiddenItems = array();
             // loop columns
             foreach ($json as $column => $widgets) {
                 $columnValue = 'left';
                 if ($column == 1) {
                     $columnValue = 'middle';
                 } elseif ($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
  */
 public function execute()
 {
     parent::execute();
     $overwrite = (bool) \SpoonFilter::getPostValue('overwrite', null, '');
     if ($overwrite) {
         BackendCompressionModel::writeToCacheFile("");
     }
     $this->output(self::OK);
 }
 /**
  * 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);
     }
 }
Example #21
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $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(), null, 'string');
     $name = \SpoonFilter::getPostValue('name', null, null, 'string');
     $type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->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 (urlencode($value) != CommonUri::getUrl($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);
     }
 }
Example #22
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Set post var to check submit
     $_POST["form"] = "add_image";
     // get parameters
     $this->id = \SpoonFilter::getPostValue('id', null, '', 'int');
     //--Load form
     $this->loadForm();
     //--Validate form
     $this->validateForm();
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // Get POST parameters
     $userId = \SpoonFilter::getPostValue('userId', null, '');
     // Get count settings
     $this->recentCount = FrontendModel::get('fork.settings')->get('Instagram', 'num_recent_items', 10);
     // Get the images from the Instagram API
     $this->images = FrontendInstagramModel::getRecentMedia($userId, $this->recentCount);
     // Output the result
     $this->output(self::OK, $this->images);
 }
Example #24
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the id of the link to mediaitem
     $id = \SpoonFilter::getPostValue('id', null, '', 'string');
     //--Get new name for file
     $nameGet = \SpoonFilter::getPostValue('name', null, '', 'string');
     //--Check if the id is not empty
     if (!empty($id)) {
         //--Get link to mediaitem
         $mediaModule = BackendMediaModel::getMediaModule($id);
         //--Get mediaitem
         $media = BackendMediaModel::get($mediaModule['media_id']);
         //--Clean new name for file
         $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $nameGet);
         //--Get all image folders defined by sizes
         $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true);
         //--Create filesystem for file actions
         $fs = new Filesystem();
         //--Get path to files
         $path = FRONTEND_FILES_PATH . '/Media/';
         //--If old and new name is not the same -> do rename
         if ($media['filename'] != $name . '.' . $media['extension']) {
             //--Rename files on disk
             if ($media['filetype'] == 1) {
                 if ($fs->exists($path . 'Images/Source/' . $media['filename'])) {
                     $fs->rename($path . 'Images/Source/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/Source/' . $name . '.' . $media['extension']);
                 }
                 foreach ($folders as $folder) {
                     if ($fs->exists($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'])) {
                         $fs->rename($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $name . '.' . $media['extension']);
                     }
                 }
             } else {
                 if ($fs->exists($path . 'Files/' . $media['filename'])) {
                     $fs->rename($path . 'Files/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Files/' . $name . '.' . $media['extension']);
                 }
             }
             //--Set new name on mediaitem
             $media['filename'] = $name . '.' . $media['extension'];
             //--Update mediaitem
             BackendMediaModel::update($mediaModule['media_id'], $media);
             //--Create url to new file for ajax
             $url = FRONTEND_FILES_URL . '/Media/Files/' . $media['filename'];
             //--Return the new URL -> replaces the old url of the media on page
             $this->output(self::OK, $url, 'file renamed');
         } else {
             $this->output(self::OK, null, 'file name is the same');
         }
     }
     // success output
 }
 public function testGetPostValue()
 {
     // setup
     $_POST['id'] = '1337';
     $_POST['type'] = 'web';
     $_POST['animal'] = 'donkey';
     // perform tests
     $this->assertEquals(0, SpoonFilter::getPostValue('category_id', null, 0, 'int'));
     $this->assertEquals(1337, SpoonFilter::getPostValue('id', null, 0, 'int'));
     $this->assertEquals('web', SpoonFilter::getPostValue('type', array('web', 'print'), 'print'));
     $this->assertEquals('whale', SpoonFilter::getPostValue('animal', array('whale', 'horse'), 'whale'));
     $this->assertEquals('donkey', SpoonFilter::getPostValue('animal', null, 'whale'));
 }
Example #26
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the id
     $id = \SpoonFilter::getPostValue('id', null, '', 'string');
     //--Check if the id is not empty
     if (!empty($id)) {
         //--Delete file
         BackendGalleryModel::delete($id);
     }
     // success output
     $this->output(self::OK, null, 'image deleted');
 }
Example #27
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $term = SpoonFilter::getPostValue('term', null, '');
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // get tags
     $tags = BackendTagsModel::getStartsWith($term);
     // output
     $this->output(self::OK, $tags);
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $clientId = SpoonFilter::getPostValue('client_id', null, '');
     // check input
     if (empty($clientId)) {
         $this->output(self::BAD_REQUEST);
     }
     // get basic details for this client
     $client = BackendMailmotorCMHelper::getCM()->getClient($clientId);
     // CM was successfully initialized
     $this->output(self::OK, $client);
 }
 /**
  * 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
     $questionId = SpoonFilter::getPostValue('questionId', null, '', 'int');
     $fromCategoryId = SpoonFilter::getPostValue('fromCategoryId', null, '', 'int');
     $toCategoryId = SpoonFilter::getPostValue('toCategoryId', null, '', 'int');
     $fromCategorySequence = SpoonFilter::getPostValue('fromCategorySequence', null, '', 'string');
     $toCategorySequence = SpoonFilter::getPostValue('toCategorySequence', null, '', 'string');
     // invalid question id
     if (!BackendFaqModel::existsQuestion($questionId)) {
         $this->output(self::BAD_REQUEST, null, 'question does not exist');
     }
     // list ids
     $fromCategorySequence = (array) explode(',', ltrim($fromCategorySequence, ','));
     $toCategorySequence = (array) explode(',', ltrim($toCategorySequence, ','));
     // is the question moved to a new category?
     if ($fromCategoryId != $toCategoryId) {
         // build item
         $item['id'] = $questionId;
         $item['category_id'] = $toCategoryId;
         // update the category
         BackendFaqModel::updateQuestion($item);
         // loop id's and set new sequence
         foreach ($toCategorySequence as $i => $id) {
             // build item
             $item = array();
             $item['id'] = (int) $id;
             $item['sequence'] = $i + 1;
             // update sequence
             if (BackendFaqModel::existsQuestion($item['id'])) {
                 BackendFaqModel::updateQuestion($item);
             }
         }
     }
     // loop id's and set new sequence
     foreach ($fromCategorySequence as $i => $id) {
         // build item
         $item['id'] = (int) $id;
         $item['sequence'] = $i + 1;
         // update sequence
         if (BackendFaqModel::existsQuestion($item['id'])) {
             BackendFaqModel::updateQuestion($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Example #30
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent
     parent::execute();
     // get parameters
     $id = SpoonFilter::getPostValue('id', null, 0, 'int');
     // validate
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     // get page
     $page = BackendPagesModel::get($id);
     // output
     $this->output(self::OK, $page);
 }