/**
  * Book an appointment. All checks (assignment possible, max booking) must be done before
  * @param type $a_usr_id
  * @param type $a_app_id
  * @return bool
  */
 public static function bookAppointment($a_usr_id, $a_app_id)
 {
     global $lng;
     // Create new default consultation hour calendar
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $cal_lang = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
     $cal_lang->loadLanguageModule('dateplaner');
     include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $ch = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_CH, $a_usr_id, $cal_lang->txt('cal_ch_personal_ch'), true);
     // duplicate appointment
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     $app = new ilCalendarEntry($a_app_id);
     $personal_app = clone $app;
     $personal_app->save();
     // assign appointment to category
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $assignment = new ilCalendarCategoryAssignments($personal_app->getEntryId());
     $assignment->addAssignment($ch->getCategoryID());
     // book appointment
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     $booking = new ilBookingEntry($app->getContextId());
     $booking->book($app->getEntryId(), $a_usr_id);
     return true;
 }
Exemplo n.º 2
0
 /**
  * get auto generated info string
  *
  * @access public
  * @static
  *
  * @param string language
  */
 public static function _getAutoGeneratedMessageString($lang = null)
 {
     global $ilSetting;
     if (!$lang) {
         include_once './Services/Language/classes/class.ilLanguageFactory.php';
         $lang = ilLanguageFactory::_getLanguage();
     }
     $http_path = ilUtil::_getHttpPath();
     $lang->loadLanguageModule('mail');
     return sprintf($lang->txt('mail_auto_generated_info'), $ilSetting->get('inst_name', 'ILIAS 4'), $http_path . "\n\n");
 }
 /**
  * send notifications about new EContent
  */
 protected function sendNewContentNotification($a_server_id)
 {
     include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
     $settings = ilECSSetting::getInstanceByServerId($a_server_id);
     if (!count($rcps = $settings->getEContentRecipients())) {
         return;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
     if (strlen($desc = $this->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($settings->getEContentRecipientsAsString(), '', '', $lang->txt('ecs_new_econtent_subject'), $message, array(), array('normal'));
 }
 /**
  * send notifications about new EContent
  *
  * @return bool
  */
 protected function sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
 {
     global $ilLog;
     if (!count($rcps = $a_server->getApprovalRecipients())) {
         return true;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     // @TODO: read mail
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
     if (strlen($desc = $this->content_obj->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     // Participant info
     $message .= "\n" . $lang->txt('ecs_published_for');
     try {
         $found = false;
         $receivers = null;
         include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
         $details = ilECSEContentDetails::getInstance($a_server->getServerId(), $a_econtent_id, $this->getECSObjectType());
         if ($details instanceof ilECSEContentDetails) {
             $receivers = $details->getReceivers();
         }
         if ($receivers) {
             foreach ($receivers as $member) {
                 $found = true;
                 include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
                 $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
                 $message .= "\n\n" . $part->getParticipantName() . "\n";
                 $message .= $part->getDescription();
             }
         }
         if ($found) {
             $message .= "\n\n";
         } else {
             $message .= ' ' . $lang->txt('ecs_not_published') . "\n\n";
         }
     } catch (ilECSConnectorException $e) {
         $ilLog->write(__METHOD__ . ': Cannot read approvements.');
         return false;
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($a_server->getApprovalRecipientsAsString(), '', '', $lang->txt('ecs_new_approval_subject'), $message, array(), array('normal'));
     return true;
 }
 /**
  * 
  * @return 
  */
 public function send()
 {
     global $rbacreview, $lng;
     switch ($this->getType()) {
         case self::TYPE_USER:
             $rcp = array_pop($this->getRecipients());
             $this->initLanguage($rcp);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_mail_notification_subject'), $this->getAppointment()->getTitle()));
             $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_mail_notification_body'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail($this->getRecipients(), array('system'), true);
             break;
         case self::TYPE_USER_ANONYMOUS:
             $rcp = array_pop($this->getRecipients());
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->getLanguage()->loadLanguageModule('mail');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_mail_notification_subject'), $this->getAppointment()->getTitle()));
             $this->setBody(ilMail::getSalutation(0, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_mail_notification_body'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail($this->getRecipients(), array('email'), false);
             break;
         case self::TYPE_GRP_NEW_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('grp');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_grp_new_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('grp_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_grp_new_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_grp_admin_' . $this->getRefId(), '#il_grp_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_GRP_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('grp');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_grp_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('grp_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_grp_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_grp_admin_' . $this->getRefId(), '#il_grp_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_CRS_NEW_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('crs');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_crs_new_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('crs_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_crs_new_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_crs_admin_' . $this->getRefId(), '#il_crs_tutor_' . $this->getRefId(), '#il_crs_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_CRS_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('crs');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_crs_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('crs_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_crs_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_crs_admin_' . $this->getRefId(), '#il_crs_tutor_' . $this->getRefId(), '#il_crs_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_BOOKING_CONFIRMATION:
             $user_id = array_pop($this->getRecipients());
             include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilCalendarEntry($this->getAppointmentId());
             $booking = new ilBookingEntry($entry->getContextId());
             $this->initLanguage($user_id);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_booking_confirmation_subject'), $entry->getTitle()));
             $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_booking_confirmation_body'), ilObjUser::_lookupFullname($booking->getObjId())));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails($booking);
             /*
             				$this->appendBody("\n\n");
             				$this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
             				$this->appendBody("\n\n");
             				$this->appendBody($this->createPermanentLink());
             */
             $this->getMail()->appendInstallationSignature(true);
             $this->sendMail(array($user_id), array('system'), true);
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_booking_confirmation_user') . "\n");
             $this->appendBody(ilObjUser::_lookupFullname($user_id));
             $this->sendMail(array($booking->getObjId()), array('system'), true);
             break;
         case self::TYPE_BOOKING_CANCELLATION:
             $user_id = array_pop($this->getRecipients());
             include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilCalendarEntry($this->getAppointmentId());
             $booking = new ilBookingEntry($entry->getContextId());
             $user_id = array_pop($this->getRecipients());
             $this->initLanguage($user_id);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_booking_cancellation_subject'), $entry->getTitle()));
             $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_booking_cancellation_body'), ilObjUser::_lookupFullname($booking->getObjId())));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails($booking);
             $this->getMail()->appendInstallationSignature(true);
             $this->sendMail(array($user_id), array('system'), true);
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_booking_cancellation_user') . "\n");
             $this->appendBody(ilObjUser::_lookupFullname($user_id));
             $this->sendMail(array($booking->getObjId()), array('system'), true);
             break;
     }
     $this->deleteAttachments();
 }
 /**
  * send notification about new user accounts
  *
  * @access protected
  */
 protected static function _sendNotification(ilECSSetting $server, ilObjUser $user_obj)
 {
     if (!count($server->getUserRecipients())) {
         return true;
     }
     // If sub id is set => mail was send
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($server->getServerId(), $user_obj->getId());
     if ($import->getSubId()) {
         return false;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($server->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
     // Store sub_id = 1 in ecs import which means mail is send
     $import->setSubId(1);
     $import->save();
     return true;
 }
 /**
  * Send notification
  *
  * @access private
  * @param
  * 
  */
 private function sendNotification($user_obj)
 {
     if (!count($this->getCurrentServer()->getUserRecipients())) {
         return true;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     include_once './Services/Language/classes/class.ilLanguage.php';
     $lang = ilLanguageFactory::_getLanguage();
     $GLOBALS['lng'] = $lang;
     $GLOBALS['ilUser'] = $user_obj;
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($this->getCurrentServer()->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
 }
Exemplo n.º 8
0
 /**
  * Init language by ISO2 code
  * @param string $a_code
  */
 protected function initLanguageByIso2Code($a_code = '')
 {
     $this->language = ilLanguageFactory::_getLanguage($a_code);
     $this->language->loadLanguageModule('mail');
     if (sizeof($this->lang_modules)) {
         foreach ($this->lang_modules as $lmod) {
             $this->language->loadLanguageModule($lmod);
         }
     }
 }
 /**
  * Init language by ISO2 code
  * @param string $a_code
  */
 protected function initLanguageByIso2Code($a_code = '')
 {
     $this->language = ilLanguageFactory::_getLanguage($a_code);
     $this->language->loadLanguageModule('mail');
 }