Esempio n. 1
0
 /**
  * change event test 
  * @param
  * @return
  */
 public function testChangeEvent()
 {
     global $ilUser;
     include_once './Services/Tracking/classes/class.ilChangeEvent.php';
     $ret = ilChangeEvent::_deactivate();
     $ret = ilChangeEvent::_activate();
     $res = ilChangeEvent::_lookupUncaughtWriteEvents(9, $ilUser->getId());
     $res = ilChangeEvent::_lookupChangeState(9, $ilUser->getId());
     $res = ilChangeEvent::_lookupInsideChangeState(9, $ilUser->getId());
 }
 /**
  * Track read access to the object
  * Prevents a call of determineStatus() that would return "not attempted"
  * @see ilLearningProgress::_tracProgress()
  *
  * @param $a_user_id
  * @param $a_obj_id
  * @param $a_ref_id
  * @param string $a_obj_type
  */
 public static function trackAccess($a_user_id, $a_obj_id, $a_ref_id)
 {
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordReadEvent('xxco', $a_ref_id, $a_obj_id, $a_user_id);
     $status = self::getLPDataForUser($a_obj_id, $a_user_id);
     if ($status == self::LP_STATUS_NOT_ATTEMPTED_NUM) {
         self::writeStatus($a_obj_id, $a_user_id, self::LP_STATUS_IN_PROGRESS_NUM);
         self::raiseEventStatic($a_obj_id, $a_user_id, self::LP_STATUS_IN_PROGRESS_NUM, self::getPercentageForUser($a_obj_id, $a_user_id));
     }
 }
 /**
  * Sets view output into column layout
  *
  * This method sets the output of the right and main column
  * in the global standard template.
  */
 public function setOutput()
 {
     global $tpl;
     // BEGIN ChangeEvent: record read event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
     ilChangeEvent::_recordReadEvent($this->getContainerObject()->getType(), $this->getContainerObject()->getRefId(), $obj_id, $ilUser->getId());
     // END ChangeEvent: record read event.
     $tpl->setContent($this->getCenterColumnHTML());
     $tpl->setRightContent($this->getRightColumnHTML());
 }
 /**
  * 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)
 {
     $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     include_once "Services/Tracking/classes/class.ilChangeEvent.php";
     if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
         $status = self::LP_STATUS_IN_PROGRESS_NUM;
         include_once "Modules/LearningModule/classes/class.ilLMTracker.php";
         $tracker = ilLMTracker::getInstanceByObjId($a_obj_id, $a_user_id);
         if ($tracker->getAllQuestionsCorrect()) {
             $status = self::LP_STATUS_COMPLETED_NUM;
         }
     }
     return $status;
 }
 /**
  * call remote object
  *
  * @return bool
  */
 public function callObject()
 {
     include_once './Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordReadEvent($this->getType(), $this->object->getRefId(), $this->object->getId(), $GLOBALS['ilUser']->getId());
     // check if the assigned object is hosted on the same installation
     $link = $this->object->getFullRemoteLink();
     if ($link) {
         ilUtil::redirect($link);
         return true;
     } else {
         ilUtil::sendFailure('Cannot call remote object.');
         $this->infoScreenObject();
         return false;
     }
 }
 /**
  * lookup progress for a specific object
  *
  * @access public
  * @param int obj_id
  * @return array of progress data 
  */
 public static function _lookupProgressByObjId($a_obj_id)
 {
     include_once './Services/Tracking/classes/class.ilChangeEvent.php';
     foreach (ilChangeEvent::_lookupReadEvents($a_obj_id) as $row) {
         if (isset($progress[$row['usr_id']])) {
             $progress[$row['usr_id']]['spent_seconds'] += $row['spent_seconds'];
             $progress[$row['usr_id']]['read_count'] += $row['read_count'];
             $progress[$row['usr_id']]['ts'] = max($row['last_access'], $progress[$row['usr_id']]['ts']);
         } else {
             $progress[$row['usr_id']]['spent_seconds'] = $row['spent_seconds'];
             $progress[$row['usr_id']]['read_count'] = $row['read_count'];
             $progress[$row['usr_id']]['ts'] = $row['last_access'];
         }
         $progress[$row['usr_id']]['usr_id'] = $row['usr_id'];
         $progress[$row['usr_id']]['obj_id'] = $row['obj_id'];
     }
     return $progress ? $progress : array();
 }
 /**
  * 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 = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case 'dbk':
         case 'lm':
         case 'htlm':
             include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
             if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
                 $status = self::LP_STATUS_IN_PROGRESS_NUM;
                 // completed?
                 $set = $ilDB->query($q = "SELECT usr_id FROM ut_lp_marks " . "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " . "AND usr_id = " . $ilDB->quote($a_user_id, 'integer') . " " . "AND completed = '1' ");
                 if ($rec = $ilDB->fetchAssoc($set)) {
                     $status = self::LP_STATUS_COMPLETED_NUM;
                 }
             }
             break;
     }
     return $status;
 }
 /**
  * Sets view output into column layout
  *
  * This method sets the output of the right and main column
  * in the global standard template.
  */
 public function setOutput()
 {
     global $tpl, $ilCtrl;
     // note: we do not want to get the center html in case of
     // asynchronous calls to blocks in the right column (e.g. news)
     // see #13012
     if ($ilCtrl->getNextClass() == "ilcolumngui" && $ilCtrl->isAsynch()) {
         $tpl->setRightContent($this->getRightColumnHTML());
     }
     // BEGIN ChangeEvent: record read event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     //global $log;
     //$log->write("setOutput");
     $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
     ilChangeEvent::_recordReadEvent($this->getContainerObject()->getType(), $this->getContainerObject()->getRefId(), $obj_id, $ilUser->getId());
     // END ChangeEvent: record read event.
     $tpl->setContent($this->getCenterColumnHTML());
     // see above, all other cases (this was the old position of setRightContent,
     // maybe the position above is ok and all ifs can be removed)
     if ($ilCtrl->getNextClass() != "ilcolumngui" || !$ilCtrl->isAsynch()) {
         $tpl->setRightContent($this->getRightColumnHTML());
     }
 }
 public function addToExternalSettingsForm($a_form_id)
 {
     switch ($a_form_id) {
         case ilAdministrationSettingsFormHandler::FORM_LP:
             require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
             $fields = array('trac_repository_changes' => array(ilChangeEvent::_isActive(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
             return array(array("view", $fields));
     }
 }
Esempio n. 10
0
 protected function increaseViewCount()
 {
     global $ilUser;
     $this->getWikiPage()->increaseViewCnt();
     // enable object statistics
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordReadEvent("wiki", $this->getWikiPage()->getWikiRefId(), $this->getWikiPage()->getWikiId(), $ilUser->getId());
 }
    /**
     * Synch read event table
     *
     * @param
     * @return
     */
    function _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
    {
        global $ilDB, $ilLog;
        // get attempts
        $val_set = $ilDB->queryF('
		SELECT rvalue FROM cmi_custom 
		WHERE user_id = %s
				AND sco_id = %s
				AND lvalue = %s
				AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($a_user_id, 0, 'package_attempts', $a_obj_id));
        $val_rec = $ilDB->fetchAssoc($val_set);
        $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
        if ($val_rec["rvalue"] == null) {
            $val_rec["rvalue"] = "";
        }
        $attempts = $val_rec["rvalue"];
        // time
        $scos = array();
        $val_set = $ilDB->queryF('SELECT cp_node_id FROM cp_node 
			WHERE nodename = %s
			AND cp_node.slm_id = %s', array('text', 'integer'), array('item', $a_obj_id));
        while ($val_rec = $ilDB->fetchAssoc($val_set)) {
            array_push($scos, $val_rec['cp_node_id']);
        }
        $time = 0;
        foreach ($scos as $sco) {
            include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
            $data_set = $ilDB->queryF('
				SELECT total_time
				FROM cmi_node 
				WHERE cp_node_id = %s
				AND user_id = %s', array('integer', 'integer'), array($sco, $a_user_id));
            while ($data_rec = $ilDB->fetchAssoc($data_set)) {
                // see bug report 7246
                //				$sec = ilObjSCORM2004LearningModule::_ISODurationToCentisec($data_rec["session_time"]) / 100;
                $sec = ilObjSCORM2004LearningModule::_ISODurationToCentisec($data_rec["total_time"]) / 100;
            }
            $time += (int) $sec;
            $sec = 0;
            //$ilLog->write("++".$time);
        }
        include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
        ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
    }
 protected function redirectToLink($a_ref_id, $a_obj_id, $a_url)
 {
     global $ilUser;
     if ($a_url) {
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordReadEvent("webr", $a_ref_id, $a_obj_id, $ilUser->getId());
         ilUtil::redirect($a_url);
     }
 }
Esempio n. 13
0
 /**
  * add standard object section
  */
 function addObjectSections()
 {
     global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $ilSetting, $ilObjDataCache;
     $this->addSection($lng->txt("additional_info"));
     $a_obj = $this->gui_object->object;
     // links to the object
     if (is_object($a_obj)) {
         // permanent link
         $type = $a_obj->getType();
         $ref_id = $a_obj->getRefId();
         if ($ref_id) {
             include_once './Services/Link/classes/class.ilLink.php';
             $href = ilLink::_getStaticLink($ref_id, $type, true);
             include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
             if (ilECSServerSettings::getInstance()->activeServerExists()) {
                 $this->addProperty($lng->txt("object_id"), $a_obj->getId());
             }
             include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
             $pm = new ilPermanentLinkGUI($type, $ref_id);
             $pm->setIncludePermanentLinkText(false);
             $pm->setAlignCenter(false);
             $this->addProperty($lng->txt("perma_link"), $pm->getHTML(), "");
             // bookmarks
             $title = $ilObjDataCache->lookupTitle($a_obj->getId());
             $bms = ilPermanentLinkGUI::_getBookmarksSelectionList($title, $href);
             // links to resource
             if ($ilAccess->checkAccess("write", "", $ref_id) || $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
                 $obj_id = $a_obj->getId();
                 $rs = ilObject::_getAllReferences($obj_id);
                 $refs = array();
                 foreach ($rs as $r) {
                     if ($tree->isInTree($r)) {
                         $refs[] = $r;
                     }
                 }
                 if (count($refs) > 1) {
                     $links = $sep = "";
                     foreach ($refs as $r) {
                         $cont_loc = new ilLocatorGUI();
                         $cont_loc->addContextItems($r, true);
                         $links .= $sep . $cont_loc->getHTML();
                         $sep = "<br />";
                     }
                     $this->addProperty($lng->txt("res_links"), '<div class="small">' . $links . '</div>');
                 }
             }
         }
     }
     // creation date
     $this->addProperty($lng->txt("create_date"), ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME)));
     // owner
     if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         include_once './Services/User/classes/class.ilObjUser.php';
         if (ilObjUser::userExists(array($a_obj->getOwner()))) {
             $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
         } else {
             $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
         }
         if (!is_object($ownerObj) || $ownerObj->getType() != "usr") {
             $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
         } else {
             if ($ownerObj->hasPublicProfile()) {
                 $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
                 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName(), $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
             } else {
                 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
             }
         }
     }
     // disk usage
     require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
     if ($ilUser->getId() != ANONYMOUS_USER_ID && ilDiskQuotaActivationChecker::_isActive()) {
         $size = $a_obj->getDiskUsage();
         if ($size !== null) {
             $this->addProperty($lng->txt("disk_usage"), ilFormat::formatSize($size, 'long'));
         }
     }
     // change event
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     if (ilChangeEvent::_isActive()) {
         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
             $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
             $count_users = 0;
             $count_members = 0;
             $count_user_reads = 0;
             $count_anonymous_reads = 0;
             foreach ($readEvents as $evt) {
                 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
                     $count_anonymous_reads += $evt['read_count'];
                 } else {
                     $count_user_reads += $evt['read_count'];
                     $count_users++;
                     /* to do: if ($evt['user_id'] is member of $this->getRefId())
                     			{
                     				$count_members++;
                     			}*/
                 }
             }
             if ($count_anonymous_reads > 0) {
                 $this->addProperty($this->lng->txt("readcount_anonymous_users"), $count_anonymous_reads);
             }
             if ($count_user_reads > 0) {
                 $this->addProperty($this->lng->txt("readcount_users"), $count_user_reads);
             }
             if ($count_users > 0) {
                 $this->addProperty($this->lng->txt("accesscount_registered_users"), $count_users);
             }
         }
     }
     // END ChangeEvent: Display change event info
     // BEGIN WebDAV: Display locking information
     require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
     if (ilDAVServer::_isActive()) {
         global $ilias, $ilUser;
         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
             $davLocks = new ilDAVLocks();
             // Show lock info
             if ($ilias->account->getId() != ANONYMOUS_USER_ID) {
                 $locks =& $davLocks->getLocksOnObjectObj($a_obj->getId());
                 if (count($locks) > 0) {
                     $lockUser = new ilObjUser($locks[0]['ilias_owner']);
                     $this->addProperty($this->lng->txt("in_use_by"), $lockUser->getPublicName(), "./ilias.php?user=" . $locks[0]['ilias_owner'] . '&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI');
                 }
             }
         }
     }
     // END WebDAV: Display locking information
 }
 function adminSync()
 {
     global $ilCtrl, $lng;
     include_once "Services/Tracking/classes/class.ilChangeEvent.php";
     ilChangeEvent::_syncObjectStats(time(), 1);
     ilUtil::sendSuccess($lng->txt("trac_sync_obj_stats_success"), true);
     $ilCtrl->redirect($this, "admin");
 }
 /**
  * Output course content
  */
 function view()
 {
     // BEGIN ChangeEvent: record read event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     $obj_id = ilObject::_lookupObjId($this->container_obj->getRefId());
     ilChangeEvent::_recordReadEvent($this->container_obj->getType(), $this->container_obj->getRefId(), $obj_id, $ilUser->getId());
     // END ChangeEvent: record read event.
     $this->getCenterColumnHTML();
     if (!$this->no_right_column) {
         $this->tpl->setRightContent($this->getRightColumnHTML());
     }
 }
    function deleteTrackingDataOfUsers($a_users)
    {
        global $ilDB;
        include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
        include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
        ilChangeEvent::_deleteReadEventsForUsers($this->getId(), $a_users);
        foreach ($a_users as $user) {
            $ilDB->manipulateF('
				DELETE FROM scorm_tracking
				WHERE user_id = %s
				AND obj_id = %s', array('integer', 'integer'), array($user, $this->getID()));
            $ilDB->manipulateF('
				DELETE FROM sahs_user
				WHERE user_id = %s
				AND obj_id = %s', array('integer', 'integer'), array($user, $this->getID()));
            ilLPStatusWrapper::_updateStatus($this->getId(), $user);
        }
    }
    /**
     * Synch read event table
     *
     * @param
     * @return
     */
    function _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
    {
        global $ilDB, $ilLog;
        // get attempts
        $val_set = $ilDB->queryF('
		SELECT rvalue FROM scorm_tracking 
		WHERE user_id = %s
		AND sco_id = %s
		AND lvalue = %s
		AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($a_user_id, 0, 'package_attempts', $a_obj_id));
        $val_rec = $ilDB->fetchAssoc($val_set);
        $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
        if ($val_rec["rvalue"] == null) {
            $val_rec["rvalue"] = "";
        }
        $attempts = $val_rec["rvalue"];
        // get learning time
        $sco_set = $ilDB->queryF('
		SELECT sco_id, rvalue FROM scorm_tracking 
		WHERE obj_id = %s
		AND user_id = %s
		AND lvalue = %s
		AND sco_id <> %s', array('integer', 'integer', 'text', 'integer'), array($a_obj_id, $a_user_id, 'cmi.core.total_time', 0));
        $time = 0;
        while ($sco_rec = $ilDB->fetchAssoc($sco_set)) {
            $tarr = explode(":", $sco_rec["rvalue"]);
            $sec = (int) $tarr[2] + (int) $tarr[1] * 60 + (int) substr($tarr[0], strlen($tarr[0]) - 3) * 60 * 60;
            $time += $sec;
        }
        include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
        ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
    }
 /**
  * info screen
  *
  * @access protected
  * @param
  * @return
  */
 public function infoScreen()
 {
     global $ilAccess, $ilUser, $ilCtrl, $tree, $ilToolbar;
     $this->checkPermission('visible');
     $this->tabs_gui->setTabActive('info_short');
     $appointment_obj = $this->object->getFirstAppointment();
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     if ($this->object->enabledRegistration()) {
         include_once './Modules/Session/classes/class.ilEventParticipants.php';
         if (ilEventParticipants::_isRegistered($ilUser->getId(), $this->object->getId())) {
             $ilToolbar->addFormButton($this->lng->txt('event_unregister'), 'join');
         } else {
             if (!isset($_SESSION['sess_hide_info'])) {
                 ilUtil::sendInfo($this->lng->txt('sess_join_info'));
             }
             $ilToolbar->addFormButton($this->lng->txt('join_session'), 'join', '', true);
         }
         $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
     }
     // Session information
     if (strlen($this->object->getLocation()) or strlen($this->object->getDetails())) {
         $info->addSection($this->lng->txt('event_section_information'));
     }
     if (strlen($location = $this->object->getLocation())) {
         $info->addProperty($this->lng->txt('event_location'), nl2br($this->object->getLocation()));
     }
     if (strlen($this->object->getDetails())) {
         $info->addProperty($this->lng->txt('event_details_workflow'), nl2br($this->object->getDetails()));
     }
     // Tutor information
     if ($this->object->hasTutorSettings()) {
         $info->addSection($this->lng->txt('event_tutor_data'));
         if (strlen($fullname = $this->object->getName())) {
             $info->addProperty($this->lng->txt('event_lecturer'), $fullname);
         }
         if (strlen($email = $this->object->getEmail())) {
             $info->addProperty($this->lng->txt('tutor_email'), $email);
         }
         if (strlen($phone = $this->object->getPhone())) {
             $info->addProperty($this->lng->txt('tutor_phone'), $phone);
         }
     }
     $html = '';
     include_once './Services/Object/classes/class.ilObjectActivation.php';
     include_once './Services/Container/classes/class.ilContainerSorting.php';
     include_once './Modules/Session/classes/class.ilSessionObjectListGUIFactory.php';
     $eventItems = ilObjectActivation::getItemsByEvent($this->object->getId());
     $parent_id = $tree->getParentId($this->object->getRefId());
     $parent_id = ilObject::_lookupObjId($parent_id);
     $eventItems = ilContainerSorting::_getInstance($parent_id)->sortSubItems('sess', $this->object->getId(), $eventItems);
     foreach ($eventItems as $item) {
         $list_gui = ilSessionObjectListGUIFactory::factory($item['type']);
         $list_gui->setContainerObject($this);
         $this->modifyItemGUI($list_gui, $item, false);
         $html .= $list_gui->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description']);
     }
     if (strlen($html)) {
         $info->addSection($this->lng->txt('event_materials'));
         $info->addProperty('&nbsp;', $html);
     }
     // forward the command
     $this->ctrl->forwardCommand($info);
     // store read event
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(), $this->object->getId(), $ilUser->getId());
 }
Esempio n. 19
0
 /**
  * COPY method handler
  *
  * @param  array  general parameter passing array
  * @return bool   true on success
  */
 public function COPY($options, $del = false)
 {
     global $ilUser;
     $this->writelog('COPY(' . var_export($options, true) . ' ,del=' . $del . ')');
     $this->writelog('COPY ' . $options['path'] . ' ' . $options['dest']);
     // no copying to different WebDAV Servers
     if (isset($options["dest_url"])) {
         return "502 bad gateway";
     }
     $src = $this->davDeslashify($options['path']);
     $srcParent = dirname($src);
     $srcName = $this->davBasename($src);
     $dst = $this->davDeslashify($options['dest']);
     $dstParent = dirname($dst);
     $dstName = $this->davBasename($dst);
     // sanity check
     if ($src == $dst) {
         return '409 Conflict';
         // src and dst are the same
     }
     if (substr($dst, strlen($src) + 1) == $src . '/') {
         return '409 Conflict';
         // dst is in subtree of src
     }
     $this->writelog('COPY src=' . $src . ' dst=' . $dst);
     // get dav object for path
     $srcDAV =& $this->getObject($src);
     $dstDAV =& $this->getObject($dst);
     $dstParentDAV =& $this->getObject($dstParent);
     if (is_null($srcDAV) || $srcDAV->isNullResource()) {
         return '409 Conflict';
         // src does not exist
     }
     if (is_null($dstParentDAV) || $dstParentDAV->isNullResource()) {
         return '409 Conflict';
         // parent of dst does not exist
     }
     $isOverwritten = false;
     // XXX Handle nulltype for dstDAV
     if (!is_null($dstDAV)) {
         if ($options['overwrite'] == 'T') {
             if ($dstDAV->isPermitted('delete')) {
                 $dstParentDAV->remove($dstDAV);
                 ilChangeEvent::_recordWriteEvent($dstDAV->getObjectId(), $ilUser->getId(), 'delete', $dstParentDAV->getObjectId());
                 $dstDAV = null;
                 $isOverwritten = true;
             } else {
                 return '403 Forbidden';
             }
         } else {
             return '412 Precondition Failed';
         }
     }
     if (!$dstParentDAV->isPermitted('create', $srcDAV->getILIASType())) {
         return '403 Forbidden';
     }
     $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
     // Record write event
     ilChangeEvent::_recordReadEvent($srcDAV->getILIASType(), $srcDAV->getRefId(), $srcDAV->getObjectId(), $ilUser->getId());
     ilChangeEvent::_recordWriteEvent($dstDAV->getObjectId(), $ilUser->getId(), 'create', $dstParentDAV->getObjectId());
     return $isOverwritten ? '204 No Content' : '201 Created';
 }
 /**
  * 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;
     // the status completed depends on:
     // $status_info['num_objectives'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // - ilCourseObjective::_getObjectiveIds($a_obj_id);
     // - table crs_objectives manipulated in
     // - ilCourseObjective
     // $status_info['objective_result']  (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // table crs_objective_status (must not contain a dataset)
     // ilCourseObjectiveResult -> added ilLPStatusWrapper::_updateStatus()
     $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case "crs":
             include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
             if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
                 $status = self::LP_STATUS_IN_PROGRESS_NUM;
                 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
                 $objectives = ilCourseObjective::_getObjectiveIds($a_obj_id);
                 if ($objectives) {
                     $set = $ilDB->query("SELECT count(objective_id) cnt FROM crs_objective_status " . "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
                     if ($rec = $ilDB->fetchAssoc($set)) {
                         if ($rec["cnt"] == count($objectives)) {
                             $status = self::LP_STATUS_COMPLETED_NUM;
                         }
                     }
                 }
             }
             break;
     }
     return $status;
 }
Esempio n. 21
0
 /**
  * Handles the upload of a single file and adds it to the parent object.
  * 
  * @param array $file_upload An array containing the file upload parameters.
  * @return object The response object.
  */
 protected function handleFileUpload($file_upload)
 {
     global $ilUser;
     // file upload params
     $filename = $file_upload["name"];
     $type = $file_upload["type"];
     $size = $file_upload["size"];
     $temp_name = $file_upload["tmp_name"];
     // additional params
     $title = $file_upload["title"];
     $description = $file_upload["description"];
     $extract = $file_upload["extract"];
     $keep_structure = $file_upload["keep_structure"];
     // create answer object
     $response = new stdClass();
     $response->fileName = $filename;
     $response->fileSize = intval($size);
     $response->fileType = $type;
     $response->fileUnzipped = $extract;
     $response->error = null;
     // extract archive?
     if ($extract) {
         $zip_file = $filename;
         $adopt_structure = $keep_structure;
         include_once "Services/Utilities/classes/class.ilFileUtils.php";
         // Create unzip-directory
         $newDir = ilUtil::ilTempnam();
         ilUtil::makeDir($newDir);
         // Check if permission is granted for creation of object, if necessary
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             $type = ilObject::_lookupType((int) $this->parent_id, true);
         } else {
             $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
         }
         $tree = $access_handler = null;
         switch ($type) {
             // workspace structure
             case 'wfld':
             case 'wsrt':
                 $permission = $this->checkPermissionBool("create", "", "wfld");
                 $containerType = "WorkspaceFolder";
                 $tree = $this->tree;
                 $access_handler = $this->getAccessHandler();
                 break;
                 // use categories as structure
             // use categories as structure
             case 'cat':
             case 'root':
                 $permission = $this->checkPermissionBool("create", "", "cat");
                 $containerType = "Category";
                 break;
                 // use folders as structure (in courses)
             // use folders as structure (in courses)
             default:
                 $permission = $this->checkPermissionBool("create", "", "fold");
                 $containerType = "Folder";
                 break;
         }
         try {
             // 	processZipFile (
             //		Dir to unzip,
             //		Path to uploaded file,
             //		should a structure be created (+ permission check)?
             //		ref_id of parent
             //		object that contains files (folder or category)
             //		should sendInfo be persistent?)
             ilFileUtils::processZipFile($newDir, $temp_name, $adopt_structure && $permission, $this->parent_id, $containerType, $tree, $access_handler);
         } catch (ilFileUtilsException $e) {
             $response->error = $e->getMessage();
         } catch (Exception $ex) {
             $response->error = $ex->getMessage();
         }
         ilUtil::delDir($newDir);
         // #15404
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             foreach (ilFileUtils::getNewObjects() as $parent_ref_id => $objects) {
                 if ($parent_ref_id != $this->parent_id) {
                     continue;
                 }
                 foreach ($objects as $object) {
                     $this->after_creation_callback_objects[] = $object;
                 }
             }
         }
     } else {
         if (trim($title) == "") {
             $title = $filename;
         } else {
             // BEGIN WebDAV: Ensure that object title ends with the filename extension
             $fileExtension = ilObjFileAccess::_getFileExtension($filename);
             $titleExtension = ilObjFileAccess::_getFileExtension($title);
             if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
                 $title .= '.' . $fileExtension;
             }
             // END WebDAV: Ensure that object title ends with the filename extension
         }
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setTitle($title);
         $fileObj->setDescription($description);
         $fileObj->setFileName($filename);
         include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
         $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $filename, $type));
         $fileObj->setFileSize($size);
         $this->object_id = $fileObj->create();
         $this->putObjectInTree($fileObj, $this->parent_id);
         // see uploadFiles()
         if (is_array($this->after_creation_callback_objects)) {
             $this->after_creation_callback_objects[] = $fileObj;
         }
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->raiseUploadError(false);
         $fileObj->getUploadFile($temp_name, $filename);
         $this->handleAutoRating($fileObj);
         // BEGIN ChangeEvent: Record write event.
         require_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
         // END ChangeEvent: Record write event.
     }
     return $response;
 }
 /**
  * Determine percentage
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		percentage
  */
 function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
 {
     $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
     $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
     $spent = (int) $re[0]["spent_seconds"];
     if ($tlt > 0) {
         $per = min(100, 100 / $tlt * $spent);
     } else {
         $per = 100;
     }
     return $per;
 }
 public function addToExternalSettingsForm($a_form_id)
 {
     global $ilSetting;
     switch ($a_form_id) {
         case ilAdministrationSettingsFormHandler::FORM_LP:
             require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
             $fields = array('trac_repository_changes' => array(ilChangeEvent::_isActive(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
             return array(array("view", $fields));
         case ilAdministrationSettingsFormHandler::FORM_TAGGING:
             $fields = array('adm_show_comments_tagging_in_lists' => array($ilSetting->get('comments_tagging_in_lists'), ilAdministrationSettingsFormHandler::VALUE_BOOL, array('adm_show_comments_tagging_in_lists_tags' => array($ilSetting->get('comments_tagging_in_lists_tags'), ilAdministrationSettingsFormHandler::VALUE_BOOL))));
             return array(array("view", $fields));
     }
 }
Esempio n. 24
0
 /**
  * paste object from clipboard to current place
  * Depending on the chosen command the object(s) are linked, copied or moved
  *
  * @access	public
  */
 function pasteObject()
 {
     global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree;
     global $ilUser, $lng, $ilCtrl;
     // BEGIN ChangeEvent: Record paste event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     // END ChangeEvent: Record paste event.
     //var_dump($_SESSION["clipboard"]);exit;
     if (!in_array($_SESSION["clipboard"]["cmd"], array("cut", "link", "copy"))) {
         $message = get_class($this) . "::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
         $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
     }
     // this loop does all checks
     foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) {
         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
         // CHECK ACCESS
         if (!$rbacsystem->checkAccess('create', $this->object->getRefId(), $obj_data->getType())) {
             $no_paste[] = $ref_id;
             $no_paste_titles[] = $obj_data->getTitle();
         }
         // CHECK IF REFERENCE ALREADY EXISTS
         if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId())) {
             $exists[] = $ref_id;
             break;
         }
         // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
         if ($this->tree->isGrandChild($ref_id, $this->object->getRefId())) {
             $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
         }
         if ($ref_id == $this->object->getRefId()) {
             $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
         }
         // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
         $obj_type = $obj_data->getType();
         if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType())))) {
             $not_allowed_subobject[] = $obj_data->getType();
         }
     }
     ////////////////////////////
     // process checking results
     // BEGIN WebDAV: Copying an object into the same container is allowed
     if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy") {
         $this->ilias->raiseError($this->lng->txt("msg_obj_exists"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($is_child)) {
         $this->ilias->raiseError($this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child), $this->ilias->error_obj->MESSAGE);
     }
     if (count($not_allowed_subobject)) {
         $this->ilias->raiseError($this->lng->txt("msg_may_not_contain") . " " . implode(',', $not_allowed_subobject), $this->ilias->error_obj->MESSAGE);
     }
     if (count($no_paste)) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste") . " " . implode(',', $no_paste), $this->ilias->error_obj->MESSAGE);
     }
     // log pasteObject call
     $log->write("ilObjectGUI::pasteObject(), cmd: " . $_SESSION["clipboard"]["cmd"]);
     ////////////////////////////////////////////////////////
     // everything ok: now paste the objects to new location
     // to prevent multiple actions via back/reload button
     $ref_ids = $_SESSION["clipboard"]["ref_ids"];
     unset($_SESSION["clipboard"]["ref_ids"]);
     // BEGIN WebDAV: Support a copy command in the repository
     // process COPY command
     if ($_SESSION["clipboard"]["cmd"] == "copy") {
         unset($_SESSION["clipboard"]["cmd"]);
         // new implementation, redirects to ilObjectCopyGUI
         if (count($ref_ids) == 1) {
             $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
             $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]);
             $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
         } else {
             $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId());
             $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($ref_ids, "_"));
             $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget");
         }
         /* old implementation
         
         			foreach($ref_ids as $ref_id)
         			{
         				$revIdMapping = array(); 
                                         
         				$oldNode_data = $tree->getNodeData($ref_id);
         				if ($oldNode_data['parent'] == $this->object->getRefId())
         				{
         					require_once 'Modules/File/classes/class.ilObjFileAccess.php';
         					$newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null);
         					$newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle);
         				}
         				else
         				{
         					$newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null);
         				}
         
         				// BEGIN ChangeEvent: Record copy event.
         				$old_parent_data = $tree->getParentNodeData($ref_id);
         				$newNode_data = $tree->getNodeData($newRef);
         				ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id,
         					$oldNode_data['obj_id'], $ilUser->getId());
         				ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add', 
         					$this->object->getId());
         				ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());				
         				// END ChangeEvent: Record copy event.
         			}*/
         $log->write("ilObjectGUI::pasteObject(), copy finished");
     }
     // END WebDAV: Support a Copy command in the repository
     // process CUT command
     if ($_SESSION["clipboard"]["cmd"] == "cut") {
         foreach ($ref_ids as $ref_id) {
             // Store old parent
             $old_parent = $tree->getParentId($ref_id);
             $this->tree->moveTree($ref_id, $this->object->getRefId());
             $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
             include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
             ilConditionHandler::_adjustMovedObjectConditions($ref_id);
             // BEGIN ChangeEvent: Record cut event.
             $node_data = $tree->getNodeData($ref_id);
             $old_parent_data = $tree->getNodeData($old_parent);
             ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove', $old_parent_data['obj_id']);
             ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId());
             ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
             // END PATCH ChangeEvent: Record cut event.
         }
     }
     // END CUT
     // process LINK command
     if ($_SESSION["clipboard"]["cmd"] == "link") {
         foreach ($ref_ids as $ref_id) {
             // get node data
             $top_node = $this->tree->getNodeData($ref_id);
             // get subnodes of top nodes
             $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
         }
         // now move all subtrees to new location
         foreach ($subnodes as $key => $subnode) {
             // first paste top_node....
             $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
             $new_ref_id = $obj_data->createReference();
             $obj_data->putInTree($_GET["ref_id"]);
             $obj_data->setPermissions($_GET["ref_id"]);
             // BEGIN ChangeEvent: Record link event.
             $node_data = $tree->getNodeData($new_ref_id);
             ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId());
             ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
             // END PATCH ChangeEvent: Record link event.
         }
         $log->write("ilObjectGUI::pasteObject(), link finished");
         // inform other objects in hierarchy about link operation
         //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
     }
     // END LINK
     // save cmd for correct message output after clearing the clipboard
     $last_cmd = $_SESSION["clipboard"]["cmd"];
     // clear clipboard
     $this->clearObject();
     if ($last_cmd == "cut") {
         ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"), true);
     } else {
         if ($last_cmd == "copy") {
             ilUtil::sendSuccess($this->lng->txt("msg_cloned"), true);
         } else {
             if ($last_cmd == 'link') {
                 ilUtil::sendSuccess($this->lng->txt("msg_linked"), true);
             }
         }
     }
     $this->ctrl->returnToParent($this);
 }
 /**
  * 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;
     $status = LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case 'exc':
             include_once './Services/Tracking/classes/class.ilChangeEvent.php';
             include_once './Modules/Exercise/classes/class.ilExerciseMembers.php';
             if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id) || ilExerciseMembers::_hasReturned($a_obj_id, $a_user_id)) {
                 $status = LP_STATUS_IN_PROGRESS_NUM;
             }
             $ex_stat = ilExerciseMembers::_lookupStatus($a_obj_id, $a_user_id);
             if ($ex_stat == "passed") {
                 $status = LP_STATUS_COMPLETED_NUM;
             }
             if ($ex_stat == "failed") {
                 $status = LP_STATUS_FAILED_NUM;
             }
             break;
     }
     return $status;
 }
Esempio n. 26
0
 /**
  * Add object to tree at given position
  *
  * @param ilObject $a_obj
  * @param int $a_parent_node_id
  */
 protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
 {
     global $rbacreview, $ilUser, $objDefinition;
     $this->object_id = $a_obj->getId();
     if (!$a_parent_node_id) {
         $a_parent_node_id = $this->parent_id;
     }
     // add new object to custom parent container
     if ((int) $_REQUEST["crtptrefid"]) {
         $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
     }
     switch ($this->id_type) {
         case self::REPOSITORY_NODE_ID:
         case self::REPOSITORY_OBJECT_ID:
             if (!$this->node_id) {
                 $a_obj->createReference();
                 $this->node_id = $a_obj->getRefId();
             }
             $a_obj->putInTree($a_parent_node_id);
             $a_obj->setPermissions($a_parent_node_id);
             // rbac log
             include_once "Services/AccessControl/classes/class.ilRbacLog.php";
             $rbac_log_roles = $rbacreview->getParentRoleIds($this->node_id, false);
             $rbac_log = ilRbacLog::gatherFaPa($this->node_id, array_keys($rbac_log_roles), true);
             ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->node_id, $rbac_log);
             $this->ctrl->setParameter($this, "ref_id", $this->node_id);
             break;
         case self::WORKSPACE_NODE_ID:
         case self::WORKSPACE_OBJECT_ID:
             if (!$this->node_id) {
                 $this->node_id = $this->tree->insertObject($a_parent_node_id, $this->object_id);
             }
             $this->getAccessHandler()->setPermissions($a_parent_node_id, $this->node_id);
             $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
             break;
         case self::OBJECT_ID:
         case self::PORTFOLIO_OBJECT_ID:
             // do nothing
             break;
     }
     // BEGIN ChangeEvent: Record save object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordWriteEvent($this->object_id, $ilUser->getId(), 'create');
     // END ChangeEvent: Record save object.
     // use forced callback after object creation
     self::handleAfterSaveCallback($a_obj, $_REQUEST["crtcb"]);
 }
