/** * Execute the action */ 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) { // build item $item['id'] = (int) $id; // change sequence $item['sequence'] = $i + 1; // update sequence if (BackendGalleriaModel::existsAlbum($item['id'])) { BackendGalleriaModel::updateAlbum($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * Validate the form * * @return void */ private function validateForm() { //--Check if the form is 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')); // no errors? if ($this->frm->isCorrect()) { // first, build the album array $album['id'] = (int) $this->id; $album['extra_id'] = $this->record['extra_id']; $album['title'] = (string) $this->frm->getField('title')->getValue(); $album['description'] = (string) $this->frm->getField('description')->getValue(); $album['category_id'] = (int) $this->frm->getField('category')->getValue(); $album['meta_id'] = $this->meta->save(); $album['language'] = (string) BL::getWorkingLanguage(); $album['hidden'] = (string) $this->frm->getField('hidden')->getValue(); $album['show_in_overview'] = (string) $this->frm->getField('show_in_overview')->getValue(); // ... then, update the album BackendGalleriaModel::updateAlbum($album); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_album', array('item' => $album)); // save the tags BackendTagsModel::saveTags($album['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('albums') . '&report=edited-album&var=' . urlencode($album['title']) . '&highlight=row-' . $album['id']); } } }