ILIAS  release_4-3 Revision
 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 include_once './Services/Payment/classes/class.ilTermsConditionsGUI.php';
13 
14 include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
15 include_once './Services/Payment/classes/class.ilPaymentObject.php';
16 include_once './Services/Payment/classes/class.ilPaymentSettings.php';
17 include_once './Services/Payment/classes/class.ilPaymentVendors.php';
18 include_once './Services/Payment/classes/class.ilPaymentTrustees.php';
19 include_once './Services/Payment/classes/class.ilPaymentBookings.php';
20 include_once './Services/Payment/classes/class.ilShopTopics.php';
21 
22 include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
23 include_once './Services/Payment/classes/class.ilShopLinkBuilder.php';
24 
25 
42 {
43  protected $ctrl = null;
44  protected $ilErr = null;
45  protected $lng = null;
46  protected $tpl = null;
47 
48  public function __construct()
49  {
50  global $ilCtrl, $ilErr, $lng, $tpl;
51 
52  $this->ilErr = $ilErr;
53  $this->ctrl = $ilCtrl;
54  $this->lng = $lng;
55  $this->tpl = $tpl;
56  }
57 
58  public function executeCommand()
59  {
60  global $ilUser;
61 
62  if(!IS_PAYMENT_ENABLED)
63  {
64  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
65  }
66 
67  $this->buildTabs();
68 
69  $next_class = $this->ctrl->getNextClass();
70  $cmd = $this->ctrl->getCmd();
71  $cmd_class = $this->ctrl->getCmdClass();
72 
73  if(!$next_class && $cmd_class)
74  {
75  $next_class = $cmd_class;
76  }
77 
79  $allSet = $obj->getAll();
80 
81  if(($ilUser->getId() == ANONYMOUS_USER_ID) && $next_class == 'ilshopboughtobjectsgui')
82  {
83  $next_class = 'ilshopshoppingcartgui';
84  }
85 
86  switch($next_class)
87  {
88  case 'ilpurchasebillgui':
89  include_once './Services/Payment/classes/class.ilPurchaseBillGUI.php';
90  $pt = new ilPurchaseBillGUI($ilUser);
91  $this->ctrl->forwardCommand($pt);
92  break;
93 
94  case 'ilpurchasebmfgui':
95  include_once './Services/Payment/classes/class.ilPurchaseBMFGUI.php';
96  $pt = new ilPurchaseBMFGUI($ilUser);
97  $this->ctrl->forwardCommand($pt);
98  break;
99 
100  case 'ilshopboughtobjectsgui':
101  include_once './Services/Payment/classes/class.ilShopBoughtObjectsGUI.php';
102  $this->ctrl->forwardCommand(new ilShopBoughtObjectsGUI($ilUser));
103  break;
104 
105  case 'ilshopshoppingcartgui':
106  include_once './Services/Payment/classes/class.ilShopShoppingCartGUI.php';
107  $this->ctrl->forwardCommand(new ilShopShoppingCartGUI($ilUser));
108  break;
109 
110  case 'ilshopadvancedsearchgui':
111  if ((bool) $allSet['hide_advanced_search'])
112  {
113  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
114  }
115  include_once './Services/Payment/classes/class.ilShopAdvancedSearchGUI.php';
116  $this->ctrl->forwardCommand(new ilShopAdvancedSearchGUI());
117  break;
118 
119  case 'ilshoppersonalsettingsgui':
120  include_once './Services/Payment/classes/class.ilShopPersonalSettingsGUI.php';
121  $this->ctrl->forwardCommand(new ilShopPersonalSettingsGUI());
122  break;
123 
124  case 'ilpaymentadmingui':
125  include_once './Services/Payment/classes/class.ilPaymentAdminGUI.php';
126  $this->ctrl->forwardCommand(new ilPaymentAdminGUI($ilUser));
127  break;
128 
129  case 'ilshopinfogui':
130  if ((bool) $allSet['hide_shop_info'])
131  {
132  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
133  }
134  include_once './Services/Payment/classes/class.ilShopInfoGUI.php';
135  $this->ctrl->forwardCommand(new ilShopInfoGUI());
136  break;
137 
138  case 'ilshopnewsgui':
139  if ((bool) $allSet['hide_news'])
140  {
141  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
142  }
143  include_once './Services/Payment/classes/class.ilShopNewsGUI.php';
144  $this->ctrl->forwardCommand(new ilShopNewsGUI());
145  break;
146 
147  case 'iltermsconditionsgui':
148 
149  include_once './Services/Payment/classes/class.ilTermsConditionsGUI.php';
150  $this->ctrl->forwardCommand(new ilTermsConditionsGUI());
151  break;
152 
153  case 'ilshoppurchasegui':
154  include_once './Services/Payment/classes/class.ilShopPurchaseGUI.php';
155  $this->ctrl->forwardCommand(new ilShopPurchaseGUI($_GET['ref_id']));
156  break;
157 
158  case 'ilshopgui':
159  default:
160  if($cmd == 'redirect')
161  {
162  $this->redirect();
163  }
164 
165  include_once './Services/Payment/classes/class.ilShopGUI.php';
166  $this->ctrl->forwardCommand(new ilShopGUI());
167  break;
168  }
169 
170  $this->tpl->show();
171 
172  return true;
173  }
174 
175  private function buildTabs()
176  {
177  global $ilTabs, $ilUser;
178 
179 // $shop_obj = new ilPaymentShoppingCart($ilUser);
180 
182  $allSet = $obj->getAll();
183 
184  $ilTabs->addTarget('content', $this->ctrl->getLinkTargetByClass('ilshopgui','firstpage'), '', '', '');
185 
186  if (!(bool)$allSet['hide_advanced_search']) {
187  $ilTabs->addTarget('advanced_search', $this->ctrl->getLinkTargetByClass('ilshopadvancedsearchgui'), '', '', '');
188  }
189  if (!(bool)$allSet['hide_shop_info'])
190  {
191  $ilTabs->addTarget('shop_info',$this->ctrl->getLinkTargetByClass('ilshopinfogui') ,'' , '', '');
192  }
193  if (!(bool)$allSet['hide_news'])
194  {
195  $ilTabs->addTarget('payment_news',$this->ctrl->getLinkTargetByClass('ilshopnewsgui'),'' , '', '');
196  }
197  if(ANONYMOUS_USER_ID != $ilUser->getId())
198  {
199  if((bool)ilPaymentSettings::_getInstance()->get('topics_allow_custom_sorting'))
200  {
201  $ilTabs->addTarget('pay_personal_settings', $this->ctrl->getLinkTargetByClass('ilshoppersonalsettingsgui'), '', '', '');
202  }
203 
204  // Only show if not empty
205  $ilTabs->addTarget('paya_buyed_objects', $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui'), '', '', '');
206 
207  // Only show if user is vendor
208  if(ilPaymentVendors::_isVendor($ilUser->getId()) ||
209  ilPaymentTrustees::_hasAccess($ilUser->getId()))
210  {
211  $ilTabs->addTarget('paya_header', $this->ctrl->getLinkTargetByClass('ilpaymentadmingui'), '', '', '');
212  }
213  }
214 
215  // Only show cart if not empty
216  $ilTabs->addTarget('paya_shopping_cart', $this->ctrl->getLinkTargetByClass('ilshopshoppingcartgui'), '', '', '');
217 
218  $ilTabs->addTarget('terms_conditions',$this->ctrl->getLinkTargetByClass(array('iltermsconditionsgui'), ''));
219  }
220 
221  public function redirect()
222  {
223  global $ilCtrl;
224 
225  switch(strtolower(ilUtil::stripSlashes($_GET['redirect_class'])))
226  {
227  case 'ilshopshoppingcartgui':
228  $ilCtrl->redirectByClass('ilshopshoppingcartgui','','',false, false);
229  break;
230  case 'ilshopadvancedsearchgui':
231  $ilCtrl->redirectByClass('ilshopadvancedsearchgui','','',false, false);
232  break;
233  case 'ilshopboughtobjectsgui':
234  $ilCtrl->redirectByClass('ilshopboughtobjectsgui','','',false, false);
235  break;
236 
237  default:
238  break;
239  }
240  }
241 }
242 ?>