2010-11-12 22:40:12 +00:00
< ? php
2010-11-30 12:23:46 +00:00
/**
* Implementation of the document management system
*
* @ category DMS
2013-02-14 11:10:53 +00:00
* @ package SeedDMS_Core
2010-11-30 12:23:46 +00:00
* @ license GPL 2
* @ version @ version @
* @ author Uwe Steinmann < uwe @ steinmann . cx >
* @ copyright Copyright ( C ) 2010 , Uwe Steinmann
* @ version Release : @ package_version @
*/
2010-11-12 22:40:12 +00:00
2010-11-30 12:23:46 +00:00
/**
* Include some files
*/
2010-11-22 20:42:19 +00:00
require_once ( " inc.AccessUtils.php " );
2010-11-25 21:04:53 +00:00
require_once ( " inc.FileUtils.php " );
2010-11-27 20:52:03 +00:00
require_once ( " inc.ClassAccess.php " );
2012-10-09 09:53:11 +00:00
require_once ( " inc.ClassObject.php " );
2010-11-12 22:40:12 +00:00
require_once ( " inc.ClassFolder.php " );
require_once ( " inc.ClassDocument.php " );
2010-11-27 20:52:03 +00:00
require_once ( " inc.ClassGroup.php " );
require_once ( " inc.ClassUser.php " );
require_once ( " inc.ClassKeywords.php " );
2010-12-22 19:48:08 +00:00
require_once ( " inc.ClassNotification.php " );
2012-10-09 09:53:11 +00:00
require_once ( " inc.ClassAttribute.php " );
2010-11-12 22:40:12 +00:00
/**
2010-12-22 19:48:08 +00:00
* Class to represent the complete document management system .
* This class is needed to do most of the dms operations . It needs
2013-02-14 11:10:53 +00:00
* an instance of { @ link SeedDMS_Core_DatabaseAccess } to access the
2010-12-22 19:48:08 +00:00
* underlying database . Many methods are factory functions which create
* objects representing the entities in the dms , like folders , documents ,
* users , or groups .
*
2011-01-20 14:26:02 +00:00
* Each dms has its own database for meta data and a data store for document
* content . Both must be specified when creating a new instance of this class .
* All folders and documents are organized in a hierachy like
2010-12-22 19:48:08 +00:00
* a regular file system starting with a { @ link $rootFolderID }
*
* This class does not enforce any access rights on documents and folders
* by design . It is up to the calling application to use the methods
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_Folder :: getAccessMode ()} and
* { @ link SeedDMS_Core_Document :: getAccessMode ()} and interpret them as desired .
2011-01-14 19:40:38 +00:00
* Though , there are two convinient functions to filter a list of
* documents / folders for which users have access rights for . See
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS :: filterAccess ()}
* and { @ link SeedDMS_Core_DMS :: filterUsersByAccess ()}
2010-12-22 19:48:08 +00:00
*
* Though , this class has two methods to set the currently logged in user
* ({ @ link setUser } and { @ link login }), none of them need to be called , because
2013-02-14 11:10:53 +00:00
* there is currently no class within the SeedDMS core which needs the logged
2010-12-22 19:48:08 +00:00
* in user .
*
* < code >
* < ? php
* include ( " inc/inc.ClassDMS.php " );
2013-02-14 11:10:53 +00:00
* $db = new SeedDMS_Core_DatabaseAccess ( $type , $hostname , $user , $passwd , $name );
2010-12-22 19:48:08 +00:00
* $db -> connect () or die ( " Could not connect to db-server " );
2013-02-14 11:10:53 +00:00
* $dms = new SeedDMS_Core_DMS ( $db , $contentDir );
2010-12-22 19:48:08 +00:00
* $dms -> setRootFolderID ( 1 );
* ...
* ?>
* </ code >
2010-11-12 22:40:12 +00:00
*
* @ category DMS
2013-02-14 11:10:53 +00:00
* @ package SeedDMS_Core
2010-11-30 12:23:46 +00:00
* @ version @ version @
2010-11-12 22:40:12 +00:00
* @ author Uwe Steinmann < uwe @ steinmann . cx >
* @ copyright Copyright ( C ) 2010 , Uwe Steinmann
* @ version Release : @ package_version @
*/
2013-02-14 11:10:53 +00:00
class SeedDMS_Core_DMS {
2010-11-12 22:40:12 +00:00
/**
2010-11-30 12:23:46 +00:00
* @ var object $db reference to database object . This must be an instance
2013-02-14 11:10:53 +00:00
* of { @ link SeedDMS_Core_DatabaseAccess } .
2010-11-12 22:40:12 +00:00
* @ access protected
*/
protected $db ;
2010-11-15 12:01:21 +00:00
/**
2010-11-30 12:23:46 +00:00
* @ var object $user reference to currently logged in user . This must be
2013-02-14 11:10:53 +00:00
* an instance of { @ link SeedDMS_Core_User } . This variable is currently not
2010-12-22 19:48:08 +00:00
* used . It is set by { @ link setUser } .
* @ access private
2010-11-15 12:01:21 +00:00
*/
2010-12-22 19:48:08 +00:00
private $user ;
2010-11-15 12:01:21 +00:00
2010-11-12 22:40:12 +00:00
/**
2010-11-30 12:23:46 +00:00
* @ var string $contentDir location in the file system where all the
2010-12-22 19:48:08 +00:00
* document data is located . This should be an absolute path .
2010-11-12 22:40:12 +00:00
* @ access public
*/
public $contentDir ;
2010-11-15 21:08:07 +00:00
/**
* @ var integer $rootFolderID ID of root folder
* @ access public
*/
public $rootFolderID ;
2010-11-18 10:32:10 +00:00
/**
2010-12-22 19:48:08 +00:00
* @ var boolean $enableConverting set to true if conversion of content
* is desired
2010-11-18 10:32:10 +00:00
* @ access public
*/
public $enableConverting ;
/**
* @ var array $convertFileTypes list of files types that shall be converted
* @ access public
*/
public $convertFileTypes ;
2010-11-25 21:04:53 +00:00
/**
* @ var array $viewOnlineFileTypes list of files types that can be viewed
* online
* @ access public
*/
public $viewOnlineFileTypes ;
2011-02-03 15:10:46 +00:00
/**
* @ var string $version version of pear package
* @ access public
*/
public $version ;
2013-01-24 08:29:58 +00:00
/**
* @ var array $callbacks list of methods called when certain operations ,
* like removing a document , are executed . Set a callback with
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS :: setCallback ()} .
2013-01-24 08:29:58 +00:00
* The key of the array is the internal callback function name . Each
* array element is an array with two elements : the function name
* and the parameter passed to the function .
*
* Currently implemented callbacks are :
*
* onPreRemoveDocument ( $user_param , $document );
* called before deleting a document . If this function returns false
* the document will not be deleted .
*
* onPostRemoveDocument ( $user_param , $document_id );
* called after the successful deletion of a document .
*
* @ access public
*/
public $callbacks ;
/**
* Checks if two objects are equal by comparing its ID
*
* The regular php check done by '==' compares all attributes of
* two objects , which isn ' t required . The method will first check
* if the objects are instances of the same class .
*
* @ param object $object1
* @ param object $object2
* @ return boolean true if objects are equal , otherwise false
*/
static function checkIfEqual ( $object1 , $object2 ) { /* {{{ */
if ( get_class ( $object1 ) != get_class ( $object2 ))
return false ;
if ( $object1 -> getID () != $object2 -> getID ())
return false ;
return true ;
} /* }}} */
2010-11-22 20:42:19 +00:00
/**
* Filter objects out which are not accessible in a given mode by a user .
*
* @ param array $objArr list of objects ( either documents or folders )
* @ param object $user user for which access is checked
* @ param integer $minMode minimum access mode required
* @ return array filtered list of objects
*/
static function filterAccess ( $objArr , $user , $minMode ) { /* {{{ */
if ( ! is_array ( $objArr )) {
return array ();
}
$newArr = array ();
foreach ( $objArr as $obj ) {
if ( $obj -> getAccessMode ( $user ) >= $minMode )
array_push ( $newArr , $obj );
}
return $newArr ;
} /* }}} */
/**
* Filter users out which cannot access an object in a given mode .
*
* @ param object $obj object that shall be accessed
* @ param array $users list of users which are to check for sufficient
* access rights
* @ param integer $minMode minimum access right on the object for each user
* @ return array filtered list of users
*/
static function filterUsersByAccess ( $obj , $users , $minMode ) { /* {{{ */
$newArr = array ();
foreach ( $users as $currUser ) {
if ( $obj -> getAccessMode ( $currUser ) >= $minMode )
array_push ( $newArr , $currUser );
}
return $newArr ;
} /* }}} */
2010-12-22 19:48:08 +00:00
/**
* Create a new instance of the dms
*
* @ param object $db object to access the underlying database
* @ param string $contentDir path in filesystem containing the data store
* all document contents is stored
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_DMS }
2010-12-22 19:48:08 +00:00
*/
function __construct ( $db , $contentDir ) { /* {{{ */
2010-11-12 22:40:12 +00:00
$this -> db = $db ;
2010-12-22 19:48:08 +00:00
if ( substr ( $contentDir , - 1 ) == '/' )
$this -> contentDir = $contentDir ;
else
$this -> contentDir = $contentDir . '/' ;
2010-11-15 21:08:07 +00:00
$this -> rootFolderID = 1 ;
2011-12-08 18:36:57 +00:00
$this -> maxDirID = 0 ; //31998;
2010-11-18 10:32:10 +00:00
$this -> enableAdminRevApp = false ;
$this -> enableConverting = false ;
$this -> convertFileTypes = array ();
2011-02-03 15:10:46 +00:00
$this -> version = '@package_version@' ;
if ( $this -> version [ 0 ] == '@' )
2013-01-30 09:59:43 +00:00
$this -> version = '4.0.0' ;
2010-11-15 21:08:07 +00:00
} /* }}} */
2010-11-16 09:07:19 +00:00
function getDB () { /* {{{ */
return $this -> db ;
} /* }}} */
2011-02-03 15:10:46 +00:00
/**
* Return the database version
*
* @ return array array with elements major , minor , subminor , date
*/
function getDBVersion () { /* {{{ */
$tbllist = $this -> db -> TableList ();
2011-03-23 13:28:17 +00:00
$tbllist = explode ( ',' , strtolower ( join ( ',' , $tbllist )));
if ( ! array_search ( 'tblversion' , $tbllist ))
2011-02-03 15:10:46 +00:00
return false ;
$queryStr = " SELECT * FROM tblVersion order by major,minor,subminor limit 1 " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( count ( $resArr ) != 1 )
return false ;
$resArr = $resArr [ 0 ];
return $resArr ;
} /* }}} */
/**
* Check if the version in the database is the same as of this package
* Only the major and minor version number will be checked .
*
2011-11-28 14:03:01 +00:00
* @ return boolean returns false if versions do not match , but returns
* true if version matches or table tblVersion does not exists .
2011-02-03 15:10:46 +00:00
*/
function checkVersion () { /* {{{ */
$tbllist = $this -> db -> TableList ();
2011-03-23 13:28:17 +00:00
$tbllist = explode ( ',' , strtolower ( join ( ',' , $tbllist )));
if ( ! array_search ( 'tblversion' , $tbllist ))
2011-11-28 14:03:01 +00:00
return true ;
2011-02-03 15:10:46 +00:00
$queryStr = " SELECT * FROM tblVersion order by major,minor,subminor limit 1 " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( count ( $resArr ) != 1 )
return false ;
$resArr = $resArr [ 0 ];
$ver = explode ( '.' , $this -> version );
if (( $resArr [ 'major' ] != $ver [ 0 ]) || ( $resArr [ 'minor' ] != $ver [ 1 ]))
return false ;
return true ;
} /* }}} */
2010-12-22 19:48:08 +00:00
/**
* Set id of root folder
* This function must be called right after creating an instance of
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS }
2010-12-22 19:48:08 +00:00
*
* @ param interger $id id of root folder
*/
2010-11-15 21:08:07 +00:00
function setRootFolderID ( $id ) { /* {{{ */
$this -> rootFolderID = $id ;
} /* }}} */
2010-12-22 19:48:08 +00:00
/**
2011-12-08 18:36:57 +00:00
* Set maximum number of subdirectories per directory
*
* The value of maxDirID is quite crucial because , all documents are
* associated with a directory in the filesystem . Consequently , there is
* maximum number of documents , because depending on the file system
* the maximum number of subdirectories is limited . Since version 3.3 . 0 of
2013-02-14 11:10:53 +00:00
* SeedDMS an additional directory level has been introduced . All documents
2011-12-08 18:36:57 +00:00
* from 1 to maxDirID - 1 will be saved in 1 /< docid > , documents from maxDirID
* to 2 * maxDirID - 1 are stored in 2 /< docid > and so on .
*
* This function must be called right after creating an instance of
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS }
2011-12-08 18:36:57 +00:00
*
* @ param interger $id id of root folder
*/
function setMaxDirID ( $id ) { /* {{{ */
$this -> maxDirID = $id ;
} /* }}} */
/**
2010-12-22 19:48:08 +00:00
* Get root folder
*
* @ return object / boolean return the object of the root folder or false if
* the root folder id was not set before with { @ link setRootFolderID } .
*/
2010-12-01 13:36:33 +00:00
function getRootFolder () { /* {{{ */
2010-12-22 19:48:08 +00:00
if ( ! $this -> rootFolderID ) return false ;
2010-12-01 13:36:33 +00:00
return $this -> getFolder ( $this -> rootFolderID );
} /* }}} */
2010-11-16 09:07:19 +00:00
function setEnableAdminRevApp ( $enable ) { /* {{{ */
$this -> enableAdminRevApp = $enable ;
} /* }}} */
2010-11-18 10:32:10 +00:00
function setEnableConverting ( $enable ) { /* {{{ */
$this -> enableConverting = $enable ;
} /* }}} */
function setConvertFileTypes ( $types ) { /* {{{ */
$this -> convertFileTypes = $types ;
} /* }}} */
2010-11-25 21:04:53 +00:00
function setViewOnlineFileTypes ( $types ) { /* {{{ */
$this -> viewOnlineFileTypes = $types ;
} /* }}} */
2010-11-15 12:01:21 +00:00
/**
* Login as a user
*
2010-12-22 19:48:08 +00:00
* Checks if the given credentials are valid and returns a user object .
2010-11-15 12:01:21 +00:00
* It also sets the property $user for later access on the currently
* logged in user
*
* @ param string $username login name of user
* @ param string $password password of user
*
2013-02-14 11:10:53 +00:00
* @ return object instance of class { @ link SeedDMS_Core_User } or false
2010-11-15 12:01:21 +00:00
*/
function login ( $username , $password ) { /* {{{ */
} /* }}} */
/**
* Set the logged in user
*
2010-11-23 14:56:25 +00:00
* If user authentication was done externally , this function can
2010-11-15 12:01:21 +00:00
* be used to tell the dms who is currently logged in .
*
* @ param object $user
*
*/
function setUser ( $user ) { /* {{{ */
$this -> user = $user ;
} /* }}} */
2010-11-12 22:40:12 +00:00
/**
* Return a document by its id
*
* This function retrieves a document from the database by its id .
*
* @ param integer $id internal id of document
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_Document } or false
2010-11-12 22:40:12 +00:00
*/
function getDocument ( $id ) { /* {{{ */
if ( ! is_numeric ( $id )) return false ;
2010-12-01 13:36:33 +00:00
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblDocuments WHERE id = " . ( int ) $id ;
2010-11-12 22:40:12 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( count ( $resArr ) != 1 )
return false ;
$resArr = $resArr [ 0 ];
2010-12-01 13:36:33 +00:00
2010-11-12 22:40:12 +00:00
// New Locking mechanism uses a separate table to track the lock.
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblDocumentLocks WHERE document = " . ( int ) $id ;
2010-11-12 22:40:12 +00:00
$lockArr = $this -> db -> getResultArray ( $queryStr );
if (( is_bool ( $lockArr ) && $lockArr == false ) || ( count ( $lockArr ) == 0 )) {
// Could not find a lock on the selected document.
$lock = - 1 ;
}
else {
// A lock has been identified for this document.
$lock = $lockArr [ 0 ][ " userID " ];
}
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$document = new SeedDMS_Core_Document ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " comment " ], $resArr [ " date " ], $resArr [ " expires " ], $resArr [ " owner " ], $resArr [ " folder " ], $resArr [ " inheritAccess " ], $resArr [ " defaultAccess " ], $lock , $resArr [ " keywords " ], $resArr [ " sequence " ]);
2010-11-12 22:40:12 +00:00
$document -> setDMS ( $this );
return $document ;
} /* }}} */
2010-11-22 14:49:29 +00:00
/**
* Returns all documents of a given user
*
* @ param object $user
* @ return array list of documents
*/
function getDocumentsByUser ( $user ) { /* {{{ */
2013-02-05 09:05:13 +00:00
return $user -> getDocuments ();
2010-11-22 14:49:29 +00:00
} /* }}} */
2012-08-28 07:28:16 +00:00
/**
* Returns all documents locked by a given user
* FIXME : Not full implemented . Do not use , because it still requires the
* temporary tables !
*
* @ param object $user
* @ return array list of documents
*/
function getDocumentsLockedByUser ( $user ) { /* {{{ */
2013-02-05 09:05:13 +00:00
return $user -> getDocumentsLocked ();
2012-08-28 07:28:16 +00:00
} /* }}} */
2010-12-01 13:36:33 +00:00
/**
* Returns a document by its name
*
* This function searches a document by its name and restricts the search
* to given folder if passed as the second parameter .
*
* @ param string $name
* @ param object $folder
* @ return object / boolean found document or false
*/
function getDocumentByName ( $name , $folder = null ) { /* {{{ */
if ( ! $name ) return false ;
$queryStr = " SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser` " .
" FROM `tblDocuments` " .
" LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` " .
2011-12-01 21:20:58 +00:00
" WHERE `tblDocuments`.`name` = " . $this -> db -> qstr ( $name );
2010-12-01 13:36:33 +00:00
if ( $folder )
$queryStr .= " AND `tblDocuments`.`folder` = " . $folder -> getID ();
$queryStr .= " LIMIT 1 " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
if ( ! $resArr )
return false ;
$row = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$document = new SeedDMS_Core_Document ( $row [ " id " ], $row [ " name " ], $row [ " comment " ], $row [ " date " ], $row [ " expires " ], $row [ " owner " ], $row [ " folder " ], $row [ " inheritAccess " ], $row [ " defaultAccess " ], $row [ " lockUser " ], $row [ " keywords " ], $row [ " sequence " ]);
2010-12-01 13:36:33 +00:00
$document -> setDMS ( $this );
return $document ;
} /* }}} */
2012-10-05 19:45:57 +00:00
function makeTimeStamp ( $hour , $min , $sec , $year , $month , $day ) {
$thirtyone = array ( 1 , 3 , 5 , 7 , 8 , 10 , 12 );
$thirty = array ( 4 , 6 , 9 , 11 );
// Very basic check that the terms are valid. Does not fail for illegal
// dates such as 31 Feb.
if ( ! is_numeric ( $hour ) || ! is_numeric ( $min ) || ! is_numeric ( $sec ) || ! is_numeric ( $year ) || ! is_numeric ( $month ) || ! is_numeric ( $day ) || $month < 1 || $month > 12 || $day < 1 || $day > 31 || $hour < 0 || $hour > 23 || $min < 0 || $min > 59 || $sec < 0 || $sec > 59 ) {
return false ;
}
$year = ( int ) $year ;
$month = ( int ) $month ;
$day = ( int ) $day ;
if ( array_search ( $month , $thirtyone )) {
$max = 31 ;
}
else if ( array_search ( $month , $thirty )) {
$max = 30 ;
}
else {
$max = (( $year % 4 == 0 ) && ( $year % 100 != 0 || $year % 400 == 0 )) ? 29 : 28 ;
}
// If the date falls out of bounds, set it to the maximum for the given
// month. Makes assumption about the user's intention, rather than failing
// for absolutely everything.
if ( $day > $max ) {
$day = $max ;
}
return mktime ( $hour , $min , $sec , $month , $day , $year );
}
2010-11-12 22:40:12 +00:00
/*
* Search the database for documents
*
2012-10-09 09:53:11 +00:00
* Note : the creation date will be used to check againts the
* date saved with the document
* or folder . The modification date will only be used for documents . It
* is checked against the creation date of the document content . This
* meanѕ that updateѕ of a document will only result in a searchable
* modification if a new version is uploaded .
*
2010-11-12 22:40:12 +00:00
* @ param query string seach query with space separated words
* @ param limit integer number of items in result set
* @ param offset integer index of first item in result set
2012-01-17 08:36:08 +00:00
* @ param logicalmode string either AND or OR
2010-11-12 22:40:12 +00:00
* @ param searchin array () list of fields to search in
2011-11-28 14:03:01 +00:00
* 1 = keywords , 2 = name , 3 = comment
2010-11-12 22:40:12 +00:00
* @ param startFolder object search in the folder only ( null for root folder )
* @ param owner object search for documents owned by this user
* @ param status array list of status
* @ param creationstartdate array search for documents created after this date
* @ param creationenddate array search for documents created before this date
2012-10-05 19:45:57 +00:00
* @ param modificationstartdate array search for documents modified after this date
* @ param modificationenddate array search for documents modified before this date
2011-12-06 12:31:20 +00:00
* @ param categories array list of categories the documents must have assigned
2012-10-09 09:53:11 +00:00
* @ param attributes array list of attributes
2011-12-06 12:31:20 +00:00
* @ param mode int decide whether to search for documents / folders
* 0x1 = documents only
* 0x2 = folders only
* 0x3 = both
2013-01-24 08:29:58 +00:00
* @ param expirationstartdate array search for documents expiring after this date
* @ param expirationenddate array search for documents expiring before this date
2010-11-12 22:40:12 +00:00
* @ return array containing the elements total and docs
*/
2013-01-24 08:29:58 +00:00
function search ( $query , $limit = 0 , $offset = 0 , $logicalmode = 'AND' , $searchin = array (), $startFolder = null , $owner = null , $status = array (), $creationstartdate = array (), $creationenddate = array (), $modificationstartdate = array (), $modificationenddate = array (), $categories = array (), $attributes = array (), $mode = 0x3 , $expirationstartdate = array (), $expirationenddate = array ()) { /* {{{ */
2010-11-12 22:40:12 +00:00
// Split the search string into constituent keywords.
$tkeys = array ();
if ( strlen ( $query ) > 0 ) {
2011-04-12 07:19:55 +00:00
$tkeys = preg_split ( " /[ \t \r \n ,]+/ " , $query );
2010-11-12 22:40:12 +00:00
}
2010-12-01 13:36:33 +00:00
2010-11-12 22:40:12 +00:00
// if none is checkd search all
if ( count ( $searchin ) == 0 )
2013-01-25 09:33:13 +00:00
$searchin = array ( 1 , 2 , 3 , 4 );
2010-11-12 22:40:12 +00:00
2011-11-28 14:03:01 +00:00
/*--------- Do it all over again for folders -------------*/
2011-12-06 12:31:20 +00:00
if ( $mode & 0x2 ) {
2011-11-28 14:03:01 +00:00
$searchKey = " " ;
if ( in_array ( 2 , $searchin )) {
2012-02-13 08:31:01 +00:00
$searchFields [] = " `tblFolders`.`name` " ;
2011-11-28 14:03:01 +00:00
}
if ( in_array ( 3 , $searchin )) {
2012-02-13 08:31:01 +00:00
$searchFields [] = " `tblFolders`.`comment` " ;
2011-11-28 14:03:01 +00:00
}
2012-10-09 09:53:11 +00:00
if ( in_array ( 4 , $searchin )) {
$searchFields [] = " `tblFolderAttributes`.`value` " ;
}
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
if ( count ( $searchFields ) > 0 ) {
2011-11-28 14:03:01 +00:00
foreach ( $tkeys as $key ) {
$key = trim ( $key );
if ( strlen ( $key ) > 0 ) {
2012-02-13 08:31:01 +00:00
$searchKey = ( strlen ( $searchKey ) == 0 ? " " : $searchKey . " " . $logicalmode . " " ) . " ( " . implode ( " like " . $this -> db -> qstr ( " % " . $key . " % " ) . " OR " , $searchFields ) . " like " . $this -> db -> qstr ( " % " . $key . " % " ) . " ) " ;
2011-11-28 14:03:01 +00:00
}
}
}
// Check to see if the search has been restricted to a particular sub-tree in
// the folder hierarchy.
$searchFolder = " " ;
if ( $startFolder ) {
$searchFolder = " `tblFolders`.`folderList` LIKE '%: " . $startFolder -> getID () . " :%' " ;
}
// Check to see if the search has been restricted to a particular
// document owner.
$searchOwner = " " ;
if ( $owner ) {
$searchOwner = " `tblFolders`.`owner` = ' " . $owner -> getId () . " ' " ;
}
// Is the search restricted to documents created between two specific dates?
$searchCreateDate = " " ;
if ( $creationstartdate ) {
2013-02-14 11:10:53 +00:00
$startdate = SeedDMS_Core_DMS :: makeTimeStamp ( $creationstartdate [ 'hour' ], $creationstartdate [ 'minute' ], $creationstartdate [ 'second' ], $creationstartdate [ 'year' ], $creationstartdate [ " month " ], $creationstartdate [ " day " ]);
2011-11-28 14:03:01 +00:00
if ( $startdate ) {
$searchCreateDate .= " `tblFolders`.`date` >= " . $startdate ;
}
}
if ( $creationenddate ) {
2013-02-14 11:10:53 +00:00
$stopdate = SeedDMS_Core_DMS :: makeTimeStamp ( $creationenddate [ 'hour' ], $creationstartdate [ 'minute' ], $creationstartdate [ 'second' ], $creationenddate [ " year " ], $creationenddate [ " month " ], $creationenddate [ " day " ]);
2011-11-28 14:03:01 +00:00
if ( $stopdate ) {
if ( $startdate )
$searchCreateDate .= " AND " ;
$searchCreateDate .= " `tblFolders`.`date` <= " . $stopdate ;
}
}
2012-10-09 09:53:11 +00:00
$searchQuery = " FROM `tblFolders` LEFT JOIN `tblFolderAttributes` on `tblFolders`.`id`=`tblFolderAttributes`.`folder` WHERE 1=1 " ;
2011-11-28 14:03:01 +00:00
if ( strlen ( $searchKey ) > 0 ) {
$searchQuery .= " AND ( " . $searchKey . " ) " ;
}
if ( strlen ( $searchFolder ) > 0 ) {
$searchQuery .= " AND " . $searchFolder ;
}
if ( strlen ( $searchOwner ) > 0 ) {
$searchQuery .= " AND ( " . $searchOwner . " ) " ;
}
if ( strlen ( $searchCreateDate ) > 0 ) {
$searchQuery .= " AND ( " . $searchCreateDate . " ) " ;
}
2012-09-14 10:47:03 +00:00
/* Do not search for folders if not at least a search for a key ,
* an owner , or creation date is requested .
*/
2013-02-26 14:00:59 +00:00
$totalFolders = 0 ;
2012-09-14 10:47:03 +00:00
if ( $searchKey || $searchOwner || $searchCreateDate ) {
// Count the number of rows that the search will produce.
2012-12-13 21:23:34 +00:00
$resArr = $this -> db -> getResultArray ( " SELECT COUNT(*) AS num " . $searchQuery );
if ( $resArr && isset ( $resArr [ 0 ]) && is_numeric ( $resArr [ 0 ][ " num " ]) && $resArr [ 0 ][ " num " ] > 0 ) {
2012-09-14 10:47:03 +00:00
$totalFolders = ( integer ) $resArr [ 0 ][ " num " ];
}
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
// If there are no results from the count query, then there is no real need
// to run the full query. TODO: re-structure code to by-pass additional
// queries when no initial results are found.
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
// Only search if the offset is not beyond the number of folders
if ( $totalFolders > $offset ) {
// Prepare the complete search query, including the LIMIT clause.
2012-12-13 21:23:34 +00:00
$searchQuery = " SELECT DISTINCT `tblFolders`.* " . $searchQuery . " GROUP BY `tblFolders`.`id` " ;
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
if ( $limit ) {
$searchQuery .= " LIMIT " . $offset . " , " . $limit ;
}
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
// Send the complete search query to the database.
$resArr = $this -> db -> getResultArray ( $searchQuery );
} else {
$resArr = array ();
}
2011-11-28 14:03:01 +00:00
2012-09-14 10:47:03 +00:00
// ------------------- Ausgabe der Ergebnisse ----------------------------
$numResults = count ( $resArr );
if ( $numResults == 0 ) {
$folderresult = array ( 'totalFolders' => $totalFolders , 'folders' => array ());
} else {
foreach ( $resArr as $folderArr ) {
$folders [] = $this -> getFolder ( $folderArr [ 'id' ]);
}
$folderresult = array ( 'totalFolders' => $totalFolders , 'folders' => $folders );
2011-11-28 14:03:01 +00:00
}
2012-09-14 10:47:03 +00:00
} else {
$folderresult = array ( 'totalFolders' => 0 , 'folders' => array ());
2011-11-28 14:03:01 +00:00
}
} else {
$folderresult = array ( 'totalFolders' => 0 , 'folders' => array ());
}
/*--------- Do it all over again for documents -------------*/
2011-12-06 12:31:20 +00:00
if ( $mode & 0x1 ) {
$searchKey = " " ;
2012-02-13 08:31:01 +00:00
$searchFields = array ();
2011-12-06 12:31:20 +00:00
if ( in_array ( 1 , $searchin )) {
2012-02-13 08:31:01 +00:00
$searchFields [] = " `tblDocuments`.`keywords` " ;
2011-12-06 12:31:20 +00:00
}
if ( in_array ( 2 , $searchin )) {
2012-02-13 08:31:01 +00:00
$searchFields [] = " `tblDocuments`.`name` " ;
2011-12-06 12:31:20 +00:00
}
if ( in_array ( 3 , $searchin )) {
2012-02-13 08:31:01 +00:00
$searchFields [] = " `tblDocuments`.`comment` " ;
2011-12-06 12:31:20 +00:00
}
2012-10-09 09:53:11 +00:00
if ( in_array ( 4 , $searchin )) {
$searchFields [] = " `tblDocumentAttributes`.`value` " ;
$searchFields [] = " `tblDocumentContentAttributes`.`value` " ;
}
2010-12-01 13:36:33 +00:00
2012-09-14 10:47:03 +00:00
if ( count ( $searchFields ) > 0 ) {
2011-12-06 12:31:20 +00:00
foreach ( $tkeys as $key ) {
$key = trim ( $key );
if ( strlen ( $key ) > 0 ) {
2012-02-13 08:31:01 +00:00
$searchKey = ( strlen ( $searchKey ) == 0 ? " " : $searchKey . " " . $logicalmode . " " ) . " ( " . implode ( " like " . $this -> db -> qstr ( " % " . $key . " % " ) . " OR " , $searchFields ) . " like " . $this -> db -> qstr ( " % " . $key . " % " ) . " ) " ;
2011-12-06 12:31:20 +00:00
}
2010-11-12 22:40:12 +00:00
}
}
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
// Check to see if the search has been restricted to a particular sub-tree in
// the folder hierarchy.
$searchFolder = " " ;
if ( $startFolder ) {
$searchFolder = " `tblDocuments`.`folderList` LIKE '%: " . $startFolder -> getID () . " :%' " ;
}
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
// Check to see if the search has been restricted to a particular
// document owner.
$searchOwner = " " ;
if ( $owner ) {
$searchOwner = " `tblDocuments`.`owner` = ' " . $owner -> getId () . " ' " ;
}
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
// Check to see if the search has been restricted to a particular
// document category.
$searchCategories = " " ;
if ( $categories ) {
$catids = array ();
foreach ( $categories as $category )
$catids [] = $category -> getId ();
$searchCategories = " `tblDocumentCategory`.`categoryID` in ( " . implode ( ',' , $catids ) . " ) " ;
}
2011-03-10 14:27:05 +00:00
2012-10-09 09:53:11 +00:00
// Check to see if the search has been restricted to a particular
// attribute.
$searchAttributes = array ();
if ( $attributes ) {
foreach ( $attributes as $attrdefid => $attribute ) {
if ( $attribute ) {
$attrdef = $this -> getAttributeDefinition ( $attrdefid );
2013-02-14 11:10:53 +00:00
if ( $attrdef -> getObjType () == SeedDMS_Core_AttributeDefinition :: objtype_document ) {
2012-10-09 09:53:11 +00:00
if ( $attrdef -> getValueSet ())
$searchAttributes [] = " `tblDocumentAttributes`.`attrdef`= " . $attrdefid . " AND `tblDocumentAttributes`.`value`=' " . $attribute . " ' " ;
else
$searchAttributes [] = " `tblDocumentAttributes`.`attrdef`= " . $attrdefid . " AND `tblDocumentAttributes`.`value` like '% " . $attribute . " %' " ;
2013-02-14 11:10:53 +00:00
} elseif ( $attrdef -> getObjType () == SeedDMS_Core_AttributeDefinition :: objtype_documentcontent ) {
2012-10-09 09:53:11 +00:00
if ( $attrdef -> getValueSet ())
$searchAttributes [] = " `tblDocumentContentAttributes`.`attrdef`= " . $attrdefid . " AND `tblDocumentContentAttributes`.`value`=' " . $attribute . " ' " ;
else
$searchAttributes [] = " `tblDocumentContentAttributes`.`attrdef`= " . $attrdefid . " AND `tblDocumentContentAttributes`.`value` like '% " . $attribute . " %' " ;
}
}
}
}
2011-12-06 12:31:20 +00:00
// Is the search restricted to documents created between two specific dates?
$searchCreateDate = " " ;
if ( $creationstartdate ) {
2013-02-14 11:10:53 +00:00
$startdate = SeedDMS_Core_DMS :: makeTimeStamp ( $creationstartdate [ 'hour' ], $creationstartdate [ 'minute' ], $creationstartdate [ 'second' ], $creationstartdate [ 'year' ], $creationstartdate [ " month " ], $creationstartdate [ " day " ]);
2011-12-06 12:31:20 +00:00
if ( $startdate ) {
$searchCreateDate .= " `tblDocuments`.`date` >= " . $startdate ;
}
2010-11-12 22:40:12 +00:00
}
2011-12-06 12:31:20 +00:00
if ( $creationenddate ) {
2013-02-14 11:10:53 +00:00
$stopdate = SeedDMS_Core_DMS :: makeTimeStamp ( $creationenddate [ 'hour' ], $creationenddate [ 'minute' ], $creationenddate [ 'second' ], $creationenddate [ " year " ], $creationenddate [ " month " ], $creationenddate [ " day " ]);
2011-12-06 12:31:20 +00:00
if ( $stopdate ) {
2012-10-05 19:45:57 +00:00
if ( $searchCreateDate )
2011-12-06 12:31:20 +00:00
$searchCreateDate .= " AND " ;
$searchCreateDate .= " `tblDocuments`.`date` <= " . $stopdate ;
}
2010-11-12 22:40:12 +00:00
}
2012-10-05 19:45:57 +00:00
if ( $modificationstartdate ) {
2013-02-14 11:10:53 +00:00
$startdate = SeedDMS_Core_DMS :: makeTimeStamp ( $modificationstartdate [ 'hour' ], $modificationstartdate [ 'minute' ], $modificationstartdate [ 'second' ], $modificationstartdate [ 'year' ], $modificationstartdate [ " month " ], $modificationstartdate [ " day " ]);
2012-10-05 19:45:57 +00:00
if ( $startdate ) {
if ( $searchCreateDate )
$searchCreateDate .= " AND " ;
$searchCreateDate .= " `tblDocumentContent`.`date` >= " . $startdate ;
}
}
if ( $modificationenddate ) {
2013-02-14 11:10:53 +00:00
$stopdate = SeedDMS_Core_DMS :: makeTimeStamp ( $modificationenddate [ 'hour' ], $modificationenddate [ 'minute' ], $modificationenddate [ 'second' ], $modificationenddate [ " year " ], $modificationenddate [ " month " ], $modificationenddate [ " day " ]);
2012-10-05 19:45:57 +00:00
if ( $stopdate ) {
if ( $searchCreateDate )
$searchCreateDate .= " AND " ;
$searchCreateDate .= " `tblDocumentContent`.`date` <= " . $stopdate ;
}
}
2013-01-24 08:29:58 +00:00
$searchExpirationDate = '' ;
if ( $expirationstartdate ) {
2013-02-14 11:10:53 +00:00
$startdate = SeedDMS_Core_DMS :: makeTimeStamp ( $expirationstartdate [ 'hour' ], $expirationstartdate [ 'minute' ], $expirationstartdate [ 'second' ], $expirationstartdate [ 'year' ], $expirationstartdate [ " month " ], $expirationstartdate [ " day " ]);
2013-01-24 08:29:58 +00:00
if ( $startdate ) {
if ( $searchExpirationDate )
$searchExpirationDate .= " AND " ;
$searchExpirationDate .= " `tblDocuments`.`expires` >= " . $startdate ;
}
}
if ( $expirationenddate ) {
2013-02-14 11:10:53 +00:00
$stopdate = SeedDMS_Core_DMS :: makeTimeStamp ( $expirationenddate [ 'hour' ], $expirationenddate [ 'minute' ], $expirationenddate [ 'second' ], $expirationenddate [ " year " ], $expirationenddate [ " month " ], $expirationenddate [ " day " ]);
2013-01-24 08:29:58 +00:00
if ( $stopdate ) {
if ( $searchExpirationDate )
$searchExpirationDate .= " AND " ;
$searchExpirationDate .= " `tblDocuments`.`expires` <= " . $stopdate ;
}
}
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
// ---------------------- Suche starten ----------------------------------
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
//
// Construct the SQL query that will be used to search the database.
//
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
if ( ! $this -> db -> createTemporaryTable ( " ttcontentid " ) || ! $this -> db -> createTemporaryTable ( " ttstatid " )) {
return false ;
}
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
$searchQuery = " FROM `tblDocumentContent` " .
" LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` " .
2012-10-09 09:53:11 +00:00
" LEFT JOIN `tblDocumentAttributes` ON `tblDocuments`.`id` = `tblDocumentAttributes`.`document` " .
" LEFT JOIN `tblDocumentContentAttributes` ON `tblDocumentContent`.`id` = `tblDocumentContentAttributes`.`content` " .
2011-12-06 12:31:20 +00:00
" LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` " .
" LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusID` = `tblDocumentStatus`.`statusID` " .
" LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` " .
" LEFT JOIN `ttcontentid` ON `ttcontentid`.`maxVersion` = `tblDocumentStatus`.`version` AND `ttcontentid`.`document` = `tblDocumentStatus`.`documentID` " .
" LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` " .
" LEFT JOIN `tblDocumentCategory` ON `tblDocuments`.`id`=`tblDocumentCategory`.`documentID` " .
" WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` " .
" AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` " ;
2010-12-01 13:36:33 +00:00
2011-12-06 12:31:20 +00:00
if ( strlen ( $searchKey ) > 0 ) {
$searchQuery .= " AND ( " . $searchKey . " ) " ;
}
if ( strlen ( $searchFolder ) > 0 ) {
$searchQuery .= " AND " . $searchFolder ;
}
if ( strlen ( $searchOwner ) > 0 ) {
$searchQuery .= " AND ( " . $searchOwner . " ) " ;
}
if ( strlen ( $searchCategories ) > 0 ) {
$searchQuery .= " AND ( " . $searchCategories . " ) " ;
}
if ( strlen ( $searchCreateDate ) > 0 ) {
$searchQuery .= " AND ( " . $searchCreateDate . " ) " ;
}
2013-01-24 08:29:58 +00:00
if ( strlen ( $searchExpirationDate ) > 0 ) {
$searchQuery .= " AND ( " . $searchExpirationDate . " ) " ;
}
2012-10-09 09:53:11 +00:00
if ( $searchAttributes ) {
$searchQuery .= " AND ( " . implode ( " AND " , $searchAttributes ) . " ) " ;
}
2010-11-12 22:40:12 +00:00
2011-12-06 12:31:20 +00:00
// status
if ( $status ) {
$searchQuery .= " AND `tblDocumentStatusLog`.`status` IN ( " . implode ( ',' , $status ) . " ) " ;
}
// Count the number of rows that the search will produce.
2013-01-30 09:59:43 +00:00
$resArr = $this -> db -> getResultArray ( " SELECT COUNT(*) AS num FROM (SELECT DISTINCT `tblDocuments`.id " . $searchQuery . " ) a " );
2011-12-06 12:31:20 +00:00
$totalDocs = 0 ;
if ( is_numeric ( $resArr [ 0 ][ " num " ]) && $resArr [ 0 ][ " num " ] > 0 ) {
$totalDocs = ( integer ) $resArr [ 0 ][ " num " ];
}
2010-11-12 22:40:12 +00:00
2011-12-06 12:31:20 +00:00
// If there are no results from the count query, then there is no real need
// to run the full query. TODO: re-structure code to by-pass additional
// queries when no initial results are found.
// Prepare the complete search query, including the LIMIT clause.
2012-10-09 09:53:11 +00:00
$searchQuery = " SELECT DISTINCT `tblDocuments`.*, " .
2011-12-06 12:31:20 +00:00
" `tblDocumentContent`.`version`, " .
" `tblDocumentStatusLog`.`status`, `tblDocumentLocks`.`userID` as `lockUser` " . $searchQuery ;
// calculate the remaining entrїes of the current page
// If page is not full yet, get remaining entries
2013-01-24 08:29:58 +00:00
if ( $limit ) {
$remain = $limit - count ( $folderresult [ 'folders' ]);
if ( $remain ) {
if ( $remain == $limit )
$offset -= $totalFolders ;
else
$offset = 0 ;
if ( $limit )
$searchQuery .= " LIMIT " . $offset . " , " . $remain ;
2011-12-06 12:31:20 +00:00
2013-01-24 08:29:58 +00:00
// Send the complete search query to the database.
$resArr = $this -> db -> getResultArray ( $searchQuery );
} else {
$resArr = array ();
}
} else {
2011-12-06 12:31:20 +00:00
// Send the complete search query to the database.
$resArr = $this -> db -> getResultArray ( $searchQuery );
}
// ------------------- Ausgabe der Ergebnisse ----------------------------
$numResults = count ( $resArr );
if ( $numResults == 0 ) {
$docresult = array ( 'totalDocs' => $totalDocs , 'docs' => array ());
} else {
foreach ( $resArr as $docArr ) {
$docs [] = $this -> getDocument ( $docArr [ 'id' ]);
}
$docresult = array ( 'totalDocs' => $totalDocs , 'docs' => $docs );
}
} else {
$docresult = array ( 'totalDocs' => 0 , 'docs' => array ());
2010-11-12 22:40:12 +00:00
}
2011-12-06 12:31:20 +00:00
2010-11-12 22:40:12 +00:00
if ( $limit ) {
2011-11-28 14:03:01 +00:00
$totalPages = ( integer )(( $totalDocs + $totalFolders ) / $limit );
if ((( $totalDocs + $totalFolders ) % $limit ) > 0 ) {
2010-11-12 22:40:12 +00:00
$totalPages ++ ;
}
} else {
$totalPages = 1 ;
}
2010-12-01 13:36:33 +00:00
2011-11-28 14:03:01 +00:00
return array_merge ( $docresult , $folderresult , array ( 'totalPages' => $totalPages ));
2010-11-12 22:40:12 +00:00
} /* }}} */
/**
* Return a folder by its id
*
* This function retrieves a folder from the database by its id .
*
* @ param integer $id internal id of folder
2013-02-14 11:10:53 +00:00
* @ return object instance of SeedDMS_Core_Folder or false
2010-11-12 22:40:12 +00:00
*/
function getFolder ( $id ) { /* {{{ */
if ( ! is_numeric ( $id )) return false ;
2010-12-01 13:36:33 +00:00
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblFolders WHERE id = " . ( int ) $id ;
2010-11-12 22:40:12 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-12 22:40:12 +00:00
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
else if ( count ( $resArr ) != 1 )
return false ;
2010-12-01 13:36:33 +00:00
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$folder = new SeedDMS_Core_Folder ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " parent " ], $resArr [ " comment " ], $resArr [ " date " ], $resArr [ " owner " ], $resArr [ " inheritAccess " ], $resArr [ " defaultAccess " ], $resArr [ " sequence " ]);
2010-12-01 13:36:33 +00:00
$folder -> setDMS ( $this );
return $folder ;
} /* }}} */
/**
* Return a folder by its name
*
2010-12-22 19:48:08 +00:00
* This function retrieves a folder from the database by its name . The
* search covers the whole database . If
* the parameter $folder is not null , it will search for the name
* only within this parent folder . It will not be done recursively .
2010-12-01 13:36:33 +00:00
*
2010-12-22 19:48:08 +00:00
* @ param string $name name of the folder
* @ param object $folder parent folder
2010-12-01 13:36:33 +00:00
* @ return object / boolean found folder or false
*/
function getFolderByName ( $name , $folder = null ) { /* {{{ */
if ( ! $name ) return false ;
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblFolders WHERE name = " . $this -> db -> qstr ( $name );
2010-12-01 13:36:33 +00:00
if ( $folder )
$queryStr .= " AND `parent` = " . $folder -> getID ();
$queryStr .= " LIMIT 1 " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( ! $resArr )
return false ;
2010-11-12 22:40:12 +00:00
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$folder = new SeedDMS_Core_Folder ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " parent " ], $resArr [ " comment " ], $resArr [ " date " ], $resArr [ " owner " ], $resArr [ " inheritAccess " ], $resArr [ " defaultAccess " ], $resArr [ " sequence " ]);
2010-11-12 22:40:12 +00:00
$folder -> setDMS ( $this );
return $folder ;
} /* }}} */
2010-11-15 12:01:21 +00:00
/**
* Return a user by its id
*
* This function retrieves a user from the database by its id .
*
* @ param integer $id internal id of user
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_User } or false
2010-11-15 12:01:21 +00:00
*/
function getUser ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
2010-12-01 13:36:33 +00:00
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblUsers WHERE id = " . ( int ) $id ;
2010-11-15 12:01:21 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
$resArr = $resArr [ 0 ];
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$user = new SeedDMS_Core_User ( $resArr [ " id " ], $resArr [ " login " ], $resArr [ " pwd " ], $resArr [ " fullName " ], $resArr [ " email " ], $resArr [ " language " ], $resArr [ " theme " ], $resArr [ " comment " ], $resArr [ " role " ], $resArr [ " hidden " ], $resArr [ " disabled " ], $resArr [ " pwdExpiration " ], $resArr [ " loginfailures " ], $resArr [ " quota " ]);
2010-11-15 21:08:07 +00:00
$user -> setDMS ( $this );
return $user ;
2010-11-15 12:01:21 +00:00
} /* }}} */
/**
* Return a user by its login
*
* This function retrieves a user from the database by its login .
2011-10-07 16:14:31 +00:00
* If the second optional parameter $email is not empty , the user must
2012-01-26 13:23:22 +00:00
* also have the given email .
2010-11-15 12:01:21 +00:00
*
2011-10-07 16:14:31 +00:00
* @ param string $login internal login of user
* @ param string $email email of user
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_User } or false
2010-11-15 12:01:21 +00:00
*/
2011-10-07 16:14:31 +00:00
function getUserByLogin ( $login , $email = '' ) { /* {{{ */
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblUsers WHERE login = " . $this -> db -> qstr ( $login );
2011-10-07 16:14:31 +00:00
if ( $email )
2011-12-01 21:20:58 +00:00
$queryStr .= " AND email= " . $this -> db -> qstr ( $email );
2011-10-07 16:14:31 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$user = new SeedDMS_Core_User ( $resArr [ " id " ], $resArr [ " login " ], $resArr [ " pwd " ], $resArr [ " fullName " ], $resArr [ " email " ], $resArr [ " language " ], $resArr [ " theme " ], $resArr [ " comment " ], $resArr [ " role " ], $resArr [ " hidden " ], $resArr [ " disabled " ], $resArr [ " pwdExpiration " ], $resArr [ " loginfailures " ], $resArr [ " quota " ]);
2011-10-07 16:14:31 +00:00
$user -> setDMS ( $this );
return $user ;
} /* }}} */
/**
* Return a user by its email
*
* This function retrieves a user from the database by its email .
* It is needed when the user requests a new password .
*
* @ param integer $email email address of user
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_User } or false
2011-10-07 16:14:31 +00:00
*/
function getUserByEmail ( $email ) { /* {{{ */
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblUsers WHERE email = " . $this -> db -> qstr ( $email );
2010-11-15 12:01:21 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
$resArr = $resArr [ 0 ];
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$user = new SeedDMS_Core_User ( $resArr [ " id " ], $resArr [ " login " ], $resArr [ " pwd " ], $resArr [ " fullName " ], $resArr [ " email " ], $resArr [ " language " ], $resArr [ " theme " ], $resArr [ " comment " ], $resArr [ " role " ], $resArr [ " hidden " ], $resArr [ " disabled " ], $resArr [ " pwdExpiration " ], $resArr [ " loginfailures " ], $resArr [ " quota " ]);
2010-11-15 21:08:07 +00:00
$user -> setDMS ( $this );
return $user ;
2010-11-15 12:01:21 +00:00
} /* }}} */
2011-01-11 09:06:59 +00:00
/**
* Return list of all users
*
2013-02-14 11:10:53 +00:00
* @ return array of instances of { @ link SeedDMS_Core_User } or false
2011-01-11 09:06:59 +00:00
*/
2012-08-28 07:28:16 +00:00
function getAllUsers ( $orderby = '' ) { /* {{{ */
if ( $orderby == 'fullname' )
$queryStr = " SELECT * FROM tblUsers ORDER BY fullname " ;
else
$queryStr = " SELECT * FROM tblUsers ORDER BY login " ;
2010-11-15 12:01:21 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
$users = array ();
2010-12-01 13:36:33 +00:00
2010-11-15 21:08:07 +00:00
for ( $i = 0 ; $i < count ( $resArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$user = new SeedDMS_Core_User ( $resArr [ $i ][ " id " ], $resArr [ $i ][ " login " ], $resArr [ $i ][ " pwd " ], $resArr [ $i ][ " fullName " ], $resArr [ $i ][ " email " ], ( isset ( $resArr [ " language " ]) ? $resArr [ " language " ] : NULL ), ( isset ( $resArr [ " theme " ]) ? $resArr [ " theme " ] : NULL ), $resArr [ $i ][ " comment " ], $resArr [ $i ][ " role " ], $resArr [ $i ][ " hidden " ], $resArr [ $i ][ " disabled " ], $resArr [ $i ][ " pwdExpiration " ], $resArr [ $i ][ " loginfailures " ], $resArr [ $i ][ " quota " ]);
2010-11-15 21:08:07 +00:00
$user -> setDMS ( $this );
$users [ $i ] = $user ;
}
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
return $users ;
} /* }}} */
2010-12-01 13:36:33 +00:00
2011-01-11 09:06:59 +00:00
/**
* Add a new user
*
* @ param string $login login name
* @ param string $pwd password of new user
* @ param string $email Email of new user
* @ param string $language language of new user
* @ param string $comment comment of new user
* @ param integer $role role of new user ( can be 0 = normal , 1 = admin , 2 = guest )
* @ param integer $isHidden hide user in all lists , if this is set login
* is still allowed
2012-08-28 07:28:16 +00:00
* @ param integer $isDisabled disable user and prevent login
2013-02-14 11:10:53 +00:00
* @ return object of { @ link SeedDMS_Core_User }
2011-01-11 09:06:59 +00:00
*/
2012-08-28 07:28:16 +00:00
function addUser ( $login , $pwd , $fullName , $email , $language , $theme , $comment , $role = '0' , $isHidden = 0 , $isDisabled = 0 , $pwdexpiration = '' ) { /* {{{ */
2012-09-11 12:58:30 +00:00
$db = $this -> db ;
2010-11-15 12:01:21 +00:00
if ( is_object ( $this -> getUserByLogin ( $login ))) {
return false ;
}
2011-12-01 21:20:58 +00:00
if ( $role == '' )
$role = '0' ;
2012-09-11 12:58:30 +00:00
$queryStr = " INSERT INTO tblUsers (login, pwd, fullName, email, language, theme, comment, role, hidden, disabled, pwdExpiration) VALUES ( " . $db -> qstr ( $login ) . " , " . $db -> qstr ( $pwd ) . " , " . $db -> qstr ( $fullName ) . " , " . $db -> qstr ( $email ) . " , ' " . $language . " ', ' " . $theme . " ', " . $db -> qstr ( $comment ) . " , ' " . intval ( $role ) . " ', ' " . intval ( $isHidden ) . " ', ' " . intval ( $isDisabled ) . " ', " . $db -> qstr ( $pwdexpiration ) . " ) " ;
2010-11-15 12:01:21 +00:00
$res = $this -> db -> getResult ( $queryStr );
if ( ! $res )
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
return $this -> getUser ( $this -> db -> getInsertID ());
} /* }}} */
2010-12-22 19:48:08 +00:00
/**
* Get a group by its id
*
* @ param integer $id id of group
* @ return object / boolean group or false if no group was found
*/
2010-11-15 12:01:21 +00:00
function getGroup ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
2011-03-10 14:27:05 +00:00
return false ;
2010-12-01 13:36:33 +00:00
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblGroups WHERE id = " . ( int ) $id ;
2010-11-15 12:01:21 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
else if ( count ( $resArr ) != 1 ) //wenn, dann wohl eher 0 als > 1 ;-)
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
$resArr = $resArr [ 0 ];
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$group = new SeedDMS_Core_Group ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " comment " ]);
2010-11-15 21:08:07 +00:00
$group -> setDMS ( $this );
return $group ;
2010-11-15 12:01:21 +00:00
} /* }}} */
2010-12-22 19:48:08 +00:00
/**
* Get a group by its name
*
* @ param string $name name of group
* @ return object / boolean group or false if no group was found
*/
2010-11-15 12:01:21 +00:00
function getGroupByName ( $name ) { /* {{{ */
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT `tblGroups`.* FROM `tblGroups` WHERE `tblGroups`.`name` = " . $this -> db -> qstr ( $name );
2010-11-15 12:01:21 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
else if ( count ( $resArr ) != 1 ) //wenn, dann wohl eher 0 als > 1 ;-)
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
$resArr = $resArr [ 0 ];
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$group = new SeedDMS_Core_Group ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " comment " ]);
2010-11-15 21:08:07 +00:00
$group -> setDMS ( $this );
return $group ;
} /* }}} */
2010-11-30 12:23:46 +00:00
/**
* Get a list of all groups
*
2013-02-14 11:10:53 +00:00
* @ return array array of instances of { @ link SeedDMS_Core_Group }
2010-11-30 12:23:46 +00:00
*/
2010-11-15 21:08:07 +00:00
function getAllGroups () { /* {{{ */
$queryStr = " SELECT * FROM tblGroups ORDER BY name " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
2010-12-01 13:36:33 +00:00
2010-11-15 21:08:07 +00:00
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 21:08:07 +00:00
$groups = array ();
2010-12-01 13:36:33 +00:00
2010-11-15 21:08:07 +00:00
for ( $i = 0 ; $i < count ( $resArr ); $i ++ ) {
2010-12-01 13:36:33 +00:00
2013-02-14 11:10:53 +00:00
$group = new SeedDMS_Core_Group ( $resArr [ $i ][ " id " ], $resArr [ $i ][ " name " ], $resArr [ $i ][ " comment " ]);
2010-11-15 21:08:07 +00:00
$group -> setDMS ( $this );
$groups [ $i ] = $group ;
}
2010-12-01 13:36:33 +00:00
2010-11-15 21:08:07 +00:00
return $groups ;
2010-11-15 12:01:21 +00:00
} /* }}} */
2010-11-30 12:23:46 +00:00
/**
* Create a new user group
*
* @ param string $name name of group
* @ param string $comment comment of group
2013-02-14 11:10:53 +00:00
* @ return object / boolean instance of { @ link SeedDMS_Core_Group } or false in
2010-11-30 12:23:46 +00:00
* case of an error .
*/
2010-11-15 12:01:21 +00:00
function addGroup ( $name , $comment ) { /* {{{ */
if ( is_object ( $this -> getGroupByName ( $name ))) {
return false ;
}
2012-09-11 12:58:30 +00:00
$queryStr = " INSERT INTO tblGroups (name, comment) VALUES ( " . $this -> db -> qstr ( $name ) . " , " . $this -> db -> qstr ( $comment ) . " ) " ;
2010-11-15 12:01:21 +00:00
if ( ! $this -> db -> getResult ( $queryStr ))
return false ;
2010-12-01 13:36:33 +00:00
2010-11-15 12:01:21 +00:00
return $this -> getGroup ( $this -> db -> getInsertID ());
} /* }}} */
2010-11-27 20:52:03 +00:00
function getKeywordCategory ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
2011-03-10 14:27:05 +00:00
return false ;
2010-11-27 20:52:03 +00:00
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblKeywordCategories WHERE id = " . ( int ) $id ;
2010-11-27 20:52:03 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if (( is_bool ( $resArr ) && ! $resArr ) || ( count ( $resArr ) != 1 ))
return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_Keywordcategory ( $resArr [ " id " ], $resArr [ " owner " ], $resArr [ " name " ]);
2010-11-27 20:52:03 +00:00
$cat -> setDMS ( $this );
return $cat ;
} /* }}} */
2012-04-26 20:26:56 +00:00
function getKeywordCategoryByName ( $name , $userID ) { /* {{{ */
$queryStr = " SELECT * FROM tblKeywordCategories WHERE name = " . $this -> db -> qstr ( $name ) . " AND owner = " . ( int ) $userID ;
2010-11-27 20:52:03 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if (( is_bool ( $resArr ) && ! $resArr ) || ( count ( $resArr ) != 1 ))
return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_Keywordcategory ( $resArr [ " id " ], $resArr [ " owner " ], $resArr [ " name " ]);
2010-11-27 20:52:03 +00:00
$cat -> setDMS ( $this );
return $cat ;
} /* }}} */
function getAllKeywordCategories ( $userIDs = array ()) { /* {{{ */
$queryStr = " SELECT * FROM tblKeywordCategories " ;
if ( $userIDs )
$queryStr .= " WHERE owner in ( " . implode ( ',' , $userIDs ) . " ) " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$categories = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_KeywordCategory ( $row [ " id " ], $row [ " owner " ], $row [ " name " ]);
2010-11-27 20:52:03 +00:00
$cat -> setDMS ( $this );
array_push ( $categories , $cat );
}
return $categories ;
} /* }}} */
2012-04-26 20:26:56 +00:00
/**
* This function should be replaced by getAllKeywordCategories ()
*/
2010-11-27 20:52:03 +00:00
function getAllUserKeywordCategories ( $userID ) { /* {{{ */
$queryStr = " SELECT * FROM tblKeywordCategories " ;
if ( $userID != - 1 )
2011-12-01 21:20:58 +00:00
$queryStr .= " WHERE owner = " . ( int ) $userID ;
2010-11-27 20:52:03 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$categories = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_KeywordCategory ( $row [ " id " ], $row [ " owner " ], $row [ " name " ]);
2010-11-27 20:52:03 +00:00
$cat -> setDMS ( $this );
array_push ( $categories , $cat );
}
return $categories ;
} /* }}} */
2012-04-26 20:26:56 +00:00
function addKeywordCategory ( $userID , $name ) { /* {{{ */
if ( is_object ( $this -> getKeywordCategoryByName ( $name , $userID ))) {
2010-11-27 20:52:03 +00:00
return false ;
}
2012-09-11 12:58:30 +00:00
$queryStr = " INSERT INTO tblKeywordCategories (owner, name) VALUES ( " . ( int ) $userID . " , " . $this -> db -> qstr ( $name ) . " ) " ;
2010-11-27 20:52:03 +00:00
if ( ! $this -> db -> getResult ( $queryStr ))
return false ;
return $this -> getKeywordCategory ( $this -> db -> getInsertID ());
} /* }}} */
2011-03-10 14:27:05 +00:00
function getDocumentCategory ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblCategory WHERE id = " . ( int ) $id ;
2011-03-10 14:27:05 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if (( is_bool ( $resArr ) && ! $resArr ) || ( count ( $resArr ) != 1 ))
return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_DocumentCategory ( $resArr [ " id " ], $resArr [ " name " ]);
2011-03-10 14:27:05 +00:00
$cat -> setDMS ( $this );
return $cat ;
} /* }}} */
function getDocumentCategories () { /* {{{ */
$queryStr = " SELECT * FROM tblCategory " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$categories = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_DocumentCategory ( $row [ " id " ], $row [ " name " ]);
2011-03-10 14:27:05 +00:00
$cat -> setDMS ( $this );
array_push ( $categories , $cat );
}
return $categories ;
} /* }}} */
2011-07-20 16:47:09 +00:00
/**
* Get a category by its name
*
* The name of a category is by default unique .
*
* @ param string $name human readable name of category
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_DocumentCategory }
2011-07-20 16:47:09 +00:00
*/
2011-03-10 14:27:05 +00:00
function getDocumentCategoryByName ( $name ) { /* {{{ */
2013-02-11 07:46:02 +00:00
if ( ! $name ) return false ;
2011-03-10 14:27:05 +00:00
2013-02-11 07:46:02 +00:00
$queryStr = " SELECT * FROM tblCategory where name= " . $this -> db -> qstr ( $name );
2011-03-10 14:27:05 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
2011-07-22 20:48:31 +00:00
if ( ! $resArr )
2011-03-10 14:27:05 +00:00
return false ;
2011-07-20 16:47:09 +00:00
$row = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$cat = new SeedDMS_Core_DocumentCategory ( $row [ " id " ], $row [ " name " ]);
2011-07-20 16:47:09 +00:00
$cat -> setDMS ( $this );
2011-03-10 14:27:05 +00:00
2011-07-20 16:47:09 +00:00
return $cat ;
2011-03-10 14:27:05 +00:00
} /* }}} */
function addDocumentCategory ( $name ) { /* {{{ */
if ( is_object ( $this -> getDocumentCategoryByName ( $name ))) {
return false ;
}
2012-10-13 19:20:40 +00:00
$queryStr = " INSERT INTO tblCategory (name) VALUES ( " . $this -> db -> qstr ( $name ) . " ) " ;
2011-03-10 14:27:05 +00:00
if ( ! $this -> db -> getResult ( $queryStr ))
return false ;
return $this -> getDocumentCategory ( $this -> db -> getInsertID ());
} /* }}} */
2010-12-21 17:41:05 +00:00
/**
* Get all notifications for a group
*
2010-12-22 19:48:08 +00:00
* @ param object $group group for which notifications are to be retrieved
* @ param integer $type type of item ( T_DOCUMENT or T_FOLDER )
* @ return array array of notifications
2010-12-21 17:41:05 +00:00
*/
function getNotificationsByGroup ( $group , $type = 0 ) { /* {{{ */
2010-12-22 19:48:08 +00:00
$queryStr = " SELECT `tblNotify`.* FROM `tblNotify` " .
2010-12-21 17:41:05 +00:00
" WHERE `tblNotify`.`groupID` = " . $group -> getID ();
if ( $type ) {
2011-12-01 21:20:58 +00:00
$queryStr .= " AND `tblNotify`.`targetType` = " . ( int ) $type ;
2010-12-21 17:41:05 +00:00
}
2010-12-22 19:48:08 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$notifications = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$not = new SeedDMS_Core_Notification ( $row [ " target " ], $row [ " targetType " ], $row [ " userID " ], $row [ " groupID " ]);
2010-12-22 19:48:08 +00:00
$not -> setDMS ( $this );
array_push ( $notifications , $cat );
}
return $notifications ;
2010-12-21 17:41:05 +00:00
} /* }}} */
/**
* Get all notifications for a user
*
2010-12-22 19:48:08 +00:00
* @ param object $user user for which notifications are to be retrieved
* @ param integer $type type of item ( T_DOCUMENT or T_FOLDER )
* @ return array array of notifications
2010-12-21 17:41:05 +00:00
*/
2012-04-26 20:26:56 +00:00
function getNotificationsByUser ( $user , $type = 0 ) { /* {{{ */
2010-12-21 17:41:05 +00:00
$queryStr = " SELECT `tblNotify`.* FROM `tblNotify` " .
" WHERE `tblNotify`.`userID` = " . $user -> getID ();
2010-12-22 19:48:08 +00:00
if ( $type ) {
2011-12-01 21:20:58 +00:00
$queryStr .= " AND `tblNotify`.`targetType` = " . ( int ) $type ;
2010-12-22 19:48:08 +00:00
}
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$notifications = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$not = new SeedDMS_Core_Notification ( $row [ " target " ], $row [ " targetType " ], $row [ " userID " ], $row [ " groupID " ]);
2010-12-22 19:48:08 +00:00
$not -> setDMS ( $this );
array_push ( $notifications , $cat );
}
2010-12-21 17:41:05 +00:00
2010-12-22 19:48:08 +00:00
return $notifications ;
2010-12-21 17:41:05 +00:00
} /* }}} */
2011-10-10 14:08:24 +00:00
/**
* Create a token to request a new password .
* This function will not delete the password but just creates an entry
* in tblUserRequestPassword indicating a password request .
*
* @ return string hash value of false in case of an error
*/
function createPasswordRequest ( $user ) { /* {{{ */
$hash = md5 ( uniqid ( time ()));
2013-01-29 13:17:32 +00:00
$queryStr = " INSERT INTO tblUserPasswordRequest (userID, hash, `date`) VALUES ( " . $user -> getId () . " , " . $this -> db -> qstr ( $hash ) . " , CURRENT_TIMESTAMP) " ;
2011-10-10 14:08:24 +00:00
$resArr = $this -> db -> getResult ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr ) return false ;
return $hash ;
} /* }}} */
/**
* Check if hash for a password request is valid .
* This function searches a previously create password request and
* returns the user .
*
* @ param string $hash
*/
function checkPasswordRequest ( $hash ) { /* {{{ */
/* Get the password request from the database */
2011-12-01 21:20:58 +00:00
$queryStr = " SELECT * FROM tblUserPasswordRequest where hash= " . $this -> db -> qstr ( $hash );
2011-10-10 14:08:24 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
if ( count ( $resArr ) != 1 )
return false ;
$resArr = $resArr [ 0 ];
return $this -> getUser ( $resArr [ 'userID' ]);
} /* }}} */
/**
* Delete a password request
*
* @ param string $hash
*/
function deletePasswordRequest ( $hash ) { /* {{{ */
/* Delete the request, so nobody can use it a second time */
2011-12-01 21:20:58 +00:00
$queryStr = " DELETE FROM tblUserPasswordRequest WHERE hash= " . $this -> db -> qstr ( $hash );
2011-10-10 14:08:24 +00:00
if ( ! $this -> db -> getResult ( $queryStr ))
return false ;
return true ;
2012-10-09 09:53:11 +00:00
} /* }}} */
/**
* Return a attribute definition by its id
*
* This function retrieves a attribute definitionr from the database by
* its id .
*
* @ param integer $id internal id of attribute defintion
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_AttributeDefinition } or false
2012-10-09 09:53:11 +00:00
*/
function getAttributeDefinition ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
$queryStr = " SELECT * FROM tblAttributeDefinitions WHERE id = " . ( int ) $id ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$attrdef = new SeedDMS_Core_AttributeDefinition ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " objtype " ], $resArr [ " type " ], $resArr [ " multiple " ], $resArr [ " minvalues " ], $resArr [ " maxvalues " ], $resArr [ " valueset " ]);
2012-10-09 09:53:11 +00:00
$attrdef -> setDMS ( $this );
return $attrdef ;
} /* }}} */
/**
* Return a attribute definition by its name
*
* This function retrieves an attribute def . from the database by its name .
*
* @ param string $name internal name of attribute def .
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_AttributeDefinition } or false
2012-10-09 09:53:11 +00:00
*/
function getAttributeDefinitionByName ( $name ) { /* {{{ */
2013-02-11 07:46:02 +00:00
if ( ! $name ) return false ;
2012-10-09 09:53:11 +00:00
$queryStr = " SELECT * FROM tblAttributeDefinitions WHERE name = " . $this -> db -> qstr ( $name );
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$attrdef = new SeedDMS_Core_AttributeDefinition ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " objtype " ], $resArr [ " type " ], $resArr [ " multiple " ], $resArr [ " minvalues " ], $resArr [ " maxvalues " ], $resArr [ " valueset " ]);
2012-10-09 09:53:11 +00:00
$attrdef -> setDMS ( $this );
return $attrdef ;
} /* }}} */
/**
* Return list of all attributes definitions
*
* @ param integer $objtype select those attributes defined for an object type
2013-02-14 11:10:53 +00:00
* @ return array of instances of { @ link SeedDMS_Core_AttributeDefinition } or false
2012-10-09 09:53:11 +00:00
*/
function getAllAttributeDefinitions ( $objtype = 0 ) { /* {{{ */
$queryStr = " SELECT * FROM tblAttributeDefinitions " ;
if ( $objtype ) {
if ( is_array ( $objtype ))
$queryStr .= ' WHERE objtype in (\'' . implode ( " ',' " , $objtype ) . '\')' ;
else
$queryStr .= ' WHERE objtype=' . intval ( $objtype );
}
$queryStr .= ' ORDER BY name' ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
$attrdefs = array ();
for ( $i = 0 ; $i < count ( $resArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$attrdef = new SeedDMS_Core_AttributeDefinition ( $resArr [ $i ][ " id " ], $resArr [ $i ][ " name " ], $resArr [ $i ][ " objtype " ], $resArr [ $i ][ " type " ], $resArr [ $i ][ " multiple " ], $resArr [ $i ][ " minvalues " ], $resArr [ $i ][ " maxvalues " ], $resArr [ $i ][ " valueset " ]);
2012-10-09 09:53:11 +00:00
$attrdef -> setDMS ( $this );
$attrdefs [ $i ] = $attrdef ;
}
return $attrdefs ;
} /* }}} */
/**
* Add a new attribute definition
*
* @ param string $name name of attribute
* @ param string $type type of attribute
* @ param boolean $multiple set to 1 if attribute has multiple attributes
* @ param integer $minvalues minimum number of values
* @ param integer $maxvalues maximum number of values if multiple is set
* @ param string $valueset list of allowed values ( csv format )
2013-02-14 11:10:53 +00:00
* @ return object of { @ link SeedDMS_Core_User }
2012-10-09 09:53:11 +00:00
*/
function addAttributeDefinition ( $name , $objtype , $type , $multiple = 0 , $minvalues = 0 , $maxvalues = 1 , $valueset = '' ) { /* {{{ */
if ( is_object ( $this -> getAttributeDefinitionByName ( $name ))) {
return false ;
}
if ( ! $type )
return false ;
$queryStr = " INSERT INTO tblAttributeDefinitions (name, objtype, type, multiple, minvalues, maxvalues, valueset) VALUES ( " . $this -> db -> qstr ( $name ) . " , " . intval ( $objtype ) . " , " . intval ( $type ) . " , " . intval ( $multiple ) . " , " . intval ( $minvalues ) . " , " . intval ( $maxvalues ) . " , " . $this -> db -> qstr ( $valueset ) . " ) " ;
$res = $this -> db -> getResult ( $queryStr );
if ( ! $res )
return false ;
return $this -> getAttributeDefinition ( $this -> db -> getInsertID ());
} /* }}} */
2013-01-24 08:29:58 +00:00
/**
* Return list of all workflows
*
2013-02-14 11:10:53 +00:00
* @ return array of instances of { @ link SeedDMS_Core_Workflow } or false
2013-01-24 08:29:58 +00:00
*/
function getAllWorkflows () { /* {{{ */
$queryStr = " SELECT * FROM tblWorkflows ORDER BY name " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
$queryStr = " SELECT * FROM tblWorkflowStates ORDER BY name " ;
$ressArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $ressArr ) && $ressArr == false )
return false ;
for ( $i = 0 ; $i < count ( $ressArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$wkfstates [ $ressArr [ $i ][ " id " ]] = new SeedDMS_Core_Workflow_State ( $ressArr [ $i ][ " id " ], $ressArr [ $i ][ " name " ], $ressArr [ $i ][ " maxtime " ], $ressArr [ $i ][ " precondfunc " ], $ressArr [ $i ][ " documentstatus " ]);
2013-01-24 08:29:58 +00:00
}
$workflows = array ();
for ( $i = 0 ; $i < count ( $resArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$workflow = new SeedDMS_Core_Workflow ( $resArr [ $i ][ " id " ], $resArr [ $i ][ " name " ], $wkfstates [ $resArr [ $i ][ " initstate " ]]);
2013-01-24 08:29:58 +00:00
$workflow -> setDMS ( $this );
$workflows [ $i ] = $workflow ;
}
return $workflows ;
} /* }}} */
/**
* Return workflow by its Id
*
2013-02-14 11:10:53 +00:00
* @ return object of instances of { @ link SeedDMS_Core_Workflow } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflow ( $id ) { /* {{{ */
$queryStr = " SELECT * FROM tblWorkflows WHERE id= " . intval ( $id );
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( ! $resArr )
return false ;
$initstate = $this -> getWorkflowState ( $resArr [ 0 ][ 'initstate' ]);
2013-02-14 11:10:53 +00:00
$workflow = new SeedDMS_Core_Workflow ( $resArr [ 0 ][ " id " ], $resArr [ 0 ][ " name " ], $initstate );
2013-01-24 08:29:58 +00:00
$workflow -> setDMS ( $this );
return $workflow ;
} /* }}} */
/**
* Return workflow by its name
*
2013-02-14 11:10:53 +00:00
* @ return object of instances of { @ link SeedDMS_Core_Workflow } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflowByName ( $name ) { /* {{{ */
2013-02-11 07:46:02 +00:00
if ( ! $name ) return false ;
2013-01-24 08:29:58 +00:00
$queryStr = " SELECT * FROM tblWorkflows WHERE name= " . $this -> db -> qstr ( $name );
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( ! $resArr )
return false ;
$initstate = $this -> getWorkflowState ( $resArr [ 0 ][ 'initstate' ]);
2013-02-14 11:10:53 +00:00
$workflow = new SeedDMS_Core_Workflow ( $resArr [ 0 ][ " id " ], $resArr [ 0 ][ " name " ], $initstate );
2013-01-24 08:29:58 +00:00
$workflow -> setDMS ( $this );
return $workflow ;
} /* }}} */
function addWorkflow ( $name , $initstate ) { /* {{{ */
$db = $this -> db ;
if ( is_object ( $this -> getWorkflowByName ( $name ))) {
return false ;
}
$queryStr = " INSERT INTO tblWorkflows (name, initstate) VALUES ( " . $db -> qstr ( $name ) . " , " . $initstate -> getID () . " ) " ;
$res = $db -> getResult ( $queryStr );
if ( ! $res )
return false ;
return $this -> getWorkflow ( $db -> getInsertID ());
} /* }}} */
/**
* Return a workflow state by its id
*
* This function retrieves a workflow state from the database by its id .
*
* @ param integer $id internal id of workflow state
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_Workflow_State } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflowState ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
$queryStr = " SELECT * FROM tblWorkflowStates WHERE id = " . ( int ) $id ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$state = new SeedDMS_Core_Workflow_State ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " maxtime " ], $resArr [ " precondfunc " ], $resArr [ " documentstatus " ]);
2013-01-24 08:29:58 +00:00
$state -> setDMS ( $this );
return $state ;
} /* }}} */
/**
* Return workflow state by its name
*
2013-01-24 16:43:39 +00:00
* @ param string $name name of workflow state
2013-02-14 11:10:53 +00:00
* @ return object of instances of { @ link SeedDMS_Core_Workflow_State } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflowStateByName ( $name ) { /* {{{ */
2013-02-11 07:46:02 +00:00
if ( ! $name ) return false ;
2013-01-24 08:29:58 +00:00
$queryStr = " SELECT * FROM tblWorkflowStates WHERE name= " . $this -> db -> qstr ( $name );
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
if ( ! $resArr )
return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$state = new SeedDMS_Core_Workflow_State ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " maxtime " ], $resArr [ " precondfunc " ], $resArr [ " documentstatus " ]);
2013-01-24 08:29:58 +00:00
$state -> setDMS ( $this );
return $state ;
} /* }}} */
/**
* Return list of all workflow states
*
2013-02-14 11:10:53 +00:00
* @ return array of instances of { @ link SeedDMS_Core_Workflow_State } or false
2013-01-24 08:29:58 +00:00
*/
function getAllWorkflowStates () { /* {{{ */
$queryStr = " SELECT * FROM tblWorkflowStates ORDER BY name " ;
$ressArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $ressArr ) && $ressArr == false )
return false ;
$wkfstates = array ();
for ( $i = 0 ; $i < count ( $ressArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$wkfstate = new SeedDMS_Core_Workflow_State ( $ressArr [ $i ][ " id " ], $ressArr [ $i ][ " name " ], $ressArr [ $i ][ " maxtime " ], $ressArr [ $i ][ " precondfunc " ], $ressArr [ $i ][ " documentstatus " ]);
2013-01-24 08:29:58 +00:00
$wkfstate -> setDMS ( $this );
$wkfstates [ $i ] = $wkfstate ;
}
return $wkfstates ;
} /* }}} */
2013-01-24 16:43:39 +00:00
/**
* Add new workflow state
*
* @ param string $name name of workflow state
* @ param integer $docstatus document status when this state is reached
* @ return object instance of new workflow state
*/
2013-01-24 08:29:58 +00:00
function addWorkflowState ( $name , $docstatus ) { /* {{{ */
$db = $this -> db ;
if ( is_object ( $this -> getWorkflowStateByName ( $name ))) {
return false ;
}
$queryStr = " INSERT INTO tblWorkflowStates (name, documentstatus) VALUES ( " . $db -> qstr ( $name ) . " , " . ( int ) $docstatus . " ) " ;
$res = $db -> getResult ( $queryStr );
if ( ! $res )
return false ;
return $this -> getWorkflowState ( $db -> getInsertID ());
} /* }}} */
/**
* Return a workflow action by its id
*
* This function retrieves a workflow action from the database by its id .
*
2013-01-24 16:43:39 +00:00
* @ param integer $id internal id of workflow action
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_Workflow_Action } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflowAction ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
$queryStr = " SELECT * FROM tblWorkflowActions WHERE id = " . ( int ) $id ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$action = new SeedDMS_Core_Workflow_Action ( $resArr [ " id " ], $resArr [ " name " ]);
2013-01-24 08:29:58 +00:00
$action -> setDMS ( $this );
return $action ;
} /* }}} */
2013-01-24 16:43:39 +00:00
/**
* Return a workflow action by its name
*
* This function retrieves a workflow action from the database by its name .
*
* @ param string $name name of workflow action
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_Workflow_Action } or false
2013-01-24 16:43:39 +00:00
*/
function getWorkflowActionByName ( $name ) { /* {{{ */
2013-02-11 07:46:02 +00:00
if ( ! $name ) return false ;
2013-01-24 16:43:39 +00:00
$queryStr = " SELECT * FROM tblWorkflowActions WHERE name = " . $this -> db -> qstr ( $name );
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$action = new SeedDMS_Core_Workflow_Action ( $resArr [ " id " ], $resArr [ " name " ]);
2013-01-24 16:43:39 +00:00
$action -> setDMS ( $this );
return $action ;
} /* }}} */
2013-01-24 08:29:58 +00:00
/**
* Return list of workflow action
*
2013-02-14 11:10:53 +00:00
* @ return array list of instances of { @ link SeedDMS_Core_Workflow_Action } or false
2013-01-24 08:29:58 +00:00
*/
function getAllWorkflowActions () { /* {{{ */
$queryStr = " SELECT * FROM tblWorkflowActions " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
$wkfactions = array ();
for ( $i = 0 ; $i < count ( $resArr ); $i ++ ) {
2013-02-14 11:10:53 +00:00
$action = new SeedDMS_Core_Workflow_Action ( $resArr [ $i ][ " id " ], $resArr [ $i ][ " name " ]);
2013-01-24 08:29:58 +00:00
$action -> setDMS ( $this );
$wkfactions [ $i ] = $action ;
}
return $wkfactions ;
} /* }}} */
2013-01-24 16:43:39 +00:00
/**
* Add new workflow action
*
* @ param string $name name of workflow action
* @ return object instance new workflow action
*/
function addWorkflowAction ( $name ) { /* {{{ */
$db = $this -> db ;
if ( is_object ( $this -> getWorkflowActionByName ( $name ))) {
return false ;
}
$queryStr = " INSERT INTO tblWorkflowActions (name) VALUES ( " . $db -> qstr ( $name ) . " ) " ;
$res = $db -> getResult ( $queryStr );
if ( ! $res )
return false ;
return $this -> getWorkflowAction ( $db -> getInsertID ());
} /* }}} */
2013-01-24 08:29:58 +00:00
/**
* Return a workflow transition by its id
*
* This function retrieves a workflow transition from the database by its id .
*
* @ param integer $id internal id of workflow transition
2013-02-14 11:10:53 +00:00
* @ return object instance of { @ link SeedDMS_Core_Workflow_Transition } or false
2013-01-24 08:29:58 +00:00
*/
function getWorkflowTransition ( $id ) { /* {{{ */
if ( ! is_numeric ( $id ))
return false ;
$queryStr = " SELECT * FROM tblWorkflowTransitions WHERE id = " . ( int ) $id ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false ) return false ;
if ( count ( $resArr ) != 1 ) return false ;
$resArr = $resArr [ 0 ];
2013-02-14 11:10:53 +00:00
$transition = new SeedDMS_Core_Workflow_Transition ( $resArr [ " id " ], $this -> getWorkflow ( $resArr [ " workflow " ]), $this -> getWorkflowState ( $resArr [ " state " ]), $this -> getWorkflowAction ( $resArr [ " action " ]), $this -> getWorkflowState ( $resArr [ " nextstate " ]), $resArr [ " maxtime " ]);
2013-01-24 08:29:58 +00:00
$transition -> setDMS ( $this );
return $transition ;
} /* }}} */
2012-10-22 10:50:49 +00:00
/**
* Returns document content which is not linked to a document
*
* This method is for finding straying document content without
* a parent document . In normal operation this should not happen
* but little checks for database consistency and possible errors
* in the application may have left over document content though
* the document is gone already .
*/
function getUnlinkedDocumentContent () { /* {{{ */
$queryStr = " SELECT * FROM tblDocumentContent WHERE document NOT IN (SELECT id FROM tblDocuments) " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( ! $resArr )
return false ;
$versions = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$document = new SeedDMS_Core_Document ( $row [ 'document' ], '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' );
2012-10-22 10:50:49 +00:00
$document -> setDMS ( $this );
2013-02-14 11:10:53 +00:00
$version = new SeedDMS_Core_DocumentContent ( $row [ 'id' ], $document , $row [ 'version' ], $row [ 'comment' ], $row [ 'date' ], $row [ 'createdBy' ], $row [ 'dir' ], $row [ 'orgFileName' ], $row [ 'fileType' ], $row [ 'mimeType' ], $row [ 'fileSize' ], $row [ 'checksum' ]);
2012-10-22 10:50:49 +00:00
$versions [] = $version ;
}
return $versions ;
} /* }}} */
2012-12-19 10:24:12 +00:00
/**
* Returns document content which has no file size set
*
* This method is for finding document content without a file size
2013-02-08 14:57:05 +00:00
* set in the database . The file size of a document content was introduced
2013-02-14 11:10:53 +00:00
* in version 4.0 . 0 of SeedDMS for implementation of user quotas .
2012-12-19 10:24:12 +00:00
*/
function getNoFileSizeDocumentContent () { /* {{{ */
2013-02-08 14:57:05 +00:00
$queryStr = " SELECT * FROM tblDocumentContent WHERE fileSize = 0 OR fileSize is null " ;
2012-12-19 10:24:12 +00:00
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( ! $resArr )
return false ;
$versions = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$document = new SeedDMS_Core_Document ( $row [ 'document' ], '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' );
2012-12-19 10:24:12 +00:00
$document -> setDMS ( $this );
2013-02-14 11:10:53 +00:00
$version = new SeedDMS_Core_DocumentContent ( $row [ 'id' ], $document , $row [ 'version' ], $row [ 'comment' ], $row [ 'date' ], $row [ 'createdBy' ], $row [ 'dir' ], $row [ 'orgFileName' ], $row [ 'fileType' ], $row [ 'mimeType' ], $row [ 'fileSize' ], $row [ 'checksum' ], $row [ 'fileSize' ], $row [ 'checksum' ]);
2013-02-08 14:57:05 +00:00
$versions [] = $version ;
}
return $versions ;
} /* }}} */
/**
* Returns document content which has no checksum set
*
* This method is for finding document content without a checksum
* set in the database . The checksum of a document content was introduced
2013-02-14 11:10:53 +00:00
* in version 4.0 . 0 of SeedDMS for finding duplicates .
2013-02-08 14:57:05 +00:00
*/
function getNoChecksumDocumentContent () { /* {{{ */
$queryStr = " SELECT * FROM tblDocumentContent WHERE checksum = '' OR checksum is null " ;
$resArr = $this -> db -> getResultArray ( $queryStr );
if ( ! $resArr )
return false ;
$versions = array ();
foreach ( $resArr as $row ) {
2013-02-14 11:10:53 +00:00
$document = new SeedDMS_Core_Document ( $row [ 'document' ], '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' );
2013-02-08 14:57:05 +00:00
$document -> setDMS ( $this );
2013-02-14 11:10:53 +00:00
$version = new SeedDMS_Core_DocumentContent ( $row [ 'id' ], $document , $row [ 'version' ], $row [ 'comment' ], $row [ 'date' ], $row [ 'createdBy' ], $row [ 'dir' ], $row [ 'orgFileName' ], $row [ 'fileType' ], $row [ 'mimeType' ], $row [ 'fileSize' ], $row [ 'checksum' ]);
2012-12-19 10:24:12 +00:00
$versions [] = $version ;
}
return $versions ;
} /* }}} */
2013-01-24 08:29:58 +00:00
/**
* Set a callback function
*
* @ param string $name internal name of callback
* @ param mixed $func function name as expected by { call_user_method }
* @ param mixed $params parameter passed as the first argument to the
* callback
*/
function setCallback ( $name , $func , $params = null ) { /* {{{ */
if ( $name && $func )
$this -> callbacks [ $name ] = array ( $func , $params );
} /* }}} */
2010-11-12 22:40:12 +00:00
}
?>