summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-01-06 17:50:06 +0100
committerArthur Schiwon <blizzz@owncloud.com>2015-01-06 17:50:06 +0100
commite724b78694cb17c7a3ff4427ae103b01baa4688c (patch)
tree21ad2d4a24d1e4e3a8da5e5d0ee6f1dd8ff40cf1 /apps
parent61ed363f820a3b25b68289ed2c03ff5e5edfed91 (diff)
downloadnextcloud-server-e724b78694cb17c7a3ff4427ae103b01baa4688c.tar.gz
nextcloud-server-e724b78694cb17c7a3ff4427ae103b01baa4688c.zip
smaller fixes: coding style, PHPdoc, typos and few for DI
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/appinfo/register_command.php8
-rw-r--r--apps/user_ldap/command/checkuser.php16
-rw-r--r--apps/user_ldap/command/showremnants.php25
-rw-r--r--apps/user_ldap/lib/jobs.php4
-rw-r--r--apps/user_ldap/lib/jobs/cleanup.php32
-rw-r--r--apps/user_ldap/lib/user/deletedusersindex.php7
-rw-r--r--apps/user_ldap/lib/user/offlineuser.php6
-rw-r--r--apps/user_ldap/tests/jobs/cleanup.php24
8 files changed, 51 insertions, 71 deletions
diff --git a/apps/user_ldap/appinfo/register_command.php b/apps/user_ldap/appinfo/register_command.php
index e0013c4eb7a..0e918b82335 100644
--- a/apps/user_ldap/appinfo/register_command.php
+++ b/apps/user_ldap/appinfo/register_command.php
@@ -20,7 +20,8 @@ $uBackend = new User_Proxy(
new LDAP()
);
$deletedUsersIndex = new DeletedUsersIndex(
- \OC::$server->getConfig(), $dbConnection, $userMapping);
+ \OC::$server->getConfig(), $dbConnection, $userMapping
+);
$application->add(new OCA\user_ldap\Command\ShowConfig());
$application->add(new OCA\user_ldap\Command\SetConfig());
@@ -28,6 +29,7 @@ $application->add(new OCA\user_ldap\Command\TestConfig());
$application->add(new OCA\user_ldap\Command\CreateEmptyConfig());
$application->add(new OCA\user_ldap\Command\DeleteConfig());
$application->add(new OCA\user_ldap\Command\Search());
-$application->add(new OCA\user_ldap\Command\ShowRemnants($userMapping));
+$application->add(new OCA\user_ldap\Command\ShowRemnants($deletedUsersIndex));
$application->add(new OCA\user_ldap\Command\CheckUser(
- $uBackend, $helper, $deletedUsersIndex, $userMapping));
+ $uBackend, $helper, $deletedUsersIndex, $userMapping)
+);
diff --git a/apps/user_ldap/command/checkuser.php b/apps/user_ldap/command/checkuser.php
index 5b1dc36c1d0..f9065a7c8d6 100644
--- a/apps/user_ldap/command/checkuser.php
+++ b/apps/user_ldap/command/checkuser.php
@@ -17,7 +17,8 @@ use Symfony\Component\Console\Output\OutputInterface;
use OCA\user_ldap\lib\user\User;
use OCA\User_LDAP\lib\user\Manager;
use OCA\User_LDAP\lib\User\DeletedUsersIndex;
-use OCA\user_ldap\lib\Helper;
+use OCA\User_LDAP\Mapping\UserMapping;
+use OCA\user_ldap\lib\Helper as LDAPHelper;
use OCA\user_ldap\User_Proxy;
class CheckUser extends Command {
@@ -35,10 +36,11 @@ class CheckUser extends Command {
/**
* @param OCA\user_ldap\User_Proxy $uBackend
- * @param OCA\User_LDAP\lib\Helper $helper
- * @param OCP\IConfig $config
+ * @param OCA\user_ldap\lib\Helper $helper
+ * @param OCA\User_LDAP\lib\User\DeletedUsersIndex $dui
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
*/
- public function __construct(User_Proxy $uBackend, Helper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
+ public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
$this->backend = $uBackend;
$this->helper = $helper;
$this->dui = $dui;
@@ -100,13 +102,13 @@ class CheckUser extends Command {
}
/**
- * checks whether the setup allows reliable checking of LDAP user existance
+ * checks whether the setup allows reliable checking of LDAP user existence
* @throws \Exception
- * @return bool
+ * @return true
*/
protected function isAllowed($force) {
if($this->helper->haveDisabledConfigurations() && !$force) {
- throw new \Exception('Cannot check user existance, because '
+ throw new \Exception('Cannot check user existence, because '
. 'disabled LDAP configurations are present.');
}
diff --git a/apps/user_ldap/command/showremnants.php b/apps/user_ldap/command/showremnants.php
index 8144a54cbee..ab78cee96e7 100644
--- a/apps/user_ldap/command/showremnants.php
+++ b/apps/user_ldap/command/showremnants.php
@@ -19,16 +19,14 @@ use OCA\User_LDAP\lib\Connection;
use OCA\User_LDAP\Mapping\UserMapping;
class ShowRemnants extends Command {
- /** @var OCA\User_LDAP\Mapping\UserMapping */
- protected $mapping;
+ /** @var use OCA\User_LDAP\lib\User\DeletedUsersIndex; */
+ protected $dui;
/**
- * @param OCA\user_ldap\User_Proxy $uBackend
- * @param OCA\User_LDAP\lib\Helper $helper
- * @param OCP\IConfig $config
+ * @param OCA\user_ldap\lib\user\DeletedUsersIndex $dui
*/
- public function __construct(UserMapping $mapper) {
- $this->mapper = $mapper;
+ public function __construct(DeletedUsersIndex $dui) {
+ $this->dui = $dui;
parent::__construct();
}
@@ -39,20 +37,19 @@ class ShowRemnants extends Command {
;
}
+ /**
+ * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted
+ *
+ * {@inheritdoc}
+ */
protected function execute(InputInterface $input, OutputInterface $output) {
- $dui = new DeletedUsersIndex(
- \OC::$server->getConfig(),
- \OC::$server->getDatabaseConnection(),
- $this->mapper
- );
-
/** @var \Symfony\Component\Console\Helper\Table $table */
$table = $this->getHelperSet()->get('table');
$table->setHeaders(array(
'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login',
'Dir', 'Sharer'));
$rows = array();
- $resultSet = $dui->getUsers();
+ $resultSet = $this->dui->getUsers();
foreach($resultSet as $user) {
$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
$lastLogin = ($user->getLastLogin() > 0) ?
diff --git a/apps/user_ldap/lib/jobs.php b/apps/user_ldap/lib/jobs.php
index 391a10d31f8..e8e6df0b9d0 100644
--- a/apps/user_ldap/lib/jobs.php
+++ b/apps/user_ldap/lib/jobs.php
@@ -24,6 +24,7 @@
namespace OCA\user_ldap\lib;
use OCA\User_LDAP\Mapping\GroupMapping;
+use OCA\User_LDAP\Mapping\UserMapping;
class Jobs extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB;
@@ -172,6 +173,9 @@ class Jobs extends \OC\BackgroundJob\TimedJob {
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager);
$groupMapper = new GroupMapping(\OC::$server->getDatabaseConnection());
+ $userMapper = new UserMapping(\OC::$server->getDatabaseConnection());
+ $ldapAccess->setGroupMapper($groupMapper);
+ $ldapAccess->setUserMapper($userMapper);
self::$groupBE = new \OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
self::$groupBE = new \OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
diff --git a/apps/user_ldap/lib/jobs/cleanup.php b/apps/user_ldap/lib/jobs/cleanup.php
index 35252d6f6e5..83cfeb048c8 100644
--- a/apps/user_ldap/lib/jobs/cleanup.php
+++ b/apps/user_ldap/lib/jobs/cleanup.php
@@ -22,29 +22,22 @@ use \OCA\User_LDAP\Mapping\UserMapping;
* @package OCA\user_ldap\lib;
*/
class CleanUp extends \OC\BackgroundJob\TimedJob {
- /**
- * @var int $limit amount of users that should be checked per run
- */
+ /** @var int $limit amount of users that should be checked per run */
protected $limit = 50;
- /**
- * @var \OCP\UserInterface $userBackend
- */
+ /** @var int $defaultIntervalMin default interval in minutes */
+ protected $defaultIntervalMin = 51;
+
+ /** @var \OCP\UserInterface $userBackend */
protected $userBackend;
- /**
- * @var \OCP\IConfig $ocConfig
- */
+ /** @var \OCP\IConfig $ocConfig */
protected $ocConfig;
- /**
- * @var \OCP\IDBConnection $db
- */
+ /** @var \OCP\IDBConnection $db */
protected $db;
- /**
- * @var Helper $ldapHelper
- */
+ /** @var Helper $ldapHelper */
protected $ldapHelper;
/** @var \OCA\User_LDAP\Mapping\UserMapping */
@@ -53,11 +46,6 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
/** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */
protected $dui;
- /**
- * @var int $defaultIntervalMin default interval in minutes
- */
- protected $defaultIntervalMin = 51;
-
public function __construct() {
$minutes = \OC::$server->getConfig()->getSystemValue(
'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
@@ -177,7 +165,7 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
* checks users whether they are still existing
* @param array $users result from getMappedUsers()
*/
- private function checkUsers($users) {
+ private function checkUsers(array $users) {
foreach($users as $user) {
$this->checkUser($user);
}
@@ -187,7 +175,7 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
* checks whether a user is still existing in LDAP
* @param string[] $user
*/
- private function checkUser($user) {
+ private function checkUser(array $user) {
if($this->userBackend->userExistsOnLDAP($user['name'])) {
//still available, all good
diff --git a/apps/user_ldap/lib/user/deletedusersindex.php b/apps/user_ldap/lib/user/deletedusersindex.php
index 67585530279..e17ed3384da 100644
--- a/apps/user_ldap/lib/user/deletedusersindex.php
+++ b/apps/user_ldap/lib/user/deletedusersindex.php
@@ -49,8 +49,13 @@ class DeletedUsersIndex {
/**
* @var array $deletedUsers
*/
- protected $deletedUsers = false;
+ protected $deletedUsers;
+ /**
+ * @param OCP\IConfig $config
+ * @param OCP\IDBConnection $db
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
+ */
public function __construct(\OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->config = $config;
$this->db = $db;
diff --git a/apps/user_ldap/lib/user/offlineuser.php b/apps/user_ldap/lib/user/offlineuser.php
index 9383320fae2..e5c87fd23fc 100644
--- a/apps/user_ldap/lib/user/offlineuser.php
+++ b/apps/user_ldap/lib/user/offlineuser.php
@@ -71,6 +71,12 @@ class OfflineUser {
*/
protected $mapping;
+ /**
+ * @param string $ocName
+ * @param OCP\IConfig $config
+ * @param OCP\IDBConnection $db
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
+ */
public function __construct($ocName, \OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->ocName = $ocName;
$this->config = $config;
diff --git a/apps/user_ldap/tests/jobs/cleanup.php b/apps/user_ldap/tests/jobs/cleanup.php
index 642bad57134..78bda66c54f 100644
--- a/apps/user_ldap/tests/jobs/cleanup.php
+++ b/apps/user_ldap/tests/jobs/cleanup.php
@@ -106,30 +106,6 @@ class Test_CleanUp extends \PHPUnit_Framework_TestCase {
}
/**
- * test whether sql is OK
- */
- public function test_getMappedUsers() {
- $args = $this->getMocks();
-
- $bgJob = new \OCA\User_LDAP\Jobs\CleanUp();
- $bgJob->setArguments($args);
-
- if(version_compare(\PHPUnit_Runner_Version::id(), '3.8', '<')) {
- //otherwise we run into
- //https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
- $this->markTestIncomplete();
- }
-
- $stmt = $this->getMock('\Doctrine\DBAL\Driver\Statement');
-
- $args['db']->expects($this->once())
- ->method('prepare')
- ->will($this->returnValue($stmt));
-
- $bgJob->getMappedUsers(0, $bgJob->getChunkSize());
- }
-
- /**
* check whether offset will be reset when it needs to
*/
public function test_OffsetResetIsNecessary() {