Robert Vogel has uploaded a new change for review. https://gerrit.wikimedia.org/r/223027
Change subject: New API: UserStore ...................................................................... New API: UserStore This is the first draft of the new UserStore api. It is going to replace the BsCommonAJAXInterface::getUserStoreData implementation Change-Id: I6895a12a059513f58ee00a1be89d3c1b4436d95f --- M BlueSpiceFoundation.php M includes/AutoLoader.php A includes/api/BSApiUserStore.php M resources/bluespice.extjs/BS/model/User.js 4 files changed, 51 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation refs/changes/27/223027/1 diff --git a/BlueSpiceFoundation.php b/BlueSpiceFoundation.php index 1248ff0..ef2f7c5 100644 --- a/BlueSpiceFoundation.php +++ b/BlueSpiceFoundation.php @@ -66,6 +66,7 @@ $wgAjaxExportList[] = 'BsCore::ajaxBSPing'; $wgAPIModules['bs-filebackend-store'] = 'BSApiFileBackendStore'; +$wgAPIModules['bs-user-store'] = 'BSApiUserStore'; //I18N MW1.23+ $wgMessagesDirs['BlueSpice'] = __DIR__ . '/i18n/core'; diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 99d11e9..89604a1 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -56,6 +56,7 @@ $GLOBALS['wgAutoloadClasses']['BSApiTasksBase'] = __DIR__."/api/BSApiTasksBase.php"; $GLOBALS['wgAutoloadClasses']['BSApiExtJSStoreBase'] = __DIR__."/api/BSApiExtJSStoreBase.php"; $GLOBALS['wgAutoloadClasses']['BSApiFileBackendStore'] = __DIR__."/api/BSApiFileBackendStore.php"; +$GLOBALS['wgAutoloadClasses']['BSApiUserStore'] = __DIR__."/api/BSApiUserStore.php"; //adapter $GLOBALS['wgAutoloadClasses']['BsExtensionMW'] = __DIR__."/ExtensionMW.class.php"; diff --git a/includes/api/BSApiUserStore.php b/includes/api/BSApiUserStore.php new file mode 100644 index 0000000..e8875e2 --- /dev/null +++ b/includes/api/BSApiUserStore.php @@ -0,0 +1,42 @@ +<?php + +class BSApiUserStore extends BSApiExtJSStoreBase { + + protected function makeData($sQuery = '') { + $dbr = $this->getDB(); + + $aGroups = array(); + $groupsRes = $dbr->select( 'user_groups', '*' ); + foreach( $groupsRes as $row ) { + if( !isset( $aGroups[$row->ug_user] ) ) { + $aGroups[$row->ug_user] = array(); + } + $aGroups[$row->ug_user][] = $row->ug_group; + } + + //TODO: It would be very cool to have the permissions as a filterable + //field. Unfortunately this requires some context information from the + //client. I.e. The page/namespace for which the permissions should be + //calculated. This would also be very expensive and a potential + //security issue. + + $aData = array(); + $userRes = $dbr->select( 'user', '*' ); + foreach( $userRes as $row ) { + $aData[] = (object)array( + 'user_id' => $row->user_id, + 'user_name' => $row->user_name, + 'user_real_name' => $row->user_real_name, + 'user_registration' => $row->user_registration, + 'user_editcount' => $row->user_editcount, + 'groups' => isset( $aGroups[$row->user_id] ) ? $aGroups[$row->user_id] : array(), + + //legacy fields + 'display_name' => $row->user_real_name == null ? $row->user_name : $row->user_real_name, + 'page_prefixed_text' => Title::makeTitle( NS_USER, $row->user_name )->getPrefixedText() + ); + } + + return $aData; + } +} \ No newline at end of file diff --git a/resources/bluespice.extjs/BS/model/User.js b/resources/bluespice.extjs/BS/model/User.js index bb219c4..e164b0d 100644 --- a/resources/bluespice.extjs/BS/model/User.js +++ b/resources/bluespice.extjs/BS/model/User.js @@ -4,7 +4,13 @@ fields: [ { name: 'user_id', type: 'int' }, { name: 'user_name', type: 'string' }, + { name: 'user_real_name', type: 'string' }, + { name: 'user_registration', type: 'date', defaultValue: '19700101000000', dateFormat: 'YmdHis' }, + { name: 'user_editcount', type: 'int' }, + { name: 'groups', type: 'array', defaultValue: [] }, + + //legacy fields { name: 'display_name', type: 'string' }, - { name: 'page_prefixed_text', type: 'string' }, + { name: 'page_prefixed_text', type: 'string' } ] }); -- To view, visit https://gerrit.wikimedia.org/r/223027 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6895a12a059513f58ee00a1be89d3c1b4436d95f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits