Пример #1
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'])));
 }
Пример #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));
 }
Пример #3
0
 /**
  * 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 field
         $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
         $this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
         if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
             $this->frm->getField('term')->addError(BL::err('TermExists'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item = array();
             $item['term'] = $this->frm->getField('term')->getValue();
             $item['synonym'] = $this->frm->getField('synonym')->getValue();
             $item['language'] = BL::getWorkingLanguage();
             // insert the item
             $id = BackendSearchModel::insertSynonym($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('synonyms') . '&report=added-synonym&var=' . urlencode($item['term']) . '&highlight=row-' . $id);
         }
     }
 }
Пример #4
0
 private function validateForm()
 {
     if ($this->form->isSubmitted()) {
         $fields = $this->form->getFields();
         if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
             return;
         }
         if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
             return;
         }
         $newStartDate = Model::getUTCTimestamp($fields['start_date']);
         $newEndDate = Model::getUTCTimestamp($fields['end_date']);
         // startdate cannot be before 2005 (earliest valid google startdate)
         if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         // enddate cannot be in the future
         if ($newEndDate > time()) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         // enddate cannot be before the startdate
         if ($newStartDate > $newEndDate) {
             $fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
         }
         if ($this->form->isCorrect()) {
             $this->startDate = $newStartDate;
             $this->endDate = $newEndDate;
         }
     }
 }
Пример #5
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');
         // validate fields
         if ($txtName->isFilled(BL::err('NameIsRequired'))) {
             if ($txtName->getValue() != $this->record['name'] && BackendMailmotorModel::existsCampaignByName($txtName->getValue())) {
                 $txtName->addError(BL::err('CampaignExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['name'] = $txtName->getValue();
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             // update the item
             BackendMailmotorModel::updateCampaign($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_campaign', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('campaigns') . '&report=edited&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
         }
     }
 }
Пример #6
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()));
     }
 }
Пример #7
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']);
         }
     }
 }
Пример #8
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // redefine fields
         $fileFile = $this->frm->getField('file');
         $chkOverwrite = $this->frm->getField('overwrite');
         // name checks
         if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
             // only xml files allowed
             if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) {
                 // load xml
                 $xml = @simplexml_load_file($fileFile->getTempFileName());
                 // invalid xml
                 if ($xml === false) {
                     $fileFile->addError(BL::getError('InvalidXML'));
                 }
             }
         }
         if ($this->frm->isCorrect()) {
             // import
             $statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
             // everything is imported, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery);
         }
     }
 }
Пример #9
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired'));
         $this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->getField('website')->isFilled()) {
             $this->frm->getField('website')->isURL(BL::err('InvalidURL'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['status'] = $this->record['status'];
             $item['author'] = $this->frm->getField('author')->getValue();
             $item['email'] = $this->frm->getField('email')->getValue();
             $item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null;
             $item['text'] = $this->frm->getField('text')->getValue();
             // insert the item
             BackendBlogModel::updateComment($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . SpoonFilter::toCamelCase($item['status']));
         }
     }
 }
Пример #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
     $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'])));
 }
Пример #11
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired'));
         $this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired'));
         $this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired'));
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['meta_id'] = $this->meta->save();
             $item['category_id'] = $this->frm->getField('category_id')->getValue();
             $item['user_id'] = BackendAuthentication::getUser()->getUserId();
             $item['language'] = BL::getWorkingLanguage();
             $item['question'] = $this->frm->getField('title')->getValue();
             $item['answer'] = $this->frm->getField('answer')->getValue(true);
             $item['created_on'] = BackendModel::getUTCDate();
             $item['hidden'] = $this->frm->getField('hidden')->getValue();
             $item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1;
             // save the data
             $item['id'] = BackendFaqModel::insert($item);
             BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
             BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
             // add search index
             BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
             $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #12
0
 /**
  * Validates the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('mailer_from_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_from_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_to_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_reply_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_reply_to_email')->isEmail(BL::err('EmailIsInvalid'));
         // SMTP type was chosen
         if ($this->frm->getField('mailer_type')->getValue() == 'smtp') {
             // server & port are required
             $this->frm->getField('smtp_server')->isFilled(BL::err('FieldIsRequired'));
             $this->frm->getField('smtp_port')->isFilled(BL::err('FieldIsRequired'));
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // e-mail settings
             BackendModel::setModuleSetting('core', 'mailer_type', $this->frm->getField('mailer_type')->getValue());
             BackendModel::setModuleSetting('core', 'mailer_from', array('name' => $this->frm->getField('mailer_from_name')->getValue(), 'email' => $this->frm->getField('mailer_from_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_to', array('name' => $this->frm->getField('mailer_to_name')->getValue(), 'email' => $this->frm->getField('mailer_to_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_reply_to', array('name' => $this->frm->getField('mailer_reply_to_name')->getValue(), 'email' => $this->frm->getField('mailer_reply_to_email')->getValue()));
             // smtp settings
             BackendModel::setModuleSetting('core', 'smtp_server', $this->frm->getField('smtp_server')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_port', $this->frm->getField('smtp_port')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_username', $this->frm->getField('smtp_username')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_password', $this->frm->getField('smtp_password')->getValue());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
Пример #13
0
 /**
  * Parse the correct messages into the template
  */
 protected function parse()
 {
     parent::parse();
     // grab the error-type from the parameters
     $errorType = $this->getParameter('type');
     // set correct headers
     switch ($errorType) {
         case 'module-not-allowed':
         case 'action-not-allowed':
             SpoonHTTP::setHeadersByCode(403);
             break;
         case 'not-found':
             SpoonHTTP::setHeadersByCode(404);
             break;
     }
     // querystring provided?
     if ($this->getParameter('querystring') !== null) {
         // split into file and parameters
         $chunks = explode('?', $this->getParameter('querystring'));
         // get extension
         $extension = SpoonFile::getExtension($chunks[0]);
         // if the file has an extension it is a non-existing-file
         if ($extension != '' && $extension != $chunks[0]) {
             // set correct headers
             SpoonHTTP::setHeadersByCode(404);
             // give a nice error, so we can detect which file is missing
             echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
             // stop script execution
             exit;
         }
     }
     // assign the correct message into the template
     $this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
 }
