mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 12:11:19 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
3c4be73678
|
@ -261,6 +261,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
return $searchFields;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return an document by its id
|
||||
*
|
||||
* @param integer $id id of document
|
||||
* @return object/boolean instance of SeedDMS_Core_Document if document exists, null
|
||||
* if document does not exist, false in case of error
|
||||
*/
|
||||
public static function getInstance($id, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
||||
|
@ -269,7 +276,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
if (count($resArr) != 1)
|
||||
return false;
|
||||
return null;
|
||||
$resArr = $resArr[0];
|
||||
|
||||
// New Locking mechanism uses a separate table to track the lock.
|
||||
|
@ -417,6 +424,61 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add a list of categories to the document
|
||||
* This function will add a list of new categories to the document.
|
||||
*
|
||||
* @param array $newCategories list of category objects
|
||||
*/
|
||||
function addCategories($newCategories) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if(!$this->_categories)
|
||||
self::getCategories();
|
||||
|
||||
$catids = array();
|
||||
foreach($this->_categories as $cat)
|
||||
$catids[] = $cat->getID();
|
||||
|
||||
$db->startTransaction();
|
||||
$ncat = array(); // Array containing actually added new categories
|
||||
foreach($newCategories as $cat) {
|
||||
if(!in_array($cat->getID(), $catids)) {
|
||||
$queryStr = "INSERT INTO `tblDocumentCategory` (`categoryID`, `documentID`) VALUES (". $cat->getId() .", ". $this->_id .")";
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$ncat[] = $cat;
|
||||
}
|
||||
}
|
||||
$db->commitTransaction();
|
||||
$this->_categories = array_merge($this->_categories, $ncat);
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Remove a list of categories from the document
|
||||
* This function will remove a list of assigned categories to the document.
|
||||
*
|
||||
* @param array $newCategories list of category objects
|
||||
*/
|
||||
function removeCategories($categories) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$catids = array();
|
||||
foreach($categories as $cat)
|
||||
$catids[] = $cat->getID();
|
||||
|
||||
$queryStr = "DELETE from `tblDocumentCategory` WHERE `documentID` = ". $this->_id ." AND `categoryID` IN (".implode(',', $catids).")";
|
||||
if (!$db->getResult($queryStr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_categories = null;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return creation date of the document
|
||||
*
|
||||
|
|
|
@ -125,6 +125,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
return $sql;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return a folder by its id
|
||||
*
|
||||
* @param integer $id id of folder
|
||||
* @return object/boolean instance of SeedDMS_Core_Folder if document exists, null
|
||||
* if document does not exist, false in case of error
|
||||
*/
|
||||
public static function getInstance($id, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
||||
|
@ -133,7 +140,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
else if (count($resArr) != 1)
|
||||
return false;
|
||||
return null;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
$classname = $dms->getClassname('folder');
|
||||
|
|
|
@ -58,14 +58,15 @@ class SeedDMS_Core_Group { /* {{{ */
|
|||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create an instance of a group object
|
||||
* Return an instance of a group object
|
||||
*
|
||||
* @param string|integer $id Id, name of group, depending
|
||||
* on the 3rd parameter.
|
||||
* @param object $dms instance of dms
|
||||
* @param string $by search by group name if set to 'name'.
|
||||
* Search by Id of group if left empty.
|
||||
* @return object instance of class SeedDMS_Core_Group
|
||||
* @return object instance of class SeedDMS_Core_Group if group was found, null
|
||||
* if group was not found, false in case of error
|
||||
*/
|
||||
public static function getInstance($id, $dms, $by='') { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
@ -82,7 +83,7 @@ class SeedDMS_Core_Group { /* {{{ */
|
|||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
|
||||
return false;
|
||||
return null;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
|
|
|
@ -404,7 +404,8 @@ class SeedDMS_Core_User { /* {{{ */
|
|||
* will check for the 4th paramater and also filter by email. If this
|
||||
* parameter is left empty, the user will be search by its Id.
|
||||
* @param string $email optional email address if searching for name
|
||||
* @return object instance of class SeedDMS_Core_User
|
||||
* @return object instance of class SeedDMS_Core_User if user was found, null
|
||||
* if user was not found, false in case of error
|
||||
*/
|
||||
public static function getInstance($id, $dms, $by='', $email='') { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
@ -424,7 +425,7 @@ class SeedDMS_Core_User { /* {{{ */
|
|||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false) return false;
|
||||
if (count($resArr) != 1) return false;
|
||||
if (count($resArr) != 1) return null;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
|
|
|
@ -1566,6 +1566,9 @@ returns just users which are not disabled
|
|||
- remove SeedDMS_Core_DocumentCategory::addCategory() and getCategories()
|
||||
- add optional parameters $limit and $offset to SeedDMS_Core_Folder::getDocuments()
|
||||
and SeedDMS_Core_Folder::getSubFolders()
|
||||
- getInstance() returns now null instead of false if the object was not found in the db
|
||||
- add new methods SeedDMS_Core_Document::addCategories() and
|
||||
SeedDMS_Core_Document::removeCategories()
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
|
|
|
@ -94,7 +94,7 @@ class SeedDMS_Session {
|
|||
* @return string/boolean id of session of false in case of an error
|
||||
*/
|
||||
function create($data) { /* {{{ */
|
||||
$id = "" . rand() . time() . rand() . "";
|
||||
$id = "" . rand() . '-'.microtime() . '-'.rand() . "";
|
||||
$id = md5($id);
|
||||
$lastaccess = time();
|
||||
$queryStr = "INSERT INTO `tblSessions` (`id`, `userID`, `lastAccess`, `theme`, `language`, `su`) ".
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
require_once("../inc/inc.ClassSettings.php");
|
||||
#require_once("../inc/inc.ClassSettings.php");
|
||||
include("../inc/inc.Settings.php");
|
||||
include("../inc/inc.Extension.php");
|
||||
|
||||
function usage() { /* {{{ */
|
||||
echo "Usage:\n";
|
||||
|
@ -15,7 +17,7 @@ function usage() { /* {{{ */
|
|||
echo " --config: set alternative config file.\n";
|
||||
} /* }}} */
|
||||
|
||||
$version = "0.0.1";
|
||||
$version = "0.0.2";
|
||||
$shortoptions = "hvc";
|
||||
$longoptions = array('help', 'version', 'config:');
|
||||
if(false === ($options = getopt($shortoptions, $longoptions))) {
|
||||
|
@ -83,7 +85,16 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
|||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||
try {
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
|
||||
# $index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
|
||||
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
|
||||
if (method_exists($hookObj, 'preIndexDocument')) {
|
||||
$hookObj->preIndexDocument(null, $document, $idoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
$index->addDocument($idoc);
|
||||
echo " (Document added)\n";
|
||||
} catch(Exception $e) {
|
||||
echo " (Timeout)\n";
|
||||
|
@ -100,7 +111,17 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
|||
} else {
|
||||
$index->delete($hit->id);
|
||||
try {
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
|
||||
# $index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
|
||||
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
|
||||
if (method_exists($hookObj, 'preIndexDocument')) {
|
||||
$hookObj->preIndexDocument(null, $document, $idoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
$index->addDocument($idoc);
|
||||
|
||||
echo " (Document updated)\n";
|
||||
} catch(Exception $e) {
|
||||
echo " (Timeout)\n";
|
||||
|
|
Loading…
Reference in New Issue
Block a user