ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilShopPersonalSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Payment/classes/class.ilShopBaseGUI.php';
5 
15 {
16  public function __construct()
17  {
19  }
20 
21  public function executeCommand()
22  {
23  global $ilUser, $ilCtrl, $ilErr;
24 
25  // check access
26  if(!(bool)$this->oGeneralSettings->get('topics_allow_custom_sorting'))
27  {
28  $ilCtrl->redirectByClass('ilshopgui','','',false, false);
29  }
30 
31  if(ANONYMOUS_USER_ID == $ilUser->getId())
32  {
33  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
34  }
35 
36  $next_class = $this->ctrl->getNextClass($this);
37  $cmd = $this->ctrl->getCmd();
38 
39  switch($next_class)
40  {
41  default:
42  if (!$cmd)
43  {
44  $cmd = 'showTopicsSortingTable';
45  }
46  $this->prepareOutput();
47  $this->$cmd();
48 
49  break;
50  }
51  }
52 
53  protected function prepareOutput()
54  {
55  global $ilTabs;
56 
58 
59  $ilTabs->setTabActive('pay_personal_settings');
60  }
61 
62  public function saveSorting()
63  {
64  if(count($_POST['sorting']))
65  {
66  foreach($_POST['sorting'] as $topic_id => $sorting_value)
67  {
68  $oTopic = new ilShopTopic($topic_id);
69  $oTopic->setCustomSorting((int)$sorting_value);
70  $oTopic->saveCustomSorting();
71  }
72  }
73 
74  ilUtil::sendInfo($this->lng->txt('saved_successfully'));
75 
76  return $this->showTopicsSortingTable();
77  }
78 
79  public function showTopicsSortingTable()
80  {
81  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
82 
83  include_once 'Services/Payment/classes/class.ilShopPersonalSettingsTopicsTableGUI.php';
84  $table_gui = new ilShopPersonalSettingsTopicsTableGUI($this, 'showTopicsSortingTable');
85  $table_gui->setTitle($this->lng->txt('pay_manual_sorting_of_topics'));
86  ilShopTopics::_getInstance()->enableCustomSorting(true);
88  ilShopTopics::_getInstance()->setSortingDirection('ASC');
90  $table_gui->parseRecords(ilShopTopics::_getInstance()->getTopics());
91  $table_gui->addCommandButton('saveSorting', $this->lng->txt('pay_save_sorting'));
92 
93  $this->tpl->setVariable('TABLE', $table_gui->getHTML());
94  }
95 }
96 ?>