コード例 #1
0
ファイル: pear-database-user.php プロジェクト: stof/pearweb
 static function isQA($handle)
 {
     require_once 'Damblan/Karma.php';
     global $dbh;
     $karma = new Damblan_Karma($dbh);
     return $karma->has($handle, 'pear.qa');
 }
コード例 #2
0
ファイル: pepr-proposal.php プロジェクト: stof/pearweb
 function sendActionEmail($event, $userType, $user_handle = null, $comment = '')
 {
     global $dbh, $karma, $auth_user;
     if (empty($karma)) {
         $karma = new Damblan_Karma($dbh);
     }
     require 'pepr/pepr-emails.php';
     $email = $proposalEmailTexts[$event];
     if (empty($email)) {
         return PEAR::raiseError("Email template for {$event} not found");
     }
     switch ($userType) {
         case 'admin':
             $prefix = "[ADMIN]";
             break;
         case 'mixed':
             if ($karma->has($user_handle, "pear.pepr.admin") && $this->user_handle != $user_handle) {
                 $prefix = "[ADMIN]";
             } else {
                 $prefix = "";
             }
             break;
         default:
             $prefix = "";
     }
     $prefix = PROPOSAL_EMAIL_PREFIX . $prefix . " ";
     include_once 'pear-database-user.php';
     $actorinfo = user::info($user_handle);
     $ownerinfo = user::info($this->user_handle);
     $this->getVotes($dbh);
     $vote = @$this->votes[$user_handle];
     if (isset($vote)) {
         $vote->value = $vote->value > 0 ? "+" . $vote->value : $vote->value;
         if ($vote->is_conditional) {
             $vote_conditional = "\n\nThis vote is conditional. The condition is:\n\n" . $vote->comment;
         } elseif ($vote->comment) {
             $comment = "\n\nComment:\n\n" . $vote->comment;
         }
         $vote_url = "http://" . PEAR_CHANNELNAME . "/pepr/pepr-vote-show.php?id=" . $this->id . "&handle=" . $user_handle;
     }
     if ($event == 'change_status_finished') {
         $proposalVotesSum = ppVote::getSum($dbh, $this->id);
         $vote_result = 'Sum of Votes: ' . $proposalVotesSum['all'];
         $vote_result .= ' (' . $proposalVotesSum['conditional'] . ' conditional)';
         if ($proposalVotesSum['all'] >= 5) {
             $vote_result .= "\nResult:       This proposal was accepted";
         } else {
             $vote_result .= "\nResult:       This proposal was rejected";
         }
     }
     $proposal_url = "http://" . PEAR_CHANNELNAME . "/pepr/pepr-proposal-show.php?id=" . $this->id;
     $end_voting_time = @$this->longened_date > 0 ? $this->longened_date + PROPOSAL_STATUS_VOTE_TIMELINE : @$this->vote_date + PROPOSAL_STATUS_VOTE_TIMELINE;
     if ($event == 'proposal_comment' && $user_handle == $this->user_handle) {
         $email['to'] = $email['to']['owner'];
     } else {
         if (!isset($user_handle)) {
             $email['to'] = $email['to']['pearweb'];
         } else {
             if ($karma->has($user_handle, "pear.pepr.admin")) {
                 $email['to'] = $email['to']['admin'];
             } else {
                 $email['to'] = $email['to']['user'];
             }
         }
     }
     $email['subject'] = $prefix . $email['subject'];
     $replace = array("/\\{pkg_category\\}/", "/\\{pkg_name\\}/", "/\\{owner_name\\}/", "/\\{owner_email\\}/", "/\\{owner_link\\}/", "/\\{actor_name\\}/", "/\\{actor_email\\}/", "/\\{actor_link\\}/", "/\\{proposal_url\\}/", "/\\{end_voting_time\\}/", "/\\{vote_value\\}/", "/\\{vote_url\\}/", "/\\{email_pear_dev\\}/", "/\\{email_pear_group\\}/", "/\\{comment\\}/", "/\\{vote_result\\}/", "/\\{vote_conditional\\}/");
     $replacements = array($this->pkg_category, $this->pkg_name, isset($ownerinfo['name']) ? $ownerinfo['name'] : "", isset($ownerinfo['email']) ? "<{$ownerinfo['email']}>" : '', isset($ownerinfo['handle']) ? user_link($ownerinfo['handle'], true) : "", isset($actorinfo['name']) ? $actorinfo['name'] : "", isset($actorinfo['email']) ? $actorinfo['email'] : "", isset($actorinfo['handle']) ? "http://" . PEAR_CHANNELNAME . "/user/" . $actorinfo['handle'] : "", $proposal_url, format_date($end_voting_time), isset($vote) ? $vote->value : 0, isset($vote) ? $vote_url : "", PROPOSAL_MAIL_PEAR_DEV, PROPOSAL_MAIL_PEAR_GROUP, isset($comment) ? wordwrap($comment) : '', isset($vote_result) ? $vote_result : '', isset($vote_conditional) ? $vote_conditional : "");
     $email = preg_replace($replace, $replacements, $email);
     $email['text'] .= PROPOSAL_EMAIL_POSTFIX;
     if (is_object($auth_user)) {
         $from = '"' . $auth_user->name . '" <' . $auth_user->email . '>';
     } else {
         $from = PROPOSAL_MAIL_FROM;
     }
     $to = explode(", ", $email['to']);
     $email['to'] = array_shift($to);
     $headers = "CC: " . implode(", ", $to) . "\n";
     $headers .= "From: " . $from . "\n";
     $headers .= "X-Mailer: " . "PEPr, PEAR Proposal System" . "\n";
     $headers .= "X-PEAR-Category: " . $this->pkg_category . "\n";
     $headers .= "X-PEAR-Package: " . $this->pkg_name . "\n";
     $headers .= "X-PEPr-Status: " . $this->getStatus() . "\n";
     if ($event == "change_status_proposal") {
         $headers .= "Message-ID: <proposal-" . $this->id . "@" . PEAR_CHANNELNAME . ">\n";
     } else {
         $headers .= "In-Reply-To: <proposal-" . $this->id . "@" . PEAR_CHANNELNAME . ">\n";
     }
     if (!DEVBOX) {
         $res = mail($email['to'], $email['subject'], $email['text'], $headers, '-f ' . PEAR_BOUNCE_EMAIL);
     } else {
         $res = true;
     }
     if (!$res) {
         return PEAR::raiseError('Could not send notification email.');
     }
     return true;
 }
