Skip to content

Commit

Permalink
Merge branch 'rowanthorpe-add-as112-active-config-var'
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jun 29, 2015
2 parents 14497bf + 0789156 commit 56bef0f
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 34 deletions.
9 changes: 9 additions & 0 deletions application/configs/application.ini.dist
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ reseller.enabled = true
;;
reseller.no_billing_for_resold_customers = true

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Specifies whether to display and enable control of AS112 functionality for customers
;;
;; See https://github.com/inex/IXP-Manager/wiki/AS112
;;

as112_ui_active = true

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; We use Minify to bundle and compress CSS and JS in
Expand Down
1 change: 1 addition & 0 deletions application/controllers/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ protected function formPostProcess( $form, $object, $isEdit, $options = null, $c

$form->enableResller( $this->resellerMode() );
$form->setMultiIXP( $this->multiIXP(), $isEdit );
$form->setAs112client( $this->as112UiActive(), $isEdit );

if( $this->resellerMode() )
{
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/VlanInterfaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ protected function _feInit()
'ipv6canping' => 'Monitoring Enabled via IPv6 ICMP',
'ipv4monitorrcbgp' => 'Monitor Route Collector IPv4 BGP Session',
'ipv6monitorrcbgp' => 'Monitor Route Collector IPv6 BGP Session',
'as112client' => 'AS112 Client',
'busyhost' => 'Busy Host?',
'notes' => 'Notes'
]
],
( $this->as112UiActive() ? ['as112client' => 'AS112 Client'] : [] )
);

break;
Expand Down
9 changes: 7 additions & 2 deletions application/views/customer/detail.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,13 @@
<td><strong>Route Server Client:</strong></td>
<td id="value">{if $vli->getRsclient()}Yes{else}No{/if}</td>
<td></td>
<td><strong>AS112 Client:</strong></td>
<td id="value">{if $vli->getAs112client()}Yes{else}No{/if}</td>
{if $as112UiActive}
<td><strong>AS112 Client:</strong></td>
<td id="value">{if $vli->getAs112client()}Yes{else}No{/if}</td>
{else}
<td></td>
<td></td>
{/if}
</tr>

</table>
Expand Down
6 changes: 4 additions & 2 deletions application/views/customer/overview-tabs/overview.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
<td colspan="2">
{if not $cust->isTypeAssociate()}
<span class="label label-{if $rsclient}success{else}important{/if}">RS Client</span>
&nbsp;&nbsp;&nbsp;
<span class="label label-{if $as112client}success{else}important{/if}">AS112</span>
{if $as112UiActive}
&nbsp;&nbsp;&nbsp;
<span class="label label-{if $as112client}success{else}important{/if}">AS112</span>
{/if}
{/if}
</td>
</tr>
Expand Down
9 changes: 7 additions & 2 deletions application/views/customer/overview-tabs/ports/port.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,13 @@
<td><strong>Route Server Client:</strong></td>
<td id="value">{if $vli->getRsclient()}Yes{else}No{/if}</td>
<td></td>
<td><strong>AS112 Client:</strong></td>
<td id="value">{if $vli->getAs112client()}Yes{else}No{/if}</td>
{if $as112UiActive}
<td><strong>AS112 Client:</strong></td>
<td id="value">{if $vli->getAs112client()}Yes{else}No{/if}</td>
{else}
<td></td>
<td></td>
{/if}
</tr>

</table>
Expand Down
4 changes: 3 additions & 1 deletion application/views/virtual-interface/forms/add-wizard.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
{$element->irrdbfilter}
{$element->mcastenabled}
{$element->rsclient}
{$element->as112client}
{if $as112UiActive}
{$element->as112client}
{/if}

</fieldset>

Expand Down
4 changes: 3 additions & 1 deletion application/views/vlan-interface/forms/vlan-interface.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

{$element->maxbgpprefix}
{$element->rsclient}
{$element->as112client}
{if $as112UiActive}
{$element->as112client}
{/if}
{$element->busyhost}

