Ejemplo n.º 1
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'])));
 }
Ejemplo n.º 2
0
 /**
  * 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));
 }
Ejemplo n.º 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');
 }
Ejemplo n.º 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'));
     }
     // 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'])));
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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');
     }
 }
Ejemplo n.º 7
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // init vars
     $templates = array();
     $theme = BackendModel::getModuleSetting('core', 'theme');
     $files[] = BACKEND_PATH . '/core/layout/editor_templates/templates.js';
     $themePath = FRONTEND_PATH . '/themes/' . $theme . '/core/layout/editor_templates/templates.js';
     if (SpoonFile::exists($themePath)) {
         $files[] = $themePath;
     }
     // loop all files
     foreach ($files as $file) {
         // process file
         $templates = array_merge($templates, $this->processFile($file));
     }
     // set headers
     SpoonHTTP::setHeaders('Content-type: text/javascript');
     // output the templates
     if (!empty($templates)) {
         echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n";
         echo json_encode($templates) . "\n";
         echo '});';
     }
     exit;
 }
Ejemplo n.º 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
     $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()));
     }
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized', 'message' => BL::msg('Redirecting')), 'No longer authorized.');
     }
     // get data
     $this->getData();
     // get html
     $referrersHtml = $this->parseReferrers();
     $keywordsHtml = $this->parseKeywords();
     // return status
     $this->output(self::OK, array('status' => 'success', 'referrersHtml' => $referrersHtml, 'keywordsHtml' => $keywordsHtml, 'date' => BL::lbl('Today'), 'message' => BL::msg('RefreshedTrafficSources')), 'Data has been retrieved.');
 }
Ejemplo n.º 10
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');
     }
 }
Ejemplo n.º 11
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
     $newSequence = SpoonFilter::getPostValue('new_sequence', null, '');
     // validate
     if ($newSequence == '') {
         $this->output(self::BAD_REQUEST, null, 'no new_sequence provided');
     }
     // convert into array
     $json = @json_decode($newSequence, true);
     // validate
     if ($json === false) {
         $this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided');
     }
     // initialize
     $userSequence = array();
     $hiddenItems = array();
     // loop columns
     foreach ($json as $column => $widgets) {
         $columnValue = 'left';
         if ($column == 1) {
             $columnValue = 'middle';
         }
         if ($column == 2) {
             $columnValue = 'right';
         }
         // loop widgets
         foreach ($widgets as $sequence => $widget) {
             // store position
             $userSequence[$widget['module']][$widget['widget']] = array('column' => $columnValue, 'position' => $sequence, 'hidden' => $widget['hidden'], 'present' => $widget['present']);
             // add to array
             if ($widget['hidden']) {
                 $hiddenItems[] = $widget['module'] . '_' . $widget['widget'];
             }
         }
     }
     // get previous setting
     $currentSetting = BackendAuthentication::getUser()->getSetting('dashboard_sequence');
     $data['reload'] = false;
     // any settings?
     if ($currentSetting !== null) {
         // loop modules
         foreach ($currentSetting as $module => $widgets) {
             foreach ($widgets as $widget => $values) {
                 if ($values['hidden'] && isset($userSequence[$module][$widget]['hidden']) && !$userSequence[$module][$widget]['hidden']) {
                     $data['reload'] = true;
                 }
             }
         }
     }
     // store
     BackendAuthentication::getUser()->setSetting('dashboard_sequence', $userSequence);
     // output
     $this->output(self::OK, $data, BL::msg('Saved'));
 }
Ejemplo n.º 12
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();
     // 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);
     }
 }
Ejemplo n.º 13
0
 /**
  * You have to specify the action and module so we know what to do with this instance
  *
  * @param string $action The action to load.
  * @param string $module The module to load.
  */
 public function __construct($action, $module)
 {
     $this->setModule($module);
     $this->setAction($action);
     $this->loadConfig();
     $allowed = false;
     // is this an allowed action
     if (BackendAuthentication::isAllowedAction($action, $this->getModule())) {
         $allowed = true;
     }
     // is this an allowed AJAX-action?
     if (!$allowed) {
         // set correct headers
         SpoonHTTP::setHeadersByCode(403);
         // output
         $fakeAction = new BackendBaseAJAXAction('', '');
         $fakeAction->output(BackendBaseAJAXAction::FORBIDDEN, null, 'Not logged in.');
     }
 }