コード例 #3
0
ファイル: pear-auth.php プロジェクト: stof/pearweb
function auth_check($atom)
{
    global $dbh;
    static $karma;
    require_once "Damblan/Karma.php";
    global $auth_user;
    if (!isset($auth_user)) {
        return false;
    }
    // Check for backwards compatibility
    if (is_bool($atom)) {
        $atom = $atom === true ? 'pear.admin' : 'pear.dev';
    }
    if (!isset($karma)) {
        $karma = new Damblan_Karma($dbh);
    }
    return $karma->has($auth_user->handle, $atom);
}
コード例 #4
0
ファイル: account-info.php プロジェクト: stof/pearweb
}
if ($row['pgpkeyid']) {
    echo '    <li>PGP Key: &nbsp;';
    echo make_link('http://pgp.mit.edu:11371/pks/lookup?search=0x' . htmlspecialchars($row['pgpkeyid']) . '&amp;op=get', htmlspecialchars($row['pgpkeyid']));
    echo "</li>\n";
}
echo '    <li>RSS Feed: &nbsp;';
echo make_link('http://' . PEAR_CHANNELNAME . '/feeds/user_' . $handle . '.rss');
echo '</li>' . "\n";
if (!empty($row['latitude']) && !empty($row['longitude'])) {
    echo '    <li class="geo">Map: &nbsp;';
    $geo = '<span class="latitude">' . $row['latitude'] . '</span>, <span class="longitude">' . $row['longitude'] . '</span>';
    echo make_link('http://' . PEAR_CHANNELNAME . '/map/?handle=' . $handle, $geo);
    echo '</li>' . "\n";
}
if ($karma->has($handle, 'pear.dev')) {
    echo '    <li>Bug Statistics: <br />' . "\n";
    echo '     <ul>' . "\n";
    $info = $bugs->developerBugStats($handle);
    echo '      <li>Rank: <strong><a href="/bugs/stats_dev.php">#' . $info['rank'] . ' of ' . count($info['rankings']) . '</a></strong> developers who have fixed bugs <strong>(' . $info['alltime'] . ' fixed bugs)</strong></li>' . "\n";
    echo '      <li>Average age of open bugs: <strong>' . $info['openage'] . ' days</strong></li>' . "\n";
    $url = '/bugs/search.php?handle=' . $handle . '&amp;cmd=display&amp;bug_type=Bug&amp;status=OpenFeedback&amp;showmenu=1';
    echo '      <li>Number of open bugs: <strong><a href="' . $url . '">' . $info['opencount'] . '</a></strong></li>' . "\n";
    echo '      <li>Assigned bugs relative to all maintained packages bugs: <strong>' . round($info['assigned'] * 100) . '%</strong></li>' . "\n";
    echo '      <li>Number of submitted patches: <strong>' . $info['patches'] . '</strong></li>' . "\n";
    echo '      <li>Number of bugs opened using account: <strong>' . $info['opened'] . '</strong></li>' . "\n";
    echo '      <li>Number of bug comments using account: <strong>' . $info['commented'] . '</strong></li>' . "\n";
    echo '     </ul>' . "\n";
    echo '    </li>' . "\n";
}
?>
コード例 #5
0
ファイル: peclKarmaUpgrade.php プロジェクト: stof/pearweb
if (DB::isError($dbh)) {
    die("Failed to connect: {$dsn}\n");
}
require_once 'pear-database-maintainer.php';
require_once 'pear-database-note.php';
require_once 'Damblan/Karma.php';
$karma = new Damblan_Karma($dbh);
$karma_level = 'pecl.dev';
$sql = "SELECT p.name, p.id\n        FROM packages p\n        WHERE p.package_type = 'pecl'\n        ORDER BY p.name";
$packages = $dbh->getAssoc($sql, false, null, DB_FETCHMODE_ASSOC);
foreach ($packages as $n => $id) {
    $m = maintainer::get((int) $id);
    if (!empty($m)) {
        echo "\nAltering karma for maintainers of {$n} package id {$id}\n";
        foreach ($m as $handle => $m_data) {
            if (!$karma->has($handle, $karma_level)) {
                echo "Giving {$handle} {$karma_level} karma\n";
                // Bypassing damblan karma because it needs a logged in user
                $id = $dbh->nextId('karma');
                if (DB::isError($id)) {
                    echo "Couldn't get a new id from the karma table\n";
                    exit;
                }
                $query = 'INSERT INTO karma (id, user, level, granted_by, granted_at)
                          VALUES (?, ?, ?, ?, NOW())';
                $sth = $dbh->query($query, array($id, $handle, $karma_level, 'peclweb'));
                if (DB::isError($sth)) {
                    echo "Giving karma to {$handle} failed!\n";
                    exit;
                }
                // Adding a note about it
コード例 #6
0
ファイル: pear-auth.php プロジェクト: phpsource/web-pecl
function auth_check($atom)
{
    global $dbh;
    static $karma;
    require_once "Damblan/Karma.php";
    global $auth_user;
    // admins are almighty
    if (user::isAdmin($auth_user->handle)) {
        return true;
    }
    // Check for backwards compatibility
    if (is_bool($atom)) {
        if ($atom == true) {
            $atom = "pear.admin";
        } else {
            $atom = "pear.dev";
        }
    }
    // every authenticated user has the pear.user and pear.dev karma
    if (in_array($atom, array("pear.user", "pear.dev"))) {
        return true;
    }
    if (!isset($karma)) {
        $karma = new Damblan_Karma($dbh);
    }
    $a = $karma->has($auth_user->handle, $atom);
    if (PEAR::isError($a)) {
        return false;
    }
    return $a;
}
コード例 #7
0
ファイル: pepr-proposal-delete.php プロジェクト: stof/pearweb
    report_error('The requested proposal does not exist.');
    response_footer();
    exit;
}
$karma = new Damblan_Karma($dbh);
$form = new HTML_QuickForm2('delete-proposal', 'post', array('action' => 'pepr-proposal-delete.php?id=' . $proposal->id));
ob_start();
response_header('PEPr :: Delete :: ' . htmlspecialchars($proposal->pkg_name));
echo '<h1>Delete Proposal &quot;' . htmlspecialchars($proposal->pkg_name) . "&quot;</h1>\n";
if (!$proposal->mayEdit($auth_user->handle)) {
    report_error('You are not allowed to delete this proposal,' . ' probably due to it having reached the "' . $proposal->getStatus(true) . '" phase.' . ' If this MUST be deleted, contact someone ELSE' . ' who has pear.pepr.admin karma.');
    response_footer();
    exit;
}
if ($proposal->compareStatus('>', 'proposal')) {
    if ($karma->has($auth_user->handle, 'pear.pepr.admin')) {
        report_error('This proposal has reached the "' . $proposal->getStatus(true) . '" phase.' . ' Are you SURE you want to delete it?', 'warnings', 'WARNING:');
    }
}
$form->removeAttribute('name');
$form->addElement('checkbox', 'delete', array('required' => 'required'))->setLabel('You are sure?');
$reason = $form->addElement('textarea', 'reason');
$reason->setLabel('Why?');
$form->addElement('submit', 'submit', 'Do it');
if (isset($_POST['submit'])) {
    if ($form->validate()) {
        $proposal->delete($dbh);
        $proposal->sendActionEmail('proposal_delete', 'mixed', $auth_user->handle, $reason->getValue());
        ob_end_clean();
        localRedirect('pepr-proposal-delete.php?id=' . $proposal->id . '&isDeleted=1');
    } else {