/**
  * Execute this action for generating an XML response with participation summary information
  * 
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         $this->error("Permission Denied");
     }
     $node = SiteDispatcher::getCurrentNode();
     $id = RequestContext::value('participant');
     $view = new Participation_View($node);
     $idMgr = Services::getService('Id');
     $participantView = new Participation_Participant($view, $idMgr->getId($id));
     $this->start();
     print "\n\t<role id='comments' number='" . $participantView->getNumActionsByCategory('commenter') . "'/>";
     print "\n\t<role id='author' number='" . $participantView->getNumActionsByCategory('author') . "'/>";
     print "\n\t<role id='editor' number='" . $participantView->getNumActionsByCategory('editor') . "'/>";
     $this->end();
 }
예제 #2
0
 /**
  * Display a list of participants with summary of their contributions
  * 
  * @param string $id
  * @return string XHTML markup
  * @access private
  * @since 1/28/09
  */
 private function getActionsList()
 {
     $node = SiteDispatcher::getCurrentNode();
     $view = new Participation_View($node);
     $participants = $view->getParticipants();
     // create an array of reorder urls
     $sortValues = array('timestamp', 'contributor', 'contribution', 'role');
     $reorderUrl = array();
     foreach ($sortValues as $sortValue) {
         $reorderUrl[$sortValue] = SiteDispatcher::quickURL('participation', 'actions', array('node' => $node->getId(), 'sort' => $sortValue, 'direction' => $this->_reorder, 'participant' => $this->_participant, 'role' => $this->_role));
     }
     // header row for list of actions
     ob_start();
     print "\n\t<thead>";
     print "\n\t\t<tr>";
     // time
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['timestamp'];
     print "'>" . _("Time") . " " . ($this->_sort == 'timestamp' ? $this->_reorderFlag : "") . "</a></th>";
     // contributor
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['contributor'];
     print "'>" . _("Contributor") . " " . ($this->_sort == 'contributor' ? $this->_reorderFlag : "") . "</a></th>";
     // role
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['role'];
     print "'>" . _("Role") . " " . ($this->_sort == 'role' ? $this->_reorderFlag : "") . "</a>";
     print "</th>";
     // contribution
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['contribution'];
     print "'>" . _("Contribution") . " " . ($this->_sort == 'contribution' ? $this->_reorderFlag : "") . "</a></th>";
     // pushdown link
     print "\n\t\t\t<th style='border-bottom: 1px dotted'></th>";
     print "\n\t</thead>";
     $headRow = ob_get_clean();
     // if participant specified get their actions
     if (isset($this->_participant) && $this->_participant != 'all') {
         $idMgr = Services::getService('Id');
         $participantId = $idMgr->getId($this->_participant);
         $participantView = new Participation_Participant($view, $participantId);
         $actions = $participantView->getActions();
         //get list of all actions in site
     } else {
         $actions = $view->getActions();
     }
     // sort actions by sort key
     $sortKeys = array();
     if ($this->_sort == 'timestamp') {
         foreach ($actions as $action) {
             $sortKeys[] = $action->getTimeStamp()->asString();
         }
     } else {
         if ($this->_sort == 'contributor') {
             foreach ($actions as $action) {
                 $sortKeys[] = $action->getParticipant()->getDisplayName();
             }
         } else {
             if ($this->_sort == 'contribution') {
                 foreach ($actions as $action) {
                     $sortKeys[] = $action->getTargetDisplayName();
                 }
             } else {
                 if ($this->_sort == 'role') {
                     foreach ($actions as $action) {
                         $sortKeys[] = $action->getCategoryDisplayName();
                     }
                 } else {
                     throw new InvalidArguementException("Unknown sort field {$sort}");
                 }
             }
         }
     }
     array_multisort($sortKeys, $this->_direction, array_keys($actions), SORT_ASC, $actions);
     // if role action specified then filter actions
     $selectedActions = array();
     if ($this->_role != 'all') {
         foreach ($actions as $action) {
             if ($action->getCategoryId() == $this->_role) {
                 $selectedActions[] = $action;
             }
         }
     } else {
         $selectedActions = $actions;
     }
     $this->_node = $node;
     $this->_sortValue = $sortValue;
     $printer = new ParticipationResultPrinter($selectedActions, $headRow, $this->_display, array($this, 'printAction'));
     print $printer->getMarkup();
     return ob_get_clean();
 }
예제 #3
0
 /**
  * Print out a row.
  * 
  * @param Participation_Participant $participant
  * @return string
  * @access public
  * @since 1/30/09
  */
 public function printAction(Participation_Participant $participants)
 {
     $participant = $participants->getId()->getIdString();
     $participantView = new Participation_Participant($this->_view, $participants->getId());
     // determine color of current row
     if ($this->_rowColor == "#F6F6F6") {
         $rowColor = "#FFFFFF";
         $this->_rowColor = "#FFFFFF";
     } else {
         $rowColor = "#F6F6F6";
         $this->_rowColor = "#F6F6F6";
     }
     ob_start();
     print "\n\t\t<tr>";
     print "\n\t\t\t<td class='participant_row' style='background-color: " . $rowColor . "'>";
     print "<a href='";
     print SiteDispatcher::quickURL('participation', 'actions', array('node' => $this->_node->getId(), 'sort' => 'timestamp', 'direction' => 'DESC', 'participant' => $participant)) . "'>";
     print $participants->getDisplayName();
     print "</a>";
     print "\n\t\t\t</td>";
     print "\n\t\t\t<td class='participant_row' style='background-color: " . $rowColor . "'>";
     print "<a href='";
     print SiteDispatcher::quickURL('participation', 'actions', array('node' => $this->_node->getId(), 'sort' => 'timestamp', 'direction' => 'DESC', 'participant' => $participant, 'role' => 'commenter')) . "'>";
     print $participantView->getNumActionsByCategory('commenter');
     print "</a>";
     print "\n\t\t\t</td>";
     print "\n\t\t\t<td class='participant_row' style='background-color: " . $rowColor . "'>";
     print "<a href='";
     print SiteDispatcher::quickURL('participation', 'actions', array('node' => $this->_node->getId(), 'sort' => 'timestamp', 'direction' => 'DESC', 'participant' => $participant, 'role' => 'author')) . "'>";
     print $participantView->getNumActionsByCategory('author');
     print "</a>";
     print "\n\t\t\t</td>";
     print "\n\t\t\t<td class='participant_row' style='background-color: " . $rowColor . "'>";
     print "<a href='";
     print SiteDispatcher::quickURL('participation', 'actions', array('node' => $this->_node->getId(), 'sort' => 'timestamp', 'direction' => 'DESC', 'participant' => $participant, 'role' => 'editor')) . "'>";
     print $participantView->getNumActionsByCategory('editor');
     print "</a>";
     print "\n\t\t\t</td>";
     print "\n\t\t</tr>";
     return ob_get_clean();
 }