public static function edit($username, $groupname, $newrights) { if (!TlonGroup::exists($groupname)) { return false; } return TlonData::update(self::$TABLE, TlonDataComparison::set('rights', $newrights), array(TlonDataComparison::equals('username', $username), TlonDataComparison::equals('groupname', $groupname))); }
/** * add(): Add a new user to TABLE, auto-generating password-hash and salt, and automatically * adding her to the 'all' group and to a group with the name '${username}_grp'. * @param string $username Username. * @param string $password Unhashed password. * @param string $realname Real name. * @return bool */ public static function add($username, $password, $realname) { list($hash, $salt) = TlonHash::password($password); if (!(TlonUserGroup::add($username, TlonGroup::EVERYONE, TlonRights::READ, TlonGroup::EVERYONEINFO) && TlonUserGroup::add($username, TlonGroup::userGroupname($username), TlonRights::READ_WRITE, $realname))) { return false; } return TlonData::insert(self::$TABLE, array($username, $hash, $realname, $salt, null)); }
public static function add($groupname, $document_id, $rights = TlonRights::READ_WRITE, $groupinfo = '') { if (!TlonGroup::exists($groupname)) { if (!TlonGroup::add($groupname, $groupinfo)) { return false; } } return TlonData::insert(self::$TABLE, array($groupname, $document_id, $rights)); }
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'class.tlondata.php'; TlonGroup::$TABLE = new TlonDataTable('tl_group', 'groupname, info'); class TlonGroup { public static $TABLE = null; const USERGROUP = '%s_group'; const EVERYONE = 'all'; const EVERYONEINFO = 'All Tlon users'; /** * All users are automatically added to two groups: 'all' * to which all users are added, and a group with the name '{$username}_group' * which is unique for each user. */ public static function userGroupname($username) { return sprintf(self::USERGROUP, $username); }
/** * info(): get group info. * @param string $authtoken Authentication token. * @param string $groupname Groupname. * @return TlonSoapResponse Result */ public function info($authtoken, $groupname) { if ($this->_checkRights($authtoken, $groupname, TlonRights::READ)) { return $this->returnByBool(TlonGroup::getByGroupname($groupname), $authtoken); } else { return $this->returnFailure($authtoken); } }