function confirmRequest($salt) { if (!$this->find($salt)) { return PEAR::raiseError('cannot find request'); } // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma include_once 'pear-database-user.php'; $user = user::info($this->handle, null, 0); if (!isset($user['registered'])) { return PEAR::raiseError('Error - user request was deleted, please try again'); } include_once 'pear-database-note.php'; note::removeAll($this->handle); $data = array(); $data['handle'] = $user['handle']; $data['registered'] = 1; $data['created'] = gmdate('Y-m-d'); $data['createdby'] = SITE . 'web'; $e = user::update($data, true); if (PEAR::isError($e) || !$e) { return $e; } $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web')); $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web')); if (!DB::isError($sth)) { note::add($this->handle, 'Account opened', SITE . 'web'); $msg = "Your PEAR voter account has been opened.\n" . "You can now participate in the elections by going to\n" . " http://" . PEAR_CHANNELNAME . "/election/"; $xhdr = "From: " . PEAR_WEBMASTER_EMAIL; if (!DEVBOX) { mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL); } $this->deleteRequest(); return true; } return false; }
static function activate($uid, $karmalevel = 'pear.dev') { require_once 'Damblan/Karma.php'; global $dbh, $auth_user; $karma = new Damblan_Karma($dbh); $user = user::info($uid, null, 0); if (!isset($user['registered'])) { return false; } @($arr = unserialize($user['userinfo'])); include_once 'pear-database-note.php'; note::removeAll($uid); $data = array(); $data['registered'] = 1; $data['active'] = 1; /* $data['ppp_only'] = 0; */ if (is_array($arr)) { $data['userinfo'] = $arr[1]; } $data['created'] = gmdate('Y-m-d H:i'); $data['createdby'] = $auth_user->handle; $data['handle'] = $user['handle']; user::update($data, true); $karma->grant($user['handle'], $karmalevel); if ($karma->has($user['handle'], 'pear.dev')) { include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh); $pear_rest->saveMaintainerREST($user['handle']); $pear_rest->saveAllMaintainersREST(); } include_once 'pear-database-note.php'; note::add($uid, "Account opened"); $msg = "Your PEAR account request has been opened.\n" . "To log in, go to http://" . PEAR_CHANNELNAME . "/ and click on \"login\" in\n" . "the top-right menu.\n"; $xhdr = 'From: ' . $auth_user->handle . '@php.net'; if (!DEVBOX) { mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, '-f ' . PEAR_BOUNCE_EMAIL); } return true; }
function activate($uid) { global $dbh, $auth_user; $user =& new PEAR_User($dbh, $uid); if (@$user->registered) { return false; } @($arr = unserialize($user->userinfo)); note::removeAll("uid", $uid); $user->set('registered', 1); /* $user->set('ppp_only', 0); */ if (is_array($arr)) { $user->set('userinfo', $arr[1]); } $user->set('created', gmdate('Y-m-d H:i')); $user->set('createdby', $auth_user->handle); $user->set('registered', 1); $user->store(); note::add("uid", $uid, "Account opened"); $GLOBALS['pear_rest']->saveMaintainerREST($user->handle); $GLOBALS['pear_rest']->saveAllmaintainersREST(); $msg = "Your PECL/PEAR account request has been opened.\n" . "To log in, go to http://pecl.php.net/ and click on \"login\" in\n" . "the top-right menu.\n"; $xhdr = "From: " . $auth_user->handle . "@php.net"; mail($user->email, "Your PECL Account Request", $msg, $xhdr, "-f noreply@php.net"); return true; }
function confirmRequest($handle, $password, $name) { $sql = 'SELECT handle FROM users WHERE handle = ?'; if ($handle == $this->dbh->getOne($sql, array($handle))) { $id = $this->dbh->nextId("karma"); $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); return true; } list($firstname, $lastname) = explode(' ', $name, 2); $data = array('handle' => $handle, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $this->email, 'purpose' => 'bug tracker', 'password' => $password, 'password2' => $password, 'purpose' => 'Open/Comment on bugs', 'moreinfo' => 'Automatic Account Request', 'homepage' => ''); include_once 'pear-database-user.php'; $useradd = user::add($data, true, true); if ($useradd !== true) { return $useradd; } $sql = 'SELECT handle from bug_account_request WHERE salt = ?'; $temphandle = $this->dbh->getOne($sql, array($this->salt)); // update all relevant records to the new handle $this->dbh->query('UPDATE bugdb_comments set reporter_name = ? WHERE handle = ?', array($name, $temphandle)); $this->dbh->query('UPDATE bugdb set reporter_name = ? WHERE handle = ?', array($name, $temphandle)); $this->dbh->query('UPDATE users set handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb set registered = 1, handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb_comments set handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb_patchtracker set developer = ? WHERE developer = ?', array($handle, $temphandle)); $this->handle = $handle; // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma include_once 'pear-database-user.php'; $user = user::info($handle, null, 0); if (!isset($user['registered'])) { return false; } @($arr = unserialize($user['userinfo'])); include_once 'pear-database-note.php'; note::removeAll($handle); $data = array(); $data['registered'] = 1; $data['password'] = $password; $data['name'] = $name; if (is_array($arr)) { $data['userinfo'] = $arr[1]; } $data['create'] = gmdate('Y-m-d'); $data['createBy'] = SITE . 'web'; $data['handle'] = $handle; user::update($data, true); $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web')); $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web')); if (!DB::isError($sth)) { require_once 'bugs/pear-bugs-utils.php'; $pbu = new PEAR_Bugs_Utils(); note::add($this->handle, 'Account opened', SITE . 'web'); $bugs = $this->dbh->getAll('SELECT * FROM bugdb WHERE handle = ?', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($bugs as $bug) { $this->sendBugEmail($bug); } $patches = $this->dbh->getAll('SELECT bugdb.package_name, bugdb_patchtracker.* FROM bugdb_patchtracker, bugdb WHERE bugdb_patchtracker.developer = ? AND bugdb.id = bugdb_patchtracker.bugdb_id', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($patches as $patch) { $pbu->sendPatchEmail($patch); } $bugs = $this->dbh->getAll('SELECT bugdb_comments.email,bugdb_comments.comment, bugdb_comments.reporter_name, bugdb.id, bugdb.bug_type,bugdb.package_name,bugdb.sdesc, bugdb.ldesc,bugdb.php_version, bugdb.php_os,bugdb.status, bugdb.assign,bugdb.package_version FROM bugdb_comments, bugdb WHERE bugdb.id = bugdb_comments.bug AND bugdb_comments.handle = ?', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($bugs as $bug) { $this->sendBugCommentEmail($bug); } $msg = "Your PEAR bug tracker account has been opened.\n" . "Bugs you have opened will now be displayed, and you can\n" . "add new comments to existing bugs"; $xhdr = "From: " . PEAR_WEBMASTER_EMAIL; if (!DEVBOX) { mail($user['email'], "Your PEAR Bug Tracker Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL); } $this->deleteRequest(); return true; } return false; }