Exemple #1
0
 /**
  * Loads the dataGrids
  */
 private function loadDatagrids()
 {
     // load all categories
     $categories = BackendFaqModel::getCategories(true);
     // loop categories and create a dataGrid for each one
     foreach ($categories as $categoryId => $categoryTitle) {
         $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
         $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
         $dataGrid->setColumnsHidden(array('category_id', 'sequence'));
         $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
         $dataGrid->setColumnsSequence('dragAndDropHandle');
         $dataGrid->setColumnAttributes('question', array('class' => 'title'));
         $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
         $dataGrid->setRowAttributes(array('id' => '[id]'));
         // check if this action is allowed
         if (BackendAuthentication::isAllowedAction('Edit')) {
             $dataGrid->setColumnURL('question', BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
             $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]', BL::lbl('Edit'));
         }
         // add dataGrid to list
         $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
     }
     // set empty datagrid
     $this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => '')));
     $this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid'));
     $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null));
 }
Exemple #2
0
 /**
  * Load the data
  */
 private function loadData()
 {
     $allFeedback = BackendFaqModel::getAllFeedback();
     // build the urls
     foreach ($allFeedback as $feedback) {
         $feedback['full_url'] = BackendModel::createURLForAction('Edit', 'Faq') . '&id=' . $feedback['question_id'] . '#tabFeedback';
         $this->feedback[] = $feedback;
     }
 }
Exemple #3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $feedbackId = $this->getParameter('id', 'int');
     $feedback = BackendFaqModel::getFeedback($feedbackId);
     BackendModel::triggerEvent($this->getModule(), 'after_delete_feedback', array('item' => $feedback));
     // there is no feedback data, so redirect
     if (empty($feedback)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
     BackendFaqModel::deleteFeedback($feedbackId);
     $this->redirect(BackendModel::createURLForAction('Edit') . '&amp;id=' . $feedback['question_id'] . '&report=deleted#tabFeedback');
 }
Exemple #4
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     if ($this->id !== null && BackendFaqModel::exists($this->id)) {
         parent::execute();
         $this->record = BackendFaqModel::get($this->id);
         // delete item
         BackendFaqModel::delete($this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('item' => $this->record));
         $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted&var=' . rawurlencode($this->record['question']));
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $questionId = \SpoonFilter::getPostValue('questionId', null, '', 'int');
     $fromCategoryId = \SpoonFilter::getPostValue('fromCategoryId', null, '', 'int');
     $toCategoryId = \SpoonFilter::getPostValue('toCategoryId', null, '', 'int');
     $fromCategorySequence = \SpoonFilter::getPostValue('fromCategorySequence', null, '', 'string');
     $toCategorySequence = \SpoonFilter::getPostValue('toCategorySequence', null, '', 'string');
     // invalid question id
     if (!BackendFaqModel::exists($questionId)) {
         $this->output(self::BAD_REQUEST, null, 'question does not exist');
     } else {
         // list ids
         $fromCategorySequence = (array) explode(',', ltrim($fromCategorySequence, ','));
         $toCategorySequence = (array) explode(',', ltrim($toCategorySequence, ','));
         // is the question moved to a new category?
         if ($fromCategoryId != $toCategoryId) {
             $item['id'] = $questionId;
             $item['category_id'] = $toCategoryId;
             BackendFaqModel::update($item);
             // loop id's and set new sequence
             foreach ($toCategorySequence as $i => $id) {
                 $item = array();
                 $item['id'] = (int) $id;
                 $item['sequence'] = $i + 1;
                 // update sequence if the item exists
                 if (BackendFaqModel::exists($item['id'])) {
                     BackendFaqModel::update($item);
                 }
             }
         }
         // loop id's and set new sequence
         foreach ($fromCategorySequence as $i => $id) {
             $item['id'] = (int) $id;
             $item['sequence'] = $i + 1;
             // update sequence if the item exists
             if (BackendFaqModel::exists($item['id'])) {
                 BackendFaqModel::update($item);
             }
         }
         // success output
         $this->output(self::OK, null, 'sequence updated');
     }
 }
Exemple #6
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendFaqModel::existsCategory($this->id)) {
         $this->record = (array) BackendFaqModel::getCategory($this->id);
         if (BackendFaqModel::deleteCategoryAllowed($this->id)) {
             parent::execute();
             // delete item
             BackendFaqModel::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');
     }
 }
Exemple #7
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 (BackendFaqModel::existsCategory($item['id'])) {
             BackendFaqModel::updateCategory($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Exemple #8
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setURLCallback('Backend\\Modules\\Faq\\Engine\\Model', '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']);
         }
     }
 }
Exemple #9
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setUrlCallback('Backend\\Modules\\Faq\\Engine\\Model', 'getURL', array($this->record['id']));
         $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['id'] = $this->id;
             $item['meta_id'] = $this->meta->save(true);
             $item['category_id'] = $this->frm->getField('category_id')->getValue();
             $item['language'] = $this->record['language'];
             $item['question'] = $this->frm->getField('title')->getValue();
             $item['answer'] = $this->frm->getField('answer')->getValue(true);
             $item['hidden'] = $this->frm->getField('hidden')->getValue();
             // update the item
             BackendFaqModel::update($item);
             BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
             BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item));
             // edit search index
             BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=saved&var=' . urlencode($item['question']) . '&highlight=' . $item['id']);
         }
     }
 }
Exemple #10
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($this->getModule(), $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=' . $item['id']);
         }
     }
 }
Exemple #11
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->meta->setUrlCallback('Backend\\Modules\\Faq\\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['extra_id'] = $this->record['extra_id'];
             $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']);
         }
     }
 }