[ Index ] |
PHP Cross Reference of Eventum |
[Summary view] [Print] [Text view]
1 #!/usr/bin/php 2 <?php 3 /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */ 4 // +----------------------------------------------------------------------+ 5 // | Eventum - Defect Tracking System | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 2003 Joao Prado Maia | 8 // +----------------------------------------------------------------------+ 9 // | Authors: João Prado Maia <jpm@impleo.net> | 10 // +----------------------------------------------------------------------+ 11 // 12 // @(#) $Id: eventum 3425 2007-11-09 21:11:50Z glen $ 13 // 14 require_once(dirname(__FILE__) . '/config.inc.php'); 15 require_once(APP_INC_PATH . 'class.command_line.php'); 16 require_once(APP_PEAR_PATH . 'XML/RPC.php'); 17 18 list($user_email, $user_password, $url, $port, $relative_url) = Command_Line::getEnvironmentSettings(); 19 if (empty($port)) { 20 $port = 80; 21 } 22 if (empty($relative_url)) { 23 $relative_url = '/'; 24 } 25 26 if (count($argv) == 1) { 27 Command_Line::quit("Requirement argument not found"); 28 } 29 // show usage information if user gave --help 30 if (($argv[1] == '--help') || ($argv[1] == 'help')) { 31 Command_Line::usage(__FILE__); 32 } 33 34 $should_confirm = Command_Line::isSafeExecution(); 35 36 $client = new XML_RPC_Client($relative_url . "rpc/xmlrpc.php", $url, $port); 37 //$client->setDebug(1); 38 39 // need to process authentication first 40 Command_Line::checkAuthentication($client, $user_email, $user_password); 41 42 $auth = array($user_email, $user_password); 43 44 // log command 45 Command_Line::log($client, $auth, join(' ', $argv)); 46 47 $issue_id = (integer )$argv[1]; 48 if ($issue_id > 0) { 49 if (count($argv) == 2) { 50 Command_Line::printIssueDetails($client, $auth, $issue_id); 51 } else { 52 if ($should_confirm) { 53 Command_Line::promptConfirmation($client, $auth, $issue_id, @$argv); 54 } 55 switch ($argv[2]) { 56 case 'assign': 57 if (count($argv) == 3) { 58 Command_Line::quit("Missing parameter for the developer"); 59 } 60 Command_Line::assignIssue($client, $auth, $issue_id, $argv[3]); 61 break; 62 case 'add-replier': 63 case 'ar': 64 // adds a user to the list of authorized repliers 65 if (count($argv) == 3) { 66 Command_Line::quit("Missing parameter for the developer"); 67 } 68 Command_Line::addAuthorizedReplier($client, $auth, $issue_id, $argv[3]); 69 break; 70 case 'set-status': 71 if (count($argv) == 3) { 72 Command_Line::quit("Missing parameter for the status"); 73 } 74 Command_Line::setIssueStatus($client, $auth, $issue_id, $argv[3]); 75 break; 76 case 'add-time': 77 if (count($argv) == 3) { 78 Command_Line::quit("Missing parameter for time worked"); 79 } 80 $check = (integer) $argv[3]; 81 if ($check == 0) { 82 Command_Line::quit("Third argument to command 'add-time' should be a number"); 83 } 84 Command_Line::addTimeEntry($client, $auth, $issue_id, $check); 85 break; 86 case 'list-files': 87 case 'lf': 88 Command_Line::printFileList($client, $auth, $issue_id); 89 break; 90 case 'get-file': 91 case 'gf': 92 if (count($argv) == 3) { 93 Command_Line::quit("Missing parameter for the file number"); 94 } 95 Command_Line::getFile($client, $auth, $issue_id, $argv[3]); 96 break; 97 case 'close': 98 Command_Line::closeIssue($client, $auth, $issue_id); 99 break; 100 101 // email related commands 102 case 'list-emails': 103 case 'le': 104 // lists all emails for the given issue 105 Command_Line::listEmails($client, $auth, $issue_id); 106 break; 107 case 'get-email': 108 case 'ge': 109 // views an email 110 if (count($argv) == 3) { 111 Command_Line::quit("Missing parameter for the email number"); 112 } 113 if (@$argv[4] == "--full") { 114 $full = true; 115 } else { 116 $full = false; 117 } 118 Command_Line::printEmail($client, $auth, $issue_id, $argv[3], $full); 119 break; 120 121 // note related commands 122 case 'list-notes': 123 case 'ln': 124 // list notes for the given issues 125 Command_Line::listNotes($client, $auth, $issue_id); 126 break; 127 case 'get-note': 128 case 'gn': 129 // view a note 130 if (count($argv) == 3) { 131 Command_Line::quit("Missing parameter for the note number"); 132 } 133 Command_Line::printNote($client, $auth, $issue_id, $argv[3]); 134 break; 135 case 'convert-note': 136 case 'cn': 137 // convert a note to an email 138 if (empty($argv[3])) { 139 Command_Line::quit("Missing parameter for the note number"); 140 } 141 if (@$argv[4] != 'draft' && @$argv[4] != 'email' ) { 142 Command_Line::quit("4th parameter must be 'draft' or 'email'"); 143 } 144 if (@$argv[5] == 'authorize') { 145 $authorize_sender = true; 146 } else { 147 $authorize_sender = false; 148 } 149 Command_Line::convertNote($client, $auth, $issue_id, $argv[3], $argv[4], $authorize_sender); 150 break; 151 152 // draft related commands 153 case 'list-drafts': 154 case 'ld': 155 // list drafts 156 Command_Line::listDrafts($client, $auth, $issue_id); 157 break; 158 case 'get-draft': 159 case 'gd': 160 // viewing a draft 161 if (count($argv) == 3) { 162 Command_Line::quit("Missing parameter for the draft number"); 163 } 164 Command_Line::printDraft($client, $auth, $issue_id, $argv[3]); 165 break; 166 case 'send-draft': 167 case 'sd': 168 // viewing a draft 169 if (count($argv) == 3) { 170 Command_Line::quit("Missing parameter for the draft number"); 171 } 172 Command_Line::sendDraft($client, $auth, $issue_id, $argv[3]); 173 break; 174 175 case 'redeem': 176 // marking an issue as redeemed 177 Command_Line::redeemIssue($client, $auth, $issue_id); 178 break; 179 180 case 'unredeem': 181 // unmarks issue as redeemed incident 182 Command_Line::unredeemIssue($client, $auth, $issue_id); 183 break; 184 185 default: 186 Command_Line::quit("Unknown command '" . $argv[2] . "'"); 187 } 188 } 189 } else { 190 if ($argv[1] == 'developers') { 191 Command_Line::printDeveloperList($client, $auth); 192 } elseif ($argv[1] == 'open-issues') { 193 if (count($argv) == 3) { 194 if (@$argv[2] == 'my') { 195 $show_all_issues = false; 196 $status = ''; 197 } else { 198 $show_all_issues = true; 199 $status = $argv[2]; 200 } 201 } elseif (count($argv) == 4) { 202 if (@$argv[3] == 'my') { 203 $show_all_issues = false; 204 } else { 205 $show_all_issues = true; 206 } 207 $status = $argv[2]; 208 } else { 209 $show_all_issues = true; 210 $status = ''; 211 } 212 Command_Line::printOpenIssues($client, $auth, $show_all_issues, $status); 213 } elseif ($argv[1] == 'list-status') { 214 Command_Line::printStatusList($client, $auth); 215 } elseif ($argv[1] == 'customer') { 216 if (count($argv) != 4) { 217 Command_Line::quit("Wrong parameter count"); 218 } 219 Command_Line::lookupCustomer($client, $auth, $argv[2], $argv[3]); 220 } elseif (($argv[1] == 'weekly-report') || ($argv[1] == 'wr')) { 221 if (count(@$argv) >= 4 and $argv[3] != '--separate-closed') { 222 $separate_closed = (@$argv[4] == '--separate-closed'); 223 // date range 224 Command_Line::getWeeklyReport($client, $auth, 0, $argv[2], $argv[3], $separate_closed); 225 } else { 226 // weekly 227 if (@$argv[2] == '') { 228 $separate_closed = false; 229 @$argv[2] = 0; 230 } else { 231 $separate_closed = (@$argv[3] == '--separate-closed' or @$argv[2] == '--separate-closed'); 232 } 233 Command_Line::getWeeklyReport($client, $auth, $argv[2], '', '', $separate_closed); 234 } 235 } elseif ($argv[1] == 'clock') { 236 Command_Line::timeClock($client, $auth, @$argv[2]); 237 } else { 238 Command_Line::quit("Unknown parameter '" . $argv[1] . "'"); 239 } 240 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 19 21:21:33 2007 | Cross-referenced by PHPXref 0.7 |