r106235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106234‎ | r106235 | r106236 >
Date:19:35, 14 December 2011
Author:laner
Status:ok (Comments)
Tags:openstack 
Comment:
Add membership and role dialog to project creation.
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.i18n.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaProject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
@@ -58,6 +58,23 @@
5959 'section' => 'project/info',
6060 'name' => 'projectname',
6161 );
 62+ $projectInfo['member'] = array(
 63+ 'type' => 'text',
 64+ 'label-message' => 'openstackmanager-member',
 65+ 'default' => '',
 66+ 'section' => 'project/membership',
 67+ 'name' => 'member',
 68+ );
 69+ foreach ( OpenStackNovaProject::$rolenames as $rolename ) {
 70+ $role_keys["$rolename"] = $rolename;
 71+ }
 72+ $projectInfo['roles'] = array(
 73+ 'type' => 'multiselect',
 74+ 'label-message' => 'openstackmanager-roles',
 75+ 'section' => 'project/membership',
 76+ 'options' => $role_keys,
 77+ 'name' => 'roles',
 78+ );
6279
6380 $projectInfo['action'] = array(
6481 'type' => 'hidden',
@@ -299,7 +316,18 @@
300317 return true;
301318 }
302319 $project = OpenStackNovaProject::getProjectByName( $formData['projectname'] );
303 - $project->editArticle();
 320+ $members = explode( ',', $formData['member'] );
 321+ foreach ( $members as $member ) {
 322+ $project->addMember( $formData['member'] );
 323+ }
 324+ $roles = $project->getRoles();
 325+ foreach ( $roles as $role ) {
 326+ if ( in_array( $role->getRoleName(), $formData['roles'] ) ) {
 327+ foreach ( $members as $member ) {
 328+ $role->addMember( $member );
 329+ }
 330+ }
 331+ }
304332 # Create a default security group for this project, and add configured default rules
305333 $groupname = 'default';
306334 # Change the connection to reference this project
@@ -343,6 +371,7 @@
344372 }
345373 # Reset connection to default
346374 $this->adminNova->configureConnection();
 375+ $project->editArticle();
347376 $wgOut->addWikiMsg( 'openstackmanager-createdproject' );
348377 $sk = $wgOut->getSkin();
349378 $out = '<br />';
@@ -385,12 +414,15 @@
386415 global $wgOut;
387416
388417 $project = new OpenStackNovaProject( $formData['projectname'] );
389 - $success = $project->addMember( $formData['member'] );
390 - if ( $success ) {
391 - $project->editArticle();
392 - $wgOut->addWikiMsg( 'openstackmanager-addedto', $formData['member'], $formData['projectname'] );
393 - } else {
394 - $wgOut->addWikiMsg( 'openstackmanager-failedtoadd', $formData['member'], $formData['projectname'] );
 418+ $members = explode( ',', $formData['member'] );
 419+ foreach ( $members as $member ) {
 420+ $success = $project->addMember( $member );
 421+ if ( $success ) {
 422+ $project->editArticle();
 423+ $wgOut->addWikiMsg( 'openstackmanager-addedto', $formData['member'], $formData['projectname'] );
 424+ } else {
 425+ $wgOut->addWikiMsg( 'openstackmanager-failedtoadd', $formData['member'], $formData['projectname'] );
 426+ }
395427 }
396428 $sk = $wgOut->getSkin();
397429 $out = '<br />';
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php
@@ -185,6 +185,7 @@
186186 'openstackmanager-failedtoremove' => 'Failed to remove $1 from $2.',
187187 'openstackmanager-novaproject-project' => 'Project',
188188 'openstackmanager-novaproject-info' => 'Project information',
 189+ 'openstackmanager-novaproject-membership' => 'Project membership',
189190
190191 'openstackmanager-roles' => 'Roles',
191192 'openstackmanager-rolename' => 'Role name',

Follow-up revisions

RevisionCommit summaryAuthorDate
r106519followup r106235 - Add message documentationmah19:03, 17 December 2011
r107240Followup r106235...reedy23:20, 24 December 2011

Comments

#Comment by Siebrand (talk | contribs)   20:06, 14 December 2011

Please add message documentation for the newly added messages. Thanks.

Status & tagging log