Ejemplo n.º 14
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);
     }
     // check input
     if (empty($url)) {
         $this->output(self::BAD_REQUEST, array('field' => 'url'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($username)) {
         $this->output(self::BAD_REQUEST, array('field' => 'username'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($password)) {
         $this->output(self::BAD_REQUEST, array('field' => 'password'), BL::err('NoCMAccountCredentials'));
     }
     try {
         // check if the CampaignMonitor class exists
         if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) {
             // the class doesn't exist, so stop here
             $this->output(self::BAD_REQUEST, null, BL::err('ClassDoesNotExist', $this->getModule()));
         }
         // require CampaignMonitor class
         require_once 'external/campaignmonitor.php';
         // init CampaignMonitor object
         new CampaignMonitor($url, $username, $password, 10);
         // save the new data
         BackendModel::setModuleSetting($this->getModule(), 'cm_url', $url);
         BackendModel::setModuleSetting($this->getModule(), 'cm_username', $username);
         BackendModel::setModuleSetting($this->getModule(), 'cm_password', $password);
         // account was linked
         BackendModel::setModuleSetting($this->getModule(), 'cm_account', true);
     } catch (Exception $e) {
         // timeout occured
         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()));
     }
     // 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()));
 }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
 /**
  * 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);
 }
Ejemplo n.º 17
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
     $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');
 }
Ejemplo n.º 18
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $itemId = trim(SpoonFilter::getPostValue('id', null, '', 'int'));
     $lat = SpoonFilter::getPostValue('lat', null, null, 'float');
     $lng = SpoonFilter::getPostValue('lng', null, null, 'float');
     if ($itemId == 0) {
         $this->output(self::BAD_REQUEST, null, BL::err('NonExisting'));
     }
     $updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage());
     BackendLocationModel::update($updateData);
     // output
     $this->output(self::OK);
 }
Ejemplo n.º 19
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
     $term = SpoonFilter::getGetValue('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);
 }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
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
     $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);
 }
Ejemplo n.º 22
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
     $mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
     $subject = SpoonFilter::getPostValue('subject', null, '');
     $contentHTML = urldecode(SpoonFilter::getPostValue('content_html', null, ''));
     $contentPlain = SpoonFilter::getPostValue('content_plain', null, '');
     $fullContentHTML = SpoonFilter::getPostValue('full_content_html', null, '');
     // validate mailing ID
     if ($mailingId == '') {
         $this->output(self::BAD_REQUEST, null, 'No mailing ID provided');
     }
     // get mailing record
     $this->mailing = BackendMailmotorModel::getMailing($mailingId);
     // record is empty
     if (empty($this->mailing)) {
         $this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', $this->getModule()));
     }
     // validate other fields
     if ($subject == '') {
         $this->output(900, array('element' => 'subject', 'element_error' => BL::err('NoSubject', $this->getModule())), BL::err('FormError'));
     }
     // set full HTML
     $HTML = $this->getEmailContent($this->mailing['template'], $contentHTML, $fullContentHTML);
     // set plain content
     $contentPlain = empty($contentPlain) ? SpoonFilter::stripHTML($HTML) : $contentPlain;
     // add unsubscribe link
     if (mb_strpos($contentPlain, '[unsubscribe]') === false) {
         $contentPlain .= PHP_EOL . '[unsubscribe]';
     }
     // build data
     $item['id'] = $this->mailing['id'];
     $item['subject'] = $subject;
     $item['content_plain'] = $contentPlain;
     $item['content_html'] = $contentHTML;
     $item['data'] = serialize(array('full_content_html' => $HTML));
     $item['edited_on'] = date('Y-m-d H:i:s');
     // update mailing
     BackendMailmotorModel::updateMailing($item);
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step3', array('item' => $item));
     // output
     $this->output(self::OK, array('mailing_id' => $mailingId), BL::msg('MailingEdited', $this->getModule()));
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $generalSettings = BackendModel::getModuleSettings();
     $generalSettings = $generalSettings['location'];
     // get parameters
     $itemId = SpoonFilter::getPostValue('id', null, null, 'int');
     $zoomLevel = trim(SpoonFilter::getPostValue('zoom', null, 'auto'));
     $mapType = strtoupper(trim(SpoonFilter::getPostValue('type', array('roadmap', 'satelitte', 'hybrid', 'terrain'), 'roadmap')));
     $centerLat = SpoonFilter::getPostValue('centerLat', null, 1, 'float');
     $centerlng = SpoonFilter::getPostValue('centerLng', null, 1, 'float');
     $height = SpoonFilter::getPostValue('height', null, $generalSettings['height'], 'int');
     $width = SpoonFilter::getPostValue('width', null, $generalSettings['width'], 'int');
     $showLink = SpoonFilter::getPostValue('link', array('true', 'false'), 'false', 'string');
     $showDirections = SpoonFilter::getPostValue('directions', array('true', 'false'), 'false', 'string');
     $showOverview = SpoonFilter::getPostValue('showOverview', array('true', 'false'), 'true', 'string');
     // reformat
     $center = array('lat' => $centerLat, 'lng' => $centerlng);
     $showLink = $showLink == 'true';
     $showDirections = $showDirections == 'true';
     $showOverview = $showOverview == 'true';
     // standard dimensions
     if ($width > 800) {
         $width = 800;
     }
     if ($width < 300) {
         $width = $generalSettings['width'];
     }
     if ($height < 150) {
         $height = $generalSettings['height'];
     }
     // no id given, this means we should update the main map
     BackendLocationModel::setMapSetting($itemId, 'zoom_level', (string) $zoomLevel);
     BackendLocationModel::setMapSetting($itemId, 'map_type', (string) $mapType);
     BackendLocationModel::setMapSetting($itemId, 'center', (array) $center);
     BackendLocationModel::setMapSetting($itemId, 'height', (int) $height);
     BackendLocationModel::setMapSetting($itemId, 'width', (int) $width);
     BackendLocationModel::setMapSetting($itemId, 'directions', $showDirections);
     BackendLocationModel::setMapSetting($itemId, 'full_url', $showLink);
     $item = array('id' => $itemId, 'language' => BL::getWorkingLanguage(), 'show_overview' => $showOverview ? 'Y' : 'N');
     BackendLocationModel::update($item);
     // output
     $this->output(self::OK, null, FL::msg('Success'));
 }
Ejemplo n.º 24
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');
     }
     // invalid fieldId
     if (!BackendFormBuilderModel::existsField($fieldId, $formId)) {
         $this->output(self::BAD_REQUEST, null, 'field does not exist');
     }
     // get field
     $field = BackendFormBuilderModel::getField($fieldId);
     // success output
     $this->output(self::OK, array('field' => $field));
 }
Ejemplo n.º 25
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $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::exists($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) {
         $item['id'] = $questionId;
         $item['category_id'] = $toCategoryId;
         BackendFaqModel::update($item);
         // loop id's and set new sequence
         foreach ($toCategorySequence as $i => $id) {
             $item = array();
             $item['id'] = (int) $id;
             $item['sequence'] = $i + 1;
             // update sequence if the item exists
             if (BackendFaqModel::exists($item['id'])) {
                 BackendFaqModel::update($item);
             }
         }
     }
     // loop id's and set new sequence
     foreach ($fromCategorySequence as $i => $id) {
         $item['id'] = (int) $id;
         $item['sequence'] = $i + 1;
         // update sequence if the item exists
         if (BackendFaqModel::exists($item['id'])) {
             BackendFaqModel::update($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Ejemplo n.º 26
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.');
     }
     // 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(900, null, BL::err('MailingAlreadySent', $this->getModule()));
     }
     // 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 {
             BackendMailmotorCMHelper::sendMailing($mailing);
         }
     } catch (Exception $e) {
         // stop the script and show our error
         $this->output(902, null, $e->getMessage());
     }
     // 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()));
 }
Ejemplo n.º 27
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::getGetValue('form_id', null, '', 'int'));
     $fieldId = trim(SpoonFilter::getGetValue('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);
     // success output
     $this->output(self::OK, array('field' => $field));
 }
Ejemplo n.º 28
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
     $newIdSequence = trim(SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // list id
     $ids = (array) explode(',', rtrim($newIdSequence, ','));
     // loop id's and set new sequence
     foreach ($ids as $i => $id) {
         // build item
         $item['id'] = (int) $id;
         // change sequence
         $item['sequence'] = $i + 1;
         // update sequence
         if (BackendFaqModel::existsCategory($item['id'])) {
             BackendFaqModel::updateCategory($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Ejemplo n.º 29
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = SpoonFilter::getPostValue('form_id', null, '', 'int');
     $fieldId = SpoonFilter::getPostValue('field_id', null, '', 'int');
     $type = SpoonFilter::getPostValue('type', array('checkbox', 'dropdown', 'heading', 'paragraph', 'radiobutton', 'submit', 'textarea', 'textbox'), '', 'string');
     $label = trim(SpoonFilter::getPostValue('label', null, '', 'string'));
     $values = trim(SpoonFilter::getPostValue('values', null, '', 'string'));
     $defaultValues = trim(SpoonFilter::getPostValue('default_values', null, '', 'string'));
     $required = SpoonFilter::getPostValue('required', array('Y', 'N'), 'N', 'string');
     $requiredErrorMessage = trim(SpoonFilter::getPostValue('required_error_message', null, '', 'string'));
     $validation = SpoonFilter::getPostValue('validation', array('email', 'numeric'), '', 'string');
     $validationParameter = trim(SpoonFilter::getPostValue('validation_parameter', null, '', 'string'));
     $errorMessage = trim(SpoonFilter::getPostValue('error_message', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     }
     // invalid fieldId
     if ($fieldId !== 0 && !BackendFormBuilderModel::existsField($fieldId, $formId)) {
         $this->output(self::BAD_REQUEST, null, 'field does not exist');
     }
     // invalid type
     if ($type == '') {
         $this->output(self::BAD_REQUEST, null, 'invalid type provided');
     }
     // init
     $errors = array();
     // validate textbox
     if ($type == 'textbox') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($validation != '' && $errorMessage == '') {
             $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     } elseif ($type == 'textarea') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($validation != '' && $errorMessage == '') {
             $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     } elseif ($type == 'heading' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'paragraph' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'submit' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'dropdown') {
         // values trim
         $values = trim($values, ',');
         // validate
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($values == '') {
             $errors['values'] = BL::getError('ValueIsRequired');
         }
     } elseif ($type == 'radiobutton') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($values == '') {
             $errors['values'] = BL::getError('ValueIsRequired');
         }
     } elseif ($type == 'checkbox') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     }
     // got errors
     if (!empty($errors)) {
         $this->output(self::OK, array('errors' => $errors), 'form contains errors');
     }
     // htmlspecialchars except for paragraphs
     if ($type != 'paragraph') {
         if ($values != '') {
             $values = SpoonFilter::htmlspecialchars($values);
         }
         if ($defaultValues != '') {
             $defaultValues = SpoonFilter::htmlspecialchars($defaultValues);
         }
     }
     // split
     if ($type == 'dropdown' || $type == 'radiobutton' || $type == 'checkbox') {
         $values = (array) explode('|', $values);
     }
     /**
      * Save!
      */
     // settings
     $settings = array();
     if ($label != '') {
         $settings['label'] = SpoonFilter::htmlspecialchars($label);
     }
     if ($values != '') {
         $settings['values'] = $values;
     }
     if ($defaultValues != '') {
         $settings['default_values'] = $defaultValues;
     }
     // build array
     $field = array();
     $field['form_id'] = $formId;
     $field['type'] = $type;
     $field['settings'] = !empty($settings) ? serialize($settings) : null;
     // existing field
     if ($fieldId !== 0) {
         // update field
         BackendFormBuilderModel::updateField($fieldId, $field);
         // delete all validation (added again later)
         BackendFormBuilderModel::deleteFieldValidation($fieldId);
     } else {
         // sequence
         $field['sequence'] = BackendFormBuilderModel::getMaximumSequence($formId) + 1;
         // insert
         $fieldId = BackendFormBuilderModel::insertField($field);
     }
     // required
     if ($required == 'Y') {
         // build array
         $validate['field_id'] = $fieldId;
         $validate['type'] = 'required';
         $validate['error_message'] = SpoonFilter::htmlspecialchars($requiredErrorMessage);
         // add validation
         BackendFormBuilderModel::insertFieldValidation($validate);
         // add to field (for parsing)
         $field['validations']['required'] = $validate;
     }
     // other validation
     if ($validation != '') {
         // build array
         $validate['field_id'] = $fieldId;
         $validate['type'] = $validation;
         $validate['error_message'] = SpoonFilter::htmlspecialchars($errorMessage);
         $validate['parameter'] = $validationParameter != '' ? SpoonFilter::htmlspecialchars($validationParameter) : null;
         // add validation
         BackendFormBuilderModel::insertFieldValidation($validate);
         // add to field (for parsing)
         $field['validations'][$type] = $validate;
     }
     // get item from database (i do this call again to keep the points of failure as low as possible)
     $field = BackendFormBuilderModel::getField($fieldId);
     // submit button isnt parsed but handled directly via javascript
     if ($type == 'submit') {
         $fieldHTML = '';
     } else {
         $fieldHTML = FormBuilderHelper::parseField($field);
     }
     // success output
     $this->output(self::OK, array('field_id' => $fieldId, 'field_html' => $fieldHTML), 'field saved');
 }
