function getContent()
 {
     $content = '';
     $uh = UserHelper::instance();
     if (is_a($this->item, 'Docman_File')) {
         $content .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions') . '</h3>';
         $version_factory =& new Docman_VersionFactory();
         $approvalFactory =& Docman_ApprovalTableFactory::getFromItem($this->item);
         if ($versions = $version_factory->getAllVersionForItem($this->item)) {
             if (count($versions)) {
                 $titles = array();
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_version');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_date');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_author');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_label');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_changelog');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval');
                 $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_delete_version');
                 $content .= html_build_list_table_top($titles, false, false, false);
                 $odd_even = array('boxitem', 'boxitemalt');
                 $i = 0;
                 foreach ($versions as $key => $nop) {
                     $download = Docman_View_View::buildUrl($this->url, array('action' => 'show', 'id' => $this->item->getId(), 'version_number' => $versions[$key]->getNumber()));
                     $delete = Docman_View_View::buildUrl($this->url, array('action' => 'confirmDelete', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber()));
                     $user = $versions[$key]->getAuthorId() ? $uh->getDisplayNameFromUserId($versions[$key]->getAuthorId()) : $GLOBALS['Language']->getText('plugin_docman', 'details_history_anonymous');
                     $content .= '<tr class="' . $odd_even[$i++ % count($odd_even)] . '">';
                     $content .= '<td align="center"><a href="' . $download . '">' . $versions[$key]->getNumber() . '</a></td>';
                     $content .= '<td>' . html_time_ago($versions[$key]->getDate()) . '</td>';
                     $content .= '<td>' . $this->hp->purify($user) . '</td>';
                     $content .= '<td>' . $this->hp->purify($versions[$key]->getLabel()) . '</td>';
                     $content .= '<td>' . $this->hp->purify($versions[$key]->getChangelog(), CODENDI_PURIFIER_LIGHT) . '</td>';
                     $table = $approvalFactory->getTableFromVersion($versions[$key]);
                     if ($table != null) {
                         $appTable = Docman_View_View::buildUrl($this->url, array('action' => 'details', 'section' => 'approval', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber()));
                         $content .= '<td align="center"><a href="' . $appTable . '">' . ($titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval_show') . '</a></td>');
                     } else {
                         $content .= '<td></td>';
                     }
                     $content .= '<td align="center"><a href="' . $delete . '"><img src="' . util_get_image_theme("ic/trash.png") . '" height="16" width="16" border="0"></a></td>';
                     $content .= '</tr>';
                 }
                 $content .= '</table>';
             } else {
                 $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_no') . '</div>';
             }
         } else {
             $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_error') . '</div>';
         }
     }
     if ($this->logger) {
         $content .= $this->logger->fetchLogsForItem($this->item->getId(), $this->display_access_logs);
     }
     return $content;
 }
 function _getApprovalTable()
 {
     $html = '';
     $atf =& Docman_ApprovalTableFactory::getFromItem($this->item);
     if ($atf->tableExistsForItem()) {
         $html .= '<dt>' . $GLOBALS['Language']->getText('plugin_docman', 'details_actions_update_apptable') . '</dt><dd>';
         $html .= '<dd>';
         $html .= Docman_View_ItemDetailsSectionApprovalCreate::displayImportLastTable(false);
         $html .= '</dd>';
     }
     return $html;
 }
 function initDisplay()
 {
     $request =& HTTPRequest::instance();
     //
     // User may request a specific table id
     $vVersion = new Valid_UInt('version');
     $vVersion->required();
     if ($request->valid($vVersion)) {
         $this->version = $request->get('version');
     }
     $this->atf =& Docman_ApprovalTableFactory::getFromItem($this->item, $this->version);
     $this->table =& $this->atf->getTable();
 }
 function displayNotificationEmail()
 {
     $html = '';
     $html .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_title') . '</h3>';
     $atsm = new Docman_ApprovalTableNotificationCycle();
     $atsm->setItem($this->item);
     $atf =& Docman_ApprovalTableFactory::getFromItem($this->item);
     $table = $atf->getTable(false);
     $atsm->setTable($table);
     $um =& UserManager::instance();
     $owner =& $um->getUserById($table->getOwner());
     $atsm->setOwner($owner);
     $email = $atsm->getNotifReviewer($owner);
     $html .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_subject') . ' ' . $email->getSubject() . "\n";
     $html .= '<p class="docman_approval_email">';
     $html .= htmlentities($email->getBody(), ENT_COMPAT, 'UTF-8');
     $html .= '</p>';
     $backurl = $this->url . '&action=approval_create&id=' . $this->item->getId();
     $html .= '<a href="' . $backurl . '">' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_back') . '</a>';
     return $html;
 }
 function approval_user_commit()
 {
     // Params
     $item = $this->_controler->_actionParams['item'];
     $svState = $this->_controler->_actionParams['svState'];
     $sVersion = $this->_controler->_actionParams['sVersion'];
     $usComment = $this->_controler->_actionParams['usComment'];
     $user = $this->_controler->getUser();
     $review = new Docman_ApprovalReviewer();
     $review->setId($user->getId());
     $review->setState($svState);
     $review->setComment($usComment);
     if ($svState != PLUGIN_DOCMAN_APPROVAL_STATE_NOTYET) {
         $review->setVersion($sVersion);
         $review->setReviewDate(time());
     } else {
         $review->setVersion(null);
         $review->setReviewDate(null);
     }
     $atrf =& Docman_ApprovalTableFactory::getReviewerFactoryFromItem($item);
     $atrf->setNotificationManager($this->_controler->notificationsManager);
     $updated = $atrf->updateReview($review);
     if ($updated) {
         $this->event_manager->processEvent(PLUGIN_DOCMAN_EVENT_APPROVAL_TABLE_COMMENT, array('item' => $item, 'version_nb' => $sVersion, 'table' => $atrf->getTable(), 'review' => $review));
         $this->_controler->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'approval_review_success'));
     } else {
         $this->_controler->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'approval_review_failure'));
     }
     $this->monitor($this->_controler->_actionParams);
 }
 function _validateApprovalTable($request, $item)
 {
     $atf = Docman_ApprovalTableFactory::getFromItem($item);
     if ($atf && $atf->tableExistsForItem()) {
         $vAppTable = new Valid_WhiteList('app_table_import', array('copy', 'reset', 'empty'));
         $vAppTable->required();
         if (!$request->valid($vAppTable)) {
             $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_no_option'));
             return false;
         }
     }
     return true;
 }
 function Docman_ApprovalTableVersionnedFactory($item, $versionNumber = null)
 {
     parent::Docman_ApprovalTableFactory($item);
 }