/** * Execute the action */ public function execute() { parent::execute(); // action to execute $action = SpoonFilter::getGetValue('action', array('deleteImages', 'deleteFiles', 'deleteVideos'), 'delete'); if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('index') . '&error=no-selection'); } else { // redefine id's $aIds = (array) $_GET['id']; $agendaID = (int) $_GET['agenda_id']; // delete media if ($action == 'deleteImages') { BackendAgendaModel::deleteImage($aIds); } else { if ($action == 'deleteFiles') { BackendAgendaModel::deleteFile($aIds); } else { if ($action == 'deleteVideos') { BackendAgendaModel::deleteVideo($aIds); } } } } $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $agendaID . '&report=deleted'); }
/** * Execute the action */ public function execute() { parent::execute(); BackendAgendaModel::deleteSubscribedSubscriptions(); // item was deleted, so redirect $this->redirect(BackendModel::createURLForAction('subscriptions') . '&report=deleted-subscribed#tabSubscribed'); }
/** * Execute the action */ public function execute() { parent::execute(); // current status $from = \SpoonFilter::getGetValue('from', array('subscribed', 'moderation'), 'subscribed'); // action to execute $action = \SpoonFilter::getGetValue('action', array('subscribed', 'moderation', 'delete'), 'moderation'); // no id's provided if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('subscriptions') . '&error=no-subscriptions-selected'); } // redefine id's $ids = (array) $_GET['id']; // delete comment(s) if ($action == 'delete') { BackendAgendaModel::deleteSubscriptions($ids); } else { // set new status BackendAgendaModel::updateSubscriptionStatuses($ids, $action); } // define report $report = count($ids) > 1 ? 'subscriptions-' : 'subscription-'; // init var if ($action == 'subscribed') { $report .= 'moved-subscribed'; } if ($action == 'moderation') { $report .= 'moved-moderation'; } if ($action == 'delete') { $report .= 'deleted'; } // redirect $this->redirect(BackendModel::createURLForAction('subscriptions') . '&report=' . $report . '#tab' . \SpoonFilter::ucfirst($from)); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendAgendaModel::exists($this->id)) { parent::execute(); $this->record = (array) BackendAgendaModel::get($this->id); BackendAgendaModel::delete($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
public function execute() { 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) { $item['id'] = $id; $item['sequence'] = $i + 1; // update sequence if (BackendAgendaModel::existsCategory($id)) { BackendAgendaModel::updateCategory($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendAgendaModel::existsCategory($this->id)) { $this->record = (array) BackendAgendaModel::getCategory($this->id); if (BackendAgendaModel::deleteCategoryAllowed($this->id)) { parent::execute(); // delete item BackendAgendaModel::deleteCategory($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record)); // category was deleted, so redirect $this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title'])); } } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing'); } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->meta->setURLCallback('Backend\\Modules\\Agenda\\Engine\\Model', 'getURLForCategory'); $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['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['meta_id'] = $this->meta->save(); $item['sequence'] = BackendAgendaModel::getMaximumCategorySequence() + 1; // save the data $item['id'] = BackendAgendaModel::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']); } } }
/** * Validate the form */ protected 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 $image = $this->frm->getField('image'); $this->frm->getField('title')->isFilled(BL::err('NameIsRequired')); if ($this->image['filename'] === null) { $image->isFilled(BL::err('FieldIsRequired')); } // no errors? if ($this->frm->isCorrect()) { // build image record to insert $item['id'] = $this->id; $item['title'] = $this->frm->getField('title')->getValue(); $item['filename'] = $this->image['filename']; // set files path for this record $path = FRONTEND_FILES_PATH . '/' . $this->module . '/' . $this->itemId; $formats = array(); $formats[] = array('size' => '64x64', 'force_aspect_ratio' => false); $formats[] = array('size' => '128x128', 'force_aspect_ratio' => false); if ($image->isFilled()) { // only delete the picture when there is one allready if (!empty($item['filename'])) { $fs = new Filesystem(); $fs->remove(FRONTEND_FILES_PATH . '/agenda/thumbnails/' . $item['filename']); $fs->remove(FRONTEND_FILES_PATH . '/agenda/' . $item['filename']); } // overwrite the filename if ($item['filename'] === null) { $item['filename'] = time() . '.' . $image->getExtension(); } // add images BackendAgendaHelper::addImages($image, $path, $item['filename'], $formats); } // save the item $id = BackendAgendaModel::saveImage($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_image', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $this->itemId . '&report=edited&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Validate the form */ protected function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validation $fields = $this->frm->getFields(); $fields['title']->isFilled(BL::err('FieldIsRequired')); $fields['begin_date_date']->isFilled(BL::err('FieldIsRequired')); $fields['begin_date_time']->isFilled(BL::err('FieldIsRequired')); $fields['begin_date_date']->isValid(BL::err('DateIsInvalid')); $fields['begin_date_time']->isValid(BL::err('TimeIsInvalid')); $fields['end_date_date']->isFilled(BL::err('FieldIsRequired')); $fields['end_date_time']->isFilled(BL::err('FieldIsRequired')); $fields['end_date_date']->isValid(BL::err('DateIsInvalid')); $fields['end_date_time']->isValid(BL::err('TimeIsInvalid')); $fields['category_id']->isFilled(BL::err('FieldIsRequired')); if ($fields['price']->isFilled()) { $fields['price']->isPrice(BL::err('InvalidValue')); } // validate meta $this->meta->validate(); $this->media->validate(); if ($this->frm->isCorrect()) { $item['id'] = $this->id; $item['language'] = BL::getWorkingLanguage(); $item['title'] = $fields['title']->getValue(); $item['text'] = $fields['text']->getValue(); $item['introduction'] = $fields['introduction']->getValue(); $item['begin_date'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('begin_date_date'), $this->frm->getField('begin_date_time'))); $item['end_date'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('end_date_date'), $this->frm->getField('end_date_time'))); $item['category_id'] = $this->frm->getField('category_id')->getValue(); $item['price'] = $fields['price']->getValue(); $item['whole_day'] = $fields['whole_day']->getChecked() ? 'Y' : 'N'; $item['recurring'] = $fields['recurring']->getChecked() ? 'Y' : 'N'; $item['allow_subscriptions'] = $fields['subscriptions']->getValue(); $item['google_maps'] = $fields['google_maps']->getChecked() ? 'Y' : 'N'; $item['location_name'] = $fields['name']->getValue(); $item['street'] = $fields['street']->getValue(); $item['number'] = $fields['number']->getValue(); $item['zip'] = $fields['zip']->getValue(); $item['city'] = $fields['city']->getValue(); $item['country'] = $fields['country']->getValue(); $item['meta_id'] = $this->meta->save(); // 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; // update item BackendAgendaModel::update($item); $item['id'] = $this->id; // recurring item if ($item['recurring'] == 'Y') { $recurringItem['id'] = $this->recurringOptions['id']; $recurringItem['agenda_id'] = $item['id']; $recurringItem['type'] = $fields['type']->getValue(); $recurringItem['interval'] = $fields['interval']->getValue(); $recurringItem['ends_on'] = $fields['ends_on']->getValue(); // if recurring type is weekly, get days checked if ($recurringItem['type'] == 1) { $days = $fields['days']->getChecked(); $recurringItem['days'] = implode(",", $days); } // if item ends on x amount of times if ($recurringItem['ends_on'] == 1) { $recurringItem['frequency'] = $fields['frequency']->getValue(); } else { if ($recurringItem['ends_on'] == 2) { // item ends on specific date // check date/time fields if ($fields['recurr_end_date_date']->isFilled() || $fields['recurr_end_date_time']->isFilled()) { $recurringItem['end_date'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('recurr_end_date_date'), $this->frm->getField('recurr_end_date_time'))); } } } // update if options exist if (BackendAgendaModel::existsRecurringOptions($recurringItem['id'], $recurringItem['agenda_id'])) { BackendAgendaModel::updateRecurringOptions($recurringItem); } else { // insert new options BackendAgendaModel::insertRecurringOptions($recurringItem); } } // add search index BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'Text' => $item['text'])); BackendModel::triggerEvent($this->getModule(), 'after_edit', $item); $this->redirect(BackendModel::createURLForAction('index') . '&report=edited&highlight=row-' . $item['id']); } } }
/** * Validate the form */ protected 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('NameIsRequired')); $this->frm->getField('video')->isFilled(BL::err('FieldIsRequired')); // no errors? if ($this->frm->isCorrect()) { // build image record to insert $item['id'] = $this->id; $item['title'] = $this->frm->getField('title')->getValue(); $item['filename'] = $this->frm->getField('video')->getValue(); // save the item $id = BackendAgendaModel::saveVideo($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_video', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $this->itemId . '&report=edited&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabVideos'); } } }
/** * 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('name')->isFilled(BL::err('AuthorIsRequired')); $this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid')); // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['status'] = $this->record['status']; $item['name'] = $this->frm->getField('name')->getValue(); $item['email'] = $this->frm->getField('email')->getValue(); // insert the item BackendAgendaModel::updateSubscription($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_subscription', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('subscriptions') . '&report=edited-subscription&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . \SpoonFilter::toCamelCase($item['status'])); } } }
/** * 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 $image = $this->frm->getField('image'); $this->frm->getField('title')->isFilled(BL::err('NameIsRequired')); $image->isFilled(BL::err('FieldIsRequired')); $settings = BackendModel::get('fork.settings')->getForModule('Agenda'); // no errors? if ($this->frm->isCorrect()) { // build image record to insert $item['agenda_id'] = $this->item['id']; $item['title'] = $this->frm->getField('title')->getValue(); // set files path for this record $path = FRONTEND_FILES_PATH . '/' . $this->module . '/' . $item['agenda_id']; // set formats $formats = array(); $formats[] = array('size' => '64x64', 'allow_enlargement' => true, 'force_aspect_ratio' => false); $formats[] = array('size' => '128x128', 'allow_enlargement' => true, 'force_aspect_ratio' => false); $formats[] = array('size' => $settings['width1'] . 'x' . $settings['height1'], 'allow_enlargement' => $settings['allow_enlargement1'], 'force_aspect_ratio' => $settings['force_aspect_ratio1']); $formats[] = array('size' => $settings['width2'] . 'x' . $settings['height2'], 'allow_enlargement' => $settings['allow_enlargement2'], 'force_aspect_ratio' => $settings['force_aspect_ratio2']); $formats[] = array('size' => $settings['width3'] . 'x' . $settings['height3'], 'allow_enlargement' => $settings['allow_enlargement3'], 'force_aspect_ratio' => $settings['force_aspect_ratio3']); // set the filename $item['filename'] = time() . '.' . $image->getExtension(); $item['sequence'] = BackendAgendaModel::getMaximumImagesSequence($item['agenda_id']) + 1; // add images BackendAgendaHelper::addImages($image, $path, $item['filename'], $formats); // save the item $item['id'] = BackendAgendaModel::saveImage($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_image', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $item['agenda_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * 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 $file = $this->frm->getField('file'); $this->frm->getField('title')->isFilled(BL::err('NameIsRequired')); $file->isFilled(BL::err('FieldIsRequired')); // validate the file if ($this->frm->getField('file')->isFilled()) { // file extension $this->frm->getField('file')->isAllowedExtension($this->allowedExtensions, BL::err('FileExtensionNotAllowed')); } // no errors? if ($this->frm->isCorrect()) { // build file record to insert $item['agenda_id'] = $this->item['id']; $item['title'] = $this->frm->getField('title')->getValue(); // the file path $filePath = FRONTEND_FILES_PATH . '/' . $this->getModule() . '/' . $item['agenda_id'] . '/source'; // create folders if needed if (!\SpoonDirectory::exists($filePath)) { \SpoonDirectory::create($filePath); } // file provided? if ($file->isFilled()) { // build the file name $item['filename'] = time() . '.' . $file->getExtension(); // upload the file $file->moveFile($filePath . '/' . $item['filename']); } $item['sequence'] = BackendAgendaModel::getMaximumFilesSequence($item['agenda_id']) + 1; // insert it $item['id'] = BackendAgendaModel::saveFile($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_file', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $item['agenda_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabFiles'); } } }
/** * Gets all necessary data */ protected function getData() { $this->item = BackendAgendaModel::get($this->id); }
/** * Validate the form */ protected 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 $file = $this->frm->getField('file'); $this->frm->getField('title')->isFilled(BL::err('NameIsRequired')); if ($this->file['filename'] === null) { $file->isFilled(BL::err('FieldIsRequired')); } // validate the file if ($this->frm->getField('file')->isFilled()) { // file extension $this->frm->getField('file')->isAllowedExtension($this->allowedExtensions, BL::err('FileExtensionNotAllowed')); } // no errors? if ($this->frm->isCorrect()) { // build image record to insert $item['id'] = $this->id; $item['title'] = $this->frm->getField('title')->getValue(); $item['filename'] = $this->file['filename']; // the file path $filePath = FRONTEND_FILES_PATH . '/' . $this->getModule() . '/' . $this->itemId . '/source'; if ($file->isFilled()) { $item['filename'] = time() . '.' . $file->getExtension(); $file->moveFile($filePath . '/' . $item['filename']); } // save the item $id = BackendAgendaModel::saveFile($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_file', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $this->itemId . '&report=edited&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabFiles'); } } }