mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
replace array_search by in_array, makeTimestamp() returns an error if days > max days of month
This commit is contained in:
parent
ad52fffd21
commit
b0d13f9518
|
@ -123,13 +123,6 @@ class SeedDMS_Core_DMS {
|
|||
*/
|
||||
public $maxDirID;
|
||||
|
||||
/**
|
||||
* @var boolean $enableConverting set to true if conversion of content
|
||||
* is desired
|
||||
* @access public
|
||||
*/
|
||||
public $enableConverting;
|
||||
|
||||
/**
|
||||
* @var boolean $forceRename use renameFile() instead of copyFile() when
|
||||
* copying the document content into the data store. The default is
|
||||
|
@ -141,19 +134,6 @@ class SeedDMS_Core_DMS {
|
|||
*/
|
||||
public $forceRename;
|
||||
|
||||
/**
|
||||
* @var array $convertFileTypes list of files types that shall be converted
|
||||
* @access public
|
||||
*/
|
||||
public $convertFileTypes;
|
||||
|
||||
/**
|
||||
* @var array $viewOnlineFileTypes list of files types that can be viewed
|
||||
* online
|
||||
* @access public
|
||||
*/
|
||||
public $viewOnlineFileTypes;
|
||||
|
||||
/**
|
||||
* @var array $noReadForStatus list of status without read right
|
||||
* online.
|
||||
|
@ -391,8 +371,6 @@ class SeedDMS_Core_DMS {
|
|||
$this->maxDirID = 0; //31998;
|
||||
$this->forceRename = false;
|
||||
$this->checkWithinRootDir = false;
|
||||
$this->enableConverting = false;
|
||||
$this->convertFileTypes = array();
|
||||
$this->noReadForStatus = array();
|
||||
$this->classnames = array();
|
||||
$this->classnames['folder'] = 'SeedDMS_Core_Folder';
|
||||
|
@ -507,7 +485,7 @@ class SeedDMS_Core_DMS {
|
|||
function getDBVersion() { /* {{{ */
|
||||
$tbllist = $this->db->TableList();
|
||||
$tbllist = explode(',',strtolower(join(',',$tbllist)));
|
||||
if(!array_search('tblversion', $tbllist))
|
||||
if(!in_array('tblversion', $tbllist))
|
||||
return false;
|
||||
$queryStr = "SELECT * FROM `tblVersion` order by `major`,`minor`,`subminor` limit 1";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
|
@ -529,7 +507,7 @@ class SeedDMS_Core_DMS {
|
|||
function checkVersion() { /* {{{ */
|
||||
$tbllist = $this->db->TableList();
|
||||
$tbllist = explode(',',strtolower(join(',',$tbllist)));
|
||||
if(!array_search('tblversion', $tbllist))
|
||||
if(!in_array('tblversion', $tbllist))
|
||||
return true;
|
||||
$queryStr = "SELECT * FROM `tblVersion` order by `major`,`minor`,`subminor` limit 1";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
|
@ -592,18 +570,6 @@ class SeedDMS_Core_DMS {
|
|||
return $this->getFolder($this->rootFolderID);
|
||||
} /* }}} */
|
||||
|
||||
function setEnableConverting($enable) { /* {{{ */
|
||||
$this->enableConverting = $enable;
|
||||
} /* }}} */
|
||||
|
||||
function setConvertFileTypes($types) { /* {{{ */
|
||||
$this->convertFileTypes = $types;
|
||||
} /* }}} */
|
||||
|
||||
function setViewOnlineFileTypes($types) { /* {{{ */
|
||||
$this->viewOnlineFileTypes = $types;
|
||||
} /* }}} */
|
||||
|
||||
function setForceRename($enable) { /* {{{ */
|
||||
$this->forceRename = $enable;
|
||||
} /* }}} */
|
||||
|
@ -640,7 +606,7 @@ class SeedDMS_Core_DMS {
|
|||
* This function retrieves a document from the database by its id.
|
||||
*
|
||||
* @param integer $id internal id of document
|
||||
* @return SeedDMS_Core_Document instance of {@link SeedDMS_Core_Document} or false
|
||||
* @return SeedDMS_Core_Document instance of {@link SeedDMS_Core_Document}, null or false
|
||||
*/
|
||||
function getDocument($id) { /* {{{ */
|
||||
$classname = $this->classnames['document'];
|
||||
|
@ -1367,7 +1333,7 @@ class SeedDMS_Core_DMS {
|
|||
else $queryStr .= "ORDER BY `name`";
|
||||
$queryStr .= " ".$orderdir;
|
||||
break; // }}}
|
||||
default:
|
||||
default: // {{{
|
||||
return false;
|
||||
break; // }}}
|
||||
}
|
||||
|
@ -1402,21 +1368,17 @@ class SeedDMS_Core_DMS {
|
|||
$month = (int) $month;
|
||||
$day = (int) $day;
|
||||
|
||||
if (array_search($month, $thirtyone)) {
|
||||
if(in_array($month, $thirtyone)) {
|
||||
$max=31;
|
||||
}
|
||||
else if (array_search($month, $thirty)) {
|
||||
} elseif(in_array($month, $thirty)) {
|
||||
$max=30;
|
||||
}
|
||||
else {
|
||||
} 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.
|
||||
// Check again if day of month is valid in the given month
|
||||
if ($day>$max) {
|
||||
$day=$max;
|
||||
return false;
|
||||
}
|
||||
|
||||
return mktime($hour, $min, $sec, $month, $day, $year);
|
||||
|
@ -2013,26 +1975,6 @@ class SeedDMS_Core_DMS {
|
|||
function getFolderByName($name, $folder=null) { /* {{{ */
|
||||
$classname = $this->classnames['folder'];
|
||||
return $classname::getInstanceByName($name, $folder, $this);
|
||||
|
||||
if (!$name) return false;
|
||||
|
||||
$queryStr = "SELECT * FROM `tblFolders` WHERE `name` = " . $this->db->qstr($name);
|
||||
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;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
/** @var SeedDMS_Core_Folder $folder */
|
||||
$folder = new $this->classnames['folder']($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["date"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
|
||||
$folder->setDMS($this);
|
||||
return $folder;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
@ -2057,7 +1999,27 @@ class SeedDMS_Core_DMS {
|
|||
foreach($cache as $id=>$rec) {
|
||||
if(!array_key_exists($rec['parent'], $cache) && $rec['parent'] != 0) {
|
||||
$errors[$id] = array('id'=>$id, 'name'=>$rec['name'], 'parent'=>$rec['parent'], 'msg'=>'Missing parent');
|
||||
} else {
|
||||
}
|
||||
if(!isset($errors[$id])) {
|
||||
/* Create the real folderList and compare it with the stored folderList */
|
||||
$parent = $rec['parent'];
|
||||
$fl = [];
|
||||
while($parent) {
|
||||
array_unshift($fl, $parent);
|
||||
$parent = $cache[$parent]['parent'];
|
||||
}
|
||||
if($fl)
|
||||
$flstr = ':'.implode(':', $fl).':';
|
||||
else
|
||||
$flstr = '';
|
||||
if($flstr != $rec['folderList'])
|
||||
$errors[$id] = array('id'=>$id, 'name'=>$rec['name'], 'parent'=>$rec['parent'], 'msg'=>'Wrong folder list '.$flstr.'!='.$rec['folderList']);
|
||||
}
|
||||
if(!isset($errors[$id])) {
|
||||
/* This is the old insufficient test which will most likely not be called
|
||||
* anymore, because the check for a wrong folder list will cache a folder
|
||||
* list problem anyway.
|
||||
*/
|
||||
$tmparr = explode(':', $rec['folderList']);
|
||||
array_shift($tmparr);
|
||||
if(count($tmparr) != count(array_unique($tmparr))) {
|
||||
|
@ -2102,7 +2064,21 @@ class SeedDMS_Core_DMS {
|
|||
foreach($dcache as $id=>$rec) {
|
||||
if(!array_key_exists($rec['parent'], $fcache) && $rec['parent'] != 0) {
|
||||
$errors[$id] = array('id'=>$id, 'name'=>$rec['name'], 'parent'=>$rec['parent'], 'msg'=>'Missing parent');
|
||||
} else {
|
||||
}
|
||||
if(!isset($errors[$id])) {
|
||||
/* Create the real folderList and compare it with the stored folderList */
|
||||
$parent = $rec['parent'];
|
||||
$fl = [];
|
||||
while($parent) {
|
||||
array_unshift($fl, $parent);
|
||||
$parent = $fcache[$parent]['parent'];
|
||||
}
|
||||
if($fl)
|
||||
$flstr = ':'.implode(':', $fl).':';
|
||||
if($flstr != $rec['folderList'])
|
||||
$errors[$id] = array('id'=>$id, 'name'=>$rec['name'], 'parent'=>$rec['parent'], 'msg'=>'Wrong folder list '.$flstr.'!='.$rec['folderList']);
|
||||
}
|
||||
if(!isset($errors[$id])) {
|
||||
$tmparr = explode(':', $rec['folderList']);
|
||||
array_shift($tmparr);
|
||||
if(count($tmparr) != count(array_unique($tmparr))) {
|
||||
|
@ -3107,13 +3083,13 @@ class SeedDMS_Core_DMS {
|
|||
break;
|
||||
}
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` where";
|
||||
$queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` WHERE";
|
||||
switch($usergroup) {
|
||||
case 'user':
|
||||
$queryStr .= " a.`type`=0 and a.`required` not in (select `id` from `tblUsers`) ORDER by b.`id`";
|
||||
$queryStr .= " a.`type`=0 and a.`required` not in (SELECT `id` FROM `tblUsers`) ORDER by b.`id`";
|
||||
break;
|
||||
case 'group':
|
||||
$queryStr .= " a.`type`=1 and a.`required` not in (select `id` from `tblGroups`) ORDER by b.`id`";
|
||||
$queryStr .= " a.`type`=1 and a.`required` not in (SELECT `id` FROM `tblGroups`) ORDER by b.`id`";
|
||||
break;
|
||||
}
|
||||
return $this->db->getResultArray($queryStr);
|
||||
|
@ -3169,58 +3145,60 @@ class SeedDMS_Core_DMS {
|
|||
* documents or used space per user, recent activity, etc.
|
||||
*
|
||||
* @param string $type type of statistic
|
||||
* @return array|bool
|
||||
* @return array|bool returns false if the sql statement fails, returns an empty
|
||||
* array if no documents or folder where found, otherwise returns a non empty
|
||||
* array with statistical data
|
||||
*/
|
||||
function getStatisticalData($type='') { /* {{{ */
|
||||
switch($type) {
|
||||
case 'docsperuser':
|
||||
$queryStr = "select ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." as `key`, count(`owner`) as total from `tblDocuments` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`";
|
||||
$queryStr = "SELECT ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." AS `key`, count(`owner`) AS total FROM `tblDocuments` a LEFT JOIN `tblUsers` b ON a.`owner`=b.`id` GROUP BY `owner`, b.`fullName`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'foldersperuser':
|
||||
$queryStr = "select ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." as `key`, count(`owner`) as total from `tblFolders` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`";
|
||||
$queryStr = "SELECT ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." AS `key`, count(`owner`) AS total FROM `tblFolders` a LEFT JOIN `tblUsers` b ON a.`owner`=b.`id` GROUP BY `owner`, b.`fullName`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'docspermimetype':
|
||||
$queryStr = "select b.`mimeType` as `key`, count(`mimeType`) as total from `tblDocuments` a left join `tblDocumentContent` b on a.`id`=b.`document` group by b.`mimeType`";
|
||||
$queryStr = "SELECT b.`mimeType` AS `key`, count(`mimeType`) AS total FROM `tblDocuments` a LEFT JOIN `tblDocumentContent` b ON a.`id`=b.`document` GROUP BY b.`mimeType`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'docspercategory':
|
||||
$queryStr = "select b.`name` as `key`, count(a.`categoryID`) as total from `tblDocumentCategory` a left join `tblCategory` b on a.`categoryID`=b.id group by a.`categoryID`, b.`name`";
|
||||
$queryStr = "SELECT b.`name` AS `key`, count(a.`categoryID`) AS total FROM `tblDocumentCategory` a LEFT JOIN `tblCategory` b ON a.`categoryID`=b.id GROUP BY a.`categoryID`, b.`name`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'docsperstatus':
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$queryStr = "select b.`status` as `key`, count(b.`status`) as total from (select a.id, max(b.version), max(c.`statusLogID`) as maxlog from `tblDocuments` a left join `tblDocumentStatus` b on a.id=b.`documentID` left join `tblDocumentStatusLog` c on b.`statusID`=c.`statusID` group by a.`id`, b.`version` order by a.`id`, b.`statusID`) a left join `tblDocumentStatusLog` b on a.`maxlog`=b.`statusLogID` group by b.`status`";
|
||||
$queryStr = "select b.`status` as `key`, count(b.`status`) as total from (select a.`id`, max(c.`statusLogID`) as maxlog from `tblDocuments` a left join `tblDocumentStatus` b on a.id=b.`documentID` left join `tblDocumentStatusLog` c on b.`statusID`=c.`statusID` group by a.`id` order by a.id) a left join `tblDocumentStatusLog` b on a.maxlog=b.`statusLogID` group by b.`status`";
|
||||
$queryStr = "SELECT b.`status` AS `key`, count(b.`status`) AS total FROM (SELECT a.id, max(b.version), max(c.`statusLogID`) AS maxlog FROM `tblDocuments` a LEFT JOIN `tblDocumentStatus` b ON a.id=b.`documentID` LEFT JOIN `tblDocumentStatusLog` c ON b.`statusID`=c.`statusID` GROUP BY a.`id`, b.`version` ORDER BY a.`id`, b.`statusID`) a LEFT JOIN `tblDocumentStatusLog` b ON a.`maxlog`=b.`statusLogID` GROUP BY b.`status`";
|
||||
$queryStr = "SELECT b.`status` AS `key`, count(b.`status`) AS total FROM (SELECT a.`id`, max(c.`statusLogID`) AS maxlog FROM `tblDocuments` a LEFT JOIN `tblDocumentStatus` b ON a.id=b.`documentID` LEFT JOIN `tblDocumentStatusLog` c ON b.`statusID`=c.`statusID` GROUP BY a.`id` ORDER BY a.id) a LEFT JOIN `tblDocumentStatusLog` b ON a.maxlog=b.`statusLogID` GROUP BY b.`status`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'docspermonth':
|
||||
$queryStr = "select *, count(`key`) as total from (select ".$this->db->getDateExtract("date", '%Y-%m')." as `key` from `tblDocuments`) a group by `key` order by `key`";
|
||||
$queryStr = "SELECT *, count(`key`) AS total FROM (SELECT ".$this->db->getDateExtract("date", '%Y-%m')." AS `key` FROM `tblDocuments`) a GROUP BY `key` ORDER BY `key`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
case 'docsaccumulated':
|
||||
$queryStr = "select *, count(`key`) as total from (select ".$this->db->getDateExtract("date")." as `key` from `tblDocuments`) a group by `key` order by `key`";
|
||||
$queryStr = "SELECT *, count(`key`) AS total FROM (SELECT ".$this->db->getDateExtract("date")." AS `key` FROM `tblDocuments`) a GROUP BY `key` ORDER BY `key`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$sum = 0;
|
||||
|
@ -3234,9 +3212,9 @@ class SeedDMS_Core_DMS {
|
|||
}
|
||||
return $resArr;
|
||||
case 'sizeperuser':
|
||||
$queryStr = "select ".$this->db->concat(array('c.`fullName`', "' ('", 'c.`login`', "')'"))." as `key`, sum(`fileSize`) as total from `tblDocuments` a left join `tblDocumentContent` b on a.id=b.`document` left join `tblUsers` c on a.`owner`=c.`id` group by a.`owner`, c.`fullName`";
|
||||
$queryStr = "SELECT ".$this->db->concat(array('c.`fullName`', "' ('", 'c.`login`', "')'"))." AS `key`, sum(`fileSize`) AS total FROM `tblDocuments` a LEFT JOIN `tblDocumentContent` b ON a.id=b.`document` LEFT JOIN `tblUsers` c ON a.`owner`=c.`id` GROUP BY a.`owner`, c.`fullName`";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
if (!$resArr)
|
||||
if(is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
return $resArr;
|
||||
|
|
Loading…
Reference in New Issue
Block a user