ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilShopUtils Class Reference

Class ilShopUtils. More...

+ Collaboration diagram for ilShopUtils:

Static Public Member Functions

static _formatVAT ($a_vat)
 Formats a vat rate for gui output. More...
 
static _formatFloat ($a_float, $a_num_decimals=2)
 Formats a float value for gui output. More...
 
static _checkVATRate ($a_vat_rate)
 Checks if the passed vat rate is valid. More...
 
static _sendNotificationToVATAdministration ($oPaymentObject)
 Sends a notification message to all users responsible for vat assignment. More...
 
static _createRandomUserAccount ($keyarray)
 
static _assignTransactionToCustomerId ($a_old_user_id, $a_new_user_id, $a_transaction_extern)
 
static _addPurchasedObjToDesktop ($oPaymentObject, $a_user_id=0)
 
static _assignPurchasedCourseMemberRole ($oPaymentObject, $a_user_id=0)
 
static _addToShoppingCartSymbol ($a_type, $a_ref_id)
 
static _getSpecialObjectSymbol ()
 
static _getPaymethodSymbol ($a_paymethod)
 
static _deassignPurchasedCourseMemberRole ($a_ref_id, $a_user_id)
 

Detailed Description

Class ilShopUtils.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 13 of file class.ilShopUtils.php.

Member Function Documentation

◆ _addPurchasedObjToDesktop()

static ilShopUtils::_addPurchasedObjToDesktop (   $oPaymentObject,
  $a_user_id = 0 
)
static

Definition at line 217 of file class.ilShopUtils.php.

References $ilUser, and ilObject\_lookupType().

Referenced by ilPurchaseBaseGUI\__addBookings(), and ilObjPaymentSettingsGUI\saveCustomerObject().

218  {
219  global $ilUser;
220 
221  $type = ilObject::_lookupType($oPaymentObject->getRefId(),true);
222 
223  if($a_user_id > 0)
224  {
225  // administrator added a selling process to statistics
226  $tmp_usr = new ilObjUser($a_user_id);
227  $tmp_usr->addDesktopItem($oPaymentObject->getRefId(),$type);
228  }
229  else
230  {
231  // user purchased object
232  $ilUser->addDesktopItem($oPaymentObject->getRefId(),$type);
233  }
234  }
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _addToShoppingCartSymbol()

static ilShopUtils::_addToShoppingCartSymbol (   $a_type,
  $a_ref_id 
)
static

Definition at line 255 of file class.ilShopUtils.php.

References $ilCtrl, $img, and ilUtil\img().

Referenced by ilShopResultPresentationGUI\renderItems().

256  {
257  global $ilCtrl;
258 
259  switch($a_type)
260  {
261  case 'sahs':
262  $detail_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id='.$a_ref_id;
263  break;
264 
265  case 'lm':
266  $detail_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$a_ref_id;
267  break;
268  case 'exc':
269  $detail_link = $ilCtrl->getLinkTargetByClass("ilShopPurchaseGUI", "showDetails").'&ref_id='.$a_ref_id;
270  break;
271 
272  default:
273  $detail_link = $ilCtrl->getLinkTargetByClass("ilShopPurchaseGUI", "showDetails").'&ref_id='.$a_ref_id;
274  break;
275  }
276  $img = ilUtil::img('./templates/default/images/payment/shopcart_add_32.png');
277  $link = '<a href="'.$detail_link.'">'.$img.'</a>';
278 
279  return $link;
280  }
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="")
Build img tag.
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _assignPurchasedCourseMemberRole()

static ilShopUtils::_assignPurchasedCourseMemberRole (   $oPaymentObject,
  $a_user_id = 0 
)
static

Definition at line 236 of file class.ilShopUtils.php.

References $ilUser, $res, ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjectId(), and IL_CRS_MEMBER.

Referenced by ilPurchaseBaseGUI\__addBookings(), and ilObjPaymentSettingsGUI\saveCustomerObject().

