function unregister($a_usr_id)
 {
     return ilEventParticipants::_unregister($a_usr_id, $this->getEventId());
 }
 /**
  * Determine status
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		status
  */
 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
 {
     global $ilObjDataCache, $ilDB;
     $status = LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case 'sess':
             include_once './Modules/Session/classes/class.ilEventParticipants.php';
             include_once './Modules/Session/classes/class.ilSessionAppointment.php';
             include_once './Modules/Session/classes/class.ilObjSession.php';
             $time_info = ilSessionAppointment::_lookupAppointment($a_obj_id);
             $registration = ilObjSession::_lookupRegistrationEnabled($a_obj_id);
             // If registration is disabled in_progress is not available
             // If event has occured in_progress is impossible
             if ($registration && $time_info['start'] >= time()) {
                 // is user registered -> in progress
                 if (ilEventParticipants::_isRegistered($a_user_id, $a_obj_id)) {
                     $status = LP_STATUS_IN_PROGRESS_NUM;
                 }
             }
             if (ilEventParticipants::_hasParticipated($a_user_id, $a_obj_id)) {
                 $status = LP_STATUS_COMPLETED_NUM;
             }
             break;
     }
     return $status;
 }
 /**
  * Events List CSV Export
  *
  * @access public
  * @param
  * 
  */
 public function exportCSV()
 {
     global $tree, $ilAccess;
     include_once 'Services/Utilities/classes/class.ilCSVWriter.php';
     include_once 'Modules/Session/classes/class.ilEventParticipants.php';
     $members = $this->members_obj->getParticipants();
     $members = ilUtil::_sortIds($members, 'usr_data', 'lastname', 'usr_id');
     $events = array();
     foreach ($tree->getSubtree($tree->getNodeData($this->course_ref_id), false, 'sess') as $event_id) {
         $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
         if (!is_object($tmp_event) or !$ilAccess->checkAccess('write', '', $event_id)) {
             continue;
         }
         $events[] = $tmp_event;
     }
     $this->csv = new ilCSVWriter();
     $this->csv->addColumn($this->lng->txt("lastname"));
     $this->csv->addColumn($this->lng->txt("firstname"));
     $this->csv->addColumn($this->lng->txt("login"));
     foreach ($events as $event_obj) {
         // TODO: do not export relative dates
         $this->csv->addColumn($event_obj->getTitle() . ' (' . $event_obj->getFirstAppointment()->appointmentToString() . ')');
     }
     $this->csv->addRow();
     foreach ($members as $user_id) {
         $name = ilObjUser::_lookupName($user_id);
         $this->csv->addColumn($name['lastname']);
         $this->csv->addColumn($name['firstname']);
         $this->csv->addColumn(ilObjUser::_lookupLogin($user_id));
         foreach ($events as $event_obj) {
             $event_part = new ilEventParticipants((int) $event_obj->getId());
             $this->csv->addColumn($event_part->hasParticipated($user_id) ? $this->lng->txt('event_participated') : $this->lng->txt('event_not_participated'));
         }
         $this->csv->addRow();
     }
     $date = new ilDate(time(), IL_CAL_UNIX);
     ilUtil::deliverData($this->csv->getCSVString(), $date->get(IL_CAL_FKT_DATE, 'Y-m-d') . "_course_events.csv", "text/csv");
 }
 /**
  * list sessions of all user
  *
  * @access public
  * @param
  * @return
  */
 public function eventsListObject()
 {
     global $ilErr, $ilAccess, $ilUser, $tree;
     if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
     }
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_list.html', 'Modules/Session');
     $this->__showButton($this->ctrl->getLinkTarget($this, 'exportCSV'), $this->lng->txt('event_csv_export'));
     include_once 'Modules/Session/classes/class.ilEventParticipants.php';
     $this->tpl->addBlockfile("EVENTS_TABLE", "events_table", "tpl.table.html");
     $this->tpl->addBlockfile('TBL_CONTENT', 'tbl_content', 'tpl.sess_list_row.html', 'Modules/Session');
     $members_obj = $this->initContainer(true);
     $members = $members_obj->getParticipants();
     $members = ilUtil::_sortIds($members, 'usr_data', 'lastname', 'usr_id');
     // Table
     $tbl = new ilTableGUI();
     $tbl->setTitle($this->lng->txt("event_overview"), 'icon_usr.png', $this->lng->txt('obj_usr'));
     $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
     $course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
     $events = array();
     foreach ($tree->getSubtree($tree->getNodeData($course_ref_id), false, 'sess') as $event_id) {
         $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
         if (!is_object($tmp_event) or $tmp_event->getType() != 'sess') {
             continue;
         }
         $events[] = $tmp_event;
     }
     $headerNames = array();
     $headerVars = array();
     $colWidth = array();
     $headerNames[] = $this->lng->txt('name');
     $headerVars[] = "name";
     $colWidth[] = '20%';
     for ($i = 1; $i <= count($events); $i++) {
         $headerNames[] = $i;
         $headerVars[] = "event_" . $i;
         $colWidth[] = 80 / count($events) . "%";
     }
     $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
     $tbl->setHeaderNames($headerNames);
     $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this, 'eventsList'));
     $tbl->setColumnWidth($colWidth);
     $tbl->setOrderColumn($_GET["sort_by"]);
     $tbl->setOrderDirection($_GET["sort_order"]);
     $tbl->setOffset($_GET["offset"]);
     $tbl->setLimit($ilUser->getPref("hits_per_page"));
     $tbl->setMaxCount(count($members));
     $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
     $sliced_users = array_slice($members, $_GET['offset'], $_SESSION['tbl_limit']);
     $tbl->disable('sort');
     $tbl->render();
     $counter = 0;
     foreach ($sliced_users as $user_id) {
         foreach ($events as $event_obj) {
             $this->tpl->setCurrentBlock("eventcols");
             $event_part = new ilEventParticipants($this->object->getId());
             $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ? ilUtil::getImagePath('icon_ok.png') : ilUtil::getImagePath('icon_not_ok.png'));
             $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ? $this->lng->txt('event_participated') : $this->lng->txt('event_not_participated'));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock("tbl_content");
         $name = ilObjUser::_lookupName($user_id);
         $this->tpl->setVariable("CSS_ROW", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
         $this->tpl->setVariable("LASTNAME", $name['lastname']);
         $this->tpl->setVariable("FIRSTNAME", $name['firstname']);
         $this->tpl->setVariable("LOGIN", ilObjUser::_lookupLogin($user_id));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
     $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
     $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
     $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
     $this->tpl->setVariable("HEAD_TXT_DATE_TIME", $this->lng->txt("event_date_time"));
     $i = 1;
     foreach ($events as $event_obj) {
         $this->tpl->setCurrentBlock("legend_loop");
         $this->tpl->setVariable("LEGEND_CSS_ROW", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
         $this->tpl->setVariable("LEGEND_DIGIT", $i++);
         $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
         $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
         $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
         $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
         $this->tpl->parseCurrentBlock();
     }
 }
示例#5
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;
 }
 /**
  * delete session and all related data
  *
  * @access public
  * @return bool
  */
 public function delete()
 {
     global $ilDB;
     global $ilAppEventHandler;
     if (!parent::delete()) {
         return false;
     }
     $query = "DELETE FROM event " . "WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
     $res = $ilDB->manipulate($query);
     include_once './Modules/Session/classes/class.ilSessionAppointment.php';
     ilSessionAppointment::_deleteBySession($this->getId());
     include_once './Modules/Session/classes/class.ilEventItems.php';
     ilEventItems::_delete($this->getId());
     include_once './Modules/Session/classes/class.ilEventParticipants.php';
     ilEventParticipants::_deleteByEvent($this->getId());
     foreach ($this->getFiles() as $file) {
         $file->delete();
     }
     $ilAppEventHandler->raise('Modules/Session', 'delete', array('object' => $this, 'obj_id' => $this->getId(), 'appointments' => $this->prepareCalendarAppointments('delete')));
     return true;
 }
 /**
  * return list of users following dtd users_3_7
  */
 function getUsersForContainer($sid, $ref_id, $attachRoles, $active)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $ilDB, $tree, $rbacreview, $rbacsystem;
     if ($ref_id == -1) {
         $ref_id = USER_FOLDER_ID;
     }
     $object = $this->checkObjectAccess($ref_id, array("crs", "cat", "grp", "usrf", "sess"), "read", true);
     if ($this->isFault($object)) {
         return $object;
     }
     $data = array();
     switch ($object->getType()) {
         case "usrf":
             $data = ilObjUser::_getUsersForFolder(USER_FOLDER_ID, $active);
             break;
         case "cat":
             $data = ilObjUser::_getUsersForFolder($ref_id, $active);
             break;
         case "crs":
             // GET ALL MEMBERS
             $roles = $object->__getLocalRoles();
             foreach ($roles as $role_id) {
                 $data = array_merge($rbacreview->assignedUsers($role_id, array()), $data);
             }
             break;
         case "grp":
             $member_ids = $object->getGroupMemberIds();
             $data = ilObjUser::_getUsersForGroup($member_ids, $active);
             break;
         case "sess":
             $course_ref_id = $tree->checkForParentType($ref_id, 'crs');
             if (!$course_ref_id) {
                 return $this->__raiseError("No course for session", "Client");
             }
             $event_obj_id = ilObject::_lookupObjId($ref_id);
             include_once 'Modules/Session/classes/class.ilEventParticipants.php';
             $event_part = new ilEventParticipants($event_obj_id);
             $member_ids = array_keys($event_part->getParticipants());
             $data = ilObjUser::_getUsersForIds($member_ids, $active);
             break;
     }
     if (is_array($data)) {
         include_once './Services/User/classes/class.ilUserXMLWriter.php';
         $xmlWriter = new ilUserXMLWriter();
         $xmlWriter->setObjects($data);
         $xmlWriter->setAttachRoles($attachRoles);
         if ($xmlWriter->start()) {
             return $xmlWriter->getXML();
         }
     }
     return $this->__raiseError('Error in processing information. This is likely a bug.', 'Server');
 }
 /**
  * add from waiting list 
  *
  * @access public
  * @param
  * @return
  */
 public function assignFromWaitingListObject()
 {
     $this->checkPermission('write');
     if (!count($_POST["waiting"])) {
         ilUtil::sendFailure($this->lng->txt("no_checkbox"));
         $this->membersObject();
         return false;
     }
     include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
     $waiting_list = new ilSessionWaitingList($this->object->getId());
     include_once './Modules/Session/classes/class.ilEventParticipants.php';
     $part = new ilEventParticipants($this->object->getId());
     $added_users = 0;
     foreach ($_POST["waiting"] as $user_id) {
         $part->register($user_id);
         $waiting_list->removeFromList($user_id);
         include_once './Modules/Session/classes/class.ilSessionMembershipMailNotification.php';
         $noti = new ilSessionMembershipMailNotification();
         $noti->setRefId($this->object->getRefId());
         $noti->setRecipients(array($user_id));
         $noti->setType(ilSessionMembershipMailNotification::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER);
         $noti->send();
         ++$added_users;
     }
     if ($added_users) {
         ilUtil::sendSuccess($this->lng->txt("sess_users_added"));
         $this->membersObject();
         return true;
     } else {
         ilUtil::sendFailure($this->lng->txt("sess_users_already_assigned"));
         $this->searchObject();
         return false;
     }
 }
 /**
  * Static function to check if a user is a participant of the container object
  *
  * @access public
  * @param int ref_id
  * @param int user id
  * @static
  */
 public static function _isParticipant($a_ref_id, $a_usr_id)
 {
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     return ilEventParticipants::_isRegistered($a_usr_id, $obj_id);
 }