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

197 lines
6.6 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of FolderNotify 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 FolderNotify 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_FolderNotify extends SeedDMS_Theme_Style {
2012-12-14 07:53:13 +00:00
2016-03-16 19:10:59 +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;
}
2016-03-16 19:10:59 +00:00
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
if(checkForm()) return;
2016-03-22 13:47:13 +00:00
ev.preventDefault();
2016-03-16 19:10:59 +00:00
});
});
2012-12-14 07:53:13 +00:00
<?php
2016-03-16 19:10:59 +00:00
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$allUsers = $this->params['allusers'];
$allGroups = $this->params['allgroups'];
$sortusersinlist = $this->params['sortusersinlist'];
2016-03-16 19:10:59 +00:00
2021-02-05 12:26:03 +00:00
$notifyList = $folder->getNotifyList(0, true);
2016-03-16 19:10:59 +00:00
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
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-20 18:40:47 +00:00
<form class="form-horizontal" action="../op/op.FolderNotify.php" method="post" id="form1" name="form1">
2012-12-14 07:53:13 +00:00
<?php echo createHiddenFieldWithKey('foldernotify'); ?>
2018-06-20 18:40:47 +00:00
<input type="hidden" name="folderid" value="<?php print $folder->getID()?>">
<input type="hidden" name="action" value="addnotify">
<?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() && ($folder->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()))));
2018-06-20 18:40:47 +00:00
}
} elseif (!$user->isGuest() && !in_array($user->getID(), $userNotifyIDs)) {
$options[] = array($user->getID(), htmlspecialchars($user->getLogin() . " - " .$user->getFullName()));
}
$this->contentContainerStart();
2018-06-20 18:40:47 +00:00
$this->formField(
getMLText("user"),
array(
'element'=>'select',
'id'=>'userid',
'name'=>'userid',
2021-03-02 06:31:23 +00:00
'class'=>'chzn-select',
2018-06-20 18:40:47 +00:00
'options'=>$options
)
);
$options = array();
$options[] = array('-1', getMLText("select_one"));
$allGroups = $dms->getAllGroups();
foreach ($allGroups as $groupObj) {
if (($user->isAdmin() || $groupObj->isMember($user,true)) && $folder->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',
2018-06-20 18:40:47 +00:00
'options'=>$options
)
);
$this->contentContainerEnd();
2018-06-20 18:40:47 +00:00
$this->formSubmit(getMLText('add'));
?>
2012-12-14 07:53:13 +00:00
</form>
<?php
$this->columnEnd();
$this->columnStart(6);
if (empty($notifyList["users"]) && empty($notifyList["groups"])) {
2021-05-06 12:49:10 +00:00
$this->infoMsg(getMLText("empty_notify_list"));
} else {
print "<table class=\"table table-condensed table-sm\">\n";
foreach ($notifyList["users"] as $userNotify) {
if ($user->isAdmin() || $user->getID() == $userNotify->getID()) {
print "<tr>";
print "<td><i class=\"fa fa-user\"></i></td>";
print "<td>" . htmlspecialchars($userNotify->getLogin() . " - " . $userNotify->getFullName()) . "</td>";
print "<form action=\"../op/op.FolderNotify.php\" method=\"post\">\n";
echo createHiddenFieldWithKey('foldernotify')."\n";
print "<input type=\"Hidden\" name=\"folderid\" value=\"".$folder->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>";
print "</td>";
print "</form>\n";
print "</tr>";
}
}
foreach ($notifyList["groups"] as $groupNotify) {
if ($user->isAdmin() || $groupNotify->isMember($user,true)) {
print "<tr>";
print "<td><i class=\"fa fa-group\"></i></td>";
print "<td>" . htmlspecialchars($groupNotify->getName()) . "</td>";
print "<form action=\"../op/op.FolderNotify.php\" method=\"post\">\n";
echo createHiddenFieldWithKey('foldernotify')."\n";
print "<input type=\"Hidden\" name=\"folderid\" value=\"".$folder->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>";
print "</td>";
print "</form>\n";
print "</tr>";
}
}
2021-05-06 12:49:10 +00:00
print "</table>\n";
}
$this->columnEnd();
$this->rowEnd();
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>