Example #1
0
 /**
  * 按权限获取平台列表
  * @param bool $perm	按不按当前登录用户权限
  */
 public function getPlatformList($perm = TRUE)
 {
     $list = $this->findBy(array('status' => 0, 'pid' => 0), 'id');
     if (!$perm || Passport::IsAdmin()) {
         return $list;
     }
     $new_list = array();
     $user = new User();
     $perms = $user->getPerms(Passport::GetLoginUid());
     foreach ($list as $key => $value) {
         if (array_key_exists($key, $perms)) {
             $new_list[$key] = $value;
         }
     }
     return $new_list;
 }
Example #2
0
<?php

/**
 * 用户管理页面。修改用户密码、类型、权限
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
if (!Passport::IsAdmin()) {
    redirect('login.php');
}
$user = new User();
$smarty = new Template();
$TEMPLATE['title'] = '用户管理';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['users'] = 'current';
switch (strtolower($_GET['action'])) {
    case 'edit':
        $id = intval($_GET['id']);
        $TEMPLATE['data'] = $user->get($id);
        $TEMPLATE['data']['perms'] = unserialize($TEMPLATE['data']['perms']);
        if (Request::IsPost()) {
            $fields = $_POST['f'];
            if (validate($fields)) {
                if (!isset($fields['type'])) {
                    $fields['type'] = 0;
                }
                // 按平台权限拷贝第一个管理员的Token
                $thirdAccount = new ThirdAccount();
                $thirdAccount->copyToken($id, @array_keys($fields['perms']));
Example #3
0
 /**
  * 按状态和分页获取任务列表
  * @param int $status
  * @param string $limit
  */
 public function GetList($status, $limit = NULL)
 {
     $cond = array('status' => $status);
     if (!Passport::IsAdmin()) {
         $user = new User();
         $perms = $user->getPerms(Passport::GetLoginUid());
         if (count($perms) > 0) {
             $cond['pid'] = array_keys($perms);
         } else {
             $cond['uid'] = Passport::GetLoginUid();
         }
     }
     $list = $this->findBy($cond, $this->primary_key, $limit, null, 'send_time desc, id desc');
     // 查询 username 字段
     $uids = array();
     foreach ($list as $item) {
         $uids[] = $item['uid'];
     }
     $uids = array_unique($uids);
     $user = new User();
     $user_list = $user->gets($uids);
     foreach ($list as &$item) {
         $item['username'] = if_null($user_list[$item['uid']]['username'], 'uid: ' . $item['uid']);
         unset($item);
     }
     return $list;
 }
Example #4
0
include_once ROOT_DIR . '_CLASS' . DS . 'FX' . DS . 'function.inc.php';
include_once ROOT_DIR . '_CLASS' . DS . 'function.inc.php';
function autoload($class_name)
{
    $file = ROOT_DIR . '_CLASS' . DS . 'FX' . DS . $class_name . '.class.php';
    if (file_exists($file)) {
        include_once $file;
    } else {
        $file = ROOT_DIR . '_CLASS' . DS . $class_name . '.class.php';
        if (file_exists($file)) {
            include_once $file;
        }
    }
}
spl_autoload_register('autoload');
/*---Debug Begin---*/
if (defined('DEBUG') && DEBUG == true || $_REQUEST['debug'] == 1) {
    //Debug模式将错误打开
    ini_set('display_errors', true);
    //设置错误级别
    error_reporting(ERROR_LEVEL);
    //开启ob函数
    ob_start();
    //Debug开关打开
    Debug::start();
    //注册shutdown函数用来Debug显示
    register_shutdown_function(array('Debug', 'show'));
}
/*---Debug End---*/
$TEMPLATE['is_admin'] = Passport::IsAdmin();