query("INSERT INTO " . $default->owl_folders_table . " (name, description, parent_id, creator_id, document_type_id, unit_id, is_public) " . "VALUES ('" . $sName . "', '" . $sDescription . "', " . $iParentID . ", " . $iCreatorID . ", " . $iDocumentTypeID . ", " . $iUnitID . ", " . $bIsPublic . ")"); if (!$result) { $_SESSION["errorMessage"] = $lang_err_database; return false; } return true; } //error message set in folderExistsName return false; } /** * Delete and existing folder * * $iFolderID Primary key of folder to delete * * @return true on successfuly deletion, false otherwise and set $_SESSION["errorMessage"] */ function deleteFolder($iFolderID) { global $default,$lang_err_folder_not_exist; //if the folder exists if (FolderManager::folderExistsID($iFolderID)) { $sql = new Owl_DB(); $result = $sql->query("DELETE FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID); if (!$result) { $_SESSION["errorMessage"] = $lang_err_database; return false; } return true; } $_SESSION["errorMessage"] = $lang_err_folder_not_exist . "id " . $iFolderID; return false; } /** * Checks if a given folder already exists using the folder name * * @param $sName Name of folder * @param $iParentID Primary key of parent folder * * @return true if the folder exists, false otherwise and set $_SESSION["errorMessage"] */ function folderExistsName($sName, $iParentID) { $sName = addslashes($sName); global $default, $lang_err_folder_exist; $sql = new Owl_DB(); $sql->query("SELECT * FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " . $iParentID); if ($sql->next_record()) { return true; } $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName . " parent_id " . $iParentID; return false; } /** * Checks if a given folder already exists using the folder name * * @param $iFolderID Primary key of folder * * @return true if the folder exists, false otherwise and set $_SESSION["errorMessage"] */ function folderExistsID($iFolderID) { global $default, $lang_err_folder_exist; $sql = new Owl_DB(); $sql->query("SELECT * FROM " . $default->owl_folders_table . " WHERE id = " . $iFolderID); if ($sql->next_record()) { return true; } $_SESSION["errorMessage"] =$lang_err_folder_exist . "id " . $iFolderID; return false; } /** * Get a folder's primary key using the folder name and the parent id * * @param $sName Name of folder * @param $iParentID Primary key of parent folder * * @return id integer on successful lookup, false otherwise and set $_SESSION["errorMessage"] * */ function getFolderID($sName, $iParentID) { $sName = addslashes($sName); global $default, $lang_err_folder_exist; $sql = new Owl_DB(); $sql->query("SELECT id FROM " . $default->owl_folders_table . " WHERE name = '" . $sName . "' AND parent_id = " . $iParentID); if ($sql->next_record()) { return $sql->f("id"); } $_SESSION["errorMessage"] = $lang_err_folder_exist . $sName; return false; } } ?>