Skip to content

Commit 4e946cd

Browse files
committed
Merge pull request #120 from bio/arden_fix
Made compatible with latest arden. Removed 'force' params from save method. See #118.
2 parents 934b69c + c713b21 commit 4e946cd

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

src/Zizaco/Confide/ConfideUser.php

+18-24
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,9 @@ public function resetPassword( $params )
164164
* @param array $options
165165
* @param \Closure $beforeSave
166166
* @param \Closure $afterSave
167-
* @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
168167
* @return bool
169168
*/
170-
public function save( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null, $force = false )
169+
public function save( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null )
171170
{
172171
$duplicated = false;
173172

@@ -178,7 +177,7 @@ public function save( array $rules = array(), array $customMessages = array(), a
178177

179178
if(! $duplicated)
180179
{
181-
return $this->real_save( $rules, $customMessages, $options, $beforeSave, $afterSave, $force );
180+
return $this->real_save( $rules, $customMessages, $options, $beforeSave, $afterSave );
182181
}
183182
else
184183
{
@@ -196,23 +195,22 @@ public function save( array $rules = array(), array $customMessages = array(), a
196195
* Before save the user. Generate a confirmation
197196
* code if is a new user.
198197
*
199-
* @param User $user
200198
* @return bool
201199
*/
202-
public static function beforeSave( $user )
200+
public function beforeSave()
203201
{
204-
if ( empty($user->id) )
202+
if ( empty($this->id) )
205203
{
206-
$user->confirmation_code = md5( uniqid(mt_rand(), true) );
204+
$this->confirmation_code = md5( uniqid(mt_rand(), true) );
207205
}
208206

209207
/*
210208
* Remove password_confirmation field before save to
211209
* database.
212210
*/
213-
if ( isset($user->password_confirmation) )
211+
if ( isset($this->password_confirmation) )
214212
{
215-
unset( $user->password_confirmation );
213+
unset( $this->password_confirmation );
216214
}
217215

218216
return true;
@@ -223,23 +221,21 @@ public static function beforeSave( $user )
223221
* After save, delivers the confirmation link email.
224222
* code if is a new user.
225223
*
226-
* @param User $user
227-
* @param string event status
228224
* @return bool
229225
*/
230-
public static function afterSave( $user, $status = '' )
226+
public function afterSave()
231227
{
232-
if (! $user->confirmed && ! static::$app['cache']->get('confirmation_email_'.$user->id) )
228+
if (! $this->confirmed && ! static::$app['cache']->get('confirmation_email_'.$this->id) )
233229
{
234230
$view = static::$app['config']->get('confide::email_account_confirmation');
235231

236-
$user->sendEmail( 'confide::confide.email.account_confirmation.subject', $view, array('user' => $user) );
232+
$this->sendEmail( 'confide::confide.email.account_confirmation.subject', $view, array('user' => $this) );
237233

238234
// Save in cache that the email has been sent.
239235
$signup_cache = (int)static::$app['config']->get('confide::signup_cache');
240236
if ($signup_cache !== 0)
241237
{
242-
static::$app['cache']->put('confirmation_email_'.$user->id, true, $signup_cache);
238+
static::$app['cache']->put('confirmation_email_'.$this->id, true, $signup_cache);
243239
}
244240
}
245241

@@ -257,15 +253,14 @@ public static function afterSave( $user, $status = '' )
257253
* @param array $options
258254
* @param \Closure $beforeSave
259255
* @param \Closure $afterSave
260-
* @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
261256
* @return bool
262257
*/
263-
protected function real_save( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null, $force = false )
258+
protected function real_save( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null )
264259
{
265260
if ( defined('CONFIDE_TEST') )
266261
{
267-
self::beforeSave( $this );
268-
self::afterSave( $this );
262+
$this->beforeSave();
263+
$this->afterSave();
269264
return true;
270265
}
271266
else{
@@ -280,7 +275,7 @@ protected function real_save( array $rules = array(), array $customMessages = ar
280275
$rules['password'] = 'required';
281276
}
282277

283-
return parent::save( $rules, $customMessages, $options, $beforeSave, $afterSave, $force );
278+
return parent::save( $rules, $customMessages, $options, $beforeSave, $afterSave );
284279
}
285280
}
286281

@@ -291,15 +286,14 @@ protected function real_save( array $rules = array(), array $customMessages = ar
291286
* @param array $options
292287
* @param Closure $beforeSave
293288
* @param Closure $afterSave
294-
* @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
295289
* @return bool
296290
*/
297-
public function amend( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null, $force = false )
291+
public function amend( array $rules = array(), array $customMessages = array(), array $options = array(), \Closure $beforeSave = null, \Closure $afterSave = null )
298292
{
299293
if (empty($rules)) {
300294
$rules = $this->getUpdateRules();
301295
}
302-
return $this->save( $rules, $customMessages, $options, $beforeSave, $afterSave, $force );
296+
return $this->save( $rules, $customMessages, $options, $beforeSave, $afterSave );
303297
}
304298

305299
/**
@@ -335,7 +329,7 @@ protected function sendEmail( $subject_translation, $view_name, $params = array(
335329
static::$app['mailer']->send($view_name, $params, function($m) use ($subject_translation, $user)
336330
{
337331
$m->to( $user->email )
338-
->subject( ConfideUser::$app['translator']->get($subject_translation) );
332+
->subject( ConfideUser::$app['translator']->get($subject_translation) );
339333
});
340334
}
341335

0 commit comments

Comments
 (0)