Commit 585efb98a68a7045659ebe4d31883b0c2d5b980d

Authored by michael
1 parent 1619e878

added archiving classes


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1880 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/archiving/ArchivingDateSettings.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents archive date settings for a document
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class ArchivingDateSettings {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The expiration date
  23 + */
  24 + var $dExpirationDate;
  25 + /**
  26 + * The expiration time period
  27 + */
  28 + var $iTimePeriodID;
  29 +
  30 + /**
  31 + * Constructs an archive date settings instance
  32 + *
  33 + * @param date the expiration date
  34 + * @param integer the expiration time period id
  35 + */
  36 + function ArchivingDateSettings($dNewExpirationDate, $iNewTimePeriodID) {
  37 + global $default;
  38 +
  39 + // primary key not set as this is not stored yet
  40 + $this->iId = -1;
  41 + $this->dExpirationDate = $dNewExpirationDate;
  42 + $this->iTimePeriodID = $iNewTimePeriodID;
  43 + }
  44 +
  45 + /**
  46 + * Gets the primary key
  47 + */
  48 + function getID(){
  49 + return $this->iId;
  50 + }
  51 +
  52 + /**
  53 + * Gets the expiration date
  54 + */
  55 + function getExpirationDate() {
  56 + return $this->dExpirationDate;
  57 + }
  58 +
  59 + /**
  60 + * Sets the expiration date
  61 + *
  62 + * @param date the new expiration date
  63 + */
  64 + function setExpirationDate($dNewExpirationDate){
  65 + $this->dExpirationDate = $dNewExpirationDate;
  66 + }
  67 +
  68 + /**
  69 + * Gets the time period id
  70 + */
  71 + function getTimePeriodID(){
  72 + return $this->iTimePeriodID;
  73 + }
  74 +
  75 + /**
  76 + * Sets the time period id
  77 + *
  78 + * @param integer the new time period id
  79 + */
  80 + function setTimePeriodID($iNewTimePeriodID){
  81 + $this->iTimePeriodID = $iNewTimePeriodID;
  82 + }
  83 +
  84 + /**
  85 + * Inserts the archive date settings into the database
  86 + *
  87 + * @return boolean true on successful update, false otherwise
  88 + */
  89 + function create(){
  90 + global $default;
  91 + //if the id >= 0, then the object has already been created
  92 + if ($this->iId < 0) {
  93 + $sql = $default->db;
  94 + $result = $sql->query("INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " .
  95 + "VALUES ('$this->dExpirationDate', $this->iTimePeriodID)");
  96 + if ($result) {
  97 + //set the current primary key
  98 + $this->iId = $sql->insert_id();
  99 + return true;
  100 + }
  101 + return false;
  102 + }
  103 + return false;
  104 + }
  105 +
  106 + /**
  107 + * Update the archive date settings current values in the database
  108 + *
  109 + * @return boolean true on successful update, false otherwise
  110 + */
  111 + function update(){
  112 + global $default;
  113 + if ($this->iId >= 0) {
  114 + $sql = $default->db;
  115 + $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " .
  116 + "expiration_date = '$this->dExpirationDate', " .
  117 + "time_period_id = $this->iTimePeriodID " .
  118 + "WHERE id = $this->iId";
  119 + $result = $sql->query($sQuery);
  120 + if ($result) {
  121 + return true;
  122 + }
  123 + return false;
  124 + }
  125 + return false;
  126 + }
  127 +
  128 + /**
  129 + * Delete the current archive date settings from the database. Set the primary key to -1
  130 + * on successful deletion
  131 + *
  132 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  133 + */
  134 + function delete() {
  135 + global $default;
  136 + if ($this->iId >= 0) {
  137 + $sql = $default->db;
  138 + $result = $sql->query("DELETE FROM $default->owl_archiving_date_settings_table WHERE id = $this->iId");
  139 + if ($result) {
  140 + $this->iId = -1;
  141 + return true;
  142 + }
  143 + return false;
  144 + }
  145 + return false;
  146 + }
  147 +
  148 + /**
  149 + * Static function. Given a news item primary key will create
  150 + * a ArchivingDateSettings object and populate it with the corresponding
  151 + * database values
  152 + *
  153 + * @return ArchivingDateSettings populated ArchivingDateSettings object on success, false otherwise
  154 + */
  155 + function & get($iArchivingDateSettingsID) {
  156 + global $default;
  157 + $sql = $default->db;
  158 + $sql->query("SELECT * FROM $default->owl_archiving_date_settings_table WHERE id = $iArchivingDateSettingsID");
  159 + if ($sql->next_record()) {
  160 + $oArchivingDateSettings = & new ArchivingDateSettings($sql->f("expiration_date"), $sql->f("time_period_id"));
  161 + $oArchivingDateSettings->iId = $iArchivingDateSettingsID;
  162 + return $oArchivingDateSettings;
  163 + }
  164 + return false;
  165 + }
  166 +
  167 + /**
  168 + * Static function
  169 + * Get a list of ArchivingDateSettings objects
  170 + *
  171 + * @param String Where clause (optional)
  172 + * @return Array array of ArchivingDateSettings objects, false otherwise
  173 + */
  174 + function getList($sWhereClause = null) {
  175 + global $default;
  176 + $aArchivingDateSettingsArray = array();
  177 + $sql = $default->db;
  178 + $result = $sql->query("SELECT * FROM $default->owl_archiving_date_settings_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  179 + if ($result) {
  180 + $iCount = 0;
  181 + while ($sql->next_record()) {
  182 + $oArchivingDateSettings = & ArchivingDateSettings::get($sql->f("id"));
  183 + $aArchivingDateSettingsArray[$iCount++] = $oArchivingDateSettings;
  184 + }
  185 + return $aArchivingDateSettingsArray;
  186 + }
  187 + return false;
  188 + }
  189 +}
