Esempio n. 1
0
 public function dashboard($request, $match, $working = true)
 {
     $otags = array();
     // Note that this approach does not scale, we will need to add
     // a table to cache the meaning of the tags for large forges.
     foreach (IDF_Views::getProjects($request->user) as $project) {
         $otags = array_merge($otags, $project->getTagIdsByStatus('open'));
     }
     if (count($otags) == 0) {
         $otags[] = 0;
     }
     if ($working) {
         $title = __('Your Dashboard - Working Issues');
         $f_sql = new Pluf_SQL('owner=%s AND status IN (' . implode(', ', $otags) . ')', array($request->user->id));
     } else {
         $title = __('Your Dashboard - Submitted Issues');
         $f_sql = new Pluf_SQL('submitter=%s AND status IN (' . implode(', ', $otags) . ')', array($request->user->id));
     }
     // Get stats about the issues
     $sql = new Pluf_SQL('submitter=%s AND status IN (' . implode(', ', $otags) . ')', array($request->user->id));
     $nb_submit = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     $sql = new Pluf_SQL('owner=%s AND status IN (' . implode(', ', $otags) . ')', array($request->user->id));
     $nb_owner = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     // Paginator to paginate the issues
     $pag = new Pluf_Paginator(new IDF_Issue());
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('current_user' => $request->user);
     $pag->summary = __('This table shows the open issues.');
     $pag->forced_where = $f_sql;
     $pag->action = $working ? 'idf_dashboard' : 'idf_dashboard_submit';
     $pag->sort_order = array('modif_dtime', 'ASC');
     // will be reverted
     $pag->sort_reverse_order = array('modif_dtime');
     $list_display = array('id' => __('Id'), array('project', 'Pluf_Paginator_FkToString', __('Project')), array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')));
     $pag->configure($list_display, array(), array('status', 'modif_dtime'));
     $pag->items_per_page = 10;
     $pag->no_results_text = $working ? __('No issues are assigned to you, yeah!') : __('All the issues you submitted are fixed, yeah!');
     $pag->setFromRequest($request);
     return Pluf_Shortcuts_RenderToResponse('idf/user/dashboard.html', array('page_title' => $title, 'nb_submit' => $nb_submit, 'nb_owner' => $nb_owner, 'issues' => $pag), $request);
 }
Esempio n. 2
0
function IDF_Middleware_ContextPreProcessor($request)
{
    $c = array();
    $c['request'] = $request;
    $c['isAdmin'] = ($request->user->administrator or $request->user->staff);
    if (isset($request->project)) {
        $c['project'] = $request->project;
        $c['isOwner'] = $request->user->hasPerm('IDF.project-owner', $request->project);
        $c['isMember'] = $request->user->hasPerm('IDF.project-member', $request->project);
        $c = array_merge($c, $request->rights);
    }
    $c['usherConfigured'] = Pluf::f("mtn_usher_conf", null) !== null;
    $c['allProjects'] = IDF_Views::getProjects($request->user);
    return $c;
}
Esempio n. 3
0
 public function forgeWatchList($request, $match)
 {
     $otags = array();
     $ctags = array();
     // Note that this approach does not scale, we will need to add
     // a table to cache the meaning of the tags for large forges.
     foreach (IDF_Views::getProjects($request->user) as $project) {
         $otags = array_merge($otags, $project->getTagIdsByStatus('open'));
     }
     foreach (IDF_Views::getProjects($request->user) as $project) {
         $ctags = array_merge($ctags, $project->getTagIdsByStatus('closed'));
     }
     if (count($otags) == 0) {
         $otags[] = 0;
     }
     if (count($ctags) == 0) {
         $ctags[] = 0;
     }
     // Get the id list of issue in the user watch list (for all projects !)
     $db =& Pluf::db();
     $sql_results = $db->select('SELECT idf_issue_id as id FROM ' . Pluf::f('db_table_prefix', '') . 'idf_issue_pluf_user_assoc WHERE pluf_user_id=' . $request->user->id);
     $issue_ids = array(0);
     foreach ($sql_results as $id) {
         $issue_ids[] = $id['id'];
     }
     $issue_ids = implode(',', $issue_ids);
     // Count open and close issues
     $sql = new Pluf_SQL('id IN (' . $issue_ids . ') AND status IN (' . implode(', ', $otags) . ')', array());
     $nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     $sql = new Pluf_SQL('id IN (' . $issue_ids . ') AND status IN (' . implode(', ', $ctags) . ')', array());
     $nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     // Generate a filter for the paginator
     switch ($match[1]) {
         case 'closed':
             $title = sprintf(__('Watch List: Closed Issues'));
             $summary = __('This table shows the closed issues in your watch list.');
             $f_sql = new Pluf_SQL('id IN (' . $issue_ids . ') AND status IN (' . implode(', ', $ctags) . ')', array());
             break;
         case 'open':
         default:
             $title = sprintf(__('Watch List: Open Issues'));
             $summary = __('This table shows the open issues in your watch list.');
             $f_sql = new Pluf_SQL('id IN (' . $issue_ids . ') AND status IN (' . implode(', ', $otags) . ')', array());
             break;
     }
     // Paginator to paginate the issues
     $pag = new Pluf_Paginator(new IDF_Issue());
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('current_user' => $request->user);
     $pag->summary = $summary;
     $pag->forced_where = $f_sql;
     $pag->action = array('IDF_Views_Issue::forgeWatchList', array($match[1]));
     $pag->sort_order = array('modif_dtime', 'ASC');
     // will be reverted
     $pag->sort_reverse_order = array('modif_dtime');
     $pag->sort_link_title = true;
     $pag->extra_classes = array('a-c', '', 'a-c', 'a-c', 'a-c');
     $list_display = array('id' => __('Id'), array('summary', 'IDF_Views_Issue_SummaryAndLabelsUnknownProject', __('Summary')), array('project', 'Pluf_Paginator_FkToString', __('Project')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')));
     $pag->configure($list_display, array(), array('id', 'project', 'status', 'modif_dtime'));
     $pag->items_per_page = 10;
     $pag->no_results_text = __('No issues were found.');
     $pag->setFromRequest($request);
     return Pluf_Shortcuts_RenderToResponse('idf/issues/forge-watchlist.html', array('page_title' => $title, 'open' => $nb_open, 'closed' => $nb_closed, 'issues' => $pag), $request);
 }