function grantRole($name) { $role = new Profile_role(); $role->profile_id = $this->id; $role->role = $name; $role->created = common_sql_now(); $result = $role->insert(); if (!$result) { common_log_db_error($role, 'INSERT', __FILE__); return false; } return true; }
function grantRole($name) { if (Event::handle('StartGrantRole', array($this, $name))) { $role = new Profile_role(); $role->profile_id = $this->id; $role->role = $name; $role->created = common_sql_now(); $result = $role->insert(); if (!$result) { throw new Exception("Can't save role '{$name}' for profile '{$this->id}'"); } if ($name == 'owner') { User::blow('user:site_owner'); } Event::handle('EndGrantRole', array($this, $name)); } return $result; }
if (empty($fullname)) { echo 'username required'; exit; } if (empty($email)) { echo 'email required'; exit; } if (empty($password)) { echo 'password required'; exit; } $profile = new Profile(); $profile->fullname = $fullname; $profile->email = $email; $profile->created = common_sql_now(); $profile_id = $profile->insert(); if (!$profile_id) { common_log_db_error($profile, 'INSERT', __FILE__); exit; } $profile_role = new Profile_role(); $profile_role->profile_id = $profile_id; $profile_role->role = Profile_role::SUPERADMIN; $profile_role->created = common_sql_now(); $profile_role->insert(); $pnew = Profile::staticGet($profile_id); $orig = clone $pnew; $pnew->password = common_munge_password($password, $profile_id); $pnew->update($orig); echo "Done!";