コード例 #1
0
ファイル: class.tlonuser.php プロジェクト: raisanen/tlon
	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';
require_once 'class.tlonhash.php';
require_once 'class.tlonusergroup.php';
TlonUser::$TABLE = new TlonDataTable('tl_user', 'username, password, realname, salt, auth_token');
class TlonUser
{
    public static $TABLE = null;
    /**
     * 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))) {