GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( f6fa23...df8a48 )
by Lonnie
06:13
created
application/mailers/UserMailer.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -2,85 +2,85 @@
 block discarded – undo
2 2
 
3 3
 class UserMailer extends \Myth\Mail\BaseMailer {
4 4
 
5
-    protected $from     = null;
6
-    protected $to       = null;
5
+	protected $from     = null;
6
+	protected $to       = null;
7 7
 
8
-    public function __construct()
9
-    {
10
-        $this->from = [ config_item('site.auth_email'), config_item('site.name') ];
11
-    }
8
+	public function __construct()
9
+	{
10
+		$this->from = [ config_item('site.auth_email'), config_item('site.name') ];
11
+	}
12 12
 
13
-    //--------------------------------------------------------------------
13
+	//--------------------------------------------------------------------
14 14
 
15
-    /**
16
-     * Sends the output from the cronjob to the admin.
17
-     *
18
-     * The params array contains:
19
-     *  - user_id
20
-     *  - email
21
-     *  - token
22
-     *
23
-     * @param $params
24
-     * @return bool
25
-     */
26
-    public function didRegister($params=null)
27
-    {
28
-        $data = [
29
-            'user_id'   => $params['user_id'],
30
-            'email'     => $params['email'],
31
-            'link'      => site_url( \Myth\Route::named('activate_user') ),
32
-            'token'     => $params['token'],
33
-            'site_name' => config_item('site.name'),
34
-            'site_link' => site_url()
35
-        ];
15
+	/**
16
+	 * Sends the output from the cronjob to the admin.
17
+	 *
18
+	 * The params array contains:
19
+	 *  - user_id
20
+	 *  - email
21
+	 *  - token
22
+	 *
23
+	 * @param $params
24
+	 * @return bool
25
+	 */
26
+	public function didRegister($params=null)
27
+	{
28
+		$data = [
29
+			'user_id'   => $params['user_id'],
30
+			'email'     => $params['email'],
31
+			'link'      => site_url( \Myth\Route::named('activate_user') ),
32
+			'token'     => $params['token'],
33
+			'site_name' => config_item('site.name'),
34
+			'site_link' => site_url()
35
+		];
36 36
 
37
-        // Send it immediately - don't queue.
38
-        return $this->send($params['email'], lang('auth.register_subject'), $data);
39
-    }
37
+		// Send it immediately - don't queue.
38
+		return $this->send($params['email'], lang('auth.register_subject'), $data);
39
+	}
40 40
 
41
-    //--------------------------------------------------------------------
41
+	//--------------------------------------------------------------------
42 42
 
43
-    /**
44
-     * Sends the Password Reset Instructions email.
45
-     *
46
-     * @param array  $user
47
-     * @param string $token
48
-     * @return bool
49
-     */
50
-    public function remindUser($user, $token)
51
-    {
52
-        $data = [
53
-            'email' => $user['email'],
54
-            'code'  => $token,
55
-            'link'  => site_url( \Myth\Route::named('reset_pass') ),
56
-            'site_name' => config_item('site.name'),
57
-            'site_link' => site_url()
58
-        ];
43
+	/**
44
+	 * Sends the Password Reset Instructions email.
45
+	 *
46
+	 * @param array  $user
47
+	 * @param string $token
48
+	 * @return bool
49
+	 */
50
+	public function remindUser($user, $token)
51
+	{
52
+		$data = [
53
+			'email' => $user['email'],
54
+			'code'  => $token,
55
+			'link'  => site_url( \Myth\Route::named('reset_pass') ),
56
+			'site_name' => config_item('site.name'),
57
+			'site_link' => site_url()
58
+		];
59 59
 
60
-        // Send it immediately - don't queue.
61
-        return $this->send($user['email'], lang('auth.remind_subject'), $data);
62
-    }
60
+		// Send it immediately - don't queue.
61
+		return $this->send($user['email'], lang('auth.remind_subject'), $data);
62
+	}
63 63
 
64
-    //--------------------------------------------------------------------
64
+	//--------------------------------------------------------------------
65 65
 
66
-    /**
67
-     * Sends the Password Reset Confirmation email.
68
-     *
69
-     * @param array  $user
70
-     * @return bool
71
-     */
72
-    public function resetPassword($user)
73
-    {
74
-        $data = [
75
-            'email' => $user['email'],
76
-            'link'  => site_url( \Myth\Route::named('forgot_pass') ),
77
-            'site_name' => config_item('site.name'),
78
-            'site_link' => site_url()
79
-        ];
66
+	/**
67
+	 * Sends the Password Reset Confirmation email.
68
+	 *
69
+	 * @param array  $user
70
+	 * @return bool
71
+	 */
72
+	public function resetPassword($user)
73
+	{
74
+		$data = [
75
+			'email' => $user['email'],
76
+			'link'  => site_url( \Myth\Route::named('forgot_pass') ),
77
+			'site_name' => config_item('site.name'),
78
+			'site_link' => site_url()
79
+		];
80 80
 
81
-        // Send it immediately - don't queue.
82
-        return $this->send($user['email'], lang('auth.reset_subject'), $data);
83
-    }
81
+		// Send it immediately - don't queue.
82
+		return $this->send($user['email'], lang('auth.reset_subject'), $data);
83
+	}
84 84
 
85
-    //--------------------------------------------------------------------
85
+	//--------------------------------------------------------------------
86 86
 }
