示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
         $shippedFilter = $input->getOption('shipped') === 'true';
     } else {
         $shippedFilter = null;
     }
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if ($shippedFilter !== null && \OC_App::isShipped($app) !== $shippedFilter) {
             continue;
         }
         if ($this->manager->isInstalled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if ($this->manager->isInstalled($appId)) {
         try {
             $this->manager->disableApp($appId);
             $output->writeln($appId . ' disabled');
         } catch (\Exception $e) {
             $output->writeln($e->getMessage());
             return 2;
         }
     } else {
         $output->writeln('No such app enabled: ' . $appId);
     }
 }
示例#3
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * Shows the albums and pictures at the root folder or a message if
  * there are no pictures.
  *
  * This is the entry page for logged-in users accessing the app from
  * within ownCloud.
  * A TemplateResponse response uses a template from the templates folder
  * and parameters provided here to build the page users will see
  *
  * @return TemplateResponse
  */
 public function index()
 {
     $appName = $this->appName;
     if ($this->appManager->isInstalled('gallery')) {
         $message = 'You need to disable the Pictures app before being able to use the Gallery+ app';
         return $this->htmlError($this->urlGenerator, $appName, new \Exception($message));
     } else {
         // Parameters sent to the template
         $params = ['appName' => $appName];
         // Will render the page using the template found in templates/index.php
         $response = new TemplateResponse($appName, 'index', $params);
         $this->addContentSecurityToResponse($response);
         return $response;
     }
 }
示例#4
0
 /**
  * @param MapperEvent $event
  */
 public function mapperEvent(MapperEvent $event)
 {
     $tagIds = $event->getTags();
     if ($event->getObjectType() !== 'files' || empty($tagIds) || !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN]) || !$this->appManager->isInstalled('activity')) {
         // System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy)
         return;
     }
     try {
         $tags = $this->tagManager->getTagsByIds($tagIds);
     } catch (TagNotFoundException $e) {
         // User assigned/unassigned a non-existing tag, ignore...
         return;
     }
     if (empty($tags)) {
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getObjectId());
         if (!empty($nodes)) {
             /** @var Node $node */
             $node = array_shift($nodes);
             $path = $node->getPath();
             if (strpos($path, '/' . $owner . '/files/') === 0) {
                 $path = substr($path, strlen('/' . $owner . '/files'));
             }
             // Get all users that have access to the mount point
             $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
         }
     }
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor)->setObject($event->getObjectType(), $event->getObjectId());
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         foreach ($tags as $tag) {
             if ($event->getEvent() === MapperEvent::EVENT_ASSIGN) {
                 $activity->setSubject(Extension::ASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
             } else {
                 if ($event->getEvent() === MapperEvent::EVENT_UNASSIGN) {
                     $activity->setSubject(Extension::UNASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
                 }
             }
             $this->activityManager->publish($activity);
         }
     }
 }
示例#5
0
 /**
  * @param CommentsEvent $event
  */
 public function commentEvent(CommentsEvent $event)
 {
     if ($event->getComment()->getObjectType() !== 'files' || !in_array($event->getEvent(), [CommentsEvent::EVENT_ADD]) || !$this->appManager->isInstalled('activity')) {
         // Comment not for file, not adding a comment or no activity-app enabled (save the energy)
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getComment()->getObjectId());
         if (!empty($nodes)) {
             /** @var Node $node */
             $node = array_shift($nodes);
             $path = $node->getPath();
             if (strpos($path, '/' . $owner . '/files/') === 0) {
                 $path = substr($path, strlen('/' . $owner . '/files'));
             }
             // Get all users that have access to the mount point
             $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
         }
     }
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor)->setObject($event->getComment()->getObjectType(), $event->getComment()->getObjectId())->setMessage(Extension::ADD_COMMENT_MESSAGE, [$event->getComment()->getId()]);
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         $activity->setSubject(Extension::ADD_COMMENT_SUBJECT, [$actor, $path]);
         $this->activityManager->publish($activity);
     }
 }
示例#6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (!\OC_App::getAppPath($appId)) {
         $output->writeln($appId . ' not found');
         return 1;
     }
     $groups = $input->getOption('groups');
     if ($this->manager->isInstalled($appId) && empty($groups)) {
         $output->writeln($appId . ' is already enabled');
     }
     if (empty($groups)) {
         \OC_App::enable($appId);
         $output->writeln($appId . ' enabled');
     } else {
         \OC_App::enable($appId, $groups);
         $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups));
     }
     return 0;
 }
示例#7
0
 public function testIsInstalledEnabledForGroups()
 {
     $this->appConfig->setValue('test', 'enabled', '["foo"]');
     $this->assertTrue($this->manager->isInstalled('test'));
 }