seeddms-code/views/bootstrap/class.GroupMgr.php

341 lines
10 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of GroupMgr view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
//require_once("class.Bootstrap.php");
2012-12-14 07:53:13 +00:00
/**
* Include class to preview documents
*/
require_once("SeedDMS/Preview.php");
2012-12-14 07:53:13 +00:00
/**
* Class which outputs the html page for GroupMgr view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_GroupMgr extends SeedDMS_Theme_Style {
2012-12-14 07:53:13 +00:00
2015-12-11 07:21:04 +00:00
function js() { /* {{{ */
$selgroup = $this->params['selgroup'];
$strictformcheck = $this->params['strictformcheck'];
header('Content-Type: application/javascript; charset=UTF-8');
?>
function checkForm1() {
msg = new Array();
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
<?php
if ($strictformcheck) {
?>
if($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
<?php
}
?>
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
function checkForm2() {
msg = "";
if($("#userid").val() == -1) msg += "<?php printMLText("js_select_user");?>\n";
if (msg != "") {
noty({
text: msg,
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
$(document).ready( function() {
$('body').on('submit', '#form_1', function(ev){
if(checkForm1())
return;
2016-03-22 13:47:13 +00:00
ev.preventDefault();
});
$('body').on('submit', '#form_2', function(ev){
if(checkForm2())
return;
2016-03-22 13:47:13 +00:00
ev.preventDefault();
});
$( "#selector" ).change(function() {
$('div.ajax').trigger('update', {groupid: $(this).val()});
2020-02-25 08:52:27 +00:00
window.history.pushState({"html":"","pageTitle":""},"", '../out/out.GroupMgr.php?groupid=' + $(this).val());
});
});
<?php
} /* }}} */
2015-12-10 11:43:42 +00:00
function info() { /* {{{ */
$dms = $this->params['dms'];
$selgroup = $this->params['selgroup'];
$cachedir = $this->params['cachedir'];
$previewwidth = $this->params['previewWidthList'];
$workflowmode = $this->params['workflowmode'];
2016-02-15 09:57:37 +00:00
$timeout = $this->params['timeout'];
2019-01-18 12:07:39 +00:00
$xsendfile = $this->params['xsendfile'];
2015-12-10 11:43:42 +00:00
if($selgroup) {
2019-01-18 12:07:39 +00:00
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
2015-12-10 11:43:42 +00:00
$this->contentHeading(getMLText("group_info"));
echo "<table class=\"table table-condensed\">\n";
if($workflowmode == "traditional") {
$reviewstatus = $selgroup->getReviewStatus();
$i = 0;
foreach($reviewstatus as $rv) {
if($rv['status'] == 0) {
$i++;
}
}
echo "<tr><td>".getMLText('pending_reviews')."</td><td>".$i."</td></tr>";
}
if($workflowmode == "traditional" || $workflowmode == 'traditional_only_approval') {
$approvalstatus = $selgroup->getApprovalStatus();
$i = 0;
foreach($approvalstatus as $rv) {
if($rv['status'] == 0) {
$i++;
}
}
echo "<tr><td>".getMLText('pending_approvals')."</td><td>".$i."</td></tr>";
}
if($workflowmode == 'advanced') {
$workflowStatus = $selgroup->getWorkflowStatus();
if($workflowStatus)
echo "<tr><td>".getMLText('pending_workflows')."</td><td>".count($workflowStatus)."</td></tr>\n";
}
2015-12-10 11:43:42 +00:00
echo "</table>";
}
} /* }}} */
2017-12-04 11:01:29 +00:00
function actionmenu() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$selgroup = $this->params['selgroup'];
if($selgroup) {
$button = array(
'label'=>getMLText('action'),
'menuitems'=>array(
)
);
$button['menuitems'][] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText("rm_group"), 'link'=>'../out/out.RemoveGroup.php?groupid='.$selgroup->getID());
2020-09-29 15:07:16 +00:00
if($selgroup->getUsers())
$button['menuitems'][] = array('label'=>'<i class="fa fa-download"></i> '.getMLText("export_user_list_csv"), 'link'=>'../op/op.UserListCsv.php?groupid='.$selgroup->getID());
self::showButtonwithMenu($button);
2017-12-04 11:01:29 +00:00
}
} /* }}} */
2015-12-10 11:43:42 +00:00
function showGroupForm($group) { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$allUsers = $this->params['allusers'];
$groups = $this->params['allgroups'];
?>
<form class="form-horizontal" action="../op/op.GroupMgr.php" name="form_1" id="form_1" method="post">
2015-12-10 11:43:42 +00:00
<?php
if($group) {
echo createHiddenFieldWithKey('editgroup');
?>
<input type="hidden" name="groupid" value="<?php print $group->getID();?>">
<input type="hidden" name="action" value="editgroup">
<?php
} else {
echo createHiddenFieldWithKey('addgroup');
?>
<input type="hidden" name="action" value="addgroup">
<?php
}
2018-04-23 13:50:46 +00:00
$this->formField(
getMLText("name"),
array(
'element'=>'input',
'type'=>'text',
'id'=>'name',
'name'=>'name',
'value'=>($group ? htmlspecialchars($group->getName()) : '')
)
2018-04-23 13:50:46 +00:00
);
$this->formField(
getMLText("comment"),
array(
'element'=>'textarea',
'id'=>'comment',
'name'=>'comment',
'rows'=>4,
'value'=>($group ? htmlspecialchars($group->getComment()) : '')
)
2018-04-23 13:50:46 +00:00
);
2020-08-27 05:52:52 +00:00
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('save'));
2015-12-10 11:43:42 +00:00
?>
</form>
<?php
if($group) {
$this->contentSubHeading(getMLText("group_members"));
?>
<table class="table-condensed">
<?php
$members = $group->getUsers();
if (count($members) == 0)
print "<tr><td>".getMLText("no_group_members")."</td></tr>";
else {
foreach ($members as $member) {
print "<tr>";
2020-08-27 05:52:52 +00:00
print "<td><i class=\"fa fa-user\"></i></td>";
2015-12-10 11:43:42 +00:00
print "<td>" . htmlspecialchars($member->getFullName()) . "</td>";
print "<td>" . ($group->isMember($member,true)?getMLText("manager"):"&nbsp;") . "</td>";
print "<td>";
2020-08-27 05:52:52 +00:00
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"action\" value=\"rmmember\" /><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('rmmember')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</button></form>";
2015-12-10 11:43:42 +00:00
print "&nbsp;";
2020-08-27 05:52:52 +00:00
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"tmanager\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('tmanager')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"fa fa-random\"></i> ".getMLText("toggle_manager")."</button></form>";
2015-12-10 11:43:42 +00:00
print "</td></tr>";
}
}
?>
</table>
<?php
$this->contentSubHeading(getMLText("add_member"));
?>
<form class="form-horizontal" action="../op/op.GroupMgr.php" method="POST" name="form_2" id="form_2">
2015-12-10 11:43:42 +00:00
<?php echo createHiddenFieldWithKey('addmember'); ?>
<input type="Hidden" name="action" value="addmember">
<input type="Hidden" name="groupid" value="<?php print $group->getID();?>">
<?php
$options = array();
$allUsers = $dms->getAllUsers($sortusersinlist);
foreach ($allUsers as $currUser) {
if (!$group->isMember($currUser))
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), ($currUser->getID()==$user->getID()), array(array('data-subtitle', htmlspecialchars($currUser->getEmail()))));
}
$this->formField(
getMLText("user"),
array(
'element'=>'select',
'id'=>'userid',
'name'=>'userid',
'class'=>'chzn-select',
'options'=>$options
)
);
$this->formField(
getMLText("manager"),
array(
'element'=>'input',
'type'=>'checkbox',
'name'=>'manager',
'value'=>1
)
);
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('add'));
?>
2015-12-10 11:43:42 +00:00
</form>
<?php
}
} /* }}} */
function form() { /* {{{ */
$selgroup = $this->params['selgroup'];
$this->showGroupForm($selgroup);
} /* }}} */
2012-12-14 07:53:13 +00:00
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$selgroup = $this->params['selgroup'];
2012-12-14 07:53:13 +00:00
$allUsers = $this->params['allusers'];
$allGroups = $this->params['allgroups'];
$strictformcheck = $this->params['strictformcheck'];
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("group_management"));
$this->rowStart();
$this->columnStart(4);
2012-12-14 07:53:13 +00:00
?>
<form class="form-horizontal">
2012-12-14 07:53:13 +00:00
<?php
$options = array();
$options[] = array("-1", getMLText("choose_group"));
$options[] = array("0", getMLText("add_group"));
2012-12-14 07:53:13 +00:00
foreach ($allGroups as $group) {
$options[] = array($group->getID(), htmlspecialchars($group->getName()), $selgroup && $group->getID()==$selgroup->getID());
2012-12-14 07:53:13 +00:00
}
$this->formField(
null, //getMLText("selection"),
array(
'element'=>'select',
'id'=>'selector',
'class'=>'chzn-select',
2021-01-14 21:35:03 +00:00
'options'=>$options,
'placeholder'=>getMLText('select_groups'),
)
);
2012-12-14 07:53:13 +00:00
?>
</form>
2017-12-04 11:01:29 +00:00
<div class="ajax" style="margin-bottom: 15px;" data-view="GroupMgr" data-action="actionmenu" <?php echo ($selgroup ? "data-query=\"groupid=".$selgroup->getID()."\"" : "") ?>></div>
2016-04-22 06:30:19 +00:00
<div class="ajax" data-view="GroupMgr" data-action="info" <?php echo ($selgroup ? "data-query=\"groupid=".$selgroup->getID()."\"" : "") ?>></div>
<?php
$this->columnEnd();
$this->columnStart(8);
$this->contentContainerStart();
?>
2016-04-22 06:30:19 +00:00
<div class="ajax" data-view="GroupMgr" data-action="form" <?php echo ($selgroup ? "data-query=\"groupid=".$selgroup->getID()."\"" : "") ?>></div>
2012-12-14 07:53:13 +00:00
<?php
$this->contentContainerEnd();
$this->columnEnd();
$this->rowEnd();
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>