0 190 \ No newline at end of file
... ...
lib/archiving/ArchivingType.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents archiving types
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class ArchivingType {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The archiving type
  23 + */
  24 + var $sName;
  25 +
  26 + /**
  27 + * Constructs an archiving type instance
  28 + *
  29 + * @param string the archiving type name
  30 + */
  31 + function ArchivingType($sNewName) {
  32 + global $default;
  33 +
  34 + // primary key not set as this is not stored yet
  35 + $this->iId = -1;
  36 + $this->sName = $sNewName;
  37 + }
  38 +
  39 + /**
  40 + * Gets the primary key
  41 + */
  42 + function getID(){
  43 + return $this->iId;
  44 + }
  45 +
  46 + /**
  47 + * Gets the name
  48 + */
  49 + function getName() {
  50 + return $this->sName;
  51 + }
  52 +
  53 + /**
  54 + * Sets the name
  55 + *
  56 + * @param string the new name
  57 + */
  58 + function setName($sNewName){
  59 + $this->sName = $sNewName;
  60 + }
  61 +
  62 + /**
  63 + * Inserts the archive type into the database
  64 + *
  65 + * @return boolean true on successful update, false otherwise
  66 + */
  67 + function create(){
  68 + global $default;
  69 + //if the id >= 0, then the object has already been created
  70 + if ($this->iId < 0) {
  71 + $sql = $default->db;
  72 + $result = $sql->query("INSERT INTO $default->owl_archiving_type_lookup_table (name) " .
  73 + "VALUES ('" . addslashes($this->sName) . "')");
  74 + if ($result) {
  75 + //set the current primary key
  76 + $this->iId = $sql->insert_id();
  77 + return true;
  78 + }
  79 + return false;
  80 + }
  81 + return false;
  82 + }
  83 +
  84 + /**
  85 + * Update the archive type's current values in the database
  86 + *
  87 + * @return boolean true on successful update, false otherwise
  88 + */
  89 + function update(){
  90 + global $default;
  91 + if ($this->iId >= 0) {
  92 + $sql = $default->db;
  93 + $sQuery = "UPDATE $default->owl_archiving_type_lookup_table SET " .
  94 + "name = '" . addslashes($this->sName) . "' " .
  95 + "WHERE id = $this->iId";
  96 + $result = $sql->query($sQuery);
  97 + if ($result) {
  98 + return true;
  99 + }
  100 + return false;
  101 + }
  102 + return false;
  103 + }
  104 +
  105 + /**
  106 + * Delete the current archive type from the database. Set the primary key to -1
  107 + * on successful deletion
  108 + *
  109 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  110 + */
  111 + function delete() {
  112 + global $default;
  113 + if ($this->iId >= 0) {
  114 + $sql = $default->db;
  115 + $result = $sql->query("DELETE FROM $default->owl_archiving_type_lookup_table WHERE id = $this->iId");
  116 + if ($result) {
  117 + $this->iId = -1;
  118 + return true;
  119 + }
  120 + return false;
  121 + }
  122 + return false;
  123 + }
  124 +
  125 + /**
  126 + * Static function. Given a news item primary key will create
  127 + * a ArchivingType object and populate it with the corresponding
  128 + * database values
  129 + *
  130 + * @return ArchivingType populated ArchivingType object on success, false otherwise
  131 + */
  132 + function & get($iArchivingTypeID) {
  133 + global $default;
  134 + $sql = $default->db;
  135 + $sql->query("SELECT * FROM $default->owl_archiving_type_lookup_table WHERE id = $iArchivingTypeID");
  136 + if ($sql->next_record()) {
  137 + $oArchivingType = & new ArchivingType($sql->f("name"));
  138 + $oArchivingType->iId = $iArchivingTypeID;
  139 + return $oArchivingType;
  140 + }
  141 + return false;
  142 + }
  143 +
  144 + /**
  145 + * Static function
  146 + * Get a list of ArchivingType objects
  147 + *
  148 + * @param String Where clause (optional)
  149 + * @return Array array of ArchivingType objects, false otherwise
  150 + */
  151 + function getList($sWhereClause = null) {
  152 + global $default;
  153 + $aArchivingTypeArray = array();
  154 + $sql = $default->db;
  155 + $result = $sql->query("SELECT * FROM $default->owl_archiving_type_lookup_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  156 + if ($result) {
  157 + $iCount = 0;
  158 + while ($sql->next_record()) {
  159 + $oArchivingType = & ArchivingType::get($sql->f("id"));
  160 + $aArchivingTypeArray[$iCount++] = $oArchivingType;
  161 + }
  162 + return $aArchivingTypeArray;
  163 + }
  164 + return false;
  165 + }
  166 +}
