/**
  * @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;
 }
 /**
  * @param ilPropertyFormGUI $form
  * @param ilObjCloud        $obj
  */
 public function afterSavePluginCreation(ilObjCloud &$obj, ilPropertyFormGUI $form)
 {
     if ($form->getInput(self::F_BASE_FOLDER) == self::F_DEFAULT_BASE_FOLDER) {
         $root_folder = $obj->getTitle();
     } else {
         $root_folder = $form->getInput(self::F_CUSTOM_BASE_FOLDER_INPUT);
     }
     $root_folder = '/ILIASCloud/' . ltrim($root_folder, "/");
     $obj->setRootFolder($root_folder);
 }
 /**
  * @param ilPropertyFormGUI $form
  * @param ilObjCloud $obj
  */
 function afterSavePluginCreation(ilObjCloud &$obj, ilPropertyFormGUI $form)
 {
     if ($form->getInput(self::F_BASE_FOLDER) == self::F_DROPBOX_DEFAULT_BASE_FOLDER) {
         $obj->setRootFolder($obj->getTitle());
     } else {
         $obj->setRootFolder($form->getInput(self::F_DROPBOX_CUSTOM_BASE_FOLDER_INPUT));
     }
     if ($form->getInput(self::F_ONLINE) == "1") {
         $obj->setOnline(true);
     }
     $obj->doUpdate();
 }
Esempio n. 4
0
 /**
  * @param $object
  */
 protected function serviceAuth(ilObjCloud $object)
 {
     global $ilCtrl;
     try {
         $service = ilCloudConnector::getServiceClass($object->getServiceName(), $object->getId());
         $service->authService($ilCtrl->getLinkTarget($this, "afterServiceAuth") . "&authMode=true");
     } catch (Exception $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         ilObjectGUI::redirectToRefId($this->parent_id);
     }
 }
 protected function afterSave(ilObjCloud $a_new_object)
 {
     try {
         $form = $this->initCreateForm("cld");
         if ($form->checkInput()) {
             $a_new_object->setServiceName($form->getInput("service"));
             $a_new_object->setRootFolder("/");
             $a_new_object->setOnline(false);
             $a_new_object->setAuthComplete(false);
             $this->plugin_service = new ilCloudPluginService($a_new_object->getServiceName(), $a_new_object->getId());
             $init_gui = ilCloudConnector::getCreationGUIClass($this->plugin_service);
             if ($init_gui) {
                 $init_gui->afterSavePluginCreation($a_new_object, $form);
             }
             $a_new_object->update();
             $this->serviceAuth($a_new_object);
         }
     } catch (Exception $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         ilObjectGUI::redirectToRefId($this->parent_id);
     }
 }
Esempio n. 6
0
 /**
  * $return integer
  */
 public function getOwnerId()
 {
     include_once "./Modules/Cloud/classes/class.ilObjCloud.php";
     $cloud_object = new ilObjCloud($this->getObjId(), false);
     return $cloud_object->getOwnerId();
 }