Пример #1
0
 /**
  * @see ilMembershipRegistrationCodes::register()
  * @param int user_id
  * @param int role
  * @param bool force registration and do not check registration constraints.
  */
 public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false)
 {
     global $ilCtrl, $tree;
     include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     $part = ilCourseParticipants::_getInstanceByObjId($this->getId());
     if ($part->isAssigned($a_user_id)) {
         return true;
     }
     if (!$a_force_registration) {
         // Availability
         if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) {
             include_once './Modules/Group/classes/class.ilObjGroupAccess.php';
             if (!ilObjCourseAccess::_usingRegistrationCode()) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course subscription is deactivated.', '456');
             }
         }
         // Time Limitation
         if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) {
             if (!$this->inSubscriptionTime()) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course is out of registration time.', '789');
             }
         }
         // Max members
         if ($this->isSubscriptionMembershipLimited()) {
             $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers());
             include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
             $waiting_list = new ilCourseWaitingList($this->getId());
             if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
                 $waiting_list->addToList($a_user_id);
                 $this->lng->loadLanguageModule("crs");
                 $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($a_user_id));
                 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
                 $participants = ilCourseParticipants::_getInstanceByObjId($this->getId());
                 $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id);
                 throw new ilMembershipRegistrationException($info, '124');
             }
             if (!$this->enabledWaitingList() && !$free) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', membership is limited.', '123');
             }
         }
     }
     $part->add($a_user_id, $a_role);
     $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
     $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id);
     include_once './Modules/Forum/classes/class.ilForumNotification.php';
     ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id);
     return true;
 }
 /**
  * @see ilMembershipRegistrationCodes::register()
  * @param int user_id
  * @param int role
  * @param bool force registration and do not check registration constraints.
  */
 public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false)
 {
     include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     $part = ilCourseParticipants::_getInstanceByObjId($this->getId());
     if ($part->isAssigned($a_user_id)) {
         return true;
     }
     if (!$a_force_registration) {
         // Availability
         if (!self::_registrationEnabled($this->getId())) {
             $this->lng->loadLanguageModule('crs');
             throw new ilMembershipRegistrationException($this->lng->txt('crs_info_reg_deactivated'), $this->getRefId());
         }
         // Max members
         if ($this->isSubscriptionMembershipLimited()) {
             $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers());
             include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
             $waiting_list = new ilCourseWaitingList($this->getId());
             if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
                 throw new ilMembershipRegistrationException('', $this->getRefId());
             }
         }
     }
     $part->add($a_user_id, $a_role);
     $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
     include_once './Modules/Forum/classes/class.ilForumNotification.php';
     ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id);
     return true;
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     switch ($a_component) {
         case "Services/News":
             switch ($a_event) {
                 case "readNews":
                     // here we could set postings to read, if news is
                     // read (has to be implemented)
                     break;
             }
             break;
         case "Services/Tree":
             switch ($a_event) {
                 case "moveTree":
                     include_once './Modules/Forum/classes/class.ilForumNotification.php';
                     ilForumNotification::_clearForcedForumNotifications($a_parameter);
                     break;
             }
             break;
         case "Modules/Course":
             switch ($a_event) {
                 case "addParticipant":
                     include_once './Modules/Forum/classes/class.ilForumNotification.php';
                     $ref_ids = self::getCachedReferences($a_parameter['obj_id']);
                     foreach ($ref_ids as $ref_id) {
                         ilForumNotification::checkForumsExistsInsert($ref_id, $a_parameter['usr_id']);
                         break;
                     }
                     break;
                 case 'deleteParticipant':
                     include_once './Modules/Forum/classes/class.ilForumNotification.php';
                     $ref_ids = self::getCachedReferences($a_parameter['obj_id']);
                     foreach ($ref_ids as $ref_id) {
                         ilForumNotification::checkForumsExistsDelete($ref_id, $a_parameter['usr_id']);
                         break;
                     }
                     break;
             }
             break;
         case "Modules/Group":
             switch ($a_event) {
                 case "addParticipant":
                     include_once './Modules/Forum/classes/class.ilForumNotification.php';
                     $ref_ids = self::getCachedReferences($a_parameter['obj_id']);
                     foreach ($ref_ids as $ref_id) {
                         ilForumNotification::checkForumsExistsInsert($ref_id, $a_parameter['usr_id']);
                         break;
                     }
                     break;
                 case 'deleteParticipant':
                     include_once './Modules/Forum/classes/class.ilForumNotification.php';
                     $ref_ids = self::getCachedReferences($a_parameter['obj_id']);
                     foreach ($ref_ids as $ref_id) {
                         ilForumNotification::checkForumsExistsDelete($ref_id, $a_parameter['usr_id']);
                         break;
                     }
                     break;
             }
             break;
     }
 }
 /**
  * add user 
  *
  * @access protected
  * @param
  * @return
  */
 protected function add()
 {
     global $ilUser, $tree, $ilCtrl;
     // TODO: language vars
     // set aggreement accepted
     $this->setAccepted(true);
     include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
     $free = max(0, $this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers());
     $waiting_list = new ilCourseWaitingList($this->container->getId());
     if ($this->container->isSubscriptionMembershipLimited() and $this->container->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
         $waiting_list->addToList($ilUser->getId());
         $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($ilUser->getId()));
         ilUtil::sendSuccess($info, true);
         $this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST, $ilUser->getId());
         $this->participants->sendNotification($this->participants->NOTIFY_WAITING_LIST, $ilUser->getId());
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
         $ilCtrl->redirectByClass("ilrepositorygui", "");
     }
     switch ($this->container->getSubscriptionType()) {
         case IL_CRS_SUBSCRIPTION_CONFIRMATION:
             $this->participants->addSubscriber($ilUser->getId());
             $this->participants->updateSubscriptionTime($ilUser->getId(), time());
             $this->participants->updateSubject($ilUser->getId(), ilUtil::stripSlashes($_POST['subject']));
             $this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST, $ilUser->getId());
             ilUtil::sendSuccess($this->lng->txt("application_completed"), true);
             $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
             $ilCtrl->redirectByClass("ilrepositorygui", "");
             break;
         default:
             $this->participants->add($ilUser->getId(), IL_CRS_MEMBER);
             $this->participants->sendNotification($this->participants->NOTIFY_ADMINS, $ilUser->getId());
             $this->participants->sendNotification($this->participants->NOTIFY_REGISTERED, $ilUser->getId());
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId());
             if ($this->container->getType() == "crs") {
                 $this->container->checkLPStatusSync($ilUser->getId());
             }
             if (!$_SESSION["pending_goto"]) {
                 ilUtil::sendSuccess($this->lng->txt("crs_subscription_successful"), true);
                 $this->ctrl->returnToParent($this);
             } else {
                 $tgt = $_SESSION["pending_goto"];
                 unset($_SESSION["pending_goto"]);
                 ilUtil::redirect($tgt);
             }
             break;
     }
 }
 /**
  * displays confirmation formular with users that shall be assigned to group
  * @access public
  */
 function addUserObject($user_ids, $a_type)
 {
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     if (empty($user_ids[0])) {
         $GLOBALS['lng']->loadLanguageModule('search');
         ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'), true);
         return false;
     }
     foreach ($user_ids as $new_member) {
         switch ($a_type) {
             case ilObjGroup::GRP_MEMBER:
                 if (!$this->object->addMember($new_member, $this->object->getDefaultMemberRole())) {
                     $this->ilErr->raiseError("An Error occured while assigning user to group !", $this->ilErr->MESSAGE);
                 }
                 break;
             case ilObjGroup::GRP_ADMIN:
                 if (!$this->object->addMember($new_member, $this->object->getDefaultAdminRole())) {
                     $this->ilErr->raiseError("An Error occured while assigning user to group !", $this->ilErr->MESSAGE);
                 }
                 break;
         }
         ilObjUser::_addDesktopItem($new_member, $this->object->getRefId(), 'grp');
         include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
         $this->object->members_obj->sendNotification(ilGroupMembershipMailNotification::TYPE_ADMISSION_MEMBER, $new_member);
         include_once './Modules/Forum/classes/class.ilForumNotification.php';
         ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $new_member);
     }
     unset($_SESSION["saved_post"]);
     unset($_SESSION['grp_usr_search_result']);
     ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"), true);
     $this->ctrl->redirect($this, 'members');
 }
 function add()
 {
     global $ilErr, $ilObjDataCache, $lng, $ilAccess;
     if (sizeof($_POST["usrs"])) {
         if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"])) {
             ilUtil::sendFailure($lng->txt("permission_denied"), true);
             $this->show();
             return;
         }
         include_once './Modules/Group/classes/class.ilGroupParticipants.php';
         $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"]));
         foreach ($_POST["usrs"] as $new_member) {
             if (!$members_obj->add($new_member, IL_GRP_MEMBER)) {
                 $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE);
             }
             include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
             $members_obj->sendNotification(ilGroupMembershipMailNotification::TYPE_ADMISSION_MEMBER, $new_member);
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsInsert($this->ref_id, $new_member);
         }
         ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned"));
     }
     $this->show();
 }
 public function assignSubscribersObject()
 {
     global $rbacsystem, $ilErr;
     $this->checkPermission('write');
     if (!is_array($_POST["subscribers"])) {
         ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
         $this->membersObject();
         return false;
     }
     if (!$this->object->getMembersObject()->assignSubscribers($_POST["subscribers"])) {
         ilUtil::sendFailure($ilErr->getMessage());
         $this->membersObject();
         return false;
     } else {
         foreach ($_POST["subscribers"] as $usr_id) {
             $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_ACCEPT_SUBSCRIBER, $usr_id);
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $usr_id);
             $this->object->checkLPStatusSync($usr_id);
         }
     }
     ilUtil::sendSuccess($this->lng->txt("crs_subscribers_assigned"));
     $this->membersObject();
     return true;
 }
 /**
  * add user 
  *
  * @access protected
  * @param
  * @return
  */
 protected function add()
 {
     global $ilUser, $tree, $rbacreview, $lng, $ilCtrl;
     // set aggreement accepted
     $this->setAccepted(true);
     include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
     $free = max(0, $this->container->getMaxMembers() - $this->participants->getCountMembers());
     $waiting_list = new ilGroupWaitingList($this->container->getId());
     if ($this->container->isMembershipLimited() and $this->container->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) {
         $waiting_list->addToList($ilUser->getId());
         $info = sprintf($this->lng->txt('grp_added_to_list'), $this->container->getTitle(), $waiting_list->getPosition($ilUser->getId()));
         $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER, $ilUser->getId());
         ilUtil::sendSuccess($info, true);
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
         $ilCtrl->redirectByClass("ilrepositorygui", "");
     }
     switch ($this->container->getRegistrationType()) {
         case GRP_REGISTRATION_REQUEST:
             $this->participants->addSubscriber($ilUser->getId());
             $this->participants->updateSubscriptionTime($ilUser->getId(), time());
             $this->participants->updateSubject($ilUser->getId(), ilUtil::stripSlashes($_POST['subject']));
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION_REQUEST, $ilUser->getId());
             ilUtil::sendSuccess($this->lng->txt("application_completed"), true);
             $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
             $ilCtrl->redirectByClass("ilrepositorygui", "");
             break;
         default:
             $this->participants->add($ilUser->getId(), IL_GRP_MEMBER);
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION, $ilUser->getId());
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_SUBSCRIBE_MEMBER, $ilUser->getId());
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId());
             if (!$_SESSION["pending_goto"]) {
                 ilUtil::sendSuccess($this->lng->txt("grp_registration_completed"), true);
                 $this->ctrl->returnToParent($this);
             } else {
                 $tgt = $_SESSION["pending_goto"];
                 unset($_SESSION["pending_goto"]);
                 ilUtil::redirect($tgt);
             }
             break;
     }
 }