Example #1
0
 /**
  * deletes a user
  * @access	public
  * @param	integer		user_id
  */
 function delete()
 {
     global $rbacadmin, $ilDB;
     // deassign from ldap groups
     include_once 'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php';
     $mapping = ilLDAPRoleGroupMapping::_getInstance();
     $mapping->deleteUser($this->getId());
     // remove mailbox / update sent mails
     include_once "Services/Mail/classes/class.ilMailbox.php";
     $mailbox = new ilMailbox($this->getId());
     $mailbox->delete();
     $mailbox->updateMailsOfDeletedUser($this->getLogin());
     // delete feed blocks on personal desktop
     include_once "./Services/Block/classes/class.ilCustomBlock.php";
     $costum_block = new ilCustomBlock();
     $costum_block->setContextObjId($this->getId());
     $costum_block->setContextObjType("user");
     $c_blocks = $costum_block->queryBlocksForContext();
     include_once "./Services/Feeds/classes/class.ilPDExternalFeedBlock.php";
     foreach ($c_blocks as $c_block) {
         if ($c_block["type"] == "pdfeed") {
             $fb = new ilPDExternalFeedBlock($c_block["id"]);
             $fb->delete();
         }
     }
     // delete block settings
     include_once "./Services/Block/classes/class.ilBlockSetting.php";
     ilBlockSetting::_deleteSettingsOfUser($this->getId());
     // delete user_account
     $ilDB->manipulateF("DELETE FROM usr_data WHERE usr_id = %s", array("integer"), array($this->getId()));
     // delete user_prefs
     ilObjUser::_deleteAllPref($this->getId());
     // delete user_session
     include_once "./Services/Authentication/classes/class.ilSession.php";
     ilSession::_destroyByUserId($this->getId());
     // remove user from rbac
     $rbacadmin->removeUser($this->getId());
     // remove bookmarks
     // TODO: move this to class.ilBookmarkFolder
     $q = "DELETE FROM bookmark_tree WHERE tree = " . $ilDB->quote($this->getId(), "integer");
     $ilDB->manipulate($q);
     $q = "DELETE FROM bookmark_data WHERE user_id = " . $ilDB->quote($this->getId(), "integer");
     $ilDB->manipulate($q);
     // DELETE FORUM ENTRIES (not complete in the moment)
     include_once './Modules/Forum/classes/class.ilObjForum.php';
     ilObjForum::_deleteUser($this->getId());
     // Delete link check notify entries
     include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
     ilLinkCheckNotify::_deleteUser($this->getId());
     // Delete crs entries
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     ilObjCourse::_deleteUser($this->getId());
     // Delete user tracking
     include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
     ilObjUserTracking::_deleteUser($this->getId());
     include_once 'Modules/Session/classes/class.ilEventParticipants.php';
     ilEventParticipants::_deleteByUser($this->getId());
     // Delete Tracking data SCORM 2004 RTE
     include_once 'Modules/Scorm2004/classes/ilSCORM13Package.php';
     ilSCORM13Package::_removeTrackingDataForUser($this->getId());
     // Delete Tracking data SCORM 1.2 RTE
     include_once 'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
     ilObjSCORMLearningModule::_removeTrackingDataForUser($this->getId());
     // remove all notifications
     include_once "./Services/Notification/classes/class.ilNotification.php";
     ilNotification::removeForUser($this->getId());
     // remove portfolios
     include_once "./Modules/Portfolio/classes/class.ilObjPortfolio.php";
     ilObjPortfolio::deleteUserPortfolios($this->getId());
     // remove workspace
     include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     $tree = new ilWorkspaceTree($this->getId());
     $tree->cascadingDelete();
     // remove disk quota entries
     include_once "./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
     ilDiskQuotaHandler::deleteByOwner($this->getId());
     // Delete user defined field entries
     $this->deleteUserDefinedFieldEntries();
     // Delete clipboard entries
     $this->clipboardDeleteAll();
     // Reset owner
     $this->resetOwner();
     // Trigger deleteUser Event
     global $ilAppEventHandler;
     $ilAppEventHandler->raise('Services/User', 'deleteUser', array('usr_id' => $this->getId()));
     // delete object data
     parent::delete();
     return true;
 }
 /**
  * Determine which blocks to show.
  */
 function determineBlocks()
 {
     global $ilUser, $ilCtrl, $ilSetting;
     include_once "./Services/Block/classes/class.ilBlockSetting.php";
     $this->blocks[IL_COL_LEFT] = array();
     $this->blocks[IL_COL_RIGHT] = array();
     $this->blocks[IL_COL_CENTER] = array();
     $user_id = $this->getColType() == "pd" ? $ilUser->getId() : 0;
     $def_nr = 1000;
     if (is_array($this->default_blocks[$this->getColType()])) {
         foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) {
             $type = self::$block_types[$class];
             if ($this->isGloballyActivated($type)) {
                 $nr = ilBlockSetting::_lookupNr($type, $user_id);
                 if ($nr === false) {
                     $nr = $def_nr++;
                 }
                 // extra handling for system messages, feedback block and news
                 if ($type == "news") {
                     $nr = -15;
                 }
                 if ($type == "cal") {
                     $nr = -8;
                 }
                 if ($type == "pdsysmess") {
                     //						$nr = -15;
                 }
                 if ($type == "pdfeedb") {
                     $nr = -10;
                 }
                 $side = ilBlockSetting::_lookupSide($type, $user_id);
                 if ($side === false) {
                     $side = $def_side;
                 }
                 $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => 0, "custom" => false);
             }
         }
     }
     if (!$this->getRepositoryMode()) {
         include_once "./Services/Block/classes/class.ilCustomBlock.php";
         $costum_block = new ilCustomBlock();
         $costum_block->setContextObjId($ilCtrl->getContextObjId());
         $costum_block->setContextObjType($ilCtrl->getContextObjType());
         $c_blocks = $costum_block->queryBlocksForContext();
         foreach ($c_blocks as $c_block) {
             $type = $c_block["type"];
             if ($this->isGloballyActivated($type)) {
                 $class = array_search($type, self::$block_types);
                 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
                 if ($nr === false) {
                     $nr = $def_nr++;
                 }
                 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
                 if ($side === false) {
                     $side = IL_COL_RIGHT;
                 }
                 $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true);
             }
         }
     } else {
         include_once "./Services/Block/classes/class.ilCustomBlock.php";
         $rep_items = $this->getRepositoryItems();
         foreach ($this->rep_block_types as $block_type) {
             if ($this->isGloballyActivated($block_type)) {
                 if (!is_array($rep_items[$block_type])) {
                     continue;
                 }
                 foreach ($rep_items[$block_type] as $item) {
                     $costum_block = new ilCustomBlock();
                     $costum_block->setContextObjId($item["obj_id"]);
                     $costum_block->setContextObjType($block_type);
                     $c_blocks = $costum_block->queryBlocksForContext();
                     $c_block = $c_blocks[0];
                     $type = $block_type;
                     $class = array_search($type, self::$block_types);
                     $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
                     if ($nr === false) {
                         $nr = $def_nr++;
                     }
                     $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
                     if ($side === false) {
                         $side = IL_COL_RIGHT;
                     }
                     $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true, "ref_id" => $item["ref_id"]);
                 }
             }
         }
     }
     $this->blocks[IL_COL_LEFT] = ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
     $this->blocks[IL_COL_RIGHT] = ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
     $this->blocks[IL_COL_CENTER] = ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
 }
 function getFeedBlock()
 {
     global $ilLog;
     // delete feed block
     include_once "./Services/Block/classes/class.ilCustomBlock.php";
     $costum_block = new ilCustomBlock();
     $costum_block->setContextObjId($this->getId());
     $costum_block->setContextObjType($this->getType());
     $c_blocks = $costum_block->queryBlocksForContext();
     include_once "./Services/Block/classes/class.ilExternalFeedBlock.php";
     foreach ($c_blocks as $c_block) {
         if ($c_block["type"] == "feed") {
             $fb = new ilExternalFeedBlock($c_block["id"]);
             return $fb;
         }
     }
     return false;
 }