ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilShopController.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 
5 include_once './Services/Payment/classes/class.ilShopBaseGUI.php';
6 include_once './Services/Payment/classes/class.ilShopGUI.php';
7 include_once './Services/Payment/classes/class.ilShopAdvancedSearchGUI.php';
8 
9 include_once './Services/Payment/classes/class.ilShopSearchResult.php';
10 include_once './Services/Payment/classes/class.ilShopInfoGUI.php';
11 include_once './Services/Payment/classes/class.ilShopNewsGUI.php';
12 
13 include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
14 include_once './Services/Payment/classes/class.ilPaymentObject.php';
15 include_once './Services/Payment/classes/class.ilGeneralSettings.php';
16 include_once './Services/Payment/classes/class.ilPaymentVendors.php';
17 include_once './Services/Payment/classes/class.ilPaymentTrustees.php';
18 include_once './Services/Payment/classes/class.ilPaymentBookings.php';
19 include_once './Services/Payment/classes/class.ilShopTopics.php';
20 
21 include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
22 
23 
39 {
40  protected $ctrl = null;
41  protected $ilias = null;
42  protected $lng = null;
43  protected $tpl = null;
44 
45  public function __construct()
46  {
47  global $ilCtrl, $ilias, $lng, $tpl;
48 
49  $this->ilias = $ilias;
50  $this->ctrl = $ilCtrl;
51  $this->lng = $lng;
52  $this->tpl = $tpl;
53  }
54 
55  public function executeCommand()
56  {
57  global $ilUser;
58 
59  if(!(bool)ilGeneralSettings::_getInstance()->get('shop_enabled'))
60  {
61  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
62  }
63 
64  $this->buildTabs();
65 
66  $next_class = $this->ctrl->getNextClass();
67  $cmd = $this->ctrl->getCmd();
68 
69  $obj = new ilGeneralSettings();
70  $allSet = $obj->getAll();
71 
72  if(($ilUser->getId() == ANONYMOUS_USER_ID) && $next_class == 'ilshopboughtobjectsgui')
73  {
74  $next_class = 'ilshopshoppingcartgui';
75  }
76 
77  switch($next_class)
78  {
79  case 'ilpurchasebillgui':
80  include_once './Services/Payment/classes/class.ilPurchaseBillGUI.php';
81  $pt = new ilPurchaseBillGUI($ilUser);
82  $this->ctrl->forwardCommand($pt);
83  break;
84 
85  case 'ilpurchasebmfgui':
86  include_once './Services/Payment/classes/class.ilPurchaseBMFGUI.php';
87  $pt = new ilPurchaseBMFGUI($ilUser);
88  $this->ctrl->forwardCommand($pt);
89  break;
90 
91  case 'ilshopboughtobjectsgui':
92  include_once './Services/Payment/classes/class.ilShopBoughtObjectsGUI.php';
93  $this->ctrl->forwardCommand(new ilShopBoughtObjectsGUI($ilUser));
94  break;
95 
96  case 'ilshopshoppingcartgui':
97  include_once './Services/Payment/classes/class.ilShopShoppingCartGUI.php';
98  $this->ctrl->forwardCommand(new ilShopShoppingCartGUI($ilUser));
99  break;
100 
101  case 'ilshopadvancedsearchgui':
102  if ((bool) $allSet['hide_advanced_search'])
103  {
104  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
105  }
106  include_once './Services/Payment/classes/class.ilShopAdvancedSearchGUI.php';
107  $this->ctrl->forwardCommand(new ilShopAdvancedSearchGUI());
108  break;
109 
110  case 'ilshoppersonalsettingsgui':
111  include_once './Services/Payment/classes/class.ilShopPersonalSettingsGUI.php';
112  $this->ctrl->forwardCommand(new ilShopPersonalSettingsGUI());
113  break;
114 
115  case 'ilpaymentadmingui':
116  include_once './Services/Payment/classes/class.ilPaymentAdminGUI.php';
117  $this->ctrl->forwardCommand(new ilPaymentAdminGUI($ilUser));
118  break;
119 
120  case 'ilshopinfogui':
121  include_once './Services/Payment/classes/class.ilShopInfoGUI.php';
122  $this->ctrl->forwardCommand(new ilShopInfoGUI());
123  break;
124 
125  case 'ilshopnewsgui':
126  if ((bool) $allSet['hide_news'])
127  {
128  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
129  }
130  include_once './Services/Payment/classes/class.ilShopNewsGUI.php';
131  $this->ctrl->forwardCommand(new ilShopNewsGUI());
132  break;
133 
134  case 'ilshopgui':
135  default:
136  if($cmd == 'redirect')
137  {
138  $this->redirect();
139  }
140 
141  include_once './Services/Payment/classes/class.ilShopGUI.php';
142  $this->ctrl->forwardCommand(new ilShopGUI());
143  break;
144  }
145 
146  $this->tpl->show();
147 
148  return true;
149  }
150 
151  private function buildTabs()
152  {
153  global $ilTabs, $ilUser;
154 
155  $shop_obj = new ilPaymentShoppingCart($ilUser);
156 
157  $obj = new ilGeneralSettings();
158  $allSet = $obj->getAll();
159 
160  $ilTabs->addTarget('content', $this->ctrl->getLinkTargetByClass('ilshopgui'), '', '', '');
161  if (!(bool)$allSet['hide_advanced_search']) {
162  $ilTabs->addTarget('advanced_search', $this->ctrl->getLinkTargetByClass('ilshopadvancedsearchgui'), '', '', '');
163  }
164 
165  $ilTabs->addTarget('shop_info',$this->ctrl->getLinkTargetByClass('ilshopinfogui') ,'' , '', '');
166 
167  if (!(bool)$allSet['hide_news'])
168  {
169  $ilTabs->addTarget('payment_news',$this->ctrl->getLinkTargetByClass('ilshopnewsgui'),'' , '', '');
170  }
171  if(ANONYMOUS_USER_ID != $ilUser->getId())
172  {
173  if((bool)ilGeneralSettings::_getInstance()->get('topics_allow_custom_sorting'))
174  {
175  $ilTabs->addTarget('pay_personal_settings', $this->ctrl->getLinkTargetByClass('ilshoppersonalsettingsgui'), '', '', '');
176  }
177 
178  // Only show if not empty
179  $ilTabs->addTarget('paya_buyed_objects', $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui'), '', '', '');
180 
181  // Only show if user is vendor
182  if(ilPaymentVendors::_isVendor($ilUser->getId()) ||
183  ilPaymentTrustees::_hasAccess($ilUser->getId()))
184  {
185  $ilTabs->addTarget('paya_header', $this->ctrl->getLinkTargetByClass('ilpaymentadmingui'), '', '', '');
186  }
187  }
188 
189  // Only show cart if not empty
190  $ilTabs->addTarget('paya_shopping_cart', $this->ctrl->getLinkTargetByClass('ilshopshoppingcartgui'), '', '', '');
191 
192  }
193 
194  public function redirect()
195  {
196  global $ilUser, $ilCtrl;
197 
198  switch(strtolower(ilUtil::stripSlashes($_GET['redirect_class'])))
199  {
200  case 'ilshopshoppingcartgui':
201  $ilCtrl->redirectByClass('ilshopshoppingcartgui','','',false, false);
202  break;
203 
204  default:
205  break;
206  }
207  }
208 }
209 ?>