// 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); } }