$('a.action.delete').tipsy({gravity:'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
+ $('td.lastLogin').tipsy({gravity:'s', fade:true, html:true});
$('input').tipsy({gravity:'w', fade:true});
// toggle for menus
// if return is true we are logged in -> redirect to the default page
if ($return === true) {
+ OC_User::getManager()->get(OC_User::getUser())->updateLastLogin();
$_REQUEST['redirect_url'] = \OC_Request::requestUri();
OC_Util::redirectToDefaultPage();
exit;
$granted = OC_User::loginWithCookie(
$_COOKIE['oc_username'], $_COOKIE['oc_token']);
if($granted === true) {
+ OC_User::getManager()->get(OC_User::getUser())->updateLastLogin();
OC_Util::redirectToDefaultPage();
// doesn't return
}
}
$userid = OC_User::getUser();
+ OC_User::getManager()->get($userid)->updateLastLogin();
self::cleanupLoginTokens($userid);
if (!empty($_POST["remember_login"])) {
if (defined("DEBUG") && DEBUG) {
if (OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
//OC_Log::write('core',"Logged in with HTTP Authentication", OC_Log::DEBUG);
+ OC_User::getManager()->get(OC_User::getUser())->updateLastLogin();
OC_User::unsetMagicInCookie();
$_SERVER['HTTP_REQUESTTOKEN'] = OC_Util::callRegister();
}
*/
private $config;
+ /**
+ * @var int $home
+ */
+ private $lastLogin;
+
/**
* @param string $uid
* @param \OC_User_Interface $backend
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled);
}
}
+
+ /**
+ * returns the timestamp of the user's last login or 0 if the user did never
+ * login
+ *
+ * @return int
+ */
+ public function getLastLogin() {
+ return $this->lastLogin;
+ }
+
+ public function updateLastLogin() {
+ $this->lastLogin = time();
+ \OC_Preferences::setValue($this->uid, 'login', 'lastLogin', $this->lastLogin);
+ }
}
'groups' => join(', ', OC_Group::getUserGroups($uid)),
'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($uid)),
'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'),
- 'storageLocation' => $user->getHome());
+ 'storageLocation' => $user->getHome(),
+ 'lastLogin' => $user->getLastLogin(),
+ );
}
} else {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
'displayname' => $user->getDisplayName(),
'groups' => join(', ', OC_Group::getUserGroups($uid)),
'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'),
- 'storageLocation' => $user->getHome());
+ 'storageLocation' => $user->getHome(),
+ 'lastLogin' => $user->getLastLogin(),
+ );
}
}
OC_JSON::success(array('data' => $users));
}
},
- add: function (username, displayname, groups, subadmin, quota, storageLocation, sort) {
+ add: function (username, displayname, groups, subadmin, quota, storageLocation, lastLogin, sort) {
var tr = $('tbody tr').first().clone();
var subadminsEl;
var subadminSelect;
}
}
tr.find('td.storageLocation').text(storageLocation);
+ if(lastLogin == 0) {
+ lastLogin = t('settings', 'never');
+ } else {
+ lastLogin = new Date(lastLogin);
+ lastLogin = relative_modified_date(lastLogin.getTime() / 1000);
+ }
+ tr.find('td.lastLogin').text(lastLogin);
$(tr).appendTo('tbody');
if (sort) {
if($('tr[data-uid="' + user.name + '"]').length > 0) {
return true;
}
- alert(user.storageLocation);
+ var tr = UserList.add(user.name, user.displayname, user.groups, user.subadmin, user.quota, user.storageLocation, user.lastLogin, false);
tr.addClass('appear transparent');
trs.push(tr);
loadedUsers++;
}, 10000);
}
if($('tr[data-uid="' + username + '"]').length === 0) {
- UserList.add(username, username, result.data.groups, null, 'default', result.data.storageLocation, true);
+ UserList.add(username, username, result.data.groups, null, 'default', result.data.storageLocation, 0, true);
}
}
}
<?php endif;?>
<th id="headerQuota"><?php p($l->t('Quota')); ?></th>
<th id="headerStorageLocation"><?php p($l->t('Storage Location')); ?></th>
+ <th id="headerLastLogin"><?php p($l->t('Last Login')); ?></th>
<th id="headerRemove"> </th>
</tr>
</thead>
</select>
</td>
<td class="storageLocation"><?php p($user["storageLocation"]); ?></td>
+ <?php
+ if($user["lastLogin"] === 0) {
+ $lastLogin = 'never';
+ $lastLoginDate = '';
+ } else {
+ $lastLogin = relative_modified_date($user["lastLogin"]);
+ $lastLoginDate = \OC_Util::formatDate($user["lastLogin"]);
+ }
+ ?>
+ <td class="lastLogin" title="<?php p('<span style="white-space: nowrap;">').p($lastLoginDate).p('</span>'); ?>"><?php p($lastLogin); ?></td>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>
<a href="#" class="action delete" original-title="<?php p($l->t('Delete'))?>">
'isQuotaUserDefined' => $isQuotaUserDefined,
'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid),
'storageLocation' => $user->getHome(),
+ 'lastLogin' => $user->getLastLogin(),
);
}