Пример #14
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // set callback for generating an unique URL
         $this->meta->setURLCallback('BackendBlogModel', 'getURLForCategory');
         // 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();
             // insert the item
             $item['id'] = BackendBlogModel::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']);
         }
     }
 }
Пример #15
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
             $item['user_id'] = BackendAuthentication::getUser()->getUserId();
             $item['template'] = count($this->templates) > 1 ? $this->frm->getField('template')->getValue() : $this->templates[0];
             $item['language'] = BL::getWorkingLanguage();
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['text'] = $this->frm->getField('text')->getValue();
             $item['hidden'] = $this->frm->getField('hidden')->getValue() ? 'N' : 'Y';
             $item['status'] = 'active';
             $item['created_on'] = BackendModel::getUTCDate();
             $item['edited_on'] = BackendModel::getUTCDate();
             // insert the item
             $item['revision_id'] = BackendContentBlocksModel::insert($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #16
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);
     }
 }
Пример #17
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()));
 }
Пример #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);
 }
Пример #19
0
 /**
  * Checks the settings and optionally returns an array with warnings
  *
  * @return array
  */
 public static function checkSettings()
 {
     $warnings = array();
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('settings', 'mailmotor')) {
         // analytics session token
         if (BackendModel::getModuleSetting('mailmotor', 'cm_account') == false) {
             $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMAccount', 'mailmotor'), BackendModel::createURLForAction('settings', 'mailmotor')));
         } elseif (BackendModel::getModuleSetting('mailmotor', 'cm_client_id') == '') {
             // add warning
             $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMClientID', 'mailmotor'), BackendModel::createURLForAction('settings', 'mailmtor')));
         }
     }
     return $warnings;
 }
