php - Yii HumHub Inject Event into Main App -
i trying attach event global scope of yii application called humhub however, when try run function through "topmenu" global, doesn't appear anything. possibly because i'm not using $event variable scope?
i trying make development mode module prevent access administrators viewing system when it's activated. global way know code across pages (with limited understanding of humhub , yii) topmenu appears on pages (besides login page disabled when guest mode active)
autostart.php
yii::app()->modulemanager->register(array( 'id' => 'devmode', 'class' => 'application.modules.devmode.devmodemodule', 'import' => array( 'application.modules.devmode.*', ), // events catch 'events' => array( array('class' => 'adminmenuwidget', 'event' => 'oninit', 'callback' => array('devmodeevents', 'onadminmenuinit')), array('class' => 'topmenuwidget', 'event' => 'oninit', 'callback' => array('devmodeevents', 'devblock')), array('class' => 'dashboardsidebarwidget', 'event' => 'oninit', 'callback' => array('devmodemodule', 'onsidebarinit')), ), )); devmodeevents.php
<?php /** * defines module events * * @package humhub.modules.devmode.events * @author jordan thompson */ class devmodeevents { public static function onadminmenuinit($event) { $event->sender->additem(array( 'label' => yii::t('devmode.base', 'development mode'), 'url' => yii::app()->createurl('//devmode/config/config'), 'group' => 'settings', 'icon' => '<i class="fa fa-lock"></i>', 'isactive' => (yii::app()->controller->module && yii::app()->controller->module->id == 'devmode' && yii::app()->controller->id == 'admin'), 'sortorder' => 300, )); } public static function devblock($event) { $devmode = hsetting::get('devmode', 'devmode'); if ($devmode == 1 ) { if (!yii::app()->user->isguest) { if (!yii::app()->user->isadmin()) { throw new chttpexception('418', yii::t('devmode.base', yii::app()->name . ' under maintenance, check later.')); } } else { throw new chttpexception('418', yii::t('devmode.base', yii::app()->name . ' under maintenance, check later.')); } } } }
change sort order 1, , access using css
li:nth-child(1) { //do something; }
Comments
Post a Comment