function _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type = '')
 {
     global $ilDB;
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordReadEvent($a_obj_type, $a_ref_id, $a_obj_id, $a_user_id);
     require_once 'Services/Tracking/classes/class.ilLPStatus.php';
     ilLPStatus::setInProgressIfNotAttempted($a_obj_id, $a_user_id);
     return true;
 }
 /**
  * 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());
 }
 /**
  * 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;
     }
 }
 /**
  * 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());
     }
 }
 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);
     }
 }
예제 #7
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());
 }
 /**
  * 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());
     }
 }
예제 #9
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);
    }
    /**
     * 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);
    }
예제 #12
0
    /**
     * Synch read event table
     *
     * @param
     * @return
     */
    function _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id, $time_from_lms = null)
    {
        global $ilDB;
        //get condition to select time
        $val_set = $ilDB->queryF('SELECT time_from_lms FROM sahs_lm WHERE id = %s', array('integer'), array($a_obj_id));
        $val_rec = $ilDB->fetchAssoc($val_set);
        $time_from_lms = ilUtil::yn2tf($val_rec["time_from_lms"]);
        // get attempts and time
        $val_set = $ilDB->queryF('
			SELECT package_attempts, sco_total_time_sec, total_time_sec 
			FROM sahs_user WHERE obj_id = %s AND user_id = %s', array('integer', 'integer'), array($a_obj_id, $a_user_id));
        $val_rec = $ilDB->fetchAssoc($val_set);
        if ($time_from_lms == false) {
            $time = $val_rec["sco_total_time_sec"];
        } else {
            $time = $val_rec["total_time_sec"];
        }
        $attempts = $val_rec["package_attempts"];
        if ($attempts == null) {
            $attempts = "";
        }
        //??
        if ($attempts != "" && $time == null) {
            //use old way
            $time = self::getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, true);
        }
        include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
        ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
    }
예제 #13
0
 /**
  * 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());
 }
예제 #14
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';
 }
    /**
     * Synch read event table
     *
     * @param
     * @return
     */
    function _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
    {
        global $ilDB;
        // get attempts and time
        $val_set = $ilDB->queryF('
			SELECT package_attempts, sco_total_time_sec 
			FROM sahs_user WHERE obj_id = %s AND user_id = %s', array('integer', 'integer'), array($a_obj_id, $a_user_id));
        $val_rec = $ilDB->fetchAssoc($val_set);
        $time = $val_rec["sco_total_time_sec"];
        //could be changed to total_time_sec if switch is available
        $attempts = $val_rec["package_attempts"];
        if ($attempts == null) {
            $attempts = "";
        }
        if ($attempts != "" && $time == null) {
            //use old way
            $time = self::getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, true);
        }
        include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
        ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
    }
예제 #16
0
 function sendFile()
 {
     global $ilUser, $ilCtrl;
     if (ANONYMOUS_USER_ID == $ilUser->getId() && isset($_GET['transaction'])) {
         $this->object->sendFile($_GET["hist_id"]);
     }
     if ($this->checkPermissionBool("read")) {
         // BEGIN ChangeEvent: Record read event.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         // Record read event and catchup with write events
         ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(), $this->object->getId(), $ilUser->getId());
         // END ChangeEvent: Record read event.
         $this->object->sendFile($_GET["hist_id"]);
     } else {
         $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
     }
     return true;
 }
