mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 21:51:32 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
446472c3b1
|
@ -167,6 +167,7 @@
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
- add hooks showDocumentAttribute and showDocumentContentAttribute in Search view
|
- add hooks showDocumentAttribute and showDocumentContentAttribute in Search view
|
||||||
- fix layout problems of select2 menu, add option for adding an icon to each option
|
- fix layout problems of select2 menu, add option for adding an icon to each option
|
||||||
|
- better import for users from csv file
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Changes in version 5.1.18
|
Changes in version 5.1.18
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace SeedDMS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the document iterartor
|
* Implementation of the document iterartor
|
||||||
*
|
*
|
||||||
|
@ -11,7 +13,7 @@
|
||||||
* @version Release: @package_version@
|
* @version Release: @package_version@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DocumentIterator implements Iterator {
|
class DocumentIterator implements \Iterator {
|
||||||
/**
|
/**
|
||||||
* @var object folder
|
* @var object folder
|
||||||
*/
|
*/
|
||||||
|
@ -88,7 +90,7 @@ class DocumentIterator implements Iterator {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
}
|
}
|
||||||
|
|
||||||
class FolderIterator implements Iterator { /* {{{ */
|
class FolderIterator implements \Iterator { /* {{{ */
|
||||||
/**
|
/**
|
||||||
* @var object folder
|
* @var object folder
|
||||||
*/
|
*/
|
||||||
|
@ -177,7 +179,7 @@ class FolderIterator implements Iterator { /* {{{ */
|
||||||
echo $ff->getName()."<br />";
|
echo $ff->getName()."<br />";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
class FolderFilterIterator extends FilterIterator { /* {{{ */
|
class FolderFilterIterator extends \FilterIterator { /* {{{ */
|
||||||
public function __construct(Iterator $iterator , $filter ) {
|
public function __construct(Iterator $iterator , $filter ) {
|
||||||
parent::__construct($iterator);
|
parent::__construct($iterator);
|
||||||
$this->userFilter = $filter;
|
$this->userFilter = $filter;
|
||||||
|
@ -196,7 +198,7 @@ class FolderFilterIterator extends FilterIterator { /* {{{ */
|
||||||
echo $ff->getID().': '.$ff->getName()."<br />";
|
echo $ff->getID().': '.$ff->getName()."<br />";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
class RecursiveFolderIterator extends FolderIterator implements RecursiveIterator { /* {{{ */
|
class RecursiveFolderIterator extends FolderIterator implements \RecursiveIterator { /* {{{ */
|
||||||
|
|
||||||
public function hasChildren() { /* {{{ */
|
public function hasChildren() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
|
@ -662,6 +662,18 @@ function resolveTask($task) {
|
||||||
return $task;
|
return $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for creating encrypted api keys
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* $CSRF = new SeedDMS_CSRF($settings->_encryptionKey);
|
||||||
|
* $kkk = $CSRF->create_api_key();
|
||||||
|
* echo $kkk;
|
||||||
|
* echo $CSRF->check_api_key($kkk) ? 'valid' : 'invalid';
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
*/
|
||||||
class SeedDMS_CSRF { /* {{{ */
|
class SeedDMS_CSRF { /* {{{ */
|
||||||
|
|
||||||
protected $secret;
|
protected $secret;
|
||||||
|
@ -709,7 +721,15 @@ class SeedDMS_CSRF { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
//$CSRF = new SeedDMS_CSRF($settings->_encryptionKey);
|
class SeedDMS_FolderTree { /* {{{ */
|
||||||
//$kkk = $CSRF->create_api_key();
|
|
||||||
//echo $kkk;
|
public function __construct($folder, $callback) { /* {{{ */
|
||||||
//echo $CSRF->check_api_key($kkk) ? 'valid' : 'invalid';
|
$iter = new \SeedDMS\RecursiveFolderIterator($folder);
|
||||||
|
$iter2 = new RecursiveIteratorIterator($iter, RecursiveIteratorIterator:: SELF_FIRST);
|
||||||
|
foreach($iter2 as $ff) {
|
||||||
|
call_user_func($callback, $ff);
|
||||||
|
// echo $ff->getID().': '.$ff->getFolderPathPlain().'-'.$ff->getName()."<br />";
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
} /* }}} */
|
||||||
|
|
|
@ -31,11 +31,19 @@ function getBaseData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
return $objdata;
|
return $objdata;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function renderBaseData($colname, $objdata) { /* {{{ */
|
||||||
|
return $objdata[$colname];
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function getPasswordPlainData($colname, $coldata, $objdata) { /* {{{ */
|
function getPasswordPlainData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
$objdata['passenc'] = seed_pass_hash($coldata);
|
$objdata['passenc'] = seed_pass_hash($coldata);
|
||||||
return $objdata;
|
return $objdata;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function renderPasswordPlainData($colname, $objdata) { /* {{{ */
|
||||||
|
return $objdata[$colname];
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function getQuotaData($colname, $coldata, $objdata) { /* {{{ */
|
function getQuotaData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
$objdata[$colname] = SeedDMS_Core_File::parse_filesize($coldata);
|
$objdata[$colname] = SeedDMS_Core_File::parse_filesize($coldata);
|
||||||
return $objdata;
|
return $objdata;
|
||||||
|
@ -46,6 +54,9 @@ function getFolderData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
if($coldata) {
|
if($coldata) {
|
||||||
if($folder = $dms->getFolder((int)$coldata)) {
|
if($folder = $dms->getFolder((int)$coldata)) {
|
||||||
$objdata['homefolder'] = $folder;
|
$objdata['homefolder'] = $folder;
|
||||||
|
} else {
|
||||||
|
$objdata['homefolder'] = null;
|
||||||
|
$objdata['__logs__'][] = array('type'=>'error', 'msg'=> "No such folder with id '".(int) $coldata."'");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$objdata['homefolder'] = null;
|
$objdata['homefolder'] = null;
|
||||||
|
@ -53,14 +64,30 @@ function getFolderData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
return $objdata;
|
return $objdata;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function renderFolderData($colname, $objdata) { /* {{{ */
|
||||||
|
return is_object($objdata[$colname]) ? $objdata[$colname]->getName() : '';
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function getGroupData($colname, $coldata, $objdata) { /* {{{ */
|
function getGroupData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
global $dms;
|
global $dms;
|
||||||
|
if(!isset($objdata['groups']))
|
||||||
|
$objdata['groups'] = [];
|
||||||
if($group = $dms->getGroupByName($coldata)) {
|
if($group = $dms->getGroupByName($coldata)) {
|
||||||
$objdata['groups'][] = $group;
|
$objdata['groups'][] = $group;
|
||||||
|
} else {
|
||||||
|
$objdata['groups'] = [];
|
||||||
|
$objdata['__logs__'][] = array('type'=>'error', 'msg'=> "No such group with name '".$coldata."'");
|
||||||
}
|
}
|
||||||
return $objdata;
|
return $objdata;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function renderGroupData($colname, $objdata) { /* {{{ */
|
||||||
|
$html = '';
|
||||||
|
foreach($objdata[$colname] as $g)
|
||||||
|
$html .= $g->getName().';';
|
||||||
|
return $html;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function getRoleData($colname, $coldata, $objdata) { /* {{{ */
|
function getRoleData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
switch($coldata) {
|
switch($coldata) {
|
||||||
case 'admin':
|
case 'admin':
|
||||||
|
@ -69,18 +96,28 @@ function getRoleData($colname, $coldata, $objdata) { /* {{{ */
|
||||||
case 'guest':
|
case 'guest':
|
||||||
$role = 2;
|
$role = 2;
|
||||||
break;
|
break;
|
||||||
|
case 'user':
|
||||||
|
$role = 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$role = 0;
|
$role = 0;
|
||||||
|
$objdata['__logs__'][] = array('type'=>'error', 'msg'=> "No such role with name '".$coldata."'");
|
||||||
}
|
}
|
||||||
$objdata['role'] = $role;
|
$objdata['role'] = $role;
|
||||||
return $objdata;
|
return $objdata;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function renderRoleData($colname, $objdata) { /* {{{ */
|
||||||
|
return ($objdata[$colname] == 1 ? 'admin' : ($objdata[$colname] == 2 ? 'guest' : 'user'));
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
if (!$user->isAdmin()) {
|
if (!$user->isAdmin()) {
|
||||||
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = array();
|
$log = array();
|
||||||
|
$newusers = array();
|
||||||
|
$csvheader = array();
|
||||||
if (isset($_FILES['userdata']) && $_FILES['userdata']['error'] == 0) {
|
if (isset($_FILES['userdata']) && $_FILES['userdata']['error'] == 0) {
|
||||||
if(!is_uploaded_file($_FILES["userdata"]["tmp_name"]))
|
if(!is_uploaded_file($_FILES["userdata"]["tmp_name"]))
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||||
|
@ -91,26 +128,37 @@ if (isset($_FILES['userdata']) && $_FILES['userdata']['error'] == 0) {
|
||||||
$csvdelim = ';';
|
$csvdelim = ';';
|
||||||
$csvencl = '"';
|
$csvencl = '"';
|
||||||
if($fp = fopen($_FILES['userdata']['tmp_name'], 'r')) {
|
if($fp = fopen($_FILES['userdata']['tmp_name'], 'r')) {
|
||||||
|
/* First of all build up a column map, which contains for each columen
|
||||||
|
* the column name
|
||||||
|
* (taken from the first line of the csv file), a function for getting
|
||||||
|
* interpreting the data from the csv file and a function to return the
|
||||||
|
* interpreted data as a string.
|
||||||
|
* The column map will only contain entries for known column (whose head
|
||||||
|
* line is one of 'login', 'email', 'name', 'role', 'homefolder', etc.)
|
||||||
|
* Unknown columns will be skipped and the index in the column map will
|
||||||
|
* be left out.
|
||||||
|
*/
|
||||||
$colmap = array();
|
$colmap = array();
|
||||||
if($header = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
if($csvheader = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
||||||
foreach($header as $i=>$colname) {
|
foreach($csvheader as $i=>$colname) {
|
||||||
$colname = trim($colname);
|
$colname = trim($colname);
|
||||||
if(substr($colname, 0, 5) == 'group') {
|
if(substr($colname, 0, 5) == 'group') {
|
||||||
$colmap[$i] = array("getGroupData", $colname);
|
$colmap[$i] = array("getGroupData", "renderGroupData", $colname);
|
||||||
} elseif(in_array($colname, array('role'))) {
|
} elseif(in_array($colname, array('role'))) {
|
||||||
$colmap[$i] = array("getRoleData", $colname);
|
$colmap[$i] = array("getRoleData", "renderRoleData", $colname);
|
||||||
} elseif(in_array($colname, array('homefolder'))) {
|
} elseif(in_array($colname, array('homefolder'))) {
|
||||||
$colmap[$i] = array("getFolderData", $colname);
|
$colmap[$i] = array("getFolderData", "renderFolderData", $colname);
|
||||||
} elseif(in_array($colname, array('quota'))) {
|
} elseif(in_array($colname, array('quota'))) {
|
||||||
$colmap[$i] = array("getQuotaData", $colname);
|
$colmap[$i] = array("getQuotaData", "renderQuotaData", $colname);
|
||||||
} elseif(in_array($colname, array('password'))) {
|
} elseif(in_array($colname, array('password'))) {
|
||||||
$colmap[$i] = array("getPasswordPlainData", $colname);
|
/* getPasswordPlainData() will set 'passenc' */
|
||||||
|
$colmap[$i] = array("getPasswordPlainData", "renderPasswordPlainData", 'passenc');
|
||||||
} elseif(in_array($colname, array('login', 'name', 'passenc', 'email', 'comment', 'group'))) {
|
} elseif(in_array($colname, array('login', 'name', 'passenc', 'email', 'comment', 'group'))) {
|
||||||
$colmap[$i] = array("getBaseData", $colname);
|
$colmap[$i] = array("getBaseData", "renderBaseData", $colname);
|
||||||
} elseif(substr($colname, 0, 5) == 'attr:') {
|
} elseif(substr($colname, 0, 5) == 'attr:') {
|
||||||
$kk = explode(':', $colname, 2);
|
$kk = explode(':', $colname, 2);
|
||||||
if(($attrdef = $dms->getAttributeDefinitionByName($kk[1])) || ($attrdef = $dms->getAttributeDefinition((int) $kk[1]))) {
|
if(($attrdef = $dms->getAttributeDefinitionByName($kk[1])) || ($attrdef = $dms->getAttributeDefinition((int) $kk[1]))) {
|
||||||
$colmap[$i] = array("getAttributeData", $attrdef);
|
$colmap[$i] = array("getAttributeData", "renderAttributeData", $attrdef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,61 +169,71 @@ if (isset($_FILES['userdata']) && $_FILES['userdata']['error'] == 0) {
|
||||||
$userids = array();
|
$userids = array();
|
||||||
foreach($allusers as $muser)
|
foreach($allusers as $muser)
|
||||||
$userids[$muser->getLogin()] = $muser;
|
$userids[$muser->getLogin()] = $muser;
|
||||||
|
/* Run through all records in the csv file and fill $newusers.
|
||||||
|
* $newusers will contain an associated array for each record, with
|
||||||
|
* the key being the column name. The array may be shorter than
|
||||||
|
* the number of columns, because $colmap may not contain a mapping
|
||||||
|
* for each column.
|
||||||
|
*/
|
||||||
$newusers = array();
|
$newusers = array();
|
||||||
while(!feof($fp)) {
|
while(!feof($fp)) {
|
||||||
if($data = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
if($data = fgetcsv($fp, 0, $csvdelim, $csvencl)) {
|
||||||
$md = array();
|
$md = array();
|
||||||
foreach($data as $i=>$coldata) {
|
foreach($data as $i=>$coldata) {
|
||||||
|
/* First check if a column mapping exists. It could be missing
|
||||||
|
* because the column has a not known header or it is missing.
|
||||||
|
*/
|
||||||
if(isset($colmap[$i])) {
|
if(isset($colmap[$i])) {
|
||||||
$md = call_user_func($colmap[$i][0], $colmap[$i][1], $coldata, $md);
|
$md = call_user_func($colmap[$i][0], $colmap[$i][2], $coldata, $md);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($md)
|
if($md && $md['login'])
|
||||||
$newusers[] = $md;
|
$newusers[$md['login']] = $md;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// echo "<pre>";print_r($newusers);echo "</pre>";
|
// echo "<pre>";print_r($newusers);echo "</pre>";
|
||||||
$makeupdate = !empty($_POST['update']);
|
$makeupdate = !empty($_POST['update']);
|
||||||
foreach($newusers as $u) {
|
foreach($newusers as $uhash=>$u) {
|
||||||
|
$log[$uhash] = [];
|
||||||
if($eu = $dms->getUserByLogin($u['login'])) {
|
if($eu = $dms->getUserByLogin($u['login'])) {
|
||||||
if(isset($u['name']) && $u['name'] != $eu->getFullName()) {
|
if(isset($u['name']) && $u['name'] != $eu->getFullName()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Name of user updated. '".$u['name']."' != '".$eu->getFullName()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Name of user updated. '".$u['name']."' != '".$eu->getFullName()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setFullName($u['name']);
|
$eu->setFullName($u['name']);
|
||||||
}
|
}
|
||||||
if(isset($u['email']) && $u['email'] != $eu->getEmail()) {
|
if(isset($u['email']) && $u['email'] != $eu->getEmail()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Email of user updated. '".$u['email']."' != '".$eu->getEmail()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Email of user updated. '".$u['email']."' != '".$eu->getEmail()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setEmail($u['email']);
|
$eu->setEmail($u['email']);
|
||||||
}
|
}
|
||||||
if(isset($u['passenc']) && $u['passenc'] != $eu->getPwd()) {
|
if(isset($u['passenc']) && $u['passenc'] != $eu->getPwd()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Encrypted password of user updated. '".$u['passenc']."' != '".$eu->getPwd()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Encrypted password of user updated. '".$u['passenc']."' != '".$eu->getPwd()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setPwd($u['passenc']);
|
$eu->setPwd($u['passenc']);
|
||||||
}
|
}
|
||||||
if(isset($u['comment']) && $u['comment'] != $eu->getComment()) {
|
if(isset($u['comment']) && $u['comment'] != $eu->getComment()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Comment of user updated. '".$u['comment']."' != '".$eu->getComment()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Comment of user updated. '".$u['comment']."' != '".$eu->getComment()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setComment($u['comment']);
|
$eu->setComment($u['comment']);
|
||||||
}
|
}
|
||||||
if(isset($u['language']) && $u['language'] != $eu->getLanguage()) {
|
if(isset($u['language']) && $u['language'] != $eu->getLanguage()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Language of user updated. '".$u['language']."' != '".$eu->getLanguage()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Language of user updated. '".$u['language']."' != '".$eu->getLanguage()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setLanguage($u['language']);
|
$eu->setLanguage($u['language']);
|
||||||
}
|
}
|
||||||
if(isset($u['quota']) && $u['quota'] != $eu->getQuota()) {
|
if(isset($u['quota']) && $u['quota'] != $eu->getQuota()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Quota of user updated. '".$u['quota']."' != '".$eu->getQuota()."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Quota of user updated. '".$u['quota']."' != '".$eu->getQuota()."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setQuota($u['language']);
|
$eu->setQuota($u['language']);
|
||||||
}
|
}
|
||||||
if(isset($u['homefolder']) && $u['homefolder']->getId() != $eu->getHomeFolder()) {
|
if(isset($u['homefolder']) && $u['homefolder']->getId() != $eu->getHomeFolder()) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Homefolder of user updated. '".(is_object($u['homefolder']) ? $u['homefolder']->getId() : '')."' != '".($eu->getHomeFolder() ? $eu->getHomeFolder() : '')."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Homefolder of user updated. '".(is_object($u['homefolder']) ? $u['homefolder']->getId() : '')."' != '".($eu->getHomeFolder() ? $eu->getHomeFolder() : '')."'");
|
||||||
if($makeupdate)
|
if($makeupdate)
|
||||||
$eu->setHomeFolder($u['homefolder']);
|
$eu->setHomeFolder($u['homefolder']);
|
||||||
}
|
}
|
||||||
$func = function($o) {return $o->getID();};
|
$func = function($o) {return $o->getID();};
|
||||||
if(isset($u['groups']) && implode(',',array_map($func, $u['groups'])) != implode(',',array_map($func, $eu->getGroups()))) {
|
if(isset($u['groups']) && implode(',',array_map($func, $u['groups'])) != implode(',',array_map($func, $eu->getGroups()))) {
|
||||||
$log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Groups of user updated. '".implode(',',array_map($func, $u['groups']))."' != '".implode(',',array_map($func, $eu->getGroups()))."'");
|
$log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "Groups of user updated. '".implode(',',array_map($func, $u['groups']))."' != '".implode(',',array_map($func, $eu->getGroups()))."'");
|
||||||
if($makeupdate) {
|
if($makeupdate) {
|
||||||
foreach($eu->getGroups() as $g)
|
foreach($eu->getGroups() as $g)
|
||||||
$eu->leaveGroup($g);
|
$eu->leaveGroup($g);
|
||||||
|
@ -183,15 +241,21 @@ if (isset($_FILES['userdata']) && $_FILES['userdata']['error'] == 0) {
|
||||||
$eu->joinGroup($g);
|
$eu->joinGroup($g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $log[] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "User '".$eu->getLogin()."' updated.");
|
// $log[$uhash][] = array('id'=>$eu->getLogin(), 'type'=>'success', 'msg'=> "User '".$eu->getLogin()."' updated.");
|
||||||
} else {
|
} else {
|
||||||
if(!empty($_POST['addnew'])) {
|
if(!empty($u['login']) && !empty($u['name']) && !empty($u['email'])) {
|
||||||
if(!empty($u['login']) && !empty($u['name']) && !empty($u['email'])) {
|
if(!empty($_POST['addnew'])) {
|
||||||
$ret = $dms->addUser($u['login'], '', $u['name'], $u['email'], !empty($u['language']) ? $u['language'] : 'en_GB', 'bootstrap', !empty($u['comment']) ? $u['comment'] : '', $u['role']);
|
$ret = $dms->addUser($u['login'], '', $u['name'], $u['email'], !empty($u['language']) ? $u['language'] : 'en_GB', 'bootstrap', !empty($u['comment']) ? $u['comment'] : '', $u['role']);
|
||||||
var_dump($ret);
|
if($ret)
|
||||||
|
$log[$uhash][] = array('id'=>$u['login'], 'type'=>'success', 'msg'=> "User '".$u['name']."' added.");
|
||||||
|
else
|
||||||
|
$log[$uhash][] = array('id'=>$u['login'], 'type'=>'error', 'msg'=> "User '".$u['name']."' could not be added.");
|
||||||
|
} else {
|
||||||
|
// $log[$uhash][] = array('id'=>$u['login'], 'type'=>'success', 'msg'=> "User '".$u['name']."' can be added.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$log[$uhash][] = array('id'=>$u['login'], 'type'=>'error', 'msg'=> "Too much data missing");
|
||||||
}
|
}
|
||||||
$log[] = array('id'=>$u['login'], 'type'=>'success', 'msg'=> "User '".$u['name']."' added.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +266,8 @@ $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||||
if($view) {
|
if($view) {
|
||||||
$view->setParam('log', $log);
|
$view->setParam('log', $log);
|
||||||
|
$view->setParam('newusers', $newusers);
|
||||||
|
$view->setParam('colmap', $colmap);
|
||||||
$view($_GET);
|
$view($_GET);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,6 +283,8 @@ ul.jqtree-tree li.jqtree_common > .jqtree-element:hover {
|
||||||
bottom: 270px;
|
bottom: 270px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i.success {color: #00b000;}
|
||||||
|
i.error {color: #b00000;}
|
||||||
i.initstate {color: #ff9900;}
|
i.initstate {color: #ff9900;}
|
||||||
i.released {color: #00b000;}
|
i.released {color: #00b000;}
|
||||||
i.rejected {color: #b00000;}
|
i.rejected {color: #b00000;}
|
||||||
|
|
|
@ -41,6 +41,8 @@ class SeedDMS_View_ImportUsers extends SeedDMS_Bootstrap_Style {
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$log = $this->params['log'];
|
$log = $this->params['log'];
|
||||||
|
$newusers = $this->params['newusers'];
|
||||||
|
$colmap = $this->params['colmap'];
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("import_users"));
|
$this->htmlStartPage(getMLText("import_users"));
|
||||||
$this->globalNavigation();
|
$this->globalNavigation();
|
||||||
|
@ -81,14 +83,42 @@ class SeedDMS_View_ImportUsers extends SeedDMS_Bootstrap_Style {
|
||||||
|
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
echo "<div class=\"span8\">\n";
|
echo "<div class=\"span8\">\n";
|
||||||
if($log) {
|
if($newusers) {
|
||||||
echo "<table class=\"table table-condensed\">\n";
|
echo "<table class=\"table table-condensed\">\n";
|
||||||
echo "<tr><th>".getMLText('id')."</th>\n";
|
echo "<tr>";
|
||||||
echo "<th>".getMLText('message')."</th></tr>\n";
|
foreach($colmap as $col) {
|
||||||
|
echo "<th>".$col[2]."</th>\n";
|
||||||
|
}
|
||||||
|
echo "<th>".getMLText('message')."</th>";
|
||||||
|
echo "</tr>\n";
|
||||||
|
echo "<tr>";
|
||||||
|
foreach($newusers as $uhash=>$newuser) {
|
||||||
|
foreach($colmap as $i=>$coldata) {
|
||||||
|
echo "<td>";
|
||||||
|
echo call_user_func($colmap[$i][1], $colmap[$i][2], $newuser);
|
||||||
|
echo "</td>\n";
|
||||||
|
}
|
||||||
|
echo "<td>";
|
||||||
|
if(isset($newuser['__logs__'])) {
|
||||||
|
foreach($newuser['__logs__'] as $item) {
|
||||||
|
$class = $item['type'] == 'success' ? 'success' : 'error';
|
||||||
|
echo "<i class=\"icon-circle ".$class."\"></i> ".htmlspecialchars($item['msg'])."<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach($log[$uhash] as $item) {
|
||||||
|
$class = $item['type'] == 'success' ? 'success' : 'error';
|
||||||
|
echo "<i class=\"icon-circle ".$class."\"></i> ".htmlspecialchars($item['msg'])."<br />";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>\n";
|
||||||
|
}
|
||||||
|
echo "</tr>\n";
|
||||||
|
/*
|
||||||
foreach($log as $item) {
|
foreach($log as $item) {
|
||||||
$class = $item['type'] == 'success' ? 'success' : 'error';
|
$class = $item['type'] == 'success' ? 'success' : 'error';
|
||||||
echo "<tr class=\"".$class."\"><td>".$item['id']."</td><td>".htmlspecialchars($item['msg'])."</td></tr>\n";
|
echo "<tr class=\"".$class."\"><td>".$item['id']."</td><td>".htmlspecialchars($item['msg'])."</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
}
|
}
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
|
|
|
@ -18,6 +18,76 @@
|
||||||
*/
|
*/
|
||||||
require_once("class.Bootstrap.php");
|
require_once("class.Bootstrap.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for processing a single folder
|
||||||
|
*
|
||||||
|
* SeedDMS_View_Indexer_Process_Folder::process() is used as a callable when
|
||||||
|
* iterating over all folders recursively.
|
||||||
|
*/
|
||||||
|
class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
|
||||||
|
protected $forceupdate;
|
||||||
|
|
||||||
|
protected $index;
|
||||||
|
|
||||||
|
protected $indexconf;
|
||||||
|
|
||||||
|
public function __construct($index, $indexconf, $forceupdate) { /* {{{ */
|
||||||
|
$this->index = $index;
|
||||||
|
$this->indexconf = $indexconf;
|
||||||
|
$this->forceupdate = $forceupdate;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function process($folder) { /* {{{ */
|
||||||
|
$documents = $folder->getDocuments();
|
||||||
|
if($documents) {
|
||||||
|
echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>";
|
||||||
|
foreach($documents as $document) {
|
||||||
|
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
|
||||||
|
/* If the document wasn't indexed before then just add it */
|
||||||
|
$lucenesearch = new $this->indexconf['Search']($this->index);
|
||||||
|
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||||
|
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
|
||||||
|
echo "(document added)";
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $indent."(adding document failed '".$e->getMessage()."')";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
/* Check if the attribute created is set or has a value older
|
||||||
|
* than the lastet content. Documents without such an attribute
|
||||||
|
* where added when a new document was added to the dms. In such
|
||||||
|
* a case the document content wasn't indexed.
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
$created = (int) $hit->getDocument()->getFieldValue('created');
|
||||||
|
} catch (/* Zend_Search_Lucene_ */Exception $e) {
|
||||||
|
$created = 0;
|
||||||
|
}
|
||||||
|
$content = $document->getLatestContent();
|
||||||
|
if($created >= $content->getDate() && !$this->forceupdate) {
|
||||||
|
echo "<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
|
||||||
|
} else {
|
||||||
|
$this->index->delete($hit->id);
|
||||||
|
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
|
||||||
|
echo $indent."(document updated)";
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $indent."(updating document failed)";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which outputs the html page for Indexer view
|
* Class which outputs the html page for Indexer view
|
||||||
*
|
*
|
||||||
|
@ -205,6 +275,9 @@ $(document).ready( function() {
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
li {line-height: 20px;}
|
li {line-height: 20px;}
|
||||||
|
div.document {line-height: 20px;}
|
||||||
|
div.document:hover {background-color: #eee;}
|
||||||
|
div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
|
||||||
.nav-header {line-height: 19px; margin-bottom: 0px;}
|
.nav-header {line-height: 19px; margin-bottom: 0px;}
|
||||||
.nav-list {padding-right: 0px;}
|
.nav-list {padding-right: 0px;}
|
||||||
.nav-list>li.document:hover {background-color: #eee;}
|
.nav-list>li.document:hover {background-color: #eee;}
|
||||||
|
@ -226,7 +299,10 @@ li {line-height: 20px;}
|
||||||
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
|
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$this->tree($dms, $index, $indexconf, $folder);
|
$folderprocess = new SeedDMS_View_Indexer_Process_Folder($index, $indexconf, $forceupdate);
|
||||||
|
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
|
||||||
|
call_user_func(array($folderprocess, 'process'), $folder);
|
||||||
|
// $this->tree($dms, $index, $indexconf, $folder);
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
$index->commit();
|
$index->commit();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user