</div>
Expand Down
5 changes: 3 additions & 2 deletions library/IXP/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ public function __construct(
$this->view->registerClass( 'SWITCHPORT', '\\Entities\\SwitchPort' );
$this->view->registerClass( 'VLAN', '\\Entities\\Vlan' );

$this->view->resellerMode = $this->resellerMode();
$this->view->multiIXP = $this->multiIXP();
$this->view->resellerMode = $this->resellerMode();
$this->view->multiIXP = $this->multiIXP();
$this->view->as112UiActive = $this->as112UiActive();

if( $this->getAuth()->hasIdentity() && $this->getUser()->getPrivs() == Entities\User::AUTH_SUPERUSER )
$this->superUserSetup();
Expand Down
5 changes: 3 additions & 2 deletions library/IXP/Controller/CliAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public function __construct(
$this->view->registerClass( 'SWITCHPORT', '\\Entities\\SwitchPort' );
$this->view->registerClass( 'VLAN', '\\Entities\\Vlan' );

$this->view->resellerMode = $this->resellerMode();
$this->view->multiIXP = $this->multiIXP();
$this->view->resellerMode = $this->resellerMode();
$this->view->multiIXP = $this->multiIXP();
$this->view->as112UiActive = $this->as112UiActive();
}


Expand Down
56 changes: 36 additions & 20 deletions library/IXP/Controller/Trait/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function resellerMode()
{
return ( isset( $this->_options['reseller']['enabled'] ) && $this->_options['reseller']['enabled'] );
}

/**
* Checks if multi IXP mode is enabled.
*
Expand All @@ -60,7 +60,24 @@ protected function multiIXP()
{
return ( isset( $this->_options['multiixp']['enabled'] ) && $this->_options['multiixp']['enabled'] );
}


/**
* Checks if as112 is activated in the UI.
*
* To disable as112 in the UI set as112_ui_active to false in application.ini
*
* NB: set to false is required to maintain backwards compatibility without user
* intervention. Defaulting to false will be implemented in v4.
*
* @see https://github.com/inex/IXP-Manager/wiki/AS112
*
* @return bool
*/
protected function as112UiActive()
{
return ( !isset( $this->_options['as112_ui_active'] ) || $this->_options['as112_ui_active'] );
}


/**
* Loads a customer object via an optional posted / getted `shortname` parameter.
Expand All @@ -83,7 +100,7 @@ protected function resolveCustomerByShortnameParam()
if( $this->getUser()->getPrivs() == \Entities\User::AUTH_SUPERUSER )
{
$shortname = $this->getParam( 'shortname', false );

if( !$shortname )
{
$this->addMessage( 'Customer shortname expected but not found.', OSS_Message::ERROR );
Expand All @@ -93,7 +110,7 @@ protected function resolveCustomerByShortnameParam()
else
{
$shortname = $this->getCustomer()->getShortname();

if( $this->getParam( 'shortname', $shortname ) != $this->getCustomer()->getShortname() )
{
$this->addMessage( 'Illegal attempt to access another customer. This event has been logged.',
Expand All @@ -104,18 +121,18 @@ protected function resolveCustomerByShortnameParam()
$this->redirect( '' );
}
}

$c = $this->getD2EM()->getRepository( '\\Entities\\Customer' )->findOneBy( [ 'shortname' => $shortname ] );

if( !$c )
{
$this->addMessage( 'Invalid customer', OSS_Message::ERROR );
$this->redirect();
}

return $c;
}

/**
* Load a customer from the database by shortname but redirect to `error/error` if no such customer.
*
Expand All @@ -129,19 +146,19 @@ protected function loadCustomerByShortname( $shortname = false, $redirect = null
{
if( $shortname === false )
$shortname = $this->getParam( 'shortname', false );

if( $shortname )
$c = $this->getD2EM()->getRepository( '\\Entities\\Customer' )->findOneBy( [ 'shortname' => $shortname ] );

if( !$shortname || !$c )
{
$this->addMessage( 'Invalid customer', OSS_Message::ERROR );
$this->redirect( $redirect === null ? 'error/error' : $redirect );
}

return $c;
}

/**
* Load a customer from the database by ID but redirect to `error/error` if no such customer.
*
Expand All @@ -153,16 +170,16 @@ protected function loadCustomerById( $id, $redirect = null )
{
if( $id )
$c = $this->getD2R( '\\Entities\\Customer' )->find( $id );

if( !$id || !$c )
{
$this->addMessage( "Could not load the requested customer object", OSS_Message::ERROR );
$this->redirect( $redirect === null ? 'error/error' : $redirect );
}

return $c;
}

/**
* Load an IXP from the database by ID but redirect to `error/error` if no such IXP.
*
Expand All @@ -173,18 +190,17 @@ protected function loadCustomerById( $id, $redirect = null )
protected function loadIxpById( $id, $redirect = null )
{
$i = $this->getD2R( '\\Entities\\IXP' )->find( $id );

if( !$id || !$i )
{
if( $redirect === false )
return false;

$this->addMessage( "Could not load the IXP object", OSS_Message::ERROR );
$this->redirect( $redirect === null ? '' : $redirect );
}

return $i;
}

}

}

0 comments on commit 56bef0f

Please sign in to comment.