Ejemplo n.º 1
0
/**
 * Format the annotations and only include data which the user wants to see. 
 * The array which is passed to the method will be modified.
 *
 * @param $ann array the annotation array (userid => (time, costs) )
 */
function formatAnnotations(&$ann)
{
    $type = usr_get_preference('ui.sublistAnnotations');
    $userIds = array_keys($ann);
    if ($type == null) {
        $type = 0;
    }
    switch ($type) {
        case 0:
            // just time
            foreach ($userIds as $userId) {
                $ann[$userId] = formatDuration($ann[$userId]['time']);
            }
            break;
        case 1:
            // just costs
            foreach ($userIds as $userId) {
                $ann[$userId] = formatCurrency($ann[$userId]['costs']);
            }
            break;
        case 2:
        default:
            // both
            foreach ($userIds as $userId) {
                $time = formatDuration($ann[$userId]['time']);
                $costs = formatCurrency($ann[$userId]['costs']);
                $ann[$userId] = "<span style=\"white-space: nowrap;\">{$time} |</span>  {$costs}";
            }
    }
}
Ejemplo n.º 2
0
/**
 * write details of a specific user into $kga
 *
 * @param integer $user ID of user in table usr
 * @global array $kga kimai-global-array
 * @return array $kga 
 * @author th
 *
 */
function get_user_config($user)
{
    global $kga, $conn;
    if (!$user) {
        return;
    }
    $table = $kga['server_prefix'] . "usr";
    $filter['usr_ID'] = MySQL::SQLValue($user, MySQL::SQLVALUE_NUMBER);
    // get values from user record
    $columns[] = "usr_ID";
    $columns[] = "usr_name";
    $columns[] = "usr_grp";
    $columns[] = "usr_sts";
    $columns[] = "usr_trash";
    $columns[] = "usr_active";
    $columns[] = "usr_mail";
    $columns[] = "pw";
    $columns[] = "ban";
    $columns[] = "banTime";
    $columns[] = "secure";
    $columns[] = "lastProject";
    $columns[] = "lastEvent";
    $columns[] = "lastRecord";
    $columns[] = "timespace_in";
    $columns[] = "timespace_out";
    $conn->SelectRows($table, $filter, $columns);
    $rows = $conn->RowArray(0, MYSQL_ASSOC);
    foreach ($rows as $key => $value) {
        $kga['usr'][$key] = $value;
    }
    // get values from user configuration (user-preferences)
    unset($columns);
    unset($filter);
    $kga['conf'] = array_merge($kga['conf'], usr_get_preferences_by_prefix('ui.'));
    $userTimezone = usr_get_preference('timezone');
    if ($userTimezone != '') {
        $kga['conf']['timezone'] = $userTimezone;
    }
    date_default_timezone_set($kga['conf']['timezone']);
}
Ejemplo n.º 3
0
/**
 * write details of a specific user into $kga
 *
 * @param integer $user ID of user in table usr
 * @global array $kga kimai-global-array
 * @return array $kga 
 * @author th
 *
 */
function get_user_config($user)
{
    global $kga, $pdo_conn;
    $p = $kga['server_prefix'];
    if (!$user) {
        return;
    }
    // get values from user record
    $pdo_query = $pdo_conn->prepare("SELECT\n  `usr_ID`,\n  `usr_name`,\n  `usr_grp`,\n  `usr_sts`,\n  `usr_trash`,\n  `usr_active`,\n  `usr_mail`,\n  `pw`,\n  `ban`,\n  `banTime`,\n  `secure`,\n\n  `lastProject`,\n  `lastEvent`,\n  `lastRecord`,\n  `timespace_in`,\n  `timespace_out`\n\n  FROM {$p}usr WHERE usr_ID = ?;");
    $result = $pdo_query->execute(array($user));
    $row = $pdo_query->fetch(PDO::FETCH_ASSOC);
    foreach ($row as $key => $value) {
        $kga['usr'][$key] = $value;
    }
    $kga['conf'] = array_merge($kga['conf'], usr_get_preferences_by_prefix('ui.', $kga['usr']['usr_ID']));
    $userTimezone = usr_get_preference('timezone');
    if ($userTimezone != '') {
        $kga['conf']['timezone'] = $userTimezone;
    }
    date_default_timezone_set($kga['conf']['timezone']);
}