summaryrefslogtreecommitdiff
path: root/scripts/user.php
blob: 9993d9adf3031f1a89b690f984c027de6b6e5b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

  /*********************************************************\
  | View a user's profile                                   |
  | ~~~~~~~~~~~~~~~~~~~~                                    |
  \*********************************************************/

if (!defined('IN_FS')) {
    die('Do not access this file directly.');
}

$page->assign('groups', Flyspray::listGroups());

if ($proj->id) {
    $page->assign('project_groups', Flyspray::listGroups($proj->id));
}

$id = Flyspray::validUserId(Get::val('id', Get::val('uid')));
if (!$id) {
  $id = Flyspray::usernameToId(Get::val('user_name'));
}

$theuser = new User($id);
if ($theuser->isAnon()) {
    Flyspray::show_error(19);
}

// Some possibly interesting information about the user
$sql = $db->query('SELECT count(*) FROM {comments} WHERE user_id = ?', array($theuser->id));
$page->assign('comments', $db->fetchOne($sql));

$sql = $db->query('SELECT count(*) FROM {tasks} WHERE opened_by = ?', array($theuser->id));
$page->assign('tasks', $db->fetchOne($sql));

$sql = $db->query('SELECT count(*) FROM {assigned} WHERE user_id = ?', array($theuser->id));
$page->assign('assigned', $db->fetchOne($sql));

$page->assign('theuser', $theuser);

$page->setTitle($fs->prefs['page_title'] . L('viewprofile'));
$page->pushTpl('profile.tpl');

?>