Skip to content

Commit

Permalink
Fix merge conflict #58
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuNls committed Feb 8, 2016
2 parents 0c7313c + 7c5169f commit 5c19d8c
Show file tree
Hide file tree
Showing 190 changed files with 244,318 additions and 517 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ application/logs/*
application/tests/build/*
vendor/
.env
.phpintel/*
.phpintel/*
application/config/google-api.p12
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ notifications:
slack: toolwatchapp:AfvHCPE9Em1MY3j04gdlqbYe
email: false

script: cd application/tests/ && phpunit --coverage-text
script:
- cd application/tests/ && phpunit --coverage-text
- php coverage-checker.php build/logs/clover.xml 100
9 changes: 9 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
},
"MC_APIKEY": {
"required":true
},
"GOOGLE_API_ACCOUNT":{
"required":true
},
"GOOGLE_API_KEY":{
"required":true
},
"GOOGLE_API_LINK":{
"required":true
}
},
"addons": [
Expand Down
23 changes: 23 additions & 0 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,26 @@
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
$config['proxy_ips'] = '';

/*
|--------------------------------------------------------------------------
| Google API Config
|--------------------------------------------------------------------------
|
| Google API requires a P12 enrypted key. The key is downloaded
| from a secure location if not already present on the disk
*/
if(!file_exists(APPPATH.'config/google-api.p12')){
$out = fopen(APPPATH.'config/google-api.p12', "wb");
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, getenv("GOOGLE_API_LINK"));
curl_setopt($ch, CURLOPT_USERPWD, getenv("GOOGLE_API_KEY"));
curl_exec($ch);

curl_close($ch);
fclose($out);
}
$config['google_api_key'] = APPPATH.'config/google-api.p12';
$config['google_api_account'] = getenv("GOOGLE_API_ACCOUNT");
12 changes: 3 additions & 9 deletions application/controllers/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ function login() {
}

echo json_encode($result);
}else{
echo "POST FAIL";
}

}
Expand Down Expand Up @@ -216,9 +214,6 @@ function signup() {
//Log the user will create his session and so on
$this->user->login($email, $password);

} else {

$result['success'] = false;
}

