Skip to content

Commit fa1f05d

Browse files
committed
Fixed expiry field change, and moved paging element to avoid view mess
1 parent 8344375 commit fa1f05d

2 files changed

Lines changed: 52 additions & 52 deletions

File tree

Model/User.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ public function validateToken($token = null, $reset = false, $now = null) {
247247
$data = false;
248248
$match = $this->find(array(
249249
$this->alias . '.email_token' => $token),
250-
'id, email, email_token_expires, role');
250+
'id, email, email_token_expiry, role');
251251

252252
if (!empty($match)){
253-
$expires = strtotime($match[$this->alias]['email_token_expires']);
253+
$expires = strtotime($match[$this->alias]['email_token_expiry']);
254254
if ($expires > $now) {
255255
$data[$this->alias]['id'] = $match[$this->alias]['id'];
256256
$data[$this->alias]['email'] = $match[$this->alias]['email'];
@@ -263,7 +263,7 @@ public function validateToken($token = null, $reset = false, $now = null) {
263263
}
264264

265265
$data[$this->alias]['email_token'] = null;
266-
$data[$this->alias]['email_token_expires'] = null;
266+
$data[$this->alias]['email_token_expiry'] = null;
267267
}
268268
}
269269
return $data;
@@ -301,7 +301,7 @@ public function passwordReset($postData = array()) {
301301
$sixtyMins = time() + 43000;
302302
$token = $this->generateToken();
303303
$user[$this->alias]['password_token'] = $token;
304-
$user[$this->alias]['email_token_expires'] = date('Y-m-d H:i:s', $sixtyMins);
304+
$user[$this->alias]['email_token_expiry'] = date('Y-m-d H:i:s', $sixtyMins);
305305
$user = $this->save($user, false);
306306
return $user;
307307
} elseif (!empty($user) && $user[$this->alias]['email_verified'] == 0){
@@ -324,7 +324,7 @@ public function checkPasswordToken($token = null) {
324324
'conditions' => array(
325325
$this->alias . '.active' => 1,
326326
$this->alias . '.password_token' => $token,
327-
$this->alias . '.email_token_expires >=' => date('Y-m-d H:i:s'))));
327+
$this->alias . '.email_token_expiry >=' => date('Y-m-d H:i:s'))));
328328
if (empty($user)) {
329329
return false;
330330
}
@@ -497,7 +497,7 @@ public function resendVerification($postData = array()) {
497497
}
498498

499499
$user[$this->alias]['email_token'] = $this->generateToken();
500-
$user[$this->alias]['email_token_expires'] = date('Y-m-d H:i:s', time() + 86400);
500+
$user[$this->alias]['email_token_expiry'] = date('Y-m-d H:i:s', time() + 86400);
501501

502502
return $this->save($user, false);
503503
}
@@ -551,7 +551,7 @@ public function generateToken($length = 10) {
551551
protected function _beforeRegistration($postData = array(), $useEmailVerification = true) {
552552
if ($useEmailVerification == true) {
553553
$postData[$this->alias]['email_token'] = $this->generateToken();
554-
$postData[$this->alias]['email_token_expires'] = date('Y-m-d H:i:s', time() + 86400);
554+
$postData[$this->alias]['email_token_expiry'] = date('Y-m-d H:i:s', time() + 86400);
555555
} else {
556556
$postData[$this->alias]['email_verified'] = 1;
557557
}
@@ -707,6 +707,6 @@ public function edit($userId = null, $postData = null) {
707707
protected function _removeExpiredRegistrations() {
708708
$this->deleteAll(array(
709709
$this->alias . '.email_verified' => 0,
710-
$this->alias . '.email_token_expires <' => date('Y-m-d H:i:s')));
710+
$this->alias . '.email_token_expiry <' => date('Y-m-d H:i:s')));
711711
}
712712
}

View/Users/index.ctp

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,53 @@
1010
*/
1111
?>
1212
<div class="users index">
13-
<h2><?php echo __d('users', 'Users'); ?></h2>
13+
<h2><?php echo __d('users', 'Users'); ?></h2>
1414