Please login to merge, or discard this patch.
application/models/User_model.php 1 patch
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -4,363 +4,363 @@
 block discarded – undo
4 4
 
5 5
 class User_model extends \Myth\Models\CIDbModel {
6 6
 
7
-    protected $table_name = 'users';
8
-
9
-    protected $soft_deletes = true;
10
-
11
-    protected $set_created = true;
12
-
13
-    protected $set_modified = false;
14
-
15
-    protected $protected_attributes = ['id', 'submit'];
16
-
17
-    protected $validation_rules = [
18
-        [
19
-            'field' => 'first_name',
20
-            'label' => 'lang:auth.first_name',
21
-            'rules' => 'trim|alpha|max_length[255]'
22
-        ],
23
-        [
24
-            'field' => 'last_name',
25
-            'label' => 'lang:auth.last_name',
26
-            'rules' => 'trim|alpha|max_length[255]'
27
-        ],
28
-        [
29
-            'field' => 'email',
30
-            'label' => 'lang:auth.email',
31
-            'rules' => 'trim|valid_email|max_length[255]'
32
-        ],
33
-        [
34
-            'field' => 'username',
35
-            'label' => 'lang:auth.username',
36
-            'rules' => 'trim|alpha_numeric|max_length[255]'
37
-        ],
38
-        [
39
-            'field' => 'password',
40
-            'label' => 'lang:auth.password',
41
-            'rules' => 'trim|max_length[255]|isStrongPassword'
42
-        ],
43
-        [
44
-            'field' => 'pass_confirm',
45
-            'label' => 'lang:auth.pass_confirm',
46
-            'rules' => 'trim|matches[password]'
47
-        ],
48
-    ];
49
-
50
-    protected $insert_validate_rules = [
51
-        'email'        => 'required|is_unique[users.email]',
52
-        'username'     => 'required|is_unique[users.username]',
53
-        'password'     => 'required',
54
-        'pass_confirm' => 'required'
55
-    ];
56
-
57
-    protected $before_insert = ['hashPassword'];
58
-    protected $before_update = ['hashPassword'];
59
-    protected $after_insert  = ['updateMeta'];
60
-    protected $after_update  = ['updateMeta'];
61
-
62
-    // The columns in the 'users_meta' table - for auto updating of profile information.
63
-    protected $meta_fields = ['first_name', 'last_name'];
64
-
65
-    protected $fields = ['id', 'email', 'username', 'password_hash', 'reset_hash', 'activate_hash', 'created_on', 'status', 'status_message', 'active', 'deleted', 'force_pass_reset'];
66
-
67
-    //--------------------------------------------------------------------
68
-
69
-    public function __construct()
70
-    {
71
-        parent::__construct();
72
-
73
-        $this->load->helper('auth/password');
74
-    }
75
-
76
-    //--------------------------------------------------------------------
77
-
78
-    /**
79
-     * Works with any find queries to return user_meta information.
80
-     *
81
-     * @return $this
82
-     */
83
-    public function withMeta()
84
-    {
85
-        $this->after_find[] = 'grabMeta';
86
-
87
-        return $this;
88
-    }
89
-
90
-    //--------------------------------------------------------------------
91
-
92
-    /**
93
-     * If exists, will take our password out of the data array, and
94
-     * create a new hash for it, which is inserted back into the
95
-     * data array to be saved to the database.
96
-     *
97
-     * @param array $data
98
-     *
99
-     * @return array
100
-     */
101
-    protected function hashPassword($data)
102
-    {
103
-        if (isset($data['fields']))
104
-        {
105
-            $data = $data['fields'];
106
-        }
107
-
108
-        if (isset($data['password']))
109
-        {
110
-            $data['password_hash'] = \Myth\Auth\Password::hashPassword($data['password']);
111
-
112
-            unset($data['password'], $data['pass_confirm']);
113
-        }
114
-
115
-        return $data;
116
-    }
117
-
118
-    //--------------------------------------------------------------------
119
-
120
-    /**
121
-     * A callback designed to work with Digest Authentication to create
122
-     * and store the $A1 value since we'll never have access to the
123
-     * password except during inserts or updates.
124
-     *
125
-     * This assumes that this is working as part of an API and that
126
-     * the api config file is already loaded into memory.
127
-     *
128
-     * @param $data
129
-     *
130
-     * @return $data
131
-     */
132
-    public function createDigestKey($data)
133
-    {
134
-        $field = config_item('api.auth_field');
135
-        $value = null;
136
-
137
-        // If it's an update, we probably won't have the username/email
138
-        // so grab it so that we can use it.
139
-        if (! empty($data[ $this->primary_key ]))
140
-        {
141
-            if (! isset($data[$field]) )
142
-            {
143
-                $value = $this->get_field( $data['id'], $field );
144
-            }
145
-        }
146
-        // However, if it's an insert, then we should have it, If we don't, leave.
147
-        else
148
-        {
149
-            if (empty($data[$field]))
150
-            {
151
-                return $data;
152
-            }
153
-
154
-            $value = $data[$field];
155
-        }
156
-
157
-        // Still here? then create the hash based on the current realm.
158
-        if (! empty($data['password']) )
159
-        {
160
-            $key = md5($value .':'. config_item('api.realm') .':'. $data['password']);
161
-            $data['api_key'] = $key;
162
-        }
163
-
164
-        return $data;
165
-    }
166
-
167
-    //--------------------------------------------------------------------
168
-
169
-
170
-    /**
171
-     * A callback method intended to hook into the after_insert and after_udpate
172
-     * methods.
173
-     *
174
-     * NOTE: Will only work for insert and update methods.
175
-     *
176
-     * @param array $data
177
-     * @return mixed
178
-     */
179
-    public function updateMeta($data)
180
-    {
181
-        // If no 'id' is in the $data array, then
182
-        // we don't have successful insert, get out of here
183
-        if (empty($data['id']) || ($data['method'] != 'insert' && $data['method'] != 'update'))
184
-        {
185
-            return $data;
186
-        }
187
-
188
-        // Collect any meta fields
189
-        foreach ($data['fields'] as $key => $value)
190
-        {
191
-            if (in_array($key, $this->meta_fields))
192
-            {
193
-                $this->db->where('user_id', $data['id']);
194
-                $this->db->where('meta_key', $key);
195
-                $query = $this->db->get('user_meta');
196
-
197
-                $obj = [
198
-                    'user_id'    => $data['id'],
199
-                    'meta_key'   => $key,
200
-                    'meta_value' => $value
201
-                ];
202
-
203
-                if ($query->num_rows() == 0)
204
-                {
205
-                    $this->db->insert('user_meta', $obj);
206
-                }
207
-                else if ($query->num_rows() > 0)
208
-                {
209
-                    $this->db->where('user_id', $data['id'])
210
-                             ->where('meta_key', $key)
211
-                             ->set('meta_value', $value)
212
-                             ->update('user_meta', $obj);
213
-                }
214
-            }
215
-        }
216
-
217
-        return $data;
218
-    }
219
-
220
-    //--------------------------------------------------------------------
221
-
222
-    /**
223
-     * Adds a single piece of meta information to a user.
224
-     *
225
-     * @param $user_id
226
-     * @param $key
227
-     * @param null $value
228
-     *
229
-     * @return object
230
-     */
231
-    public function saveMetaToUser($user_id, $key, $value=null)
232
-    {
233
-        if (! Events::trigger('beforeAddMetaToUser', [$user_id, $key]))
234
-        {
235
-            return false;
236
-        }
237
-
238
-        $user_id = (int)$user_id;
239
-
240
-        // Does this key already exist?
241
-        $test = $this->db->where([ 'user_id' => $user_id, 'meta_key' => $key ])->get('user_meta');
242
-
243
-        // Doesn't exist, so insert it.
244
-        if (! $test->num_rows())
245
-        {
246
-            $data = [
247
-                'user_id'       => $user_id,
248
-                'meta_key'      => $key,
249
-                'meta_value'    => $value
250
-            ];
251
-
252
-            return $this->db->insert('user_meta', $data);
253
-        }
254
-
255
-        // Otherwise, we need to update the existing.
256
-        return $this->db->where('user_id', $user_id)
257
-                        ->where('meta_key', $key)
258
-                        ->set('meta_value', $value)
259
-                        ->update('user_meta');
260
-    }
7
+	protected $table_name = 'users';
8
+
9
+	protected $soft_deletes = true;
10
+
11
+	protected $set_created = true;
12
+
13
+	protected $set_modified = false;
14
+
15
+	protected $protected_attributes = ['id', 'submit'];
16
+
17
+	protected $validation_rules = [
18
+		[
19
+			'field' => 'first_name',
20
+			'label' => 'lang:auth.first_name',
21
+			'rules' => 'trim|alpha|max_length[255]'
22
+		],
23
+		[
24
+			'field' => 'last_name',
25
+			'label' => 'lang:auth.last_name',
26
+			'rules' => 'trim|alpha|max_length[255]'
27
+		],
28
+		[
29
+			'field' => 'email',
30
+			'label' => 'lang:auth.email',
31
+			'rules' => 'trim|valid_email|max_length[255]'
32
+		],
33
+		[
34
+			'field' => 'username',
35
+			'label' => 'lang:auth.username',
36
+			'rules' => 'trim|alpha_numeric|max_length[255]'
37
+		],
38
+		[
39
+			'field' => 'password',
40
+			'label' => 'lang:auth.password',
41
+			'rules' => 'trim|max_length[255]|isStrongPassword'
42
+		],
43
+		[
44
+			'field' => 'pass_confirm',
45
+			'label' => 'lang:auth.pass_confirm',
46
+			'rules' => 'trim|matches[password]'
47
+		],
48
+	];
49
+
50
+	protected $insert_validate_rules = [
51
+		'email'        => 'required|is_unique[users.email]',
52
+		'username'     => 'required|is_unique[users.username]',
53
+		'password'     => 'required',
54
+		'pass_confirm' => 'required'
55
+	];
56
+
57
+	protected $before_insert = ['hashPassword'];
58
+	protected $before_update = ['hashPassword'];
59
+	protected $after_insert  = ['updateMeta'];
60
+	protected $after_update  = ['updateMeta'];
61
+
62
+	// The columns in the 'users_meta' table - for auto updating of profile information.
63
+	protected $meta_fields = ['first_name', 'last_name'];
64
+
65
+	protected $fields = ['id', 'email', 'username', 'password_hash', 'reset_hash', 'activate_hash', 'created_on', 'status', 'status_message', 'active', 'deleted', 'force_pass_reset'];
66
+
67
+	//--------------------------------------------------------------------
68
+
69
+	public function __construct()
70
+	{
71
+		parent::__construct();
72
+
73
+		$this->load->helper('auth/password');
74
+	}
75
+
76
+	//--------------------------------------------------------------------
77
+
78
+	/**
79
+	 * Works with any find queries to return user_meta information.
80
+	 *
81
+	 * @return $this
82
+	 */
83
+	public function withMeta()
84
+	{
85
+		$this->after_find[] = 'grabMeta';
86
+
87
+		return $this;
88
+	}
89
+
90
+	//--------------------------------------------------------------------
91
+
92
+	/**
93
+	 * If exists, will take our password out of the data array, and
94
+	 * create a new hash for it, which is inserted back into the
95
+	 * data array to be saved to the database.
96
+	 *
97
+	 * @param array $data
98
+	 *
99
+	 * @return array
100
+	 */
101
+	protected function hashPassword($data)
102
+	{
103
+		if (isset($data['fields']))
104
+		{
105
+			$data = $data['fields'];
106
+		}
107
+
108
+		if (isset($data['password']))
109
+		{
110
+			$data['password_hash'] = \Myth\Auth\Password::hashPassword($data['password']);
111
+
112
+			unset($data['password'], $data['pass_confirm']);
113
+		}
114
+
115
+		return $data;
116
+	}
117
+
118
+	//--------------------------------------------------------------------
119
+
120
+	/**
121
+	 * A callback designed to work with Digest Authentication to create
122
+	 * and store the $A1 value since we'll never have access to the
123
+	 * password except during inserts or updates.
124
+	 *
125
+	 * This assumes that this is working as part of an API and that
126
+	 * the api config file is already loaded into memory.
127
+	 *
128
+	 * @param $data
129
+	 *
130
+	 * @return $data
131
+	 */
132
+	public function createDigestKey($data)
133
+	{
134
+		$field = config_item('api.auth_field');
135
+		$value = null;
136
+
137
+		// If it's an update, we probably won't have the username/email
138
+		// so grab it so that we can use it.
139
+		if (! empty($data[ $this->primary_key ]))
140
+		{
141
+			if (! isset($data[$field]) )
142
+			{
143
+				$value = $this->get_field( $data['id'], $field );
144
+			}
145
+		}
146
+		// However, if it's an insert, then we should have it, If we don't, leave.
147
+		else
148
+		{
149
+			if (empty($data[$field]))
150
+			{
151
+				return $data;
152
+			}
153
+
154
+			$value = $data[$field];
155
+		}
156
+
157
+		// Still here? then create the hash based on the current realm.
158
+		if (! empty($data['password']) )
159
+		{
160
+			$key = md5($value .':'. config_item('api.realm') .':'. $data['password']);
161
+			$data['api_key'] = $key;
162
+		}
163
+
164
+		return $data;
165
+	}
166
+
167
+	//--------------------------------------------------------------------
168
+
169
+
170
+	/**
171
+	 * A callback method intended to hook into the after_insert and after_udpate
172
+	 * methods.
173
+	 *
174
+	 * NOTE: Will only work for insert and update methods.
175
+	 *
176
+	 * @param array $data
177
+	 * @return mixed
178
+	 */
179
+	public function updateMeta($data)
180
+	{
181
+		// If no 'id' is in the $data array, then
182
+		// we don't have successful insert, get out of here
183
+		if (empty($data['id']) || ($data['method'] != 'insert' && $data['method'] != 'update'))
184
+		{
185
+			return $data;
186
+		}
187
+
188
+		// Collect any meta fields
189
+		foreach ($data['fields'] as $key => $value)
190
+		{
191
+			if (in_array($key, $this->meta_fields))
192
+			{
193
+				$this->db->where('user_id', $data['id']);
194
+				$this->db->where('meta_key', $key);
195
+				$query = $this->db->get('user_meta');
196
+
197
+				$obj = [
198
+					'user_id'    => $data['id'],
199
+					'meta_key'   => $key,
200
+					'meta_value' => $value
201
+				];
202
+
203
+				if ($query->num_rows() == 0)
204
+				{
205
+					$this->db->insert('user_meta', $obj);
206
+				}
207
+				else if ($query->num_rows() > 0)
208
+				{
209
+					$this->db->where('user_id', $data['id'])
210
+							 ->where('meta_key', $key)
211
+							 ->set('meta_value', $value)
212
+							 ->update('user_meta', $obj);
213
+				}
214
+			}
215
+		}
216
+
217
+		return $data;
218
+	}
219
+
220
+	//--------------------------------------------------------------------
221
+
222
+	/**
223
+	 * Adds a single piece of meta information to a user.
224
+	 *
225
+	 * @param $user_id
226
+	 * @param $key
227
+	 * @param null $value
228
+	 *
229
+	 * @return object
230
+	 */
231
+	public function saveMetaToUser($user_id, $key, $value=null)
232
+	{
233
+		if (! Events::trigger('beforeAddMetaToUser', [$user_id, $key]))
234
+		{
235
+			return false;
236
+		}
237
+
238
+		$user_id = (int)$user_id;
239
+
240
+		// Does this key already exist?
241
+		$test = $this->db->where([ 'user_id' => $user_id, 'meta_key' => $key ])->get('user_meta');
242
+
243
+		// Doesn't exist, so insert it.
244
+		if (! $test->num_rows())
245
+		{
246
+			$data = [
247
+				'user_id'       => $user_id,
248
+				'meta_key'      => $key,
249
+				'meta_value'    => $value
250
+			];
251
+
252
+			return $this->db->insert('user_meta', $data);
253
+		}
254
+
255
+		// Otherwise, we need to update the existing.
256
+		return $this->db->where('user_id', $user_id)
257
+						->where('meta_key', $key)
258
+						->set('meta_value', $value)
259
+						->update('user_meta');
260
+	}
261 261
     
262
-    //--------------------------------------------------------------------
263
-
264
-    /**
265
-     * Gets the value of a single Meta item from a user.
266
-     *
267
-     * @param $user_id
268
-     * @param $key
269
-     *
270
-     * @return mixed
271
-     */
272
-    public function getMetaItem($user_id, $key)
273
-    {
274
-        $query = $this->db->where('user_id', (int)$user_id)
275
-                          ->where('meta_key', $key)
276
-                          ->select('meta_value')
277
-                          ->get('user_meta');
278
-
279
-        if (! $query->num_rows())
280
-        {
281
-            return null;
282
-        }
283
-
284
-        return $query->row()->meta_value;
285
-    }
286
-
287
-    //--------------------------------------------------------------------
288
-
289
-    /**
290
-     * Deletes one or more meta values from a user.
291
-     *
292
-     * @param $user_id
293
-     * @param $key
294
-     *
295
-     * @return bool
296
-     */
297
-    public function removeMetaFromUser($user_id, $key)
298
-    {
299
-        if (! Events::trigger('beforeRemoveMetaFromUser', [$user_id, $key]))
300
-        {
301
-            return false;
302
-        }
303
-
304
-	    if (is_array($key))
305
-	    {
306
-		    $this->db->where_in('meta_key', $key);
307
-	    }
308
-	    else
309
-	    {
310
-		    $this->db->where('meta_key', $key);
311
-	    }
312
-
313
-        $this->db->where('user_id', (int)$user_id)
314
-                 ->delete('user_meta');
315
-    }
316
-
317
-    //--------------------------------------------------------------------
318
-
319
-    public function getMetaForUser($user_id)
320
-    {
321
-        $query = $this->db->where('user_id', (int)$user_id)
322
-                          ->select('meta_key, meta_value')
323
-                          ->get('user_meta');
324
-
325
-        $rows = $query->result();
326
-
327
-        $meta = [];
328
-
329
-        if (count($rows))
330
-        {
331
-            array_walk( $rows, function ( $row ) use ( &$meta )
332
-            {
333
-                $meta[ $row->meta_key ] = $row->meta_value;
334
-            } );
335
-        }
336
-
337
-        return $meta;
338
-    }
339
-
340
-    //--------------------------------------------------------------------
341
-
342
-    protected function grabMeta($data)
343
-    {
344
-        if (strpos($data['method'], 'find') === false)
345
-        {
346
-            return $data;
347
-        }
348
-
349
-        $meta = $this->getMetaForUser($data['fields']->id);
350
-
351
-        if (is_object($data['fields']))
352
-        {
353
-            $data['fields']->meta = (object)$meta;
354
-        }
355
-        else
356
-        {
357
-            $data['fields']['meta']= $meta;
358
-        }
359
-
360
-        return $data;
361
-    }
362
-
363
-    //--------------------------------------------------------------------
262
+	//--------------------------------------------------------------------
263
+
264
+	/**
265
+	 * Gets the value of a single Meta item from a user.
266
+	 *
267
+	 * @param $user_id
268
+	 * @param $key
269
+	 *
270
+	 * @return mixed
271
+	 */
272
+	public function getMetaItem($user_id, $key)
273
+	{
274
+		$query = $this->db->where('user_id', (int)$user_id)
275
+						  ->where('meta_key', $key)
276
+						  ->select('meta_value')
277
+						  ->get('user_meta');
278
+
279
+		if (! $query->num_rows())
280
+		{
281
+			return null;
282
+		}
283
+
284
+		return $query->row()->meta_value;
285
+	}
286
+
287
+	//--------------------------------------------------------------------
288
+
289
+	/**
290
+	 * Deletes one or more meta values from a user.
291
+	 *
292
+	 * @param $user_id
293
+	 * @param $key
294
+	 *
295
+	 * @return bool
296
+	 */
297
+	public function removeMetaFromUser($user_id, $key)
298
+	{
299
+		if (! Events::trigger('beforeRemoveMetaFromUser', [$user_id, $key]))
300
+		{
301
+			return false;
302
+		}
303
+
304
+		if (is_array($key))
305
+		{
306
+			$this->db->where_in('meta_key', $key);
307
+		}
308
+		else
309
+		{
310
+			$this->db->where('meta_key', $key);
311
+		}
312
+
313
+		$this->db->where('user_id', (int)$user_id)
314
+				 ->delete('user_meta');
315
+	}
316
+
317
+	//--------------------------------------------------------------------
318
+
319
+	public function getMetaForUser($user_id)
320
+	{
321
+		$query = $this->db->where('user_id', (int)$user_id)
322
+						  ->select('meta_key, meta_value')
323
+						  ->get('user_meta');
324
+
325
+		$rows = $query->result();
326
+
327
+		$meta = [];
328
+
329
+		if (count($rows))
330
+		{
331
+			array_walk( $rows, function ( $row ) use ( &$meta )
332
+			{
333
+				$meta[ $row->meta_key ] = $row->meta_value;
334
+			} );
335
+		}
336
+
337
+		return $meta;
338
+	}
339
+
340
+	//--------------------------------------------------------------------
341
+
342
+	protected function grabMeta($data)
343
+	{
344
+		if (strpos($data['method'], 'find') === false)
345
+		{
346
+			return $data;
347
+		}
348
+
349
+		$meta = $this->getMetaForUser($data['fields']->id);
350
+
351
+		if (is_object($data['fields']))
352
+		{
353
+			$data['fields']->meta = (object)$meta;
354
+		}
355
+		else
356
+		{
357
+			$data['fields']['meta']= $meta;
358
+		}
359
+
360
+		return $data;
361
+	}
362
+
363
+	//--------------------------------------------------------------------
364 364
 
365 365
 
366 366
 }