Пример #20
0
 /**
  * Checks the settings and optionally returns an array with warnings
  *
  * @return	array
  */
 public static function checkSettings()
 {
     // init var
     $warnings = array();
     // analytics session token
     if (BackendModel::getModuleSetting('analytics', 'session_token', null) == '') {
         // add warning
         $warnings[] = array('message' => sprintf(BL::err('AnalyseNoSessionToken', 'analytics'), BackendModel::createURLForAction('settings', 'analytics')));
     }
     // analytics table id (only show this error if no other exist)
     if (empty($warnings) && BackendModel::getModuleSetting('analytics', 'table_id', null) == '') {
         // add warning
         $warnings[] = array('message' => sprintf(BL::err('AnalyseNoTableId', 'analytics'), BackendModel::createURLForAction('settings', 'analytics')));
     }
     // return
     return $warnings;
 }
Пример #21
0
 /**
  * Checks the settings and optionally returns an array with warnings
  *
  * @return array
  */
 public static function checkSettings()
 {
     $warnings = array();
     // check if debug-mode is active
     if (SPOON_DEBUG) {
         $warnings[] = array('message' => BL::err('DebugModeIsActive'));
     }
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('index', 'settings')) {
         // check if the fork API keys are available
         if (self::getModuleSetting('core', 'fork_api_private_key') == '' || self::getModuleSetting('core', 'fork_api_public_key') == '') {
             $warnings[] = array('message' => sprintf(BL::err('ForkAPIKeys'), BackendModel::createURLForAction('index', 'settings')));
         }
     }
     // check for extensions warnings
     $warnings = array_merge($warnings, BackendExtensionsModel::checkSettings());
     return $warnings;
 }
