Пример #1
0
/**
 * Helper to display the pepr proposal information better.
 */
function render_proposal($dbh, $proposal, $user, $already_voted)
{
    ob_start();
    if ($already_voted) {
        echo '(Already voted) ';
    }
    echo make_link('pepr-proposal-show.php?id=' . $proposal->id, htmlspecialchars($proposal->pkg_category) . ' :: ' . htmlspecialchars($proposal->pkg_name));
    echo ' by ';
    echo make_link('/user/' . htmlspecialchars($proposal->user_handle), htmlspecialchars($user['name']));
    switch ($proposal->getStatus()) {
        case 'proposal':
            echo ' &nbsp;(<a href="pepr-comments-show.php?id=' . $proposal->id;
            echo '">Comments</a>)';
            break;
        case 'vote':
        case 'finished':
            $voteSums = ppVote::getSum($dbh, $proposal->id);
            echo ' &nbsp;(<a href="pepr-votes-show.php?id=' . $proposal->id;
            echo '">Vote</a> sum: <strong>' . $voteSums['all'] . '</strong>';
            echo '<small>, ' . $voteSums['conditional'];
            echo ' conditional</small>)';
    }
    return ob_get_clean();
}
Пример #2
0
 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
// Get the database class.
require_once 'DB.php';
$options = array('persistent' => false, 'portability' => DB_PORTABILITY_ALL);
$dbh =& DB::connect(PEAR_DATABASE_DSN, $options);
if (DB::isError($dbh)) {
    die("Failed to connect: {$dsn}\n");
}
// Obtain PEPr's common functions and classes.
require_once 'pepr/pepr.php';
$proposals =& proposal::getAll($dbh, 'vote');
// This checks if a proposal should automatically be finished
foreach ($proposals as $id => $proposal) {
    if ($proposal->getStatus() == 'vote') {
        $lastVoteDate = $proposal->longened_date > 0 ? $proposal->longened_date : $proposal->vote_date;
        if ($lastVoteDate + PROPOSAL_STATUS_VOTE_TIMELINE < time()) {
            if (ppVote::getCount($dbh, $proposal->id) > 4) {
                $proposals[$id]->status = 'finished';
                $proposal->sendActionEmail('change_status_finished', 'pearweb', null);
            } else {
                if ($proposal->longened_date > 0) {
                    $proposals[$id]->status = 'finished';
                    $proposal->sendActionEmail('change_status_finished', 'pearweb', null);
                } else {
                    $proposals[$id]->longened_date = time();
                    $proposal->sendActionEmail('longened_timeline_sys', 'pearweb', null);
                }
            }
            $proposals[$id]->getLinks($dbh);
            $proposals[$id]->store($dbh);
        }
    }
Пример #4
0
}
response_header('PEPr :: Vote Details :: ' . htmlspecialchars($proposal->pkg_name) . ' :: ' . $handle);
echo '<h1>Vote Details for "' . htmlspecialchars($proposal->pkg_name) . '" by ';
echo $handle . "</h1>\n";
display_pepr_nav($proposal);
?>

<table border="0" cellspacing="0" cellpadding="2" style="width: 100%">

 <tr>
  <th class="headrow">&raquo; Details</th>
 </tr>
 <tr>

<?php 
$vote = ppVote::get($dbh, $proposal->id, $handle);
if (!$vote) {
    echo '<td class="textcell" valign="top">';
    echo 'This user has not voted on this proposal yet.';
} else {
    echo '<td class="ulcell" valign="top">';
    echo "<ul>\n";
    echo ' <li>Voter: ';
    echo user_link($handle);
    echo "</li>\n";
    echo ' <li>Vote: ';
    if ($vote->value > 0) {
        echo '+';
    }
    echo $vote->value;
    if ($vote->is_conditional) {
Пример #5
0
                if ($vote->value > 0) {
                    $vote->value = '+' . $vote->value;
                }
                echo ' <li><strong>';
                echo make_link('pepr-vote-show.php?id=' . $proposal->id . '&amp;handle=' . htmlspecialchars($vote->user_handle), $vote->value);
                echo '</strong>';
                if ($vote->is_conditional) {
                    echo '^';
                } elseif (!empty($vote->comment)) {
                    echo '*';
                }
                echo ' &nbsp;(';
                echo make_link('/user/' . htmlspecialchars($vote->user_handle), htmlspecialchars($users[$vote->user_handle]['name']));
                echo ')&nbsp; ' . format_date($vote->timestamp);
                echo "</li>\n";
            }
            $proposalVotesSum = ppVote::getSum($dbh, $proposal->id);
            echo "</ul>\n" . '<p style="padding-left: 1.2em;"><strong>';
            echo 'Sum: ' . $proposalVotesSum['all'] . '</strong> <small>(';
            echo $proposalVotesSum['conditional'];
            echo ' conditional)</small></p>' . "\n";
            echo '<p style="padding-left: 1.2em;"><small>^ Indicates';
            echo ' the vote is conditional.' . "\n";
            echo '<br />* Indicates';
            echo ' the vote contains a comment.</small></p>' . "\n";
        }
}
echo "  </td>\n";
echo " </tr>\n";
echo "</table>\n";
response_footer();