本文整理汇总了PHP中role类的典型用法代码示例。如果您正苦于以下问题:PHP role类的具体用法?PHP role怎么用?PHP role使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了role类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* 添加
*/
public function add()
{
$this->site_ids = role::check('role_edit');
if ($_POST) {
//标签过滤
tool::filter_strip_tags($_POST);
$name = $this->input->post('name');
$role = Myrole::instance()->get_by_name($name);
$parent_id = $this->input->post('parent_id');
if ($role['id']) {
remind::set(Kohana::lang('o_manage.group_has_exist'), 'manage/role/add');
}
if ($parent_id > 0) {
$role = Myrole::instance($parent_id)->get();
//zhu add
if ($role['type'] != $this->input->post('type')) {
remind::set(Kohana::lang('o_manage.parent_group_type_not_match'), 'manage/role/add');
}
$_POST['level_depth'] = $role['level_depth'] + 1;
} else {
$_POST['level_depth'] = 1;
}
if (Myrole::instance()->add($_POST)) {
remind::set(Kohana::lang('o_global.add_success'), 'manage/role', 'success');
} else {
remind::set(Kohana::lang('o_global.add_error'), 'manage/role/add');
}
}
$roles = Myrole::instance()->roles();
$this->template->content = new View("manage/role_add");
$this->template->content->roles = $roles;
}
示例2: do_active
/**
* 改变状态
*/
function do_active($id)
{
//权限验证
role::check('user_charge');
if (!$id) {
remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
}
$db = Database::instance();
$data = array_shift($db->query('SELECT * FROM user_charge_order WHERE id=' . $id)->result_array(false));
if ($data['id'] <= 0 || $data['status'] > 0) {
remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
}
$logodata = array();
$logodata['manager_id'] = $this->manager_id;
$logodata['ip'] = tool::get_str_ip();
$logodata['user_log_type'] = 27;
$logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
$logodata['memo'] = "充值订单号:" . $data['order_num'] . ", 购买拍点数:" . $data['price'] . ", 充值金额:" . $data['money'];
$sql = "UPDATE user_charge_order SET status=1 WHERE id='" . $id . "' ";
if ($db->query($sql)) {
//充值用户Money
$sql_reward = "UPDATE users \r\n SET user_money = user_money+" . $data['price'] . "\r\n WHERE id='" . $data['user_id'] . "'\r\n ";
$db->query($sql_reward);
//操作log
ulog::add($logodata);
remind::set(Kohana::lang('o_global.update_success'), 'user/user_charge', 'success');
} else {
//操作log
ulog::add($logodata, 1);
remind::set(Kohana::lang('o_global.update_error'), 'user/user_charge', 'error');
}
}
示例3: __construct
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
// checke request is ajax
$this->ajax_request = request::is_ajax();
// Load the template
$this->template = new View($this->template);
if ($this->auto_render == TRUE) {
Event::add('system.post_controller', array($this, '_render'));
}
/**
* 判断用户登录情况
*/
if (isset($_REQUEST['session_id'])) {
$session = Session::instance($_REQUEST['session_id']);
$manager = role::get_manager($_REQUEST['session_id']);
} else {
$session = Session::instance();
$manager = role::get_manager();
}
/* 当前请求的URL */
$current_url = urlencode(url::current(TRUE));
//当前用户管理的站点的ID
$this->site_id = site::id();
}
示例4: index
public function index()
{
role::check('user_charge_orders');
/* 初始化默认查询条件 */
$user_query_struct = array('where' => array(), 'like' => array(), 'orderby' => array('id' => "DESC"), 'limit' => array('per_page' => 20, 'offset' => 0));
/* 用户列表模板 */
$this->template->content = new View("user/user_charge_orders");
/* 搜索功能 */
$search_arr = array('order_num');
$search_value = $this->input->get('search_value');
$where_view = array();
$user_query_struct['like']['order_num'] = $search_value;
//$user_query_struct['like']['ret_order_num'] = $search_value;
$where_view['search_value'] = $search_value;
/* 每页显示条数 */
$per_page = controller_tool::per_page();
$user_query_struct['limit']['per_page'] = $per_page;
/* 调用分页 */
$this->pagination = new Pagination(array('total_items' => User_chargeService::get_instance()->query_count($user_query_struct), 'items_per_page' => $per_page));
//d($this->pagination->sql_offset);
$user_query_struct['limit']['offset'] = $this->pagination->sql_offset;
$users = User_chargeService::get_instance()->lists($user_query_struct);
$userobj = user::get_instance();
foreach ($users as $key => $rowuser) {
$users[$key]['userinfo'] = $userobj->get($rowuser['user_id']);
}
/* 调用列表 */
$this->template->content->user_list = $users;
$this->template->content->where = $where_view;
$this->template->content->pay_banks = Kohana::config('pay_banks');
}
示例5: __construct
public function __construct()
{
role::check('site_seo');
parent::__construct();
if ($this->is_ajax_request() == TRUE) {
$this->template = new View('layout/default_json');
}
}
示例6: __construct
public function __construct()
{
parent::__construct();
if ($this->is_ajax_request()) {
$this->template = new View('layout/default_json');
}
role::check('order_edit');
}
示例7: index
function index()
{
//判断用户是否是已经登录状态
$data = role::get_manager();
if ($data['id'] > 0) {
$data['success'] = 'true';
$data['msg'] = 1;
} else {
$data['success'] = 'false';
$data['msg'] = 1;
}
$username = $this->input->post('username');
$password = $this->input->post('password');
$secode = $this->input->post('secode');
$remember = $this->input->post('remember');
$data['success'] = 'false';
//验证登录
$manager = role::log_in($username, $password);
if (isset($manager['username'])) {
//判断普通账号的状态、权限
if (!role::is_root($manager['username'])) {
if ($manager['active'] != 1) {
ulog::login($manager['id'], 1);
$data['msg'] = Kohana::lang('o_global.account_was_locked');
}
$actions = role::manager_actions($manager['id'], TRUE);
if (count($actions) < 1) {
ulog::login($manager['id'], 2);
$data['msg'] = Kohana::lang('o_global.account_permission_enough');
}
}
//是否记录用户名
if ($remember == 1) {
cookie::set('opococ_username', $username);
} else {
cookie::delete('opococ_username');
}
//清除记录登录错误记录
//Session::instance()->delete('login_error_count');
//记入SESSION
role::set_manager_session($manager);
//记录日志
ulog::login($manager['id']);
$data['success'] = 'true';
$data['msg'] = 1;
/*if(empty($request_url))
{
remind::set(Kohana::lang('o_global.login_success'), '/index', 'success');
}
else
{
$request_url = url::base() . urldecode($request_url);
remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success');
}*/
}
die(json_encode($data));
}
示例8: __construct
public function __construct()
{
role::check('product_inquiry');
$this->package_name = 'product';
$this->class_name = strtolower(substr(__CLASS__, 0, strpos(__CLASS__, '_')));
parent::__construct();
if ($this->is_ajax_request()) {
$this->template = new View('layout/default_json');
}
}
示例9: __construct
public function __construct()
{
parent::__construct();
if ($this->is_ajax_request() == TRUE) {
$this->template = new View('layout/default_json');
}
role::check('orders');
$this->order_basic_obj = OrderBasic::instance();
$this->order_detail_obj = OrderDetail::instance();
}
示例10: init
public static function init()
{
if (!isset(self::$roles)) {
$qry = DBFactory::getDBQuery();
$qry->execute('select rol_id,rol_name, rol_descr from kb3_roles where rol_site=\'' . KB_SITE . "' order by rol_name");
while ($row = $qry->getRow()) {
self::$roles['keys'][$row['rol_name']] = $row['rol_descr'];
self::$roles['hard'][$row['rol_name']] = $row['rol_descr'];
}
role::register('admin', 'Basic Admin Role');
}
}
示例11: batch_delete
/**
* 批量删除支付方式
*/
public function batch_delete()
{
//初始化返回数据
$return_data = array();
//请求结构体
$request_data = array();
/* 可管理的站点ID列表 */
role::check('manage_payment_type');
try {
$payment_type_ids = $this->input->post('payment_type_id');
if (is_array($payment_type_ids) && count($payment_type_ids) > 0) {
/* 初始化默认查询条件 */
$query_struct = array('where' => array('id' => $payment_type_ids), 'like' => array(), 'limit' => array('per_page' => 300, 'offset' => 0));
$payment_types = Mypayment_type::instance()->query_assoc($query_struct);
/* 删除失败的 */
$failed_payment_type_names = '';
/* 执行操作 */
foreach ($payment_types as $key => $payment_type) {
if (!Mypayment_type::instance($payment_type['id'])->delete()) {
$failed_payment_type_names .= ' | ' . $payment_type['name'];
}
}
if (empty($failed_payment_type_names)) {
throw new MyRuntimeException(Kohana::lang('o_manage.delete_payment_type_success'), 403);
} else {
/* 中转提示页面的停留时间 */
$return_struct['action']['time'] = 10;
$failed_payment_type_names = trim($failed_payment_type_names, ' | ');
throw new MyRuntimeException(Kohana::lang('o_manage.delete_payment_type_error', $failed_payment_type_names), 403);
}
} else {
throw new MyRuntimeException(Kohana::lang('o_global.data_load_error'), 403);
}
} catch (MyRuntimeException $ex) {
$return_struct['status'] = 0;
$return_struct['code'] = $ex->getCode();
$return_struct['msg'] = $ex->getMessage();
//TODO 异常处理
//throw $ex;
if ($this->is_ajax_request()) {
$this->template = new View('layout/empty_html');
$this->template->content = $return_struct['msg'];
} else {
$this->template->return_struct = $return_struct;
$content = new View('info');
$this->template->content = $content;
/* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
/* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
}
}
}
示例12: login
function login($obj)
{
$name = isset($obj->name) ? $obj->name : '';
$password = isset($obj->password) ? $obj->password : '';
$rememberme = isset($obj->rememberme) ? $obj->rememberme : false;
$user = new user();
$listUser = $user->getbynameandpassword($name, $password);
if (count($listUser) > 0) {
$role = new role();
$_SESSION['id'] = $listUser[0]->id;
$_SESSION['name'] = $listUser[0]->name;
$_SESSION['group_id'] = $listUser[0]->group_id;
$_SESSION['role'] = $role->getbyid($listUser[0]->group_id);
if ($rememberme) {
setcookie("tasktrack", "id=" . $listUser[0]->id, time() + 86400, "/");
}
return array("status" => "success", "msg" => "Login Successful");
} else {
return array("status" => "warning", "msg" => "Your User name and password is incorrect!");
}
}
示例13: index
/**
* 列表
*/
public function index()
{
$this->template->content = new View("manage/action_list");
$actions = Myaction::instance()->actions();
//用户可管理权限资源的ID
$user_action_ids = role::get_action_ids();
foreach ($actions as $key => $value) {
if (!in_array($value['id'], $user_action_ids)) {
unset($actions[$key]);
}
}
$this->template->content->actions = $actions;
}
示例14: __construct
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
// checke request is ajax
$this->ajax_request = request::is_ajax();
// Load the template
$this->template = new View($this->template);
if ($this->auto_render == TRUE) {
Event::add('system.post_controller', array($this, '_render'));
}
/**
* 判断用户登录情况
*/
if (isset($_REQUEST['session_id'])) {
$session = Session::instance($_REQUEST['session_id']);
$manager = role::get_manager($_REQUEST['session_id']);
} else {
$session = Session::instance();
$manager = role::get_manager();
}
/* 当前请求的URL */
$current_url = urlencode(url::current(TRUE));
//zhu
if (isset($manager['id'])) {
$active_time = $session->get('Opococ_manager_active_time');
//用户最后操作时间
$session->set('Opococ_manager_active_time', time());
//用户最后操作时间
$login_ip = $session->get('Opococ_manager_login_ip');
//用户登录的IP
//操作超时
if (time() - $active_time > Kohana::config('login.time_out')) {
$session->delete('Opococ_manager');
$session->delete('Opococ_manager_active_time');
$session->delete('Opococ_manager_login_ip');
remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
}
//用户IP(登录状态更换IP需要重新登录)
$ip = tool::get_long_ip();
if ($ip != $login_ip) {
remind::set(Kohana::lang('o_global.login_again'), 'login?request_url=' . $current_url);
}
$this->manager = $manager;
$this->manager_id = $manager['id'];
$this->manager_name = $manager['name'];
$this->manager_is_admin = role::is_root($manager['name']) ? 1 : $manager['is_admin'];
$this->template->manager_data = $manager;
} else {
remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
}
}
示例15: index
public function index()
{
role::check('card_system_manage');
$per_page = controller_tool::per_page();
$orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('order' => 'ASC'), 3 => array('order' => 'DESC'));
$orderby = controller_tool::orderby($orderby_arr);
$query_struct = array('where' => array(), 'orderby' => $orderby, 'limit' => array('per_page' => $per_page, 'offset' => 0));
$total = $this->cardLogDao->count_items_with_condition($query_struct['where']);
$this->pagination = new Pagination(array('base_url' => url::current(), 'uri_segment' => 'page', 'total_items' => $total, 'items_per_page' => $per_page, 'style' => 'digg'));
$query_struct['limit']['offset'] = $this->pagination->sql_offset;
$cardLogList = $this->cardLogDao->lists($query_struct);
$this->template->content = new View("card/card_log_list");
$this->template->content->data = $cardLogList;
}