Example #1
0
 /**
  * 用户组绑定权限
  */
 public function actionIndex($id)
 {
     $id = (int) $id;
     $model = Group::model()->findByPk($id);
     if ($model->access) {
         foreach ($model->access as $g) {
             $access[] = $g->access_id;
         }
     }
     $cache = cache('auth_controller_file');
     if (!$cache) {
         $d = $this->_get_modules(\Yii::getPathOfAlias('application.modules'));
         if ($d) {
             Access::generate($d);
         }
         DirHelper::$kep_list_file = false;
         cache('auth_controller_file', true);
     }
     $rows = DB::all('access', array('select' => "id,name,pid"));
     foreach ($rows as $v) {
         $out[$v['id']] = $v;
     }
     $rows = ArrHelper::_tree_id($rows);
     if ($_POST) {
         $auth = $_POST['auth'];
         GroupAccess::saveAccess($id, $auth);
         cache('acl', false);
         flash('success', __('set access success'));
         $this->redirect(url('admin/auth/index', array('id' => $id)));
     }
     return $this->render('index', array('rows' => $rows, 'out' => $out, 'model' => $model, 'id' => $id, 'access' => $access));
 }
Example #2
0
 public function testQueryFindsAll()
 {
     $user = new StdClass();
     $user->name = 'matthew';
     $statement = Mockery::mock('\\PDOStatement');
     $statement->shouldReceive('execute')->once()->with(['matthew'])->andReturn(true);
     $statement->shouldReceive('fetchAll')->once()->andReturn([$user]);
     $pdo = Mockery::mock('\\PDO');
     $pdo->shouldReceive('prepare')->once()->with('SELECT * FROM users WHERE name = ?')->andReturn($statement);
     $conn = Mockery::mock('\\Fyuze\\Database\\Drivers\\ConnectionInterface');
     $conn->shouldReceive('open')->once()->andReturn($pdo);
     $db = new DB($conn);
     $query = $db->all('SELECT * FROM users WHERE name = ?', ['matthew']);
     $this->assertEquals(1, count($query));
 }
Example #3
0
 static function load()
 {
     $all = DB::all('core_modules', array('where' => array('active' => 1), 'orderBy' => 'sort desc,id asc'));
     $dir = base_path() . 'modules/';
     foreach ($all as $v) {
         $name = $v['name'];
         $out[$name] = 1;
         //加载Hook.php
         $h = $dir . $name . '/Hook.php';
         if (file_exists($h)) {
             $reflection = new \ReflectionClass("\\app\\modules\\{$name}\\Hook");
             $methods = $reflection->getMethods();
             foreach ($methods as $m) {
                 $action[$m->name][] = $name;
             }
         }
     }
     cache_pre('all_modules', $out);
     cache_pre('hooks', $action);
 }
Example #4
0
<?php

require 'DB.php';
$db = new DB();
if ($_POST) {
    $db->add($_POST['name'], $_POST['phone']);
}
if ($_GET['delete']) {
    $db->remove($_GET['delete']);
}
$contacts = $db->all();
?>

<html>
<head>
    <title>PHP-Apache-Mysql-Sample 示例312hh - DaoCloud</title>

    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

    <style>
        body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            color: #666;
            display: table;
        }

        .container {
            display: table-cell;