Changeset 18880


Ignore:
Timestamp:
06/17/17 14:05:57 (7 years ago)
Author:
Daniela Dorner
Message:
fix to avoid errors when used on command line, changes as discussed in telcon
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/dch/shiftinfo.php

    r18841 r18880  
    33  <meta name="Author" content="The FACT Group" />
    44  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    5   <title>FACT Project</title>
     5  <title>FACT Contact Info</title>
    66  <link rel="StyleSheet" type="text/css" href="../style.css" />
    77</head>
     
    1818<?php
    1919
    20 if ($argv)
     20//find out if php was started with command-line or on browswer
     21//echo php_sapi_name();
     22//echo PHP_SAPI;
     23if (strcmp(php_sapi_name(), "cli")==0 && $argv)
     24{
    2125    parse_str(implode('&', array_slice($argv, 1)), $_GET);
     26    $_SERVER["REMOTE_USER"]="FACT";
     27}
    2228
    2329if (isset($_GET['date']))
     
    4652{
    4753    // this is getting exactly one entry from the DB, since we get only
    48     // one username, which is unique in the DB.
    49     $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
     54    //   one username, which is unique in the DB.
     55    // contactinfo and availability need to be queried as else PHP complains
     56    //   in the function userinfo_to_string(), but for shifter they can/should be empty
     57    $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype, '' as contactinfo, '' as availability
    5058        FROM logbook.userfields
    5159        LEFT JOIN logbook.users
     
    6169function get_expertinfo($db)
    6270{
    63     $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
     71    $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype, fid8 as contactinfo, fid6 as availability
    6472        FROM logbook.userfields
    6573        LEFT JOIN logbook.users ON (uid=ufid)
     
    7684{
    7785    $s = $userinfo['name'] . "[" .$userinfo['login']."]" . ": <br>";
    78     $s .= "    email:" . $userinfo['email'] . "<br>";
    79     $s .= "    mobile:" . $userinfo['mobile'] . "<br>";
    80     $s .= "    skype:" . $userinfo['skype'] . "<br>";
     86    if (str_replace(' ', '', $userinfo['contactinfo']))
     87        $s .= $userinfo['contactinfo']."<br>";
     88    else
     89    {
     90        $s .= "    email:" . $userinfo['email'] . "<br>";
     91        $s .= "    mobile:" . $userinfo['mobile'] . "<br>";
     92        $s .= "    skype:" . $userinfo['skype'] . "<br>";
     93    }
     94    if ((strcmp($_SERVER['REMOTE_USER'], "FACT")==0) && str_replace(' ', '', $userinfo['availability']))
     95        $s .= "availability information: <br>".$userinfo['availability']."<br>";
    8196    return $s;
    8297}
     
    105120while ($row = $result->fetch_assoc())
    106121{
    107    
    108122    $userinfo = get_userinfo($db, $row['u']);
    109     if ($userinfo['name']){
     123    if ($userinfo['name'])
     124    {
    110125        echo "<li>".userinfo_to_string($userinfo)."</li>\n";
    111126        if (!$userinfo['mobile'])
     
    118133echo "Expert-On-Call Contact Info: <br>\n <ul>\n";
    119134
    120 foreach (get_expertinfo($db) as $expertinfo) {
     135foreach (get_expertinfo($db) as $expertinfo)
     136{
    121137    echo "<li>".userinfo_to_string($expertinfo)."</li><br>\n";
    122138
Note: See TracChangeset for help on using the changeset viewer.