Example #1
0
function showOneEntry($r, $only_phone = false)
{
    global $db, $table, $table_grp_adr, $table_groups, $print, $is_fix_group, $mail_as_image, $page_ext_qry;
    $view = "";
    $view .= add("<b>" . $r['firstname'] . (!empty($r['middlename']) ? " " . $r['middlename'] : "") . " " . $r['lastname'] . "</b>");
    $view .= add($r['nickname']);
    $b64 = explode(";", $r['photo']);
    if (count($b64) >= 3 && !$only_phone) {
        $b64 = $b64[2];
        $b64 = explode(":", $b64);
        if (count($b64) >= 2) {
            $b64 = str_replace(" ", "", $b64[1]);
            $view .= $r['photo'] != "" ? '<img alt="Embedded Image" width=75 src="data:image/jpg;base64,' . $b64 . '"/><br>' : "";
        }
    }
    if (!$only_phone) {
        $view .= ($r['title'] != "" ? "<i>" : "") . add($r['title']) . ($r['title'] != "" ? "</i>" : "");
        $view .= add($r['company']);
        //     $view .= addGroup($r, array('address'));
        $view .= add(str_replace("\n", "<br />", trim($r["address"])));
        $view .= addGroup($r, array('home', 'mobile', 'work', 'fax'));
    }
    $view .= addPhone($r['home'], ucfmsg('H:'));
    $view .= addPhone($r['mobile'], ucfmsg('M:'));
    $view .= addPhone($r['work'], ucfmsg('W:'));
    $view .= addPhone($r['fax'], ucfmsg('F:'));
    if (!$only_phone) {
        $view .= addGroup($r, array('email', 'email2', 'email3', 'homepage'));
        if ($mail_as_image) {
            // B64IMG: Thanks to NelloD
            $view .= $r['email'] != "" ? "<img src=\"b64img.php?text=" . base64_encode($r['email']) . "\"><br/>" : "";
            $view .= $r['email2'] != "" ? "<img src=\"b64img.php?text=" . base64_encode($r['email2']) . "\"><br/>" : "";
            $view .= $r['email3'] != "" ? "<img src=\"b64img.php?text=" . base64_encode($r['email3']) . "\"><br/>" : "";
        } else {
            $view .= addEmail($r['email']);
            $view .= addEmail($r['email2']);
            $view .= addEmail($r['email3']);
        }
        $view .= addHomepage($r['homepage']);
        $view .= addGroup($r, array('bday', 'bmonth', 'byear'));
        $view .= addBirthday($r['bday'], $r['bmonth'], $r['byear'], ucfmsg('BIRTHDAY'));
        $view .= addBirthday($r['aday'], $r['amonth'], $r['ayear'], ucfmsg('ANNIVERSARY'));
        $view .= addGroup($r, array('address2', 'phone2'));
        $view .= add(str_replace("\n", "<br />", trim($r['address2'])));
        $view .= addGroup($r, array('phone2'));
    }
    $view .= add($r['phone2'], ucfmsg('P:'));
    if (!$only_phone) {
        // Detect URLs (http://*, www.*) and show as link.
        //
        // $text = "Hello, http://www.google.com";
        // $new = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $test);
        //
        $view .= $r['notes'] != "" ? "<br />" . str_replace("\n", "<br />", trim($r['notes'])) . "<br /><br />" : "";
    }
    echo $view . "\n";
    if (!isset($print) and !$is_fix_group) {
        $sql = "SELECT DISTINCT {$table_groups}.group_id, group_name\n\t             FROM {$table_grp_adr}, {$table_groups}, {$table}\n\t            WHERE {$table}.id = {$table_grp_adr}.id\n\t              AND {$table}.id = " . $r['id'] . "\n\t              AND {$table_grp_adr}.group_id  = {$table_groups}.group_id";
        $result = mysql_query($sql, $db);
        $first = true;
        while ($result && ($g = mysql_fetch_array($result))) {
            if ($first) {
                echo "<br /><i>" . ucfmsg('MEMBER_OF') . ": ";
            } else {
                echo ", ";
            }
            echo "<a href='./index{$page_ext_qry}group=" . urlencode($g['group_name']) . "'>" . $g['group_name'] . "</a>";
            $first = false;
        }
        if ($first != true) {
            echo "</i>";
        }
        /*
        echo "<br/><br/>";
        echo ucfmsg('MODIFIED') . ": ".$r['modified'];
        echo "<i>(".ucfmsg('CREATED')  . ": ".$r['created'].")</i><br/>";
        */
    }
}
        $user->newid = $id;
    } else {
        $largestId++;
        $user->newid = $largestId;
    }
    $users[$row['userid']] = $user;
}
echo "Part 1: extract data from Bugzilla database, construct users and user_email tables</br>";
//var_dump($users);
//up to now the user data is complete and compitable with LDAP, the original
//user data in Redmine PostgreSQL.
//The next step is write the extra user data into Redmine PostgreSQL
writeUser($users);
//add content to table, email_address, which indicates the email address of
//each user
addEmail($users);
echo "Part 2: construct member table";
/* several steps are necessary in this part. the first step is importing Developer members into each project, the second
 * step is importing Reporter members into each project.
 */
//step 1
$developers = array();
$sql = "SELECT DISTINCT assigned_to,login_name, product_id, name FROM bugs,products,profiles WHERE bugs.product_id = products.id and profiles.userid = assigned_to";
$result = mysqli_query($mysqlCon, $sql) or die(mysqli_error() . $sql);
while ($row = mysqli_fetch_array($result)) {
    $developer = new stdClass();
    $developer->id = mapuserid($row['login_name']);
    $developer->projectid = mapprojectid($row['name']);
    $developers[] = $developer;
}
//var_dump($developers);