public function docmanwatermark_toggle_item() { $itemId = $this->_controler->request->getValidated('item_id', 'UInt'); if ($itemId != null && $this->_controler->userCanManage($itemId) && $this->_controler->request->isPost()) { $itemFactory = new Docman_ItemFactory(); $dwItemFactory = new DocmanWatermark_ItemFactory(); $dwLog = new DocmanWatermark_Log(); $item = $itemFactory->getItemFromDb($itemId); $user = $this->_controler->getUser(); if ($this->_controler->request->existAndNonEmpty('disable_watermarking')) { if ($dwItemFactory->disableWatermarking($itemId)) { $dwLog->disableWatermarking($item, $user); $dwItemFactory->notifyOnDisable($item, $user, $this->_controler->getDefaultUrl()); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_docmanwatermark', 'action_watermarking_disabled')); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_docmanwatermark', 'action_watermarking_disable_error')); } } else { if ($dwItemFactory->enableWatermarking($itemId)) { $dwLog->enableWatermarking($item, $user); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_docmanwatermark', 'action_watermarking_enabled')); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_docmanwatermark', 'action_watermarking_enable_error')); } } $this->_controler->view = 'RedirectAfterCrud'; $this->_controler->_viewParams['redirect_to'] = $this->_controler->getDefaultUrl() . '&action=details&id=' . $itemId . '§ion=watermarking'; } else { // Bad Item Id or attempt to fake the server, redirect to root // @todo: log those kind of attempt. $this->_controler->view = 'RedirectAfterCrud'; $this->_controler->_viewParams['redirect_to'] = $this->_controler->getDefaultUrl(); } }
function getDisabledTable($groupId) { $dwLog = new DocmanWatermark_ItemFactory(); $dar = $dwLog->getNotWatermarkedByProject($groupId); $html = '<h3>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_title') . '</h3>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_desc') . '</p>'; if ($dar && $dar->rowCount() > 0) { $titles = array($GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_document'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_when'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_directaccess')); $html .= html_build_list_table_top($titles, false, false, false); $altColor = 0; $previousItem = null; foreach ($dar as $row) { if ($row['item_id'] != $previousItem) { $html .= '<tr class="' . html_get_alt_row_color($altColor++) . '">'; $html .= '<td>' . $row['title'] . '</td>'; $html .= '<td>' . util_timestamp_to_userdateformat($row['time']) . '</td>'; $html .= '<td><a href="' . $this->_controller->getDefaultUrl() . '&action=details&id=' . $row['item_id'] . '§ion=watermarking">' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'admin_disabled_link') . '</a></td>'; $html .= '<tr>'; $previousItem = $row['item_id']; } } $html .= '</table>'; } return $html; }