0 167 \ No newline at end of file
... ...
lib/archiving/ArchivingUtilisationSettings.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents archive utilisation settings for a document
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class ArchivingUtilisationSettings {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The document transaction id
  23 + */
  24 + var $iDocumentTransactionID;
  25 + /**
  26 + * The expiration time period
  27 + */
  28 + var $iTimePeriodID;
  29 +
  30 + /**
  31 + * Constructs an archive utilisation settings instance
  32 + *
  33 + * @param date the expiration date
  34 + * @param integer the expiration time period id
  35 + */
  36 + function ArchivingUtilisationSettings($iNewDocumentTransactionID, $iNewTimePeriodID) {
  37 + global $default;
  38 +
  39 + // primary key not set as this is not stored yet
  40 + $this->iId = -1;
  41 + $this->iDocumentTransactionID = $iNewDocumentTransactionID;
  42 + $this->iTimePeriodID = $iNewTimePeriodID;
  43 + }
  44 +
  45 + /**
  46 + * Gets the primary key
  47 + */
  48 + function getID(){
  49 + return $this->iId;
  50 + }
  51 +
  52 + /**
  53 + * Gets the document transaction id
  54 + */
  55 + function getDocumentTransactionID() {
  56 + return $this->iDocumentTransactionID;
  57 + }
  58 +
  59 + /**
  60 + * Sets the document transaction id
  61 + *
  62 + * @param integer the new document transaction id
  63 + */
  64 + function setDocumentTransactionID($iNewDocumentTransactionID){
  65 + $this->iDocumentTransactionID = $iNewDocumentTransactionID;
  66 + }
  67 +
  68 + /**
  69 + * Gets the time period id
  70 + */
  71 + function getTimePeriodID(){
  72 + return $this->iTimePeriodID;
  73 + }
  74 +
  75 + /**
  76 + * Sets the time period id
  77 + *
  78 + * @param integer the new time period id
  79 + */
  80 + function setTimePeriodID($iNewTimePeriodID){
  81 + $this->iTimePeriodID = $iNewTimePeriodID;
  82 + }
  83 +
  84 + /**
  85 + * Inserts the archive utilisation settings into the database
  86 + *
  87 + * @return boolean true on successful update, false otherwise
  88 + */
  89 + function create(){
  90 + global $default;
  91 + //if the id >= 0, then the object has already been created
  92 + if ($this->iId < 0) {
  93 + $sql = $default->db;
  94 + $result = $sql->query("INSERT INTO $default->owl_archiving_utilisation_settings_table (document_transaction_id, time_period_id) " .
  95 + "VALUES ($this->iDocumentTransactionID, $this->iTimePeriodID)");
  96 + if ($result) {
  97 + //set the current primary key
  98 + $this->iId = $sql->insert_id();
  99 + return true;
  100 + }
  101 + return false;
  102 + }
  103 + return false;
  104 + }
  105 +
  106 + /**
  107 + * Update the archive utilisation settings current values in the database
  108 + *
  109 + * @return boolean true on successful update, false otherwise
  110 + */
  111 + function update(){
  112 + global $default;
  113 + if ($this->iId >= 0) {
  114 + $sql = $default->db;
  115 + $sQuery = "UPDATE $default->owl_archiving_utilisation_settings_table SET " .
  116 + "document_transaction_id = $this->iDocumentTransactionID, " .
  117 + "time_period_id = $this->iTimePeriodID " .
  118 + "WHERE id = $this->iId";
  119 + $result = $sql->query($sQuery);
  120 + if ($result) {
  121 + return true;
  122 + }
  123 + return false;
  124 + }
  125 + return false;
  126 + }
  127 +
  128 + /**
  129 + * Delete the current archive utilisation settings from the database. Set the primary key to -1
  130 + * on successful deletion
  131 + *
  132 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  133 + */
  134 + function delete() {
  135 + global $default;
  136 + if ($this->iId >= 0) {
  137 + $sql = $default->db;
  138 + $result = $sql->query("DELETE FROM $default->owl_archiving_utilisation_settings_table WHERE id = $this->iId");
  139 + if ($result) {
  140 + $this->iId = -1;
  141 + return true;
  142 + }
  143 + return false;
  144 + }
  145 + return false;
  146 + }
  147 +
  148 + /**
  149 + * Static function. Given a news item primary key will create
  150 + * a ArchivingUtilisationSettings object and populate it with the corresponding
  151 + * database values
  152 + *
  153 + * @return ArchivingUtilisationSettings populated ArchivingUtilisationSettings object on success, false otherwise
  154 + */
  155 + function & get($iArchivingUtilisationSettingsID) {
  156 + global $default;
  157 + $sql = $default->db;
  158 + $sql->query("SELECT * FROM $default->owl_archiving_utilisation_settings_table WHERE id = $iArchivingUtilisationSettingsID");
  159 + if ($sql->next_record()) {
  160 + $oArchivingUtilisationSettings = & new ArchivingUtilisationSettings($sql->f("document_transaction_id"), $sql->f("time_period_id"));
  161 + $oArchivingUtilisationSettings->iId = $iArchivingUtilisationSettingsID;
  162 + return $oArchivingUtilisationSettings;
  163 + }
  164 + return false;
  165 + }
  166 +
  167 + /**
  168 + * Static function
  169 + * Get a list of ArchivingUtilisationSettings objects
  170 + *
  171 + * @param String Where clause (optional)
  172 + * @return Array array of ArchivingUtilisationSettings objects, false otherwise
  173 + */
  174 + function getList($sWhereClause = null) {
  175 + global $default;
  176 + $aArchivingUtilisationSettingsArray = array();
  177 + $sql = $default->db;
  178 + $result = $sql->query("SELECT * FROM $default->owl_archiving_utilisation_settings_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  179 + if ($result) {
  180 + $iCount = 0;
  181 + while ($sql->next_record()) {
  182 + $oArchivingUtilisationSettings = & ArchivingUtilisationSettings::get($sql->f("id"));
  183 + $aArchivingUtilisationSettingsArray[$iCount++] = $oArchivingUtilisationSettings;
  184 + }
  185 + return $aArchivingUtilisationSettingsArray;
  186 + }
  187 + return false;
  188 + }
  189 +}
