2010-11-16 09:10:39 +00:00
< ? php
2010-12-06 20:00:18 +00:00
/**
* Implementation of a folder in the document management system
*
* @ category DMS
2013-02-14 11:10:53 +00:00
* @ package SeedDMS_Core
2010-12-06 20:00:18 +00:00
* @ license GPL2
* @ author Markus Westphal , Malcolm Cowe , Matteo Lucarelli ,
* Uwe Steinmann < uwe @ steinmann . cx >
* @ copyright Copyright ( C ) 2002 - 2005 Markus Westphal , 2006 - 2008 Malcolm Cowe ,
* 2010 Matteo Lucarelli , 2010 Uwe Steinmann
* @ version Release : @ package_version @
*/
2010-11-16 09:10:39 +00:00
/**
2010-12-06 20:00:18 +00:00
* Class to represent a folder in the document management system
2010-11-16 09:10:39 +00:00
*
2013-02-14 11:10:53 +00:00
* A folder in SeedDMS is equivalent to a directory in a regular file
2011-01-20 14:26:02 +00:00
* system . It can contain further subfolders and documents . Each folder
* has a single parent except for the root folder which has no parent .
*
2010-11-16 09:10:39 +00:00
* @ category DMS
2013-02-14 11:10:53 +00:00
* @ package SeedDMS_Core
2010-12-06 20:00:18 +00:00
* @ version @ version @
* @ author Uwe Steinmann < uwe @ steinmann . cx >
* @ copyright Copyright ( C ) 2002 - 2005 Markus Westphal , 2006 - 2008 Malcolm Cowe ,
* 2010 Matteo Lucarelli , 2010 Uwe Steinmann
2010-11-16 09:10:39 +00:00
* @ version Release : @ package_version @
*/
2013-02-14 11:10:53 +00:00
class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
2010-12-10 13:39:28 +00:00
/**
* @ var string name of folder
*/
2013-01-24 08:25:01 +00:00
protected $_name ;
2010-12-10 13:39:28 +00:00
/**
* @ var integer id of parent folder
*/
2013-01-24 08:25:01 +00:00
protected $_parentID ;
2010-12-10 13:39:28 +00:00
/**
* @ var string comment of document
*/
2013-01-24 08:25:01 +00:00
protected $_comment ;
2010-12-10 13:39:28 +00:00
/**
* @ var integer id of user who is the owner
*/
2013-01-24 08:25:01 +00:00
protected $_ownerID ;
2010-12-10 13:39:28 +00:00
/**
* @ var boolean true if access is inherited , otherwise false
*/
2013-01-24 08:25:01 +00:00
protected $_inheritAccess ;
2010-12-10 13:39:28 +00:00
/**
* @ var integer default access if access rights are not inherited
*/
2013-01-24 08:25:01 +00:00
protected $_defaultAccess ;
2010-12-10 13:39:28 +00:00
2013-02-11 13:55:51 +00:00
/**
* @ var array list of notifications for users and groups
*/
protected $_readAccessList ;
2011-01-20 12:48:06 +00:00
/**
* @ var array list of notifications for users and groups
*/
2013-01-24 08:25:01 +00:00
public $_notifyList ;
2011-01-20 12:48:06 +00:00
2010-12-10 13:39:28 +00:00
/**
* @ var integer position of folder within the parent folder
*/
2013-01-24 08:25:01 +00:00
protected $_sequence ;
2010-12-10 13:39:28 +00:00
2018-02-08 08:25:45 +00:00
/**
* @ var
*/
protected $_date ;
/**
* @ var SeedDMS_Core_Folder
*/
protected $_parent ;
/**
* @ var SeedDMS_Core_User
*/
protected $_owner ;
/**
* @ var SeedDMS_Core_Folder []
*/
protected $_subFolders ;
/**
* @ var SeedDMS_Core_Document []
*/
protected $_documents ;
/**
* @ var SeedDMS_Core_UserAccess [] | SeedDMS_Core_GroupAccess []
*/
protected $_accessList ;
/**
* SeedDMS_Core_Folder constructor .
* @ param $id
* @ param $name
* @ param $parentID
* @ param $comment
* @ param $date
* @ param $ownerID
* @ param $inheritAccess
* @ param $defaultAccess
* @ param $sequence
*/
2016-03-22 14:08:36 +00:00
function __construct ( $id , $name , $parentID , $comment , $date , $ownerID , $inheritAccess , $defaultAccess , $sequence ) { /* {{{ */
2012-10-09 09:56:28 +00:00
parent :: __construct ( $id );
2010-11-15 21:08:07 +00:00
$this -> _id = $id ;
$this -> _name = $name ;
$this -> _parentID = $parentID ;
$this -> _comment = $comment ;
2010-12-10 13:39:28 +00:00
$this -> _date = $date ;
2010-11-15 21:08:07 +00:00
$this -> _ownerID = $ownerID ;
$this -> _inheritAccess = $inheritAccess ;
$this -> _defaultAccess = $defaultAccess ;
$this -> _sequence = $sequence ;
2011-01-20 12:48:06 +00:00
$this -> _notifyList = array ();
2010-11-16 09:10:39 +00:00
} /* }}} */
2019-08-08 06:43:20 +00:00
/**
* Check if this object is of type 'folder' .
*
* @ param string $type type of object
*/
public function isType ( $type ) { /* {{{ */
return $type == 'folder' ;
} /* }}} */
2015-02-05 06:36:37 +00:00
/**
* Return an array of database fields which used for searching
* a term entered in the database search form
*
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_DMS $dms
2015-02-05 06:36:37 +00:00
* @ param array $searchin integer list of search scopes ( 2 = name , 3 = comment ,
* 4 = attributes )
* @ return array list of database fields
*/
2017-02-14 07:57:32 +00:00
public static function getSearchFields ( $dms , $searchin ) { /* {{{ */
$db = $dms -> getDB ();
2015-02-05 06:36:37 +00:00
$searchFields = array ();
if ( in_array ( 2 , $searchin )) {
$searchFields [] = " `tblFolders`.`name` " ;
}
if ( in_array ( 3 , $searchin )) {
$searchFields [] = " `tblFolders`.`comment` " ;
}
if ( in_array ( 4 , $searchin )) {
$searchFields [] = " `tblFolderAttributes`.`value` " ;
}
2017-01-18 14:11:45 +00:00
if ( in_array ( 5 , $searchin )) {
2017-02-14 07:57:32 +00:00
$searchFields [] = $db -> castToText ( " `tblFolders`.`id` " );
2017-01-18 14:11:45 +00:00
}
2015-02-05 06:36:37 +00:00
return $searchFields ;
} /* }}} */
/**
* Return a sql statement with all tables used for searching .
* This must be a syntactically correct left join of all tables .
*
* @ return string sql expression for left joining tables
*/
public static function getSearchTables () { /* {{{ */
$sql = " `tblFolders` LEFT JOIN `tblFolderAttributes` on `tblFolders`.`id`=`tblFolderAttributes`.`folder` " ;
return $sql ;
} /* }}} */
2019-12-13 08:03:44 +00:00
/**
* Return a folder by its database record
*
* @ param array $resArr array of folder data as returned by database
* @ param SeedDMS_Core_DMS $dms
* @ return SeedDMS_Core_Folder | bool instance of SeedDMS_Core_Folder if document exists
*/
public static function getInstanceByData ( $resArr , $dms ) { /* {{{ */
$classname = $dms -> getClassname ( 'folder' );
/** @var SeedDMS_Core_Folder $folder */
$folder = new $classname ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " parent " ], $resArr [ " comment " ], $resArr [ " date " ], $resArr [ " owner " ], $resArr [ " inheritAccess " ], $resArr [ " defaultAccess " ], $resArr [ " sequence " ]);
$folder -> setDMS ( $dms );
$folder = $folder -> applyDecorators ();
return $folder ;
} /* }}} */
2017-12-22 12:01:38 +00:00
/**
* Return a folder by its id
*
* @ param integer $id id of folder
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_DMS $dms
* @ return SeedDMS_Core_Folder | bool instance of SeedDMS_Core_Folder if document exists , null
2017-12-22 12:01:38 +00:00
* if document does not exist , false in case of error
*/
2014-12-08 13:33:13 +00:00
public static function getInstance ( $id , $dms ) { /* {{{ */
$db = $dms -> getDB ();
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT * FROM `tblFolders` WHERE `id` = " . ( int ) $id ;
2014-12-08 13:33:13 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
else if ( count ( $resArr ) != 1 )
2017-12-22 12:01:38 +00:00
return null ;
2014-12-08 13:33:13 +00:00
2019-12-13 08:03:44 +00:00
return self :: getInstanceByData ( $resArr [ 0 ], $dms );
2014-12-08 13:33:13 +00:00
$resArr = $resArr [ 0 ];
2015-07-15 20:28:58 +00:00
$classname = $dms -> getClassname ( 'folder' );
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_Folder $folder */
2015-07-15 20:28:58 +00:00
$folder = new $classname ( $resArr [ " id " ], $resArr [ " name " ], $resArr [ " parent " ], $resArr [ " comment " ], $resArr [ " date " ], $resArr [ " owner " ], $resArr [ " inheritAccess " ], $resArr [ " defaultAccess " ], $resArr [ " sequence " ]);
2014-12-08 13:33:13 +00:00
$folder -> setDMS ( $dms );
2019-08-08 06:43:20 +00:00
$folder = $folder -> applyDecorators ();
2014-12-08 13:33:13 +00:00
return $folder ;
} /* }}} */
2019-08-08 06:43:20 +00:00
/**
* Apply decorators
*
* @ return object final object after all decorators has been applied
*/
function applyDecorators () { /* {{{ */
if ( $decorators = $this -> _dms -> getDecorators ( 'folder' )) {
$s = $this ;
foreach ( $decorators as $decorator ) {
$s = new $decorator ( $s );
}
return $s ;
} else {
return $this ;
}
} /* }}} */
2017-10-28 12:28:12 +00:00
/**
2010-11-16 09:10:39 +00:00
* Get the name of the folder .
*
* @ return string name of folder
*/
2014-12-08 13:33:13 +00:00
public function getName () { return $this -> _name ; }
2010-11-16 09:10:39 +00:00
2018-02-08 08:25:45 +00:00
/**
2010-11-16 09:10:39 +00:00
* Set the name of the folder .
*
* @ param string $newName set a new name of the folder
2018-02-08 08:25:45 +00:00
* @ return bool
2010-11-16 09:10:39 +00:00
*/
2014-12-08 13:33:13 +00:00
public function setName ( $newName ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `name` = " . $db -> qstr ( $newName ) . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _name = $newName ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
return true ;
} /* }}} */
2018-02-08 08:25:45 +00:00
/**
* @ return string
*/
2014-12-08 13:33:13 +00:00
public function getComment () { return $this -> _comment ; }
2010-11-16 09:10:39 +00:00
2018-02-08 08:25:45 +00:00
/**
* @ param $newComment
* @ return bool
*/
2014-12-08 13:33:13 +00:00
public function setComment ( $newComment ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `comment` = " . $db -> qstr ( $newComment ) . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _comment = $newComment ;
return true ;
} /* }}} */
2010-12-10 13:39:28 +00:00
/**
2010-12-14 12:43:14 +00:00
* Return creation date of folder
2010-12-10 13:39:28 +00:00
*
* @ return integer unix timestamp of creation date
*/
2014-12-08 13:33:13 +00:00
public function getDate () { /* {{{ */
2010-12-10 13:39:28 +00:00
return $this -> _date ;
} /* }}} */
2015-08-04 05:39:14 +00:00
/**
* Set creation date of the document
*
* @ param integer $date timestamp of creation date . If false then set it
* to the current timestamp
* @ return boolean true on success
*/
function setDate ( $date ) { /* {{{ */
$db = $this -> _dms -> getDB ();
if ( ! $date )
$date = time ();
else {
if ( ! is_numeric ( $date ))
return false ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `date` = " . ( int ) $date . " WHERE `id` = " . $this -> _id ;
2015-08-04 05:39:14 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _date = $date ;
return true ;
} /* }}} */
2010-12-14 12:43:14 +00:00
/**
* Returns the parent
*
2017-10-28 12:28:12 +00:00
* @ return bool | SeedDMS_Core_Folder
2010-12-14 12:43:14 +00:00
*/
2014-12-08 13:33:13 +00:00
public function getParent () { /* {{{ */
2010-12-14 12:43:14 +00:00
if ( $this -> _id == $this -> _dms -> rootFolderID || empty ( $this -> _parentID )) {
2010-11-16 09:10:39 +00:00
return false ;
}
if ( ! isset ( $this -> _parent )) {
$this -> _parent = $this -> _dms -> getFolder ( $this -> _parentID );
}
return $this -> _parent ;
} /* }}} */
2013-11-25 21:10:17 +00:00
/**
* Check if the folder is subfolder
*
* This function checks if the passed folder is a subfolder of the current
2018-02-08 08:25:45 +00:00
* folder .
2013-11-25 21:10:17 +00:00
*
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_Folder $subfolder
* @ return bool true if passes folder is a subfolder
2013-11-25 21:10:17 +00:00
*/
function isSubFolder ( $subfolder ) { /* {{{ */
2015-01-29 17:15:04 +00:00
$target_path = $subfolder -> getPath ();
foreach ( $target_path as $next_folder ) {
// the target folder contains this instance in the parent path
if ( $this -> getID () == $next_folder -> getID ()) return true ;
2013-11-25 21:10:17 +00:00
}
2015-01-29 17:15:04 +00:00
return false ;
2013-11-25 21:10:17 +00:00
} /* }}} */
2010-12-14 12:43:14 +00:00
/**
* Set a new folder
*
* This function moves a folder from one parent folder into another parent
* folder . It will fail if the root folder is moved .
*
2017-10-28 12:28:12 +00:00
* @ param SeedDMS_Core_Folder $newParent new parent folder
2010-12-14 12:43:14 +00:00
* @ return boolean true if operation was successful otherwise false
*/
2014-12-08 13:33:13 +00:00
public function setParent ( $newParent ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2010-12-14 12:43:14 +00:00
if ( $this -> _id == $this -> _dms -> rootFolderID || empty ( $this -> _parentID )) {
2010-11-16 09:10:39 +00:00
return false ;
}
2013-11-25 21:10:17 +00:00
/* Check if the new parent is the folder to be moved or even
* a subfolder of that folder
*/
if ( $this -> isSubFolder ( $newParent )) {
return false ;
}
2011-11-28 14:03:01 +00:00
// Update the folderList of the folder
$pathPrefix = " " ;
$path = $newParent -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `parent` = " . $newParent -> getID () . " , `folderList`=' " . $pathPrefix . " ' WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
$res = $db -> getResult ( $queryStr );
if ( ! $res )
return false ;
2013-04-08 05:50:46 +00:00
2010-11-16 09:10:39 +00:00
$this -> _parentID = $newParent -> getID ();
$this -> _parent = $newParent ;
// Must also ensure that any documents in this folder tree have their
// folderLists updated.
$pathPrefix = " " ;
$path = $this -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
2013-04-08 05:50:46 +00:00
/* Update path in folderList for all documents */
2010-11-16 09:10:39 +00:00
$queryStr = " SELECT `tblDocuments`.`id`, `tblDocuments`.`folderList` FROM `tblDocuments` WHERE `folderList` LIKE '%: " . $this -> _id . " :%' " ;
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
foreach ( $resArr as $row ) {
2012-07-18 12:06:47 +00:00
$newPath = preg_replace ( " /^.*: " . $this -> _id . " :(.* $ )/ " , $pathPrefix . " \\ 1 " , $row [ " folderList " ]);
2010-11-16 09:10:39 +00:00
$queryStr = " UPDATE `tblDocuments` SET `folderList` = ' " . $newPath . " ' WHERE `tblDocuments`.`id` = ' " . $row [ " id " ] . " ' " ;
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUnusedLocalVariableInspection */
2010-11-16 09:10:39 +00:00
$res = $db -> getResult ( $queryStr );
2010-11-12 22:47:41 +00:00
}
2010-11-16 09:10:39 +00:00
2013-04-08 05:50:46 +00:00
/* Update path in folderList for all documents */
$queryStr = " SELECT `tblFolders`.`id`, `tblFolders`.`folderList` FROM `tblFolders` WHERE `folderList` LIKE '%: " . $this -> _id . " :%' " ;
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
foreach ( $resArr as $row ) {
$newPath = preg_replace ( " /^.*: " . $this -> _id . " :(.* $ )/ " , $pathPrefix . " \\ 1 " , $row [ " folderList " ]);
$queryStr = " UPDATE `tblFolders` SET `folderList` = ' " . $newPath . " ' WHERE `tblFolders`.`id` = ' " . $row [ " id " ] . " ' " ;
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUnusedLocalVariableInspection */
2013-04-08 05:50:46 +00:00
$res = $db -> getResult ( $queryStr );
}
2010-11-16 09:10:39 +00:00
return true ;
} /* }}} */
2010-12-14 12:43:14 +00:00
/**
* Returns the owner
*
* @ return object owner of the folder
*/
2014-12-08 13:33:13 +00:00
public function getOwner () { /* {{{ */
2010-11-16 09:10:39 +00:00
if ( ! isset ( $this -> _owner ))
$this -> _owner = $this -> _dms -> getUser ( $this -> _ownerID );
return $this -> _owner ;
} /* }}} */
2010-12-14 12:43:14 +00:00
/**
* Set the owner
*
2017-10-28 12:28:12 +00:00
* @ param SeedDMS_Core_User $newOwner of the folder
2010-12-14 12:43:14 +00:00
* @ return boolean true if successful otherwise false
*/
2010-11-16 09:10:39 +00:00
function setOwner ( $newOwner ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` set `owner` = " . $newOwner -> getID () . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _ownerID = $newOwner -> getID ();
$this -> _owner = $newOwner ;
return true ;
} /* }}} */
2018-02-08 08:25:45 +00:00
/**
* @ return bool | int
*/
2010-11-16 09:10:39 +00:00
function getDefaultAccess () { /* {{{ */
if ( $this -> inheritsAccess ()) {
$res = $this -> getParent ();
if ( ! $res ) return false ;
return $this -> _parent -> getDefaultAccess ();
2010-11-12 22:47:41 +00:00
}
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
return $this -> _defaultAccess ;
} /* }}} */
2015-06-19 10:47:30 +00:00
/**
* Set default access mode
*
* This method sets the default access mode and also removes all notifiers which
* will not have read access anymore .
*
* @ param integer $mode access mode
2015-06-19 13:02:37 +00:00
* @ param boolean $noclean set to true if notifier list shall not be clean up
2018-02-08 08:25:45 +00:00
* @ return bool
2015-06-19 10:47:30 +00:00
*/
2015-06-19 13:02:37 +00:00
function setDefaultAccess ( $mode , $noclean = false ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` set `defaultAccess` = " . ( int ) $mode . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _defaultAccess = $mode ;
2015-06-19 13:02:37 +00:00
if ( ! $noclean )
2019-08-08 06:43:20 +00:00
$this -> cleanNotifyList ();
2010-11-16 09:10:39 +00:00
return true ;
} /* }}} */
function inheritsAccess () { return $this -> _inheritAccess ; }
2015-06-19 13:02:37 +00:00
/**
* Set inherited access mode
* Setting inherited access mode will set or unset the internal flag which
* controls if the access mode is inherited from the parent folder or not .
* It will not modify the
* access control list for the current object . It will remove all
* notifications of users which do not even have read access anymore
* after setting or unsetting inherited access .
*
* @ param boolean $inheritAccess set to true for setting and false for
* unsetting inherited access mode
* @ param boolean $noclean set to true if notifier list shall not be clean up
* @ return boolean true if operation was successful otherwise false
*/
function setInheritAccess ( $inheritAccess , $noclean = false ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
$inheritAccess = ( $inheritAccess ) ? " 1 " : " 0 " ;
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `inheritAccess` = " . ( int ) $inheritAccess . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
$this -> _inheritAccess = $inheritAccess ;
2015-06-19 13:02:37 +00:00
if ( ! $noclean )
2019-08-08 06:43:20 +00:00
$this -> cleanNotifyList ();
2010-11-16 09:10:39 +00:00
return true ;
} /* }}} */
function getSequence () { return $this -> _sequence ; }
function setSequence ( $seq ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `sequence` = " . $seq . " WHERE `id` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
$this -> _sequence = $seq ;
return true ;
} /* }}} */
2012-12-13 21:25:21 +00:00
/**
* Check if folder has subfolders
* This function just checks if a folder has subfolders disregarding
* any access rights .
*
* @ return int number of subfolders or false in case of an error
*/
function hasSubFolders () { /* {{{ */
$db = $this -> _dms -> getDB ();
if ( isset ( $this -> _subFolders )) {
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUndefinedFieldInspection */
return count ( $this -> subFolders ); /** @todo not $this->_subFolders? */
2012-12-13 21:25:21 +00:00
}
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this -> _id ;
2012-12-13 21:25:21 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
return $resArr [ 0 ][ 'c' ];
} /* }}} */
2019-07-01 08:46:27 +00:00
/**
* Check if folder has as subfolder with given name
*
* @ param string $name
* @ return bool true if subfolder exists , false if not or in case
* of an error
*/
function hasSubFolderByName ( $name ) { /* {{{ */
$db = $this -> _dms -> getDB ();
/* Always check the database instead of iterating over $this -> _documents , because
* it is probably not slower
*/
$queryStr = " SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this -> _id . " AND `name` = " . $db -> qstr ( $name );
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
return ( $resArr [ 0 ][ 'c' ] > 0 );
} /* }}} */
2010-12-14 12:43:14 +00:00
/**
* Returns a list of subfolders
2010-12-22 13:18:02 +00:00
* This function does not check for access rights . Use
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS :: filterAccess } for checking each folder against
2010-12-22 13:18:02 +00:00
* the currently logged in user and the access rights .
2010-12-14 12:43:14 +00:00
*
* @ param string $orderby if set to 'n' the list is ordered by name , otherwise
* it will be ordered by sequence
2015-06-18 11:49:52 +00:00
* @ param string $dir direction of sorting ( asc or desc )
2017-12-19 06:05:08 +00:00
* @ param integer $limit limit number of subfolders
* @ param integer $offset offset in retrieved list of subfolders
2018-02-08 08:25:45 +00:00
* @ return SeedDMS_Core_Folder [] | bool list of folder objects or false in case of an error
2010-12-14 12:43:14 +00:00
*/
2017-12-19 06:05:08 +00:00
function getSubFolders ( $orderby = " " , $dir = " asc " , $limit = 0 , $offset = 0 ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
if ( ! isset ( $this -> _subFolders )) {
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT * FROM `tblFolders` WHERE `parent` = " . $this -> _id ;
2014-02-01 14:21:32 +00:00
2019-06-26 16:02:26 +00:00
if ( $orderby && $orderby [ 0 ] == " n " ) $queryStr .= " ORDER BY `name` " ;
elseif ( $orderby && $orderby [ 0 ] == " s " ) $queryStr .= " ORDER BY `sequence` " ;
elseif ( $orderby && $orderby [ 0 ] == " d " ) $queryStr .= " ORDER BY `date` " ;
2015-06-18 11:49:52 +00:00
if ( $dir == 'desc' )
$queryStr .= " DESC " ;
2017-12-19 06:05:08 +00:00
if ( is_int ( $limit ) && $limit > 0 ) {
$queryStr .= " LIMIT " . $limit ;
if ( is_int ( $offset ) && $offset > 0 )
$queryStr .= " OFFSET " . $offset ;
}
2015-06-18 11:49:52 +00:00
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
2011-07-20 07:17:18 +00:00
2019-12-13 08:03:44 +00:00
$classname = $this -> _dms -> getClassname ( 'folder' );
2010-11-16 09:10:39 +00:00
$this -> _subFolders = array ();
for ( $i = 0 ; $i < count ( $resArr ); $i ++ )
2019-12-13 08:03:44 +00:00
// $this->_subFolders[$i] = $this->_dms->getFolder($resArr[$i]["id"]);
$this -> _subFolders [ $i ] = $classname :: getInstanceByData ( $resArr [ $i ], $this -> _dms );
2010-11-16 09:10:39 +00:00
}
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
return $this -> _subFolders ;
} /* }}} */
2012-10-09 09:56:28 +00:00
/**
* Add a new subfolder
*
* @ param string $name name of folder
* @ param string $comment comment of folder
* @ param object $owner owner of folder
* @ param integer $sequence position of folder in list of sub folders .
* @ param array $attributes list of document attributes . The element key
* must be the id of the attribute definition .
2017-10-28 12:28:12 +00:00
* @ return bool | SeedDMS_Core_Folder
2012-10-09 09:56:28 +00:00
* an error .
*/
2013-01-24 08:25:01 +00:00
function addSubFolder ( $name , $comment , $owner , $sequence , $attributes = array ()) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-11-28 14:03:01 +00:00
// Set the folderList of the folder
$pathPrefix = " " ;
$path = $this -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
2012-10-22 13:33:30 +00:00
$db -> startTransaction ();
2010-11-16 09:10:39 +00:00
//inheritAccess = true, defaultAccess = M_READ
2017-02-10 07:04:19 +00:00
$queryStr = " INSERT INTO `tblFolders` (`name`, `parent`, `folderList`, `comment`, `date`, `owner`, `inheritAccess`, `defaultAccess`, `sequence`) " .
2015-09-22 05:50:36 +00:00
" VALUES ( " . $db -> qstr ( $name ) . " , " . $this -> _id . " , " . $db -> qstr ( $pathPrefix ) . " , " . $db -> qstr ( $comment ) . " , " . $db -> getCurrentTimestamp () . " , " . $owner -> getID () . " , 1, " . M_READ . " , " . $sequence . " ) " ;
2012-10-22 13:33:30 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
2010-11-16 09:10:39 +00:00
return false ;
2012-10-22 13:33:30 +00:00
}
2017-02-11 14:19:36 +00:00
$newFolder = $this -> _dms -> getFolder ( $db -> getInsertID ( 'tblFolders' ));
2010-11-16 09:10:39 +00:00
unset ( $this -> _subFolders );
2012-10-09 09:56:28 +00:00
if ( $attributes ) {
foreach ( $attributes as $attrdefid => $attribute ) {
2014-11-13 06:53:51 +00:00
if ( $attribute )
2012-10-09 09:56:28 +00:00
if ( ! $newFolder -> setAttributeValue ( $this -> _dms -> getAttributeDefinition ( $attrdefid ), $attribute )) {
2012-10-22 13:33:30 +00:00
$db -> rollbackTransaction ();
2012-10-09 09:56:28 +00:00
return false ;
}
}
}
2012-10-22 13:33:30 +00:00
$db -> commitTransaction ();
2016-04-04 05:39:39 +00:00
/* Check if 'onPostAddSubFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPostAddSubFolder' ])) {
2016-04-26 10:06:41 +00:00
foreach ( $this -> _dms -> callbacks [ 'onPostAddSubFolder' ] as $callback ) {
2018-02-08 08:25:45 +00:00
/** @noinspection PhpStatementHasEmptyBodyInspection */
if ( ! call_user_func ( $callback [ 0 ], $callback [ 1 ], $newFolder )) {
2016-04-26 10:06:41 +00:00
}
2016-04-04 05:39:39 +00:00
}
}
2010-11-16 09:10:39 +00:00
return $newFolder ;
} /* }}} */
2011-12-01 21:20:58 +00:00
/**
2010-12-01 13:36:55 +00:00
* Returns an array of all parents , grand parent , etc . up to root folder .
2010-11-16 09:10:39 +00:00
* The folder itself is the last element of the array .
*
2017-10-24 12:00:56 +00:00
* @ return array | bool
2010-11-16 09:10:39 +00:00
*/
function getPath () { /* {{{ */
2013-09-05 05:33:17 +00:00
if ( ! isset ( $this -> _parentID ) || ( $this -> _parentID == " " ) || ( $this -> _parentID == 0 ) || ( $this -> _id == $this -> _dms -> rootFolderID )) {
2010-11-16 09:10:39 +00:00
return array ( $this );
}
else {
$res = $this -> getParent ();
if ( ! $res ) return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
$path = $this -> _parent -> getPath ();
if ( ! $path ) return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
array_push ( $path , $this );
return $path ;
2010-11-12 22:47:41 +00:00
}
2010-11-16 09:10:39 +00:00
} /* }}} */
2011-12-01 21:20:58 +00:00
/**
2014-11-17 10:27:19 +00:00
* Returns a file system path
2011-12-01 21:20:58 +00:00
*
2014-11-17 10:27:19 +00:00
* This path contains spaces around the slashes for better readability .
* Run str_replace ( ' / ' , '/' , $path ) on it to get a valid unix
* file system path .
*
* @ return string path separated with ' / '
2011-12-01 21:20:58 +00:00
*/
2010-11-16 09:10:39 +00:00
function getFolderPathPlain () { /* {{{ */
2010-10-30 19:29:09 +00:00
$path = " " ;
$folderPath = $this -> getPath ();
for ( $i = 0 ; $i < count ( $folderPath ); $i ++ ) {
$path .= $folderPath [ $i ] -> getName ();
if ( $i + 1 < count ( $folderPath ))
$path .= " / " ;
}
return $path ;
2010-11-16 09:10:39 +00:00
} /* }}} */
/**
2010-12-22 13:18:02 +00:00
* Check , if this folder is a subfolder of a given folder
*
* @ param object $folder parent folder
* @ return boolean true if folder is a subfolder
2010-11-16 09:10:39 +00:00
*/
function isDescendant ( $folder ) { /* {{{ */
2019-07-01 11:06:08 +00:00
if ( ! $this -> getParent ())
2010-11-16 09:10:39 +00:00
return false ;
2019-07-01 11:06:08 +00:00
if ( $this -> getParent () -> getID () == $folder -> getID ())
return true ;
return $this -> getParent () -> isDescendant ( $folder );
2010-11-16 09:10:39 +00:00
} /* }}} */
2012-12-13 21:25:21 +00:00
/**
* Check if folder has documents
* This function just checks if a folder has documents diregarding
* any access rights .
*
* @ return int number of documents or false in case of an error
*/
function hasDocuments () { /* {{{ */
$db = $this -> _dms -> getDB ();
if ( isset ( $this -> _documents )) {
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUndefinedFieldInspection */
return count ( $this -> documents ); /** @todo not $this->_documents? */
2012-12-13 21:25:21 +00:00
}
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this -> _id ;
2012-12-13 21:25:21 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
return $resArr [ 0 ][ 'c' ];
} /* }}} */
2013-01-28 10:15:34 +00:00
/**
* Check if folder has document with given name
*
2018-02-08 08:25:45 +00:00
* @ param string $name
* @ return bool true if document exists , false if not or in case
2013-01-28 10:15:34 +00:00
* of an error
*/
function hasDocumentByName ( $name ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2019-07-01 08:46:27 +00:00
/* Always check the database instead of iterating over $this -> _documents , because
* it is probably not slower
*/
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this -> _id . " AND `name` = " . $db -> qstr ( $name );
2013-01-28 10:15:34 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
return ( $resArr [ 0 ][ 'c' ] > 0 );
} /* }}} */
2010-12-22 13:18:02 +00:00
/**
* Get all documents of the folder
* This function does not check for access rights . Use
2013-02-14 11:10:53 +00:00
* { @ link SeedDMS_Core_DMS :: filterAccess } for checking each document against
2010-12-22 13:18:02 +00:00
* the currently logged in user and the access rights .
*
* @ param string $orderby if set to 'n' the list is ordered by name , otherwise
* it will be ordered by sequence
2015-06-18 11:49:52 +00:00
* @ param string $dir direction of sorting ( asc or desc )
2017-12-19 05:34:26 +00:00
* @ param integer $limit limit number of documents
* @ param integer $offset offset in retrieved list of documents
2018-02-08 08:25:45 +00:00
* @ return SeedDMS_Core_Document [] | bool list of documents or false in case of an error
2010-12-22 13:18:02 +00:00
*/
2017-12-19 05:34:26 +00:00
function getDocuments ( $orderby = " " , $dir = " asc " , $limit = 0 , $offset = 0 ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
if ( ! isset ( $this -> _documents )) {
2019-12-13 08:03:44 +00:00
$queryStr = " SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lock` FROM `tblDocuments` LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id` = `tblDocumentLocks`.`document` WHERE `folder` = " . $this -> _id ;
2019-06-26 16:02:26 +00:00
if ( $orderby && $orderby [ 0 ] == " n " ) $queryStr .= " ORDER BY `name` " ;
elseif ( $orderby && $orderby [ 0 ] == " s " ) $queryStr .= " ORDER BY `sequence` " ;
elseif ( $orderby && $orderby [ 0 ] == " d " ) $queryStr .= " ORDER BY `date` " ;
2015-06-18 11:49:52 +00:00
if ( $dir == 'desc' )
$queryStr .= " DESC " ;
2017-12-19 06:05:08 +00:00
if ( is_int ( $limit ) && $limit > 0 ) {
2017-12-19 05:34:26 +00:00
$queryStr .= " LIMIT " . $limit ;
2017-12-19 06:05:08 +00:00
if ( is_int ( $offset ) && $offset > 0 )
$queryStr .= " OFFSET " . $offset ;
}
2010-10-30 19:29:09 +00:00
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
$this -> _documents = array ();
2019-12-13 08:03:44 +00:00
$classname = $this -> _dms -> getClassname ( 'document' );
2010-11-16 09:10:39 +00:00
foreach ( $resArr as $row ) {
2019-12-13 08:03:44 +00:00
$row [ 'lock' ] = ! $row [ 'lock' ] ? - 1 : $row [ 'lock' ];
// array_push($this->_documents, $this->_dms->getDocument($row["id"]));
array_push ( $this -> _documents , $classname :: getInstanceByData ( $row , $this -> _dms ));
2010-11-16 09:10:39 +00:00
}
}
return $this -> _documents ;
} /* }}} */
2013-04-05 11:07:50 +00:00
/**
* Count all documents and subfolders of the folder
*
* This function also counts documents and folders of subfolders , so
* basically it works like recursively counting children .
*
2013-04-10 13:40:42 +00:00
* This function checks for access rights up the given limit . If more
* documents or folders are found , the returned value will be the number
* of objects available and the precise flag in the return array will be
* set to false . This number should not be revelead to the
* user , because it allows to gain information about the existens of
* objects without access right .
* Setting the parameter $limit to 0 will turn off access right checking
* which is reasonable if the $user is an administrator .
2013-04-05 11:07:50 +00:00
*
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_User $user
2013-04-10 13:40:42 +00:00
* @ param integer $limit maximum number of folders and documents that will
* be precisly counted by taken the access rights into account
2018-02-08 08:25:45 +00:00
* @ return array | bool with four elements 'document_count' , 'folder_count'
2013-04-10 13:40:42 +00:00
* 'document_precise' , 'folder_precise' holding
2018-02-08 08:25:45 +00:00
* the counted number and a flag if the number is precise .
* @ internal param string $orderby if set to 'n' the list is ordered by name , otherwise
* it will be ordered by sequence
2013-04-05 11:07:50 +00:00
*/
2013-04-10 13:40:42 +00:00
function countChildren ( $user , $limit = 10000 ) { /* {{{ */
2013-04-05 11:07:50 +00:00
$db = $this -> _dms -> getDB ();
$pathPrefix = " " ;
$path = $this -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT id FROM `tblFolders` WHERE `folderList` like ' " . $pathPrefix . " %' " ;
2013-04-05 11:07:50 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
2013-04-10 13:40:42 +00:00
$result = array ();
$folders = array ();
$folderids = array ( $this -> _id );
$cfolders = count ( $resArr );
if ( $cfolders < $limit ) {
2013-04-05 11:07:50 +00:00
foreach ( $resArr as $row ) {
2013-04-10 13:40:42 +00:00
$folder = $this -> _dms -> getFolder ( $row [ " id " ]);
if ( $folder -> getAccessMode ( $user ) >= M_READ ) {
array_push ( $folders , $folder );
array_push ( $folderids , $row [ 'id' ]);
}
2013-04-05 11:07:50 +00:00
}
2013-04-10 13:40:42 +00:00
$result [ 'folder_count' ] = count ( $folders );
$result [ 'folder_precise' ] = true ;
} else {
foreach ( $resArr as $row ) {
array_push ( $folderids , $row [ 'id' ]);
}
$result [ 'folder_count' ] = $cfolders ;
$result [ 'folder_precise' ] = false ;
2013-04-05 11:07:50 +00:00
}
2013-04-10 13:40:42 +00:00
$documents = array ();
if ( $folderids ) {
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT id FROM `tblDocuments` WHERE `folder` in ( " . implode ( ',' , $folderids ) . " ) " ;
2013-04-05 11:07:50 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
2013-04-10 13:40:42 +00:00
$cdocs = count ( $resArr );
if ( $cdocs < $limit ) {
foreach ( $resArr as $row ) {
$document = $this -> _dms -> getDocument ( $row [ " id " ]);
if ( $document -> getAccessMode ( $user ) >= M_READ )
array_push ( $documents , $document );
}
$result [ 'document_count' ] = count ( $documents );
$result [ 'document_precise' ] = true ;
} else {
$result [ 'document_count' ] = $cdocs ;
$result [ 'document_precise' ] = false ;
2013-04-05 11:07:50 +00:00
}
}
2013-04-10 13:40:42 +00:00
return $result ;
2013-04-05 11:07:50 +00:00
} /* }}} */
2010-11-16 09:10:39 +00:00
// $comment will be used for both document and version leaving empty the version_comment
2010-12-22 13:18:02 +00:00
/**
* Add a new document to the folder
2018-02-08 08:25:45 +00:00
* This function will add a new document and its content from a given file .
2010-12-22 13:18:02 +00:00
* It does not check for access rights on the folder . The new documents
* default access right is read only and the access right is inherited .
*
* @ param string $name name of new document
* @ param string $comment comment of new document
* @ param integer $expires expiration date as a unix timestamp or 0 for no
* expiration date
* @ param object $owner owner of the new document
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_User $keywords keywords of new document
2018-02-20 05:38:22 +00:00
* @ param SeedDMS_Core_DocumentCategory [] $categories list of category objects
2010-12-22 13:18:02 +00:00
* @ param string $tmpFile the path of the file containing the content
* @ param string $orgFileName the original file name
* @ param string $fileType usually the extension of the filename
* @ param string $mimeType mime type of the content
2011-12-01 21:20:58 +00:00
* @ param float $sequence position of new document within the folder
2010-12-22 13:18:02 +00:00
* @ param array $reviewers list of users who must review this document
* @ param array $approvers list of users who must approve this document
2018-02-08 08:25:45 +00:00
* @ param int | string $reqversion version number of the content
2010-12-22 13:18:02 +00:00
* @ param string $version_comment comment of the content . If left empty
* the $comment will be used .
2012-10-09 09:56:28 +00:00
* @ param array $attributes list of document attributes . The element key
* must be the id of the attribute definition .
* @ param array $version_attributes list of document version attributes .
* The element key must be the id of the attribute definition .
2018-02-08 08:25:45 +00:00
* @ param SeedDMS_Core_Workflow $workflow
* @ return array | bool false in case of error , otherwise an array
2010-12-22 13:18:02 +00:00
* containing two elements . The first one is the new document , the
2018-02-08 08:25:45 +00:00
* second one is the result set returned when inserting the content .
2010-12-22 13:18:02 +00:00
*/
2014-07-11 06:36:46 +00:00
function addDocument ( $name , $comment , $expires , $owner , $keywords , $categories , $tmpFile , $orgFileName , $fileType , $mimeType , $sequence , $reviewers = array (), $approvers = array (), $reqversion = 0 , $version_comment = " " , $attributes = array (), $version_attributes = array (), $workflow = null ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2010-10-29 13:19:51 +00:00
$expires = ( ! $expires ) ? 0 : $expires ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
// Must also ensure that the document has a valid folderList.
$pathPrefix = " " ;
$path = $this -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
2011-07-20 07:17:18 +00:00
2012-10-22 13:33:30 +00:00
$db -> startTransaction ();
2017-02-10 07:04:19 +00:00
$queryStr = " INSERT INTO `tblDocuments` (`name`, `comment`, `date`, `expires`, `owner`, `folder`, `folderList`, `inheritAccess`, `defaultAccess`, `locked`, `keywords`, `sequence`) VALUES " .
2015-09-22 05:50:36 +00:00
" ( " . $db -> qstr ( $name ) . " , " . $db -> qstr ( $comment ) . " , " . $db -> getCurrentTimestamp () . " , " . ( int ) $expires . " , " . $owner -> getID () . " , " . $this -> _id . " , " . $db -> qstr ( $pathPrefix ) . " , 1, " . M_READ . " , -1, " . $db -> qstr ( $keywords ) . " , " . $sequence . " ) " ;
2012-10-22 13:33:30 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
2010-11-16 09:10:39 +00:00
return false ;
2012-10-22 13:33:30 +00:00
}
2011-07-20 07:17:18 +00:00
2017-02-11 14:19:36 +00:00
$document = $this -> _dms -> getDocument ( $db -> getInsertID ( 'tblDocuments' ));
2011-07-20 07:17:18 +00:00
2013-06-06 12:03:32 +00:00
// if ($version_comment!="")
2014-07-11 06:36:46 +00:00
$res = $document -> addContent ( $version_comment , $owner , $tmpFile , $orgFileName , $fileType , $mimeType , $reviewers , $approvers , $reqversion , $version_attributes , $workflow );
2013-06-06 12:03:32 +00:00
// else $res = $document->addContent($comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers, $approvers,$reqversion, $version_attributes, $workflow);
2010-10-29 13:19:51 +00:00
2010-11-16 09:10:39 +00:00
if ( is_bool ( $res ) && ! $res ) {
2012-10-22 13:33:30 +00:00
$db -> rollbackTransaction ();
2010-11-16 09:10:39 +00:00
return false ;
}
2011-03-10 14:29:26 +00:00
if ( $categories ) {
$document -> setCategories ( $categories );
}
2012-10-09 09:56:28 +00:00
if ( $attributes ) {
foreach ( $attributes as $attrdefid => $attribute ) {
2014-11-04 15:54:56 +00:00
/* $attribute can be a string or an array */
if ( $attribute )
2012-10-09 09:56:28 +00:00
if ( ! $document -> setAttributeValue ( $this -> _dms -> getAttributeDefinition ( $attrdefid ), $attribute )) {
$document -> remove ();
2012-10-22 13:33:30 +00:00
$db -> rollbackTransaction ();
2012-10-09 09:56:28 +00:00
return false ;
}
}
}
2012-10-22 13:33:30 +00:00
$db -> commitTransaction ();
2016-04-04 05:39:39 +00:00
/* Check if 'onPostAddDocument' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPostAddDocument' ])) {
2016-04-26 10:06:41 +00:00
foreach ( $this -> _dms -> callbacks [ 'onPostAddDocument' ] as $callback ) {
2018-02-08 08:25:45 +00:00
/** @noinspection PhpStatementHasEmptyBodyInspection */
if ( ! call_user_func ( $callback [ 0 ], $callback [ 1 ], $document )) {
2016-04-26 10:06:41 +00:00
}
2016-04-04 05:39:39 +00:00
}
}
2010-11-16 09:10:39 +00:00
return array ( $document , $res );
} /* }}} */
2011-07-20 07:17:18 +00:00
2014-12-08 13:33:13 +00:00
/**
* Remove a single folder
*
* Removes just a single folder , but not its subfolders or documents
* This function will fail if the folder has subfolders or documents
* because of referencial integrity errors .
*
* @ return boolean true on success , false in case of an error
*/
protected function removeFromDatabase () { /* {{{ */
$db = $this -> _dms -> getDB ();
2016-04-04 05:39:39 +00:00
/* Check if 'onPreRemoveFolder' callback is set */
2018-03-07 11:22:35 +00:00
if ( isset ( $this -> _dms -> callbacks [ 'onPreRemoveFromDatabaseFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPreRemoveFromDatabaseFolder' ] as $callback ) {
2017-05-12 06:16:05 +00:00
$ret = call_user_func ( $callback [ 0 ], $callback [ 1 ], $this );
if ( is_bool ( $ret ))
return $ret ;
2016-04-04 05:39:39 +00:00
}
}
2014-12-08 13:33:13 +00:00
$db -> startTransaction ();
2015-08-05 19:19:00 +00:00
// unset homefolder as it will no longer exist
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblUsers` SET `homefolder`=NULL WHERE `homefolder` = " . $this -> _id ;
2015-08-05 19:19:00 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
return false ;
}
2010-11-16 09:10:39 +00:00
2015-08-05 19:19:00 +00:00
// Remove database entries
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblFolders` WHERE `id` = " . $this -> _id ;
2014-12-08 13:33:13 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
return false ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblFolderAttributes` WHERE `folder` = " . $this -> _id ;
2014-12-08 13:33:13 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
return false ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblACLs` WHERE `target` = " . $this -> _id . " AND `targetType` = " . T_FOLDER ;
2014-12-08 13:33:13 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
return false ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblNotify` WHERE `target` = " . $this -> _id . " AND `targetType` = " . T_FOLDER ;
2014-12-08 13:33:13 +00:00
if ( ! $db -> getResult ( $queryStr )) {
$db -> rollbackTransaction ();
return false ;
}
$db -> commitTransaction ();
2016-04-04 05:39:39 +00:00
/* Check if 'onPostRemoveFolder' callback is set */
2018-03-07 11:22:35 +00:00
if ( isset ( $this -> _dms -> callbacks [ 'onPostRemoveFromDatabaseFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPostRemoveFromDatabaseFolder' ] as $callback ) {
/** @noinspection PhpStatementHasEmptyBodyInspection */
if ( ! call_user_func ( $callback [ 0 ], $callback [ 1 ], $this -> _id )) {
2016-04-26 10:06:41 +00:00
}
2016-04-04 05:39:39 +00:00
}
}
2014-12-08 13:33:13 +00:00
return true ;
} /* }}} */
/**
* Remove recursively a folder
*
* Removes a folder , all its subfolders and documents
2019-07-02 06:47:12 +00:00
* This method triggers the callbacks onPreRemoveFolder and onPostRemoveFolder .
* If onPreRemoveFolder returns a boolean then this method will return
* imediately with the value returned by the callback . Otherwise the
* regular removal is executed , which in turn
* triggers further onPreRemoveFolder and onPostRemoveFolder callbacks
* and its counterparts for documents ( onPreRemoveDocument , onPostRemoveDocument ) .
2014-12-08 13:33:13 +00:00
*
* @ return boolean true on success , false in case of an error
*/
2010-11-17 07:33:12 +00:00
function remove () { /* {{{ */
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUnusedLocalVariableInspection */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
// Do not delete the root folder.
if ( $this -> _id == $this -> _dms -> rootFolderID || ! isset ( $this -> _parentID ) || ( $this -> _parentID == null ) || ( $this -> _parentID == " " ) || ( $this -> _parentID == 0 )) {
return false ;
}
2018-03-07 11:22:35 +00:00
/* Check if 'onPreRemoveFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPreRemoveFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPreRemoveFolder' ] as $callback ) {
$ret = call_user_func ( $callback [ 0 ], $callback [ 1 ], $this );
if ( is_bool ( $ret ))
return $ret ;
}
}
2010-11-16 09:10:39 +00:00
//Entfernen der Unterordner und Dateien
$res = $this -> getSubFolders ();
if ( is_bool ( $res ) && ! $res ) return false ;
$res = $this -> getDocuments ();
if ( is_bool ( $res ) && ! $res ) return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
foreach ( $this -> _subFolders as $subFolder ) {
2012-10-05 19:46:32 +00:00
$res = $subFolder -> remove ();
2012-10-22 13:33:30 +00:00
if ( ! $res ) {
return false ;
}
2010-11-16 09:10:39 +00:00
}
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
foreach ( $this -> _documents as $document ) {
2012-10-05 19:46:32 +00:00
$res = $document -> remove ();
2012-10-22 13:33:30 +00:00
if ( ! $res ) {
return false ;
}
2010-11-16 09:10:39 +00:00
}
2011-07-20 07:17:18 +00:00
2018-03-07 11:22:35 +00:00
$ret = $this -> removeFromDatabase ();
if ( ! $ret )
return $ret ;
/* Check if 'onPostRemoveFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPostRemoveFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPostRemoveFolder' ] as $callback ) {
call_user_func ( $callback [ 0 ], $callback [ 1 ], $this );
}
}
return $ret ;
2010-11-16 09:10:39 +00:00
} /* }}} */
2019-07-02 06:47:12 +00:00
/**
* Empty recursively a folder
*
* Removes all subfolders and documents of a folder but not the folder itself
* This method will call remove () on all its children .
* This method triggers the callbacks onPreEmptyFolder and onPostEmptyFolder .
* If onPreEmptyFolder returns a boolean then this method will return
* imediately .
* Be aware that the recursive calls of remove () will trigger the callbacks
* onPreRemoveFolder , onPostRemoveFolder , onPreRemoveDocument and onPostRemoveDocument .
*
* @ return boolean true on success , false in case of an error
*/
2019-07-17 08:50:52 +00:00
function emptyFolder () { /* {{{ */
2019-07-02 06:47:12 +00:00
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this -> _dms -> getDB ();
/* Check if 'onPreEmptyFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPreEmptyFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPreEmptyFolder' ] as $callback ) {
$ret = call_user_func ( $callback [ 0 ], $callback [ 1 ], $this );
if ( is_bool ( $ret ))
return $ret ;
}
}
//Entfernen der Unterordner und Dateien
$res = $this -> getSubFolders ();
if ( is_bool ( $res ) && ! $res ) return false ;
$res = $this -> getDocuments ();
if ( is_bool ( $res ) && ! $res ) return false ;
foreach ( $this -> _subFolders as $subFolder ) {
$res = $subFolder -> remove ();
if ( ! $res ) {
return false ;
}
}
foreach ( $this -> _documents as $document ) {
$res = $document -> remove ();
if ( ! $res ) {
return false ;
}
}
/* Check if 'onPostEmptyFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onPostEmptyFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onPostEmptyFolder' ] as $callback ) {
call_user_func ( $callback [ 0 ], $callback [ 1 ], $this );
}
}
return true ;
} /* }}} */
2012-01-12 17:02:30 +00:00
/**
* Returns a list of access privileges
*
2012-08-28 07:30:27 +00:00
* If the folder inherits the access privileges from the parent folder
2012-01-12 17:02:30 +00:00
* those will be returned .
* $mode and $op can be set to restrict the list of returned access
* privileges . If $mode is set to M_ANY no restriction will apply
* regardless of the value of $op . The returned array contains a list
2013-02-14 11:10:53 +00:00
* of { @ link SeedDMS_Core_UserAccess } and
* { @ link SeedDMS_Core_GroupAccess } objects . Even if the document
2012-05-08 08:04:50 +00:00
* has no access list the returned array contains the two elements
* 'users' and 'groups' which are than empty . The methode returns false
* if the function fails .
2018-02-08 08:25:45 +00:00
*
* @ param int $mode access mode ( defaults to M_ANY )
* @ param int | string $op operation ( defaults to O_EQ )
* @ return bool | SeedDMS_Core_GroupAccess | SeedDMS_Core_UserAccess
2012-01-12 17:02:30 +00:00
*/
2010-11-16 09:10:39 +00:00
function getAccessList ( $mode = M_ANY , $op = O_EQ ) { /* {{{ */
$db = $this -> _dms -> getDB ();
if ( $this -> inheritsAccess ()) {
$res = $this -> getParent ();
if ( ! $res ) return false ;
return $this -> _parent -> getAccessList ( $mode , $op );
}
if ( ! isset ( $this -> _accessList [ $mode ])) {
if ( $op != O_GTEQ && $op != O_LTEQ && $op != O_EQ ) {
return false ;
}
$modeStr = " " ;
if ( $mode != M_ANY ) {
2011-12-01 21:20:58 +00:00
$modeStr = " AND mode " . $op . ( int ) $mode ;
2010-11-16 09:10:39 +00:00
}
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT * FROM `tblACLs` WHERE `targetType` = " . T_FOLDER .
" AND `target` = " . $this -> _id . $modeStr . " ORDER BY `targetType` " ;
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
$this -> _accessList [ $mode ] = array ( " groups " => array (), " users " => array ());
foreach ( $resArr as $row ) {
if ( $row [ " userID " ] != - 1 )
2013-02-14 11:10:53 +00:00
array_push ( $this -> _accessList [ $mode ][ " users " ], new SeedDMS_Core_UserAccess ( $this -> _dms -> getUser ( $row [ " userID " ]), $row [ " mode " ]));
2010-11-16 09:10:39 +00:00
else //if ($row["groupID"] != -1)
2013-02-14 11:10:53 +00:00
array_push ( $this -> _accessList [ $mode ][ " groups " ], new SeedDMS_Core_GroupAccess ( $this -> _dms -> getGroup ( $row [ " groupID " ]), $row [ " mode " ]));
2010-10-29 13:19:51 +00:00
}
2010-11-16 09:10:39 +00:00
}
return $this -> _accessList [ $mode ];
} /* }}} */
2012-01-12 17:02:30 +00:00
/**
* Delete all entries for this folder from the access control list
*
2015-06-19 13:24:19 +00:00
* @ param boolean $noclean set to true if notifier list shall not be clean up
2012-01-12 17:02:30 +00:00
* @ return boolean true if operation was successful otherwise false
*/
2015-06-19 13:24:19 +00:00
function clearAccessList ( $noclean = false ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblACLs` WHERE `targetType` = " . T_FOLDER . " AND `target` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
unset ( $this -> _accessList );
2015-06-19 13:24:19 +00:00
if ( ! $noclean )
2019-08-08 06:43:20 +00:00
$this -> cleanNotifyList ();
2015-06-19 13:24:19 +00:00
2010-11-16 09:10:39 +00:00
return true ;
} /* }}} */
2010-12-22 13:18:02 +00:00
/**
* Add access right to folder
* This function may change in the future . Instead of passing the a flag
* and a user / group id a user or group object will be expected .
*
* @ param integer $mode access mode
* @ param integer $userOrGroupID id of user or group
* @ param integer $isUser set to 1 if $userOrGroupID is the id of a
* user
2018-02-08 08:25:45 +00:00
* @ return bool
2010-12-22 13:18:02 +00:00
*/
2010-11-16 09:10:39 +00:00
function addAccess ( $mode , $userOrGroupID , $isUser ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$userOrGroup = ( $isUser ) ? " `userID` " : " `groupID` " ;
2010-11-16 09:10:39 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " INSERT INTO `tblACLs` (`target`, `targetType`, " . $userOrGroup . " , `mode`) VALUES
2011-12-01 21:20:58 +00:00
( " . $this->_id . " , " .T_FOLDER. " , " . (int) $userOrGroupID . " , " .(int) $mode . " ) " ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
unset ( $this -> _accessList );
// Update the notify list, if necessary.
if ( $mode == M_NONE ) {
$this -> removeNotify ( $userOrGroupID , $isUser );
}
return true ;
} /* }}} */
2010-12-22 13:18:02 +00:00
/**
* Change access right of folder
* This function may change in the future . Instead of passing the a flag
* and a user / group id a user or group object will be expected .
*
* @ param integer $newMode access mode
* @ param integer $userOrGroupID id of user or group
* @ param integer $isUser set to 1 if $userOrGroupID is the id of a
* user
2018-02-08 08:25:45 +00:00
* @ return bool
2010-12-22 13:18:02 +00:00
*/
2010-11-16 09:10:39 +00:00
function changeAccess ( $newMode , $userOrGroupID , $isUser ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$userOrGroup = ( $isUser ) ? " `userID` " : " `groupID` " ;
2010-11-16 09:10:39 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblACLs` SET `mode` = " . ( int ) $newMode . " WHERE `targetType` = " . T_FOLDER . " AND `target` = " . $this -> _id . " AND " . $userOrGroup . " = " . ( int ) $userOrGroupID ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
unset ( $this -> _accessList );
// Update the notify list, if necessary.
if ( $newMode == M_NONE ) {
$this -> removeNotify ( $userOrGroupID , $isUser );
}
return true ;
} /* }}} */
2018-02-08 08:25:45 +00:00
/**
* @ param $userOrGroupID
* @ param $isUser
* @ return bool
*/
2010-11-16 09:10:39 +00:00
function removeAccess ( $userOrGroupID , $isUser ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$userOrGroup = ( $isUser ) ? " `userID` " : " `groupID` " ;
2010-11-16 09:10:39 +00:00
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblACLs` WHERE `targetType` = " . T_FOLDER . " AND `target` = " . $this -> _id . " AND " . $userOrGroup . " = " . ( int ) $userOrGroupID ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return false ;
unset ( $this -> _accessList );
// Update the notify list, if necessary.
$mode = ( $isUser ? $this -> getAccessMode ( $this -> _dms -> getUser ( $userOrGroupID )) : $this -> getGroupAccessMode ( $this -> _dms -> getGroup ( $userOrGroupID )));
if ( $mode == M_NONE ) {
$this -> removeNotify ( $userOrGroupID , $isUser );
}
return true ;
} /* }}} */
2010-12-22 13:18:02 +00:00
/**
* Get the access mode of a user on the folder
2012-05-08 08:04:50 +00:00
*
* This function returns the access mode for a given user . An administrator
* and the owner of the folder has unrestricted access . A guest user has
* read only access or no access if access rights are further limited
* by access control lists . All other users have access rights according
* to the access control lists or the default access . This function will
* recursive check for access rights of parent folders if access rights
* are inherited .
*
2010-12-22 13:18:02 +00:00
* This function returns the access mode for a given user . An administrator
* and the owner of the folder has unrestricted access . A guest user has
* read only access or no access if access rights are further limited
* by access control lists . All other users have access rights according
* to the access control lists or the default access . This function will
* recursive check for access rights of parent folders if access rights
* are inherited .
*
2018-07-12 20:01:40 +00:00
* Before checking the access in the method itself a callback 'onCheckAccessFolder'
* is called . If it returns a value > 0 , then this will be returned by this
* method without any further checks . The optional paramater $context
* will be passed as a third parameter to the callback . It contains
* the operation for which the access mode is retrieved . It is for example
* set to 'removeDocument' if the access mode is used to check for sufficient
* permission on deleting a document .
*
2010-12-22 13:18:02 +00:00
* @ param object $user user for which access shall be checked
2018-07-12 20:01:40 +00:00
* @ param string $context context in which the access mode is requested
2010-12-22 13:18:02 +00:00
* @ return integer access mode
2010-11-16 09:10:39 +00:00
*/
2018-07-12 20:01:40 +00:00
function getAccessMode ( $user , $context = '' ) { /* {{{ */
2012-08-28 07:30:27 +00:00
if ( ! $user )
return M_NONE ;
2018-07-12 20:01:40 +00:00
/* Check if 'onCheckAccessFolder' callback is set */
if ( isset ( $this -> _dms -> callbacks [ 'onCheckAccessFolder' ])) {
foreach ( $this -> _dms -> callbacks [ 'onCheckAccessFolder' ] as $callback ) {
if (( $ret = call_user_func ( $callback [ 0 ], $callback [ 1 ], $this , $user , $context )) > 0 ) {
return $ret ;
}
}
}
2015-08-19 06:21:15 +00:00
/* Administrators have unrestricted access */
2010-11-16 09:10:39 +00:00
if ( $user -> isAdmin ()) return M_ALL ;
2011-07-20 07:17:18 +00:00
2015-08-19 06:21:15 +00:00
/* The owner of the document has unrestricted access */
2010-11-16 09:10:39 +00:00
if ( $user -> getID () == $this -> _ownerID ) return M_ALL ;
2011-07-20 07:17:18 +00:00
2015-08-19 06:21:15 +00:00
/* Check ACLs */
2010-11-16 09:10:39 +00:00
$accessList = $this -> getAccessList ();
if ( ! $accessList ) return false ;
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_UserAccess $userAccess */
2010-11-16 09:10:39 +00:00
foreach ( $accessList [ " users " ] as $userAccess ) {
if ( $userAccess -> getUserID () == $user -> getID ()) {
2015-08-19 06:21:15 +00:00
$mode = $userAccess -> getMode ();
if ( $user -> isGuest ()) {
if ( $mode >= M_READ ) $mode = M_READ ;
}
return $mode ;
2010-11-16 09:10:39 +00:00
}
2010-10-29 13:19:51 +00:00
}
2015-08-19 06:21:15 +00:00
2012-05-08 08:04:50 +00:00
/* Get the highest right defined by a group */
2015-08-19 06:21:15 +00:00
if ( $accessList [ 'groups' ]) {
$mode = 0 ;
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_GroupAccess $groupAccess */
2015-08-19 06:21:15 +00:00
foreach ( $accessList [ " groups " ] as $groupAccess ) {
if ( $user -> isMemberOfGroup ( $groupAccess -> getGroup ())) {
if ( $groupAccess -> getMode () > $mode )
$mode = $groupAccess -> getMode ();
}
}
if ( $mode ) {
if ( $user -> isGuest ()) {
if ( $mode >= M_READ ) $mode = M_READ ;
}
return $mode ;
2010-11-16 09:10:39 +00:00
}
}
2015-08-19 06:21:15 +00:00
$mode = $this -> getDefaultAccess ();
if ( $user -> isGuest ()) {
if ( $mode >= M_READ ) $mode = M_READ ;
}
return $mode ;
2010-11-16 09:10:39 +00:00
} /* }}} */
2010-12-22 13:18:02 +00:00
/**
* Get the access mode for a group on the folder
* This function returns the access mode for a given group . The algorithmn
* applied to get the access mode is the same as describe at
* { @ link getAccessMode }
*
2017-10-28 12:28:12 +00:00
* @ param SeedDMS_Core_Group $group group for which access shall be checked
2010-12-22 13:18:02 +00:00
* @ return integer access mode
*/
2010-11-16 09:10:39 +00:00
function getGroupAccessMode ( $group ) { /* {{{ */
$highestPrivileged = M_NONE ;
$foundInACL = false ;
$accessList = $this -> getAccessList ();
if ( ! $accessList )
return false ;
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_GroupAccess $groupAccess */
2010-11-16 09:10:39 +00:00
foreach ( $accessList [ " groups " ] as $groupAccess ) {
if ( $groupAccess -> getGroupID () == $group -> getID ()) {
$foundInACL = true ;
if ( $groupAccess -> getMode () > $highestPrivileged )
$highestPrivileged = $groupAccess -> getMode ();
2010-12-22 13:18:02 +00:00
if ( $highestPrivileged == M_ALL ) /* no need to check further */
2010-11-16 09:10:39 +00:00
return $highestPrivileged ;
}
}
if ( $foundInACL )
return $highestPrivileged ;
2010-12-22 13:18:02 +00:00
/* Take default access */
2010-11-16 09:10:39 +00:00
return $this -> getDefaultAccess ();
} /* }}} */
2018-02-08 08:25:45 +00:00
/** @noinspection PhpUnusedParameterInspection */
2010-12-22 13:18:02 +00:00
/**
* Get a list of all notification
* This function returns all users and groups that have registerd a
* notification for the folder
*
2013-01-28 10:15:34 +00:00
* @ param integer $type type of notification ( not yet used )
2017-10-28 12:28:12 +00:00
* @ return SeedDMS_Core_User [] | SeedDMS_Core_Group [] | bool array with a the elements 'users' and 'groups' which
2010-12-22 13:18:02 +00:00
* contain a list of users and groups .
*/
2013-02-06 13:52:51 +00:00
function getNotifyList ( $type = 0 ) { /* {{{ */
2011-01-28 07:32:51 +00:00
if ( empty ( $this -> _notifyList )) {
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT * FROM `tblNotify` WHERE `targetType` = " . T_FOLDER . " AND `target` = " . $this -> _id ;
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
$this -> _notifyList = array ( " groups " => array (), " users " => array ());
foreach ( $resArr as $row )
{
2017-07-27 20:10:44 +00:00
if ( $row [ " userID " ] != - 1 ) {
$u = $this -> _dms -> getUser ( $row [ " userID " ]);
if ( $u && ! $u -> isDisabled ())
array_push ( $this -> _notifyList [ " users " ], $u );
} else { //if ($row["groupID"] != -1)
$g = $this -> _dms -> getGroup ( $row [ " groupID " ]);
if ( $g )
array_push ( $this -> _notifyList [ " groups " ], $g );
}
2010-11-16 09:10:39 +00:00
}
}
return $this -> _notifyList ;
} /* }}} */
2015-06-19 13:02:37 +00:00
/**
* Make sure only users / groups with read access are in the notify list
*
*/
function cleanNotifyList () { /* {{{ */
// If any of the notification subscribers no longer have read access,
// remove their subscription.
if ( empty ( $this -> _notifyList ))
$this -> getNotifyList ();
/* Make a copy of both notifier lists because removeNotify will empty
* $this -> _notifyList and the second foreach will not work anymore .
*/
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_User[] $nusers */
2015-06-19 13:02:37 +00:00
$nusers = $this -> _notifyList [ " users " ];
$ngroups = $this -> _notifyList [ " groups " ];
foreach ( $nusers as $u ) {
if ( $this -> getAccessMode ( $u ) < M_READ ) {
$this -> removeNotify ( $u -> getID (), true );
}
}
2017-10-28 12:28:12 +00:00
2018-02-08 08:25:45 +00:00
/** @var SeedDMS_Core_Group[] $ngroups */
2015-06-19 13:02:37 +00:00
foreach ( $ngroups as $g ) {
if ( $this -> getGroupAccessMode ( $g ) < M_READ ) {
$this -> removeNotify ( $g -> getID (), false );
}
}
} /* }}} */
2017-10-28 12:28:12 +00:00
/**
2010-12-22 13:18:02 +00:00
* Add a user / group to the notification list
* This function does not check if the currently logged in user
* is allowed to add a notification . This must be checked by the calling
* application .
2010-11-16 09:10:39 +00:00
*
* @ param integer $userOrGroupID
* @ param boolean $isUser true if $userOrGroupID is a user id otherwise false
* @ return integer error code
* - 1 : Invalid User / Group ID .
* - 2 : Target User / Group does not have read access .
* - 3 : User is already subscribed .
* - 4 : Database / internal error .
* 0 : Update successful .
*/
function addNotify ( $userOrGroupID , $isUser ) { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$userOrGroup = ( $isUser ) ? " `userID` " : " `groupID` " ;
2010-11-16 09:10:39 +00:00
/* Verify that user / group exists */
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_User|SeedDMS_Core_Group $obj */
2010-11-16 09:10:39 +00:00
$obj = ( $isUser ? $this -> _dms -> getUser ( $userOrGroupID ) : $this -> _dms -> getGroup ( $userOrGroupID ));
if ( ! is_object ( $obj )) {
return - 1 ;
}
/* Verify that the requesting user has permission to add the target to
* the notification system .
*/
2010-12-22 13:18:02 +00:00
/*
* The calling application should enforce the policy on who is allowed
* to add someone to the notification system . If is shall remain here
* the currently logged in user should be passed to this function
*
GLOBAL $user ;
2010-12-03 07:27:27 +00:00
if ( $user -> isGuest ()) {
2010-11-16 09:10:39 +00:00
return - 2 ;
}
if ( ! $user -> isAdmin ()) {
if ( $isUser ) {
if ( $user -> getID () != $obj -> getID ()) {
return - 2 ;
}
}
else {
if ( ! $obj -> isMember ( $user )) {
return - 2 ;
}
}
}
2010-12-22 13:18:02 +00:00
*/
2010-11-16 09:10:39 +00:00
//
// Verify that user / group has read access to the document.
//
if ( $isUser ) {
// Users are straightforward to check.
if ( $this -> getAccessMode ( $obj ) < M_READ ) {
return - 2 ;
}
}
else {
2012-02-01 07:40:24 +00:00
// FIXME: Why not check the access list first and if this returns
// not result, then use the default access?
2010-11-16 09:10:39 +00:00
// Groups are a little more complex.
if ( $this -> getDefaultAccess () >= M_READ ) {
// If the default access is at least READ-ONLY, then just make sure
// that the current group has not been explicitly excluded.
$acl = $this -> getAccessList ( M_NONE , O_EQ );
$found = false ;
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_GroupAccess $group */
2010-11-16 09:10:39 +00:00
foreach ( $acl [ " groups " ] as $group ) {
if ( $group -> getGroupID () == $userOrGroupID ) {
$found = true ;
break ;
}
}
if ( $found ) {
return - 2 ;
}
}
else {
// The default access is restricted. Make sure that the group has
// been explicitly allocated access to the document.
$acl = $this -> getAccessList ( M_READ , O_GTEQ );
if ( is_bool ( $acl )) {
return - 4 ;
}
$found = false ;
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_GroupAccess $group */
2010-11-16 09:10:39 +00:00
foreach ( $acl [ " groups " ] as $group ) {
if ( $group -> getGroupID () == $userOrGroupID ) {
$found = true ;
break ;
}
}
if ( ! $found ) {
return - 2 ;
}
}
}
//
// Check to see if user/group is already on the list.
//
$queryStr = " SELECT * FROM `tblNotify` WHERE `tblNotify`.`target` = ' " . $this -> _id . " ' " .
" AND `tblNotify`.`targetType` = ' " . T_FOLDER . " ' " .
2017-02-13 17:23:24 +00:00
" AND `tblNotify`. " . $userOrGroup . " = ' " . ( int ) $userOrGroupID . " ' " ;
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr )) {
return - 4 ;
}
if ( count ( $resArr ) > 0 ) {
return - 3 ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " INSERT INTO `tblNotify` (`target`, `targetType`, " . $userOrGroup . " ) VALUES ( " . $this -> _id . " , " . T_FOLDER . " , " . ( int ) $userOrGroupID . " ) " ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return - 4 ;
unset ( $this -> _notifyList );
return 0 ;
} /* }}} */
2018-02-08 08:25:45 +00:00
/**
2010-11-16 09:10:39 +00:00
* Removes notify for a user or group to folder
2010-12-22 13:18:02 +00:00
* This function does not check if the currently logged in user
* is allowed to remove a notification . This must be checked by the calling
* application .
2010-11-16 09:10:39 +00:00
*
* @ param integer $userOrGroupID
* @ param boolean $isUser true if $userOrGroupID is a user id otherwise false
2018-02-08 08:25:45 +00:00
* @ param int $type type of notification ( 0 will delete all ) Not used yet !
* @ return int error code
2010-11-16 09:10:39 +00:00
* - 1 : Invalid User / Group ID .
2018-02-08 08:25:45 +00:00
* - 3 : User is not subscribed .
* - 4 : Database / internal error .
* 0 : Update successful .
2010-11-16 09:10:39 +00:00
*/
2013-01-28 10:15:34 +00:00
function removeNotify ( $userOrGroupID , $isUser , $type = 0 ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2011-07-20 07:17:18 +00:00
2010-11-16 09:10:39 +00:00
/* Verify that user / group exists. */
$obj = ( $isUser ? $this -> _dms -> getUser ( $userOrGroupID ) : $this -> _dms -> getGroup ( $userOrGroupID ));
if ( ! is_object ( $obj )) {
return - 1 ;
}
2017-02-13 17:23:24 +00:00
$userOrGroup = ( $isUser ) ? " `userID` " : " `groupID` " ;
2010-11-16 09:10:39 +00:00
/* Verify that the requesting user has permission to add the target to
* the notification system .
*/
2010-12-22 13:18:02 +00:00
/*
* The calling application should enforce the policy on who is allowed
* to add someone to the notification system . If is shall remain here
* the currently logged in user should be passed to this function
*
GLOBAL $user ;
2010-12-03 07:27:27 +00:00
if ( $user -> isGuest ()) {
2010-11-16 09:10:39 +00:00
return - 2 ;
}
if ( ! $user -> isAdmin ()) {
if ( $isUser ) {
if ( $user -> getID () != $obj -> getID ()) {
return - 2 ;
}
}
else {
if ( ! $obj -> isMember ( $user )) {
return - 2 ;
}
}
}
2010-12-22 13:18:02 +00:00
*/
2010-11-16 09:10:39 +00:00
//
// Check to see if the target is in the database.
//
$queryStr = " SELECT * FROM `tblNotify` WHERE `tblNotify`.`target` = ' " . $this -> _id . " ' " .
" AND `tblNotify`.`targetType` = ' " . T_FOLDER . " ' " .
2017-02-13 17:23:24 +00:00
" AND `tblNotify`. " . $userOrGroup . " = ' " . ( int ) $userOrGroupID . " ' " ;
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr )) {
return - 4 ;
}
if ( count ( $resArr ) == 0 ) {
return - 3 ;
}
2017-02-10 07:04:19 +00:00
$queryStr = " DELETE FROM `tblNotify` WHERE `target` = " . $this -> _id . " AND `targetType` = " . T_FOLDER . " AND " . $userOrGroup . " = " . ( int ) $userOrGroupID ;
2013-01-28 10:15:34 +00:00
/* If type is given then delete only those notifications */
if ( $type )
$queryStr .= " AND `type` = " . ( int ) $type ;
2010-11-16 09:10:39 +00:00
if ( ! $db -> getResult ( $queryStr ))
return - 4 ;
unset ( $this -> _notifyList );
return 0 ;
} /* }}} */
2013-02-11 13:55:51 +00:00
/**
* Get List of users and groups which have read access on the document
*
* This function is deprecated . Use
2013-02-14 11:10:53 +00:00
* { @ see SeedDMS_Core_Folder :: getReadAccessList ()} instead .
2013-02-11 13:55:51 +00:00
*/
2010-11-16 09:10:39 +00:00
function getApproversList () { /* {{{ */
2013-02-27 08:06:45 +00:00
return $this -> getReadAccessList ( 0 , 0 );
2013-02-11 13:55:51 +00:00
} /* }}} */
/**
* Returns a list of groups and users with read access on the folder
2014-03-18 06:06:08 +00:00
* The list will not include any guest users ,
* administrators and the owner of the folder unless $listadmin resp .
* $listowner is set to true .
2013-02-11 13:55:51 +00:00
*
2018-02-08 08:25:45 +00:00
* @ param bool | int $listadmin if set to true any admin will be listed too
* @ param bool | int $listowner if set to true the owner will be listed too
2013-02-11 13:55:51 +00:00
* @ return array list of users and groups
*/
2013-02-27 08:06:45 +00:00
function getReadAccessList ( $listadmin = 0 , $listowner = 0 ) { /* {{{ */
2010-11-16 09:10:39 +00:00
$db = $this -> _dms -> getDB ();
2013-02-11 13:55:51 +00:00
if ( ! isset ( $this -> _readAccessList )) {
$this -> _readAccessList = array ( " groups " => array (), " users " => array ());
2010-11-16 09:10:39 +00:00
$userIDs = " " ;
$groupIDs = " " ;
$defAccess = $this -> getDefaultAccess ();
2013-02-11 13:55:51 +00:00
/* Check if the default access is < read access or >= read access .
* If default access is less than read access , then create a list
* of users and groups with read access .
* If default access is equal or greater then read access , then
* create a list of users and groups without read access .
*/
2010-11-16 09:10:39 +00:00
if ( $defAccess < M_READ ) {
// Get the list of all users and groups that are listed in the ACL as
2013-02-11 13:55:51 +00:00
// having read access to the folder.
2010-11-16 09:10:39 +00:00
$tmpList = $this -> getAccessList ( M_READ , O_GTEQ );
}
else {
2013-02-11 13:55:51 +00:00
// Get the list of all users and groups that DO NOT have read access
2010-11-16 09:10:39 +00:00
// to the folder.
$tmpList = $this -> getAccessList ( M_NONE , O_LTEQ );
}
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_GroupAccess $groupAccess */
2011-02-18 16:25:46 +00:00
foreach ( $tmpList [ " groups " ] as $groupAccess ) {
$groupIDs .= ( strlen ( $groupIDs ) == 0 ? " " : " , " ) . $groupAccess -> getGroupID ();
2010-11-16 09:10:39 +00:00
}
2017-10-28 12:28:12 +00:00
/** @var SeedDMS_Core_UserAccess $userAccess */
2011-02-18 16:25:46 +00:00
foreach ( $tmpList [ " users " ] as $userAccess ) {
$user = $userAccess -> getUser ();
2013-02-27 08:06:45 +00:00
if ( ! $listadmin && $user -> isAdmin ()) continue ;
if ( ! $listowner && $user -> getID () == $this -> _ownerID ) continue ;
2013-02-11 13:55:51 +00:00
if ( $user -> isGuest ()) continue ;
$userIDs .= ( strlen ( $userIDs ) == 0 ? " " : " , " ) . $userAccess -> getUserID ();
2010-11-16 09:10:39 +00:00
}
// Construct a query against the users table to identify those users
2013-02-11 13:55:51 +00:00
// that have read access to this folder, either directly through an
2010-11-16 09:10:39 +00:00
// ACL entry, by virtue of ownership or by having administrative rights
// on the database.
$queryStr = " " ;
2013-02-11 13:55:51 +00:00
/* If default access is less then read , $userIDs and $groupIDs contains
* a list of user with read access
*/
2010-11-16 09:10:39 +00:00
if ( $defAccess < M_READ ) {
if ( strlen ( $groupIDs ) > 0 ) {
2013-02-11 13:55:51 +00:00
$queryStr = " SELECT `tblUsers`.* FROM `tblUsers` " .
2010-11-16 09:10:39 +00:00
" LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` " .
" WHERE `tblGroupMembers`.`groupID` IN ( " . $groupIDs . " ) " .
2013-02-14 11:10:53 +00:00
" AND `tblUsers`.`role` != " . SeedDMS_Core_User :: role_guest . " UNION " ;
2010-11-16 09:10:39 +00:00
}
2013-02-11 13:55:51 +00:00
$queryStr .=
" SELECT `tblUsers`.* FROM `tblUsers` " .
2013-02-14 11:10:53 +00:00
" WHERE (`tblUsers`.`role` != " . SeedDMS_Core_User :: role_guest . " ) " .
2010-11-16 09:10:39 +00:00
" AND ((`tblUsers`.`id` = " . $this -> _ownerID . " ) " .
2013-02-14 11:10:53 +00:00
" OR (`tblUsers`.`role` = " . SeedDMS_Core_User :: role_admin . " ) " .
2010-11-16 09:10:39 +00:00
( strlen ( $userIDs ) == 0 ? " " : " OR (`tblUsers`.`id` IN ( " . $userIDs . " )) " ) .
2013-02-11 13:55:51 +00:00
" ) ORDER BY `login` " ;
2010-11-16 09:10:39 +00:00
}
2013-02-11 13:55:51 +00:00
/* If default access is equal or greate then read , $userIDs and
* $groupIDs contains a list of user without read access
*/
2010-11-16 09:10:39 +00:00
else {
if ( strlen ( $groupIDs ) > 0 ) {
2013-02-11 13:55:51 +00:00
$queryStr = " SELECT `tblUsers`.* FROM `tblUsers` " .
2010-11-16 09:10:39 +00:00
" LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` " .
" WHERE `tblGroupMembers`.`groupID` NOT IN ( " . $groupIDs . " ) " .
2013-02-14 11:10:53 +00:00
" AND `tblUsers`.`role` != " . SeedDMS_Core_User :: role_guest . " " .
2013-02-11 13:55:51 +00:00
( strlen ( $userIDs ) == 0 ? " " : " AND (`tblUsers`.`id` NOT IN ( " . $userIDs . " )) " ) . " UNION " ;
2010-11-16 09:10:39 +00:00
}
2013-02-11 13:55:51 +00:00
$queryStr .=
" SELECT `tblUsers`.* FROM `tblUsers` " .
2010-11-16 09:10:39 +00:00
" WHERE (`tblUsers`.`id` = " . $this -> _ownerID . " ) " .
2013-02-14 11:10:53 +00:00
" OR (`tblUsers`.`role` = " . SeedDMS_Core_User :: role_admin . " ) " .
2010-11-16 09:10:39 +00:00
" UNION " .
2013-02-11 13:55:51 +00:00
" SELECT `tblUsers`.* FROM `tblUsers` " .
2013-02-14 11:10:53 +00:00
" WHERE `tblUsers`.`role` != " . SeedDMS_Core_User :: role_guest . " " .
2013-02-11 13:55:51 +00:00
( strlen ( $userIDs ) == 0 ? " " : " AND (`tblUsers`.`id` NOT IN ( " . $userIDs . " )) " ) .
2010-11-16 09:10:39 +00:00
" ORDER BY `login` " ;
2010-10-29 13:19:51 +00:00
}
2010-11-16 09:10:39 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( ! is_bool ( $resArr )) {
2010-10-29 13:19:51 +00:00
foreach ( $resArr as $row ) {
2010-11-22 14:54:55 +00:00
$user = $this -> _dms -> getUser ( $row [ 'id' ]);
2013-02-27 08:06:45 +00:00
if ( ! $listadmin && $user -> isAdmin ()) continue ;
if ( ! $listowner && $user -> getID () == $this -> _ownerID ) continue ;
2013-02-11 13:55:51 +00:00
$this -> _readAccessList [ " users " ][] = $user ;
2010-11-16 09:10:39 +00:00
}
}
2013-02-11 13:55:51 +00:00
// Assemble the list of groups that have read access to the folder.
2010-11-16 09:10:39 +00:00
$queryStr = " " ;
if ( $defAccess < M_READ ) {
if ( strlen ( $groupIDs ) > 0 ) {
$queryStr = " SELECT `tblGroups`.* FROM `tblGroups` " .
2017-01-10 16:51:46 +00:00
" WHERE `tblGroups`.`id` IN ( " . $groupIDs . " ) ORDER BY `name` " ;
2010-11-16 09:10:39 +00:00
}
}
else {
if ( strlen ( $groupIDs ) > 0 ) {
$queryStr = " SELECT `tblGroups`.* FROM `tblGroups` " .
2017-01-10 16:51:46 +00:00
" WHERE `tblGroups`.`id` NOT IN ( " . $groupIDs . " ) ORDER BY `name` " ;
2010-11-16 09:10:39 +00:00
}
else {
2017-01-10 16:51:46 +00:00
$queryStr = " SELECT `tblGroups`.* FROM `tblGroups` ORDER BY `name` " ;
2010-11-16 09:10:39 +00:00
}
}
if ( strlen ( $queryStr ) > 0 ) {
$resArr = $db -> getResultArray ( $queryStr );
if ( ! is_bool ( $resArr )) {
foreach ( $resArr as $row ) {
2011-02-08 09:00:32 +00:00
$group = $this -> _dms -> getGroup ( $row [ " id " ]);
2013-02-11 13:55:51 +00:00
$this -> _readAccessList [ " groups " ][] = $group ;
2010-11-16 09:10:39 +00:00
}
}
}
}
2013-02-11 13:55:51 +00:00
return $this -> _readAccessList ;
2010-11-16 09:10:39 +00:00
} /* }}} */
2011-11-28 14:03:01 +00:00
/**
* Get the internally used folderList which stores the ids of folders from
* the root folder to the parent folder .
*
* @ return string column separated list of folder ids
*/
function getFolderList () { /* {{{ */
$db = $this -> _dms -> getDB ();
2017-02-10 07:04:19 +00:00
$queryStr = " SELECT `folderList` FROM `tblFolders` where `id` = " . $this -> _id ;
2011-11-28 14:03:01 +00:00
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && ! $resArr )
return false ;
return $resArr [ 0 ][ 'folderList' ];
} /* }}} */
/**
* Checks the internal data of the folder and repairs it .
* Currently , this function only repairs an incorrect folderList
*
* @ return boolean true on success , otherwise false
*/
function repair () { /* {{{ */
$db = $this -> _dms -> getDB ();
$curfolderlist = $this -> getFolderList ();
// calculate the folderList of the folder
$parent = $this -> getParent ();
$pathPrefix = " " ;
$path = $parent -> getPath ();
foreach ( $path as $f ) {
$pathPrefix .= " : " . $f -> getID ();
}
if ( strlen ( $pathPrefix ) > 1 ) {
$pathPrefix .= " : " ;
}
if ( $curfolderlist != $pathPrefix ) {
2017-02-10 07:04:19 +00:00
$queryStr = " UPDATE `tblFolders` SET `folderList`=' " . $pathPrefix . " ' WHERE `id` = " . $this -> _id ;
2011-11-28 14:03:01 +00:00
$res = $db -> getResult ( $queryStr );
if ( ! $res )
return false ;
}
return true ;
} /* }}} */
2018-02-07 08:51:20 +00:00
/**
* Get the min and max sequence value for documents
*
2018-02-08 08:25:45 +00:00
* @ return bool | array array with keys 'min' and 'max' , false in case of an error
2018-02-07 08:51:20 +00:00
*/
function getDocumentsMinMax () { /* {{{ */
$db = $this -> _dms -> getDB ();
$queryStr = " SELECT min(`sequence`) AS `min`, max(`sequence`) AS `max` FROM `tblDocuments` WHERE `folder` = " . ( int ) $this -> _id ;
$resArr = $db -> getResultArray ( $queryStr );
if ( is_bool ( $resArr ) && $resArr == false )
return false ;
return $resArr [ 0 ];
} /* }}} */
2010-11-16 09:10:39 +00:00
}
?>