private function _checkReturnData($data, $errreturn) { if ($data === false) { self::$errCode = UserModel::$errCode; self::$errMsg = UserModel::$errMsg; return $errreturn; } elseif (empty($data)) { self::$errCode = 5806; self::$errMsg = 'There is no data!'; if (self::$debug === true) { self::$errMsg .= 'The SQL is ' . UserModel::$errMsg; } return $errreturn; } else { self::$errCode = 1; self::$errMsg = 'success'; return $data; } }
/** * 功能:展示所有用户 * @author wxb * 日期:2013/11/21 * */ public function showNameList() { $res = UserModel::showNameList(); self::$errCode = UserModel::$errCode; self::$errMsg = UserModel::$errMsg; return $res; }
/** * 用户登录act * @return bool * @author lzx * modify by yxd 2014-07-05 */ public function act_userLogin() { if (!isset($_POST['username']) || trim($_POST['username']) == '') { self::$errMsg[10030] = get_promptmsg(10030); return false; } if (!isset($_POST['password']) || trim($_POST['password']) == '') { self::$errMsg[10031] = get_promptmsg(10031); return false; } $loginfo = M('User')->userLogin($_POST['username'], $_POST['password']); /*############################### 新增获取导航权限代码#################################### */ $user_power = $loginfo['user_power']; //用户权限数组格式 $menul1 = array(); //一级菜单 $menul2 = array(); //二级菜单 $menul3 = array(); //三级菜单 $user_power = M('topmenu')->getTopmenuLists(array('is_delete' => array('$e' => 0)), 1, 500); //测试用所有权限 foreach ($user_power as $key) { // foreach($user_power as $key=>$value){//权限和导航树组装 $menuInfo = M('topmenu')->getMenuByModel($key['model']); $position = $menuInfo[0]['position']; $sort = $menuInfo[0]['sort']; $pid = $menuInfo[0]['pid']; if ($position == 2) { $menul2[$pid . $sort] = $menuInfo[0]; //二级导航数组 $topMenuInfo = M('topmenu')->getModelBypid($pid); //通过二级导航找一级导航 $topmodel = $topMenuInfo[0]['model']; $topposition = $topMenuInfo[0]['position']; $topsort = $topMenuInfo[0]['sort']; $toppid = $topMenuInfo[0]['pid']; if ($topposition == 1) { $menul1[$topsort] = $topMenuInfo[0]; } //一级导航数组 } if ($position == 3) { $menul3[$sort] = $menuInfo[0]; } } foreach ($user_power as $key) { $menuInfo = M('topmenu')->getMenuByModel($key['model']); $position = $menuInfo[0]['position']; $sort = $menuInfo[0]['sort']; $pid = $menuInfo[0]['pid']; if ($position == 1) { if (!array_key_exists($sort, $menul1)) { $menul1[$sort] = $menuInfo[0]; } } } $Kmenu = array(); ksort($menul1); //导航排序 ksort($menul2); ksort($menul3); $loginfo['menul1'] = $menul1; $loginfo['menul2'] = $menul2; $loginfo['menul3'] = $menul3; /*########################## end 新增获取导航权限代码#############################*/ if (empty($loginfo)) { self::$errMsg = M('User')->getErrorMsg(); return false; } return $loginfo; }