r107039 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107038‎ | r107039 | r107040 >
Date:03:38, 22 December 2011
Author:laner
Status:ok
Tags:
Comment:
Only display actions to users if they can use them. Resolves bug 32610.
Modified paths:
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -500,32 +500,34 @@
501501 $instanceOut .= Html::element( 'td', array(), $instance->getAvailabilityZone() );
502502 $instanceOut .= Html::element( 'td', array(), $instance->getImageId() );
503503 $instanceOut .= Html::element( 'td', array(), $instance->getLaunchTime() );
504 - $msg = wfMsgHtml( 'openstackmanager-delete' );
505 - $link = $sk->link( $this->getTitle(), $msg, array(),
 504+ if ( $this->userLDAP->inRole( 'sysadmin', $project ) ) {
 505+ $msg = wfMsgHtml( 'openstackmanager-delete' );
 506+ $link = $sk->link( $this->getTitle(), $msg, array(),
506507 array( 'action' => 'delete',
507508 'project' => $project,
508509 'instanceid' => $instance->getInstanceId() ) );
509 - $actions = Html::rawElement( 'li', array(), $link );
510 - $msg = wfMsgHtml( 'openstackmanager-reboot' );
511 - $link = $sk->link( $this->getTitle(), $msg, array(),
 510+ $actions = Html::rawElement( 'li', array(), $link );
 511+ $msg = wfMsgHtml( 'openstackmanager-reboot' );
 512+ $link = $sk->link( $this->getTitle(), $msg, array(),
512513 array( 'action' => 'reboot',
513514 'project' => $project,
514515 'instanceid' => $instance->getInstanceId() ) );
515 - $actions .= Html::rawElement( 'li', array(), $link );
516 - $msg = wfMsgHtml( 'openstackmanager-configure' );
517 - $link = $sk->link( $this->getTitle(), $msg, array(),
 516+ $actions .= Html::rawElement( 'li', array(), $link );
 517+ $msg = wfMsgHtml( 'openstackmanager-configure' );
 518+ $link = $sk->link( $this->getTitle(), $msg, array(),
518519 array( 'action' => 'configure',
519520 'project' => $project,
520521 'instanceid' => $instance->getInstanceId() ) );
521 - $actions .= Html::rawElement( 'li', array(), $link );
522 - $msg = wfMsgHtml( 'openstackmanager-getconsoleoutput' );
523 - $link = $sk->link( $this->getTitle(), $msg, array(),
 522+ $actions .= Html::rawElement( 'li', array(), $link );
 523+ $msg = wfMsgHtml( 'openstackmanager-getconsoleoutput' );
 524+ $link = $sk->link( $this->getTitle(), $msg, array(),
524525 array( 'action' => 'consoleoutput',
525526 'project' => $project,
526527 'instanceid' => $instance->getInstanceId() ) );
527 - $actions .= Html::rawElement( 'li', array(), $link );
528 - $actions = Html::rawElement( 'ul', array(), $actions );
529 - $instanceOut .= Html::rawElement( 'td', array(), $actions );
 528+ $actions .= Html::rawElement( 'li', array(), $link );
 529+ $actions = Html::rawElement( 'ul', array(), $actions );
 530+ $instanceOut .= Html::rawElement( 'td', array(), $actions );
 531+ }
530532 if ( isset( $projectArr["$project"] ) ) {
531533 $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut );
532534 } else {
@@ -534,13 +536,13 @@
535537 }
536538 foreach ( $userProjects as $project ) {
537539 $out .= Html::element( 'h2', array(), $project );
538 - $out .= $sk->link( $this->getTitle(), wfMsgHtml( 'openstackmanager-createinstance' ), array(),
539 - array( 'action' => 'create', 'project' => $project ) );
 540+ if ( $this->userLDAP->inRole( 'sysadmin', $project ) ) {
 541+ $out .= $sk->link( $this->getTitle(), wfMsgHtml( 'openstackmanager-createinstance' ), array(), array( 'action' => 'create', 'project' => $project ) );
 542+ }
540543 if ( isset( $projectArr["$project"] ) ) {
541544 $projectOut = $header;
542545 $projectOut .= $projectArr["$project"];
543 - $out .= Html::rawElement( 'table',
544 - array( 'id' => 'novainstancelist', 'class' => 'wikitable sortable collapsible' ), $projectOut );
 546+ $out .= Html::rawElement( 'table', array( 'id' => 'novainstancelist', 'class' => 'wikitable sortable collapsible' ), $projectOut );
545547 }
546548 }
547549

Status & tagging log