ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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_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.

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

References $ilUser, and ilObject\_lookupType().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _addToShoppingCartSymbol()

static ilShopUtils::_addToShoppingCartSymbol (   $a_ref_id)
static

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

256 {
257 global $ilCtrl;
258
259 $detail_link = $ilCtrl->getLinkTargetByClass("ilShopPurchaseGUI", "showDetails").'&ref_id='.$a_ref_id;
260 $img = ilUtil::img('./templates/default/images/payment/shopcart_add.svg');
261
262 $link = '<a href="'.$detail_link.'">'.$img.'</a>';
263
264 return $link;
265 }
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $ilCtrl
Definition: ilias.php:18

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

Referenced by ilShopResultPresentationGUI\renderItems().

+ 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.

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 }
const IL_CRS_MEMBER
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupObjectId($a_ref_id)
lookup object id

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

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

+ 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.

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 }
global $ilDB

References $ilDB, and $res.

◆ _checkVATRate()

static ilShopUtils::_checkVATRate (   $a_vat_rate)
static

Checks if the passed vat rate is valid.

@access public

Parameters
string$a_vat
Returns
bool

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

54 {
55 $reg = '/^([0]|([1-9][0-9]*))([\.,][0-9][0-9]*)?$/';
56 return preg_match($reg, $a_vat_rate);
57 }

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

+ Here is the caller graph for this function:

◆ _createRandomUserAccount()

static ilShopUtils::_createRandomUserAccount (   $keyarray)
static

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

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 }
$_SESSION["AccountId"]
const IL_PASSWD_PLAIN
this class encapsulates the PHP mail() function.
_lookupRegisterAllowed()
get all roles that are activated in user registration
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static generatePasswords($a_number)
Generate a number of passwords.
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40

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

+ Here is the call graph for this function:

◆ _deassignPurchasedCourseMemberRole()

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

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

307 {
308 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
309 $obj_id = ilObject::_lookupObjectId($a_ref_id);
310
311 $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
312 $res = $participants->delete($a_user_id, IL_CRS_MEMBER);
313 }

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

Referenced by ilPaymentStatisticGUI\performDeleteDeassignCrs().

+ 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.

@access public

Parameters
float$a_vat
Returns
string

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

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 }

References $lng.

Referenced by ilPaymentObject\getVat().

+ Here is the caller graph for this function:

◆ _formatVAT()

static ilShopUtils::_formatVAT (   $a_vat)
static

Formats a vat rate for gui output.

@access public

Parameters
float$a_vat
Returns
string

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

24 {
25 return ((float)$a_vat != floor((float)$a_vat) ?
26 self::_formatFloat((float)$a_vat) :
27 (int)$a_vat).' %';
28 }

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

+ Here is the caller graph for this function:

◆ _getPaymethodSymbol()

static ilShopUtils::_getPaymethodSymbol (   $a_paymethod)
static

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

273 {
274 switch($a_paymethod)
275 {
276 case '1':
277 case 'pm_bill':
278 case 'bill':
279 case 'PAY_METHOD_BILL': return '';
280 break;
281
282 case '2':
283 case 'pm_bmf':
284 case 'bmf':
285 case 'PAY_METHOD_BMF': return '';
286 break;
287
288 case '3':
289 case 'pm_paypal':
290 case 'paypal':
291 case 'PAY_METHOD_PAYPAL': return ilUtil::img('./templates/default/images/payment/paypal.svg');
292 break;
293
294 case '4':
295 case 'pm_epay':
296 case 'epay':
297 case 'PAY_METHOD_EPAY': return '';
298 break;
299 case 'PAY_METHOD_NOT_SPECIFIED': return '';
300 break;
301 default:
302
303 break;
304 }
305 }

References ilUtil\img().

Referenced by ilShopResultPresentationGUI\renderItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSpecialObjectSymbol()

static ilShopUtils::_getSpecialObjectSymbol ( )
static

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

268 {
269 return $img = ilUtil::img('./templates/default/images/icon_rate_10.svg','', '24px', '24px');
270 }

References $img, and ilUtil\img().

Referenced by ilShopResultPresentationGUI\renderItems().

+ 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.

@access public

Parameters
ilPaymentObject$oPaymentObject

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

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 }
$success
Definition: Utf8Test.php:87
Class Mail this class handles base functions for mail handling.
static _lookupId($a_user_str)
Lookup id by login.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

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

+ Here is the call graph for this function:

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