/**
  * Add desktop item
  * @access public 
  */
 public static function addToDesktop()
 {
     global $ilUser;
     if ($_GET["item_ref_id"] and $_GET["type"]) {
         ilObjUser::_addDesktopItem($ilUser->getId(), (int) $_GET['item_ref_id'], $_GET['type']);
     } else {
         if ($_POST["items"]) {
             foreach ($_POST["items"] as $item) {
                 $type = ilObject::_lookupType($item, true);
                 ilObjUser::_addDesktopItem($ilUser->getId(), $item, $type);
             }
         }
     }
     return true;
 }
 /**
  * Add desktop item
  *
  * @access public
  * @param int usr_id
  * 
  */
 public function addDesktopItem($a_usr_id)
 {
     if (!ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id, $this->type)) {
         ilObjUser::_addDesktopItem($a_usr_id, $this->ref_id, $this->type);
     }
     return true;
 }
示例#3
0
 /**
  * Add desktop item
  * @param type $a_rol_id
  * @param type $a_usr_id
  */
 protected function addDesktopItem($a_rol_id, $a_usr_id)
 {
     include_once 'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
     $role_desk_item_obj = new ilRoleDesktopItem($a_rol_id);
     foreach ($role_desk_item_obj->getAll() as $item_data) {
         include_once './Services/User/classes/class.ilObjUser.php';
         ilObjUser::_addDesktopItem($a_usr_id, $item_data['item_id'], $item_data['item_type']);
     }
 }
示例#4
0
 public static function applyRoleAssignments(ilObjUser $user, $code)
 {
     include_once './Services/Registration/classes/class.ilRegistrationCode.php';
     $grole = ilRegistrationCode::getCodeRole($code);
     if ($grole) {
         $GLOBALS['rbacadmin']->assignUser($grole, $user->getId());
     }
     $code_data = ilRegistrationCode::getCodeData($code);
     if ($code_data["role_local"]) {
         $code_local_roles = explode(";", $code_data["role_local"]);
         foreach ((array) $code_local_roles as $role_id) {
             $GLOBALS['rbacadmin']->assignUser($role_id, $user->getId());
             // patch to remove for 45 due to mantis 21953
             $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($role_id);
             switch (ilObject::_lookupType($role_obj)) {
                 case 'crs':
                 case 'grp':
                     $role_refs = ilObject::_getAllReferences($role_obj);
                     $role_ref = end($role_refs);
                     ilObjUser::_addDesktopItem($user->getId(), $role_ref, ilObject::_lookupType($role_obj));
                     break;
             }
         }
     }
     return true;
 }
 /**
  * Invites a role to a survey
  *
  * @param integer $role_id The database id of the invited role
  * @access public
  */
 function inviteRole($role_id)
 {
     global $rbacreview;
     global $ilAccess;
     $invited = 0;
     $members = $rbacreview->assignedUsers($role_id);
     foreach ($members as $user_id) {
         if ($ilAccess->checkAccessOfUser($user_id, "read", "", $this->getRefId(), "svy", $this->getId())) {
             $this->inviteUser($user_id);
             if ($this->getInvitation() == self::INVITATION_ON) {
                 include_once './Services/User/classes/class.ilObjUser.php';
                 ilObjUser::_addDesktopItem($user_id, $this->getRefId(), "svy");
             }
         }
     }
     return $invited;
 }
 /**
  * Assigns a user to a role.
  */
 function assignToRole($a_user_obj, $a_role_id)
 {
     require_once "./Services/AccessControl/classes/class.ilObjRole.php";
     include_once './Services/Object/classes/class.ilObject.php';
     #require_once "Modules/Course/classes/class.ilObjCourse.php";
     #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
     global $rbacreview, $rbacadmin, $tree;
     // Do nothing, if the user is already assigned to the role.
     // Specifically, we do not want to put a course object or
     // group object on the personal desktop again, if a user
     // has removed it from the personal desktop.
     if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id)) {
         return;
     }
     // If it is a course role, use the ilCourseMember object to assign
     // the user to the role
     $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
     $obj_id = $rbacreview->getObjectOfRole($a_role_id);
     switch ($type = ilObject::_lookupType($obj_id)) {
         case 'grp':
         case 'crs':
             $ref_ids = ilObject::_getAllReferences($obj_id);
             $ref_id = current((array) $ref_ids);
             if ($ref_id) {
                 ilObjUser::_addDesktopItem($a_user_obj->getId(), $ref_id, $type);
             }
             break;
         default:
             break;
     }
 }
 /**
  * Do Cloning
  */
 public function doClone($a_target_id, $a_copy_id, $new_obj)
 {
     /**
      * @var $ilDB   ilDB
      * @var $ilUser ilObjUser
      */
     global $ilDB, $ilUser;
     // to avoid date-conflicts:
     // start_date = now - 2h
     // duration = 1h
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $this->start_date = new ilDateTime($now->getUnixTime() - 7200, IL_CAL_UNIX);
     //$this->start_date = new ilDateTime(0, IL_CAL_UNIX);
     $this->duration = array('hours' => 1, 'minutes' => 0);
     $new_obj->setStartDate($this->getStartDate());
     $new_obj->setInstructions($this->getInstructions());
     $new_obj->setContactInfo($this->getContactInfo());
     $new_obj->setPermanentRoom($this->getPermanentRoom());
     $new_obj->setReadContents($this->getReadContents());
     $new_obj->setReadRecords($this->getReadRecords());
     $new_obj->setDuration($this->getDuration());
     $new_obj->setURL($this->getURL());
     $new_obj->setScoId($this->getScoId());
     $new_obj->setFolderId($this->getFolderId());
     $new_obj->update();
     // add xavc-member,  assign roles
     $new_obj_id = $new_obj->getId();
     $res = $ilDB->queryF('SELECT sco_id FROM rep_robj_xavc_data WHERE id = %s', array('integer'), array($new_obj_id));
     $row = $ilDB->fetchAssoc($res);
     $new_sco_id = $row['sco_id'];
     $this->pluginObj->includeClass('class.ilXAVCMembers.php');
     $this->pluginObj->includeClass('class.ilAdobeConnectRoles.php');
     $xavcMemberObj = new ilXAVCMembers($new_obj->getRefId(), $ilUser->getId());
     $xavcMemberObj->setPresenterStatus();
     $xavcMemberObj->setScoId($new_sco_id);
     $xavcMemberObj->insertXAVCMember();
     $xavc_role = new ilAdobeConnectRoles($new_obj->getRefId());
     $xavc_role->addAdministratorRole($ilUser->getId());
     if (ilAdobeConnectServer::getSetting('add_to_desktop') == 1) {
         ilObjUser::_addDesktopItem($ilUser->getId(), $new_obj->getRefId(), 'xavc');
     }
 }