예제 #17
0
 public function performPasteIntoMultipleObjectsObject()
 {
     global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser;
     $command = $_SESSION['clipboard']['cmd'];
     if (!in_array($command, array('cut', 'link', 'copy'))) {
         $message = __METHOD__ . ": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!";
         $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
     }
     if ($command == 'cut') {
         if (isset($_POST['node']) && (int) $_POST['node']) {
             $_POST['nodes'] = array($_POST['node']);
         }
     }
     if (!is_array($_POST['nodes']) || !count($_POST['nodes'])) {
         ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'));
         switch ($command) {
             case 'cut':
                 $this->showPasteTreeObject();
                 break;
             case 'copy':
                 $this->showPasteTreeObject();
                 break;
             case 'link':
                 $this->showPasteTreeObject();
                 break;
         }
         return;
     }
     // this loop does all checks
     $folder_objects_cache = array();
     foreach ($_SESSION['clipboard']['ref_ids'] as $ref_id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($ref_id);
         $current_parent_id = $tree->getParentId($obj_data->getRefId());
         foreach ($_POST['nodes'] as $folder_ref_id) {
             if (!array_key_exists($folder_ref_id, $folder_objects_cache)) {
                 $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id);
             }
             // CHECK ACCESS
             if (!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType())) {
                 $no_paste[] = sprintf($this->lng->txt('msg_no_perm_paste_object_in_folder'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']', $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']');
             }
             // CHECK IF REFERENCE ALREADY EXISTS
             if ($folder_ref_id == $current_parent_id) {
                 $exists[] = sprintf($this->lng->txt('msg_obj_exists_in_folder'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']', $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']');
             }
             // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
             if ($tree->isGrandChild($ref_id, $folder_ref_id) || $ref_id == $folder_ref_id) {
                 $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']');
             }
             // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
             if (!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType())))) {
                 $not_allowed_subobject[] = sprintf($this->lng->txt('msg_obj_may_not_contain_objects_of_type'), $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']', $GLOBALS['lng']->txt('obj_' . $obj_data->getType()));
             }
         }
     }
     ////////////////////////////
     // process checking results
     if (count($exists) && $command != "copy") {
         $error .= implode('<br />', $exists);
     }
     if (count($is_child)) {
         $error .= $error != '' ? '<br />' : '';
         $error .= implode('<br />', $is_child);
     }
     if (count($not_allowed_subobject)) {
         $error .= $error != '' ? '<br />' : '';
         $error .= implode('<br />', $not_allowed_subobject);
     }
     if (count($no_paste)) {
         $error .= $error != '' ? '<br />' : '';
         $error .= implode('<br />', $no_paste);
     }
     if ($error != '') {
         ilUtil::sendFailure($error);
         switch ($command) {
             case 'cut':
                 $this->showPasteTreeObject();
                 break;
             case 'copy':
                 $this->showPasteTreeObject();
                 break;
             case 'link':
                 $this->showPasteTreeObject();
                 break;
         }
         return;
     }
     // log pasteObject call
     $log->write(__METHOD__ . ", cmd: " . $command);
     ////////////////////////////////////////////////////////
     // 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 ChangeEvent: Record paste event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     // END ChangeEvent: Record paste event.
     // process COPY command
     if ($command == 'copy') {
         foreach ($_POST['nodes'] as $folder_ref_id) {
             foreach ($ref_ids as $ref_id) {
                 $revIdMapping = array();
                 $oldNode_data = $tree->getNodeData($ref_id);
                 if ($oldNode_data['parent'] == $folder_ref_id) {
                     require_once 'Modules/File/classes/class.ilObjFileAccess.php';
                     $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'], null);
                     $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle);
                 } else {
                     $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $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', $ilObjDataCache->lookupObjId($folder_ref_id));
                 ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId());
                 // END PATCH ChangeEvent: Record cut event.
             }
         }
         ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
     }
     // END COPY
     // process CUT command
     if ($command == 'cut') {
         foreach ($_POST['nodes'] as $folder_ref_id) {
             foreach ($ref_ids as $ref_id) {
                 // Store old parent
                 $old_parent = $tree->getParentId($ref_id);
                 $tree->moveTree($ref_id, $folder_ref_id);
                 $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', $ilObjDataCache->lookupObjId($folder_ref_id));
                 ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
                 // END PATCH ChangeEvent: Record cut event.
             }
             // prevent multiple iterations for cut cmommand
             break;
         }
         ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
     }
     // END CUT
     // process LINK command
     if ($command == 'link') {
         $linked_to_folders = array();
         include_once "Services/AccessControl/classes/class.ilRbacLog.php";
         $rbac_log_active = ilRbacLog::isActive();
         foreach ($_POST['nodes'] as $folder_ref_id) {
             $linked_to_folders[] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id));
             foreach ($ref_ids as $ref_id) {
                 // get node data
                 $top_node = $tree->getNodeData($ref_id);
                 // get subnodes of top nodes
                 $subnodes[$ref_id] = $tree->getSubtree($top_node);
             }
             // now move all subtrees to new location
             foreach ($subnodes as $key => $subnode) {
                 // first paste top_node....
                 $obj_data = ilObjectFactory::getInstanceByRefId($key);
                 $new_ref_id = $obj_data->createReference();
                 $obj_data->putInTree($folder_ref_id);
                 $obj_data->setPermissions($folder_ref_id);
                 // rbac log
                 if ($rbac_log_active) {
                     $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
                     $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
                     ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key);
                 }
                 // BEGIN ChangeEvent: Record link event.
                 $node_data = $tree->getNodeData($new_ref_id);
                 ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $ilObjDataCache->lookupObjId($folder_ref_id));
                 ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId());
                 // END PATCH ChangeEvent: Record link event.
             }
             $log->write(__METHOD__ . ', link finished');
         }
         ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders'), implode(', ', $linked_to_folders)), true);
     }
     // END LINK
     // clear clipboard
     $this->clearObject();
     $this->ctrl->returnToParent($this);
 }