0 190 \ No newline at end of file
... ...
lib/archiving/DocumentArchiving.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents archive settings for a document
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class DocumentArchiving {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The document ID
  23 + */
  24 + var $iDocumentID;
  25 + /**
  26 + * The archiving method- date or utilisation
  27 + */
  28 + var $iArchivingTypeID;
  29 + /**
  30 + * The archiving settings
  31 + */
  32 + var $iArchivingSettingsID;
  33 +
  34 + /**
  35 + * Constructs an archive settings instance
  36 + *
  37 + * @param integer the document id
  38 + * @param integer the archiving type id
  39 + * @param integer the archiving settings id
  40 + */
  41 + function DocumentArchiving($iNewDocumentID, $iNewArchivingTypeID, $iNewArchivingSettingsID) {
  42 + global $default;
  43 +
  44 + // primary key not set as this is not stored yet
  45 + $this->iId = -1;
  46 + $this->iDocumentID = $iNewDocumentID;
  47 + $this->iArchivingTypeID = $iNewArchivingTypeID;
  48 + $this->iArchivingSettingsID = $iNewArchivingSettingsID;
  49 + }
  50 +
  51 + /**
  52 + * Gets the primary key
  53 + */
  54 + function getID(){
  55 + return $this->iId;
  56 + }
  57 +
  58 + /**
  59 + * Gets the document id
  60 + */
  61 + function getDocumentID(){
  62 + return $this->iDocumentID;
  63 + }
  64 +
  65 + /**
  66 + * Sets the document id
  67 + *
  68 + * @param integer the new document id
  69 + */
  70 + function setDocumentID($iNewDocumentID){
  71 + $this->iDocumentID = $iNewDocumentID;
  72 + }
  73 +
  74 + /**
  75 + * Gets the archiving type
  76 + */
  77 + function getArchivingTypeID(){
  78 + return $this->iArchivingTypeID;
  79 + }
  80 +
  81 + /**
  82 + * Sets the archiving type
  83 + *
  84 + * @param integer the new archiving type
  85 + */
  86 + function setArchivingTypeID($iNewArchivingTypeID){
  87 + $this->iArchivingTypeID = $iNewArchivingTypeID;
  88 + }
  89 +
  90 + /**
  91 + * Gets the archiving settings
  92 + */
  93 + function getArchivingSettingsID(){
  94 + return $this->iArchivingSettingsID;
  95 + }
  96 +
  97 + /**
  98 + * Sets the archiving settings
  99 + *
  100 + * @param integer the new archiving settings
  101 + */
  102 + function setArchivingSettingsID($iNewArchivingSettingsID){
  103 + $this->iArchivingSettingsID = $iNewArchivingSettingsID;
  104 + }
  105 +
  106 + /**
  107 + * Inserts the archive settings into the database
  108 + *
  109 + * @return boolean true on successful update, false otherwise
  110 + */
  111 + function create(){
  112 + global $default;
  113 + //if the id >= 0, then the object has already been created
  114 + if ($this->iId < 0) {
  115 + $sql = $default->db;
  116 + $result = $sql->query("INSERT INTO $default->owl_document_archiving_table (document_id, archiving_type_id, archiving_settings_id) " .
  117 + "VALUES ($this->iDocumentID, $this->iArchivingTypeID, $this->iArchivingSettingsID)");
  118 + if ($result) {
  119 + //set the current primary key
  120 + $this->iId = $sql->insert_id();
  121 + return true;
  122 + }
  123 + return false;
  124 + }
  125 + return false;
  126 + }
  127 +
  128 + /**
  129 + * Update the archive settings current values in the database
  130 + *
  131 + * @return boolean true on successful update, false otherwise
  132 + */
  133 + function update(){
  134 + global $default;
  135 + if ($this->iId >= 0) {
  136 + $sql = $default->db;
  137 + $sQuery = "UPDATE $default->owl_document_archiving_table SET " .
  138 + "document_id = $this->iDocumentID, " .
  139 + "archiving_type_id = $this->iArchivingTypeID, " .
  140 + "archiving_settings_id = $this->iArchivingSettingsID " .
  141 + "WHERE id = $this->iId";
  142 + $result = $sql->query($sQuery);
  143 + if ($result) {
  144 + return true;
  145 + }
  146 + return false;
  147 + }
  148 + return false;
  149 + }
  150 +
  151 + /**
  152 + * Delete the current archive settings from the database. Set the primary key to -1
  153 + * on successful deletion
  154 + *
  155 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  156 + */
  157 + function delete() {
  158 + global $default;
  159 + if ($this->iId >= 0) {
  160 + $sql = $default->db;
  161 + $result = $sql->query("DELETE FROM $default->owl_document_archiving_table WHERE id = $this->iId");
  162 + if ($result) {
  163 + $this->iId = -1;
  164 + return true;
  165 + }
  166 + return false;
  167 + }
  168 + return false;
  169 + }
  170 +
  171 + /**
  172 + * Static function. Given a document primary key will create
  173 + * a DocumentArchiving object and populate it with the corresponding
  174 + * database values
  175 + *
  176 + * @return DocumentArchiving populated DocumentArchiving object on success, false otherwise
  177 + */
  178 + function & getFromDocumentID($iDocumentID) {
  179 + global $default;
  180 + $sql = $default->db;
  181 + $sql->query("SELECT * FROM $default->owl_document_archiving_table WHERE document_id = $iDocumentID");
  182 + if ($sql->next_record()) {
  183 + $oDocumentArchiving = & new DocumentArchiving($sql->f("document_id"), $sql->f("archiving_type_id"), $sql->f("archiving_settings_id"));
  184 + $oDocumentArchiving->iId = $sql->f("id");
  185 + return $oDocumentArchiving;
  186 + }
  187 + return false;
  188 + }
  189 +
  190 + /**
  191 + * Static function. Given a news item primary key will create
  192 + * a DocumentArchiving object and populate it with the corresponding
  193 + * database values
  194 + *
  195 + * @return DocumentArchiving populated DocumentArchiving object on success, false otherwise
  196 + */
  197 + function & get($iDocumentArchivingID) {
  198 + global $default;
  199 + $sql = $default->db;
  200 + $sql->query("SELECT * FROM $default->owl_document_archiving_table WHERE id = $iDocumentArchivingID");
  201 + if ($sql->next_record()) {
  202 + $oDocumentArchiving = & new DocumentArchiving($sql->f("document_id"), $sql->f("archiving_type_id"), $sql->f("archiving_settings_id"));
  203 + $oDocumentArchiving->iId = $iDocumentArchivingID;
  204 + return $oDocumentArchiving;
  205 + }
  206 + return false;
  207 + }
  208 +
  209 + /**
  210 + * Static function
  211 + * Get a list of DocumentArchiving objects
  212 + *
  213 + * @param String Where clause (optional)
  214 + * @return Array array of DocumentArchiving objects, false otherwise
  215 + */
  216 + function getList($sWhereClause = null) {
  217 + global $default;
  218 + $aDocumentArchivingArray = array();
  219 + $sql = $default->db;
  220 + $result = $sql->query("SELECT * FROM $default->owl_document_archiving_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  221 + if ($result) {
  222 + $iCount = 0;
  223 + while ($sql->next_record()) {
  224 + $oDocumentArchiving = & DocumentArchiving::get($sql->f("id"));
  225 + $aDocumentArchivingArray[$iCount++] = $oDocumentArchiving;
  226 + }
  227 + return $aDocumentArchivingArray;
  228 + }
  229 + return false;
  230 + }
  231 +}
