mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
c3ef148ca6
|
@ -127,7 +127,7 @@
|
||||||
- minimize sql queries when fetching sub folders and documents of a folder
|
- minimize sql queries when fetching sub folders and documents of a folder
|
||||||
- custom attributes can be validated in a hook
|
- custom attributes can be validated in a hook
|
||||||
- document attributes comment, keywords, categories, expiration date, and sequence
|
- document attributes comment, keywords, categories, expiration date, and sequence
|
||||||
can be turned of in the configuration
|
can be turned off in the configuration
|
||||||
- workflows can be turned off completely
|
- workflows can be turned off completely
|
||||||
- Extension can be enabled/disabled in the extension manager, the previously
|
- Extension can be enabled/disabled in the extension manager, the previously
|
||||||
used method by setting a parameter in the extension's config file will no
|
used method by setting a parameter in the extension's config file will no
|
||||||
|
|
|
@ -101,4 +101,8 @@ require_once('Core/inc.FileUtils.php');
|
||||||
*/
|
*/
|
||||||
require_once('Core/inc.ClassTransmittal.php');
|
require_once('Core/inc.ClassTransmittal.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses SeedDMS_File
|
||||||
|
*/
|
||||||
|
require_once('Core/inc.ClassIterator.php');
|
||||||
?>
|
?>
|
||||||
|
|
229
SeedDMS_Core/Core/inc.ClassIterator.php
Normal file
229
SeedDMS_Core/Core/inc.ClassIterator.php
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of the document iterartor
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS_Core
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010, Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DocumentIterator implements Iterator {
|
||||||
|
/**
|
||||||
|
* @var object folder
|
||||||
|
*/
|
||||||
|
protected $_folder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object dms
|
||||||
|
*/
|
||||||
|
protected $_dms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array documents
|
||||||
|
*/
|
||||||
|
protected $_documents;
|
||||||
|
|
||||||
|
public function __construct($folder) {
|
||||||
|
$this->_folder = $folder;
|
||||||
|
$this->_dms = $folder->getDMS();
|
||||||
|
$this->_documents = array();
|
||||||
|
$this->_pointer = 0;
|
||||||
|
$this->_cache = array();
|
||||||
|
$this->populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rewind() {
|
||||||
|
$this->_pointer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valid() {
|
||||||
|
return isset($this->_documents[$this->_pointer]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function next() {
|
||||||
|
$this->_pointer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key() {
|
||||||
|
return $this->_folders[$this->_pointer];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function current() {
|
||||||
|
if($this->_documents[$this->_pointer]) {
|
||||||
|
$documentid = $this->_documents[$this->_pointer]['id'];
|
||||||
|
if(!isset($this->_cache[$documentid])) {
|
||||||
|
// echo $documentid." not cached<br />";
|
||||||
|
$this->_cache[$documentid] = $this->_dms->getdocument($documentid);
|
||||||
|
}
|
||||||
|
return $this->_cache[$documentid];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function populate($orderby="", $dir="asc", $limit=0, $offset=0) { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr = "SELECT `id` FROM `tblDocuments` WHERE `folder` = " . $this->_folder->getID();
|
||||||
|
|
||||||
|
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`";
|
||||||
|
if($dir == 'desc')
|
||||||
|
$queryStr .= " DESC";
|
||||||
|
if(is_int($limit) && $limit > 0) {
|
||||||
|
$queryStr .= " LIMIT ".$limit;
|
||||||
|
if(is_int($offset) && $offset > 0)
|
||||||
|
$queryStr .= " OFFSET ".$offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && $resArr == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->_documents = $resArr;
|
||||||
|
} /* }}} */
|
||||||
|
}
|
||||||
|
|
||||||
|
class FolderIterator implements Iterator { /* {{{ */
|
||||||
|
/**
|
||||||
|
* @var object folder
|
||||||
|
*/
|
||||||
|
protected $_folder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object dms
|
||||||
|
*/
|
||||||
|
protected $_dms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array documents
|
||||||
|
*/
|
||||||
|
protected $_folders;
|
||||||
|
|
||||||
|
public function __construct($folder) { /* {{{ */
|
||||||
|
$this->_folder = $folder;
|
||||||
|
$this->_dms = $folder->getDMS();
|
||||||
|
$this->_folders = array();
|
||||||
|
$this->_pointer = 0;
|
||||||
|
$this->_cache = array();
|
||||||
|
$this->populate();
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function rewind() { /* {{{ */
|
||||||
|
$this->_pointer = 0;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function valid() { /* {{{ */
|
||||||
|
return isset($this->_folders[$this->_pointer]);
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function next() { /* {{{ */
|
||||||
|
$this->_pointer++;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function key() { /* {{{ */
|
||||||
|
return $this->_folders[$this->_pointer];
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function current() { /* {{{ */
|
||||||
|
if($this->_folders[$this->_pointer]) {
|
||||||
|
$folderid = $this->_folders[$this->_pointer]['id'];
|
||||||
|
if(!isset($this->_cache[$folderid])) {
|
||||||
|
// echo $folderid." not cached<br />";
|
||||||
|
$this->_cache[$folderid] = $this->_dms->getFolder($folderid);
|
||||||
|
}
|
||||||
|
return $this->_cache[$folderid];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
private function populate($orderby="", $dir="asc", $limit=0, $offset=0) { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr = "SELECT `id` FROM `tblFolders` WHERE `parent` = " . $this->_folder->getID();
|
||||||
|
|
||||||
|
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`";
|
||||||
|
if($dir == 'desc')
|
||||||
|
$queryStr .= " DESC";
|
||||||
|
if(is_int($limit) && $limit > 0) {
|
||||||
|
$queryStr .= " LIMIT ".$limit;
|
||||||
|
if(is_int($offset) && $offset > 0)
|
||||||
|
$queryStr .= " OFFSET ".$offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && $resArr == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->_folders = $resArr;
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The FolderFilterIterator checks if the given user has access on
|
||||||
|
* the current folder.
|
||||||
|
* FilterIterator uses an inner iterator passed to the constructor
|
||||||
|
* to iterate over the sub folders of a folder.
|
||||||
|
*
|
||||||
|
$iter = new FolderIterator($folder);
|
||||||
|
$iter2 = new FolderFilterIterator($iter, $user);
|
||||||
|
foreach($iter2 as $ff) {
|
||||||
|
echo $ff->getName()."<br />";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
class FolderFilterIterator extends FilterIterator { /* {{{ */
|
||||||
|
public function __construct(Iterator $iterator , $filter ) {
|
||||||
|
parent::__construct($iterator);
|
||||||
|
$this->userFilter = $filter;
|
||||||
|
}
|
||||||
|
public function accept() { /* {{{ */
|
||||||
|
$folder = $this->getInnerIterator()->current();
|
||||||
|
echo "accept() for ".$folder->getName()."<br />";
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
$iter = new RecursiveFolderIterator($folder);
|
||||||
|
$iter2 = new RecursiveIteratorIterator($iter, RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
foreach($iter2 as $ff) {
|
||||||
|
echo $ff->getID().': '.$ff->getName()."<br />";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
class RecursiveFolderIterator extends FolderIterator implements RecursiveIterator { /* {{{ */
|
||||||
|
|
||||||
|
public function hasChildren() { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
$queryStr = "SELECT id FROM `tblFolders` WHERE `parent` = ".(int) $this->current()->getID();
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function getChildren() { /* {{{ */
|
||||||
|
return new RecursiveFolderIterator($this->current());
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
class RecursiveFolderFilterIterator extends FolderFilterIterator { /* {{{ */
|
||||||
|
public function hasChildren() { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
$queryStr = "SELECT id FROM `tblFolders` WHERE `parent` = ".(int) $this->current()->getID();
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function getChildren() { /* {{{ */
|
||||||
|
return new RecursiveFolderIterator($this->current());
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
} /* }}} */
|
|
@ -87,6 +87,9 @@ remove a user from all its process can also be used to set a new user
|
||||||
<file name="inc.ClassDecorator.php" role="php">
|
<file name="inc.ClassDecorator.php" role="php">
|
||||||
<tasks:replace from="@package_version@" to="version" type="package-info" />
|
<tasks:replace from="@package_version@" to="version" type="package-info" />
|
||||||
</file>
|
</file>
|
||||||
|
<file name="inc.ClassIterator.php" role="php">
|
||||||
|
<tasks:replace from="@package_version@" to="version" type="package-info" />
|
||||||
|
</file>
|
||||||
</dir> <!-- /DTD -->
|
</dir> <!-- /DTD -->
|
||||||
<dir name="tests">
|
<dir name="tests">
|
||||||
<file name="getfoldertree.php" role="test" />
|
<file name="getfoldertree.php" role="test" />
|
||||||
|
|
|
@ -350,7 +350,7 @@ class Settings { /* {{{ */
|
||||||
// Load config file
|
// Load config file
|
||||||
if (!defined("SEEDDMS_INSTALL")) {
|
if (!defined("SEEDDMS_INSTALL")) {
|
||||||
if(!file_exists($configFilePath)) {
|
if(!file_exists($configFilePath)) {
|
||||||
echo "You does not seem to have a valid configuration. Run the <a href=\"install/install.php\">install tool</a> first.";
|
echo "You do not seem to have a valid configuration. Run the <a href=\"install/install.php\">install tool</a> first.";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,6 +615,20 @@ function getBaseUrl() { /* {{{ */
|
||||||
return "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'];
|
return "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'];
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function getToken($length){
|
||||||
|
$token = "";
|
||||||
|
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
$codeAlphabet.= "0123456789";
|
||||||
|
$max = strlen($codeAlphabet);
|
||||||
|
|
||||||
|
for ($i=0; $i < $length; $i++) {
|
||||||
|
$token .= $codeAlphabet[random_int(0, $max-1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
class SeedDMS_CSRF {
|
class SeedDMS_CSRF {
|
||||||
|
|
||||||
protected $secret;
|
protected $secret;
|
||||||
|
|
15
index.php
15
index.php
|
@ -60,6 +60,21 @@ if(true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$app->get('/out/[{path:.*}]', function($request, $response, $path = null) use ($app) {
|
||||||
|
$uri = $request->getUri();
|
||||||
|
if($uri->getBasePath())
|
||||||
|
$file = $uri->getPath();
|
||||||
|
else
|
||||||
|
$file = substr($uri->getPath(), 1);
|
||||||
|
if(file_exists($file) && is_file($file)) {
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = basename($file);
|
||||||
|
include($file);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("../inc/inc.ClassSettings.php");
|
if(isset($_SERVER['SEEDDMS_HOME'])) {
|
||||||
|
require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php");
|
||||||
|
} else {
|
||||||
|
require_once("../inc/inc.ClassSettings.php");
|
||||||
|
}
|
||||||
|
require("Log.php");
|
||||||
|
|
||||||
function usage() { /* {{{ */
|
function usage() { /* {{{ */
|
||||||
echo "Usage:\n";
|
echo "Usage:\n";
|
||||||
|
@ -50,10 +55,12 @@ if(isset($options['c'])) {
|
||||||
|
|
||||||
if(isset($settings->_extraPath))
|
if(isset($settings->_extraPath))
|
||||||
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
||||||
ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path'));
|
//ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path'));
|
||||||
|
|
||||||
|
require_once("inc/inc.Init.php");
|
||||||
|
require_once("inc/inc.Extension.php");
|
||||||
|
require_once("inc/inc.DBInit.php");
|
||||||
|
|
||||||
include("../inc/inc.Extension.php");
|
|
||||||
require_once("SeedDMS/Core.php");
|
|
||||||
if($settings->_fullSearchEngine == 'sqlitefts') {
|
if($settings->_fullSearchEngine == 'sqlitefts') {
|
||||||
$indexconf = array(
|
$indexconf = array(
|
||||||
'Indexer' => 'SeedDMS_SQLiteFTS_Indexer',
|
'Indexer' => 'SeedDMS_SQLiteFTS_Indexer',
|
||||||
|
|
|
@ -49,7 +49,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
||||||
|
|
||||||
protected function getTextField($name, $value, $type='', $placeholder='') { /* {{{ */
|
protected function getTextField($name, $value, $type='', $placeholder='') { /* {{{ */
|
||||||
$html = '';
|
$html = '';
|
||||||
if($type != 'password' && strlen($value) > 80)
|
if($type == 'textarea' || ($type != 'password' && strlen($value) > 80))
|
||||||
$html .= '<textarea class="input-xxlarge" name="'.$name.'">'.$value.'</textarea>';
|
$html .= '<textarea class="input-xxlarge" name="'.$name.'">'.$value.'</textarea>';
|
||||||
else {
|
else {
|
||||||
if(strlen($value) > 40)
|
if(strlen($value) > 40)
|
||||||
|
@ -110,7 +110,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
||||||
else
|
else
|
||||||
$value = $settings->{"_".$name};
|
$value = $settings->{"_".$name};
|
||||||
?>
|
?>
|
||||||
<td><?php $this->showTextField($name, $value, ($type=='password' ? 'password' : ''), $placeholder); ?></td>
|
<td><?php $this->showTextField($name, $value, ($type=='password' || $type=='textarea' ? $type : ''), $placeholder); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user