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');
 }
Beispiel #2
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setUrlCallback('Backend\\Modules\\Agenda\\Engine\\Model', '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
             BackendAgendaModel::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']);
         }
     }
 }