Completed
Push — master ( 45893c...373238 )
by Angus
02:39
created
application/migrations/018_favourites_rework.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@
 block discarded – undo
49 49
 
50 50
 		//We need to add data from the old favourites table
51 51
 		$query = $this->db->select('tf.id AS id, tc.user_id As user_id, tc.title_id AS title_id, tf.chapter AS chapter, tf.updated_at AS updated_at')
52
-		                  ->from('tracker_favourites AS tf')
53
-		                  ->join('tracker_chapters AS tc', 'tf.chapter_id = tc.id', 'left')
54
-		                  ->order_by('tf.id ASC')
55
-		                  ->get();
52
+						  ->from('tracker_favourites AS tf')
53
+						  ->join('tracker_chapters AS tc', 'tf.chapter_id = tc.id', 'left')
54
+						  ->order_by('tf.id ASC')
55
+						  ->get();
56 56
 		if($data = $query->result_array()) {
57 57
 			$this->db->insert_batch('tracker_favourites_new', $data);
58 58
 		}
Please login to merge, or discard this patch.
application/models/Tracker_Model.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 include_once APPPATH.'models/Tracker/Tracker_Base_Model.php';
4
-foreach (glob(APPPATH.'models/Tracker/*.php') as $filename) {
4
+foreach(glob(APPPATH.'models/Tracker/*.php') as $filename) {
5 5
 	/** @noinspection PhpIncludeInspection */
6 6
 	include_once $filename;
7 7
 }
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Tag_Model.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 		$success = FALSE;
10 10
 		if(preg_match("/^[a-z0-9\\-_,:]{0,255}$/", $tag_string)) {
11 11
 			$success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL])
12
-			                           ->where('user_id', $userID)
13
-			                           ->where('id', $chapterID)
14
-			                           ->update('tracker_chapters');
12
+									   ->where('user_id', $userID)
13
+									   ->where('id', $chapterID)
14
+									   ->update('tracker_chapters');
15 15
 		}
16 16
 
