/** Reads the folder recordset from database table @b adm_folders and throws an * AdmException if the user has no right to see the folder or the folder id doesn't exists. * @param $folderId The id of the folder. If the id is 0 then the root folder will be shown. * @return Returns @b true if everything is ok otherwise an AdmException is thrown. */ public function getFolderForDownload($folderId) { global $gCurrentOrganization, $gCurrentUser, $gValidLogin; if ($folderId > 0) { $condition = ' fol_id = ' . $folderId . ' AND fol_type = \'DOWNLOAD\' AND fol_org_id = ' . $gCurrentOrganization->getValue('org_id'); parent::readData($condition); } else { $condition = ' fol_name = \'download\' AND fol_type = \'DOWNLOAD\' AND fol_path = \'/adm_my_files\' AND fol_org_id = ' . $gCurrentOrganization->getValue('org_id'); parent::readData($condition); } //Gucken ob ueberhaupt ein Datensatz gefunden wurde... if ($this->getValue('fol_id')) { //Falls der Ordner gelocked ist und der User keine Downloadadminrechte hat, bekommt er nix zu sehen.. if (!$gCurrentUser->editDownloadRight() && $this->getValue('fol_locked')) { $this->clear(); throw new AdmException('DOW_FOLDER_NO_RIGHTS'); } elseif (!$gValidLogin && !$this->getValue('fol_public')) { //Wenn der Ordner nicht public ist und der Benutzer nicht eingeloggt ist, bekommt er nix zu sehen.. $this->clear(); throw new AdmException('DOW_FOLDER_NO_RIGHTS'); } elseif (!$gCurrentUser->editDownloadRight() && !$this->getValue('fol_public')) { //Wenn der Ordner nicht public ist und der Benutzer keine DownloadAdminrechte hat, muessen die Rechte untersucht werden $sql_rights = 'SELECT count(*) FROM ' . TBL_FOLDER_ROLES . ', ' . TBL_MEMBERS . ' WHERE flr_fol_id = ' . $this->getValue('fol_id') . ' AND flr_rol_id = mem_rol_id AND mem_usr_id = ' . $gCurrentUser->getValue('usr_id') . ' AND mem_begin <= \'' . DATE_NOW . '\' AND mem_end > \'' . DATE_NOW . '\''; $result_rights = $this->db->query($sql_rights); $row_rights = $this->db->fetch_array($result_rights); $row_count = $row_rights[0]; //Falls der User in keiner Rolle Mitglied ist, die Rechte an dem Ordner besitzt //wird auch kein Ordner geliefert. if ($row_count == 0) { $this->clear(); throw new AdmException('DOW_FOLDER_NO_RIGHTS'); } return true; } else { return true; } } throw new AdmException('DOW_FOLDER_NOT_FOUND', $folderId); }