function getAllApprovalTableForUser($userId)
 {
     $reviewsArray = array();
     $dao =& Docman_ApprovalTableReviewerFactory::_getDao();
     $dar = $dao->getAllApprovalTableForUser($userId);
     $docmanUrl = get_server_url() . '/plugins/docman';
     while ($dar->valid()) {
         $row = $dar->current();
         // Review URL
         $baseUrl = $docmanUrl . '/?group_id=' . $row['group_id'];
         $url = $baseUrl . '&action=details&section=approval&id=' . $row['item_id'];
         // Status
         $status = '';
         if ($row['status'] == PLUGIN_DOCMAN_APPROVAL_TABLE_ENABLED) {
             $approvalState = Docman_ApprovalTable::computeApprovalState($row);
             if ($approvalState !== null) {
                 $status = $GLOBALS['Language']->getText('plugin_docman', 'approval_review_state_' . $approvalState);
             }
         }
         if ($status == '') {
             $status = $GLOBALS['Language']->getText('plugin_docman', 'details_approval_table_' . $row['status']);
         }
         $reviewsArray[] = array('group' => $row['group_name'], 'group_id' => $row['group_id'], 'title' => $row['title'], 'date' => $row['date'], 'url' => $url, 'status' => $status);
         $dar->next();
     }
     return $reviewsArray;
 }
 function _getAddReviewers()
 {
     $html = '';
     if ($this->table !== null && !$this->table->isClosed() || $this->table === null) {
         $atrf = new Docman_ApprovalTableReviewerFactory($this->table, $this->item);
         $ugroups = $atrf->getUgroupsAllowedForTable($this->item->getGroupId());
         $html .= '<div id="docman_approval_table_create_add_reviewers">';
         $html .= '<table>';
         $html .= '<tr>';
         $html .= '<td>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_reviewers_hand') . '</td>';
         $html .= '<td><input type="text" name="user_list" value="" id="user_list" class="text_field"/></td>';
         $html .= '</tr>';
         $html .= '<tr>';
         $html .= '<td>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_reviewers_ugroup') . '</td>';
         $html .= '<td>' . html_build_multiple_select_box_from_array($ugroups, 'ugroup_list[]', array(), 8, true, '', false, '', false, '', false) . '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '</div>';
         $js = "new UserAutoCompleter('user_list', '" . util_get_dir_image_theme() . "', true);";
         $GLOBALS['Response']->includeFooterJavascriptSnippet($js);
     } else {
         return $GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_reviewers_oldver');
     }
     return $html;
 }
 function _getReviews($reviewer = true)
 {
     $hp = Codendi_HTMLPurifier::instance();
     require_once 'www/my/my_utils.php';
     $html = '';
     $content_html_id = 'plugin_docman_approval_' . ($reviewer ? 'reviewer' : 'requester');
     $html .= '<div style="font-weight:bold;">';
     $html .= $GLOBALS['HTML']->getImage('pointer_down.png', array('id' => $content_html_id . '_icon', 'onclick' => "plugin_docman_approval_toggle('{$content_html_id}', true)")) . ' ';
     if ($reviewer) {
         $html .= $GLOBALS['Language']->getText('plugin_docman', 'my_reviews_reviewer');
     } else {
         $html .= $GLOBALS['Language']->getText('plugin_docman', 'my_reviews_requester');
     }
     $html .= '</div>';
     $html .= '<div id="' . $content_html_id . '" style="padding-left:20px;">';
     $um =& UserManager::instance();
     $user =& $um->getCurrentUser();
     if ($reviewer) {
         $reviewsArray = Docman_ApprovalTableReviewerFactory::getAllPendingReviewsForUser($user->getId());
     } else {
         $reviewsArray = Docman_ApprovalTableReviewerFactory::getAllApprovalTableForUser($user->getId());
     }
     if (count($reviewsArray) > 0) {
         $request =& HTTPRequest::instance();
         // Get hide arguments
         $hideItemId = (int) $request->get('hide_item_id');
         $hideApproval = null;
         if ($request->exist('hide_plugin_docman_approval')) {
             $hideApproval = (int) $request->get('hide_plugin_docman_approval');
         }
         $prevGroupId = -1;
         $hideNow = false;
         $i = 0;
         $html .= '<table style="width:100%">';
         //$html .= '<TR><TD colspan="2">Reviewer - Requester</TD></TR>';
         foreach ($reviewsArray as $review) {
             if ($review['group_id'] != $prevGroupId) {
                 list($hideNow, $count_diff, $hideUrl) = my_hide_url('plugin_docman_approval', $review['group_id'], $hideItemId, 1, $hideApproval);
                 $docmanUrl = $this->pluginPath . '/?group_id=' . $review['group_id'];
                 $docmanHref = '<a href="' . $docmanUrl . '">' . $review['group'] . '</a>';
                 if ($prevGroupId != -1) {
                     if ($reviewer) {
                         $colspan = 2;
                     } else {
                         $colspan = 3;
                     }
                     $html .= '<tr class="boxitem"><td colspan="' . $colspan . '">';
                 }
                 $html .= '<strong>' . $hideUrl . $docmanHref . '</strong></td></tr>';
                 $i = 0;
             }
             if (!$hideNow) {
                 $html .= '<tr class="' . util_get_alt_row_color($i++) . '">';
                 // Document
                 $html .= '<td align="left">';
                 $html .= '<a href="' . $review['url'] . '">' . $hp->purify($review['title'], CODENDI_PURIFIER_CONVERT_HTML) . '</a>';
                 $html .= '</td>';
                 // For requester, precise the status
                 if (!$reviewer) {
                     $html .= '<td align="right">';
                     $html .= $review['status'];
                     $html .= '</td>';
                 }
                 // Date
                 $html .= '<td align="right">';
                 $html .= util_timestamp_to_userdateformat($review['date'], true);
                 $html .= '</td>';
                 $html .= '</tr>';
             }
             $prevGroupId = $review['group_id'];
         }
         $html .= '</table>';
     } else {
         if ($reviewer) {
             $html .= $GLOBALS['Language']->getText('plugin_docman', 'my_no_review');
         } else {
             $html .= $GLOBALS['Language']->getText('plugin_docman', 'my_no_request');
         }
     }
     $html .= '</div>';
     if (user_get_preference('hide_plugin_docman_approval_' . ($reviewer ? 'reviewer' : 'requester'))) {
         $html .= '<script type="text/javascript">';
         $html .= "document.observe('dom:loaded', function() \n                {\n                    plugin_docman_approval_toggle('{$content_html_id}', false);\n                }\n            );\n            </script>";
     }
     return $html;
 }