0 232 \ No newline at end of file
... ...
lib/archiving/TimePeriod.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents a time period
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class TimePeriod {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The time units
  23 + */
  24 + var $iTimeUnitID;
  25 + /**
  26 + * The number of units
  27 + */
  28 + var $iUnits;
  29 +
  30 + /**
  31 + * Constructs an time period instance
  32 + *
  33 + * @param date the time unit
  34 + * @param integer the expiration time period id
  35 + */
  36 + function TimePeriod($dNewExpirationDate, $iNewTimePeriodID) {
  37 + global $default;
  38 +
  39 + // primary key not set as this is not stored yet
  40 + $this->iId = -1;
  41 + $this->iTimeUnitID = $dNewExpirationDate;
  42 + $this->iUnits = $iNewTimePeriodID;
  43 + }
  44 +
  45 + /**
  46 + * Gets the primary key
  47 + */
  48 + function getID(){
  49 + return $this->iId;
  50 + }
  51 +
  52 + /**
  53 + * Gets the time unit
  54 + */
  55 + function getTimeUnitID() {
  56 + return $this->iTimeUnitID;
  57 + }
  58 +
  59 + /**
  60 + * Sets the time unit
  61 + *
  62 + * @param integer the new time unit
  63 + */
  64 + function setTimeUnitID($iNewTimeUnitID){
  65 + $this->iTimeUnitID = $iNewTimeUnitID;
  66 + }
  67 +
  68 + /**
  69 + * Gets the units
  70 + */
  71 + function getUnits(){
  72 + return $this->iUnits;
  73 + }
  74 +
  75 + /**
  76 + * Sets the units
  77 + *
  78 + * @param integer the new units
  79 + */
  80 + function setUnits($iNewUnits){
  81 + $this->iUnits = $iNewUnits;
  82 + }
  83 +
  84 + /**
  85 + * Inserts the time period into the database
  86 + *
  87 + * @return boolean true on successful update, false otherwise
  88 + */
  89 + function create(){
  90 + global $default;
  91 + //if the id >= 0, then the object has already been created
  92 + if ($this->iId < 0) {
  93 + $sql = $default->db;
  94 + $result = $sql->query("INSERT INTO $default->owl_time_period_table (time_unit_id, units) " .
  95 + "VALUES ($this->iTimeUnitID, $this->iUnits)");
  96 + if ($result) {
  97 + //set the current primary key
  98 + $this->iId = $sql->insert_id();
  99 + return true;
  100 + }
  101 + return false;
  102 + }
  103 + return false;
  104 + }
  105 +
  106 + /**
  107 + * Update the time period current values in the database
  108 + *
  109 + * @return boolean true on successful update, false otherwise
  110 + */
  111 + function update(){
  112 + global $default;
  113 + if ($this->iId >= 0) {
  114 + $sql = $default->db;
  115 + $sQuery = "UPDATE $default->owl_time_period_table SET " .
  116 + "time_unit_id = $this->iTimeUnitID, " .
  117 + "units = $this->iUnits " .
  118 + "WHERE id = $this->iId";
  119 + $result = $sql->query($sQuery);
  120 + if ($result) {
  121 + return true;
  122 + }
  123 + return false;
  124 + }
  125 + return false;
  126 + }
  127 +
  128 + /**
  129 + * Delete the current time period from the database. Set the primary key to -1
  130 + * on successful deletion
  131 + *
  132 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  133 + */
  134 + function delete() {
  135 + global $default;
  136 + if ($this->iId >= 0) {
  137 + $sql = $default->db;
  138 + $result = $sql->query("DELETE FROM $default->owl_time_period_table WHERE id = $this->iId");
  139 + if ($result) {
  140 + $this->iId = -1;
  141 + return true;
  142 + }
  143 + return false;
  144 + }
  145 + return false;
  146 + }
  147 +
  148 + /**
  149 + * Static function. Given a primary key will create
  150 + * a TimePeriod object and populate it with the corresponding
  151 + * database values
  152 + *
  153 + * @return TimePeriod populated TimePeriod object on success, false otherwise
  154 + */
  155 + function & get($iTimePeriodID) {
  156 + global $default;
  157 + $sql = $default->db;
  158 + $sql->query("SELECT * FROM $default->owl_time_period_table WHERE id = $iTimePeriodID");
  159 + if ($sql->next_record()) {
  160 + $oTimePeriod = & new TimePeriod($sql->f("time_unit_id"), $sql->f("units"));
  161 + $oTimePeriod->iId = $iTimePeriodID;
  162 + return $oTimePeriod;
  163 + }
  164 + return false;
  165 + }
  166 +
  167 + /**
  168 + * Static function
  169 + * Get a list of TimePeriod objects
  170 + *
  171 + * @param String Where clause (optional)
  172 + * @return Array array of TimePeriod objects, false otherwise
  173 + */
  174 + function getList($sWhereClause = null) {
  175 + global $default;
  176 + $aTimePeriodArray = array();
  177 + $sql = $default->db;
  178 + $result = $sql->query("SELECT * FROM $default->owl_time_period_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  179 + if ($result) {
  180 + $iCount = 0;
  181 + while ($sql->next_record()) {
  182 + $oTimePeriod = & TimePeriod::get($sql->f("id"));
  183 + $aTimePeriodArray[$iCount++] = $oTimePeriod;
  184 + }
  185 + return $aTimePeriodArray;
  186 + }
  187 + return false;
  188 + }
  189 +}