15-
<p><?php
16-
echo $this->Paginator->counter(array(
17-
'format' => __d('users', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%')
18-
));
19-
?></p>
15+
<p><?php
16+
echo $this->Paginator->counter(array(
17+
'format' => __d('users', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%')
18+
));
19+
?></p>
2020

21-
<table cellpadding="0" cellspacing="0">
22-
<tr>
23-
<th><?php echo $this->Paginator->sort('username'); ?></th>
24-
<th><?php echo $this->Paginator->sort('created'); ?></th>
25-
<th class="actions"><?php __d('users', 'Actions'); ?></th>
26-
</tr>
27-
<?php
28-
$i = 0;
29-
foreach ($users as $user):
30-
$class = null;
31-
if ($i++ % 2 == 0) {
32-
$class = ' class="altrow"';
33-
}
34-
?>
35-
<tr<?php echo $class; ?>>
36-
<td>
37-
<?php echo $user[$model]['username']; ?>
38-
</td>
39-
<td>
40-
<?php echo $user[$model]['created']; ?>
41-
</td>
42-
<td class="actions">
43-
<?php echo $this->Html->link(__d('users', 'View'), array('action' => 'view', $user[$model]['id'])); ?>
44-
<?php echo $this->Html->link(__d('users', 'Edit'), array('action' => 'edit', $user[$model]['id'])); ?>
45-
<?php echo $this->Html->link(
46-
__d('users', 'Delete'),
47-
array('action' => 'delete', $user[$model]['id']),
48-
null,
49-
sprintf(__d('users', 'Are you sure you want to delete # %s?'), $user[$model]['id'])
50-
); ?>
51-
</td>
21+
<table cellpadding="0" cellspacing="0">
22+
<tr>
23+
<th><?php echo $this->Paginator->sort('username'); ?></th>
24+
<th><?php echo $this->Paginator->sort('created'); ?></th>
25+
<th class="actions"><?php __d('users', 'Actions'); ?></th>
5226
</tr>
53-
<?php endforeach; ?>
54-
</table>
55-
</div>
56-
<div class="paging">
57-
<?php echo $this->Paginator->prev('<< ' . __d('users', 'previous'), array(), null, array('class' => 'disabled')); ?>
58-
| <?php echo $this->Paginator->numbers(); ?>
59-
<?php echo $this->Paginator->next(__d('users', 'next') . ' >>', array(), null, array('class' => 'disabled')); ?>
27+
<?php
28+
$i = 0;
29+
foreach ($users as $user):
30+
$class = null;
31+
if ($i++ % 2 == 0) {
32+
$class = ' class="altrow"';
33+
}
34+
?>
35+
<tr<?php echo $class; ?>>
36+
<td>
37+
<?php echo $user[$model]['username']; ?>
38+
</td>
39+
<td>
40+
<?php echo $user[$model]['created']; ?>
41+
</td>
42+
<td class="actions">
43+
<?php echo $this->Html->link(__d('users', 'View'), array('action' => 'view', $user[$model]['id'])); ?>
44+
<?php echo $this->Html->link(__d('users', 'Edit'), array('action' => 'edit', $user[$model]['id'])); ?>
45+
<?php echo $this->Html->link(
46+
__d('users', 'Delete'),
47+
array('action' => 'delete', $user[$model]['id']),
48+
null,
49+
sprintf(__d('users', 'Are you sure you want to delete # %s?'), $user[$model]['id'])
50+
); ?>
51+
</td>
52+
</tr>
53+
<?php endforeach; ?>
54+
</table>
55+
<div class="paging">
56+
<?php echo $this->Paginator->prev('<< ' . __d('users', 'previous'), array(), null, array('class' => 'disabled')); ?>
57+
| <?php echo $this->Paginator->numbers(); ?>
58+
<?php echo $this->Paginator->next(__d('users', 'next') . ' >>', array(), null, array('class' => 'disabled')); ?>
59+
</div>
6060
</div>
6161
<div class="actions">
6262
<ul>

0 commit comments

Comments
 (0)