Example #1
0
 public function execute($role, $permission, $params = [])
 {
     $actionId = isset($params['actionId']) ? $params['actionId'] : LuLu::getApp()->requestedAction->id;
     $actions = $permission['value'];
     if (in_array($actionId, $actions)) {
         return true;
     }
     $method = LuLu::getApp()->request->method;
     $method = strtolower($method);
     if (in_array($actionId . ':' . $method, $actions)) {
         return true;
     }
     return false;
 }
Example #2
0
 public static function getAdminMenu()
 {
     $html = '';
     $adminUrl = Resource::getAdminUrl();
     $action = LuLu::getApp()->requestedAction;
     $urlArray = explode('/', $action->uniqueId);
     $roots = self::getChildren('admin', 0, 1);
     foreach ($roots as $menu) {
         $url = $menu['url'] === '#' ? '#' : Url::to([$menu['url']]);
         $title = '<span class="da-nav-icon"><img src="' . $adminUrl . '/images/icons/black/32/' . $menu['thumb'] . '" alt="' . $menu['name'] . '" /></span>' . $menu['name'];
         $html .= '<li id="menu-item-' . $menu['id'] . '"><a href="' . $url . '">' . $title . '</a>';
         $children = self::getChildren('admin', $menu['id'], 1);
         if (count($children) > 0) {
             $opened = false;
             $childHtml = '';
             foreach ($children as $child) {
                 $menuUrlArray = explode('/', trim($child['url'], '/'));
                 if (in_array($urlArray[0], $menuUrlArray)) {
                     $opened = true;
                 }
                 $childUrl = $child['url'] === '#' ? '#' : Url::to([$child['url']]);
                 $childHtml .= '<li id="menu-item-' . $child['id'] . '"><a href="' . $childUrl . '">' . $child['name'] . '</a></li>';
             }
             $html .= $opened ? '<ul>' : '<ul class="closed">';
             $html .= $childHtml;
             $html .= '</ul>';
         }
         $html .= '</li>';
     }
     return $html;
 }
Example #3
0
 private function setDb($dbConfig)
 {
     self::_appendLog('设置数据库信息。。。');
     $dbHost = LuLu::getPostValue('dbHost');
     $dbName = LuLu::getPostValue('dbName');
     $dbUsername = LuLu::getPostValue('dbUsername');
     $dbPassword = LuLu::getPostValue('dbPassword');
     $tbPre = LuLu::getPostValue('tbPre');
     try {
         $db = new Connection($dbConfig);
         LuLu::getApp()->set('db', $db);
         $db->createCommand("USE {$dbName}")->execute();
         $db->createCommand("SET NAMES 'utf8',character_set_client=binary,sql_mode=''")->execute();
         self::_appendLog('数据库信息设置成功');
         return $db;
     } catch (\Exception $e) {
         $message = self::getDbError($e->getMessage(), ['dbHost' => $dbHost, 'dbName' => $dbName]);
         self::_appendLog($message, true);
         return false;
     }
 }
Example #4
0
<?php

use yii\helpers\Html;
use source\LuLu;
/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
$this->title = $name;
?>
<div id="da-error-wrapper">
                	                   
	<h1 class="da-error-heading"><?php 
echo $message;
?>
</h1>

	<p><a href="<?php 
echo LuLu::getApp()->request->getReferrer();
?>
">返回上一页</a></p>
	
</div>

Example #5
0
 public function checkHomePermission($permission = null, $params = [], $user = null)
 {
     if ($user === null) {
         $user = LuLu::getIdentity()->username;
     }
     if ($permission === null) {
         $permission = LuLu::getApp()->controller->uniqueId;
     }
     $permission = 'home_' . $permission;
     $rows = $this->getPermissionsByUser($user);
     if (!isset($rows[$permission])) {
         return false;
     }
     return $this->executeRule($rows[$permission], $params, $user);
 }
Example #6
0
 private function checkSkipActions()
 {
     if (empty($this->skipActions)) {
         return false;
     }
     $actionId = LuLu::getApp()->requestedAction->uniqueId;
     if (LuLu::getApp() instanceof FrontApplication) {
         $actionId = 'home_' . $actionId;
     }
     return in_array($actionId, $this->skipActions);
 }
Example #7
0
 public function checkPermission($role = null, $permission = null, $params = [])
 {
     if ($role === null) {
         $role = LuLu::getIdentity()->role;
     }
     if ($permission === null) {
         $m = LuLu::getApp()->controller->module->id;
         $c = LuLu::getApp()->controller->id;
         $permission = empty($m) ? $c : $m . '/' . $c;
     }
     $rows = $this->getPermissionsByRole($role);
     if (!isset($rows[$permission])) {
         return false;
     }
     return $this->executeRule($role, $rows[$permission], $params);
 }