17 17
 		if($success) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class History_Model extends CI_Model {
4 4
 	public function __construct() {
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Title_Model.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) {
9 9
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.latest_chapter, tracker_titles.status, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE)
10
-		                  ->from('tracker_titles')
11
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
12
-		                  ->where('tracker_titles.title_url', $titleURL)
13
-		                  ->where('tracker_titles.site_id', $siteID)
14
-		                  ->get();
10
+						  ->from('tracker_titles')
11
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
12
+						  ->where('tracker_titles.title_url', $titleURL)
13
+						  ->where('tracker_titles.site_id', $siteID)
14
+						  ->get();
15 15
 
16 16
 		if($query->num_rows() > 0) {
17 17
 			$id = (int) $query->row('id');
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 						//Make sure last_checked is always updated on successful run.
25 25
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
26 26
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
27
-						         ->where('id', $id)
28
-						         ->update('tracker_titles');
27
+								 ->where('id', $id)
28
+								 ->update('tracker_titles');
29 29
 					}
30 30
 				} else {
31 31
 					log_message('error', "{$query->row('title')} failed to update successfully");
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
 	private function addTitle(string $titleURL, int $siteID) {
54 54
 		$query = $this->db->select('site, site_class')
55
-		                  ->from('tracker_sites')
56
-		                  ->where('id', $siteID)
57
-		                  ->get();
55
+						  ->from('tracker_sites')
56
+						  ->where('id', $siteID)
57
+						  ->get();
58 58
 
59 59
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE);
60 60
 
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	public function updateByID(int $id, string $latestChapter) {
75 75
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
76 76
 		$query = $this->db->select('latest_chapter AS current_chapter')
77
-		                  ->from('tracker_titles')
78
-		                  ->where('id', $id)
79
-		                  ->get();
77
+						  ->from('tracker_titles')
78
+						  ->where('id', $id)
79
+						  ->get();
80 80
 		$row = $query->row();
81 81
 
82 82
 		$success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes
83
-		                    ->where('id', $id)
84
-		                    ->update('tracker_titles');
83
+							->where('id', $id)
84
+							->update('tracker_titles');
85 85
 
86 86
 		//Update History
87 87
 		//NOTE: To avoid doing another query to grab the last_updated time, we just use time() which <should> get the same thing.
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 
95 95
 	public function getSiteDataFromURL(string $site_url) {
96 96
 		$query = $this->db->select('id, site_class')
97
-		                  ->from('tracker_sites')
98
-		                  ->where('site', $site_url)
99
-		                  ->get();
97
+						  ->from('tracker_sites')
98
+						  ->where('site', $site_url)
99
+						  ->get();
100 100
 
101 101
 		if($query->num_rows() > 0) {
102 102
 			$siteData = $query->row();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class History_Model extends CI_Model {
4 4
 	public function __construct() {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,9 +35,13 @@
 block discarded – undo
35 35
 			$titleID = $id;
36 36
 		} else {
37 37
 			//TODO: Check if title is valid URL!
38
-			if($create) $titleID = $this->addTitle($titleURL, $siteID);
38
+			if($create) {
39
+				$titleID = $this->addTitle($titleURL, $siteID);
40
+			}
41
+		}
42
+		if(!isset($titleID) || !$titleID) {
43
+			$titleID = 0;
39 44
 		}
40
-		if(!isset($titleID) || !$titleID) $titleID = 0;
41 45
 
42 46
 		return ($returnData && $titleID !== 0 ? $query->row_array() : $titleID);
43 47
 	}
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Base_Model.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class History_Model extends CI_Model {
4 4
 	public function __construct() {
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Portation_Model.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 //http://english.stackexchange.com/a/141735
4 4
 class Tracker_Portation_Model extends Tracker_Base_Model {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 		$arr = [];
57 57
 		if($query->num_rows() > 0) {
58
-			foreach ($query->result() as $row) {
58
+			foreach($query->result() as $row) {
59 59
 				$arr[$row->category][] = [
60 60
 					'site'            => $row->site,
61 61
 					'title_url'       => $row->title_url,
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Admin_Model.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 						//Make sure last_checked is always updated on successful run.
63 63
 						//CHECK: Is there a reason we aren't just doing this in updateByID?
64 64
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
65
-						         ->where('id', $row->id)
66
-						         ->update('tracker_titles');
65
+								 ->where('id', $row->id)
66
+								 ->update('tracker_titles');
67 67
 
68 68
 						print " - ({$titleData['latest_chapter']})\n";
69 69
 					}
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 
78 78
 	public function updateCustom() {
79 79
 		$query = $this->db->select('*')
80
-		                  ->from('tracker_sites')
81
-		                  ->where('status', 'enabled')
82
-		                  ->get();
80
+						  ->from('tracker_sites')
81
+						  ->where('status', 'enabled')
82
+						  ->get();
83 83
 
84 84
 		$sites = $query->result_array();
85 85
 		foreach ($sites as $site) {
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 									//Make sure last_checked is always updated on successful run.
95 95
 									//CHECK: Is there a reason we aren't just doing this in updateByID?
96 96
 									$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
97
-									         ->where('id', $titleID)
98
-									         ->update('tracker_titles');
97
+											 ->where('id', $titleID)
98
+											 ->update('tracker_titles');
99 99
 
100 100
 									print " - ({$titleData['latest_chapter']})\n";
101 101
 								} else {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class Tracker_Admin_Model extends Tracker_Base_Model {
4 4
 	public function __construct() {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			->get();
53 53
 
54 54
 		if($query->num_rows() > 0) {
55
-			foreach ($query->result() as $row) {
55
+			foreach($query->result() as $row) {
56 56
 				print "> {$row->title} <{$row->site_class}>"; //Print this prior to doing anything so we can more easily find out if something went wrong
57 57
 				$titleData = $this->sites->{$row->site_class}->getTitleData($row->title_url);
58 58
 				if(is_array($titleData) && !is_null($titleData['latest_chapter'])) {
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		                  ->get();
83 83
 
84 84
 		$sites = $query->result_array();
85
-		foreach ($sites as $site) {
85
+		foreach($sites as $site) {
86 86
 			if($titleDataList = $this->sites->{$site['site_class']}->doCustomUpdate()) {
87
-				foreach ($titleDataList as $titleURL => $titleData) {
87
+				foreach($titleDataList as $titleURL => $titleData) {
88 88
 					print "> {$titleData['title']} <{$site['site_class']}>"; //Print this prior to doing anything so we can more easily find out if something went wrong
89 89
 					if(is_array($titleData) && !is_null($titleData['latest_chapter'])) {
90 90
 						if($dbTitleData = $this->Tracker->title->getID($titleURL, (int) $site['id'], FALSE, TRUE)) {
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Favourites_Model.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,23 +72,23 @@
 block discarded – undo
72 72
 
73 73
 			//We need the series to be tracked
74 74
 			$idCQuery = $this->db->select('id')
75
-			                     ->where('user_id', $this->User->id)
76
-			                     ->where('title_id', $titleID)
77
-			                     ->get('tracker_chapters');
75
+								 ->where('user_id', $this->User->id)
76
+								 ->where('title_id', $titleID)
77
+								 ->get('tracker_chapters');
78 78
 			if($idCQuery->num_rows() > 0) {
79 79
 				$idCQueryRow = $idCQuery->row();
80 80
 
81 81
 				//Check if it is already favourited
82 82
 				$idFQuery = $this->db->select('id')
83
-				                     ->where('chapter_id', $idCQueryRow->id)
84
-				                     ->where('chapter', $chapter)
85
-				                     ->get('tracker_favourites');
83
+									 ->where('chapter_id', $idCQueryRow->id)
84
+									 ->where('chapter', $chapter)
85
+									 ->get('tracker_favourites');
86 86
 				if($idFQuery->num_rows() > 0) {
87 87
 					//Chapter is already favourited, so remove it from DB
88 88
 					$idFQueryRow = $idFQuery->row();
89 89
 
90 90
 					$isSuccess = (bool) $this->db->where('id', $idFQueryRow->id)
91
-					                             ->delete('tracker_favourites');
91
+												 ->delete('tracker_favourites');
92 92
 
93 93
 					if($isSuccess) {
94 94
 						$success = array(
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class Tracker_Favourites_Model extends Tracker_Base_Model {
4 4
 	public function __construct() {
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 			          tf.chapter, tf.updated_at', FALSE)
15 15
 			->from('tracker_favourites AS tf')
16 16
 			->join('tracker_chapters AS tc', 'tf.chapter_id = tc.id', 'left')
17
-			->join('tracker_titles AS tt',   'tc.title_id = tt.id',   'left')
18
-			->join('tracker_sites AS ts',    'tt.site_id = ts.id',    'left')
17
+			->join('tracker_titles AS tt', 'tc.title_id = tt.id', 'left')
18
+			->join('tracker_sites AS ts', 'tt.site_id = ts.id', 'left')
19 19
 			->where('tc.user_id', $this->User->id) //CHECK: Is this inefficient? Would it be better to have a user_id column in tracker_favourites?
20 20
 			->order_by('tf.id DESC')
21 21
 			->limit($rowsPerPage, ($rowsPerPage * ($page - 1)))
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Bug_Model.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
 
12 12
 		//This is pretty barebones bug reporting, and honestly not a great way to do it, but it works for now (until the Github is public).
13 13
 		$body = "".
14
-		        (!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : "").
15
-		        "Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n".
16
-		        "<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000));
14
+				(!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : "").
15
+				"Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n".
16
+				"<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000));
17 17
 
18 18
 		$success = TRUE;
19 19
 		$this->email->from('[email protected]', $this->config->item('site_title', 'ion_auth'));
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class History_Model extends CI_Model {
4 4
 	public function __construct() {
Please login to merge, or discard this patch.