示例#8
0
 /**
  * add an item to user's personal desktop
  *
  * @param	int		$a_item_id		ref_id for objects, that are in the main tree
  *									(learning modules, forums) obj_id for others
  * @param	string	$a_type			object type
  */
 function addDesktopItem($a_item_id, $a_type, $a_par = "")
 {
     ilObjUser::_addDesktopItem($this->getId(), $a_item_id, $a_type, $a_par);
 }
 /**
  *  Add user to the Adobe Connect server
  * @param integer $a_user_id
  */
 public function addParticipant($a_user_id)
 {
     $this->pluginObj->includeClass('class.ilAdobeConnectUserUtil.php');
     $this->pluginObj->includeClass('class.ilXAVCMembers.php');
     $this->tabs->activateTab("participants");
     //check if there is an adobe connect account at the ac-server
     $ilAdobeConnectUser = new ilAdobeConnectUserUtil($a_user_id);
     $ilAdobeConnectUser->ensureAccountExistance();
     // add to desktop
     if (ilAdobeConnectServer::getSetting('add_to_desktop') == 1) {
         ilObjUser::_addDesktopItem($a_user_id, $this->object->getRefId(), 'xavc');
     }
     $is_member = ilXAVCMembers::_isMember($a_user_id, $this->object->getRefId());
     // local member table
     if (!$is_member) {
         $xavcMemberObj = new ilXAVCMembers($this->object->getRefId(), $a_user_id);
         $xavcMemberObj->setParticipantStatus();
         $xavcMemberObj->setScoId($this->object->getScoId());
         $xavcMemberObj->insertXAVCMember();
         $this->object->updateParticipant(ilXAVCMembers::_lookupXAVCLogin($a_user_id), $xavcMemberObj->getStatus());
         ilUtil::sendInfo($this->txt('participant_added_successfully'));
     } else {
         if ($is_member) {
             //only update at adobe connect server
             $this->object->updateParticipant(ilXAVCMembers::_lookupXAVCLogin($a_user_id), ilXAVCMembers::_lookupStatus($a_user_id, $this->object->getRefId()));
             ilUtil::sendInfo($this->pluginObj->txt('is_already_participant'));
         }
     }
 }
 protected function __createUser($a_role)
 {
     /**
      * @var $ilSetting ilSetting
      * @var $rbacadmin ilRbacAdmin
      * @var $lng       ilLanguage
      */
     global $ilSetting, $rbacadmin, $lng;
     // something went wrong with the form validation
     if (!$a_role) {
         global $ilias;
         $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL);
     }
     $this->userObj = new ilObjUser();
     include_once "./Services/User/classes/class.ilUserProfile.php";
     $up = new ilUserProfile();
     $up->setMode(ilUserProfile::MODE_REGISTRATION);
     $map = array();
     $up->skipGroup("preferences");
     $up->skipGroup("settings");
     $up->skipGroup("instant_messengers");
     $up->skipField("password");
     $up->skipField("birthday");
     $up->skipField("upload");
     foreach ($up->getStandardFields() as $k => $v) {
         if ($v["method"]) {
             $method = "set" . substr($v["method"], 3);
             if (method_exists($this->userObj, $method)) {
                 if ($k != "username") {
                     $k = "usr_" . $k;
                 }
                 $field_obj = $this->form->getItemByPostVar($k);
                 if ($field_obj) {
                     $this->userObj->{$method}($this->form->getInput($k));
                 }
             }
         }
     }
     $this->userObj->setFullName();
     $birthday_obj = $this->form->getItemByPostVar("usr_birthday");
     if ($birthday_obj) {
         $birthday = $this->form->getInput("usr_birthday");
         $birthday = $birthday["date"];
         // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui
         if (!is_array($birthday)) {
             $this->userObj->setBirthday($birthday);
         }
     }
     // messenger
     $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
     foreach ($map as $client) {
         $field = "usr_im_" . $client;
         $field_obj = $this->form->getItemByPostVar($field);
         if ($field_obj) {
             $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
         }
     }
     $this->userObj->setTitle($this->userObj->getFullname());
     $this->userObj->setDescription($this->userObj->getEmail());
     if ($this->registration_settings->passwordGenerationEnabled()) {
         $password = ilUtil::generatePasswords(1);
         $password = $password[0];
     } else {
         $password = $this->form->getInput("usr_password");
     }
     $this->userObj->setPasswd($password);
     // Set user defined data
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $user_defined_fields =& ilUserDefinedFields::_getInstance();
     $defs = $user_defined_fields->getRegistrationDefinitions();
     $udf = array();
     foreach ($_POST as $k => $v) {
         if (substr($k, 0, 4) == "udf_") {
             $f = substr($k, 4);
             $udf[$f] = $v;
         }
     }
     $this->userObj->setUserDefinedData($udf);
     $this->userObj->setTimeLimitOwner(7);
     $access_limit = null;
     $this->code_was_used = false;
     if ($this->code_enabled) {
         $code_local_roles = $code_has_access_limit = null;
         // #10853 - could be optional
         $code = $this->form->getInput('usr_registration_code');
         if ($code) {
             include_once './Services/Registration/classes/class.ilRegistrationCode.php';
             // set code to used
             ilRegistrationCode::useCode($code);
             $this->code_was_used = true;
             // handle code attached local role(s) and access limitation
             $code_data = ilRegistrationCode::getCodeData($code);
             if ($code_data["role_local"]) {
                 // need user id before we can assign role(s)
                 $code_local_roles = explode(";", $code_data["role_local"]);
             }
             if ($code_data["alimit"]) {
                 // see below
                 $code_has_access_limit = true;
                 switch ($code_data["alimit"]) {
                     case "absolute":
                         $abs = date_parse($code_data["alimitdt"]);
                         $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']);
                         break;
                     case "relative":
                         $rel = unserialize($code_data["alimitdt"]);
                         $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time();
                         break;
                 }
             }
         }
     }
     // code access limitation will override any other access limitation setting
     if (!($this->code_was_used && $code_has_access_limit) && $this->registration_settings->getAccessLimitation()) {
         include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
         $access_limitations_obj = new ilRegistrationRoleAccessLimitations();
         switch ($access_limitations_obj->getMode($a_role)) {
             case 'absolute':
                 $access_limit = $access_limitations_obj->getAbsolute($a_role);
                 break;
             case 'relative':
                 $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd');
                 $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm');
                 $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y');
                 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
                 break;
         }
     }
     if ($access_limit) {
         $this->userObj->setTimeLimitUnlimited(0);
         $this->userObj->setTimeLimitUntil($access_limit);
     } else {
         $this->userObj->setTimeLimitUnlimited(1);
         $this->userObj->setTimeLimitUntil(time());
     }
     $this->userObj->setTimeLimitFrom(time());
     $this->userObj->create();
     if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) {
         $this->userObj->setActive(1, 0);
     } else {
         if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) {
             $this->userObj->setActive(0, 0);
         } else {
             $this->userObj->setActive(0, 0);
         }
     }
     $this->userObj->updateOwner();
     // set a timestamp for last_password_change
     // this ts is needed by ilSecuritySettings
     $this->userObj->setLastPasswordChangeTS(time());
     $this->userObj->setIsSelfRegistered(true);
     //insert user data in table user_data
     $this->userObj->saveAsNew();
     try {
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
         ilTermsOfServiceHelper::trackAcceptance($this->userObj, ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng));
     } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) {
     }
     // setup user preferences
     $this->userObj->setLanguage($this->form->getInput('usr_language'));
     $hits_per_page = $ilSetting->get("hits_per_page");
     if ($hits_per_page < 10) {
         $hits_per_page = 10;
     }
     $this->userObj->setPref("hits_per_page", $hits_per_page);
     $show_online = $ilSetting->get("show_users_online");
     if ($show_online == "") {
         $show_online = "y";
     }
     $this->userObj->setPref("show_users_online", $show_online);
     $this->userObj->writePrefs();
     $rbacadmin->assignUser((int) $a_role, $this->userObj->getId());
     // local roles from code
     if ($this->code_was_used && is_array($code_local_roles)) {
         foreach (array_unique($code_local_roles) as $local_role_obj_id) {
             // is given role (still) valid?
             if (ilObject::_lookupType($local_role_obj_id) == "role") {
                 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
                 // patch to remove for 45 due to mantis 21953
                 $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($local_role_obj_id);
                 switch (ilObject::_lookupType($role_obj)) {
                     case 'crs':
                     case 'grp':
                         $role_refs = ilObject::_getAllReferences($role_obj);
                         $role_ref = end($role_refs);
                         ilObjUser::_addDesktopItem($this->userObj->getId(), $role_ref, ilObject::_lookupType($role_obj));
                         break;
                 }
             }
         }
     }
     return $password;
 }
 /**
  * Assigns a user to a role.
  */
 function assignToRole($a_user_obj, $a_role_id)
 {
     require_once "./Services/AccessControl/classes/class.ilObjRole.php";
     include_once './Services/Object/classes/class.ilObject.php';
     #require_once "Modules/Course/classes/class.ilObjCourse.php";
     #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
     global $rbacreview, $rbacadmin, $tree, $ilLog, $ilAppEventHandler;
     // Do nothing, if the user is already assigned to the role.
     // Specifically, we do not want to put a course object or
     // group object on the personal desktop again, if a user
     // has removed it from the personal desktop.
     if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id)) {
         return;
     }
     // If it is a course role, use the ilCourseMember object to assign
     // the user to the role
     $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
     $obj_id = $rbacreview->getObjectOfRole($a_role_id);
     switch ($type = ilObject::_lookupType($obj_id)) {
         case 'grp':
         case 'crs':
             $ref_ids = ilObject::_getAllReferences($obj_id);
             $ref_id = current((array) $ref_ids);
             if ($ref_id) {
                 ilObjUser::_addDesktopItem($a_user_obj->getId(), $ref_id, $type);
             }
             // START PATCH CPKN EVENT 2016 EJ
             // If a user is added to the Course or a Group via the roles in the User Importer,
             // fire the addParticipant event.
             $ilLog->write(__METHOD__ . ': Raise new event: Modules/Course|Group addParticipant');
             $ilAppEventHandler->raise('Services/User', "addParticipant", array('obj_id' => $obj_id, 'usr_id' => $a_user_obj->getId(), 'role_id' => $a_role_id));
             // END PATCH CPKN EVENT 2016 EJ
             break;
         default:
             break;
     }
 }
 /**
  * Perform update
  * @param type $a_content_id
  * @param type $course
  */
 protected function doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $obj_ids = ilECSImport::lookupObjIdsByContentId($status->getId());
     $obj_id = end($obj_ids);
     $ref_ids = ilObject::_getAllReferences($obj_id);
     $ref_id = end($ref_ids);
     if (!$ref_id) {
         // Remote object not found
         return TRUE;
     }
     switch ($status->getStatus()) {
         case ilECSEnrolmentStatus::STATUS_PENDING:
             // nothing todo in the moment: maybe send mail
             break;
         case ilECSEnrolmentStatus::STATUS_ACTIVE:
             $GLOBALS['ilLog']->write(__METHOD__ . ': Add desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
             ilObjUser::_addDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
             break;
         case ilECSEnrolmentStatus::STATUS_ACCOUNT_DEACTIVATED:
         case ilECSEnrolmentStatus::STATUS_DENIED:
         case ilECSEnrolmentStatus::STATUS_REJECTED:
         case ilECSEnrolmentStatus::STATUS_UNSUBSCRIBED:
             $GLOBALS['ilLog']->write(__METHOD__ . ': Remove desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
             ilObjUser::_dropDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
             break;
     }
     return TRUE;
 }
 /**
  * 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');
 }
示例#14
0
 /**
  * displays confirmation formular with users that shall be assigned to group
  * @access public
  */
 public function addUserObject($user_ids, $a_type)
 {
     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) {
         if (in_array($a_type, $this->object->getLocalGroupRoles(false))) {
             if (!$this->object->addMember($new_member, $a_type)) {
                 $this->ilErr->raiseError("An Error occured while assigning user to group !", $this->ilErr->MESSAGE);
             }
         }
         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);
     }
     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');
 }