@@ -137,7 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | $success = $this->set_db($idData, $valueData); |
140 | - if($success) $this->session->unset_tempdata("option_{$option}"); |
|
140 | + if($success) { |
|
141 | + $this->session->unset_tempdata("option_{$option}"); |
|
142 | + } |
|
141 | 143 | } else { |
142 | 144 | $success = FALSE; |
143 | 145 | } |
@@ -164,7 +166,9 @@ discard block |
||
164 | 166 | } |
165 | 167 | |
166 | 168 | //Overall fallback method. |
167 | - if(!isset($value)) $value = $this->options[$option]['default']; |
|
169 | + if(!isset($value)) { |
|
170 | + $value = $this->options[$option]['default']; |
|
171 | + } |
|
168 | 172 | } else { |
169 | 173 | $value = FALSE; |
170 | 174 | } |
@@ -215,7 +219,10 @@ discard block |
||
215 | 219 | //This should never happen. |
216 | 220 | break; |
217 | 221 | } |
218 | - if(!isset($value)) $value = FALSE; //FIXME: This won't play nice with BOOL type false? |
|
222 | + if(!isset($value)) { |
|
223 | + $value = FALSE; |
|
224 | + } |
|
225 | + //FIXME: This won't play nice with BOOL type false? |
|
219 | 226 | |
220 | 227 | return $value; |
221 | 228 | } |
@@ -114,7 +114,7 @@ |
||
114 | 114 | * @param string $option |
115 | 115 | * @param int|null $userID |
116 | 116 | * |
117 | - * @return mixed Returns option value as STRING, or FALSE if option does not exist. |
|
117 | + * @return string Returns option value as STRING, or FALSE if option does not exist. |
|
118 | 118 | */ |
119 | 119 | public function get(string $option, ?int $userID = NULL) { |
120 | 120 | $userID = (is_null($userID) ? (int) $this->User->id : $userID); |
@@ -188,18 +188,18 @@ |
||
188 | 188 | //FIXME: Query duplication. |
189 | 189 | if($this->User->id !== $userID) { |
190 | 190 | $query = $this->db->select('value_str, value_int') |
191 | - ->from('user_options') |
|
192 | - ->where('user_id', $userID) |
|
193 | - ->where('name', $option) |
|
194 | - ->limit(1); |
|
191 | + ->from('user_options') |
|
192 | + ->where('user_id', $userID) |
|
193 | + ->where('name', $option) |
|
194 | + ->limit(1); |
|
195 | 195 | $data = $query->get()->row_array(); |
196 | 196 | } else { |
197 | 197 | if(!($data = $this->session->tempdata("option_{$option}"))) { |
198 | 198 | $query = $this->db->select('value_str, value_int') |
199 | - ->from('user_options') |
|
200 | - ->where('user_id', $userID) |
|
201 | - ->where('name', $option) |
|
202 | - ->limit(1); |
|
199 | + ->from('user_options') |
|
200 | + ->where('user_id', $userID) |
|
201 | + ->where('name', $option) |
|
202 | + ->limit(1); |
|
203 | 203 | $data = $query->get()->row_array(); |
204 | 204 | $this->session->set_tempdata("option_{$option}", $data, 3600); |
205 | 205 | } |
@@ -1,4 +1,4 @@ discard block |
||
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 User_Options_Model extends CI_Model { |
4 | 4 | public $options = array( |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $query = $this->db->select('value_str, value_int') |
201 | 201 | ->from('user_options') |
202 | 202 | ->where('user_id', $userID) |
203 | - ->where('name', $option) |
|
203 | + ->where('name', $option) |
|
204 | 204 | ->limit(1); |
205 | 205 | $data = $query->get()->row_array(); |
206 | 206 | } else { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $query = $this->db->select('value_str, value_int') |
209 | 209 | ->from('user_options') |
210 | 210 | ->where('user_id', $userID) |
211 | - ->where('name', $option) |
|
211 | + ->where('name', $option) |
|
212 | 212 | ->limit(1); |
213 | 213 | $data = $query->get()->row_array(); |
214 | 214 | $this->session->set_tempdata("option_{$option}", $data, 3600); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ); |
262 | 262 | //FIXME: Get a better solution than str_replace for removing special characters |
263 | 263 | $elements = array(); |
264 | - foreach (array_values($this->options[$option]['valid_options']) as $valid_option) { |
|
264 | + foreach(array_values($this->options[$option]['valid_options']) as $valid_option) { |
|
265 | 265 | $elements[$option.'_'.str_replace(',', '_', $valid_option)] = array_merge($base_attributes, array( |
266 | 266 | 'value' => $valid_option |
267 | 267 | )); |
@@ -1,7 +1,7 @@ |
||
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 | } |
@@ -1,4 +1,4 @@ |
||
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 | 4 | foreach (glob(APPPATH.'models/Tracker/*.php') as $filename) { |
@@ -9,9 +9,9 @@ |
||
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) { |
@@ -1,4 +1,4 @@ |
||
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_Tag_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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_Tag_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -35,9 +35,13 @@ |
||
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 | } |
@@ -1,4 +1,4 @@ |
||
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_Title_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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_Title_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -122,7 +122,7 @@ |
||
122 | 122 | /** |
123 | 123 | * @param string $site_url |
124 | 124 | * |
125 | - * @return stdClass|object|null |
|
125 | + * @return string |
|
126 | 126 | */ |
127 | 127 | public function getSiteDataFromURL(string $site_url) { |
128 | 128 | $query = $this->db->select('*') |
@@ -15,11 +15,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | |
8 | 8 | public function setByID(int $userID, int $chapterID, string $category) : bool { |
9 | 9 | $success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL]) |
10 | - ->where('user_id', $userID) |
|
11 | - ->where('id', $chapterID) |
|
12 | - ->update('tracker_chapters'); |
|
10 | + ->where('user_id', $userID) |
|
11 | + ->where('id', $chapterID) |
|
12 | + ->update('tracker_chapters'); |
|
13 | 13 | |
14 | 14 | return (bool) $success; |
15 | 15 | } |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | |
41 | 41 | public function getUsed(int $userID) : array { |
42 | 42 | $query = $this->db->distinct() |
43 | - ->select('category') |
|
44 | - ->from('tracker_chapters') |
|
45 | - ->where('tracker_chapters.active', 'Y') |
|
46 | - ->where('user_id', $userID) |
|
47 | - ->get(); |
|
43 | + ->select('category') |
|
44 | + ->from('tracker_chapters') |
|
45 | + ->where('tracker_chapters.active', 'Y') |
|
46 | + ->where('user_id', $userID) |
|
47 | + ->get(); |
|
48 | 48 | |
49 | 49 | return array_column($query->result_array(), 'category'); |
50 | 50 | } |
@@ -1,4 +1,4 @@ |
||
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_Category_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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_Category_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | +defined('BASEPATH') or exit('No direct script access allowed'); |
|
3 | 3 | |
4 | 4 | echo "\nERROR: ", |
5 | 5 | $heading, |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | +defined('BASEPATH') or exit('No direct script access allowed'); |
|
3 | 3 | ?><!DOCTYPE html> |
4 | 4 | <html lang="en"> |
5 | 5 | <head> |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | +defined('BASEPATH') or exit('No direct script access allowed'); |
|
3 | 3 | ?><!DOCTYPE html> |
4 | 4 | <html lang="en"> |
5 | 5 | <head> |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | <div class="row"> |
21 | 21 | <div class="col-xs-12 col-md-12"> |
22 | - <?=form_submit($form_submit);?> |
|
22 | + <?=form_submit($form_submit); ?> |
|
23 | 23 | </div> |
24 | 24 | </div> |
25 | 25 | </form> |