/**
  * @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;
 }
예제 #2
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);
     }
 }
예제 #3
0
 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);
     }
 }