Пример #22
0
 /**
  * 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'));
         $this->frm->getField('street')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('number')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('zip')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('city')->isFilled(BL::err('FieldIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['language'] = BL::getWorkingLanguage();
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['text'] = $this->frm->getField('text')->getValue();
             $item['street'] = $this->frm->getField('street')->getValue();
             $item['number'] = $this->frm->getField('number')->getValue();
             $item['zip'] = $this->frm->getField('zip')->getValue();
             $item['city'] = $this->frm->getField('city')->getValue();
             $item['country'] = $this->frm->getField('country')->getValue();
             // geocode address
             $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($item['street'] . ' ' . $item['number'] . ', ' . $item['zip'] . ' ' . $item['city'] . ', ' . SpoonLocale::getCountry($item['country'], BL::getWorkingLanguage())) . '&sensor=false';
             $geocode = json_decode(SpoonHTTP::getContent($url));
             $item['lat'] = isset($geocode->results[0]->geometry->location->lat) ? $geocode->results[0]->geometry->location->lat : null;
             $item['lng'] = isset($geocode->results[0]->geometry->location->lng) ? $geocode->results[0]->geometry->location->lng : null;
             // insert the item
             $id = BackendLocationModel::insert($item);
             // add search index
             // if(is_callable(array('BackendSearchModel', 'addIndex'))) BackendSearchModel::addIndex($this->getModule(), (int) $id, array('title' => $item['title'], 'text' => $item['text']));
             // everything is saved, so redirect to the overview
             if ($item['lat'] && $item['lng']) {
                 // trigger event
                 BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
                 // redirect
                 $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $id);
             } else {
                 $this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $id);
             }
         }
     }
 }
Пример #23
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()));
 }
Пример #24
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');
         // validate fields
         if ($txtName->isFilled(BL::err('NameIsRequired'))) {
             if (in_array($txtName->getValue(), $this->group['custom_fields'])) {
                 $txtName->addError(BL::err('CustomFieldExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             try {
                 // add the new item to the custom fields list
                 $this->group['custom_fields'][] = $txtName->getValue();
                 // set the group fields by flipping the custom fields array for this group
                 $groupFields = array_flip($this->group['custom_fields']);
                 // group custom fields found
                 if (!empty($groupFields)) {
                     // loop the group fields and empty every value
                     foreach ($groupFields as &$field) {
                         $field = '';
                     }
                 }
                 // addresses found and custom field delete with CM
                 BackendMailmotorCMHelper::createCustomField($txtName->getValue(), $this->group['id']);
                 // update custom fields for this group
                 BackendMailmotorModel::updateCustomFields($groupFields, $this->group['id']);
             } catch (Exception $e) {
                 // redirect with a custom error
                 $this->redirect(BackendModel::createURLForAction('custom_fields') . '&group_id=' . $this->group['id'] . '&error=campaign-monitor-error&var=' . urlencode($e->getMessage()));
             }
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('custom_fields') . '&group_id=' . $this->group['id'] . '&report=added&var=' . urlencode($txtName->getValue()) . '&highlight=id-' . $this->group['id']);
         }
     }
 }
Пример #25
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 fields
         $this->frm->getField('email')->isFilled(BL::err('EmailIsRequired'));
         // get addresses
         $addresses = (array) explode(',', $this->frm->getField('email')->getValue());
         // loop addresses
         foreach ($addresses as $email) {
             // validate email
             if (!SpoonFilter::isEmail(trim($email))) {
                 // add error if needed
                 $this->frm->getField('email')->addError(BL::err('ContainsInvalidEmail'));
                 // stop looking
                 break;
             }
         }
         $this->frm->getField('groups')->isFilled(BL::err('ChooseAtLeastOneGroup'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item = $this->frm->getValues();
             $item['source'] = BL::lbl('Manual');
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             // loop the groups
             foreach ($item['groups'] as $group) {
                 foreach ($addresses as $email) {
                     BackendMailmotorCMHelper::subscribe(trim($email), $group);
                 }
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_address', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('addresses') . (!empty($this->groupId) ? '&group_id=' . $this->groupId : '') . '&report=added');
         }
     }
 }
Пример #26
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setURLCallback('BackendFaqModel', 'getURLForCategory');
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         $this->meta->validate();
         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'] = BackendFaqModel::getMaximumCategorySequence() + 1;
             // save the data
             $item['id'] = BackendFaqModel::insertCategory($item);
             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']);
         }
     }
 }
Пример #27
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setUrlCallback('BackendFaqModel', 'getURLForCategory', array($this->record['id']));
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['language'] = $this->record['language'];
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['meta_id'] = $this->meta->save(true);
             // update the item
             BackendFaqModel::updateCategory($item);
             BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #28
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'));
         // validate meta
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['meta_id'] = $this->meta->save(true);
             // upate the item
             BackendBlogModel::updateCategory($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #29
0
 /**
  * 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('name')->isFilled(BL::err('NameIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['language'] = BL::getWorkingLanguage();
             $item['name'] = $this->frm->getField('name')->getValue();
             $item['sequence'] = BackendFaqModel::getMaximumCategorySequence() + 1;
             // insert the item
             $item['id'] = BackendFaqModel::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['name']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #30
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();
         // email is present
         if ($this->frm->getField('email')->isFilled(BL::err('EmailIsRequired'))) {
             // is this an email-address
             if ($this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'))) {
                 // was this emailaddress deleted before
                 if (BackendUsersModel::emailDeletedBefore($this->frm->getField('email')->getValue())) {
                     $this->frm->getField('email')->addError(sprintf(BL::err('EmailWasDeletedBefore'), BackendModel::createURLForAction('undo_delete', null, null, array('email' => $this->frm->getField('email')->getValue()))));
                 } else {
                     // email already exists
                     if (BackendUsersModel::existsEmail($this->frm->getField('email')->getValue())) {
                         $this->frm->getField('email')->addError(BL::err('EmailAlreadyExists'));
                     }
                 }
             }
         }
         // required fields
         $this->frm->getField('password')->isFilled(BL::err('PasswordIsRequired'));
         $this->frm->getField('nickname')->isFilled(BL::err('NicknameIsRequired'));
         $this->frm->getField('name')->isFilled(BL::err('NameIsRequired'));
         $this->frm->getField('surname')->isFilled(BL::err('SurnameIsRequired'));
         $this->frm->getField('interface_language')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('groups')->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->getField('password')->isFilled()) {
             if ($this->frm->getField('password')->getValue() !== $this->frm->getField('confirm_password')->getValue()) {
                 $this->frm->getField('confirm_password')->addError(BL::err('ValuesDontMatch'));
             }
         }
         // validate avatar
         if ($this->frm->getField('avatar')->isFilled()) {
             // correct extension
             if ($this->frm->getField('avatar')->isAllowedExtension(array('jpg', 'jpeg', 'gif', 'png'), BL::err('JPGGIFAndPNGOnly'))) {
                 // correct mimetype?
                 $this->frm->getField('avatar')->isAllowedMimeType(array('image/gif', 'image/jpg', 'image/jpeg', 'image/png'), BL::err('JPGGIFAndPNGOnly'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build settings-array
             $settings['nickname'] = $this->frm->getField('nickname')->getValue();
             $settings['name'] = $this->frm->getField('name')->getValue();
             $settings['surname'] = $this->frm->getField('surname')->getValue();
             $settings['interface_language'] = $this->frm->getField('interface_language')->getValue();
             $settings['date_format'] = $this->frm->getField('date_format')->getValue();
             $settings['time_format'] = $this->frm->getField('time_format')->getValue();
             $settings['datetime_format'] = $settings['date_format'] . ' ' . $settings['time_format'];
             $settings['number_format'] = $this->frm->getField('number_format')->getValue();
             $settings['csv_split_character'] = $this->frm->getField('csv_split_character')->getValue();
             $settings['csv_line_ending'] = $this->frm->getField('csv_line_ending')->getValue();
             $settings['password_key'] = uniqid();
             $settings['current_password_change'] = time();
             $settings['avatar'] = 'no-avatar.gif';
             $settings['api_access'] = (bool) $this->frm->getField('api_access')->getChecked();
             // get selected groups
             $groups = $this->frm->getField('groups')->getChecked();
             // init var
             $newSequence = BackendGroupsModel::getSetting($groups[0], 'dashboard_sequence');
             // loop through groups and collect all dashboard widget sequences
             foreach ($groups as $group) {
                 $sequences[] = BackendGroupsModel::getSetting($group, 'dashboard_sequence');
             }
             // loop through sequences
             foreach ($sequences as $sequence) {
                 // loop through modules inside a sequence
                 foreach ($sequence as $moduleKey => $module) {
                     // loop through widgets inside a module
                     foreach ($module as $widgetKey => $widget) {
                         // if widget present set true
                         if ($widget['present']) {
                             $newSequence[$moduleKey][$widgetKey]['present'] = true;
                         }
                     }
                 }
             }
             // add new sequence to settings
             $settings['dashboard_sequence'] = $newSequence;
             // build user-array
             $user['email'] = $this->frm->getField('email')->getValue();
             $user['password'] = BackendAuthentication::getEncryptedString($this->frm->getField('password')->getValue(true), $settings['password_key']);
             // save the password strength
             $passwordStrength = BackendAuthentication::checkPassword($this->frm->getField('password')->getValue(true));
             $settings['password_strength'] = $passwordStrength;
             // save changes
             $user['id'] = (int) BackendUsersModel::insert($user, $settings);
             // has the user submitted an avatar?
             if ($this->frm->getField('avatar')->isFilled()) {
                 // create new filename
                 $filename = rand(0, 3) . '_' . $user['id'] . '.' . $this->frm->getField('avatar')->getExtension();
                 // add into settings to update
                 $settings['avatar'] = $filename;
                 // resize (128x128)
                 $this->frm->getField('avatar')->createThumbnail(FRONTEND_FILES_PATH . '/backend_users/avatars/128x128/' . $filename, 128, 128, true, false, 100);
                 // resize (64x64)
                 $this->frm->getField('avatar')->createThumbnail(FRONTEND_FILES_PATH . '/backend_users/avatars/64x64/' . $filename, 64, 64, true, false, 100);
                 // resize (32x32)
                 $this->frm->getField('avatar')->createThumbnail(FRONTEND_FILES_PATH . '/backend_users/avatars/32x32/' . $filename, 32, 32, true, false, 100);
             }
             // update settings (in this case the avatar)
             BackendUsersModel::update($user, $settings);
             // save groups
             BackendGroupsModel::insertMultipleGroups($user['id'], $groups);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $user));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . $settings['nickname'] . '&highlight=row-' . $user['id']);
         }
     }
 }