0 190 \ No newline at end of file
... ...
lib/archiving/TimeUnit.inc 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Represents time units
  7 + *
  8 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  9 + *
  10 + * @version $Revision$
  11 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  12 + * @package lib.archiving
  13 + */
  14 +
  15 +class TimeUnit {
  16 +
  17 + /**
  18 + * The primary key
  19 + */
  20 + var $iId;
  21 + /**
  22 + * The time unit
  23 + */
  24 + var $sName;
  25 +
  26 + /**
  27 + * Constructs an time unit instance
  28 + *
  29 + * @param string the time unit name
  30 + */
  31 + function TimeUnit($sNewName) {
  32 + global $default;
  33 +
  34 + // primary key not set as this is not stored yet
  35 + $this->iId = -1;
  36 + $this->sName = $sNewName;
  37 + }
  38 +
  39 + /**
  40 + * Gets the primary key
  41 + */
  42 + function getID(){
  43 + return $this->iId;
  44 + }
  45 +
  46 + /**
  47 + * Gets the name
  48 + */
  49 + function getName() {
  50 + return $this->sName;
  51 + }
  52 +
  53 + /**
  54 + * Sets the name
  55 + *
  56 + * @param string the new name
  57 + */
  58 + function setName($sNewName){
  59 + $this->sName = $sNewName;
  60 + }
  61 +
  62 + /**
  63 + * Inserts the time unit into the database
  64 + *
  65 + * @return boolean true on successful update, false otherwise
  66 + */
  67 + function create(){
  68 + global $default;
  69 + //if the id >= 0, then the object has already been created
  70 + if ($this->iId < 0) {
  71 + $sql = $default->db;
  72 + $result = $sql->query("INSERT INTO $default->owl_time_unit_lookup_table (name) " .
  73 + "VALUES ('" . addslashes($this->sName) . "')");
  74 + if ($result) {
  75 + //set the current primary key
  76 + $this->iId = $sql->insert_id();
  77 + return true;
  78 + }
  79 + return false;
  80 + }
  81 + return false;
  82 + }
  83 +
  84 + /**
  85 + * Update the current values in the database
  86 + *
  87 + * @return boolean true on successful update, false otherwise
  88 + */
  89 + function update(){
  90 + global $default;
  91 + if ($this->iId >= 0) {
  92 + $sql = $default->db;
  93 + $sQuery = "UPDATE $default->owl_time_unit_lookup_table SET " .
  94 + "name = '" . addslashes($this->sName) . "' " .
  95 + "WHERE id = $this->iId";
  96 + $result = $sql->query($sQuery);
  97 + if ($result) {
  98 + return true;
  99 + }
  100 + return false;
  101 + }
  102 + return false;
  103 + }
  104 +
  105 + /**
  106 + * Delete the current archive type from the database. Set the primary key to -1
  107 + * on successful deletion
  108 + *
  109 + * @return boolean true and reset id to -1 on successful deletion, false otherwise
  110 + */
  111 + function delete() {
  112 + global $default;
  113 + if ($this->iId >= 0) {
  114 + $sql = $default->db;
  115 + $result = $sql->query("DELETE FROM $default->owl_time_unit_lookup_table WHERE id = $this->iId");
  116 + if ($result) {
  117 + $this->iId = -1;
  118 + return true;
  119 + }
  120 + return false;
  121 + }
  122 + return false;
  123 + }
  124 +
  125 + /**
  126 + * Static function. Given a news item primary key will create
  127 + * a TimeUnit object and populate it with the corresponding
  128 + * database values
  129 + *
  130 + * @return TimeUnit populated TimeUnit object on success, false otherwise
  131 + */
  132 + function & get($iTimeUnitID) {
  133 + global $default;
  134 + $sql = $default->db;
  135 + $sql->query("SELECT * FROM $default->owl_time_unit_lookup_table WHERE id = $iTimeUnitID");
  136 + if ($sql->next_record()) {
  137 + $oTimeUnit = & new TimeUnit($sql->f("name"));
  138 + $oTimeUnit->iId = $iTimeUnitID;
  139 + return $oTimeUnit;
  140 + }
  141 + return false;
  142 + }
  143 +
  144 + /**
  145 + * Static function
  146 + * Get a list of TimeUnit objects
  147 + *
  148 + * @param String Where clause (optional)
  149 + * @return Array array of TimeUnit objects, false otherwise
  150 + */
  151 + function getList($sWhereClause = null) {
  152 + global $default;
  153 + $aTimeUnitArray = array();
  154 + $sql = $default->db;
  155 + $result = $sql->query("SELECT * FROM $default->owl_time_unit_lookup_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));
  156 + if ($result) {
  157 + $iCount = 0;
  158 + while ($sql->next_record()) {
  159 + $oTimeUnit = & TimeUnit::get($sql->f("id"));
  160 + $aTimeUnitArray[$iCount++] = $oTimeUnit;
  161 + }
  162 + return $aTimeUnitArray;
  163 + }
  164 + return false;
  165 + }
  166 +}
0 167 \ No newline at end of file
... ...