diff --git a/~dev_rating/application/classes/Controller/Handler/ErrMessages.php b/~dev_rating/application/classes/Controller/Handler/ErrMessages.php index 6c3a21f46e8a1d9ef7beaffef31bca30c1392ea5..b43e11bec734988976d868f7f1f404d2d7247dca 100644 --- a/~dev_rating/application/classes/Controller/Handler/ErrMessages.php +++ b/~dev_rating/application/classes/Controller/Handler/ErrMessages.php @@ -26,11 +26,13 @@ class Controller_Handler_ErrMessages extends Controller_Handler if ($imageinfo['mime'] != 'image/png' && $imageinfo['mime'] != 'image/jpeg') { $data['error'] = 'File must be JPEG or PNG'; } else { - $uploaddir = DOCROOT . 'support/img/'; - $uploadfile = $uploaddir . basename($_FILES['imageFile']['name']) ; + $requestID = $this->createRequestWithImg($this->user->ID); + $dir = DOCROOT . 'support/img/'; + $ext = '.' . pathinfo($_FILES['imageFile']['name'], PATHINFO_EXTENSION); + $fname = (string)$requestID; + $uploadfile = $dir . $fname . $ext; if (move_uploaded_file($_FILES['imageFile']['tmp_name'], $uploadfile)) { $data['success'] = true; - $requestID = $this->createRequestWithImg($this->user->ID, $uploadfile); // undone $data['requestID'] = $requestID; } } @@ -45,12 +47,16 @@ class Controller_Handler_ErrMessages extends Controller_Handler $title = $_POST['title']; $text = $_POST['text']; $requestID = $_POST['requestID']; - // TODO if requestID != -1 write in to existed record // constructing mail body $to = 'it.lab.mmcs@gmail.com'; - $ticket = $this->sendNewRequest($this->user->ID, $title, $text); + if ($requestID <= 0) { + $ticket = $this->sendNewRequest($this->user->ID, $title, $text); + } else { + // TODO write in to existed record + $ticket = $this->updateExistedRequest($requestID, $this->user->ID, $title, $text); // not implemented + } $subject = "Request {$ticket}: rating system report"; $message = Twig::factory('handler/report', [ @@ -81,15 +87,20 @@ class Controller_Handler_ErrMessages extends Controller_Handler ->execute()->get('Num'); } - private function createRequestWithImg($accountID, $imageFileName) { - // TODO + private function updateExistedRequest($requestID,$accountID, $title, $description) { + // TODO: implement + return $requestID; + } + + private function createRequestWithImg($accountID) { + // TODO: implement /* - $sql = "SELECT `CreateRequest`(:account, :title, :description, :imageName) AS 'Num';"; + $sql = "SELECT `CreateRequest`(:account, :title, :description, :isImage) AS 'Num';"; return DB::query(Database::SELECT, $sql) ->param(':account', (int) $accountID) ->param(':description', "") ->param(':title', "") - ->param(':imageName', $imageFileName) + ->param(':isImage',true) ->execute()->get('Num'); */ return 165;