237  {
238  global $ilUser;
239  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
240  $obj_id = ilObject::_lookupObjectId($oPaymentObject->getRefId());
241 
242  $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
243 
244  if($a_user_id > 0)
245  {
246  // administrator added a selling process to statistics
247  $res = $participants->add($a_user_id, IL_CRS_MEMBER);
248  }
249  else
250  {
251  $res = $participants->add($ilUser->getId(),IL_CRS_MEMBER);
252  }
253  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupObjectId($a_ref_id)
lookup object id
const IL_CRS_MEMBER
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _assignTransactionToCustomerId()

static ilShopUtils::_assignTransactionToCustomerId (   $a_old_user_id,
  $a_new_user_id,
  $a_transaction_extern 
)
static

Definition at line 204 of file class.ilShopUtils.php.

References $res.

205  {
206  global $ilDB;
207 
208  $res = $ilDB->manipulateF('
209  UPDATE payment_statistic
210  SET customer_id = %s
211  WHERE customer_id = %s
212  AND transaction_extern = %s',
213  array('integer', 'integer', 'text'),
214  array($a_new_user_id, $a_old_user_id, $a_transaction_extern));
215  }

◆ _checkVATRate()

static ilShopUtils::_checkVATRate (   $a_vat_rate)
static

Checks if the passed vat rate is valid.

public

Parameters
string$a_vat
Returns
bool

Definition at line 53 of file class.ilShopUtils.php.

Referenced by ilObjPaymentSettingsGUI\saveVatObject(), and ilObjPaymentSettingsGUI\updateVatObject().

54  {
55  $reg = '/^([0]|([1-9][0-9]*))([\.,][0-9][0-9]*)?$/';
56  return preg_match($reg, $a_vat_rate);
57  }
+ Here is the caller graph for this function:

◆ _createRandomUserAccount()

static ilShopUtils::_createRandomUserAccount (   $keyarray)
static

Definition at line 95 of file class.ilShopUtils.php.

References $_SESSION, $ilSetting, $ilUser, $lng, $res, $row, ilObject\_exists(), ilObjRole\_lookupRegisterAllowed(), ilUtil\generatePasswords(), and IL_PASSWD_PLAIN.

96  {
97  global $ilDB, $ilUser, $ilSetting, $rbacadmin;
98 
99  if($_SESSION['create_user_account'] != NULL)
100  {
101 
102  $obj_user = new ilObjUser($_SESSION['create_user_account']);
103  return $obj_user;
104  }
105  else
106  {
107  $userLogin = array();
108  $res = $ilDB->query('SELECT sequence FROM object_data_seq');
109  $row = $ilDB->fetchAssoc($res);
110 
111  $temp_user_id = (int)$row['sequence'] + 1;
112 
113  $userLogin['login'] = 'shop_user_'.$temp_user_id;
114 
115  $userLogin['passwd'] = ilUtil::generatePasswords(1);
116 
117  require_once 'Services/User/classes/class.ilObjUser.php';
118  include_once("Services/Mail/classes/class.ilAccountMail.php");
119 
120  $obj_user = new ilObjUser();
121  $obj_user->setId($temp_user_id);
122 
123  $obj_user->setLogin($userLogin['login']);
124  $obj_user->setPasswd((string)$userLogin['passwd'][0], IL_PASSWD_PLAIN);
125 
126  $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
127  $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
128 
129  $obj_user->setFirstname($keyarray['first_name']);
130  $obj_user->setLastname($keyarray['last_name']);
131  $obj_user->setEmail($keyarray['payer_email']);
132  # $obj_user->setEmail('nkrzywon@databay.de');
133 
134  $obj_user->setGender('f');
135  $obj_user->setLanguage( $ilSetting->get("language"));
136  $obj_user->setActive(true);
137  $obj_user->setTimeLimitUnlimited(true);
138 
139  $obj_user->setTitle($obj_user->getFullname());
140  $obj_user->setDescription($obj_user->getEmail());
141  $obj_user->setTimeLimitOwner(7);
142  $obj_user->setTimeLimitUnlimited(1);
143  $obj_user->setTimeLimitMessage(0);
144  $obj_user->setApproveDate(date("Y-m-d H:i:s"));
145 
146  // Set default prefs
147  $obj_user->setPref('hits_per_page',$ilSetting->get('hits_per_page',30));
148  $obj_user->setPref('show_users_online',$ilSetting->get('show_users_online','y'));
149  $obj_user->writePrefs();
150 
151  // at the first login the user must complete profile
152  $obj_user->setProfileIncomplete(true);
153  $obj_user->create();
154  $obj_user->saveAsNew();
155 
156  $user_role = ilObject::_exists(4, false);
157 
158  if(!$user_role)
159  {
160  include_once("./Services/AccessControl/classes/class.ilObjRole.php");
161  $reg_allowed = ilObjRole::_lookupRegisterAllowed();
162  $user_role = $reg_allowed[0]['id'];
163 
164  }
165  else $user_role = 4;
166 
167  $rbacadmin->assignUser((int)$user_role, $obj_user->getId(), true);
168 
169  include_once "Services/Mail/classes/class.ilMimeMail.php";
170  global $ilias, $lng;
171 
172  $settings = $ilias->getAllSettings();
173  $mmail = new ilMimeMail();
174  $mmail->autoCheck(false);
175  $mmail->From($settings["admin_email"]);
176  $mmail->To($obj_user->getEmail());
177 
178  // mail subject
179  $subject = $lng->txt("reg_mail_subject");
180 
181  // mail body
182  $body = $lng->txt("reg_mail_body_salutation")." ".$obj_user->getFullname().",\n\n".
183  $lng->txt("reg_mail_body_text1")."\n\n".
184  $lng->txt("reg_mail_body_text2")."\n".
185  ILIAS_HTTP_PATH."/login.php?client_id=".$ilias->client_id."\n";
186  $body .= $lng->txt("login").": ".$obj_user->getLogin()."\n";
187 
188 
189  $body.= $lng->txt("passwd").": ".$userLogin['passwd'][0]."\n";
190 
191  $body.= "\n";
192 
193  $body .= ($lng->txt("reg_mail_body_text3")."\n\r");
194  $body .= $obj_user->getProfileAsString($lng);
195  $mmail->Subject($subject);
196  $mmail->Body($body);
197  $mmail->Send();
198 
199  $_SESSION['create_user_account'] = $obj_user->getId();
200  return $obj_user;
201  }
202 
203  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
const IL_PASSWD_PLAIN
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static generatePasswords($a_number)
Generate a number of passwords.
this class encapsulates the PHP mail() function.
_lookupRegisterAllowed()
get all roles that are activated in user registration
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ _deassignPurchasedCourseMemberRole()

static ilShopUtils::_deassignPurchasedCourseMemberRole (   $a_ref_id,
  $a_user_id 
)
static

Definition at line 326 of file class.ilShopUtils.php.

References $res, ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjectId(), and IL_CRS_MEMBER.

Referenced by ilPaymentStatisticGUI\performDeleteDeassignCrs().

327  {
328  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
329  $obj_id = ilObject::_lookupObjectId($a_ref_id);
330 
331  $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
332  $res = $participants->delete($a_user_id, IL_CRS_MEMBER);
333  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupObjectId($a_ref_id)
lookup object id
const IL_CRS_MEMBER
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _formatFloat()

static ilShopUtils::_formatFloat (   $a_float,
  $a_num_decimals = 2 
)
static

Formats a float value for gui output.

public

Parameters
float$a_vat
Returns
string

Definition at line 38 of file class.ilShopUtils.php.

References $lng.

Referenced by ilPaymentObject\getVat().

39  {
40  global $lng;
41 
42  return number_format((float)$a_float, $a_num_decimals, $lng->txt('lang_sep_decimal'), $lng->txt('lang_sep_thousand'));
43  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ _formatVAT()

static ilShopUtils::_formatVAT (   $a_vat)
static

Formats a vat rate for gui output.

public

Parameters
float$a_vat
Returns
string

Definition at line 23 of file class.ilShopUtils.php.

Referenced by ilPurchaseBaseGUI\__showShoppingCart(), ilObjPaymentSettingsGUI\editDetailsObject(), ilObjPaymentSettingsGUI\objectsObject(), ilPaymentObjectGUI\resetObjectFilter(), ilShopShoppingCartGUI\showItems(), and ilObjPaymentSettingsGUI\vatsObject().

24  {
25  return ((float)$a_vat != floor((float)$a_vat) ?
26  self::_formatFloat((float)$a_vat) :
27  (int)$a_vat).' %';
28  }
+ Here is the caller graph for this function:

◆ _getPaymethodSymbol()

static ilShopUtils::_getPaymethodSymbol (   $a_paymethod)
static

Definition at line 289 of file class.ilShopUtils.php.

References ilUtil\img().

Referenced by ilShopResultPresentationGUI\renderItems().

290  {
291  switch($a_paymethod)
292  {
293  case '1':
294  case 'pm_bill':
295  case 'bill':
296  case 'PAY_METHOD_BILL': return '';
297  break;
298 
299  case '2':
300  case 'pm_bmf':
301  case 'bmf':
302  case 'PAY_METHOD_BMF': return '';
303  break;
304 
305  case '3':
306  case 'pm_paypal':
307  case 'paypal':
308  case 'PAY_METHOD_PAYPAL': return ilUtil::img('./templates/default/images/payment/paypal_48.png');
309  break;
310 
311  case '4':
312  case 'pm_epay':
313  case 'epay':
314  case 'PAY_METHOD_EPAY': return '';
315  break;
316  case 'PAY_METHOD_NOT_SPECIFIED': return '';
317  break;
318  default:
319 
320  break;
321  }
322 
323 
324 
325  }
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="")
Build img tag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSpecialObjectSymbol()

static ilShopUtils::_getSpecialObjectSymbol ( )
static

Definition at line 281 of file class.ilShopUtils.php.

References $img, and ilUtil\img().

Referenced by ilShopResultPresentationGUI\renderItems().

282  {
283  $img = ilUtil::img('./templates/default/images/payment/star_32.png');
284  #$link = '<a href="'.$detail_link.'">'.$img.'</a>';
285 
286  return $img;
287  }
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="")
Build img tag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _sendNotificationToVATAdministration()

static ilShopUtils::_sendNotificationToVATAdministration (   $oPaymentObject)
static

Sends a notification message to all users responsible for vat assignment.

public

Parameters
ilPaymentObject$oPaymentObject

Definition at line 66 of file class.ilShopUtils.php.

References $ilSetting, $lng, $success, ilObjUser\_lookupId(), and ilObjectFactory\getInstanceByRefId().

67  {
68  global $ilSetting, $lng, $ilClientIniFile;
69 
70  $payment_vat_admins = $ilSetting->get('payment_vat_admins');
71  $users = explode(',', $payment_vat_admins);
72 
73  $subject = $lng->txt('payment_vat_assignment_notification_subject');
74  $tmp_obj = ilObjectFactory::getInstanceByRefId($oPaymentObject->getRefId());
75  $message = sprintf($lng->txt('payment_vat_assignment_notification_body'), $tmp_obj->getTitle())."\n\n";
76  $message .= "------------------------------------------------------------\n";
77  $message .= sprintf($lng->txt('payment_vat_assignment_notification_intro'),
78  $ilClientIniFile->readVariable('client', 'name'),
79  ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID);
80 
81  include_once 'Services/Mail/classes/class.ilMail.php';
82  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
83  foreach((array)$users as $login)
84  {
85  if(strlen(trim($login)) &&
86  (int)ilObjUser::_lookupId(trim($login)))
87  {
88  $success = $mail_obj->sendMail(trim($login), '', '',
89  $subject, $message,
90  array(),array("system"));
91  }
92  }
93  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupId($a_user_str)
lookup id by login
$success
Definition: Utf8Test.php:87
Class Mail this class handles base functions for mail handling.
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: