{
$this->get($_REQUEST['id']);
- die("TODO");
- if (isset($_POST['cancel'])) {
- header("Location: {$$this->baseURL}/Ticket/$this->issue->nsident");
- exit;
- }
-
- if (!MTrack_Captcha::check('ticket')) {
- $this->error[] = "CAPTCHA failed, please try again";
- }
- $this->preview = isset($_POST['preview']) ? true : false;
-
- $comment = '';
- try {
- if (!$this->id) {
- MTrackACL::requireAllRights("Tickets", 'create');
- } else {
- MTrackACL::requireAllRights("ticket:" . $this->issue->tid, 'modify');
- }
- } catch (Exception $e) {
- $this->error[] = $e->getMessage();
- }
-
- if (!$this->id) {
- $comment = empty($_POST['comment']) ? '' : $_POST['comment'];
- }
-
- if (!strlen($comment)) {
- $comment = $_POST['summary'];
- }
- try {
- $CS = MTrackChangeset::begin("ticket:X", $comment);
- } catch (Exception $e) {
- $this->error[] = $e->getMessage();
- $CS = null;
- }
- if (!$this->id) {
- // compute next id number.
- // We don't use auto-number, because we allow for importing multiple
- // projects with their own ticket sequence.
- // During "normal" user-driven operation, we do want plain old id numbers
- // so we compute it here, under a transaction
- $db = MTrackDB::get();
-
-
-
- switch($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
- case 'pgsql':
- // Some versions of postgres don't like that we have "abc123" for
- // identifiers, so match on the bigest number nsident fields only
- $max = "select max(cast(nsident as integer)) + 1 from tickets where nsident ~ '^\\\\d+$'";
- break;
-
- case 'mysql':
- $max = "select max(cast(nsident as UNSIGNED)) + 1 from tickets";
- break;
-
- default:
- $max = 'select max(cast(nsident as integer)) + 1 from tickets';
- break;
- }
-
-
-
- list($this->issue->nsident) = MTrackDB::q($max)->fetchAll(PDO::FETCH_COLUMN, 0);
- if ($this->issue->nsident === null) {
- $this->issue->nsident = 1;
- }
- }
-
- if (isset($_POST['action']) && !$this->preview) {
- $act= explode('_', $_POST['action'] , 2);
- //var_dump($act);exit;
- switch ($act[0]) {
- case 'leave':
- break;
- case 'reopen':
- $this->issue->reOpen();
- break;
- case 'fixed':
- $this->issue->resolution = 'fixed';
- $this->issue->close();
- $_POST['estimated'] = $this->issue->estimated;
- break;
-
-
- case 'accept':
- // will be applied to the issue further down
- $_POST['owner'] = MTrackAuth::whoami();
- if ($this->issue->status == 'new') {
- $this->issue->status = 'open';
- }
- break;
-
-
- case 'resolve':
- //$this->issue->resolution = $_POST['resolution'];
- $this->issue->resolution = $act[1];
- $this->issue->close();
- $_POST['estimated'] = $this->issue->estimated;
- break;
-
- case 'change':
- $this->issue->status = $act[1];
- break;
- }
- }
-
- $fields = array(
- 'summary',
- 'description',
- 'classification',
- 'priority',
- 'severity',
- 'changelog',
- 'owner',
- 'cc',
- );
-
- $this->issue->applyPOSTData($_POST);
+
+ /// $this->preview = isset($_POST['preview']) ? true : false;
+ // hopefull get has sorted out permissions..
-
- foreach ($fields as $fieldname) {
- if (isset($_POST[$fieldname]) && strlen($_POST[$fieldname])) {
- $this->issue->$fieldname = $_POST[$fieldname];
- } else {
- $this->issue->$fieldname = null;
- }
- }
+ // $CS = MTrackChangeset::begin("ticket:X", $comment);
- $kw = $this->issue->getKeywords();
+ $old = clone($this->issue);
+
+ if (!$this->issue->id) {
+ // set some defaults.
+ $en = DB_DataObject:;factory('core_enum');
+ $en->setFrom(array('etype' => 'ticketstate', 'name' => 'new'));
+ $en->find(true);
+ $this->issue->status = $en->id;
+ }
+ $this->issue->setFrom($_POST);
+
+ /*
+ $kw = $this->issue->getKeywords();
$kill = array_values($kw);
foreach (preg_split('/[ \t,]+/', $_POST['keywords']) as $w) {
if (!strlen($w)) {
foreach ($kill as $w) {
$this->issue->dissocKeyword($w);
}
-
+
+
$ms = $this->issue->getMilestones();
$kill = $ms;
if (isset($_POST['milestone']) && is_array($_POST['milestone'])) {
foreach ($kill as $mid) {
$this->issue->dissocMilestone($mid);
}
-
+
$ms = $this->issue->getComponents();
$kill = $ms;
if (isset($_POST['component']) && is_array($_POST['component'])) {
empty($_POST['spent']) ? 0 : $_POST['spent'],
empty($_POST['estimate']) ? 0 : $_POST['estimate']
);
-
+ */
if (!count($this->error)) {
try {
$this->issue->save($CS);