private function sendReminder(ilObjUser $user, $reminderTime) { include_once 'Services/User/classes/class.ilCronDeleteInactiveUserReminderMailNotification.php'; $mail = new ilCronDeleteInactiveUserReminderMailNotification(); $mail->setRecipients(array($user)); $mail->setAdditionalInformation(array("www" => ilUtil::_getHttpPath(), "days" => $reminderTime)); $mail->send(); self::mailSent($user->getId()); }
function __setServer($a_server) { global $ilSetting; if (strlen($a_server)) { return $this->server = $a_server; } if (strlen(trim($ilSetting->get('soap_wsdl_path')))) { return $this->server = trim($ilSetting->get('soap_wsdl_path')); } $this->setTimeout($ilSetting->get('soap_connect_timeout', self::DEFAULT_CONNECT_TIMEOUT)); $this->server = ilUtil::_getHttpPath() . '/webservice/soap/server.php?wsdl'; }
/** * * Send notifications * * @access public * */ public function send() { global $ilDB; // parent::send(); if (count($this->getRecipients())) { $res = $ilDB->queryf("SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," . "u.time_limit_unlimited, " . $ilDB->fromUnixtime("u.time_limit_from") . ", " . $ilDB->fromUnixtime("u.time_limit_until") . "," . "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE " . $ilDB->fromUnixtime("u.time_limit_until") . " END END access_until," . " CASE WHEN " . $ilDB->unixTimestamp() . " BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," . "rq.role_disk_quota, system_role.rol_id role_id, " . "p1.value+0 user_disk_quota," . "p2.value+0 disk_usage, " . "p3.value last_update, " . "p5.value language, " . "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota\t" . "FROM usr_data u " . "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " . "FROM usr_data u " . "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " . "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s " . "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id " . "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " . "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " . "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " . "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " . "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' " . 'WHERE (((p1.value+0 > rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' . 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' . $ilDB->unixTimestamp() . ' BETWEEN u.time_limit_from AND u.time_limit_until)) ', array('integer', 'integer'), array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)); $users = array(); $counter = 0; while ($row = $ilDB->fetchAssoc($res)) { $details = ilDiskQuotaChecker::_lookupDiskUsage($row['usr_id']); $users[$counter]['disk_quota'] = $row['disk_quota']; $users[$counter]['disk_usage'] = $details['disk_usage']; $users[$counter]['email'] = $row['email']; $users[$counter]['firstname'] = $row['firstname']; $users[$counter]['lastname'] = $row['lastname']; ++$counter; } if (count($users)) { foreach ($this->getRecipients() as $rcp) { $usrId = ilObjUser::_lookupId($rcp); $this->initLanguage($usrId); $this->initMail(); $this->setSubject($this->getLanguage()->txt('disk_quota_summary_subject')); $this->setBody(ilMail::getSalutation($usrId, $this->getLanguage())); $this->appendBody("\n\n"); $this->appendBody($this->getLanguage()->txt('disk_quota_exceeded_headline')); $this->appendBody("\n\n"); $first = true; $counter = 0; $numUsers = count($users); foreach ($users as $user) { if (!$first) { $this->appendBody("\n---------------------------------------------------\n\n"); } $this->appendBody($this->getLanguage()->txt('fullname') . ': ' . $user['lastname'] . ', ' . $user['firstname'] . "\n"); $this->appendBody($this->getLanguage()->txt('email') . ': ' . $user['email'] . "\n"); $this->appendBody($this->getLanguage()->txt('disk_quota') . ': ' . ilFormat::formatSize($user['disk_quota'], 'short', $this->getLanguage()) . "\n"); $this->appendBody($this->getLanguage()->txt('currently_used_disk_space') . ': ' . ilFormat::formatSize($user['disk_usage'], 'short', $this->getLanguage()) . "\n"); $this->appendBody($this->getLanguage()->txt('usrf_profile_link') . ': ' . ilUtil::_getHttpPath() . '/goto.php?target=usrf&client_id=' . CLIENT_ID); if ($counter < $numUsers - 1) { $this->appendBody("\n"); } ++$counter; $first = false; } $this->getMail()->appendInstallationSignature(true); $this->sendMail(array($rcp), array('system'), false); } } } }
/** * Run all active jobs */ public static function runActiveJobs() { global $ilLog, $ilSetting; // separate log for cron // $this->log->setFilename($_COOKIE["ilClientId"]."_cron.txt"); $ilLog->write("CRON - batch start"); $ilSetting->set("last_cronjob_start_ts", time()); // ilLink::_getStaticLink() should work in crons if (!defined("ILIAS_HTTP_PATH")) { define("ILIAS_HTTP_PATH", ilUtil::_getHttpPath()); } // system foreach (self::getCronJobData(null, false) as $row) { $job = self::getJobInstanceById($row["job_id"]); if ($job) { self::runJob($job, $row); } } // plugins foreach (self::getPluginJobs(true) as $item) { self::runJob($item[0], $item[1]); } $ilLog->write("CRON - batch end"); }
/** * Send news mail for 1 object and 1 user * * @param int $a_user_id * @param int $a_ref_id * @param array $news */ public function sendMail($a_user_id, $a_ref_id, array $news) { global $lng, $ilUser; $obj_id = ilObject::_lookupObjId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); $this->initLanguage($a_user_id); $this->getLanguage()->loadLanguageModule("crs"); $this->getLanguage()->loadLanguageModule("news"); // needed for ilNewsItem $lng = $this->getLanguage(); $this->initMail(); $obj_title = $this->getLanguageText($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\""; $this->setRecipients($a_user_id); $this->setSubject(sprintf($this->getLanguageText("crs_subject_course_group_notification"), $obj_title)); $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage())); $this->appendBody("\n\n"); $this->appendBody(sprintf($this->getLanguageText("crs_intro_course_group_notification_for"), $obj_title)); $this->appendBody("\n\n"); // ilDatePresentation::setUseRelativeDates(false); // news summary $counter = 1; foreach ($news as $item) { $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]); $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]); /* process sub-item info if($item["aggregation"]) { $sub = array(); foreach($item["aggregation"] as $subitem) { $sub_id = ilObject::_lookupObjId($subitem["ref_id"]); $sub_title = ilObject::_lookupTitle($sub_id); // to include posting title if($subitem["context_obj_type"] == "frm") { $sub_title = ilNewsItem::determineNewsTitle($subitem["context_obj_type"], $subitem["title"], $subitem["content_is_lang_var"]); } $sub[] = $sub_title; $sub_content = ilNewsItem::determineNewsContent($subitem["context_obj_type"], $subitem["content"], $subitem["content_text_is_lang_var"]); if($sub_content) { $sub[] = strip_tags($sub_content); } } $content .= "\n".implode("\n\n", $sub); } */ $obj_id = ilObject::_lookupObjId($item["ref_id"]); $obj_title = ilObject::_lookupTitle($obj_id); // path include_once './Services/Locator/classes/class.ilLocatorGUI.php'; $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($item["ref_id"], true); $cont_loc->setTextOnly(true); // #9954/#10044 // see ilInitialisation::requireCommonIncludes() @(include_once "HTML/Template/ITX.php"); // new implementation if (class_exists("HTML_Template_ITX")) { include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php"; } else { include_once "HTML/ITX.php"; // old implementation include_once "./Services/UICore/classes/class.ilTemplateITX.php"; } require_once "./Services/UICore/classes/class.ilTemplate.php"; $loc = "[" . $cont_loc->getHTML() . "]"; $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); $this->appendBody('#' . $counter . " - " . $loc . " " . $obj_title . "\n\n"); $this->appendBody($title); if ($content) { $this->appendBody("\n"); $this->appendBody($content); } $this->appendBody("\n\n"); ++$counter; } $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); // link to object $this->appendBody($this->getLanguageText("crs_course_group_notification_link")); $this->appendBody("\n"); $object_link = ilUtil::_getHttpPath(); $object_link .= "/goto.php?target=" . $obj_type . "_" . $a_ref_id . "&client_id=" . CLIENT_ID; $this->appendBody($object_link); $this->appendBody("\n\n"); $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage())); $this->appendBody(ilMail::_getInstallationSignature()); // #10044 $mail = new ilMail($ilUser->getId()); $mail->enableSOAP(false); // #10410 $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $this->getSubject(), $this->getBody(), null, array("system")); }
/** * Static getter for the installation signature * * @access public * @static * * @return string The installation mail signature */ public static function _getInstallationSignature() { global $ilClientIniFile; $signature = "\n\n* * * * *\n"; $signature .= $ilClientIniFile->readVariable('client', 'name') . "\n"; if (strlen($desc = $ilClientIniFile->readVariable('client', 'description'))) { $signature .= $desc . "\n"; } $signature .= ilUtil::_getHttpPath(); $clientdirs = glob(ILIAS_WEB_DIR . "/*", GLOB_ONLYDIR); if (is_array($clientdirs) && count($clientdirs) > 1) { $signature .= '/?client_id=' . CLIENT_ID; } $signature .= "\n\n"; return $signature; }
public function send() { global $ilDB, $lng, $ilSetting; $is_message_enabled = $ilSetting->get("mail_notification_message"); $res = $ilDB->queryF('SELECT mail.* FROM mail_options INNER JOIN mail ON mail.user_id = mail_options.user_id INNER JOIN mail_obj_data ON mail_obj_data.obj_id = mail.folder_id WHERE cronjob_notification = %s AND send_time >= %s AND m_status = %s', array('integer', 'timestamp', 'text'), array(1, date('Y-m-d H:i:s', time() - 60 * 60 * 24), 'unread')); $users = array(); $user_id = 0; while ($row = $ilDB->fetchAssoc($res)) { if ($user_id == 0 || $row['user_id'] != $user_id) { $user_id = $row['user_id']; } $users[$user_id][] = $row; } foreach ($users as $user_id => $mail_data) { $this->initLanguage($user_id); $user_lang = $this->getLanguage() ? $this->getLanguage() : $lng; $this->initMail(); $this->setRecipients($user_id); $this->setSubject($this->getLanguageText('mail_notification_subject')); $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage())); $this->appendBody("\n\n"); if (count($mail_data) == 1) { $this->appendBody(sprintf($user_lang->txt('mail_at_the_ilias_installation'), count($mail_data), ilUtil::_getHttpPath())); } else { $this->appendBody(sprintf($user_lang->txt('mails_at_the_ilias_installation'), count($mail_data), ilUtil::_getHttpPath())); } $this->appendBody("\n\n"); $counter = 1; foreach ($mail_data as $mail) { $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); $this->appendBody('#' . $counter . "\n\n"); $this->appendBody($user_lang->txt('date') . ": " . $mail['send_time']); $this->appendBody("\n"); if ($mail['sender_id'] == ANONYMOUS_USER_ID) { $sender = ilMail::_getIliasMailerName(); } else { $sender = ilObjUser::_lookupLogin($mail['sender_id']); } $this->appendBody($user_lang->txt('sender') . ": " . $sender); $this->appendBody("\n"); $this->appendBody($user_lang->txt('subject') . ": " . $mail['m_subject']); $this->appendBody("\n\n"); if ($is_message_enabled == true) { $this->appendBody($user_lang->txt('message') . ": " . $mail['m_message']); $this->appendBody("\n\n"); } ++$counter; } $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); $this->appendBody($user_lang->txt('follow_link_to_read_mails') . " "); $this->appendBody("\n"); $mailbox_link = ilUtil::_getHttpPath(); $mailbox_link .= "/goto.php?target=mail&client_id=" . CLIENT_ID; $this->appendBody($mailbox_link); $this->appendBody("\n\n"); $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage())); $this->appendBody(ilMail::_getInstallationSignature()); $mmail = new ilMimeMail(); $mmail->autoCheck(false); $mmail->From(ilMail::getIliasMailerAddress()); $mmail->To(ilObjUser::_lookupEmail($user_id)); $mmail->Subject($this->getSubject()); $mmail->Body($this->getBody()); $mmail->Send(); } }
/** * @param int $sessionId * @return string */ public function getJsonResponse($sessionId) { /** * @var $ilDB ilDB * @var $ilUser ilObjUser * @var $ilClientIniFile ilIniFile * @var $lng ilLanguage */ global $ilDB, $ilUser, $lng, $ilClientIniFile; include_once 'Services/JSON/classes/class.ilJsonUtil.php'; $response = array('remind' => false); $res = $ilDB->queryF(' SELECT expires, user_id, data FROM usr_session WHERE session_id = %s', array('text'), array($sessionId)); $num = $ilDB->numRows($res); if ($num > 1) { $response['message'] = 'The determined session data is not unique.'; return ilJsonUtil::encode($response); } if ($num == 0) { $response['message'] = 'ILIAS could not determine the session data.'; return ilJsonUtil::encode($response); } $data = $ilDB->fetchAssoc($res); if (!$this->isAuthenticatedUsrSession($data)) { $response['message'] = 'ILIAS could not fetch the session data or the corresponding user is no more authenticated.'; return ilJsonUtil::encode($response); } $session = ilUtil::unserializeSession($data['data']); $idletime = null; foreach ((array) $session as $key => $entry) { if (strpos($key, '_auth__') === 0) { $idletime = $entry['idle']; break; } } if (null === $idletime) { $response['message'] = 'ILIAS could not determine the idle time from the session data.'; return ilJsonUtil::encode($response); } $expiretime = $idletime + ilSession::getIdleValue(); if ($this->isSessionAlreadyExpired($expiretime)) { $response['message'] = 'The session is already expired. The client should have received a remind command before.'; return ilJsonUtil::encode($response); } /** * @var $user ilObjUser */ $ilUser = ilObjectFactory::getInstanceByObjId($data['user_id']); include_once './Services/Authentication/classes/class.ilSessionReminder.php'; $remind_time = $expiretime - max(ilSessionReminder::MIN_LEAD_TIME, (double) $ilUser->getPref('session_reminder_lead_time')) * 60; if ($remind_time > time()) { // session will expire in <lead_time> minutes $response['message'] = 'Lead time not reached, yet. Current time: ' . date('Y-m-d H:i:s', time()) . ', Reminder time: ' . date('Y-m-d H:i:s', $remind_time); return ilJsonUtil::encode($response); } $dateTime = new ilDateTime($expiretime, IL_CAL_UNIX); switch ($ilUser->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_12: $formatted_expiration_time = $dateTime->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone()); break; case ilCalendarSettings::TIME_FORMAT_24: default: $formatted_expiration_time = $dateTime->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone()); break; } $response = array('extend_url' => './ilias.php?baseClass=ilPersonalDesktopGUI', 'txt' => str_replace("\\n", '%0A', sprintf($lng->txt('session_reminder_alert'), ilFormat::_secondsToString($expiretime - time()), $formatted_expiration_time, $ilClientIniFile->readVariable('client', 'name') . ' | ' . ilUtil::_getHttpPath())), 'remind' => true); return ilJsonUtil::encode($response); }
function createBill() { global $tpl, $ilObjDataCache; $customer = $this->user_obj; $transaction = $_GET['transaction']; // $total_price = 0; // $total_vat = 0; $i = 0; include_once './Services/UICore/classes/class.ilTemplate.php'; include_once './Services/Utilities/classes/class.ilUtil.php'; include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); $currency = $genSet->get('currency_unit'); $user_id = $this->user_obj->getId(); $bookings = ilPaymentBookings::__readBillByTransaction($user_id, $transaction); if ($bookings[$i]['street'] == NULL) { $bookings[$i]['street'] = nl2br(utf8_decode($customer->getStreet())); } if ($bookings[$i]['zipcode'] == NULL) { $bookings[$i]['zipcode'] = nl2br(utf8_decode($customer->getZipcode())); } if ($bookings[$i]['city'] == NULL) { $bookings[$i]['city'] = nl2br(utf8_decode($customer->getCity())); } if ($bookings[$i]['country'] == NULL) { $bookings[$i]['country'] = nl2br(utf8_decode($customer->getCountry())); } if (2 == strlen($bookings[$i]['country'])) { $this->lng->loadLanguageModule('meta'); $bookings[$i]['country'] = utf8_decode($this->lng->txt('meta_c_' . strtoupper($bookings[$i]['country']))); } $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.pay_bill.html', 'Services/Payment'); $tpl = new ilTemplate('tpl.pay_bill.html', true, true, 'Services/Payment'); if ($tpl->placeholderExists('HTTP_PATH')) { $http_path = ilUtil::_getHttpPath(); $tpl->setVariable('HTTP_PATH', $http_path); } ilDatePresentation::setUseRelativeDates(false); $tpl->setVariable('DATE', utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings[$i]['order_date'], IL_CAL_UNIX)))); $tpl->setVariable('TXT_CREDIT', utf8_decode($this->lng->txt('credit'))); $tpl->setVariable('TXT_DAY_OF_SERVICE_PROVISION', $this->lng->txt('day_of_service_provision')); include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($bookings[$i]['b_pay_method']); if (strlen(trim($bookings[$i]['transaction_extern']))) { $tpl->setVariable('TXT_EXTERNAL_BILL_NO', str_replace('%s', $str_paymethod, utf8_decode($this->lng->txt('external_bill_no')))); $tpl->setVariable('EXTERNAL_BILL_NO', $bookings[$i]['transaction_extern']); } $tpl->setVariable('TXT_POSITION', $this->lng->txt('position')); $tpl->setVariable('TXT_AMOUNT', $this->lng->txt('amount')); $tpl->setVariable('TXT_UNIT_PRICE', utf8_decode($this->lng->txt('unit_price'))); $tpl->setVariable('VENDOR_ADDRESS', nl2br(utf8_decode($genSet->get('address')))); $tpl->setVariable('VENDOR_ADD_INFO', nl2br(utf8_decode($genSet->get('add_info')))); $tpl->setVariable('VENDOR_BANK_DATA', nl2br(utf8_decode($genSet->get('bank_data')))); $tpl->setVariable('TXT_BANK_DATA', utf8_decode($this->lng->txt('pay_bank_data'))); $tpl->setVariable('CUSTOMER_FIRSTNAME', utf8_decode($customer->getFirstName())); // $customer['vorname']); $tpl->setVariable('CUSTOMER_LASTNAME', utf8_decode($customer->getLastName())); //$customer['nachname']); if ($bookings['po_box'] == '') { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings[$i]['street'])); } else { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings[$i]['po_box'])); } $tpl->setVariable('CUSTOMER_ZIPCODE', utf8_decode($bookings[$i]['zipcode'])); $tpl->setVariable('CUSTOMER_CITY', utf8_decode($bookings[$i]['city'])); $tpl->setVariable('CUSTOMER_COUNTRY', utf8_decode($bookings[$i]['country'])); $tpl->setVariable('BILL_NO', $transaction); $tpl->setVariable('TXT_BILL', utf8_decode($this->lng->txt('pays_bill'))); $tpl->setVariable('TXT_BILL_NO', utf8_decode($this->lng->txt('pay_bill_no'))); $tpl->setVariable('TXT_DATE', utf8_decode($this->lng->txt('date'))); $tpl->setVariable('TXT_ARTICLE', utf8_decode($this->lng->txt('pay_article'))); $tpl->setVariable('TXT_VAT_RATE', utf8_decode($this->lng->txt('vat_rate'))); $tpl->setVariable('TXT_VAT_UNIT', utf8_decode($this->lng->txt('vat_unit'))); $tpl->setVariable('TXT_PRICE', utf8_decode($this->lng->txt('price_a'))); for ($i = 0; $i < count($bookings[$i]); $i++) { $tmp_pobject = new ilPaymentObject($this->user_obj, $bookings[$i]['pobject_id']); $obj_id = $ilObjDataCache->lookupObjId($bookings[$i]['ref_id']); $obj_type = $ilObjDataCache->lookupType($obj_id); $tpl->setCurrentBlock('loop'); $tpl->setVariable('LOOP_POSITION', $i + 1); $tpl->setVariable('LOOP_AMOUNT', '1'); $tpl->setVariable('LOOP_TXT_PERIOD_OF_SERVICE_PROVISION', utf8_decode($this->lng->txt('period_of_service_provision'))); $tpl->setVariable('LOOP_OBJ_TYPE', utf8_decode($this->lng->txt($obj_type))); $tpl->setVariable('LOOP_TITLE', utf8_decode($bookings[$i]['object_title']) . $assigned_coupons); $tpl->setVariable('LOOP_TXT_ENTITLED_RETRIEVE', utf8_decode($this->lng->txt('pay_entitled_retrieve'))); if ($bookings[$i]['duration'] == 0 && $bookings[$i]['access_enddate'] == NULL) { $tpl->setVariable('LOOP_DURATION', utf8_decode($this->lng->txt('unlimited_duration'))); } else { $access_startdate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings[$i]['access_startdate'], IL_CAL_DATETIME))); $access_enddate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings[$i]['access_enddate'], IL_CAL_DATETIME))); $tpl->setVariable('LOOP_DURATION', $access_startdate . ' - ' . $access_enddate . ' / ' . $bookings[$i]['duration'] . ' ' . utf8_decode($this->lng->txt('paya_months'))); } // old one $tpl->setVariable('LOOP_VAT_RATE', number_format($bookings[$i]['vat_rate'], 2, ',', '.') . ' %'); $tpl->setVariable('LOOP_VAT_UNIT', number_format($bookings[$i]['vat_unit'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_UNIT_PRICE', number_format($bookings[$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_PRICE', number_format($bookings[$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock('loop'); $bookings['total'] += (double) $bookings[$i]['price']; $bookings['total_vat'] += (double) $bookings[$i]['vat_unit']; $bookings['total_discount'] += (double) $bookings[$i]['discount']; unset($tmp_pobject); $sub_total_amount = $bookings['total']; } $bookings['total'] += $bookings['total_discount']; if ($bookings['total_discount'] < 0) { $tpl->setCurrentBlock('cloop'); $tpl->setVariable('TXT_SUBTOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_subtotal_amount'))); $tpl->setVariable('SUBTOTAL_AMOUNT', number_format($sub_total_amount, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_COUPON', utf8_decode($this->lng->txt('paya_coupons_coupon') . ' ' . $coupon['pcc_code'])); $tpl->setVariable('BONUS', number_format($bookings['total_discount'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock(); } if ($bookings['total'] < 0) { $bookings['total'] = 0.0; // $bookings['total_vat'] = 0.0; } $total_net_price = $sub_total_amount - $bookings['total_vat']; $tpl->setVariable('TXT_TOTAL_NETPRICE', utf8_decode($this->lng->txt('total_netprice'))); $tpl->setVariable('TOTAL_NETPRICE', number_format($total_net_price, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_total_amount'))); $tpl->setVariable('TOTAL_AMOUNT', number_format($bookings['total'], 2, ',', '.') . ' ' . $currency); if ($bookings['total_vat'] > 0) { $tpl->setVariable('TOTAL_VAT', number_format($bookings['total_vat'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_VAT', utf8_decode($this->lng->txt('plus_vat'))); } if (1 == $bookings[0]['b_pay_method']) { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_unpayed_bill'))); } else { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_payed_bill'))); } if (!@file_exists($genSet->get('pdf_path'))) { ilUtil::makeDir($genSet->get('pdf_path')); } $file_name = time(); if (@file_exists($genSet->get('pdf_path'))) { ilUtil::html2pdf($tpl->get(), $genSet->get('pdf_path') . '/' . $file_name . '.pdf'); } if (@file_exists($genSet->get('pdf_path') . '/' . $file_name . '.pdf')) { ilUtil::deliverFile($genSet->get('pdf_path') . '/' . $file_name . '.pdf', $transaction . '.pdf', $a_mime = 'application/pdf'); } @unlink($genSet->get('pdf_path') . '/' . $file_name . '.html'); @unlink($genSet->get('pdf_path') . '/' . $file_name . '.pdf'); }
public function __sendBill($bookings) { global $tpl, $ilSetting; $i = 0; include_once './Services/UICore/classes/class.ilTemplate.php'; include_once './Services/Utilities/classes/class.ilUtil.php'; include_once './Services/Payment/classes/class.ilPaymentSettings.php'; include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php'; include_once 'Services/Mail/classes/class.ilMimeMail.php'; // $psc_obj = new ilPaymentShoppingCart($this->user_obj); $genSet = ilPaymentSettings::_getInstance(); $currency = $genSet->get('currency_unit'); // $tpl = new ilTemplate('./Services/Payment/templates/default/tpl.pay_bill.html', true, true, true); $tpl = new ilTemplate('tpl.pay_bill.html', true, true, 'Services/Payment'); if ($tpl->placeholderExists('HTTP_PATH')) { $http_path = ilUtil::_getHttpPath(); $tpl->setVariable('HTTP_PATH', $http_path); } ilDatePresentation::setUseRelativeDates(false); $tpl->setVariable('DATE', utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['order_date'], IL_CAL_UNIX)))); $tpl->setVariable('TXT_CREDIT', utf8_decode($this->lng->txt('credit'))); $tpl->setVariable('TXT_DAY_OF_SERVICE_PROVISION', $this->lng->txt('day_of_service_provision')); include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($bookings['list'][$i]['b_pay_method']); if (strlen(trim($bookings['transaction_extern']))) { $tpl->setVariable('TXT_EXTERNAL_BILL_NO', str_replace('%s', $str_paymethod, utf8_decode($this->lng->txt('external_bill_no')))); $tpl->setVariable('EXTERNAL_BILL_NO', $bookings['transaction_extern']); } $tpl->setVariable('TXT_POSITION', $this->lng->txt('position')); $tpl->setVariable('TXT_AMOUNT', $this->lng->txt('amount')); $tpl->setVariable('TXT_UNIT_PRICE', utf8_decode($this->lng->txt('unit_price'))); $tpl->setVariable('VENDOR_ADDRESS', nl2br(utf8_decode($genSet->get('address')))); $tpl->setVariable('VENDOR_ADD_INFO', nl2br(utf8_decode($genSet->get('add_info')))); $tpl->setVariable('VENDOR_BANK_DATA', nl2br(utf8_decode($genSet->get('bank_data')))); $tpl->setVariable('TXT_BANK_DATA', utf8_decode($this->lng->txt('pay_bank_data'))); $tpl->setVariable('CUSTOMER_FIRSTNAME', utf8_decode($this->user_obj->getFirstname())); $tpl->setVariable('CUSTOMER_LASTNAME', utf8_decode($this->user_obj->getLastname())); if ($bookings['po_box'] == '') { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings['street'])); // contains also housenumber } else { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings['po_box'])); } $tpl->setVariable('CUSTOMER_ZIPCODE', utf8_decode($bookings['zipcode'])); $tpl->setVariable('CUSTOMER_CITY', utf8_decode($bookings['city'])); $tpl->setVariable('CUSTOMER_COUNTRY', utf8_decode($bookings['country'])); $tpl->setVariable('BILL_NO', $bookings['transaction']); $tpl->setVariable('DATE', date('d.m.Y')); $tpl->setVariable('TXT_BILL', utf8_decode($this->lng->txt('pays_bill'))); $tpl->setVariable('TXT_BILL_NO', utf8_decode($this->lng->txt('pay_bill_no'))); $tpl->setVariable('TXT_DATE', utf8_decode($this->lng->txt('date'))); $tpl->setVariable('TXT_ARTICLE', utf8_decode($this->lng->txt('pay_article'))); $tpl->setVariable('TXT_VAT_RATE', utf8_decode($this->lng->txt('vat_rate'))); $tpl->setVariable('TXT_VAT_UNIT', utf8_decode($this->lng->txt('vat_unit'))); $tpl->setVariable('TXT_PRICE', utf8_decode($this->lng->txt('price_a'))); for ($i = 0; $i < count($bookings['list']); $i++) { $tmp_pobject = new ilPaymentObject($this->user_obj, $bookings['list'][$i]['pobject_id']); $assigned_coupons = ''; if (!empty($_SESSION['coupons'][$this->session_var])) { foreach ($_SESSION['coupons'][$this->session_var] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code']; } } } $tpl->setCurrentBlock('loop'); $tpl->setVariable('LOOP_POSITION', $i + 1); $tpl->setVariable('LOOP_AMOUNT', '1'); $tpl->setVariable('LOOP_TXT_PERIOD_OF_SERVICE_PROVISION', utf8_decode($this->lng->txt('period_of_service_provision'))); $tpl->setVariable('LOOP_OBJ_TYPE', utf8_decode($this->lng->txt($bookings['list'][$i]['type']))); $tpl->setVariable('LOOP_TITLE', $tmp = utf8_decode($bookings['list'][$i]['title'])); $tpl->setVariable('LOOP_COUPON', utf8_decode($assigned_coupons)); $tpl->setVariable('LOOP_TXT_ENTITLED_RETRIEVE', utf8_decode($this->lng->txt('pay_entitled_retrieve'))); if ($bookings['list'][$i]['duration'] == 0 && $bookings['list'][$i]['access_enddate'] == NULL) { $tpl->setVariable('LOOP_DURATION', utf8_decode($this->lng->txt('unlimited_duration'))); } else { $access_startdate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['access_startdate'], IL_CAL_DATE))); $access_enddate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['access_enddate'], IL_CAL_DATE))); $tmp_duration = $access_startdate . ' - ' . $access_enddate; if ($bookings['list'][$i]['duration'] > 0) { $tmp_duration .= ' / ' . $bookings['list'][$i]['duration'] . ' ' . utf8_decode($this->lng->txt('paya_months')); } $tpl->setVariable('LOOP_DURATION', $tmp_duration); } #$currency = $bookings['list'][$i]['currency_unit']; $tpl->setVariable('LOOP_VAT_RATE', number_format($bookings['list'][$i]['vat_rate'], 2, ',', '.') . ' %'); $tpl->setVariable('LOOP_VAT_UNIT', number_format($bookings['list'][$i]['vat_unit'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_PRICE', number_format($bookings['list'][$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_UNIT_PRICE', number_format($bookings['list'][$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock('loop'); $bookings['total'] += (double) $bookings[$i]['price']; $bookings['total_vat'] += (double) $bookings[$i]['vat_unit']; #$bookings['total_discount'] +=(float) $bookings[$i]['discount']; unset($tmp_pobject); $sub_total_amount = $bookings['total']; } $bookings['total'] += $bookings['total_discount']; if ($bookings['total_discount'] < 0) { $tpl->setCurrentBlock('cloop'); $tpl->setVariable('TXT_SUBTOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_subtotal_amount'))); $tpl->setVariable('SUBTOTAL_AMOUNT', number_format($sub_total_amount, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_COUPON', utf8_decode($this->lng->txt('paya_coupons_coupon'))); $tpl->setVariable('BONUS', number_format($bookings['total_discount'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock(); } if ($bookings['total'] < 0) { $bookings['total'] = 0.0; // $bookings['total_vat'] = 0.0; } $total_net_price = $sub_total_amount - $bookings['total_vat']; $tpl->setVariable('TXT_TOTAL_NETPRICE', utf8_decode($this->lng->txt('total_netprice'))); $tpl->setVariable('TOTAL_NETPRICE', number_format($total_net_price, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_total_amount'))); $tpl->setVariable('TOTAL_AMOUNT', number_format($bookings['total'], 2, ',', '.') . ' ' . $currency); if ($bookings['total_vat'] > 0) { $tpl->setVariable('TOTAL_VAT', number_format($bookings['total_vat'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_VAT', utf8_decode($this->lng->txt('plus_vat'))); } if (1 == $bookings['list'][0]['b_pay_method']) { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_unpayed_bill'))); } else { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_payed_bill'))); } if (!@file_exists($genSet->get('pdf_path'))) { ilUtil::makeDir($genSet->get('pdf_path')); } $file_name = time(); if (@file_exists($genSet->get('pdf_path'))) { ilUtil::html2pdf($tpl->get(), $genSet->get('pdf_path') . '/' . $file_name . '.pdf'); } if (@file_exists($genSet->get('pdf_path') . '/' . $file_name . '.pdf') && $this->user_obj->getEmail() != '' && $ilSetting->get('admin_email') != '') { $m = new ilMimeMail(); // create the mail $m->From($ilSetting->get('admin_email')); $m->To($this->user_obj->getEmail()); $m->Subject($this->lng->txt('pay_message_subject')); // if there is no mailbillingtext use this as standard $message = $this->lng->txt('pay_message_hello') . ' ' . $this->user_obj->getFirstname() . ' ' . $this->user_obj->getLastname() . ",\n\n"; $message .= $this->lng->txt('pay_message_thanks') . "\n\n"; $message .= $this->lng->txt('pay_message_attachment') . "\n\n"; $message .= $this->lng->txt('pay_message_regards') . "\n\n"; $message .= strip_tags($genSet->get('address')); //replacePlaceholders... $billing_text = $genSet->getMailBillingText(); if (!$billing_text) { $message = ''; } if ($genSet->getMailUsePlaceholders() == 1) { include_once './Services/Payment/classes/class.ilBillingMailPlaceholdersPropertyGUI.php'; $message = ilBillingMailPlaceholdersPropertyGUI::replaceBillingMailPlaceholders($billing_text, $this->user_obj->getId()); } $m->Body($message); // set the body $m->Attach($genSet->get('pdf_path') . '/' . $file_name . '.pdf', 'application/pdf'); // attach a file of type image/gif if ($genSet->get('attach_sr_invoice') == 1) { require_once 'Services/RTE/classes/class.ilRTE.php'; $regulations = ilRTE::_replaceMediaObjectImageSrc($genSet->get('statutory_regulations'), 1); $reg_file_name = 'statutory_regulations'; if (@file_exists($genSet->get('pdf_path'))) { ilUtil::html2pdf($regulations, $genSet->get('pdf_path') . '/' . $reg_file_name . '.pdf'); } $m->Attach($genSet->get('pdf_path') . '/' . $reg_file_name . '.pdf', 'application/pdf'); // attach a file of type image/gif } $m->Send(); // send the mail } @unlink($genSet->get('pdf_path') . '/' . $file_name . '.html'); @unlink($genSet->get('pdf_path') . '/' . $file_name . '.pdf'); unset($current_booking_id); unset($pobject); unset($_SESSION['coupons'][$this->session_var]); $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', ''); }
/** * Last step of chat invitations * check access for every selected user and send invitation */ public function submitInvitation() { /** * @var $ilUser ilObjUser * @var $ilCtrl ilCtrl * @var $lng ilLanguage */ global $ilUser, $ilCtrl, $lng; if (!$_POST['addr_ids']) { ilUtil::sendFailure($lng->txt('select_one'), true); $ilCtrl->redirect($this, 'showAddressbook'); } if (!$_POST['room_id']) { ilUtil::sendFailure($lng->txt('select_one')); $_POST['addr_id'] = explode(',', $_POST['addr_ids']); $this->inviteToChat(); return; } // get selected users (comma seperated user id list) $ids = explode(',', $_POST['addr_ids']); // get selected chatroom from POST-String, format: "room_id , scope" $room_ids = explode(',', $_POST['room_id']); $room_id = (int) $room_ids[0]; $scope = 0; if (count($room_ids) > 0) { $scope = (int) $room_ids[1]; } include_once 'Modules/Chatroom/classes/class.ilChatroom.php'; $room = ilChatroom::byRoomId((int) $room_id, true); $no_access = array(); $no_login = array(); $valid_users = array(); $valid_user_to_login_map = array(); foreach ($ids as $id) { $entry = $this->abook->getEntry($id); if ($entry['login']) { $user_id = $ilUser->getUserIdByLogin($entry['login']); if (!$user_id) { $no_login[] = $id; continue; } $ref_id = $room->getRefIdByRoomId($room_id); if (!ilChatroom::checkPermissionsOfUser($user_id, 'read', $ref_id) || $room->isUserBanned($user_id)) { $no_access[] = $id; } else { $valid_users[] = $user_id; $valid_user_to_login_map[$user_id] = $entry['login']; } } else { $no_login[] = $id; } } if (count($no_access) || count($no_login)) { $message = ''; if (count($no_access)) { $message .= $lng->txt('chat_users_without_permission') . ':<br>'; $list = ''; foreach ($no_access as $e) { $list .= '<li>' . $this->abook->entryToString($e) . '</li>'; } $message .= '<ul>'; $message .= $list; $message .= '</ul>'; } if (count($no_login)) { $message .= $lng->txt('chat_users_without_login') . ':<br>'; $list = ''; foreach ($no_login as $e) { $list .= '<li>' . $this->abook->entryToString($e) . '</li>'; } $message .= '<ul>'; $message .= $list; $message .= '</ul>'; } ilUtil::sendFailure($message); $_POST['addr_id'] = $ids; $this->inviteToChat(); return; } $ref_id = $room->getRefIdByRoomId($room_id); if ($scope > 0) { $url = 'ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $ref_id . '&cmd=view&rep_frame=1&sub=' . $scope; } else { $url = 'ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $ref_id . '&cmd=view&rep_frame=1'; } $url = ilUtil::_getHttpPath() . '/' . $url; $link = '<p><a target="chatframe" href="' . $url . '" title="' . $lng->txt('goto_invitation_chat') . '">' . $lng->txt('goto_invitation_chat') . '</a></p>'; $userlist = array(); foreach ($valid_users as $id) { $room->inviteUserToPrivateRoom($id, $scope); $room->sendInvitationNotification(null, $ilUser->getId(), $id, (int) $scope, $url); $userlist[] = '<li>' . $valid_user_to_login_map[$id] . '</li>'; } if ($userlist) { ilUtil::sendSuccess($lng->txt('chat_users_have_been_invited') . '<ul>' . implode('', $userlist) . '</ul>' . $link, true); } $ilCtrl->redirect($this, 'showAddressbook'); }
/** * * @global ilCtrl $ilCtrl * @param <type> $gui * @param <type> $scope_id */ public function getChatURL($gui, $scope_id = 0) { global $ilCtrl; if (!is_string($gui)) { $ilCtrl->setParameterByClass("ilrepositorygui", 'ref_id', $gui->getRefId()); $gui = "ilrepositorygui"; } if (is_string($gui)) { if ($scope_id) { $ilCtrl->setParameterByClass($gui, 'sub', $scope_id); } $link = ilUtil::_getHttpPath() . '/' . $ilCtrl->getLinkTargetByClass($gui, 'view', '', false, false); $ilCtrl->clearParametersByClass($gui); } else { /*if ($scope_id) { $ilCtrl->setParameter($gui, 'sub', $scope_id); } $link = ilUtil::_getHttpPath() . '/'. $ilCtrl->getLinkTarget($gui, 'view', '', false, false); $ilCtrl->clearParameters($gui); */ } return $link; }
/** * @param ilPropertyFormGUI $form */ public function clientsettings(ilPropertyFormGUI $form = null) { /** * @var $tpl ilTemplate * @var $ilCtrl ilCtrl * @var $lng ilLanguage */ global $tpl, $ilCtrl, $lng; ilChatroom::checkUserPermissions('read', $this->gui->ref_id); $this->defaultActions(); $this->gui->switchToVisibleMode(); $this->showSoapWarningIfNeeded(); require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php'; $adminSettings = new ilChatroomAdmin($this->gui->object->getId()); if ($form === null) { require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php'; $factory = new ilChatroomFormFactory(); $form = $factory->getClientSettingsForm(); if (!$this->commonSettings->get('soap_user_administration')) { $form->getItemByPostVar('chat_enabled')->setDisabled(!(bool) $this->commonSettings->get('soap_user_administration')); $form->getItemByPostVar('chat_enabled')->setChecked(0); } $data = (array) $adminSettings->loadClientSettings(); if (!$data['osd_intervall']) { $data['osd_intervall'] = 60; } if (!$data) { $data = array(); } if (!$data['url']) { $data['url'] = ilUtil::_getHttpPath(); } if (!$data['client']) { $data['client'] = CLIENT_ID; } $data['password_retype'] = $data['password']; $form->setValuesByArray($data); } require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php'; $serverSettings = (array) $adminSettings->loadGeneralSettings(); if ($serverSettings['port'] && $serverSettings['address'] && !(bool) @ilChatroomServerConnector::checkServerConnection()) { ilUtil::sendInfo($lng->txt('chat_cannot_connect_to_server')); } $form->setTitle($lng->txt('general_settings_title')); $form->addCommandButton('view-saveClientSettings', $lng->txt('save')); $form->setFormAction($ilCtrl->getFormAction($this->gui, 'view-saveClientSettings')); $settingsTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom'); $settingsTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML()); $settingsTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt('server_further_information'), ilUtil::_getHttpPath() . '/Modules/Chatroom/server/README.txt')); $tpl->setVariable('ADM_CONTENT', $settingsTpl->get()); }