Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php |
— | — | @@ -106,16 +106,19 @@ |
107 | 107 | $this->setHeaders(); |
108 | 108 | $wgOut->setPagetitle( wfMsg( 'openstackmanager-removemember' ) ); |
109 | 109 | |
110 | | - $member = $wgRequest->getText( 'member' ); |
111 | | - $project = $wgRequest->getText( 'projectname' ); |
112 | | - if ( ! $wgRequest->wasPosted() ) { |
113 | | - $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removememberconfirm', array(), $member, $project ) ); |
114 | | - $wgOut->addHTML( $out ); |
| 110 | + $projectname = $wgRequest->getText( 'projectname' ); |
| 111 | + $project = OpenStackNovaProject::getProjectByName( $projectname ); |
| 112 | + $projectmembers = $project->getMembers(); |
| 113 | + $member_keys = array(); |
| 114 | + foreach ( $projectmembers as $projectmember ) { |
| 115 | + $member_keys["$projectmember"] = $projectmember; |
115 | 116 | } |
116 | 117 | $projectInfo = Array(); |
117 | | - $projectInfo['member'] = array( |
118 | | - 'type' => 'hidden', |
119 | | - 'default' => $member, |
| 118 | + $projectInfo['members'] = array( |
| 119 | + 'type' => 'multiselect', |
| 120 | + 'label-message' => 'openstackmanager-member', |
| 121 | + 'section' => 'project/info', |
| 122 | + 'options' => $member_keys, |
120 | 123 | ); |
121 | 124 | $projectInfo['action'] = array( |
122 | 125 | 'type' => 'hidden', |
— | — | @@ -123,7 +126,7 @@ |
124 | 127 | ); |
125 | 128 | $projectInfo['projectname'] = array( |
126 | 129 | 'type' => 'hidden', |
127 | | - 'default' => $project, |
| 130 | + 'default' => $projectname, |
128 | 131 | ); |
129 | 132 | |
130 | 133 | $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' ); |
— | — | @@ -188,10 +191,7 @@ |
189 | 192 | $projectMembers = $project->getMembers(); |
190 | 193 | $memberOut = ''; |
191 | 194 | foreach ( $projectMembers as $projectMember ) { |
192 | | - $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-removemember' ), array(), |
193 | | - array( 'action' => 'deletemember', 'projectname' => $projectName, 'member' => $projectMember ), array() ); |
194 | | - $projectMemberOut = htmlentities( $projectMember ) . ' (' . $link . ')'; |
195 | | - $memberOut .= Html::rawElement( 'li', array(), $projectMemberOut ); |
| 195 | + $memberOut .= Html::rawElement( 'li', array(), $projectMember ); |
196 | 196 | } |
197 | 197 | if ( $memberOut ) { |
198 | 198 | $memberOut = Html::rawElement( 'ul', array(), $memberOut ); |
— | — | @@ -205,16 +205,16 @@ |
206 | 206 | $roleMembers = ''; |
207 | 207 | $specialRoleTitle = Title::newFromText( 'Special:NovaRole' ); |
208 | 208 | foreach ( $role->getMembers() as $member ) { |
209 | | - $link = $sk->link( $specialRoleTitle, wfMsg( 'openstackmanager-removerolemember' ), array(), |
210 | | - array( 'action' => 'removemember', 'projectname' => $projectName, 'rolename' => $role->getRoleName(), 'member' => $member, 'referrer' => 'Special:NovaProject' ), array() ); |
211 | | - $member = $member . ' (' . $link . ')'; |
212 | 209 | $roleMembers .= Html::rawElement( 'li', array(), $member ); |
213 | 210 | } |
214 | 211 | $roleMembers = Html::rawElement( 'ul', array(), $roleMembers ); |
215 | 212 | $roleOut .= Html::rawElement( 'td', array(), $roleMembers ); |
216 | 213 | $link = $sk->link( $specialRoleTitle, wfMsg( 'openstackmanager-addrolemember' ), array(), |
217 | | - array( 'action' => 'addmember', 'projectname' => $projectName, 'rolename' => $role->getRoleName(), 'referrer' => 'Special:NovaProject' ), array() ); |
| 214 | + array( 'action' => 'addmember', 'projectname' => $projectName, 'rolename' => $role->getRoleName(), 'returnto' => 'Special:NovaProject' ), array() ); |
218 | 215 | $actions = Html::rawElement( 'li', array(), $link ); |
| 216 | + $link = $sk->link( $specialRoleTitle, wfMsg( 'openstackmanager-removerolemember' ), array(), |
| 217 | + array( 'action' => 'deletemember', 'projectname' => $projectName, 'rolename' => $role->getRoleName(), 'returnto' => 'Special:NovaProject' ), array() ); |
| 218 | + $actions .= Html::rawElement( 'li', array(), $link ); |
219 | 219 | $actions = Html::rawElement( 'ul', array(), $actions ); |
220 | 220 | $roleOut .= Html::rawElement( 'td', array(), $actions ); |
221 | 221 | $rolesOut .= Html::rawElement( 'tr', array(), $roleOut ); |
— | — | @@ -227,6 +227,9 @@ |
228 | 228 | $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-addmember' ), array(), |
229 | 229 | array( 'action' => 'addmember', 'projectname' => $projectName ), array() ); |
230 | 230 | $actions .= Html::rawElement( 'li', array(), $link ); |
| 231 | + $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-removemember' ), array(), |
| 232 | + array( 'action' => 'deletemember', 'projectname' => $projectName ), array() ); |
| 233 | + $actions .= Html::rawElement( 'li', array(), $link ); |
231 | 234 | $actions = Html::rawElement( 'ul', array(), $actions ); |
232 | 235 | $projectOut .= Html::rawElement( 'td', array(), $actions ); |
233 | 236 | $projectsOut .= Html::rawElement( 'tr', array(), $projectOut ); |
— | — | @@ -297,14 +300,21 @@ |
298 | 301 | global $wgOut, $wgUser; |
299 | 302 | |
300 | 303 | $project = new OpenStackNovaProject( $formData['projectname'] ); |
301 | | - $success = $project->deleteMember( $formData['member'] ); |
302 | | - if ( $success ) { |
303 | | - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removedfrom', array(), $formData['member'], |
304 | | - $formData['projectname'] ) ); |
305 | | - } else { |
306 | | - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoremove', array(), $formData['member'], |
307 | | - $formData['projectname'] ) ); |
| 304 | + $project = OpenStackNovaProject::getProjectByName( $formData['projectname'] ); |
| 305 | + if ( ! $project ) { |
| 306 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistentproject' ) ); |
| 307 | + $wgOut->addHTML( $out ); |
| 308 | + return true; |
308 | 309 | } |
| 310 | + $out = ''; |
| 311 | + foreach ( $formData['members'] as $member ) { |
| 312 | + $success = $project->deleteMember( $member ); |
| 313 | + if ( $success ) { |
| 314 | + $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removedfrom', array(), $formData['member'], $formData['projectname'] ) ); |
| 315 | + } else { |
| 316 | + $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoremove', array(), $formData['member'], $formData['projectname'] ) ); |
| 317 | + } |
| 318 | + } |
309 | 319 | $out .= '<br />'; |
310 | 320 | $sk = $wgUser->getSkin(); |
311 | 321 | $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() ); |
Index: trunk/extensions/OpenStackManager/special/SpecialNovaRole.php |
— | — | @@ -0,0 +1,291 @@ |
| 2 | +<?php |
| 3 | +class SpecialNovaRole extends SpecialNova { |
| 4 | + |
| 5 | + var $userNova, $adminNova; |
| 6 | + |
| 7 | + function __construct() { |
| 8 | + parent::__construct( 'NovaRole', 'manageproject' ); |
| 9 | + |
| 10 | + global $wgOpenStackManagerNovaAdminKeys; |
| 11 | + |
| 12 | + $this->userLDAP = new OpenStackNovaUser(); |
| 13 | + $adminCredentials = $wgOpenStackManagerNovaAdminKeys; |
| 14 | + $this->adminNova = new OpenStackNovaController( $adminCredentials ); |
| 15 | + } |
| 16 | + |
| 17 | + function execute( $par ) { |
| 18 | + global $wgRequest, $wgUser; |
| 19 | + |
| 20 | + if ( !$this->userCanExecute( $wgUser ) ) { |
| 21 | + $this->displayRestrictionError(); |
| 22 | + return false; |
| 23 | + } |
| 24 | + |
| 25 | + if ( ! $wgUser->isLoggedIn() ) { |
| 26 | + $this->notLoggedIn(); |
| 27 | + return false; |
| 28 | + } |
| 29 | + |
| 30 | + $action = $wgRequest->getVal( 'action' ); |
| 31 | + if ( $action == "addmember" ) { |
| 32 | + $this->addMember(); |
| 33 | + } else if ( $action == "deletemember" ) { |
| 34 | + $this->deleteMember(); |
| 35 | + } else { |
| 36 | + $this->listGlobalRoles(); |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + function addMember() { |
| 41 | + global $wgRequest, $wgOut; |
| 42 | + |
| 43 | + $this->setHeaders(); |
| 44 | + $wgOut->setPagetitle( wfMsg( 'openstackmanager-addmember' ) ); |
| 45 | + |
| 46 | + $roleInfo = Array(); |
| 47 | + $rolename = $wgRequest->getText( 'rolename' ); |
| 48 | + $projectname = $wgRequest->getText( 'projectname' ); |
| 49 | + if ( $projectname ) { |
| 50 | + $project = OpenStackNovaProject::getProjectByName( $projectname ); |
| 51 | + $projectmembers = $project->getMembers(); |
| 52 | + $role = OpenStackNovaRole::getProjectRoleByName( $rolename, $projectname ); |
| 53 | + $rolemembers = $role->getMembers(); |
| 54 | + $member_keys = array(); |
| 55 | + foreach ( $projectmembers as $projectmember ) { |
| 56 | + if ( ! in_array( $projectmember, $rolemembers ) ) { |
| 57 | + $member_keys["$projectmember"] = $projectmember; |
| 58 | + } |
| 59 | + } |
| 60 | + if ( ! $member_keys ) { |
| 61 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nomemberstoadd' ) ); |
| 62 | + $wgOut->addHTML( $out ); |
| 63 | + return true; |
| 64 | + } |
| 65 | + $roleInfo['members'] = array( |
| 66 | + 'type' => 'multiselect', |
| 67 | + 'label-message' => 'openstackmanager-member', |
| 68 | + 'options' => $member_keys, |
| 69 | + 'section' => 'role/info', |
| 70 | + ); |
| 71 | + } else { |
| 72 | + $roleInfo['members'] = array( |
| 73 | + 'type' => 'text', |
| 74 | + 'label-message' => 'openstackmanager-member', |
| 75 | + 'default' => '', |
| 76 | + 'section' => 'role/info', |
| 77 | + ); |
| 78 | + } |
| 79 | + $roleInfo['action'] = array( |
| 80 | + 'type' => 'hidden', |
| 81 | + 'default' => 'addmember', |
| 82 | + ); |
| 83 | + $roleInfo['rolename'] = array( |
| 84 | + 'type' => 'hidden', |
| 85 | + 'default' => $rolename, |
| 86 | + ); |
| 87 | + $roleInfo['projectname'] = array( |
| 88 | + 'type' => 'hidden', |
| 89 | + 'default' => $projectname, |
| 90 | + ); |
| 91 | + $roleInfo['returnto'] = array( |
| 92 | + 'type' => 'hidden', |
| 93 | + 'default' => $wgRequest->getText('returnto'), |
| 94 | + ); |
| 95 | + |
| 96 | + $roleForm = new SpecialNovaRoleForm( $roleInfo, 'openstackmanager-novarole' ); |
| 97 | + $roleForm->setTitle( SpecialPage::getTitleFor( 'NovaRole' ) ); |
| 98 | + $roleForm->setSubmitID( 'novarole-form-addmembersubmit' ); |
| 99 | + $roleForm->setSubmitCallback( array( $this, 'tryAddMemberSubmit' ) ); |
| 100 | + $roleForm->show(); |
| 101 | + |
| 102 | + return true; |
| 103 | + } |
| 104 | + |
| 105 | + function deleteMember() { |
| 106 | + global $wgRequest, $wgOut; |
| 107 | + |
| 108 | + $this->setHeaders(); |
| 109 | + $wgOut->setPagetitle( wfMsg( 'openstackmanager-removerolemember' ) ); |
| 110 | + |
| 111 | + $rolename = $wgRequest->getText( 'rolename' ); |
| 112 | + $projectname = $wgRequest->getText( 'projectname' ); |
| 113 | + if ( $projectname ) { |
| 114 | + $project = OpenStackNovaProject::getProjectByName( $projectname ); |
| 115 | + $projectmembers = $project->getMembers(); |
| 116 | + $role = OpenStackNovaRole::getProjectRoleByName( $rolename, $projectname ); |
| 117 | + $rolemembers = $role->getMembers(); |
| 118 | + $member_keys = array(); |
| 119 | + foreach ( $projectmembers as $projectmember ) { |
| 120 | + if ( in_array( $projectmember, $rolemembers ) ) { |
| 121 | + $member_keys["$projectmember"] = $projectmember; |
| 122 | + } |
| 123 | + } |
| 124 | + } else { |
| 125 | + $role = OpenStackNovaRole::getGlobalRoleByName( $rolename ); |
| 126 | + $rolemembers = $role->getMembers(); |
| 127 | + $member_keys = array(); |
| 128 | + foreach ( $rolemembers as $rolemember ) { |
| 129 | + $member_keys["$rolemember"] = $rolemember; |
| 130 | + } |
| 131 | + } |
| 132 | + if ( ! $member_keys ) { |
| 133 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nomemberstoremove' ) ); |
| 134 | + $wgOut->addHTML( $out ); |
| 135 | + return true; |
| 136 | + } |
| 137 | + $roleInfo = Array(); |
| 138 | + $roleInfo['members'] = array( |
| 139 | + 'type' => 'multiselect', |
| 140 | + 'label-message' => 'openstackmanager-member', |
| 141 | + 'options' => $member_keys, |
| 142 | + 'section' => 'role/info', |
| 143 | + ); |
| 144 | + $roleInfo['action'] = array( |
| 145 | + 'type' => 'hidden', |
| 146 | + 'default' => 'deletemember', |
| 147 | + ); |
| 148 | + $roleInfo['rolename'] = array( |
| 149 | + 'type' => 'hidden', |
| 150 | + 'default' => $rolename, |
| 151 | + ); |
| 152 | + $roleInfo['projectname'] = array( |
| 153 | + 'type' => 'hidden', |
| 154 | + 'default' => $projectname, |
| 155 | + ); |
| 156 | + $roleInfo['returnto'] = array( |
| 157 | + 'type' => 'hidden', |
| 158 | + 'default' => $wgRequest->getText('returnto'), |
| 159 | + ); |
| 160 | + |
| 161 | + $roleForm = new SpecialNovaRoleForm( $roleInfo, 'openstackmanager-novarole' ); |
| 162 | + $roleForm->setTitle( SpecialPage::getTitleFor( 'NovaRole' ) ); |
| 163 | + $roleForm->setSubmitID( 'novarole-form-deletemembersubmit' ); |
| 164 | + $roleForm->setSubmitCallback( array( $this, 'tryDeleteMemberSubmit' ) ); |
| 165 | + $roleForm->show(); |
| 166 | + |
| 167 | + return true; |
| 168 | + } |
| 169 | + |
| 170 | + function listGlobalRoles() { |
| 171 | + global $wgOut, $wgUser; |
| 172 | + |
| 173 | + $this->setHeaders(); |
| 174 | + $wgOut->setPagetitle( wfMsg( 'openstackmanager-rolelist' ) ); |
| 175 | + |
| 176 | + $out = ''; |
| 177 | + $sk = $wgUser->getSkin(); |
| 178 | + $rolesOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-rolename' ) ); |
| 179 | + $rolesOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-members' ) ); |
| 180 | + $rolesOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) ); |
| 181 | + $roles = OpenStackNovaRole::getAllGlobalRoles(); |
| 182 | + if ( ! $roles ) { |
| 183 | + $rolesOut = ''; |
| 184 | + } |
| 185 | + foreach ( $roles as $role ) { |
| 186 | + $roleName = $role->getRoleName(); |
| 187 | + $roleOut = Html::element( 'td', array(), $roleName ); |
| 188 | + $roleMembers = $role->getMembers(); |
| 189 | + $memberOut = ''; |
| 190 | + foreach ( $roleMembers as $roleMember ) { |
| 191 | + $memberOut .= Html::rawElement( 'li', array(), $roleMember ); |
| 192 | + } |
| 193 | + if ( $memberOut ) { |
| 194 | + $memberOut = Html::rawElement( 'ul', array(), $memberOut ); |
| 195 | + } |
| 196 | + $roleOut .= Html::rawElement( 'td', array(), $memberOut ); |
| 197 | + $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-addrolemember' ), array(), array( 'action' => 'addmember', 'rolename' => $roleName, 'returnto' => 'Special:NovaRole' ), array() ); |
| 198 | + $actions = Html::rawElement( 'li', array(), $link ); |
| 199 | + $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-removerolemember' ), array(), array( 'action' => 'deletemember', 'rolename' => $roleName, 'returnto' => 'Special:NovaRole' ), array() ); |
| 200 | + $actions .= Html::rawElement( 'li', array(), $link ); |
| 201 | + $actions = Html::rawElement( 'ul', array(), $actions ); |
| 202 | + $roleOut .= Html::rawElement( 'td', array(), $actions ); |
| 203 | + $rolesOut .= Html::rawElement( 'tr', array(), $roleOut ); |
| 204 | + } |
| 205 | + if ( $rolesOut ) { |
| 206 | + $out .= Html::rawElement( 'table', array( 'class' => 'wikitable' ), $rolesOut ); |
| 207 | + } |
| 208 | + |
| 209 | + $wgOut->addHTML( $out ); |
| 210 | + } |
| 211 | + |
| 212 | + function tryAddMemberSubmit( $formData, $entryPoint = 'internal' ) { |
| 213 | + global $wgOut, $wgUser; |
| 214 | + |
| 215 | + $projectname = $formData['projectname']; |
| 216 | + if ( $projectname ) { |
| 217 | + $project = OpenStackNovaProject::getProjectByName( $projectname ); |
| 218 | + if ( ! $project ) { |
| 219 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistentproject' ) ); |
| 220 | + $wgOut->addHTML( $out ); |
| 221 | + return true; |
| 222 | + } |
| 223 | + $role = OpenStackNovaRole::getProjectRoleByName( $formData['rolename'], $project ); |
| 224 | + $members = $formData['members']; |
| 225 | + } else { |
| 226 | + $role = OpenStackNovaRole::getGlobalRoleByName( $formData['rolename'] ); |
| 227 | + $members = array( $formData['members'] ); |
| 228 | + } |
| 229 | + if ( ! $role ) { |
| 230 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistentrole' ) ); |
| 231 | + $wgOut->addHTML( $out ); |
| 232 | + return true; |
| 233 | + } |
| 234 | + $out = ''; |
| 235 | + foreach ( $members as $member ) { |
| 236 | + $success = $role->addMember( $member ); |
| 237 | + if ( $success ) { |
| 238 | + $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-addedto', array(), $member, $formData['rolename'] ) ); |
| 239 | + } else { |
| 240 | + $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoadd', array(), $member, $formData['rolename'] ) ); |
| 241 | + } |
| 242 | + } |
| 243 | + $out .= '<br />'; |
| 244 | + $sk = $wgUser->getSkin(); |
| 245 | + $returnto = Title::newFromText( $formData['returnto'] ); |
| 246 | + $out .= $sk->link( $returnto, wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() ); |
| 247 | + $wgOut->addHTML( $out ); |
| 248 | + |
| 249 | + return true; |
| 250 | + } |
| 251 | + |
| 252 | + function tryDeleteMemberSubmit( $formData, $entryPoint = 'internal' ) { |
| 253 | + global $wgOut, $wgUser; |
| 254 | + |
| 255 | + $projectname = $formData['projectname']; |
| 256 | + if ( $projectname ) { |
| 257 | + $project = OpenStackNovaProject::getProjectByName( $projectname ); |
| 258 | + if ( ! $project ) { |
| 259 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistentproject' ) ); |
| 260 | + $wgOut->addHTML( $out ); |
| 261 | + return true; |
| 262 | + } |
| 263 | + $role = OpenStackNovaRole::getProjectRoleByName( $formData['rolename'], $project ); |
| 264 | + } else { |
| 265 | + $role = OpenStackNovaRole::getGlobalRoleByName( $formData['rolename'] ); |
| 266 | + } |
| 267 | + if ( ! $role ) { |
| 268 | + $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistentrole' ) ); |
| 269 | + $wgOut->addHTML( $out ); |
| 270 | + return true; |
| 271 | + } |
| 272 | + $out = ''; |
| 273 | + foreach ( $formData['members'] as $member ) { |
| 274 | + $success = $role->deleteMember( $member ); |
| 275 | + if ( $success ) { |
| 276 | + $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removedfrom', array(), $member, $formData['rolename'] ) ); |
| 277 | + } else { |
| 278 | + $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoremove', array(), $member, $formData['rolename'] ) ); |
| 279 | + } |
| 280 | + } |
| 281 | + $out .= '<br />'; |
| 282 | + $sk = $wgUser->getSkin(); |
| 283 | + $returnto = Title::newFromText( $formData['returnto'] ); |
| 284 | + $out .= $sk->link( $returnto, wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() ); |
| 285 | + $wgOut->addHTML( $out ); |
| 286 | + |
| 287 | + return true; |
| 288 | + } |
| 289 | +} |
| 290 | + |
| 291 | +class SpecialNovaRoleForm extends HTMLForm { |
| 292 | +} |
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaRole.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 293 | + native |
Index: trunk/extensions/OpenStackManager/OpenStackNovaRole.php |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | var $rolename; |
7 | 7 | var $roleDN; |
8 | 8 | var $roleInfo; |
| 9 | + var $project; |
9 | 10 | var $global; |
10 | 11 | |
11 | 12 | function __construct( $rolename, $project=null ) { |
— | — | @@ -37,15 +38,17 @@ |
38 | 39 | if ( $this->global ) { |
39 | 40 | if ( isset ( $wgOpenStackManagerLDAPGlobalRoles["$this->rolename"] ) ) { |
40 | 41 | $dn = $wgOpenStackManagerLDAPGlobalRoles["$this->rolename"]; |
| 42 | + $query = '(objectclass=groupofnames)'; |
41 | 43 | } else { |
42 | 44 | # This condition would be a bug... |
43 | 45 | $dn = ''; |
44 | 46 | } |
45 | 47 | } else { |
46 | 48 | $dn = $this->project->projectDN; |
| 49 | + $query = '(cn=' . $this->rolename . ')'; |
47 | 50 | } |
48 | 51 | wfSuppressWarnings(); |
49 | | - $result = ldap_search( $wgAuth->ldapconn, $dn, '(cn=' . $this->rolename . ')' ); |
| 52 | + $result = ldap_search( $wgAuth->ldapconn, $dn, $query ); |
50 | 53 | $this->roleInfo = ldap_get_entries( $wgAuth->ldapconn, $result ); |
51 | 54 | wfRestoreWarnings(); |
52 | 55 | $this->roleDN = $this->roleInfo[0]['dn']; |
— | — | @@ -96,6 +99,7 @@ |
97 | 100 | $success = ldap_modify( $wgAuth->ldapconn, $this->roleDN, $values ); |
98 | 101 | wfRestoreWarnings(); |
99 | 102 | if ( $success ) { |
| 103 | + $this->fetchRoleInfo(); |
100 | 104 | $wgAuth->printDebug( "Successfully removed $user->userDN from $this->roleDN", NONSENSITIVE ); |
101 | 105 | return true; |
102 | 106 | } else { |
— | — | @@ -126,6 +130,7 @@ |
127 | 131 | $success = ldap_modify( $wgAuth->ldapconn, $this->roleDN, $values ); |
128 | 132 | wfRestoreWarnings(); |
129 | 133 | if ( $success ) { |
| 134 | + $this->fetchRoleInfo(); |
130 | 135 | $wgAuth->printDebug( "Successfully added $user->userDN to $this->roleDN", NONSENSITIVE ); |
131 | 136 | return true; |
132 | 137 | } else { |
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php |
— | — | @@ -113,7 +113,6 @@ |
114 | 114 | |
115 | 115 | 'openstackmanager-addmember' => 'Add project member', |
116 | 116 | 'openstackmanager-removemember' => 'Remove project member', |
117 | | - 'openstackmanager-removememberconfirm' => 'Are you sure you wish to remove $1 from project $2?', |
118 | 117 | 'openstackmanager-removeprojectconfirm' => 'Are you sure you wish to delete project "$1"? This action has reprecusions on all VMs. Do not take this action lightly!', |
119 | 118 | 'openstackmanager-createproject' => 'Create a new project', |
120 | 119 | 'openstackmanager-projectname' => 'Project name', |
— | — | @@ -134,10 +133,15 @@ |
135 | 134 | 'openstackmanager-badinstancename' => 'Bad instance name provided. Instance names must start with a-z, and can only contain a-z, 0-9, and - characters.', |
136 | 135 | 'openstackmanager-novaproject-project' => 'Project', |
137 | 136 | 'openstackmanager-novaproject-info' => 'Project Information', |
| 137 | + |
138 | 138 | 'openstackmanager-roles' => 'Roles', |
139 | 139 | 'openstackmanager-rolename' => 'Role Name', |
140 | 140 | 'openstackmanager-removerolemember' => 'Remove role member', |
141 | 141 | 'openstackmanager-addrolemember' => 'Add role member', |
| 142 | + 'openstackmanager-rolelist' => 'Global Role List', |
| 143 | + 'openstackmanager-nomemberstoremove' => 'There are no members to remove from this group', |
| 144 | + 'openstackmanager-novarole-role' => 'Nova Role', |
| 145 | + 'openstackmanager-novarole-info' => 'Nova Role Information', |
142 | 146 | |
143 | 147 | 'openstackmanager-shellaccountname' => 'Instance Shell Account Name', |
144 | 148 | 'openstackmanager-shellaccountnamehelp' => 'The shell account name must start with a-z, and can only contain a-z, 0-9, -, and _ characters.', |
Index: trunk/extensions/OpenStackManager/OpenStackNovaProject.php |
— | — | @@ -90,6 +90,12 @@ |
91 | 91 | $success = ldap_modify( $wgAuth->ldapconn, $this->projectDN, $values ); |
92 | 92 | wfRestoreWarnings(); |
93 | 93 | if ( $success ) { |
| 94 | + foreach ( $this->roles as $role ) { |
| 95 | + $success = $role->deleteMember( $username ); |
| 96 | + #TODO: Find a way to fail gracefully if role member |
| 97 | + # deletion fails |
| 98 | + } |
| 99 | + $this->fetchProjectInfo(); |
94 | 100 | $wgAuth->printDebug( "Successfully removed $user->userDN from $this->projectDN", NONSENSITIVE ); |
95 | 101 | return true; |
96 | 102 | } else { |
— | — | @@ -120,6 +126,7 @@ |
121 | 127 | $success = ldap_modify( $wgAuth->ldapconn, $this->projectDN, $values ); |
122 | 128 | wfRestoreWarnings(); |
123 | 129 | if ( $success ) { |
| 130 | + $this->fetchProjectInfo(); |
124 | 131 | $wgAuth->printDebug( "Successfully added $user->userDN to $this->projectDN", NONSENSITIVE ); |
125 | 132 | return true; |
126 | 133 | } else { |
Index: trunk/extensions/OpenStackManager/OpenStackNovaDomain.php |
— | — | @@ -62,6 +62,7 @@ |
63 | 63 | wfRestoreWarnings(); |
64 | 64 | if ( $success ) { |
65 | 65 | $wgAuth->printDebug( "Successfully modified soarecord for " . $this->domainDN, NONSENSITIVE ); |
| 66 | + $this->fetchDomainInfo(); |
66 | 67 | return true; |
67 | 68 | } else { |
68 | 69 | $wgAuth->printDebug( "Failed to modify soarecord for " . $this->domainDN, NONSENSITIVE ); |
Index: trunk/extensions/OpenStackManager/OpenStackNovaHost.php |
— | — | @@ -124,6 +124,7 @@ |
125 | 125 | $success = ldap_modify( $wgAuth->ldapconn, $this->hostDN, $hostEntry ); |
126 | 126 | wfRestoreWarnings(); |
127 | 127 | if ( $success ) { |
| 128 | + $this->fetchHostInfo(); |
128 | 129 | $wgAuth->printDebug( "Successfully modified puppet configuration for host", NONSENSITIVE ); |
129 | 130 | return true; |
130 | 131 | } else { |
— | — | @@ -159,6 +160,7 @@ |
160 | 161 | if ( $success ) { |
161 | 162 | $wgAuth->printDebug( "Successfully removed $fqdn from $this->hostDN", NONSENSITIVE ); |
162 | 163 | $this->domain->updateSOA(); |
| 164 | + $this->fetchHostInfo(); |
163 | 165 | return true; |
164 | 166 | } else { |
165 | 167 | $wgAuth->printDebug( "Failed to remove $fqdn from $this->hostDN", NONSENSITIVE ); |
— | — | @@ -191,6 +193,7 @@ |
192 | 194 | if ( $success ) { |
193 | 195 | $wgAuth->printDebug( "Successfully removed $ip from $this->hostDN", NONSENSITIVE ); |
194 | 196 | $this->domain->updateSOA(); |
| 197 | + $this->fetchHostInfo(); |
195 | 198 | return true; |
196 | 199 | } else { |
197 | 200 | $wgAuth->printDebug( "Failed to remove $ip from $this->hostDN", NONSENSITIVE ); |
— | — | @@ -217,6 +220,7 @@ |
218 | 221 | if ( $success ) { |
219 | 222 | $wgAuth->printDebug( "Successfully added $fqdn to $this->hostDN", NONSENSITIVE ); |
220 | 223 | $this->domain->updateSOA(); |
| 224 | + $this->fetchHostInfo(); |
221 | 225 | return true; |
222 | 226 | } else { |
223 | 227 | $wgAuth->printDebug( "Failed to add $fqdn to $this->hostDN", NONSENSITIVE ); |
— | — | @@ -240,6 +244,7 @@ |
241 | 245 | if ( $success ) { |
242 | 246 | $wgAuth->printDebug( "Successfully added $ip to $this->hostDN", NONSENSITIVE ); |
243 | 247 | $this->domain->updateSOA(); |
| 248 | + $this->fetchHostInfo(); |
244 | 249 | return true; |
245 | 250 | } else { |
246 | 251 | $wgAuth->printDebug( "Failed to add $ip to $this->hostDN", NONSENSITIVE ); |
— | — | @@ -257,6 +262,7 @@ |
258 | 263 | if ( $success ) { |
259 | 264 | $wgAuth->printDebug( "Successfully set $ip on $this->hostDN", NONSENSITIVE ); |
260 | 265 | $this->domain->updateSOA(); |
| 266 | + $this->fetchHostInfo(); |
261 | 267 | return true; |
262 | 268 | } else { |
263 | 269 | $wgAuth->printDebug( "Failed to set $ip on $this->hostDN", NONSENSITIVE ); |
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php |
— | — | @@ -226,6 +226,7 @@ |
227 | 227 | wfRestoreWarnings(); |
228 | 228 | if ( $success ) { |
229 | 229 | $wgAuth->printDebug( "Successfully imported the user's sshpublickey", NONSENSITIVE ); |
| 230 | + $this->fetchUserInfo(); |
230 | 231 | return true; |
231 | 232 | } else { |
232 | 233 | $wgAuth->printDebug( "Failed to import the user's sshpublickey", NONSENSITIVE ); |
— | — | @@ -254,6 +255,7 @@ |
255 | 256 | wfRestoreWarnings(); |
256 | 257 | if ( $success ) { |
257 | 258 | $wgAuth->printDebug( "Successfully deleted the user's sshpublickey", NONSENSITIVE ); |
| 259 | + $this->fetchHostInfo(); |
258 | 260 | return true; |
259 | 261 | } else { |
260 | 262 | $wgAuth->printDebug( "Failed to delete the user's sshpublickey", NONSENSITIVE ); |
Index: trunk/extensions/OpenStackManager/OpenStackManager.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | 'path' => __FILE__, |
23 | 23 | 'name' => 'OpenStackManager', |
24 | 24 | 'author' => 'Ryan Lane', |
25 | | - 'version' => '0.8', |
| 25 | + 'version' => '0.9', |
26 | 26 | 'url' => 'http://mediawiki.org/wiki/Extension:OpenStackManager', |
27 | 27 | 'descriptionmsg' => 'openstackmanager-desc', |
28 | 28 | ); |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | $wgAutoloadClasses['SpecialNovaDomain'] = $dir . 'special/SpecialNovaDomain.php'; |
84 | 84 | $wgAutoloadClasses['SpecialNovaAddress'] = $dir . 'special/SpecialNovaAddress.php'; |
85 | 85 | $wgAutoloadClasses['SpecialNovaSecurityGroup'] = $dir . 'special/SpecialNovaSecurityGroup.php'; |
| 86 | +$wgAutoloadClasses['SpecialNovaRole'] = $dir . 'special/SpecialNovaRole.php'; |
86 | 87 | $wgAutoloadClasses['SpecialNova'] = $dir . 'special/SpecialNova.php'; |
87 | 88 | $wgAutoloadClasses['OpenStackNovaHostJob'] = $dir . 'OpenStackNovaHostJob.php'; |
88 | 89 | $wgAutoloadClasses['AmazonEC2'] = $dir . 'aws-sdk/sdk.class.php'; |
— | — | @@ -97,6 +98,8 @@ |
98 | 99 | $wgSpecialPageGroups['NovaAddress'] = 'nova'; |
99 | 100 | $wgSpecialPages['NovaSecurityGroup'] = 'SpecialNovaSecurityGroup'; |
100 | 101 | $wgSpecialPageGroups['NovaSecurityGroup'] = 'nova'; |
| 102 | +$wgSpecialPages['NovaRole'] = 'SpecialNovaRole'; |
| 103 | +$wgSpecialPageGroups['NovaRole'] = 'nova'; |
101 | 104 | $wgJobClasses['addDNSHostToLDAP'] = 'OpenStackNovaHostJob'; |
102 | 105 | |
103 | 106 | $wgHooks['LDAPSetCreationValues'][] = 'OpenStackNovaUser::LDAPSetCreationValues'; |