예제 #18
0
 /**
  * Note the access of the current usr to an object
  *
  * This function has to be called if an object is accessed for viewing.
  *
  * @access   static
  * @param    int     	object id (not reference)
  */
 function _noteAccess($a_obj_id, $a_type, $a_ref_id)
 {
     global $ilDB, $ilUser, $ilSetting;
     // don't note the access if licensing is globally disabled
     require_once "Services/License/classes/class.ilLicenseAccess.php";
     if (!ilLicenseAccess::_isEnabled()) {
         return;
     }
     // check if user has already accessed
     $query = 'SELECT read_count FROM read_event ' . 'WHERE usr_id = %s AND obj_id = %s';
     $result = $ilDB->queryF($query, array('integer', 'integer'), array($ilUser->getId(), $a_obj_id));
     if ($row = $ilDB->fetchObject($result)) {
         // already accessed -> nothing to do
         return;
     } else {
         // note access
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $ilUser->getId());
         if (self::_isLicensed($a_obj_id)) {
             // increase used licenses
             $query = "UPDATE license_data SET used = used + 1 " . "WHERE obj_id = %s";
             $ilDB->manipulateF($query, array('integer'), array($a_obj_id));
         }
     }
 }
 public function syncGlobalStatus($userId, $packageId, $data, $new_global_status)
 {
     global $ilDB, $ilLog;
     $saved_global_status = $data->saved_global_status;
     $ilLog->write("saved_global_status=" . $saved_global_status);
     // sync access number and time in read event table
     //include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
     //ilSCORM2004Tracking::_syncReadEvent($packageId, $userId, "sahs", $a_ref_id);
     // get attempts
     if (!$data->packageAttempts) {
         $val_set = $ilDB->queryF('SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s', array('integer', 'integer'), array($packageId, $userId));
         $val_rec = $ilDB->fetchAssoc($val_set);
         $attempts = $val_rec["package_attempts"];
     } else {
         $attempts = $data->packageAttempts;
     }
     if ($attempts == null) {
         $attempts = "";
     }
     //update percentage_completed, sco_total_time_sec,status in sahs_user
     $totalTime = (int) $data->totalTimeCentisec;
     $totalTime = round($totalTime / 100);
     $ilDB->queryF('UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s, package_attempts=%s WHERE obj_id = %s AND user_id = %s', array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'), array($totalTime, $new_global_status, $data->percentageCompleted, $attempts, $packageId, $userId));
     self::ensureObjectDataCacheExistence();
     global $ilObjDataCache;
     include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
     ilChangeEvent::_recordReadEvent("sahs", (int) $_GET['ref_id'], $packageId, $userId, false, $attempts, $totalTime);
     //end sync access number and time in read event table
     // if($saved_global_status != $new_global_status)
     // {
     // update learning progress
     //			include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
     //			ilLPStatusWrapper::_updateStatus($packageId, $userId);
     include_once "./Services/Tracking/classes/class.ilObjUserTracking.php";
     include_once "./Services/Tracking/classes/class.ilLPStatus.php";
     ilLPStatus::writeStatus($packageId, $userId, $new_global_status, $data->percentageCompleted);
     //			here put code for soap to MaxCMS e.g. when if($saved_global_status != $new_global_status)
     // }
     return true;
 }
예제 #20
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;
     // 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[] = $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") {
         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_command == 'link') {
                 ilUtil::sendSuccess($this->lng->txt("msg_linked"), true);
             }
         }
     }
     $this->ctrl->returnToParent($this);
 }
예제 #21
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());
     include_once "./Modules/Wiki/classes/class.ilWikiStat.php";
     ilWikiStat::handleEvent(ilWikiStat::EVENT_PAGE_READ, $this->getWikiPage());
 }