Please login to merge, or discard this patch.
application/views/errors/cli/error_php.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 <?php echo \Myth\CLI::write("\tLine Number: {$line}"); ?>
11 11
 
12 12
 <?php
13
-    if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE) {
13
+	if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE) {
14 14
 
15
-        echo \Myth\CLI::write("\n\tBacktrace");
15
+		echo \Myth\CLI::write("\n\tBacktrace");
16 16
 
17
-        foreach (debug_backtrace() as $error) {
18
-            if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0) {
19
-                echo \Myth\CLI::write("\t\t- {$error['function']}() - Line {$error['line']} in {$error['file']}");
20
-            }
21
-        }
17
+		foreach (debug_backtrace() as $error) {
18
+			if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0) {
19
+				echo \Myth\CLI::write("\t\t- {$error['function']}() - Line {$error['line']} in {$error['file']}");
20
+			}
21
+		}
22 22
 }
23 23
 
24 24
 echo \Myth\CLI::new_line();
Please login to merge, or discard this patch.
application/views/home/index.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
     <?= $uikit->row([], function() use($uikit) {
7 7
 
8
-        echo $uikit->column(['sizes' => ['l'=>6]], function() use($uikit) { ?>
8
+		echo $uikit->column(['sizes' => ['l'=>6]], function() use($uikit) { ?>
9 9
             <h3>What Is Sprint?</h3>
10 10
 
11 11
             <p>SprintPHP is a souped-up version of <a href="http://codeigniter.com">CodeIgniter <?= CI_VERSION ?></a>. And soon to be the heart and soul
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 
28
-        echo $uikit->column(['sizes' => ['l'=>6]], function() use($uikit) { ?>
28
+		echo $uikit->column(['sizes' => ['l'=>6]], function() use($uikit) { ?>
29 29
             <h3>Get To Know Sprint</h3>
30 30
 
31 31
             <p>The following resources will help you as you explore the power and flexibility that SprintPHP provides. Feel free to dig into source code of the controllers and views
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
 
40 40
         <?php });
41 41
 
42
-    }); ?>
42
+	}); ?>
43 43
 
44 44
 </div>
Please login to merge, or discard this patch.
build/build.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,34 +1,34 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Sprint
4
- *
5
- * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in
15
- * all copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- * THE SOFTWARE.
24
- *
25
- * @package     Sprint
26
- * @author      Lonnie Ezell
27
- * @copyright   Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com)
28
- * @license     http://opensource.org/licenses/MIT  (MIT)
29
- * @link        http://sprintphp.com
30
- * @since       Version 1.0
31
- */
3
+	 * Sprint
4
+	 *
5
+	 * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow.
6
+	 *
7
+	 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+	 * of this software and associated documentation files (the "Software"), to deal
9
+	 * in the Software without restriction, including without limitation the rights
10
+	 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+	 * copies of the Software, and to permit persons to whom the Software is
12
+	 * furnished to do so, subject to the following conditions:
13
+	 *
14
+	 * The above copyright notice and this permission notice shall be included in
15
+	 * all copies or substantial portions of the Software.
16
+	 *
17
+	 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+	 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+	 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+	 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+	 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+	 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+	 * THE SOFTWARE.
24
+	 *
25
+	 * @package     Sprint
26
+	 * @author      Lonnie Ezell
27
+	 * @copyright   Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com)
28
+	 * @license     http://opensource.org/licenses/MIT  (MIT)
29
+	 * @link        http://sprintphp.com
30
+	 * @since       Version 1.0
31
+	 */
32 32
 
33 33
 /**
34 34
  * BUILD TOOL
Please login to merge, or discard this patch.
build/build_config.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 	$config['builds'] = [
12 12
 		'release'           => 'SprintRelease',
13 13
 		'postCreateProject' => 'InitialCleanup',
14
-        'publishSubTrees'   => 'SubTreeSplit'
14
+		'publishSubTrees'   => 'SubTreeSplit'
15 15
 	];
16 16
 
17 17
 //--------------------------------------------------------------------
Please login to merge, or discard this patch.
build/lib/BaseBuilder.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 	public function __construct($ci=null)
14 14
 	{
15
-	    $this->ci =& $ci;
15
+		$this->ci =& $ci;
16 16
 	}
17 17
 
18 18
 	//--------------------------------------------------------------------
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function ensureFolder($path)
59 59
 	{
60
-	    if (is_dir($path))
61
-	    {
62
-		    return true;
63
-	    }
60
+		if (is_dir($path))
61
+		{
62
+			return true;
63
+		}
64 64
 
65 65
 		return mkdir($path, 0777, true);
66 66
 	}
Please login to merge, or discard this patch.
build/scripts/SprintRelease.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
 	public function __construct($destination)
19 19
 	{
20
-	    $this->source_path = realpath(BUILDBASE .'../');
20
+		$this->source_path = realpath(BUILDBASE .'../');
21 21
 
22 22
 		if (empty($this->source_path))
23 23
 		{
Please login to merge, or discard this patch.
build/scripts/SubTreeSplit.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
  */
13 13
 class SubTreeSplit extends BaseBuilder {
14 14
 
15
-    public function run()
16
-    {
15
+	public function run()
16
+	{
17 17
 
18
-    }
18
+	}
19 19
 
20
-    //--------------------------------------------------------------------
20
+	//--------------------------------------------------------------------
21 21
 
22 22
 
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.