Completed
Push — master ( 7338a5...b104f9 )
by Angus
03:05
created
application/models/Tracker/Tracker_Favourites_Model.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,32 +71,32 @@
 block discarded – undo
71 71
 
72 72
 			////We need the series to be tracked
73 73
 			$idCQuery = $this->db->select('id')
74
-			                     ->where('user_id', $userID)
75
-			                     ->where('title_id', $titleID)
76
-			                     ->get('tracker_chapters');
74
+								 ->where('user_id', $userID)
75
+								 ->where('title_id', $titleID)
76
+								 ->get('tracker_chapters');
77 77
 			if(!($idCQuery->num_rows() > 0)) {
78 78
 				//NOTE: This pretty much repeats a lot of what we already did above. Is there a better way to do this?
79 79
 				$this->Tracker->list->update($userID, $site, $title, $chapter, FALSE);
80 80
 
81 81
 				$idCQuery = $this->db->select('id')
82
-				                     ->where('user_id', $userID)
83
-				                     ->where('title_id', $titleID)
84
-				                     ->get('tracker_chapters');
82
+									 ->where('user_id', $userID)
83
+									 ->where('title_id', $titleID)
84
+									 ->get('tracker_chapters');
85 85
 			}
86 86
 			if($idCQuery->num_rows() > 0) {
87 87
 				$idCQueryRow = $idCQuery->row();
88 88
 
89 89
 				//Check if it is already favourited
90 90
 				$idFQuery = $this->db->select('id')
91
-				                     ->where('chapter_id', $idCQueryRow->id)
92
-				                     ->where('chapter', $chapter)
93
-				                     ->get('tracker_favourites');
91
+									 ->where('chapter_id', $idCQueryRow->id)
92
+									 ->where('chapter', $chapter)
93
+									 ->get('tracker_favourites');
94 94
 				if($idFQuery->num_rows() > 0) {
95 95
 					//Chapter is already favourited, so remove it from DB
96 96
 					$idFQueryRow = $idFQuery->row();
97 97
 
98 98
 					$isSuccess = (bool) $this->db->where('id', $idFQueryRow->id)
99
-					                             ->delete('tracker_favourites');
99
+												 ->delete('tracker_favourites');
100 100
 
101 101
 					if($isSuccess) {
102 102
 						$success = array(
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_List_Model.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 			}
204 204
 
205 205
 			$idQuery = $this->db->select('id')
206
-			                    ->where('user_id', $userID)
207
-			                    ->where('title_id', $titleID)
208
-			                    ->get('tracker_chapters');
206
+								->where('user_id', $userID)
207
+								->where('title_id', $titleID)
208
+								->get('tracker_chapters');
209 209
 			if($idQuery->num_rows() > 0) {
210 210
 				$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL, 'ignore_chapter' => NULL])
211
-				                           ->where('user_id', $userID)
212
-				                           ->where('title_id', $titleID)
213
-				                           ->update('tracker_chapters');
211
+										   ->where('user_id', $userID)
212
+										   ->where('title_id', $titleID)
213
+										   ->update('tracker_chapters');
214 214
 
215 215
 				if($success) {
216 216
 					$idQueryRow = $idQuery->row();
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 	public function updateByID(int $userID, int $chapterID, string $chapter) : bool {
238 238
 		$success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
239
-		                           ->where('user_id', $userID)
240
-		                           ->where('id', $chapterID)
241
-		                           ->update('tracker_chapters');
239
+								   ->where('user_id', $userID)
240
+								   ->where('id', $chapterID)
241
+								   ->update('tracker_chapters');
242 242
 
243 243
 		if($success) {
244 244
 			$this->History->userUpdateTitle($chapterID, $chapter);
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 
249 249
 	public function ignoreByID(int $userID, int $chapterID, string $chapter) : bool {
250 250
 		$success = (bool) $this->db->set(['ignore_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL])
251
-		                           ->where('user_id', $userID)
252
-		                           ->where('id', $chapterID)
253
-		                           ->update('tracker_chapters');
251
+								   ->where('user_id', $userID)
252
+								   ->where('id', $chapterID)
253
+								   ->update('tracker_chapters');
254 254
 
255 255
 		if($success) {
256 256
 			$this->History->userIgnoreTitle($chapterID, $chapter);
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 		//This is to allow user history to function properly.
264 264
 
265 265
 		$success = $this->db->set(['active' => 'N', 'last_updated' => NULL])
266
-		                    ->where('user_id', $userID)
267
-		                    ->where('id', $chapterID)
268
-		                    ->update('tracker_chapters');
266
+							->where('user_id', $userID)
267
+							->where('id', $chapterID)
268
+							->update('tracker_chapters');
269 269
 
270 270
 		return (bool) $success;
271 271
 	}
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 		//TODO: OPTION, USE BACKEND MAL ID DB WHERE POSSIBLE (DEFAULT TRUE)
296 296
 
297 297
 		$queryC = $this->db->select('mal_id')
298
-		                   ->where('user_id', $userID)
299
-		                   ->where('title_id', $titleID)
300
-		                   ->where('mal_id IS NOT NULL', NULL, FALSE)
301
-		                   ->get('tracker_chapters');
298
+						   ->where('user_id', $userID)
299
+						   ->where('title_id', $titleID)
300
+						   ->where('mal_id IS NOT NULL', NULL, FALSE)
301
+						   ->get('tracker_chapters');
302 302
 
303 303
 		if($queryC->num_rows() > 0 && ($rowC = $queryC->row())) {
304 304
 			$malIDArr = [
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			];
308 308
 		} else {
309 309
 			$queryT = $this->db->select('mal_id')
310
-			                   ->where('id', $titleID)
311
-			                   ->get('tracker_titles');
310
+							   ->where('id', $titleID)
311
+							   ->get('tracker_titles');
312 312
 
313 313
 			if($queryT->num_rows() > 0 && ($rowT = $queryT->row())) {
314 314
 				$malIDArr = [
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 	public function setMalID(int $userID, int $chapterID, ?int $malID) : bool {
342 342
 		//TODO: Handle NULL?
343 343
 		$success = (bool) $this->db->set(['mal_id' => $malID, 'active' => 'Y', 'last_updated' => NULL])
344
-		                           ->where('user_id', $userID)
345
-		                           ->where('id', $chapterID)
346
-		                           ->update('tracker_chapters');
344
+								   ->where('user_id', $userID)
345
+								   ->where('id', $chapterID)
346
+								   ->update('tracker_chapters');
347 347
 
348 348
 		if($success) {
349 349
 			//MAL id update was successful, update history
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Title_Model.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) {
17 17
 		$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)
18
-		                  ->from('tracker_titles')
19
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
20
-		                  ->where('tracker_titles.title_url', $titleURL)
21
-		                  ->where('tracker_titles.site_id', $siteID)
22
-		                  ->get();
18
+						  ->from('tracker_titles')
19
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
20
+						  ->where('tracker_titles.title_url', $titleURL)
21
+						  ->where('tracker_titles.site_id', $siteID)
22
+						  ->get();
23 23
 
24 24
 		if($query->num_rows() > 0) {
25 25
 			$id = (int) $query->row('id');
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 						//Make sure last_checked is always updated on successful run.
33 33
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
34 34
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
35
-						         ->where('id', $id)
36
-						         ->update('tracker_titles');
35
+								 ->where('id', $id)
36
+								 ->update('tracker_titles');
37 37
 					}
38 38
 				} else {
39 39
 					log_message('error', "{$query->row('title')} failed to update successfully");
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	private function addTitle(string $titleURL, int $siteID) : int {
75 75
 		$query = $this->db->select('site, site_class')
76
-		                  ->from('tracker_sites')
77
-		                  ->where('id', $siteID)
78
-		                  ->get();
76
+						  ->from('tracker_sites')
77
+						  ->where('id', $siteID)
78
+						  ->get();
79 79
 
80 80
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE);
81 81
 
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 	public function updateByID(int $titleID, string $latestChapter) : bool {
102 102
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
103 103
 		$query = $this->db->select('latest_chapter AS current_chapter')
104
-		                  ->from('tracker_titles')
105
-		                  ->where('id', $titleID)
106
-		                  ->get();
104
+						  ->from('tracker_titles')
105
+						  ->where('id', $titleID)
106
+						  ->get();
107 107
 		$row = $query->row();
108 108
 
109 109
 		//TODO (CHECK): If failed_checks changes won't that trigger affected_rows?
110 110
 		$success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes
111
-		                    ->where('id', $titleID)
112
-		                    ->update('tracker_titles');
111
+							->where('id', $titleID)
112
+							->update('tracker_titles');
113 113
 
114 114
 		if($this->db->affected_rows() > 0) {
115 115
 			//Clear hidden latest chapter
116 116
 			$this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE)
117
-			         ->where('title_id', $titleID)
118
-			         ->update('tracker_chapters');
117
+					 ->where('title_id', $titleID)
118
+					 ->update('tracker_chapters');
119 119
 		}
120 120
 
121 121
 		//Update History
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function updateFailedChecksByID(int $titleID) : bool {
130 130
 		$success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE)
131
-		                    ->where('id', $titleID)
132
-		                    ->update('tracker_titles');
131
+							->where('id', $titleID)
132
+							->update('tracker_titles');
133 133
 
134 134
 		return $success;
135 135
 	}
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function getSiteDataFromURL(string $site_url) {
143 143
 		$query = $this->db->select('*')
144
-		                  ->from('tracker_sites')
145
-		                  ->where('site', $site_url)
146
-		                  ->get();
144
+						  ->from('tracker_sites')
145
+						  ->where('site', $site_url)
146
+						  ->get();
147 147
 
148 148
 		return $query->row();
149 149
 	}
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Admin_Model.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 						//Make sure last_checked is always updated on successful run.
75 75
 						//CHECK: Is there a reason we aren't just doing this in updateByID?
76 76
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
77
-						         ->where('id', $row->title_id)
78
-						         ->update('tracker_titles');
77
+								 ->where('id', $row->title_id)
78
+								 ->update('tracker_titles');
79 79
 
80 80
 						print " - ({$titleData['latest_chapter']})\n";
81 81
 					} else {
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 						//Make sure last_checked is always updated on successful run.
153 153
 						//CHECK: Is there a reason we aren't just doing this in updateByID?
154 154
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
155
-						         ->where('id', $row->title_id)
156
-						         ->update('tracker_titles');
155
+								 ->where('id', $row->title_id)
156
+								 ->update('tracker_titles');
157 157
 
158 158
 						print " - ({$titleData['latest_chapter']})\n";
159 159
 					} else {
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function updateCustom() {
179 179
 		$query = $this->db->select('*')
180
-		                  ->from('tracker_sites')
181
-		                  ->where('status', 'enabled')
182
-		                  ->where('tracker_sites.use_custom', 'Y')
183
-		                  ->get();
180
+						  ->from('tracker_sites')
181
+						  ->where('status', 'enabled')
182
+						  ->where('tracker_sites.use_custom', 'Y')
183
+						  ->get();
184 184
 
185 185
 		$sites = $query->result_array();
186 186
 		foreach ($sites as $site) {
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 									//Make sure last_checked is always updated on successful run.
197 197
 									//CHECK: Is there a reason we aren't just doing this in updateByID?
198 198
 									$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
199
-									         ->where('id', $titleID)
200
-									         ->update('tracker_titles');
199
+											 ->where('id', $titleID)
200
+											 ->update('tracker_titles');
201 201
 
202 202
 									print " - ({$titleData['latest_chapter']})\n";
203 203
 								} else {
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 
225 225
 	public function refollowCustom() {
226 226
 		$query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class')
227
-		                  ->from('tracker_titles')
228
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
-		                  ->where('tracker_titles.followed','N')
230
-		                  ->where('tracker_titles !=', '255')
231
-		                  ->where('tracker_sites.status', 'enabled')
232
-		                  ->where('tracker_sites.use_custom', 'Y')
233
-		                  ->get();
227
+						  ->from('tracker_titles')
228
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
+						  ->where('tracker_titles.followed','N')
230
+						  ->where('tracker_titles !=', '255')
231
+						  ->where('tracker_sites.status', 'enabled')
232
+						  ->where('tracker_sites.use_custom', 'Y')
233
+						  ->get();
234 234
 
235 235
 		if($query->num_rows() > 0) {
236 236
 			foreach($query->result() as $row) {
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 
242 242
 					if(!empty($titleData)) {
243 243
 						$this->db->set($titleData)
244
-						         ->where('id', $row->id)
245
-						         ->update('tracker_titles');
244
+								 ->where('id', $row->id)
245
+								 ->update('tracker_titles');
246 246
 
247 247
 						print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n";
248 248
 					} else {
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 				if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) {
291 291
 					if($titleData['title'] !== $row->title) {
292 292
 						$this->db->set('title', $titleData['title'])
293
-						         ->where('id', $row->id)
294
-						         ->update('tracker_titles');
293
+								 ->where('id', $row->id)
294
+								 ->update('tracker_titles');
295 295
 						//TODO: Add to history somehow?
296 296
 						print " - NEW TITLE ({$titleData['title']})\n";
297 297
 					} else {
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 					//We might as well try to update as well.
302 302
 					if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) {
303 303
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
304
-						         ->where('id', $row->id)
305
-						         ->update('tracker_titles');
304
+								 ->where('id', $row->id)
305
+								 ->update('tracker_titles');
306 306
 					}
307 307
 				} else {
308 308
 					log_message('error', "{$row->title} failed to update title successfully");
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 		$date = $temp_now->format('Y-m-d');
319 319
 
320 320
 		$query = $this->db->select('1')
321
-		                  ->from('site_stats')
322
-		                  ->where('date', $date)
323
-		                  ->get();
321
+						  ->from('site_stats')
322
+						  ->where('date', $date)
323
+						  ->get();
324 324
 
325 325
 		if($query->num_rows() > 0) {
326 326
 			$this->db->set('total_requests', 'total_requests+1', FALSE)
327
-			         ->where('date', $date)
328
-			         ->update('site_stats');
327
+					 ->where('date', $date)
328
+					 ->update('site_stats');
329 329
 		} else {
330 330
 			$this->db->insert('site_stats', [
331 331
 				'date'           => $date,
Please login to merge, or discard this patch.
application/models/User_Model.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 		$this->load->database();
46 46
 
47 47
 		$query = $this->db->select('*')
48
-		                  ->from('auth_users')
49
-		                  ->where('username', $username)
50
-		                  ->get();
48
+						  ->from('auth_users')
49
+						  ->where('username', $username)
50
+						  ->get();
51 51
 
52 52
 		return (bool) $query->num_rows();
53 53
 	}
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 			$this->load->database();
70 70
 
71 71
 			$query = $this->db->select('email')
72
-			                  ->from('auth_users')
73
-			                  ->where('username', $identity)
74
-			                  ->get();
72
+							  ->from('auth_users')
73
+							  ->where('username', $identity)
74
+							  ->get();
75 75
 
76 76
 			if($query->num_rows() > 0) {
77 77
 				//username exists, grab email
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		$user = NULL;
90 90
 
91 91
 		$query = $this->db->select('*')
92
-		                  ->from('auth_users')
93
-		                  ->where('username', $username)
94
-		                  ->get();
92
+						  ->from('auth_users')
93
+						  ->where('username', $username)
94
+						  ->get();
95 95
 
96 96
 		if($query->num_rows() > 0) {
97 97
 			$user = $query->row();
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 		$api_key = NULL;
121 121
 		if($this->logged_in()) {
122 122
 			$this->db->select('api_key')
123
-			         ->where('id', $this->User->id)
124
-			         ->get('auth_users');
123
+					 ->where('id', $this->User->id)
124
+					 ->get('auth_users');
125 125
 
126 126
 			$query = $this->db->select('api_key')
127
-			                  ->where('id', $this->User->id)
128
-			                  ->get('auth_users');
127
+							  ->where('id', $this->User->id)
128
+							  ->get('auth_users');
129 129
 
130 130
 			if($query->num_rows() > 0) {
131 131
 				$api_key = $query->row('api_key');
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	
138 138
 	public function get_id_from_api_key(string $api_key) {
139 139
 		$query = $this->db->select('id')
140
-		                  ->from('auth_users')
141
-		                  ->where('api_key', $api_key)
142
-		                  ->get();
140
+						  ->from('auth_users')
141
+						  ->where('api_key', $api_key)
142
+						  ->get();
143 143
 
144 144
 		if($query->num_rows() > 0) {
145 145
 			$userID = $query->row('id');
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 	public function hideLatestNotice() {
203 203
 		$idQuery = $this->db->select('1')
204
-		                    ->where('user_id', $this->User->id)
205
-		                    ->get('tracker_user_notices');
204
+							->where('user_id', $this->User->id)
205
+							->get('tracker_user_notices');
206 206
 		if($idQuery->num_rows() > 0) {
207 207
 			$success = (bool) $this->db->set('hidden_notice_id', '(SELECT id FROM tracker_notices ORDER BY id DESC LIMIT 1)', FALSE)
208
-			                           ->where('user_id', $this->User->id)
209
-			                           ->update('tracker_user_notices');
208
+									   ->where('user_id', $this->User->id)
209
+									   ->update('tracker_user_notices');
210 210
 		} else {
211 211
 			$success = (bool) $this->db->insert('tracker_user_notices', [
212 212
 				'user_id'           => $this->User->id,
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Issue_Model.php 1 patch
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 issue 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.