Ejemplo n.º 1
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_activity_log')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view the activity log.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'ActivityLogView.php');
     $actee = $context->get('actee');
     $actor = $context->get('actor');
     $notes = $context->get('notes');
     $exact = $context->get('exact');
     $begin = $context->get('begin');
     $end = $context->get('end');
     if (!is_null($begin) && !is_null($end) && $end <= $begin) {
         unset($_REQUEST['begin_year'], $_REQUEST['begin_month'], $_REQUEST['begin_day'], $_REQUEST['end_year'], $_REQUEST['end_month'], $_REQUEST['end_day']);
         $begin = null;
         $end = null;
         NQ::simple('hms', hms\NotificationView::WARNING, 'Invalid date range. The search results will not be filtered by date.');
     }
     $activityMap = HMS_Activity_Log::getActivityMapping();
     $activities = array();
     foreach ($activityMap as $i => $t) {
         $act = $context->get("a{$i}");
         if (!is_null($act)) {
             $activities[] = $i;
         }
     }
     $activityLogView = new ActivityLogView($actee, $actor, $notes, $exact, $begin, $end, $activities);
     $context->setContent($activityLogView->show());
 }
Ejemplo n.º 2
0
 /**
  * Shows filtering options for the log view.  The first argument is usually
  * $_SESSION. The second argument is laid out in the same way, and
  * specifies default values.  If a default value is specified in the second
  * argument, that option will not appear in the filter; this way, if you're
  * in the Student Info thing, you can show the activity log for only that
  * user.
  */
 public static function showFilters($selection = NULL)
 {
     PHPWS_Core::initCoreClass('Form.php');
     $submitCmd = CommandFactory::getCommand('ShowActivityLog');
     $form = new PHPWS_Form();
     $submitCmd->initForm($form);
     $form->setMethod('get');
     $form->addText('actor');
     $form->setLabel('actor', 'Action Performed By:');
     if (isset($selection['actor'])) {
         $form->setValue('actor', $selection['actor']);
     }
     $form->addText('actee');
     $form->setLabel('actee', 'Action Affected:');
     if (isset($selection['actee'])) {
         $form->setValue('actee', $selection['actee']);
     }
     // "exact" flag
     $form->addCheck('exact', 'yes');
     $form->setMatch('exact', 'yes');
     $form->setLabel('exact', 'Exact? ');
     $form->addText('begin', isset($selection['begin']) ? $selection['begin'] : '');
     $form->setClass('begin', 'datepicker');
     $form->addText('end', isset($selection['end']) ? $selection['end'] : '');
     $form->setClass('end', 'datepicker');
     $form->addText('notes');
     $form->setLabel('notes', 'Note:');
     if (isset($selection['notes'])) {
         $form->setValue('notes', $selection['notes']);
     }
     $activities = HMS_Activity_Log::getActivityMapping();
     foreach ($activities as $id => $text) {
         $name = "a{$id}";
         $form->addCheckbox($name);
         $form->setLabel($name, $text);
         $form->setMatch($name, isset($selection[$name]));
     }
     $form->addSubmit('Refresh');
     $tpl = $form->getTemplate();
     $tpl['BEGIN_LABEL'] = 'After:';
     $tpl['END_LABEL'] = 'Before:';
     javascript('jquery');
     javascript('modules/hms/activity_log');
     return PHPWS_Template::process($tpl, 'hms', 'admin/activity_log_filters.tpl');
 }
Ejemplo n.º 3
0
 /**
  * Returns an array of all the activity ids. Based on the activity mapping above.
  */
 public static function get_activity_list()
 {
     $activities = HMS_Activity_Log::getActivityMapping();
     $list = array();
     foreach ($activities as $id => $desc) {
         $list[] = $id;
     }
     return $list;
 }