Commit b17af6c6f5b1e7481ead256cb47d18bf731e39b9

Authored by rob
1 parent 0cac97a9

Initial revision


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@148 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentModify.inc 0 → 100644
  1 +<?php
  2 +
  3 +/***
  4 +* Class documentModify.inc
  5 +*
  6 +* Contains all functions required to upload, alter and
  7 +* delete a document.
  8 +*
  9 +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  10 +* @date 13 January 2003
  11 +*/
  12 +
  13 +class DocumentModify {
  14 +
  15 + /**
  16 + * Checks if the current user has write permission for a specific folder
  17 + *
  18 + * @param $iFolderID Primary key of folder to check
  19 + *
  20 + * @return true is the user has folder write permission, false otherwise and set $_SESSION["errorMessage"]
  21 + */
  22 + function hasFolderWritePermission($iFolderID) {
  23 +
  24 + return true;
  25 + }
  26 +
  27 + /**
  28 + * Check is the user is assigned a specific role that has write permission for a folder
  29 + * *
  30 + * @param $sRoleName Name of role to check
  31 + * @param $iFolderID Primary key of folder to check
  32 + *
  33 + * @return true is the user has the role assigned, false otherwise and set $_SESSION["errorMessage"]
  34 + */
  35 + function hasWriteRoleForFolder($sRoleName, $iFolderID) {
  36 + global $default;
  37 + $iRoleID = $this->getRoleID($sRoleName);
  38 + if (!($iRoleID === false)) {
  39 + $sql = new Owl_DB();
  40 + $sql->query("SELECT * FROM " . $default->owl_folders_user_links_table . " AS FURL INNER JOIN " . $default->owl_role_table . " AS R ON FURL.role_id = R.id WHERE role_id = " . $iRoleID . " AND folder_id = " . $iFolderID . " AND user_id = " . $_SESSION["user_id"] . " AND R.can_write = 1");
  41 + if ($sql->next_record()) {
  42 + return true;
  43 + }
  44 + $_SESSION["errorMessage"] = $lang_err_user_role;
  45 + return false;
  46 + }
  47 + //error message is set in $this->getRoleID($sRoleName);
  48 + return false;
  49 +
  50 + }
  51 +
  52 + /**
  53 + * Get the primary key for a role
  54 + *
  55 + * @param $sRoleName Name of role to get primary key for
  56 + *
  57 + * @return ID if role exists, false otherwise and set $_SESSION["errorMessage"]
  58 + */
  59 + function getRoleID($sRoleName) {
  60 + global $default, $lang_database_error;
  61 + if (roleExists($sRoleName) {
  62 + $sql = new Owl_DB();
  63 + $sql->query("SELECT id FROM " . $default->owl_role_table . " WHERE name = '" . $sRoleName . "'";
  64 + sql->next_record();
  65 + return sql->f("id");
  66 + }
  67 + $_SESSION["errorMessage"] = $lang_database_error;
  68 + return false;
  69 + }
  70 +
  71 + /**
  72 + * Checks if a given role exists
  73 + *
  74 + * @param $sRoleName Role to check for
  75 + *
  76 + * @return true if role exists, false otherwise and set $_SESSION["errorMessage"]
  77 + */
  78 + function roleExists($sRoleName) {
  79 + global $default;
  80 + $sql = new Owl_DB();
  81 + $sql->query("SELECT id FROM " . $default->owl_role_table . " WHERE name = '" . $sRoleName . "'";
  82 + if (sql->next_record()) {
  83 + return true;
  84 + }
  85 + $_SESSION["errorMessage"] = $lang_err_role_not_exist . $sRoleName;
  86 + return false;
  87 + }
  88 +
  89 +}
  90 +
  91 +?>