//The email is already in use
Expand Down Expand Up @@ -306,7 +301,8 @@ function resetPassword() {
function contact() {

if ($this->expectsPost(array('name', 'email', 'message'))) {
$result = array();

$result['success'] = false;

$name = $this->input->post('name');
$email = $this->input->post('email');
Expand Down Expand Up @@ -355,9 +351,7 @@ function contact() {

if ($mandrillResponse[0]['status'] === 'sent') {
$result['success'] = true;
} else {
$result['success'] = false;
}
}

echo json_encode($result);
}
Expand Down
73 changes: 28 additions & 45 deletions application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@

class Home extends MY_Controller {

//TODO: Can we overide load view to append .mobile ?
private $viewName = "home/home";
private $viewName;

function __construct() {
parent::__construct();
$this->load->model('measure');

if ($this->agent->is_mobile()) {
$this->viewName = "home/home-mobile";
}
$this->load->model('measure');

$this->viewName = $this->agent->is_mobile()
? "home/home-mobile"
: "home/home";
}

function index() {

if (!$this->agent->is_mobile()) {
array_push($this->_headerData['javaScripts'], "home.logic", "watch.animation");
} else {
array_push($this->_headerData['javaScripts'], "home.logic.mobile");
}
$this->agent->is_mobile()
? array_push($this->_headerData['javaScripts'], "home.logic.mobile")
: array_push($this->_headerData['javaScripts'], "home.logic", "watch.animation");

$this->load->view('header', $this->_headerData);
$this->load->view($this->viewName, $this->homeMessage());
Expand All @@ -31,55 +28,39 @@ function index() {

function result() {

if (!$this->agent->is_mobile()) {
array_push($this->_headerData['javaScripts'], "home.logic", "watch.animation");
} else {
array_push($this->_headerData['javaScripts'], "home.logic.mobile");
}

$this->_headerData["meta_img"] = img_url("accuracy.jpg");

$this->load->view('header', $this->_headerData);
$this->load->view($this->viewName, $this->homeMessage());
$this->load->view('footer');
$this->index();
}

private function homeMessage() {

$randBrands = rand(0, 2);
$randWatches = rand(0, 3);
$randWatches = rand(0, 2);

$watchBrands = array('Seiko', 'Rolex', 'Omega');
$videos = array('Omega', 'Rolex', 'Zenith', 'Vacheron');

$video = vid_url('Zenith.mp4');
$videos = array('Omega', 'Rolex', 'Vacheron');

if (!$this->user->isLoggedIn()) {

$homePage = 'HOME_PAGE_'.$randWatches;

$this->event->add($homePage);

}

if (!$this->agent->is_mobile()) {
return array('title' => $this->measure
->getMeasuresCountByWatchBrand($watchBrands[$randBrands]).
' '.$watchBrands[$randBrands].' measured on Toolwatch.io',
'video_url' => vid_url($videos[$randWatches]).'.mp4');
} else {
return array('title' => $this->measure
->getMeasuresCountByWatchBrand($watchBrands[$randBrands]).
' '.$watchBrands[$randBrands].' measured on Toolwatch.io',
'video_url' => img_url($videos[$randWatches]).'.png');
}
$title = $this->measure
->getMeasuresCountByWatchBrand($watchBrands[$randBrands]).
' '.$watchBrands[$randBrands].' measured on Toolwatch.io';

$url = $this->agent->is_mobile()
? img_url($videos[$randWatches]).'.png'
: vid_url($videos[$randWatches]).'.mp4';

return array('title'=>$title, 'video_url'=>$url);
}

function logout() {

$this->user->logout();
redirect(base_url());
return redirect(base_url());
}

function resetPassword($resetToken = '') {
Expand All @@ -92,14 +73,12 @@ function resetPassword($resetToken = '') {
$this->load->view('footer');
}

function signupEmail() {
$this->_bodyData['resetToken'] = 'a4f9g53F47gF';
$this->load->view('email/reset-password', $this->_bodyData);
}

function about() {
$this->_headerData['headerClass'] = 'blue';
$this->_headerData['title'] = 'About Toolwatch';
$this->_headerData['meta_description'] = 'Toolwatch is where
watch aficionados measure the accuracy and precision of their watch.
More than 5000 people use Toolwatch to take care of their watch.';
$this->load->view('header', $this->_headerData);
$this->load->view('about');
$this->load->view('footer');
Expand All @@ -108,8 +87,12 @@ function about() {
function contact() {
$this->_headerData['headerClass'] = 'blue';
$this->_headerData['title'] = 'Contact';
$this->_headerData['meta_description'] = 'Contact the Toolwatch
Team. We are here to answer questions about watch accuracy,
precision, maintenance for watches and lots of other
interesting topics.';
$this->load->view('header', $this->_headerData);
$this->load->view('contact');
$this->load->view('footer');
}
}
}
22 changes: 17 additions & 5 deletions application/controllers/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,24 @@ public function email($key, $time = 0){
if ($key === "bPiAi9XNEa3p9FF1lQnZfuUY") {

$this->load->library("auto_email");
$this->auto_email->cronCheck(60*60*$time);
}
}

public function reset_email($key){

//FIXME: The token has to be env value
if ($key === "bPiAi9XNEa3p9FF1lQnZfuUY") {

$emailBatch = new MY_MODEL("email_batch");
$emailBatch->truncate();
$emailBatch->insert(array("time"=>time(), "amount"=>0));


$date = new DateTime("@".time());

echo "<h1> Reset success. New last batch at " . $date->format('Y-m-d H:i:s') . "</h1>";

if($time == 0){
$this->auto_email->cronCheck(time());
}else{
$this->auto_email->cronCheck(time()+60*60*$time);
}
}
}
}
17 changes: 4 additions & 13 deletions application/controllers/Measures.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct() {
parent::__construct();
$this->load->model('watch');
$this->load->model('measure');
$this->load->library('auto_email');
}

/**
Expand Down Expand Up @@ -78,8 +79,6 @@ public function add_watch(){

$this->_bodyData['success'] = 'Watch successfully added!';

} else {
$this->_bodyData['error'] = 'An error occured while adding your watch.';
}

$this->constructMeasurePage();
Expand All @@ -101,9 +100,7 @@ public function delete_watch(){

if ($this->watch->deleteWatch($this->watchId)) {
$this->_bodyData['success'] = 'Watch successfully deleted!';
} else {
$this->_bodyData['error'] = 'An error occured while deleting your watch.';
}
}

$this->constructMeasurePage();
}
Expand All @@ -124,8 +121,6 @@ public function delete_measure(){

if ($this->measure->deleteMesure($this->measureId)) {
$this->_bodyData['success'] = 'Measures successfully deleted!';
} else {
$this->_bodyData['error'] = 'An error occured while deleting your measures.';
}

$this->constructMeasurePage();
Expand Down Expand Up @@ -186,8 +181,6 @@ public function edit_watch(){

$this->_bodyData['success'] = 'Watch successfully updated!';

} else {
$this->_bodyData['error'] = 'An error occured while updating your watch.';
}

$this->constructMeasurePage();
Expand Down Expand Up @@ -283,8 +276,6 @@ function baseMeasure() {

$result['success'] = true;

} else {
$result['success'] = false;
}

echo json_encode($result);
Expand Down Expand Up @@ -321,11 +312,11 @@ function accuracyMeasure() {
//We store the computed accuracy & percentile
$result['accuracy'] = $watchMeasure->accuracy;
$result['percentile'] = $watchMeasure->percentile;
} else {
$result['success'] = false;

}

echo json_encode($result);

}
}
}
14 changes: 1 addition & 13 deletions application/controllers/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
class Modal extends MY_Controller
{

private function ctaClick(){
if($this->input->post('cta') != ""){
$cta = 'CTA_' . strtoupper ( $this->input->post('cta') );

if(property_exists($this->event, $cta)){
$this->event->add($this->event->{$cta});
}
}
}

public function accuracyWarning(){
if($this->input->post('ajax'))
{
Expand All @@ -29,7 +19,6 @@ public function login()
{
if($this->input->post('ajax'))
{
$this->ctaClick();
$this->event->add(LOGIN_POPUP);
$this->load->view('modal/login');
}
Expand All @@ -43,9 +32,8 @@ public function signUp()
{
if($this->input->post('ajax'))
{
$this->ctaClick();
$this->event->add(SIGN_UP_POPUP);
$this->load->view('modal/sign-up');
$this->load->view('modal/sign-up');
}
else
{
Expand Down
Loading

0 comments on commit 5c19d8c

Please sign in to comment.