本文整理汇总了PHP中Model_User::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::findById方法的具体用法?PHP Model_User::findById怎么用?PHP Model_User::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::findById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUseRoleAct
/**
* 获取用户所得到的权限
* @param int $userId
*/
public function getUseRoleAct($userId)
{
$this->_modelUser = $this->_getGlobalData('Model_User', 'object');
$userInfo = $this->_modelUser->findById($userId);
$userRolesArr = $userInfo['roles'];
$userRolesArr = explode(',', $userRolesArr);
#------用户act------#
$userAct = $userInfo['act'];
$userAct = $userAct ? explode(',', $userAct) : array();
#------用户act------#
$dataList = $this->findAll();
foreach ($dataList as $key => $value) {
if ($value['allow'] == RBAC_EVERYONE) {
//如果为所有马上为true
$dataList[$key]['selected'] = 1;
continue;
}
$curRoles = explode(',', $value['allow']);
$intersect = array_intersect($curRoles, $userRolesArr);
if (count($intersect)) {
$dataList[$key]['selected'] = 1;
} else {
if (in_array($value['value'], $userAct)) {
$dataList[$key]['selected'] = 2;
} else {
$dataList[$key]['selected'] = 0;
}
}
}
return $dataList;
}
示例2: _userEdit
private function _userEdit()
{
if ($this->_isPost()) {
$updateArr = array('service_id' => $_POST['service_id'], 'department_id' => $_POST['department_id'], 'roles' => implode(',', $_POST['roles']), 'nick_name' => $_POST['nick_name'], 'date_updated' => CURRENT_TIME, 'order_vip_level' => count($_POST['order_vip_level']) ? implode(',', $_POST['order_vip_level']) : '');
if ($_POST['password']) {
//更改密码
if ($_POST['password'] != $_POST['pwd_confirm']) {
$this->_utilMsg->showMsg('两次密码输入不一致', -1, 2);
}
$updateArr['password'] = md5($_POST['password']);
}
if ($this->_modelUser->update($updateArr, "Id={$_POST['Id']}")) {
$this->_modelUser->createCache();
$this->_utilMsg->showMsg('修改用户资料成功', 1, Tools::url(CONTROL, ACTION));
} else {
$this->_utilMsg->showMsg('修改用户资料失败', 1);
}
} else {
$departmentList = $this->_modelDepartment->findAll();
$departmentList = $this->_modelDepartment->getTtwoArrConvertOneArr($departmentList, 'Id', 'name');
$rolesList = $this->_modelRoles->findAll();
$rolesList = $this->_modelRoles->getTtwoArrConvertOneArr($rolesList, 'role_value', 'role_name');
$dataList = $this->_modelUser->findById($_GET['Id']);
$dataList['roles'] = explode(',', $dataList['roles']);
$this->_view->assign('selectedVipLevel', explode(',', $dataList['order_vip_level']));
$this->_view->assign('vipLevel', array(0, 1, 2, 3, 4, 5, 6));
$this->_view->assign('dataList', $dataList);
$this->_view->assign('rolesList', $rolesList);
$this->_view->assign('departmentList', $departmentList);
$this->_view->set_tpl(array('body' => 'User/UserEdit.html'));
$this->_utilMsg->createNavBar();
$this->_view->display();
}
}
示例3: userdemoteAction
public function userdemoteAction()
{
$user = new Model_User();
if ($user->findById($this->getParamNumeric(AdminController::USER_PARAM))) {
$user->demote();
$this->getLog()->info("Demoted {$user}");
}
return $this->_helper->redirector('index');
}
示例4: cEdit
/**
* 编辑用户
*/
public function cEdit()
{
$this->_modelUser = $this->getGlobal('model/User', 'Model_User');
if ($this->isPost()) {
$postArr = array('id' => intval($this->getR('id')), 'vuser' => $this->getR('vuser'), 'pwd' => $this->getR('pwd'), 'pwd1' => $this->getR('pwd1'), 'role' => $this->getR('role'), 'login_count' => RegistryRequest::getInstance()->absInt('login_count'));
$info = $this->_modelUser->edit($postArr);
if ($info['status'] == 1) {
$this->success($info['info'], $info['url']);
} else {
$this->error($info['info'], $info['url']);
}
} else {
$this->_modelRole = $this->getGlobal('model/Role', 'Model_Role');
$roles = $this->_modelRole->getAll();
$this->assign('roleList', $roles);
$dataList = $this->_modelUser->findById($this->getR('id'));
$dataList['role'] = $dataList['role'] ? explode(',', $dataList['role']) : array();
$this->assign('dataList', $dataList);
$this->display(VIEW_PAGE);
}
}
示例5: _userModelAct
/**
* 用户的额外模块权限
*/
private function _userModelAct()
{
$moudleName = trim($_GET['moudle_name']);
//模块标识名
if (empty($moudleName)) {
$this->_utilMsg->showMsg('模块名为空', 1, 1, false);
}
$userInfo = $this->_modelUser->findById(intval($_GET['user_id']));
if (!$userInfo) {
$this->_utilMsg->showMsg('无此用户', 1, 1, false);
}
$moudleAct = array();
//记录用户的所有 个人模块权限
if ($userInfo['moudle_act']) {
$moudleAct = unserialize($userInfo['moudle_act']);
}
if ($this->_isPost()) {
if ($_POST['Id'] && is_array($_POST['Id'])) {
$moudleAct[$moudleName] = array_unique($_POST['Id']);
} else {
unset($moudleAct[$moudleName]);
//清空没有权限的模块
}
$updateArr = array('moudle_act' => serialize($moudleAct));
if ($this->_modelUser->update($updateArr, "Id={$_POST['user_id']}")) {
//更新操作
$this->_modelUser->createCache();
$this->_utilMsg->showMsg('操作成功', 1, Tools::url(CONTROL, ACTION));
} else {
$this->_utilMsg->showMsg('操作失败', 1);
}
} else {
$actForCount = $moudleAct;
$actForCount['Default'] = $userInfo['act'] ? explode(',', $userInfo['act']) : array();
$moudlesUrl = $this->_getMoudlesUrl($actForCount);
//所有模块的链接
$this->_view->assign('moudlesUrl', $moudlesUrl);
$_modelMoudle = $this->_getGlobalData('Model_Moudle', 'object');
$act = $_modelMoudle->getAct($moudleName);
//获得此模块的全部act
$checkBox = '';
//输出的内容
$userRoles = $userInfo['roles'] ? explode(',', $userInfo['roles']) : array();
//用户的所有角色
$userMoudleAct = is_array($moudleAct[$moudleName]) && $moudleAct[$moudleName] ? $moudleAct[$moudleName] : array();
//用户在此模块的个人权限
if ($act) {
foreach ($act as &$control) {
$checkBox .= '<tr><td align="left">';
$issetRoles = $control['act'] ? $control['act'] : array();
//此功能里有权限的角色
$checked = '';
if (array_intersect($userRoles, $issetRoles)) {
//角色交集检查权限
$checked = 'checked="checked" disabled="disabled" ';
} elseif (in_array($control['value'], $userMoudleAct)) {
//检查是否有个人权限
$checked = 'checked="checked" ';
}
$checkBox .= "<input type='checkbox' value='{$control['value']}' name='Id[]' {$checked} /><b>{$control['name']}.{$control['value']}</b><hr />";
if ($control['class_methods']) {
foreach ($control['class_methods'] as &$method) {
$c_a = "{$control['value']}_{$method['value']}";
$issetRoles = $method['act'] ? $method['act'] : array();
//此功能里有权限的角色
$checked = '';
if (array_intersect($userRoles, $issetRoles)) {
//角色交集检查权限
$checked = 'checked="checked" disabled="disabled" ';
} elseif (in_array($c_a, $userMoudleAct)) {
//检查是否有个人权限
$checked = 'checked="checked" ';
}
$checkBox .= " →<input type='checkbox' value='{$c_a}' name='Id[]' {$checked} />{$method['name']} .{$c_a}<br/>";
}
}
$checkBox .= '</td></tr>';
}
}
$this->_view->assign('checkBox', $checkBox);
$this->_utilMsg->createNavBar();
$this->_view->set_tpl(array('body' => 'User/UserAct.html'));
$this->_view->display();
}
}
示例6: generateDiaryAction
public function generateDiaryAction()
{
if ($this->getRequest()->isPost()) {
$userid = $this->_getParam('id');
$user = Model_User::findById($userid);
$diary = $user->Diaries;
for ($day = 0; $day < 7; $day++) {
$now = Zend_Date::now();
$date = $now->addDay($day);
$diary[]->dateField = $date->toString('yyyy-MM-dd');
}
$user->save();
}
exit;
}