diff options
author | Andreas Fischer <bantu@owncloud.com> | 2014-05-28 22:57:33 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2014-05-28 22:57:33 +0200 |
commit | 5754b0b9e70824786878b847abb6b728ca0414bb (patch) | |
tree | 9ad1fbc35edde8f54f44c9ef7029e007a16815b9 /core/command/user | |
parent | f81ee94cad8a997c3a2fef0b6aac4f8d509571f6 (diff) | |
parent | ce9d5df6df37e51587dcde638086dfe501892b56 (diff) | |
download | nextcloud-server-5754b0b9e70824786878b847abb6b728ca0414bb.tar.gz nextcloud-server-5754b0b9e70824786878b847abb6b728ca0414bb.zip |
Merge remote-tracking branch 'owncloud/master' into add_resetadminpass_command
* owncloud/master: (238 commits)
Change visibility of scanner internals
[tx-robot] updated from transifex
remove legacy OC_Filesystem being used in a hook callback
add title property to share dialog
forgotten infobox messages translations
reverts 188c543 and translates only mail
fix warning text and margin
Adjust core apps to use "requiremin" instead of "require"
Added requiremin/requiremax fields for apps
[tx-robot] updated from transifex
unwrapped strings fix
allow resharing of files with only share permissions
don't lose file size during rename
drop superflous statement in phpdoc
add preRememberedLogin hook and document this and postRememberedLogin in class descripttion. Also fixes documentation of postLogin hook
[tx-robot] updated from transifex
fix grammar
make user_ldap fully translatable
[tx-robot] updated from transifex
fix typo
...
Conflicts:
core/register_command.php
Diffstat (limited to 'core/command/user')
-rw-r--r-- | core/command/user/lastseen.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/core/command/user/lastseen.php b/core/command/user/lastseen.php new file mode 100644 index 00000000000..7a8db013e3a --- /dev/null +++ b/core/command/user/lastseen.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2014 Arthur Schiwon <blizzz@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Core\Command\User; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; + +class LastSeen extends Command { + protected function configure() { + $this + ->setName('user:lastseen') + ->setDescription('shows when the user was logged it last time') + ->addArgument( + 'uid', + InputArgument::REQUIRED, + 'the username' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $userManager = \OC::$server->getUserManager(); + $user = $userManager->get($input->getArgument('uid')); + if(is_null($user)) { + $output->writeln('User does not exist'); + return; + } + + $lastLogin = $user->getLastLogin(); + if($lastLogin === 0) { + $output->writeln('User ' . $user->getUID() . + ' has never logged in, yet.'); + } else { + $date = new \DateTime(); + $date->setTimestamp($lastLogin); + $output->writeln($user->getUID() . + '`s last login: ' . $date->format('d.m.Y H:i')); + } + } +} |