/**
  * @param string $a_cmd
  * @param string $a_permission
  * @param int $a_ref_id
  * @param int $a_obj_id
  * @param string $a_user_id
  * @return bool
  */
 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
 {
     global $ilUser, $rbacsystem;
     $object = new ilObjCloud($a_ref_id);
     /**
      * Check if plugin of object is active
      */
     try {
         ilCloudConnector::checkServiceActive($object->getServiceName());
     } catch (Exception $e) {
         return false;
     }
     if ($a_user_id == "") {
         $a_user_id = $ilUser->getId();
     }
     /**
      * Check if authentication is complete. If not, only the owner of the object has access. This prevents the
      * authentication of an account which does not belong to the owner.
      */
     if (!ilObjCloudAccess::checkAuthStatus($a_obj_id) && $a_user_id != $object->getOwnerId()) {
         return false;
     }
     switch ($a_permission) {
         case "visible":
         case "read":
             if (!ilObjCloudAccess::checkOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, "write", $a_ref_id)) {
                 return false;
             }
             break;
     }
     return true;
 }
 public function initGUI(ilObjCloudGUI $gui_class, $perm_create_folder, $perm_upload_items, $perm_delete_files, $perm_delete_folders, $perm_download, $perm_files_visible, $perm_folders_visible)
 {
     global $ilTabs, $lng, $tpl;
     $ilTabs->activateTab("content");
     $this->setGuiClass($gui_class);
     $this->setPermUploadItems($perm_upload_items);
     $this->setPermCreateFolders($perm_create_folder);
     $this->setPermDeleteFiles($perm_delete_files);
     $this->setPermDeleteFolders($perm_delete_folders);
     $this->setPermDownload($perm_download);
     $this->setPermFilesVisible($perm_files_visible);
     $this->setPermFoldersVisible($perm_folders_visible);
     try {
         ilCloudConnector::checkServiceActive($this->getGUIClass()->object->getServiceName());
         $this->beforeInitGUI();
         $tpl->addJavaScript("./Modules/Cloud/js/ilCloudFileList.js");
         $tpl->addJavaScript("./Modules/Cloud/js/jquery.address.js");
         $tpl->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
         $tpl->addCss("./Modules/Cloud/templates/css/cloud.css");
         include_once "./Services/YUI/classes/class.ilYuiUtil.php";
         ilYuiUtil::initConnection();
         $this->tpl_file_tree = new ilTemplate("tpl.cloud_file_tree.html", true, true, "Modules/Cloud");
         $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName());
         $file_tree->storeFileTreeToSession();
         $this->addToolbar($file_tree->getRootNode());
         $this->tpl_file_tree->setVariable("ASYNC_GET_BLOCK", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilobjcloudgui", "asyncGetBlock", true)));
         $this->tpl_file_tree->setVariable("ASYNC_CREATE_FOLDER", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugincreatefoldergui", "asyncCreateFolder", true)));
         $this->tpl_file_tree->setVariable("ASYNC_UPLOAD_FILE", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudpluginuploadgui", "asyncUploadFile", true)));
         $this->tpl_file_tree->setVariable("ASYNC_DELETE_ITEM", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugindeletegui", "asyncDeleteItem", true)));
         $this->tpl_file_tree->setVariable("ROOT_ID", json_encode($file_tree->getRootNode()->getId()));
         $this->tpl_file_tree->setVariable("ROOT_PATH", json_encode($file_tree->getRootNode()->getPath()));
         if (isset($_POST["path"])) {
             $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($_POST["path"]));
             $file_tree->updateFileTree($_POST["path"]);
             $node = $file_tree->getNodeFromPath($_POST["path"]);
             $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($node->getId()));
         } else {
             $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($file_tree->getRootNode()->getPath()));
             $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($file_tree->getRootNode()->getID()));
         }
         $txt_max_file_size = $lng->txt("file_notice") . " " . ilCloudConnector::getPluginClass($this->getGUIClass()->object->getServiceName(), $this->getGUIClass()->object->getId())->getMaxFileSize() . " MB";
         $this->tpl_file_tree->setVariable("MAX_FILE_SIZE", json_encode($txt_max_file_size));
         $this->beforeSetContent();
         $tpl->setContent($this->tpl_file_tree->get());
         $tpl->setPermanentLink("cld", $this->getGuiClass()->object->getRefId(), "_path__endPath");
         /**
                     else
                     {
                         $file_tree = ilCloudFileTree::getFileTreeFromSession();
                         if($_GET["current_path"] && $_GET["current_id"] && $file_tree && $file_tree->getId() == $this->getGUIClass()->object->getId())
                         {
                             $path = $_GET["current_path"];
                             $id = $_GET["current_id"];
         
                         }
                         else
                         {
                             $path = $gui_class->object->getRootFolder();
                             $id = $gui_class->object->getRootId();
                             ilCloudFileTree::clearFileTreeSession();
                             $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName());
                         }
         
         
                         $file_tree->updateFileTree($path);
                         $file_tree_gui = ilCloudConnector::getFileTreeGUIClass($this->getService(), $file_tree);
                         $this->content = $file_tree_gui->getFolderHtml($this->getGuiClass(), $id, $this->getPermDeleteFiles(), $this->getPermDeleteFolders(), $this->getPermDownload(), $this->getPermFilesVisible(), $this->getPermCreateFolders());
                         $tpl->setContent($this->content);
                     }**/
         $this->afterInitGUI();
     } catch (Exception $e) {
         if ($e->getCode() == ilCloudException::AUTHENTIFICATION_FAILED) {
             $this->getGUIClass()->object->setAuthComplete(false);
             $this->getGUIClass()->object->doUpdate();
         }
         ilUtil::sendFailure($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * @return bool
  * @throws ilCloudException
  */
 public function executeCommand()
 {
     global $ilCtrl, $ilTabs, $ilNavigationHistory, $lng;
     // Navigation History
     $link = $ilCtrl->getLinkTarget($this, "render");
     try {
         ilCloudConnector::getActiveServices();
     } catch (Exception $e) {
         ilUtil::sendFailure($lng->txt("cld_no_service_active"), true);
         ilObjectGUI::redirectToRefId($this->parent_id);
     }
     if ($this->object != NULL) {
         $ilNavigationHistory->addItem($this->object->getRefId(), $link, "cld");
         try {
             ilCloudConnector::checkServiceActive($this->object->getServiceName());
         } catch (Exception $e) {
             ilUtil::sendFailure($lng->txt("cld_plugin_not_active"), true);
             ilObjectGUI::redirectToRefId($this->parent_id);
         }
         if ($this->object->getAuthComplete() == false && !$_GET["authMode"]) {
             if ($this->checkPermissionBool("write")) {
                 $this->serviceAuth($this->object);
             } else {
                 ilUtil::sendFailure($lng->txt("cld_auth_failed"), true);
                 ilObjectGUI::redirectToRefId($this->parent_id);
             }
         }
         $this->plugin_service = ilCloudConnector::getServiceClass($this->object->getServiceName(), $this->object->getId(), false);
     }
     $next_class = $ilCtrl->getNextClass($this);
     $cmd = $ilCtrl->getCmd($this);
     switch ($cmd) {
         case "editSettings":
             $next_class = "ilcloudpluginsettingsgui";
             break;
         case "afterServiceAuth":
             $this->checkPermission("write");
             $this->{$cmd}();
             return;
         case "render":
             $this->addHeaderAction();
             break;
     }
     switch ($next_class) {
         case "ilinfoscreengui":
             $this->prepareOutput();
             $this->infoScreenForward();
             break;
         case "ilcommonactiondispatchergui":
             include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
         case "ilpermissiongui":
             $this->prepareOutput();
             $ilTabs->activateTab("id_permissions");
             include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
             $perm_gui = new ilPermissionGUI($this);
             $this->ctrl->forwardCommand($perm_gui);
             break;
         case "ilcloudpluginuploadgui":
             if ($this->checkPermissionBool("upload")) {
                 $upload_gui = ilCloudConnector::getUploadGUIClass($this->plugin_service);
                 $this->ctrl->forwardCommand($upload_gui);
             }
             break;
         case "ilcloudplugincreatefoldergui":
             if ($this->checkPermissionBool("folders_create")) {
                 $folder_gui = ilCloudConnector::getCreateFolderGUIClass($this->plugin_service);
                 $this->ctrl->forwardCommand($folder_gui);
             }
             break;
         case "ilcloudplugindeletegui":
             if ($this->checkPermissionBool("delete_files") || $this->checkPermissionBool("delete_folders")) {
                 $delete_gui = ilCloudConnector::getDeleteGUIClass($this->plugin_service);
                 $this->ctrl->forwardCommand($delete_gui);
             }
             break;
         case "ilcloudpluginsettingsgui":
             $this->prepareOutput();
             if ($this->checkPermissionBool("write")) {
                 $settings_gui = ilCloudConnector::getSettingsGUIClass($this->plugin_service);
                 $settings_gui->setCloudObject($this->object);
                 $this->ctrl->forwardCommand($settings_gui);
             }
             break;
         case "ilcloudpluginactionlistgui":
             $action_list_gui = ilCloudConnector::getActionListGUIClass($this->plugin_service);
             $this->ctrl->forwardCommand($action_list_gui);
             break;
         case "ilcloudpluginitemcreationlistgui":
             $item_creation_gui = ilCloudConnector::getItemCreationListGUIClass($this->plugin_service);
             $this->ctrl->forwardCommand($item_creation_gui);
             break;
         case "ilcloudpluginfiletreegui":
             $file_tree_gui = ilCloudConnector::getFileTreeGUIClass($this->plugin_service, ilCloudFileTree::getFileTreeFromSession());
             $this->ctrl->forwardCommand($file_tree_gui);
             break;
         case "ilcloudpluginheaderactiongui":
             $header_action_gui = ilCloudConnector::getHeaderActionGUIClass($this->plugin_service);
             $this->ctrl->forwardCommand($header_action_gui);
             break;
         case "ilcloudplugininitgui":
             $init_gui = ilCloudConnector::getInitGUIClass($this->plugin_service);
             $this->ctrl->forwardCommand($init_gui);
             break;
         default:
             return parent::executeCommand();
     }
     return true;
 }