99
1010use OC \Core \Command \Base ;
1111use OCP \App \IAppManager ;
12+ use OCP \IGroupManager ;
1213use Stecman \Component \Symfony \Console \BashCompletion \CompletionContext ;
1314use Symfony \Component \Console \Input \InputInterface ;
1415use Symfony \Component \Console \Input \InputOption ;
1718class ListApps extends Base {
1819 public function __construct (
1920 protected IAppManager $ appManager ,
21+ protected IGroupManager $ groupManager ,
2022 ) {
2123 parent ::__construct ();
2224 }
@@ -83,7 +85,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8385
8486 sort ($ enabledApps );
8587 foreach ($ enabledApps as $ app ) {
86- $ apps ['enabled ' ][$ app ] = $ versions [$ app ] ?? true ;
88+ $ appDetails = $ versions [$ app ] ?? true ;
89+ $ appRestrictions = $ this ->appManager ->getAppRestriction ($ app );
90+
91+ if ($ appRestrictions !== []) {
92+ $ appDetails = $ this ->valueToString ($ appDetails , false ) . $ this ->formatAppRestrictions ($ appRestrictions );
93+ }
94+
95+ $ apps ['enabled ' ][$ app ] = $ appDetails ;
8796 }
8897 }
8998
@@ -100,6 +109,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100109 return 0 ;
101110 }
102111
112+ /**
113+ * @param list<string> $groupIds
114+ */
115+ private function formatAppRestrictions (array $ groupIds ): string {
116+ $ groups = array_map (fn (string $ groupId ): string => $ this ->groupManager ->get ($ groupId )?->getDisplayName() ?? $ groupId , $ groupIds );
117+
118+ return ' (enabled for groups: ' . implode (', ' , $ groups ) . ') ' ;
119+ }
120+
103121 /**
104122 * @param InputInterface $input
105123 * @param OutputInterface $output
0 commit comments