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

197 lines
6.7 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of DocumentNotify 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
/**
* Class which outputs the html page for DocumentNotify 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_DocumentNotify extends SeedDMS_Theme_Style {
2012-12-14 07:53:13 +00:00
2015-12-15 20:02:47 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
2012-12-14 07:53:13 +00:00
?>
function checkForm()
{
2013-05-23 14:07:00 +00:00
msg = new Array();
2012-12-14 07:53:13 +00:00
if ((document.form1.userid.options[document.form1.userid.selectedIndex].value == -1) &&
(document.form1.groupid.options[document.form1.groupid.selectedIndex].value == -1))
2013-05-23 14:07:00 +00:00
msg.push("<?php printMLText("js_select_user_or_group");?>");
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
2012-12-14 07:53:13 +00:00
return false;
}
else
return true;
}
2015-12-15 20:02:47 +00:00
$(document).ready( function() {
$('body').on('submit', '#form1', function(ev){
if(checkForm()) return;
2016-03-22 13:47:13 +00:00
ev.preventDefault();
2015-12-15 20:02:47 +00:00
});
});
2012-12-14 07:53:13 +00:00
<?php
2015-12-15 20:02:47 +00:00
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$document = $this->params['document'];
$sortusersinlist = $this->params['sortusersinlist'];
$notifyList = $document->getNotifyList(0, true);
2015-12-15 20:02:47 +00:00
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
2012-12-14 07:53:13 +00:00
$this->contentHeading(getMLText("edit_existing_notify"));
$userNotifyIDs = array();
foreach ($notifyList["users"] as $userNotify) {
$userNotifyIDs[] = $userNotify->getID();
}
2012-12-14 07:53:13 +00:00
$groupNotifyIDs = array();
foreach ($notifyList["groups"] as $groupNotify) {
$groupNotifyIDs[] = $groupNotify->getID();
}
2012-12-14 07:53:13 +00:00
$this->rowStart();
$this->columnStart(6);
2012-12-14 07:53:13 +00:00
?>
2018-06-27 20:14:10 +00:00
<form class="form-horizontal" action="../op/op.DocumentNotify.php" method="post" name="form1" id="form1">
<?php echo createHiddenFieldWithKey('documentnotify'); ?>
2012-12-14 07:53:13 +00:00
<input type="hidden" name="documentid" value="<?php print $document->getID()?>">
<input type="hidden" name="action" value="addnotify">
2018-04-23 13:50:46 +00:00
<?php
$options = array();
$options[] = array('-1', getMLText("select_one"));
if ($user->isAdmin()) {
$allUsers = $dms->getAllUsers($sortusersinlist);
foreach ($allUsers as $userObj) {
if (!$userObj->isGuest() && !$userObj->isDisabled() && ($document->getAccessMode($userObj) >= M_READ) && !in_array($userObj->getID(), $userNotifyIDs))
2021-03-02 06:31:23 +00:00
$options[] = array($userObj->getID(), htmlspecialchars($userObj->getLogin().' - '.$userObj->getFullName()), false, array(array('data-subtitle', htmlspecialchars($userObj->getEmail()))));
}
} elseif (!$user->isGuest() && !in_array($user->getID(), $userNotifyIDs)) {
$options[] = array($user->getID(), htmlspecialchars($user->getLogin() . " - " .$user->getFullName()));
}
$this->contentContainerStart();
$this->formField(
getMLText("user"),
array(
'element'=>'select',
'id'=>'userid',
'name'=>'userid',
2021-03-02 06:31:23 +00:00
'class'=>'chzn-select',
'options'=>$options
)
);
$options = array();
$options[] = array('-1', getMLText("select_one"));
$allGroups = $dms->getAllGroups();
foreach ($allGroups as $groupObj) {
if (($user->isAdmin() || $groupObj->isMember($user,true)) && $document->getGroupAccessMode($groupObj) >= M_READ && !in_array($groupObj->getID(), $groupNotifyIDs)) {
$options[] = array($groupObj->getID(), htmlspecialchars($groupObj->getName()));
}
}
$this->formField(
getMLText("group"),
array(
'element'=>'select',
'id'=>'groupid',
'name'=>'groupid',
2021-03-02 06:31:23 +00:00
'class'=>'chzn-select',
'options'=>$options
)
);
$this->contentContainerEnd();
$this->formSubmit(getMLText('add'));
2018-04-23 13:50:46 +00:00
?>
2012-12-14 07:53:13 +00:00
</form>
<?php
$this->columnEnd();
$this->columnStart(6);
2018-06-27 20:14:10 +00:00
if ((count($notifyList["users"]) == 0) && (count($notifyList["groups"]) == 0)) {
2021-05-06 12:49:10 +00:00
$this->infoMsg(getMLText("empty_notify_list"));
} else {
print "<table class=\"table table-condensed table-sm mt-4\">\n";
2018-06-27 20:14:10 +00:00
foreach ($notifyList["users"] as $userNotify) {
print "<tr>";
2020-08-27 05:52:52 +00:00
print "<td><i class=\"fa fa-user\"></i></td>";
2018-06-27 20:14:10 +00:00
print "<td>" . htmlspecialchars($userNotify->getLogin() . " - " . $userNotify->getFullName()) . "</td>";
if ($user->isAdmin() || $user->getID() == $userNotify->getID()) {
print "<form action=\"../op/op.DocumentNotify.php\" method=\"post\">\n";
echo createHiddenFieldWithKey('documentnotify')."\n";
print "<input type=\"hidden\" name=\"documentid\" value=\"".$document->getID()."\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"delnotify\">\n";
print "<input type=\"hidden\" name=\"userid\" value=\"".$userNotify->getID()."\">\n";
print "<td>";
print "<button type=\"submit\" class=\"btn btn-danger btn-mini btn-sm\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</button>";
2018-06-27 20:14:10 +00:00
print "</td>";
print "</form>\n";
}else print "<td></td>";
print "</tr>";
}
foreach ($notifyList["groups"] as $groupNotify) {
print "<tr>";
2020-08-27 05:52:52 +00:00
print "<td><i class=\"fa fa-group\"></i></td>";
2018-06-27 20:14:10 +00:00
print "<td>" . htmlspecialchars($groupNotify->getName()) . "</td>";
if ($user->isAdmin() || $groupNotify->isMember($user,true)) {
print "<form action=\"../op/op.DocumentNotify.php\" method=\"post\">\n";
echo createHiddenFieldWithKey('documentnotify')."\n";
print "<input type=\"hidden\" name=\"documentid\" value=\"".$document->getID()."\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"delnotify\">\n";
print "<input type=\"hidden\" name=\"groupid\" value=\"".$groupNotify->getID()."\">\n";
print "<td>";
print "<button type=\"submit\" class=\"btn btn-danger btn-mini btn-sm\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</button>";
2018-06-27 20:14:10 +00:00
print "</td>";
print "</form>\n";
2018-06-27 20:14:10 +00:00
}else print "<td></td>";
print "</tr>";
}
2021-05-06 12:49:10 +00:00
print "</table>\n";
2018-06-27 20:14:10 +00:00
}
$this->columnEnd();
$this->rowEnd();
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>