We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit f0cb7e0e authored by tobyink's avatar tobyink

Fixed group ownership.

parent ea098835
......@@ -71,7 +71,7 @@ class Group {
$this->homepage = $row['homepage'];
$this->bio = $row['bio'];
$this->avatar_uri = $row["avatar_uri"];
$this->owner = new User($row['owner']);
$this->owner = User::new_from_uniqueid_number($row['owner']);
$this->count = -1;
$this->users = array();
if (! preg_match('/\:/', $this->id))
......@@ -172,13 +172,18 @@ class Group {
return $res;
}
// Get ID number for group
$q = sprintf('SELECT id FROM Groups WHERE lower(groupname) = lower(%s)', $mdb2->quote($name, 'text'));
$res = $mdb2->query($q);
if (PEAR::isError($res))
{
return $res;
}
$grp = $result->fetchOne(0);
elseif (!$res->numRows())
{
return (new PEAR_Error("Something has gone horribly, horribly wrong!"));
}
$grp = $res->fetchOne(0);
// Group owner must be a member of the group
$q = sprintf('INSERT INTO Group_Members (grp, member, joined) VALUES (%s, %s, %d)'
......
......@@ -34,7 +34,7 @@ class User {
public $name, $email, $fullname, $bio, $location, $homepage, $error, $userlevel;
public $id, $acctid, $avatar_uri, $location_uri, $webid_uri, $laconica_profile, $journal_rss;
public $password, $has_identica, $created, $modified;
public $password, $has_identica, $created, $modified, $uniqueid;
/**
* User constructor
......@@ -84,6 +84,17 @@ class User {
}
}
public static function new_from_uniqueid_number ($uid)
{
global $mdb2;
$res = $mdb2->query(sprintf('SELECT * FROM Users WHERE uniqueid = %d', (int)$uid));
if($res->numRows()) {
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
return new User($row['username'], $row);
}
}
function save ()
{
global $mdb2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment