Exemple #1
0
function autoPassSuggestedJobs()
{
    $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db(DB_NAME, $con);
    $sql = "SELECT id FROM `" . WORKLIST . "` WHERE  status  IN ( 'Suggestion', 'Bidding') AND DATEDIFF(now() , status_changed) > 30";
    $result = mysql_query($sql);
    $delay = 0;
    if (mysql_num_rows($result) > 1) {
        $delay = 5;
    }
    while ($row = mysql_fetch_assoc($result)) {
        $status = 'Pass';
        $workitem = new WorkItem($row['id']);
        $prev_status = $workitem->getStatus();
        // change status of the workitem to PASS.
        $workitem->setStatus($status);
        if ($workitem->save()) {
            $recipients = array('creator');
            $emails = array();
            $data = array('prev_status' => $prev_status);
            if ($prev_status == 'Bidding') {
                $recipients[] = 'usersWithBids';
                $emails = preg_split('/[\\s]+/', ADMINS_EMAILS);
            }
            //notify
            Notification::workitemNotify(array('type' => 'auto-pass', 'workitem' => $workitem, 'recipients' => $recipients, 'emails' => $emails), $data);
            $journal_message = "\\\\#" . $workitem->getId() . " updated by @Otto. Status set to " . $status;
            Utils::systemNotification(stripslashes($journal_message));
        } else {
            error_log("Otto failed to update the status of workitem #" . $workitem->getId() . " to " . $status);
        }
        sleep($delay);
    }
    mysql_free_result($result);
    mysql_close($con);
}
Exemple #2
0
 public function updateSandboxUrl($id)
 {
     $this->view = null;
     try {
         $workitem = new WorkItem($id);
         $user = User::find(Session::uid());
         if ($workitem->getMechanicId() != $user->getId() && !$workitem->getIsRelRunner() || $workitem->getStatus() == 'Done') {
             throw new Exception('Action not allowed');
         }
         $url = trim($_POST['url']);
         $notes = trim($_POST['notes']) ? trim($_POST['notes']) : null;
         $workitem->setSandbox($url);
         $workitem->save();
         if ($notes) {
             //add review notes
             $fee_amount = 0.0;
             $fee_desc = 'Review Notes: ' . $notes;
             $mechanic_id = $workitem->getMechanicId();
             $itemid = $workitem->getId();
             $is_expense = 1;
             $fee_category = '';
             Fee::add($itemid, $fee_amount, $fee_category, $fee_desc, $mechanic_id, $is_expense);
         }
         $journal_message = '\\#' . $workitem->getId() . ' updated by @' . $user->getNickname() . " Branch URL: {$url}";
         Utils::systemNotification($journal_message);
         echo json_encode(array('success' => false, 'message' => $journal_message));
     } catch (Exception $e) {
         echo json_encode(array('success' => false, 'message' => $e->getMessage()));
     }
 }