Commit 86b49c481d41572e08d069f0b705ae60a334111f

Authored by rob
1 parent ddaa9bfa

Initial revision. Some static functions used when working with a folder


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@231 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/foldermanagement/FolderLib.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* Class FolderLib
  5 +*
  6 +* Contains static miscellaneous functions used for folder management
  7 +*/
  8 +
  9 +class FolderLib {
  10 +
  11 + /**
  12 + * Check if the folder is a public folder
  13 + *
  14 + * @param $iFolderID Primary key of folder to check
  15 + *
  16 + * @return boolean true if folder is public, false otherwise and set $_SESSION["errorMessage"]
  17 + */
  18 + function isPublicFolder($iFolderID) {
  19 + global $default, $lang_err_database;
  20 + if (FolderManager::folderExists($iFolderID)) {
  21 + $sql = new Owl_DB();
  22 + $sql->query("SELECT is_public FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
  23 + if ($sql->next_record()) {
  24 + return $sql->f("is_public");
  25 + }
  26 + $_SESSION["errorMessage"] = $lang_err_database;
  27 + return false;
  28 + }
  29 + //error message set by FolderManager::folderExists
  30 + return false;
  31 + }
  32 +
  33 + /**
  34 + * Get the document type for a folder
  35 + *
  36 + * @param $iFolderID
  37 + *
  38 + * @return integer document type primary key, false otherwise and set $_SESSION["errorMessage"]
  39 + */
  40 + function getFolderDocumentType($iFolderID) {
  41 + global $default, $lang_err_database;
  42 + if (FolderManager::folderExists($iFolderID)) {
  43 + $sql = new Owl_DB();
  44 + $sql->query("SELECT document_type_id FROM " . $default->owl_documents_table . " WHERE id = " . $iFolderID);
  45 + if ($sql->next_record()) {
  46 + return $sql->f("document_type_id");
  47 + }
  48 + $_SESSION["errorMessage"] = $lang_err_database;
  49 +
  50 + }
  51 + //error message set by FolderManager::folderExists
  52 + return false;
  53 + }
  54 +
  55 + function getFolderName($iFolderID) {
  56 +
  57 + }
  58 +
  59 + /**
  60 + * Get the primary key of the parent folder
  61 + *
  62 + * @param $iFolderID Primary key of folder to get parent for
  63 + *
  64 + * @return integer primary key of parent folder
  65 + */
  66 + function getParentFolderID($iFolderID) {
  67 + $sql = new Owl_DB();
  68 + $sql->query("SELECT parent_id FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID);
  69 + $sql->next_record();
  70 + return $sql->f("parent_id");
  71 + }
  72 +
  73 + /**
  74 + * Get the full path for a folder
  75 + *
  76 + * @param $iFolderID Primary key of folder to generate path for
  77 + * @param $sFolderName Name of folder to generate path for
  78 + *
  79 + * @return String full path of folder
  80 + */
  81 + function getFolderPath($iFolderID, $sFolderName) {
  82 + global $default;
  83 + //if the folder has a parent
  84 + if (getParentFolderID($iFolderID) != 0) {
  85 + $sCurrentPath = getFolderPath(getParentFolder($iFolderID), getFolderName($iFolderID)) . "/" . $sCurremtPath;
  86 + }
  87 + return $default->owl_fs_root . "/" . getFolderName($iFolderID);
  88 +
  89 + }
  90 +}
  91 +?>
... ...