diff --git a/application/controllers/Ajax.php b/application/controllers/Ajax.php index 05042702..e4cc0d88 100644 --- a/application/controllers/Ajax.php +++ b/application/controllers/Ajax.php @@ -304,17 +304,15 @@ function contact() { $result['success'] = false; - $name = $this->input->post('name'); - $email = $this->input->post('email'); - $message = $this->input->post('message'); + $tags = "contact"; $this->load->library('mandrill'); $messageMandrill = array( - 'html' => $message, - 'subject' => $subject, - 'from_email' => $email, - 'from_name' => $name, + 'html' => $this->message, + 'subject' => "Contact information", + 'from_email' => $this->email, + 'from_name' => $this->name, 'to' => array( array( 'email' => 'marc@toolwatch.io', @@ -323,7 +321,7 @@ function contact() { ) ), 'headers' => array( - 'Reply-To' => $email, + 'Reply-To' => $this->email, ), 'important' => false, 'track_opens' => true, @@ -341,9 +339,9 @@ function contact() { $scheduleTime = time(); - $send_at = date('Y-', $scheduleTime).date('m-', $scheduleTime) - .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)-1).':' - .(date('i', $scheduleTime)).date(':s', $scheduleTime); + $returnValue = date('Y-', $scheduleTime).date('m-', $scheduleTime) + .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)).':' + .(date('i', $scheduleTime)).':'.(date('s', $scheduleTime)); $mandrillResponse = $this->mandrill->messages->send($messageMandrill, $async, $ip_pool, $send_at); log_message('info', 'Mandrill email: ' . print_r($mandrillResponse, true)); @@ -351,7 +349,7 @@ function contact() { if ($mandrillResponse[0]['status'] === 'sent') { $result['success'] = true; - } + } echo json_encode($result); } diff --git a/application/controllers/Measures.php b/application/controllers/Measures.php index 38eec3ec..c9f421a0 100644 --- a/application/controllers/Measures.php +++ b/application/controllers/Measures.php @@ -215,11 +215,12 @@ public function new_measure() { $this->event->add(MEASURE_LOAD); + array_push($this->_headerData['javaScripts'], "input.time.logic"); + $this->_headerData['headerClass'] = 'blue'; $this->load->view('header', $this->_headerData); $this->load->view('measure/new-measure', $this->_bodyData); - $this->load->view('measure/audio.php'); $this->load->view('footer'); } @@ -248,15 +249,17 @@ public function get_accuracy() { $this->event->add(ACCURACY_LOAD); + $this->_headerData['headerClass'] = 'blue'; - array_push($this->_headerData['javaScripts'], "watch.animation"); + array_push($this->_headerData['javaScripts'], "input.time.logic", + "watch.animation"); + $this->load->view('header', $this->_headerData); $this->_bodyData['selectedWatch'] = $this->watch->getWatch($this->input->post('watchId')); $this->_bodyData['measureId'] = $this->input->post('measureId'); $this->load->view('measure/get-accuracy', $this->_bodyData); - $this->load->view('measure/audio.php'); $this->load->view('footer'); @@ -265,15 +268,6 @@ public function get_accuracy() { } } - /** - * getReferenceTime. Set the server time to the user session. - * - * This must to be call by the user before accuracyMeasure or baseMeasure - */ - function getReferenceTime() { - $this->session->set_userdata('referenceTime', time()); - } - /** * Save the base measure (1/2) * @@ -288,21 +282,14 @@ function getReferenceTime() { */ function baseMeasure() { - if ($this->expectsPost(array('watchId', 'userTimezone', 'userTime'))) { - - $result = array('success' =>false); - - $watchId = $this->input->post('watchId'); - - //Construct user time - $referenceTime = $this->session->userdata('referenceTime'); - $userTimezone = $this->input->post('userTimezone'); - $tempUserTime = preg_split('/:/', $this->input->post('userTime')); - $userTime = mktime($tempUserTime[0], $tempUserTime[1], - $tempUserTime[2], date("n"), date("j"), date("Y")); + if ($this->expectsPost(array('watchId', 'referenceTimestamp', 'userTimestamp'))) { //Add the base measure - if ($this->measure->addBaseMesure($watchId, $referenceTime, $userTime)) { + if ($this->measure->addBaseMesure( + $this->watchId, + $this->referenceTimestamp/1000, + $this->userTimestamp/1000) + ) { $result['success'] = true; @@ -319,8 +306,6 @@ function baseMeasure() { * TODO: When this becomes doable from many endpoints (web, mobile, ...) * I'll to move it to the model. * - * FIXME: userTimezone parameter isn't used. Should it ? - * * @param POST String measureId * @param POST String userTimezone * @param POST String userTime @@ -329,20 +314,14 @@ function baseMeasure() { */ function accuracyMeasure() { - if ($this->expectsPost(array('measureId', 'userTimezone', 'userTime'))) { - - $result = array('success' =>false); - - //Construct the user time - $referenceTime = $this->session->userdata('referenceTime'); - $userTimezone = $this->input->post('userTimezone'); - $tempUserTime = preg_split('/:/', $this->input->post('userTime')); - $userTime = mktime($tempUserTime[0], $tempUserTime[1], $tempUserTime[2], - date("n"), date("j"), date("Y")); + if ($this->expectsPost(array('measureId', 'referenceTimestamp', 'userTimestamp'))) { //Add the watch measure $watchMeasure = $this->measure->addAccuracyMesure( - $this->input->post('measureId'), $referenceTime, $userTime); + $this->measureId, + $this->referenceTimestamp/1000, + $this->userTimestamp/1000 + ); // If the computed accuracy makes sense, we return success if (is_numeric($watchMeasure->accuracy)) { diff --git a/application/libraries/Auto_email.php b/application/libraries/Auto_email.php index 7db40bc9..7a902ed3 100644 --- a/application/libraries/Auto_email.php +++ b/application/libraries/Auto_email.php @@ -306,9 +306,14 @@ private function sendAtString($scheduleTime) { //sent right away. $scheduleTime = $scheduleTime-48*60*60; + log_message('info', 'Date ' . print_r($scheduleTime, true)); + + $returnValue = date('Y-', $scheduleTime).date('m-', $scheduleTime) .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)).':' - .(date('i', $scheduleTime)).date(':s', $scheduleTime); + .(date('i', $scheduleTime)).':'.(date('s', $scheduleTime)); + + log_message('info', 'Date ' . print_r($returnValue, true)); return $returnValue; } diff --git a/application/tests/controllers/Measures_test.php b/application/tests/controllers/Measures_test.php index 4f0cfecb..4bfc461d 100644 --- a/application/tests/controllers/Measures_test.php +++ b/application/tests/controllers/Measures_test.php @@ -173,7 +173,7 @@ public function test_newWatch(){ public function test_newMeasure(){ $output = $this->request('GET', ['Measures', 'new_measure']); - $this->assertContains('
The accuracy of your watch is
+ To begin measuring the accuracy of your watch, we must first
+ synchronize it with Toolwatch's accuracy system.
+ You were supposed to click when the second hand was
+
+ exactly at 12
+ .
+
You've synchronized you watch at
+ `
+ + constructoffsetedDateString(offsetedDate) +
+ `
One does not simply have a timepiece without drift ! + Press the following + button to add/retrieve a minute or + click here to retry.
+ +