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

235 lines
8.6 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of ManageNotify 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");
/**
* 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 ManageNotify 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_ManageNotify extends SeedDMS_Bootstrap_Style {
2012-12-14 07:53:13 +00:00
// Get list of subscriptions for documents or folders for user or groups
function getNotificationList($as_group, $folders) { /* {{{ */
// First, get the list of groups of which the user is a member.
$notifications = array();
2012-12-14 07:53:13 +00:00
if ($as_group){
if(!($groups = $this->user->getGroups()))
return NULL;
2012-12-14 07:53:13 +00:00
foreach ($groups as $group) {
$tmp = $group->getNotifications($folders ? T_FOLDER : T_DOCUMENT);
if($tmp) {
$notifications = array_merge($notifications, $tmp);
}
2012-12-14 07:53:13 +00:00
}
} else {
$notifications = $this->user->getNotifications($folders ? T_FOLDER : T_DOCUMENT);
2012-12-14 07:53:13 +00:00
}
return $notifications;
2012-12-14 07:53:13 +00:00
} /* }}} */
function printFolderNotificationList($notifications, $deleteaction=true) { /* {{{ */
if (count($notifications)==0) {
2012-12-14 07:53:13 +00:00
printMLText("empty_notify_list");
}
else {
print "<table class=\"table-condensed\">";
print "<thead><tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("actions")."</th>\n";
print "</tr></thead>\n<tbody>\n";
foreach($notifications as $notification) {
$fld = $this->dms->getFolder($notification->getTarget());
2012-12-14 07:53:13 +00:00
if (is_object($fld)) {
$owner = $fld->getOwner();
print "<tr class=\"folder\">";
2013-05-28 04:28:49 +00:00
print "<td><i class=\"icon-folder-close-alt\"></i></td>";
print "<td><a href=\"../out/out.ViewFolder.php?folderid=".$fld->getID()."\">" . htmlspecialchars($fld->getName()) . "</a></td>\n";
2012-12-14 07:53:13 +00:00
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$fld->getID()."&type=folder&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>";
else print "<a href='../out/out.FolderNotify.php?folderid=".$fld->getID()."' class=\"btn btn-mini\">".getMLText("edit")."</a>";
2012-12-14 07:53:13 +00:00
print "</td></tr>";
}
}
print "</tbody></table>";
}
} /* }}} */
function printDocumentNotificationList($notifications,$deleteaction=true) { /* {{{ */
2012-12-14 07:53:13 +00:00
if (count($notifications)==0) {
2012-12-14 07:53:13 +00:00
printMLText("empty_notify_list");
}
else {
2016-02-15 09:57:37 +00:00
$previewer = new SeedDMS_Preview_Previewer($this->cachedir, $this->previewwidth, $this->timeout);
2014-05-22 05:33:48 +00:00
2012-12-14 07:53:13 +00:00
print "<table class=\"table-condensed\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
2014-05-22 05:33:48 +00:00
print "<th>".getMLText("action")."</th>\n";
2012-12-14 07:53:13 +00:00
print "</tr></thead>\n<tbody>\n";
foreach ($notifications as $notification) {
$doc = $this->dms->getDocument($notification->getTarget());
2012-12-14 07:53:13 +00:00
if (is_object($doc)) {
$owner = $doc->getOwner();
$latest = $doc->getLatestContent();
$status = $latest->getStatus();
2014-05-22 05:33:48 +00:00
$previewer->createPreview($latest);
2012-12-14 07:53:13 +00:00
print "<tr>\n";
2014-05-22 05:33:48 +00:00
print "<td>";
if($previewer->hasPreview($latest)) {
print "<img class=\"mimeicon\" width=\"".$this->previewwidth."\"src=\"../op/op.Preview.php?documentid=".$doc->getID()."&version=".$latest->getVersion()."&width=".$this->previewwidth."\" title=\"".htmlspecialchars($latest->getMimeType())."\">";
} else {
print "<img class=\"mimeicon\" src=\"".$this->getMimeIcon($latest->getFileType())."\" title=\"".htmlspecialchars($latest->getMimeType())."\">";
}
print "</td>";
print "<td><a href=\"out.ViewDocument.php?documentid=".$doc->getID()."\">" . htmlspecialchars($doc->getName()) . "</a>";
print "<br /><span style=\"font-size: 85%; font-style: italic; color: #666; \">".getMLText('owner').": <b>".htmlspecialchars($owner->getFullName())."</b>, ".getMLText('creation_date').": <b>".date('Y-m-d', $doc->getDate())."</b>, ".getMLText('version')." <b>".$latest->getVersion()."</b> - <b>".date('Y-m-d', $latest->getDate())."</b></span>";
$comment = $latest->getComment();
2014-05-22 05:33:48 +00:00
if($comment) {
print "<br /><span style=\"font-size: 85%;\">".htmlspecialchars($comment)."</span>";
}
print "</td>\n";
2012-12-14 07:53:13 +00:00
print "<td>".getOverallStatusText($status["status"])."</td>";
print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$doc->getID()."&type=document&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>";
else print "<a href='../out/out.DocumentNotify.php?documentid=".$doc->getID()."' class=\"btn btn-mini\">".getMLText("edit")."</a>";
2012-12-14 07:53:13 +00:00
print "</td></tr>\n";
}
}
print "</tbody></table>";
}
} /* }}} */
2016-01-28 14:04:14 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript');
$this->printFolderChooserJs("form1");
$this->printDocumentChooserJs("form2");
} /* }}} */
2012-12-14 07:53:13 +00:00
function show() { /* {{{ */
$this->dms = $this->params['dms'];
$this->user = $this->params['user'];
2014-05-22 05:33:48 +00:00
$this->cachedir = $this->params['cachedir'];
$this->previewwidth = $this->params['previewWidthList'];
2012-12-14 07:53:13 +00:00
$this->db = $this->dms->getDB();
2016-02-15 09:57:37 +00:00
$this->timeout = $this->params['timeout'];
2012-12-14 07:53:13 +00:00
$this->htmlStartPage(getMLText("my_account"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("my_account"), "my_account");
2014-05-22 05:33:48 +00:00
echo "<div class=\"row-fluid\">";
echo "<div class=\"span6\">";
$this->contentHeading(getMLText("edit_folder_notify"));
2012-12-14 07:53:13 +00:00
$this->contentContainerStart();
print "<form method=\"post\" action=\"../op/op.ManageNotify.php?type=folder&action=add\" name=\"form1\">";
$this->contentSubHeading(getMLText("choose_target_folder"));
2016-01-28 14:04:14 +00:00
$this->printFolderChooserHtml("form1",M_READ);
2012-12-14 07:53:13 +00:00
print "<label class=\"checkbox\">";
print "<input type=\"checkbox\" name=\"recursefolder\" value=\"1\">";
print getMLText("include_subdirectories");
print "</label>";
print "<label class=\"checkbox\">";
print "<input type=\"checkbox\" name=\"recursedoc\" value=\"1\">";
print getMLText("include_documents");
print "</label>";
2013-05-22 20:47:33 +00:00
print "<button type='submit' class='btn'><i class=\"icon-plus\"></i> ".getMLText("add")."</button>";
2012-12-14 07:53:13 +00:00
print "</form>";
2014-05-22 05:33:48 +00:00
$this->contentContainerEnd();
echo "</div>";
2012-12-14 07:53:13 +00:00
2014-05-22 05:33:48 +00:00
echo "<div class=\"span6\">";
$this->contentHeading(getMLText("edit_document_notify"));
$this->contentContainerStart();
2012-12-14 07:53:13 +00:00
print "<form method=\"post\" action=\"../op/op.ManageNotify.php?type=document&action=add\" name=\"form2\">";
$this->contentSubHeading(getMLText("choose_target_document"));
2013-03-06 10:14:15 +00:00
/* 'form1' must be passed to printDocumentChooser() because the typeahead
* function is currently hardcoded on this value */
2016-01-28 14:04:14 +00:00
$this->printDocumentChooserHtml("form2");
2014-05-22 05:33:48 +00:00
print "<br /><button type='submit' class='btn'><i class=\"icon-plus\"></i> ".getMLText("add")."</button>";
2012-12-14 07:53:13 +00:00
print "</form>";
$this->contentContainerEnd();
2014-05-22 05:33:48 +00:00
echo "</div>";
echo "</div>";
2012-12-14 07:53:13 +00:00
//
// Display the results.
//
2014-05-22 05:33:48 +00:00
echo "<div class=\"row-fluid\">";
echo "<div class=\"span6\">";
$this->contentHeading(getMLText("user"));
2012-12-14 07:53:13 +00:00
$this->contentContainerStart();
$ret=$this->getNotificationList(false,true);
$this->printFolderNotificationList($ret);
2014-05-22 05:33:48 +00:00
$this->contentContainerEnd();
$this->contentHeading(getMLText("group"));
$this->contentContainerStart();
2012-12-14 07:53:13 +00:00
$ret=$this->getNotificationList(true,true);
$this->printFolderNotificationList($ret,false);
$this->contentContainerEnd();
2014-05-22 05:33:48 +00:00
echo "</div>";
2012-12-14 07:53:13 +00:00
2014-05-22 05:33:48 +00:00
echo "<div class=\"span6\">";
$this->contentHeading(getMLText("user"));
2012-12-14 07:53:13 +00:00
$this->contentContainerStart();
$ret=$this->getNotificationList(false,false);
$this->printDocumentNotificationList($ret);
2014-05-22 05:33:48 +00:00
$this->contentContainerEnd();
$this->contentHeading(getMLText("group"));
$this->contentContainerStart();
2012-12-14 07:53:13 +00:00
$ret=$this->getNotificationList(true,false);
$this->printDocumentNotificationList($ret,false);
$this->contentContainerEnd();
2014-05-22 05:33:48 +00:00
echo "</div>";
echo "</div>";
2012-12-14 07:53:13 +00:00
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>