Completed
Push — master ( 3a6730...bad5d9 )
by Angus
03:21
created
application/models/Auth_Model.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 
73 73
 	/**
74 74
 	 * @param string $verificationCode
75
-	 * @return mixed
75
+	 * @return string
76 76
 	 */
77 77
 	public function verification_check(string $verificationCode) {
78 78
 		//user is trying to validate their email for signup, check if verification code is still valid/exists
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,9 +77,9 @@
 block discarded – undo
77 77
 	public function verification_check(string $verificationCode) {
78 78
 		//user is trying to validate their email for signup, check if verification code is still valid/exists
79 79
 		$query = $this->db->select('email, verification_code_time')
80
-		                  ->from('auth_signup_verification')
81
-		                  ->where(array('verification_code' => $verificationCode))
82
-		                  ->get();
80
+						  ->from('auth_signup_verification')
81
+						  ->where(array('verification_code' => $verificationCode))
82
+						  ->get();
83 83
 
84 84
 		$return = FALSE;
85 85
 		if($query->num_rows() > 0) {
Please login to merge, or discard this patch.
application/models/Tracker_Model.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -88,6 +88,9 @@
 block discarded – undo
88 88
 		return $arr;
89 89
 	}
90 90
 
91
+	/**
92
+	 * @return string
93
+	 */
91 94
 	public function getSiteDataFromURL(string $site_url) {
92 95
 		$query = $this->db->select('id, site_class')
93 96
 		                  ->from('tracker_sites')
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
 	public function getSiteDataFromURL(string $site_url) {
92 92
 		$query = $this->db->select('id, site_class')
93
-		                  ->from('tracker_sites')
94
-		                  ->where('site', $site_url)
95
-		                  ->get();
93
+						  ->from('tracker_sites')
94
+						  ->where('site', $site_url)
95
+						  ->get();
96 96
 
97 97
 		if($query->num_rows() > 0) {
98 98
 			$siteData = $query->row();
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 
104 104
 	public function getTitleID(string $titleURL, int $siteID) {
105 105
 		$query = $this->db->select('id')
106
-		                  ->from('tracker_titles')
107
-		                  ->where('title_url', $titleURL)
108
-		                  ->where('site_id', $siteID)
109
-		                  ->get();
106
+						  ->from('tracker_titles')
107
+						  ->where('title_url', $titleURL)
108
+						  ->where('site_id', $siteID)
109
+						  ->get();
110 110
 
111 111
 		if($query->num_rows() > 0) {
112 112
 			$titleID = $query->row('id');
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 			}
141 141
 			if($this->db->select('*')->where('user_id', $userID)->where('title_id', $titleID)->get('tracker_chapters')->num_rows() > 0) {
142 142
 				$success = $this->db->set(['current_chapter' => $chapter, 'last_updated' => NULL])
143
-				                    ->where('user_id', $userID)
144
-				                    ->where('title_id', $titleID)
145
-				                    ->update('tracker_chapters');
143
+									->where('user_id', $userID)
144
+									->where('title_id', $titleID)
145
+									->update('tracker_chapters');
146 146
 			} else {
147 147
 				$success = $this->db->insert('tracker_chapters', [
148 148
 					'user_id'         => $userID,
@@ -157,31 +157,31 @@  discard block
 block discarded – undo
157 157
 
158 158
 	public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool {
159 159
 		$success = $this->db->set(['current_chapter' => $chapter, 'last_updated' => NULL])
160
-		                    ->where('user_id', $userID)
161
-		                    ->where('id', $chapterID)
162
-		                    ->update('tracker_chapters');
160
+							->where('user_id', $userID)
161
+							->where('id', $chapterID)
162
+							->update('tracker_chapters');
163 163
 
164 164
 		return (bool) $success;
165 165
 	}
166 166
 
167 167
 	public function deleteTrackerByID(int $userID, int $chapterID) {
168 168
 		$success = $this->db->where('user_id', $userID)
169
-		                    ->where('id', $chapterID)
170
-		                    ->delete('tracker_chapters');
169
+							->where('id', $chapterID)
170
+							->delete('tracker_chapters');
171 171
 
172 172
 		return (bool) $success;
173 173
 	}
174 174
 	private function updateTitleById(int $id, string $latestChapter) {
175 175
 		//FIXME: Really not too happy with how we're doing history stuff here, it just feels messy.
176 176
 		$query = $this->db->select('latest_chapter, last_updated')
177
-		                  ->from('tracker_titles')
178
-		                  ->where('id', $id)
179
-		                  ->get();
177
+						  ->from('tracker_titles')
178
+						  ->where('id', $id)
179
+						  ->get();
180 180
 		$row = $query->row();
181 181
 
182 182
 		$success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes
183
-		                    ->where('id', $id)
184
-		                    ->update('tracker_titles');
183
+							->where('id', $id)
184
+							->update('tracker_titles');
185 185
 
186 186
 		//Update History
187 187
 		$this->History->updateTitleHistory($id, $row->latest_chapter, $row->last_updated);
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 	private function updateTitleDataById(int $id, array $titleData) {
192 192
 		$success = $this->db->set($titleData)
193
-		                    ->where('id', $id)
194
-		                    ->update('tracker_titles');
193
+							->where('id', $id)
194
+							->update('tracker_titles');
195 195
 
196 196
 		return (bool) $success;
197 197
 	}
198 198
 	private function addTitle(string $titleURL, int $siteID) {
199 199
 		$query = $this->db->select('site, site_class')
200
-		                  ->from('tracker_sites')
201
-		                  ->where('id', $siteID)
202
-		                  ->get();
200
+						  ->from('tracker_sites')
201
+						  ->where('id', $siteID)
202
+						  ->get();
203 203
 
204 204
 		$titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL);
205 205
 		$this->db->insert('tracker_titles', array_merge($titleData, ['title_url' => $titleURL, 'site_id' => $siteID]));
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 		                      tracker_titles.last_updated,
225 225
 		                      from_unixtime(MAX(auth_users.last_login)) AS timestamp
226 226
 		                  ')
227
-		                  ->from('tracker_titles')
228
-		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
-		                  ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
230
-		                  ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
231
-		                  ->where('tracker_sites.status = "enabled"')
232
-		                  ->where('(`complete` = "N" AND (`latest_chapter` = NULL OR `last_checked` < DATE_SUB(NOW(), INTERVAL 12 HOUR)))', NULL, FALSE) //TODO: Each title should have specific interval time?
233
-		                  ->or_where('(`complete` = "Y" AND `last_checked` < DATE_SUB(NOW(), INTERVAL 1 WEEK))', NULL, FALSE)
234
-		                  ->group_by('tracker_titles.id')
235
-		                  ->having('timestamp IS NOT NULL')
236
-		                  ->having('timestamp > DATE_SUB(NOW(), INTERVAL 120 HOUR)')
237
-		                  ->order_by('tracker_titles.title', 'ASC')
238
-		                  ->get();
227
+						  ->from('tracker_titles')
228
+						  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
229
+						  ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left')
230
+						  ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left')
231
+						  ->where('tracker_sites.status = "enabled"')
232
+						  ->where('(`complete` = "N" AND (`latest_chapter` = NULL OR `last_checked` < DATE_SUB(NOW(), INTERVAL 12 HOUR)))', NULL, FALSE) //TODO: Each title should have specific interval time?
233
+						  ->or_where('(`complete` = "Y" AND `last_checked` < DATE_SUB(NOW(), INTERVAL 1 WEEK))', NULL, FALSE)
234
+						  ->group_by('tracker_titles.id')
235
+						  ->having('timestamp IS NOT NULL')
236
+						  ->having('timestamp > DATE_SUB(NOW(), INTERVAL 120 HOUR)')
237
+						  ->order_by('tracker_titles.title', 'ASC')
238
+						  ->get();
239 239
 
240 240
 		if($query->num_rows() > 0) {
241 241
 			foreach ($query->result() as $row) {
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 						//Make sure last_checked is always updated on successful run.
249 249
 						//CHECK: Is there a reason we aren't just doing this in updateTitleById?
250 250
 						$this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE)
251
-						         ->where('id', $row->id)
252
-						         ->update('tracker_titles');
251
+								 ->where('id', $row->id)
252
+								 ->update('tracker_titles');
253 253
 
254 254
 						//Update History
255 255
 						$this->History->updateTitleHistory((int) $row->id, $titleData['latest_chapter'], $titleData['last_updated']);
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	}
363 363
 	public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool {
364 364
 		$success = $this->db->set(['category' => $category, 'last_updated' => NULL])
365
-		                    ->where('user_id', $userID)
366
-		                    ->where('id', $chapterID)
367
-		                    ->update('tracker_chapters');
365
+							->where('user_id', $userID)
366
+							->where('id', $chapterID)
367
+							->update('tracker_chapters');
368 368
 
369 369
 		return (bool) $success;
370 370
 	}
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 		$success = FALSE;
375 375
 		if(preg_match("/^[a-z0-9-_,]{0,255}$/", $tag_string)) {
376 376
 			$success = $this->db->set(['tags' => $tag_string, 'last_updated' => NULL])
377
-			                    ->where('user_id', $userID)
378
-			                    ->where('id', $chapterID)
379
-			                    ->update('tracker_chapters');
377
+								->where('user_id', $userID)
378
+								->where('id', $chapterID)
379
+								->update('tracker_chapters');
380 380
 		}
381 381
 
382 382
 		return (bool) $success;
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 		$usedCategories = [];
387 387
 
388 388
 		$query = $this->db->distinct()
389
-		                  ->select('category')
390
-		                  ->from('tracker_chapters')
391
-		                  ->get();
389
+						  ->select('category')
390
+						  ->from('tracker_chapters')
391
+						  ->get();
392 392
 
393 393
 		return array_column($query->result_array(), 'category');
394 394
 	}
Please login to merge, or discard this patch.
application/models/User_Options_Model.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Get user option, or default option if it does not exist.
75 75
 	 * @param string $option
76
-	 * @return mixed Returns option value as STRING, or FALSE if option does not exist.
76
+	 * @return string Returns option value as STRING, or FALSE if option does not exist.
77 77
 	 */
78 78
 	public function get(string $option) {
79 79
 		return $this->get_by_userid($option, (int) $this->User->id);
@@ -135,6 +135,9 @@  discard block
 block discarded – undo
135 135
 		return $success;
136 136
 	}
137 137
 
138
+	/**
139
+	 * @return string
140
+	 */
138 141
 	private function get_db(string $option, int $userID) {
139 142
 		//This function assumes we've already done some basic validation.
140 143
 		$query = $this->db->select('value_str, value_int')
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -138,10 +138,10 @@
 block discarded – undo
138 138
 	private function get_db(string $option, int $userID) {
139 139
 		//This function assumes we've already done some basic validation.
140 140
 		$query = $this->db->select('value_str, value_int')
141
-		                  ->from('user_options')
142
-		                  ->where('user_id', $userID)
143
-		                  ->where('name',    $option)
144
-		                  ->limit(1);
141
+						  ->from('user_options')
142
+						  ->where('user_id', $userID)
143
+						  ->where('name',    $option)
144
+						  ->limit(1);
145 145
 		return $query->get()->row_array();
146 146
 	}
147 147
 	private function set_db(string $option, $value) : bool {}
Please login to merge, or discard this patch.
application/tests/libraries/MY_Form_validation_test.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -144,6 +144,10 @@
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	//utility functions
147
+
148
+	/**
149
+	 * @param string $field
150
+	 */
147 151
 	function get_error_message(/*str*/$field, /*obj*/ $customObj = FALSE) {
148 152
 		$obj = $customObj ?: $this->form_validation;
149 153
 		$error_messages = ReflectionHelper::getPrivateProperty(
Please login to merge, or discard this patch.
public/index.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -210,10 +210,10 @@
 block discarded – undo
210 210
 {
211 211
 	// Ensure there's a trailing slash
212 212
 	$system_path = strtr(
213
-		               rtrim($system_path, '/\\'),
214
-		               '/\\',
215
-		               DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
216
-	               ).DIRECTORY_SEPARATOR;
213
+					   rtrim($system_path, '/\\'),
214
+					   '/\\',
215
+					   DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
216
+				   ).DIRECTORY_SEPARATOR;
217 217
 }
218 218
 
219 219
 // Is the system path correct?
Please login to merge, or discard this patch.
application/tests/TestCase.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@  discard block
 block discarded – undo
29 29
 
30 30
 	public function getMock_ion_auth_logged_in() {
31 31
 		$ion_auth = $this->getMockBuilder('Ion_auth')
32
-		                 ->disableOriginalConstructor()
33
-		                 ->getMock();
32
+						 ->disableOriginalConstructor()
33
+						 ->getMock();
34 34
 
35 35
 		$ion_auth->expects($this->at(0))
36
-		         ->method('logged_in')
37
-		         ->willReturn(TRUE);
36
+				 ->method('logged_in')
37
+				 ->willReturn(TRUE);
38 38
 		$ion_auth->expects($this->at(1))
39
-		         ->method('logged_in')
40
-		         ->willReturn(TRUE);
39
+				 ->method('logged_in')
40
+				 ->willReturn(TRUE);
41 41
 
42 42
 		$ion_auth->expects($this->any())
43
-		         ->method($this->anything())
44
-		         ->will($this->returnSelf());
43
+				 ->method($this->anything())
44
+				 ->will($this->returnSelf());
45 45
 		
46 46
 		return $ion_auth;
47 47
 	}
48 48
 
49 49
 	public function getMock_CI_DB_result(array $methods) {
50 50
 		$db_result = $this->getMockBuilder('CI_DB_result')
51
-		                  ->disableOriginalConstructor()
52
-		                  ->getMock();
51
+						  ->disableOriginalConstructor()
52
+						  ->getMock();
53 53
 
54 54
 		foreach ($methods as $method => $return) {
55 55
 			$db_result->method($method)->willReturn($return);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
 	public function getMock_CI_DB($return) {
61 61
 		$db = $this->getMockBuilder('CI_DB')
62
-		           ->disableOriginalConstructor()
63
-		           ->setMethods(array('select', 'from', 'where', 'get'))
64
-		           ->getMock();
62
+				   ->disableOriginalConstructor()
63
+				   ->setMethods(array('select', 'from', 'where', 'get'))
64
+				   ->getMock();
65 65
 
66 66
 		$db->expects($this->at(3))
67 67
 		   ->method('get')
Please login to merge, or discard this patch.
application/tests/models/User_Model_test.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 		$User_Model = $this->User_Model;
31 31
 
32 32
 		$ion_auth = $this->getMockBuilder('ion_auth')
33
-		                 ->disableOriginalConstructor()
34
-		                 ->getMock();
33
+						 ->disableOriginalConstructor()
34
+						 ->getMock();
35 35
 		$ion_auth->method('logged_in')->willReturn(FALSE);
36 36
 
37 37
 		$User_Model->ion_auth = $ion_auth;
Please login to merge, or discard this patch.
application/models/Site_Model.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@
 block discarded – undo
228 228
 		//Bato.to is annoying and locks stuff behind auth. See: https://github.com/DakuTree/manga-tracker/issues/14#issuecomment-233830855
229 229
 		$cookies = [
230 230
 			"lang_option={$title_lang}",
231
-		    "member_id=" . $this->config->item('batoto_cookie_member_id'),
232
-		    "pass_hash=" . $this->config->item('batoto_cookie_pass_hash')
231
+			"member_id=" . $this->config->item('batoto_cookie_member_id'),
232
+			"pass_hash=" . $this->config->item('batoto_cookie_pass_hash')
233 233
 		];
234 234
 		$data = $this->get_content($title_url, implode("; ", $cookies));
235 235
 		if(!$data) {
Please login to merge, or discard this patch.
application/models/User_Model.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		$this->load->database();
41 41
 
42 42
 		$query = $this->db->select('*')
43
-		                  ->from('auth_users')
44
-		                  ->where('username', $username)
45
-		                  ->get();
43
+						  ->from('auth_users')
44
+						  ->where('username', $username)
45
+						  ->get();
46 46
 
47 47
 		return (bool) $query->num_rows();
48 48
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 			$this->load->database();
65 65
 
66 66
 			$query = $this->db->select('email')
67
-			                  ->from('auth_users')
68
-			                  ->where('username', $identity)
69
-			                  ->get();
67
+							  ->from('auth_users')
68
+							  ->where('username', $identity)
69
+							  ->get();
70 70
 
71 71
 			if($query->num_rows() > 0) {
72 72
 				//username exists, grab email
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		$user = NULL;
85 85
 
86 86
 		$query = $this->db->select('*')
87
-		                  ->from('auth_users')
88
-		                  ->where('username', $username)
89
-		                  ->get();
87
+						  ->from('auth_users')
88
+						  ->where('username', $username)
89
+						  ->get();
90 90
 
91 91
 		if($query->num_rows() > 0) {
92 92
 			$user = $query->row();
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 	
115 115
 	public function get_id_from_api_key(string $api_key) {
116 116
 		$query = $this->db->select('id')
117
-		                  ->from('auth_users')
118
-		                  ->where('api_key', $api_key)
119
-		                  ->get();
117
+						  ->from('auth_users')
118
+						  ->where('api_key', $api_key)
119
+						  ->get();
120 120
 
121 121
 		if($query->num_rows() > 0) {
122 122
 			$userID = $query->row('id');
Please login to merge, or discard this patch.