Ejemplo n.º 30
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
     $page = trim(SpoonFilter::getPostValue('page', null, ''));
     $identifier = trim(SpoonFilter::getPostValue('identifier', null, ''));
     // validate
     if ($page == '' || $identifier == '') {
         $this->output(self::BAD_REQUEST, null, 'No page provided.');
     }
     // init vars
     $filename = BACKEND_CACHE_PATH . '/analytics/' . $page . '_' . $identifier . '.txt';
     // does the temporary file still exits?
     $status = SpoonFile::getContent($filename);
     // no file - create one
     if ($status === false) {
         // create file with initial counter
         SpoonFile::setContent($filename, 'missing1');
         // return status
         $this->output(self::OK, array('status' => false), 'Temporary file was missing. We created one.');
     }
     // busy status
     if (strpos($status, 'busy') !== false) {
         // get counter
         $counter = (int) substr($status, 4) + 1;
         // file's been busy for more than hundred cycles - just stop here
         if ($counter > 100) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'timeout'), 'Error while retrieving data - the script took too long to retrieve data.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'busy' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Data is being retrieved. (' . $counter . ')');
     }
     // unauthorized status
     if ($status == 'unauthorized') {
         // remove file
         SpoonFile::delete($filename);
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized'), 'No longer authorized.');
     }
     // done status
     if ($status == 'done') {
         // remove file
         SpoonFile::delete($filename);
         // return status
         $this->output(self::OK, array('status' => 'done'), 'Data retrieved.');
     }
     // missing status
     if (strpos($status, 'missing') !== false) {
         // get counter
         $counter = (int) substr($status, 7) + 1;
         // file's been missing for more than ten cycles - just stop here
         if ($counter > 10) {
             // remove file
             SpoonFile::delete($filename);
             // return status
             $this->output(self::ERROR, array('status' => 'missing'), 'Error while retrieving data - file was never created.');
         }
         // change file content to increase counter
         SpoonFile::setContent($filename, 'missing' . $counter);
         // return status
         $this->output(self::OK, array('status' => 'busy'), 'Temporary file was still in status missing. (' . $counter . ')');
     }
     /* FALLBACK - SOMETHING WENT WRONG */
     // remove file
     SpoonFile::delete($filename);
     // return status
     $this->output(self::ERROR, array('status' => 'error'), 'Error while retrieving data.');
 }