/**
  * get commands
  * 
  * this method returns an array of all possible commands/permission combinations
  * 
  * example:    
  * $commands = array
  *    (
  *        array("permission" => "read", "cmd" => "view", "lang_var" => "show"),
  *        array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
  *    );
  */
 function _getCommands($a_obj_id)
 {
     $commands = array(array("permission" => "read", "cmd" => "view", "lang_var" => "show", "default" => true), array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"), array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"));
     if (ilObjSAHSLearningModuleAccess::_lookupOfflineModeAvailable($a_obj_id)) {
         $offlineMode = ilObjSAHSLearningModuleAccess::_lookupUserIsOfflineMode($a_obj_id);
         if ($offlineMode == false) {
             $commands[] = array("permission" => "read", "cmd" => "offlineModeStart", "lang_var" => "offline_mode");
         } else {
             $commands[] = array("permission" => "read", "cmd" => "offlineModeStop", "lang_var" => "offline_mode");
             $commands[0] = array("permission" => "read", "cmd" => "offlineModeView", "lang_var" => "show", "default" => true);
         }
     }
     return $commands;
 }
 /**
  * checks wether a user may invoke a command or not
  * (this method is called by ilAccessHandler::checkAccess)
  *
  * @param    string        $a_cmd        command (not permission!)
  * @param    string        $a_permission    permission
  * @param    int            $a_ref_id    reference id
  * @param    int            $a_obj_id    object id
  * @param    int            $a_user_id    user id (if not provided, current user is taken)
  *
  * @return    boolean        true, if everything is ok
  */
 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
 {
     global $ilUser, $lng, $rbacsystem, $ilAccess;
     if ($a_user_id == "") {
         $a_user_id = $ilUser->getId();
     }
     switch ($a_cmd) {
         case "view":
             if (!ilObjSAHSLearningModuleAccess::_lookupOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                 return false;
             }
             break;
     }
     switch ($a_permission) {
         case "visible":
             if (!ilObjSAHSLearningModuleAccess::_lookupOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                 return false;
             }
             break;
     }
     return true;
 }
 /**
  * Gets the disk usage of the object in bytes.
  *
  * @access	public
  * @return	integer		the disk usage in bytes
  */
 function getDiskUsage()
 {
     require_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     return ilObjSAHSLearningModuleAccess::_lookupDiskUsage($this->id);
 }
 /**
  * Download the certificate for the active user
  */
 public function downloadCertificate()
 {
     global $ilUser, $tree, $ilCtrl;
     $allowed = false;
     $last_access = 0;
     $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     if (ilObjSAHSLearningModuleAccess::_lookupUserCertificate($obj_id)) {
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
         switch ($type) {
             case "scorm":
                 include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
                 $allowed = true;
                 $last_access = ilObjSCORMLearningModule::_lookupLastAccess($obj_id, $ilUser->getId());
                 break;
             case "scorm2004":
                 include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
                 $allowed = true;
                 $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($obj_id, $ilUser->getId());
                 break;
             default:
                 break;
         }
     }
     if ($allowed) {
         include_once "./Services/Certificate/classes/class.ilCertificate.php";
         include_once "./Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php";
         $certificate = new ilCertificate(new ilSCORMCertificateAdapter($this->slm));
         $params = array("user_data" => ilObjUser::_lookupFields($ilUser->getId()), "last_access" => $last_access);
         $certificate->outCertificate($params, true);
         exit;
     }
     // redirect to parent category if certificate is not accessible
     $parent = $tree->getParentId($_GET["ref_id"]);
     $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
     $ilCtrl->redirectByClass("ilrepositorygui", "");
 }
 public function hasSCORMCertificate($sid, $ref_id, $usr_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!strlen($ref_id)) {
         return $this->__raiseError('No ref id given. Aborting!', 'Client');
     }
     global $rbacsystem, $tree, $ilLog;
     // get obj_id
     if (!($obj_id = ilObject::_lookupObjectId($ref_id))) {
         return $this->__raiseError('No exercise found for id: ' . $ref_id, 'Client');
     }
     if (ilObject::_isInTrash($ref_id)) {
         return $this->__raiseError("Parent with ID {$ref_id} has been deleted.", 'Client');
     }
     $result = false;
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     $result = ilObjSAHSLearningModuleAccess::_lookupUserCertificate($obj_id, $usr_id);
     return $result;
 }
 /**
  * execute command
  */
 function &executeCommand()
 {
     global $lng, $ilAccess, $ilNavigationHistory, $ilCtrl, $ilLocator, $ilObjDataCache;
     include_once "./Services/Object/classes/class.ilObjectGUI.php";
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
     $lng->loadLanguageModule("content");
     $obj_id = ilObject::_lookupObjectId($_GET['ref_id']);
     // add entry to navigation history
     if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
         if (!ilObjSAHSLearningModuleAccess::_lookupEditable($obj_id)) {
             $ilNavigationHistory->addItem($_GET["ref_id"], "ilias.php?cmd=infoScreen&baseClass=ilSAHSPresentationGUI&ref_id=" . $_GET["ref_id"], "lm");
         }
     }
     include_once 'Services/Payment/classes/class.ilPaymentObject.php';
     if (ilPaymentObject::_requiresPurchaseToAccess($_GET['ref_id'], $type = isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL)) {
         $ilLocator->addRepositoryItems();
         $ilLocator->addItem($ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($_GET['ref_id'])), 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=' . $_GET['ref_id'], '', $_GET['ref_id'], 'sahs');
         $this->tpl->setLocator();
         $this->tpl->getStandardTemplate();
         include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
         $this->ctrl->setReturn($this, '');
         $pp_gui = new ilShopPurchaseGUI($_GET['ref_id']);
         $this->ctrl->forwardCommand($pp_gui);
         $this->tpl->show();
         exit;
     }
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
     if ($cmd == "downloadCertificate") {
         require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMPresentationGUI.php";
         $scorm_gui = new ilSCORMPresentationGUI();
         $ret =& $this->ctrl->forwardCommand($scorm_gui);
     }
     switch ($type) {
         case "scorm2004":
             include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModuleGUI.php";
             $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"], true, false);
             break;
         case "scorm":
             include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModuleGUI.php";
             $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"], true, false);
             break;
         case "aicc":
             include_once "./Modules/ScormAicc/classes/class.ilObjAICCLearningModuleGUI.php";
             $this->slm_gui = new ilObjAICCLearningModuleGUI("", $_GET["ref_id"], true, false);
             break;
         case "hacp":
             include_once "./Modules/ScormAicc/classes/class.ilObjHACPLearningModuleGUI.php";
             $this->slm_gui = new ilObjHACPLearningModuleGUI("", $_GET["ref_id"], true, false);
             break;
     }
     if ($next_class != "ilinfoscreengui" && $cmd != "infoScreen" && $next_class != "illearningprogressgui") {
         include_once "./Services/License/classes/class.ilLicense.php";
         ilLicense::_noteAccess($obj_id, "sahs", $_GET["ref_id"]);
         switch ($type) {
             case "scorm2004":
                 $this->ctrl->setCmdClass("ilscorm13player");
                 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"], true, false);
                 break;
             case "scorm":
                 $this->ctrl->setCmdClass("ilscormpresentationgui");
                 $this->slm_gui = new ilObjSCORMLearningModuleGUI("", $_GET["ref_id"], true, false);
                 break;
             case "aicc":
                 $this->ctrl->setCmdClass("ilaiccpresentationgui");
                 break;
             case "hacp":
                 $this->ctrl->setCmdClass("ilhacppresentationgui");
                 break;
         }
         $next_class = $this->ctrl->getNextClass($this);
     }
     switch ($next_class) {
         case "ilinfoscreengui":
             $ret =& $this->outputInfoScreen();
             break;
         case "ilscorm13player":
             require_once "./Modules/Scorm2004/classes/ilSCORM13Player.php";
             $scorm_gui = new ilSCORM13Player();
             $ret =& $this->ctrl->forwardCommand($scorm_gui);
             break;
         case "ilscormpresentationgui":
             require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMPresentationGUI.php";
             $scorm_gui = new ilSCORMPresentationGUI();
             $ret =& $this->ctrl->forwardCommand($scorm_gui);
             break;
         case "ilaiccpresentationgui":
             require_once "./Modules/ScormAicc/classes/AICC/class.ilAICCPresentationGUI.php";
             $aicc_gui = new ilAICCPresentationGUI();
             $ret =& $this->ctrl->forwardCommand($aicc_gui);
             break;
         case "ilhacppresentationgui":
             require_once "./Modules/ScormAicc/classes/HACP/class.ilHACPPresentationGUI.php";
             $hacp_gui = new ilHACPPresentationGUI();
             $ret =& $this->ctrl->forwardCommand($hacp_gui);
             break;
         case "illearningprogressgui":
             $this->setInfoTabs("learning_progress");
             include_once "./Services/Tracking/classes/class.ilLearningProgressGUI.php";
             $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY, $_GET['ref_id']);
             $this->ctrl->forwardCommand($new_gui);
             $this->tpl->show();
             break;
         default:
             $this->{$cmd}();
     }
 }
