r81008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81007‎ | r81008 | r81009 >
Date:23:50, 25 January 2011
Author:laner
Status:deferred
Tags:
Comment:
* Some code cleanup
* Change the project search to filter on owner=*, as that is what differentiates projects from roles
* Modify Special:NovaProject to allow project members to add and remove members to/from projects they are members of
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackNovaUser.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaProject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -16,14 +16,13 @@
1717 $this->notLoggedIn();
1818 return true;
1919 }
20 - $user = new OpenStackNovaUser();
21 - if ( ! $user->exists() ) {
 20+ $this->userLDAP = new OpenStackNovaUser();
 21+ if ( ! $this->userLDAP->exists() ) {
2222 $this->noCredentials();
2323 return true;
2424 }
25 - $this->userLDAP = new OpenStackNovaUser();
2625 $project = $wgRequest->getVal( 'project' );
27 - $userCredentials = $user->getCredentials( $project );
 26+ $userCredentials = $this->userLDAP->getCredentials( $project );
2827 $this->userNova = new OpenStackNovaController( $userCredentials );
2928 $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
3029 $this->adminNova = new OpenStackNovaController( $adminCredentials );
@@ -31,25 +30,25 @@
3231 $action = $wgRequest->getVal( 'action' );
3332
3433 if ( $action == "create" ) {
35 - if ( ! $user->inProject( $project ) ) {
 34+ if ( ! $this->userLDAP->inProject( $project ) ) {
3635 $this->notInProject();
3736 return true;
3837 }
3938 $this->createInstance();
4039 } else if ( $action == "delete" ) {
41 - if ( ! $user->inProject( $project ) ) {
 40+ if ( ! $this->userLDAP->inProject( $project ) ) {
4241 $this->notInProject();
4342 return true;
4443 }
4544 $this->deleteInstance();
4645 } else if ( $action == "rename" ) {
47 - if ( ! $user->inProject( $project ) ) {
 46+ if ( ! $this->userLDAP->inProject( $project ) ) {
4847 $this->notInProject();
4948 return true;
5049 }
5150 $this->renameInstance();
5251 } else if ( $action == "configure" ) {
53 - if ( ! $user->inProject( $project ) ) {
 52+ if ( ! $this->userLDAP->inProject( $project ) ) {
5453 $this->notInProject();
5554 return true;
5655 }
Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
@@ -2,6 +2,7 @@
33 class SpecialNovaProject extends SpecialNova {
44
55 var $userNova, $adminNova;
 6+ var $userLDAP;
67
78 function __construct() {
89 parent::__construct( 'NovaProject', 'manageproject' );
@@ -16,16 +17,11 @@
1718 function execute( $par ) {
1819 global $wgRequest, $wgUser;
1920
20 - if ( !$this->userCanExecute( $wgUser ) ) {
21 - $this->displayRestrictionError();
22 - return false;
23 - }
24 -
2521 if ( ! $wgUser->isLoggedIn() ) {
2622 $this->notLoggedIn();
2723 return false;
2824 }
29 -
 25+ $this->userLDAP = new OpenStackNovaUser();
3026 $action = $wgRequest->getVal( 'action' );
3127 if ( $action == "create" ) {
3228 $this->createProject();
@@ -45,8 +41,13 @@
4642 */
4743 function createProject() {
4844 global $wgRequest, $wgOut;
 45+ global $wgUser;
4946
5047 $this->setHeaders();
 48+ if ( !$this->userCanExecute( $wgUser ) ) {
 49+ $this->displayRestrictionError();
 50+ return false;
 51+ }
5152 $wgOut->setPagetitle( wfMsg( 'openstackmanager-createproject' ) );
5253
5354 $projectInfo = array();
@@ -76,11 +77,16 @@
7778 */
7879 function addMember() {
7980 global $wgRequest, $wgOut;
 81+ global $wgUser;
8082
8183 $this->setHeaders();
8284 $wgOut->setPagetitle( wfMsg( 'openstackmanager-addmember' ) );
8385
8486 $project = $wgRequest->getText( 'projectname' );
 87+ if ( !$this->userCanExecute( $wgUser ) && !$this->userLDAP->inProject( $project ) ) {
 88+ $this->notInProject();
 89+ return false;
 90+ }
8591 $projectInfo = array();
8692 $projectInfo['member'] = array(
8793 'type' => 'text',
@@ -111,11 +117,16 @@
112118 */
113119 function deleteMember() {
114120 global $wgRequest, $wgOut;
 121+ global $wgUser;
115122
116123 $this->setHeaders();
117124 $wgOut->setPagetitle( wfMsg( 'openstackmanager-removemember' ) );
118125
119126 $projectname = $wgRequest->getText( 'projectname' );
 127+ if ( !$this->userCanExecute( $wgUser ) && !$this->userLDAP->inProject( $projectname ) ) {
 128+ $this->notInProject();
 129+ return false;
 130+ }
120131 $project = OpenStackNovaProject::getProjectByName( $projectname );
121132 $projectmembers = $project->getMembers();
122133 $member_keys = array();
@@ -152,8 +163,13 @@
153164 */
154165 function deleteProject() {
155166 global $wgOut, $wgRequest;
 167+ global $wgUser;
156168
157169 $this->setHeaders();
 170+ if ( !$this->userCanExecute( $wgUser ) ) {
 171+ $this->displayRestrictionError();
 172+ return false;
 173+ }
158174 $wgOut->setPagetitle( wfMsg( 'openstackmanager-deleteproject' ) );
159175
160176 $project = $wgRequest->getText( 'projectname' );
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php
@@ -147,7 +147,7 @@
148148
149149 $this->connect();
150150
151 - $filter = "(&(cn=$project)(member=$this->userDN))";
 151+ $filter = "(&(cn=$project)(member=$this->userDN)(owner=*))";
152152 wfSuppressWarnings();
153153 $result = ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPProjectBaseDN, $filter );
154154 wfRestoreWarnings();

Status & tagging log