1010use wcf \data \wsdb \record \RecordList ;
1111use wcf \page \IWsdbPage ;
1212use wcf \page \TWsdbRecordPage ;
13+ use wcf \page \WsdbConnectionListPage ;
1314use wcf \system \exception \PermissionDeniedException ;
1415use wcf \system \form \builder \container \FormContainer ;
1516use wcf \system \form \builder \data \processor \CustomFormDataProcessor ;
2122use wcf \system \form \builder \IFormChildNode ;
2223use wcf \system \form \builder \IFormDocument ;
2324use wcf \system \request \LinkHandler ;
25+ use wcf \system \WCF ;
2426use wcf \system \wsdb \page \WsdbPageLocationManager ;
2527
2628/**
@@ -53,7 +55,7 @@ public function readParameters()
5355 $ this ->canViewRecords ();
5456 $ this ->readRecord ();
5557
56- if (!$ this ->getRecord ()->canEdit ()) {
58+ if (!$ this ->getRecord ()->canEdit () || ! $ this -> getDatabase ()-> enableConnection ) {
5759 throw new PermissionDeniedException ();
5860 }
5961 }
@@ -79,7 +81,7 @@ protected function createForm(): void
7981 FormContainer::create ('data ' )
8082 ->appendChildren ([
8183 SelectFormField::create ('referencedDatabaseID ' )
82- ->label ('Datenbank ' )
84+ ->label ('dev.hanashi.wsdb.connection.database ' )
8385 ->options ($ this ->getDatabaseOptions ())
8486 ->required (),
8587 ...$ this ->getRecordSelects (),
@@ -128,6 +130,22 @@ public function readData()
128130 );
129131 }
130132
133+ #[\Override]
134+ public function assignVariables (): void
135+ {
136+ parent ::assignVariables ();
137+
138+ WCF ::getTPL ()->assign ([
139+ 'connectionListLink ' => LinkHandler::getInstance ()->getControllerLink (
140+ WsdbConnectionListPage::class,
141+ [
142+ '__database ' => $ this ->getRecord ()->getDatabase ()->path ,
143+ 'object ' => $ this ->getRecord (),
144+ ]
145+ ),
146+ ]);
147+ }
148+
131149 /**
132150 * @return IFormChildNode[]
133151 */
@@ -199,7 +217,11 @@ private function getDatabases(): array
199217 $ databaseList ->sqlOrderBy = 'name ASC ' ;
200218 $ databaseList ->readObjects ();
201219
202- $ this ->databases = $ databaseList ->getObjects ();
220+ $ databases = \array_filter (
221+ $ databaseList ->getObjects (),
222+ static fn (Database $ database ): bool => $ database ->enableConnection
223+ );
224+ $ this ->databases = $ databases ;
203225 }
204226
205227 return $ this ->databases ;
@@ -234,6 +256,9 @@ private function getRecordsGroupedByDatabases(): array
234256
235257 $ groupedRecords = [];
236258 foreach ($ recordList as $ record ) {
259+ if (!$ record ->canEdit ()) {
260+ continue ;
261+ }
237262 $ groupedRecords [$ record ->databaseID ][$ record ->recordID ] = $ record ->getTitle ();
238263 }
239264 $ this ->groupedRecords = $ groupedRecords ;
0 commit comments