예제 #7
0
 /**
  * inititialize new item (is called by getItemHTML())
  *
  * @param	int			$a_ref_id		reference id
  * @param	int			$a_obj_id		object id
  * @param	string		$a_title		title
  * @param	string		$a_description	description
  * @param	int			$a_context		tree/workspace
  */
 function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "", $a_context = self::CONTEXT_REPOSITORY)
 {
     $this->offline_mode = false;
     include_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
     if ($this->type == "sahs") {
         $this->offline_mode = ilObjSAHSLearningModuleAccess::_lookupUserIsOfflineMode($a_obj_id);
     }
     $this->access_cache = array();
     $this->ref_id = $a_ref_id;
     $this->obj_id = $a_obj_id;
     $this->context = $a_context;
     $this->setTitle($a_title);
     $this->setDescription($a_description);
     #$this->description = $a_description;
     // checks, whether any admin commands are included in the output
     $this->adm_commands_included = false;
     $this->prevent_access_caching = false;
 }
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $rbacsystem;
     $props = array();
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     $editable = ilObjSAHSLearningModuleAccess::_lookupEditable($this->obj_id);
     if (!$editable && ilObjSAHSLearningModuleAccess::_isOffline($this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline"));
     } else {
         if ($editable) {
             $props[] = array("alert" => true, "value" => $lng->txt("authoring_mode"));
         }
     }
     if ($rbacsystem->checkAccess("write", $this->ref_id)) {
         $props[] = array("alert" => false, "property" => $lng->txt("type"), "value" => $lng->txt("sahs"));
     }
     // check for certificates
     if (ilObjSAHSLearningModuleAccess::_lookupUserCertificate($this->obj_id)) {
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         $type = ilObjSAHSLearningModule::_lookupSubType($this->obj_id);
         switch ($type) {
             case "scorm":
                 $lng->loadLanguageModule('certificate');
                 $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=" . $this->ref_id . "&cmd=downloadCertificate";
                 $props[] = array("alert" => false, "property" => $lng->txt("condition_finished"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>');
                 break;
             case "scorm2004":
                 $lng->loadLanguageModule('certificate');
                 $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=" . $this->ref_id . "&amp;cmd=downloadCertificate";
                 $props[] = array("alert" => false, "property" => $lng->txt("condition_finished"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>');
                 break;
         }
     }
     return $props;
 }