Example #1
0
 /**
  * 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 (BackendGalleryModel::existsAlbum($item['id'])) {
             BackendGalleryModel::updateAlbum($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Example #2
0
 /**
  * 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_gallery'] = $this->record['extra_id_gallery'];
             $album['extra_id_slideshow'] = $this->record['extra_id_slideshow'];
             $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
             BackendGalleryModel::updateAlbum($album, (bool) $this->frm->getField('gallery')->getValue(), (bool) $this->frm->getField('slideshow')->getValue());
             // 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']);
         }
     }
 }