Esempio n. 27
0
 /**
  * list childs of current object
  *
  * @access	public
  */
 public function viewObject()
 {
     global $tpl;
     if (!$this->checkPermissionBool("visible,read")) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     // BEGIN ChangeEvent: record read event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(), $this->object->getId(), $ilUser->getId());
     // END ChangeEvent: record read event.
     include_once "./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php";
     if (!$this->call_by_reference) {
         $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
     }
     $itab = new ilAdminSubItemsTableGUI($this, "view", $_GET["ref_id"]);
     $tpl->setContent($itab->getHTML());
 }
Esempio n. 28
0
 /**
  * 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, $ilLog;
     $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     // if the user has accessed the scorm object
     // the status is at least "in progress"
     include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
     if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
         $status = self::LP_STATUS_IN_PROGRESS_NUM;
     }
     //$ilLog->write("-".$status."-");
     // Which sco's determine the status
     include_once './Services/Object/classes/class.ilObjectLP.php';
     $olp = ilObjectLP::getInstance($a_obj_id);
     $collection = $olp->getCollectionInstance();
     if ($collection) {
         $scos = $collection->getItems();
         if (sizeof($scos)) {
             include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
             $subtype = ilObjSAHSLearningModule::_lookupSubType($a_obj_id);
             switch ($subtype) {
                 case 'hacp':
                 case 'aicc':
                 case 'scorm':
                     include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php";
                     $scorm_status = ilObjSCORMTracking::_getCollectionStatus($scos, $a_obj_id, $a_user_id);
                     break;
                 case 'scorm2004':
                     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php";
                     $scorm_status = ilSCORM2004Tracking::_getCollectionStatus($scos, $a_obj_id, $a_user_id);
                     break;
             }
             switch ($scorm_status) {
                 case "in_progress":
                     $status = self::LP_STATUS_IN_PROGRESS_NUM;
                     break;
                 case "completed":
                     $status = self::LP_STATUS_COMPLETED_NUM;
                     break;
                 case "failed":
                     $status = self::LP_STATUS_FAILED_NUM;
                     break;
             }
         }
     }
     //$ilLog->write("-".$status."-");
     return $status;
 }
Esempio n. 29
0
 /**
  * Determine percentage
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		percentage
  */
 function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
 {
     include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
     $reqv = ilLPObjSettings::_lookupVisits($a_obj_id);
     $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
     $rc = (int) $re[0]["read_count"];
     if ($reqv > 0) {
         $per = min(100, 100 / $reqv * $rc);
     } else {
         $per = 100;
     }
     return $per;
 }
 /**
  * delete object or referenced object
  * (in the case of a referenced object, object data is only deleted
  * if last reference is deleted)
  * This function removes an object entirely from system!!
  *
  * @access	public
  * @return	boolean	true if object was removed completely; false if only a references was removed
  */
 function delete()
 {
     global $rbacadmin, $log, $ilDB;
     $remove = false;
     // delete object_data entry
     if (!$this->referenced || $this->countReferences() == 1) {
         // check type match
         $db_type = ilObject::_lookupType($this->getId());
         if ($this->type != $db_type) {
             $message = "ilObject::delete(): Type mismatch. Object with obj_id: " . $this->id . " " . "was instantiated by type '" . $this->type . "'. DB type is: " . $db_type;
             // write log entry
             $log->write($message);
             // raise error
             $this->ilias->raiseError("ilObject::delete(): Type mismatch. (" . $this->type . "/" . $this->id . ")", $this->ilias->error_obj->WARNING);
         }
         // delete entry in object_data
         $q = "DELETE FROM object_data " . "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($q);
         // delete long description
         $query = "DELETE FROM object_description WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), deleted object, obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // remove news
         include_once "./Services/News/classes/class.ilNewsItem.php";
         $news_item = new ilNewsItem();
         $news_item->deleteNewsOfContext($this->getId(), $this->getType());
         include_once "./Services/Block/classes/class.ilBlockSetting.php";
         ilBlockSetting::_deleteSettingsOfBlock($this->getId(), "news");
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByObjId($this->getId());
         /* remove notes (see infoscreen gui)
         			   as they can be seen as personal data we are keeping them for now
         			include_once("Services/Notes/classes/class.ilNote.php");
         			foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
         			{
         				foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note)
         				{
         					$note->delete();
         				}
         			}
         		    */
         // BEGIN WebDAV: Delete WebDAV properties
         $query = "DELETE FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
         $res = $ilDB->manipulate($query);
         // END WebDAV: Delete WebDAV properties
         include_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_delete($this->getId());
         include_once './Services/Tracking/classes/class.ilLPCollections.php';
         ilLPCollections::_deleteAll($this->getId());
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         ilECSImport::_deleteByObjId($this->getId());
         $remove = true;
     } else {
         // write log entry
         $log->write("ilObject::delete(), object not deleted, number of references: " . $this->countReferences() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
     }
     // delete object_reference entry
     if ($this->referenced) {
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::deleteAllEntries($this->getRefId());
         // delete entry in object_reference
         $query = "DELETE FROM object_reference " . "WHERE ref_id = " . $ilDB->quote($this->getRefId(), 'integer');
         $res = $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), reference deleted, ref_id: " . $this->getRefId() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // DELETE PERMISSION ENTRIES IN RBAC_PA
         // DONE: method overwritten in ilObjRole & ilObjUser.
         // this call only applies for objects in rbac (not usr,role,rolt)
         // TODO: Do this for role templates too
         $rbacadmin->revokePermission($this->getRefId(), 0, false);
         include_once "Services/AccessControl/classes/class.ilRbacLog.php";
         ilRbacLog::delete($this->getRefId());
         // Remove applied didactic template setting
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByRefId($this->getRefId());
         // Remove desktop items
         ilUtil::removeItemFromDesktops($this->getRefId());
     }
     // remove conditions
     if ($this->referenced) {
         $ch =& new ilConditionHandler();
         $ch->delete($this->getRefId());
         unset($ch);
     }
     return $remove;
 }