Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getOption('path');
     if ($path) {
         $path = '/' . trim($path, '/');
         list(, $user, ) = explode('/', $path, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     $quiet = $input->getOption('quiet');
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         if ($this->userManager->userExists($user)) {
             $this->scanFiles($user, $path, $quiet, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $this->scanFiles($user, $output);
     }
 }
Ejemplo n.º 3
0
 /**
  * get a list of all display names in a group
  * @param string $gid
  * @param string $search
  * @param int $limit
  * @param int $offset
  * @return array an array of display names (value) and user ids (key)
  */
 public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0)
 {
     $group = $this->get($gid);
     if (is_null($group)) {
         return array();
     }
     // only user backends have the capability to do a complex search for users
     $groupUsers = $group->searchUsers('', $limit, $offset);
     $search = trim($search);
     if (!empty($search)) {
         //TODO: for OC 7 earliest: user backend should get a method to check selected users against a pattern
         $filteredUsers = $this->userManager->search($search);
         $testUsers = true;
     } else {
         $filteredUsers = array();
         $testUsers = false;
     }
     $matchingUsers = array();
     foreach ($groupUsers as $user) {
         if (!$testUsers || isset($filteredUsers[$user->getUID()])) {
             $matchingUsers[$user->getUID()] = $user->getDisplayName();
         }
     }
     return $matchingUsers;
 }
Ejemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
         return;
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $this->scanFiles($user, $output);
     }
 }
Ejemplo n.º 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     \OC_App::loadApps('authentication');
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         if ($this->userManager->userExists($user)) {
             $this->scanFiles($user, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
 }
Ejemplo n.º 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $scanner = $this->container['Scanner'];
     $scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
         $output->writeln("Scanning <info>{$path}</info>");
     });
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($user);
         $output->writeln("Start scan for <info>{$user}</info>");
         $scanner->rescan($user, true);
     }
 }
Ejemplo n.º 7
0
Archivo: scan.php Proyecto: kenwi/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputPath = $input->getOption('path');
     if ($inputPath) {
         $inputPath = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $inputPath, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     }
     # no messaging level option means: no full printout but statistics
     # $quiet   means no print at all
     # $verbose means full printout including statistics
     # -q	-v	full	stat
     #  0	 0	no	yes
     #  0	 1	yes	yes
     #  1	--	no	no  (quiet overrules verbose)
     $verbose = $input->getOption('verbose');
     $quiet = $input->getOption('quiet');
     # restrict the verbosity level to VERBOSITY_VERBOSE
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
         $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     }
     if ($quiet) {
         $verbose = false;
     }
     $this->initTools();
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $path = $inputPath ? $inputPath : '/' . $user;
         if ($this->userManager->userExists($user)) {
             # full: printout data if $verbose was set
             $this->scanFiles($user, $path, $verbose, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
     # stat: printout statistics if $quiet was not set
     if (!$quiet) {
         $this->presentStats($output);
     }
 }
Ejemplo n.º 8
0
 /**
  * @brief get a list of all display names in a group
  * @param string $gid
  * @param string $search
  * @param int $limit
  * @param int $offset
  * @return array with display names (value) and user ids (key)
  */
 public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0)
 {
     $group = $this->get($gid);
     if (is_null($group)) {
         return array();
     }
     $search = trim($search);
     $groupUsers = array();
     if (!empty($search)) {
         // only user backends have the capability to do a complex search for users
         $searchOffset = 0;
         $searchLimit = $limit * 100;
         if ($limit === -1) {
             $searchLimit = 500;
         }
         do {
             $filteredUsers = $this->userManager->search($search, $searchLimit, $searchOffset);
             foreach ($filteredUsers as $filteredUser) {
                 if ($group->inGroup($filteredUser)) {
                     $groupUsers[] = $filteredUser;
                 }
             }
             $searchOffset += $searchLimit;
         } while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit);
         if ($limit === -1) {
             $groupUsers = array_slice($groupUsers, $offset);
         } else {
             $groupUsers = array_slice($groupUsers, $offset, $limit);
         }
     } else {
         $groupUsers = $group->searchUsers('', $limit, $offset);
     }
     $matchingUsers = array();
     foreach ($groupUsers as $groupUser) {
         $matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName();
     }
     return $matchingUsers;
 }
Ejemplo n.º 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputPath = $input->getOption('path');
     if ($inputPath) {
         $inputPath = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $inputPath, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     # no messaging level option means: no full printout but statistics
     # $quiet   means no print at all
     # $verbose means full printout including statistics
     # -q	-v	full	stat
     #  0	 0	no	yes
     #  0	 1	yes	yes
     #  1	--	no	no  (quiet overrules verbose)
     $verbose = $input->getOption('verbose');
     $quiet = $input->getOption('quiet');
     # restrict the verbosity level to VERBOSITY_VERBOSE
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
         $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     }
     if ($quiet) {
         $verbose = false;
     }
     # check quantity of users to be process and show it on the command line
     $users_total = count($users);
     if ($users_total === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     } else {
         if ($users_total > 1) {
             $output->writeln("\nScanning files for {$users_total} users");
         }
     }
     $this->initTools();
     $user_count = 0;
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $path = $inputPath ? $inputPath : '/' . $user;
         $user_count += 1;
         if ($this->userManager->userExists($user)) {
             # add an extra line when verbose is set to optical seperate users
             if ($verbose) {
                 $output->writeln("");
             }
             $output->writeln("Starting scan for user {$user_count} out of {$users_total} ({$user})");
             # full: printout data if $verbose was set
             $this->scanFiles($user, $path, $verbose, $output);
         } else {
             $output->writeln("<error>Unknown user {$user_count} {$user}</error>");
         }
         # check on each user if there was a user interrupt (ctrl-c) and exit foreach
         if ($this->hasBeenInterrupted()) {
             break;
         }
     }
     # stat: printout statistics if $quiet was not set
     if (!$quiet) {
         $this->presentStats($output);
     }
 }