https://www.mediawiki.org/wiki/Special:Code/MediaWiki/107039
Revision: 107039 Author: laner Date: 2011-12-22 03:38:04 +0000 (Thu, 22 Dec 2011) Log Message: ----------- Only display actions to users if they can use them. Resolves bug 32610. Modified Paths: -------------- trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php Modified: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php =================================================================== --- trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php 2011-12-22 03:08:45 UTC (rev 107038) +++ trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php 2011-12-22 03:38:04 UTC (rev 107039) @@ -500,32 +500,34 @@ $instanceOut .= Html::element( 'td', array(), $instance->getAvailabilityZone() ); $instanceOut .= Html::element( 'td', array(), $instance->getImageId() ); $instanceOut .= Html::element( 'td', array(), $instance->getLaunchTime() ); - $msg = wfMsgHtml( 'openstackmanager-delete' ); - $link = $sk->link( $this->getTitle(), $msg, array(), + if ( $this->userLDAP->inRole( 'sysadmin', $project ) ) { + $msg = wfMsgHtml( 'openstackmanager-delete' ); + $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'delete', 'project' => $project, 'instanceid' => $instance->getInstanceId() ) ); - $actions = Html::rawElement( 'li', array(), $link ); - $msg = wfMsgHtml( 'openstackmanager-reboot' ); - $link = $sk->link( $this->getTitle(), $msg, array(), + $actions = Html::rawElement( 'li', array(), $link ); + $msg = wfMsgHtml( 'openstackmanager-reboot' ); + $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'reboot', 'project' => $project, 'instanceid' => $instance->getInstanceId() ) ); - $actions .= Html::rawElement( 'li', array(), $link ); - $msg = wfMsgHtml( 'openstackmanager-configure' ); - $link = $sk->link( $this->getTitle(), $msg, array(), + $actions .= Html::rawElement( 'li', array(), $link ); + $msg = wfMsgHtml( 'openstackmanager-configure' ); + $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'configure', 'project' => $project, 'instanceid' => $instance->getInstanceId() ) ); - $actions .= Html::rawElement( 'li', array(), $link ); - $msg = wfMsgHtml( 'openstackmanager-getconsoleoutput' ); - $link = $sk->link( $this->getTitle(), $msg, array(), + $actions .= Html::rawElement( 'li', array(), $link ); + $msg = wfMsgHtml( 'openstackmanager-getconsoleoutput' ); + $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'consoleoutput', 'project' => $project, 'instanceid' => $instance->getInstanceId() ) ); - $actions .= Html::rawElement( 'li', array(), $link ); - $actions = Html::rawElement( 'ul', array(), $actions ); - $instanceOut .= Html::rawElement( 'td', array(), $actions ); + $actions .= Html::rawElement( 'li', array(), $link ); + $actions = Html::rawElement( 'ul', array(), $actions ); + $instanceOut .= Html::rawElement( 'td', array(), $actions ); + } if ( isset( $projectArr["$project"] ) ) { $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut ); } else { @@ -534,13 +536,13 @@ } foreach ( $userProjects as $project ) { $out .= Html::element( 'h2', array(), $project ); - $out .= $sk->link( $this->getTitle(), wfMsgHtml( 'openstackmanager-createinstance' ), array(), - array( 'action' => 'create', 'project' => $project ) ); + if ( $this->userLDAP->inRole( 'sysadmin', $project ) ) { + $out .= $sk->link( $this->getTitle(), wfMsgHtml( 'openstackmanager-createinstance' ), array(), array( 'action' => 'create', 'project' => $project ) ); + } if ( isset( $projectArr["$project"] ) ) { $projectOut = $header; $projectOut .= $projectArr["$project"]; - $out .= Html::rawElement( 'table', - array( 'id' => 'novainstancelist', 'class' => 'wikitable sortable collapsible' ), $projectOut ); + $out .= Html::rawElement( 'table', array( 'id' => 'novainstancelist', 'class' => 'wikitable sortable collapsible' ), $projectOut ); } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs