public function __construct() { parent::__construct(); parent::load('model', 'system/contrib/auth'); import('system/share/network/redirect'); $userinfo = User::info(); /*当前客户登陆的话*/ if ($userinfo['role'][0]['alias'] == '客户' || !$userinfo['role'] && User::is_authenticated()) { HTTPRedirect::to('customer'); } }
public function logout() { parent::load('model', 'system/contrib/auth.User'); User::logout(); import('system/share/network/redirect'); HTTPRedirect::to(url_reverse('auth_login')); }
public static function login_required($base_app) { $base_app->load('model', 'system/contrib/auth.User', false); if (!User::is_authenticated()) { import('system/share/network/redirect'); HTTPRedirect::to('accounts/login'); Boot::shutdown(); } return true; }
public function ls($workflow = null, $mix = false, $orders = null) { $smarty = parent::load('smarty'); $userinfo = User::info(); /* * 缓存ID */ $cache_id = sprintf('order_list_%s_%s_%s', $workflow, $_GET['page'], User::info('id')); /* * 订单导航 */ $_navigation = Workflow::get_navigation($userinfo); if (!$workflow) { if ($_navigation[0]['alias'] == '录入订单') { $action = $_navigation[1]['action']; } else { $action = $_navigation[0]['action']; } HTTPRedirect::to($action); } if (!$workflow instanceof Workflow) { $workflow = Workflow::get_by_id($workflow); } $smarty->assign('page_title', $workflow->name); /* * 当前工作流程是否允许当前用户查看 */ $role_ids = array_filter(explode(',', $workflow->roles)); AuthPlugins::required($this, $role_ids); /* * 当前导航 */ foreach ($_navigation as $nav) { if ($nav['id'] == $workflow->id) { $navigation[$nav['id']]['active'] = true; } $navigation[$nav['id']] = $nav; } $smarty->assign('page_title', $navigation[$workflow->id]['name']); $smarty->assign('active_workflow', $workflow->id); $smarty->assign('order_navigation', $navigation); /* * 获取工作流程中, 当前的可操作选项 */ $operation = Workflow::get_operation($workflow->sequence, User::info()); $smarty->assign('operations', $operation); $smarty->assign('workflow', $workflow); if (!$mix) { if (method_exists('OrderController', 'order_list_custom_' . $workflow)) { $method_name = 'order_list_custom_' . $workflow->id; $orders = $this->{$method_name}($workflow->id); } else { /* * 订单列表 */ if (count($workflow->Children) > 0) { $get_by_id = array(); foreach ($workflow->Children as $child) { $get_by_id[] = $child->id; } $get_by_id[] = $workflow->id; } else { $get_by_id = $workflow->id; } /* * 在跟进订单之后 只显示当前用户所有的 */ if ($workflow->id > 2 && !User::has_role('总经理')) { $orders = Order::get_list($get_by_id, $userinfo['id'], $userinfo['role'][0]['alias']); } else { $orders = Order::get_list($get_by_id); } } if (User::has_role('技术经理')) { $operation[] = array('label' => '分配任务', 'action' => 'order/select_designer'); } } /* * 分页 */ import('system/share/web/paginator'); $paginator = new Paginator($orders, $_GET['page'], 10); $smarty->assign('paginator', $paginator->output()); /* * 是否客服 */ if (User::has_role('客服')) { $smarty->assign('is_customer_service', true); } /* * 尝试显示对应操作的模板 */ try { if ($workflow->template) { $tpl = $workflow->template; } else { $tpl = str_replace('order/list/', 'order/list_', $navigation[$workflow->id]['action']); } $smarty->display($tpl); } catch (DoesNotExistsException $e) { $smarty->display('order/list'); } }