public function saveSorting() { if (count($_POST['sorting'])) { foreach ($_POST['sorting'] as $topic_id => $sorting_value) { $oTopic = new ilShopTopic($topic_id); $oTopic->setCustomSorting((int) $sorting_value); $oTopic->saveCustomSorting(); } } ilUtil::sendInfo($this->lng->txt('saved_successfully')); return $this->showTopicsSortingTable(); }
public function read() { global $ilUser; // $oSettings = ilPaymentSettings::_getInstance(); $this->topics = array(); if (!in_array($this->getSortingType(), array(self::TOPICS_SORT_BY_TITLE, self::TOPICS_SORT_BY_CREATEDATE, self::TOPICS_SORT_MANUALLY))) { $this->setSortingType(self::DEFAULT_SORTING_TYPE); } if (!in_array(strtoupper($this->getSortingDirection()), array('ASC', 'DESC'))) { $this->setSortingDirection(self::DEFAULT_SORTING_DIRECTION); } if (!$this->isCustomSortingEnabled()) { $data_types = array(); $data_values = array(); $query = 'SELECT * FROM payment_topics WHERE 1 = 1 '; if ((int) $this->getIdFilter() > 0) { $query .= ' AND pt_topic_pk = %s'; array_push($data_types, 'integer'); array_push($data_values, $this->getIdFilter()); } switch ($this->getSortingType()) { case 3: $query .= ' ORDER BY pt_topic_sort '; break; case 2: $query .= ' ORDER BY pt_topic_created '; break; case 1: default: $query .= ' ORDER BY pt_topic_title '; break; } $query .= ' ' . strtoupper($this->getSortingDirection()) . ' '; $query .= " , pt_topic_title "; $query .= ' ' . strtoupper($this->getSortingDirection()) . ' '; } else { $data_types = array(); $data_values = array(); $query = 'SELECT * FROM payment_topics '; switch ($this->getSortingType()) { case 3: $query .= ' LEFT JOIN payment_topic_usr_sort ON ptus_pt_topic_fk = pt_topic_pk AND ptus_usr_id = %s'; array_push($data_types, 'integer'); array_push($data_values, $ilUser->getId()); break; } $query .= ' WHERE 1 = 1 '; if ((int) $this->id_filter > 0) { $query .= ' AND pt_topic_pk = %s'; array_push($data_types, 'integer'); array_push($data_values, $this->getIdFilter()); } switch ($this->getSortingType()) { case 3: $query .= ' ORDER BY ptus_sorting '; break; case 2: $query .= ' ORDER BY pt_topic_created '; break; case 1: default: $query .= ' ORDER BY pt_topic_title '; break; } $query .= ' ' . strtoupper($this->getSortingDirection()) . ' '; $query .= " , pt_topic_sort "; $query .= ' ' . strtoupper($this->getSortingDirection()) . ' '; } if (count($data_types) > 0 && count($data_values > 0)) { $res = $this->db->queryf($query, $data_types, $data_values); } else { $res = $this->db->query($query); } $counter = 0; while ($row = $this->db->fetchObject($res)) { $oTopic = new ilShopTopic(); $oTopic->setId($row->pt_topic_pk); $oTopic->setTitle($row->pt_topic_title); $oTopic->setSorting($row->pt_topic_sort); $oTopic->setCustomSorting((int) $row->ptus_sorting); $oTopic->setCreateDate($row->pt_topic_created); $oTopic->setChangeDate($row->pt_topic_changed); $this->topics[$row->pt_topic_pk] = $oTopic; ++$counter; } return $this; }
public function showTopicsList() { $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); if ($this->ask_for_deletion) { include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $c_gui = new ilConfirmationGUI(); $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteTopic')); $c_gui->setHeaderText($this->lng->txt('sure_delete_topics')); $c_gui->setCancel($this->lng->txt('cancel'), 'showTopicsList'); $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteTopic'); foreach ($_POST['topic_id'] as $topic_id) { $c_gui->addItem('topic_id[]', $topic_id, ilShopTopic::_lookupTitle($topic_id)); } $this->tpl->setVariable('CONFIRMATION', $c_gui->getHTML()); return true; } include_once 'Services/Payment/classes/class.ilShopTopicsTableGUI.php'; $table_gui = new ilShopTopicsTableGUI($this, 'showTopicsList'); $table_gui->setTitle($this->lng->txt('topics')); ilShopTopics::_getInstance()->setSortingType(ilShopTopics::TOPICS_SORT_MANUALLY); ilShopTopics::_getInstance()->setSortingDirection('ASC'); ilShopTopics::_getInstance()->read(); $table_gui->parseRecords(ilShopTopics::_getInstance()->getTopics()); $table_gui->addCommandButton('showTopicForm', $this->lng->txt('add')); $table_gui->addCommandButton('saveSorting', $this->lng->txt('pay_save_sorting')); $this->tpl->setVariable('TABLE', $table_gui->getHTML()); return true; }