~studentersamfundet-web/dns-inside/main

« back to all changes in this revision

Viewing changes to inside/functions.php

  • Committer: nikolark
  • Date: 2011-08-19 23:44:46 UTC
  • Revision ID: nikolark@nintendo.neuf.no-20110819234446-coe44h76ufrh2ovv
Dependency injection on migration functions (uid parameter).

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
function checkForumUsername($username, $password) {
139
139
        $conn = db_connect("forum");
140
140
        $sql = sprintf("SELECT user_id FROM phpbb_users u " . "WHERE username_clean = '%s' ", strtolower($username));
 
141
    /* TODO: What happends if the forum db does not exist? How do you print the error? */
141
142
        $result = & $conn->query($sql);
142
143
        if ($result->numRows() == 0) {
143
144
                return "not-used";
1565
1566
// Migration (nikolark)
1566
1567
 
1567
1568
/* Returns true if the current logged in user have the migrated flag. */
1568
 
function is_migrated() {
 
1569
function is_migrated($uid) {
1569
1570
    $conn = db_connect();
1570
 
    $uid = getCurrentUser();
1571
1571
 
1572
1572
    $sql = sprintf("SELECT migrated FROM din_user WHERE id=%s AND migrated IS NOT NULL", $uid);
1573
1573
    $result = $conn->query($sql);
1579
1579
    return $result->numRows() > 0;
1580
1580
}
1581
1581
/* Update the migration status */
1582
 
function set_migrated() {
 
1582
function set_migrated($uid) {
1583
1583
    $conn = db_connect();
1584
 
    $uid = getCurrentUser();
1585
1584
 
1586
1585
    $sql = sprintf("UPDATE din_user SET migrated=NOW() WHERE id=%s", $uid);
1587
1586
    $result = $conn->query($sql);
1592
1591
    return true;
1593
1592
}
1594
1593
/* Find a users groups */
1595
 
function find_groups() {
 
1594
function find_groups($uid) {
1596
1595
    $conn = db_connect();
1597
 
    $uid = getCurrentUser();
1598
1596
    $sql = "SELECT g.posix_group
1599
1597
        FROM din_usergrouprelationship ugr, din_user u, din_group g
1600
1598
        WHERE ugr.user_id = $uid