protected function deletePortfolios()
 {
     global $lng, $ilCtrl;
     if (is_array($_POST["prtfs"])) {
         foreach ($_POST["prtfs"] as $id) {
             if ($this->checkAccess("write", $id)) {
                 $portfolio = new ilObjPortfolio($id, false);
                 if ($portfolio->getOwner() == $this->user_id) {
                     $this->access_handler->removePermission($id);
                     $portfolio->delete();
                 }
             }
         }
     }
     ilUtil::sendSuccess($lng->txt("prtf_portfolio_deleted"), true);
     $ilCtrl->redirect($this, "show");
 }
 protected function cancelPassword()
 {
     global $ilUser;
     if ($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
         if ($this->node_id) {
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
             $tree = new ilWorkspaceTree($ilUser->getId());
             $owner = $tree->lookupOwner($this->node_id);
             ilUtil::redirect("ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=" . $owner);
         } else {
             include_once "Services/Portfolio/classes/class.ilObjPortfolio.php";
             $prtf = new ilObjPortfolio($this->portfolio_id, false);
             $owner = $prtf->getOwner();
             ilUtil::redirect("ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToPortfolio&dsh=" . $owner);
         }
     }
 }
 /**
  * check access for an object
  *
  * @param	integer		$a_user_id
  * @param	string		$a_permission
  * @param	string		$a_cmd
  * @param	int			$a_node_id
  * @param	string		$a_type (optional)
  * @return	bool
  */
 public function checkAccessOfUser($a_user_id, $a_permission, $a_cmd, $a_node_id, $a_type = "")
 {
     global $rbacreview, $ilUser, $ilSetting;
     // #12059
     if (!$ilSetting->get('user_portfolios')) {
         return false;
     }
     // :TODO: create permission for parent node with type ?!
     $pf = new ilObjPortfolio($a_node_id, false);
     if (!$pf->getId()) {
         return false;
     }
     // portfolio owner has all rights
     if ($pf->getOwner() == $a_user_id) {
         return true;
     }
     // #11921
     if (!$pf->isOnline()) {
         return false;
     }
     // other users can only read
     if ($a_permission == "read" || $a_permission == "visible") {
         // get all objects with explicit permission
         $objects = $this->getPermissions($a_node_id);
         if ($objects) {
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php";
             // check if given user is member of object or has role
             foreach ($objects as $obj_id) {
                 switch ($obj_id) {
                     case ilWorkspaceAccessGUI::PERMISSION_ALL:
                         return true;
                     case ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD:
                         // check against input kept in session
                         if (self::getSharedNodePassword($a_node_id) == self::getSharedSessionPassword($a_node_id) || $a_permission == "visible") {
                             return true;
                         }
                         break;
                     case ilWorkspaceAccessGUI::PERMISSION_REGISTERED:
                         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                             return true;
                         }
                         break;
                     default:
                         switch (ilObject::_lookupType($obj_id)) {
                             case "grp":
                                 // member of group?
                                 if (ilGroupParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) {
                                     return true;
                                 }
                                 break;
                             case "crs":
                                 // member of course?
                                 if (ilCourseParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) {
                                     return true;
                                 }
                                 break;
                             case "role":
                                 // has role?
                                 if ($rbacreview->isAssigned($a_user_id, $obj_id)) {
                                     return true;
                                 }
                                 break;
                             case "usr":
                                 // direct assignment
                                 if ($a_user_id == $obj_id) {
                                     return true;
                                 }
                                 break;
                         }
                         break;
                 }
             }
         }
     }
     return false;
 }