@@ -16,21 +16,21 @@ class APIController extends Controller
1616 * Get the LDAP server BASE DNs
1717 *
1818 * @return Collection
19- * @throws LdapRecord\Query\ObjectNotFoundException
19+ * @throws \ LdapRecord\Query\ObjectNotFoundException
2020 */
2121 public function bases (): Collection
2222 {
2323 $ base = Server::baseDNs () ?: collect ();
2424
25- return $ base-> transform ( function ( $ item ) {
26- return [
27- ' title ' => $ item -> getRdn (),
28- ' item ' =>$ item ->getDNSecure (),
29- ' lazy ' =>TRUE ,
30- ' icon ' =>' fa-fw fas fa-sitemap ' ,
31- ' tooltip ' =>$ item -> getDn () ,
32- ];
33- } );
25+ return $ base
26+ -> transform ( fn ( $ item )=>
27+ [
28+ ' title ' =>$ item ->getRdn (),
29+ ' item ' =>$ item -> getDNSecure () ,
30+ ' lazy ' =>TRUE ,
31+ ' icon ' =>' fa-fw fas fa-sitemap ' ,
32+ ' tooltip ' => $ item -> getDn (),
33+ ] );
3434 }
3535
3636 /**
@@ -41,19 +41,31 @@ public function children(Request $request): Collection
4141 {
4242 $ levels = $ request ->query ('depth ' ,1 );
4343 $ dn = Crypt::decryptString ($ request ->query ('key ' ));
44+
45+ // Sometimes our key has a command, so we'll ignore it
46+ if (str_starts_with ($ dn ,'* ' ) && ($ x =strpos ($ dn ,'| ' )))
47+ $ dn = substr ($ dn ,$ x +1 );
48+
4449 Log::debug (sprintf ('%s: Query [%s] - Levels [%d] ' ,__METHOD__ ,$ dn ,$ levels ));
4550
4651 return (config ('server ' ))
4752 ->children ($ dn )
48- ->transform (function ($ item ) {
49- return [
53+ ->transform (fn ($ item )=>
54+ [
5055 'title ' =>$ item ->getRdn (),
5156 'item ' =>$ item ->getDNSecure (),
5257 'icon ' =>$ item ->icon (),
5358 'lazy ' =>Arr::get ($ item ->getAttribute ('hassubordinates ' ),0 ) == 'TRUE ' ,
5459 'tooltip ' =>$ item ->getDn (),
55- ];
56- });
60+ ])
61+ ->prepend (
62+ [
63+ 'title ' =>sprintf ('[%s] ' ,__ ('Create Entry ' )),
64+ 'item ' =>Crypt::encryptString (sprintf ('*%s|%s ' ,'create ' ,$ dn )),
65+ 'lazy ' =>FALSE ,
66+ 'icon ' =>'fas fa-fw fa-square-plus text-warning ' ,
67+ 'tooltip ' =>__ ('Create new LDAP item here ' ),
68+ ]);
5769 }
5870
5971 public function schema_view (Request $ request )
@@ -63,20 +75,20 @@ public function schema_view(Request $request)
6375 switch ($ request ->type ) {
6476 case 'objectclasses ' :
6577 return view ('fragment.schema.objectclasses ' )
66- ->with ('objectclasses ' ,$ server ->schema ('objectclasses ' )->sortBy (function ($ item ) { return strtolower ($ item ->name ); } ));
78+ ->with ('objectclasses ' ,$ server ->schema ('objectclasses ' )->sortBy (fn ($ item )=> strtolower ($ item ->name )));
6779
6880 case 'attributetypes ' :
6981 return view ('fragment.schema.attributetypes ' )
7082 ->with ('server ' ,$ server )
71- ->with ('attributetypes ' ,$ server ->schema ('attributetypes ' )->sortBy (function ($ item ) { return strtolower ($ item ->name ); } ));
83+ ->with ('attributetypes ' ,$ server ->schema ('attributetypes ' )->sortBy (fn ($ item )=> strtolower ($ item ->name )));
7284
7385 case 'ldapsyntaxes ' :
7486 return view ('fragment.schema.ldapsyntaxes ' )
75- ->with ('ldapsyntaxes ' ,$ server ->schema ('ldapsyntaxes ' )->sortBy (function ($ item ) { return strtolower ($ item ->description ); } ));
87+ ->with ('ldapsyntaxes ' ,$ server ->schema ('ldapsyntaxes ' )->sortBy (fn ($ item )=> strtolower ($ item ->description )));
7688
7789 case 'matchingrules ' :
7890 return view ('fragment.schema.matchingrules ' )
79- ->with ('matchingrules ' ,$ server ->schema ('matchingrules ' )->sortBy (function ($ item ) { return strtolower ($ item ->name ); } ));
91+ ->with ('matchingrules ' ,$ server ->schema ('matchingrules ' )->sortBy (fn ($ item )=> strtolower ($ item ->name )));
8092
8193 default :
8294 abort (404 );
0 commit comments