本文整理汇总了PHP中Groups::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Groups::find方法的具体用法?PHP Groups::find怎么用?PHP Groups::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Groups
的用法示例。
在下文中一共展示了Groups::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionChangeInfo
/**
* 修改个人信息
*/
function actionChangeInfo()
{
$this->_pathway->addStep('个人信息');
$currentUser = $this->_app->currentUser();
$user = Users::find()->getById($currentUser['id']);
$form = new Form_User(url('admin::usercenter/changeInfo'));
$form->element('username')->set('readonly', 'true');
$form->remove('password');
$form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name');
$form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name');
$form->remove('enabled');
$form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id']));
if ($this->_context->isPOST() && $form->validate($_POST)) {
try {
$user->changeProps($form->values());
$user->save();
return "{msg:'编辑成功'}";
} catch (QDB_ActiveRecord_ValidateFailedException $ex) {
$form->invalidate($ex);
}
} else {
$form->import($user);
}
$form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true'));
$this->_view['form'] = $form;
}
示例2: grouplistAction
public function grouplistAction()
{
if ($this->request->isPost() == true) {
$this->response->setContentType('application/json');
$user_id = $this->request->getPost('user_id');
$group_list = Groups::find("user_id={$user_id}");
$groups = array();
foreach ($group_list as $group_data) {
$groups[] = array('id' => $group_data->id, 'name' => $group_data->name, 'user_id' => $group_data->user_id, 'count' => count($group_data->groupcontact));
}
$this->response->setContent(json_encode(array('group_list' => $groups)));
$this->response->send();
}
}
示例3: postCreate
public function postCreate()
{
$validator = Validator::make(Input::all(), array('first_name' => 'required|max:30', 'last_name' => 'required|max:30', 'city' => 'required|max:30', 'state' => 'required|max:30', 'sex' => 'required', 'school_registration_code' => 'required|max:80', 'user_registration_code' => 'required|max:80', 'email' => 'max:60|email|unique:users', 'password' => 'required|min:6', 'password_again' => 'required|same:password'));
if ($validator->fails()) {
return Redirect::route('user-account-create')->withErrors($validator)->withInput();
} else {
$school_registration_code = Input::get('school_registration_code');
$user_registration_code = Input::get('user_registration_code');
$school = Schools::where('registration_code', '=', $school_registration_code)->where('code_for_students', '=', $user_registration_code)->where('active', '=', 1)->get();
if (!$school->count()) {
return Redirect::route('admin-account-create')->with('global', 'Please input Correct School code and Admin Code.');
}
$first_name = Input::get('first_name');
$last_name = Input::get('last_name');
$email = Input::get('email');
$sex = Input::get('sex');
$city = Input::get('city');
$state = Input::get('state');
$password = Input::get('password');
// Unique Username
$username = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(1, 10))), 1, 10);
//Activation Code
$code = str_random(60);
$now = date("Y-m-d H-i-s");
$groups = Groups::find(1);
$User = User::create(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'email_updated_at' => $now, 'password' => Hash::make($password), 'password_updated_at' => $now, 'username' => $username, 'sex' => $sex, 'city' => $city, 'state' => $state, 'address_updated_at' => $now, 'code' => $code, 'active' => 0, 'mobile_verified' => 0, 'permissions' => $groups->id, 'school_id' => $school->first()->id));
if ($User) {
//send email
Mail::send('emails.auth.activate.activate-user', array('link' => URL::route('user-account-activate', $code), 'username' => $username), function ($message) use($User) {
$message->to($User->email, $User->voter_id)->subject('Activate Your Account');
});
return Redirect::route('user-sign-in')->with('global', 'You have been Registered. You can activate Now.');
} else {
return Redirect::route('user-sign-in')->with('global', 'You have not Been Registered. Try Again Later Some time.');
}
}
}
示例4: editAction
public function editAction($id = null)
{
if (empty($id)) {
// Forward to index
return $this->response->redirect("/user");
}
// set page title
$this->view->pageTitle = 'Edit User';
// breadcrumb
$this->pageBreadcrumbs[] = 'Edit User';
$this->view->setVar('pageBreadcrumbs', $this->pageBreadcrumbs);
// get groups
$this->view->groups = Groups::find(array('name <> "admin"', 'order' => 'name'));
// create group list
$groupList = array();
foreach ($this->view->groups as $group) {
$groupList[$group->id] = $group->label;
}
$this->view->id = $id;
$this->view->groupId = null;
$this->view->firstName = null;
$this->view->lastName = null;
$this->view->username = null;
$this->view->status = null;
// process post
if ($this->request->isPost()) {
// Receiving the variables sent by POST
$this->view->groupId = $this->request->getPost('group_id', 'int');
$this->view->firstName = $this->request->getPost('first_name', 'string');
$this->view->lastName = $this->request->getPost('last_name', 'string');
$this->view->username = $this->request->getPost('username', 'email');
$this->view->status = $this->request->getPost('status', 'string');
// make sure email does not exists
// find user in the database
$user = Users::findFirst(array("username = :email: AND id <> :id:", "bind" => array('email' => $this->view->username, 'id' => $id)));
if (!empty($user)) {
$this->getFlashSession('error', 'Email already exists for another user.', true);
return true;
} else {
// verify group selection
if (!in_array($this->view->groupId, array_keys($groupList))) {
$this->getFlashSession('error', 'Invalid user type selection.', true);
return;
} else {
// make sure you only edit the user of logged in customer
$user = Users::findFirst(array("id = :id:", "bind" => array('id' => $id)));
// invalid user
if (empty($user)) {
$this->getFlashSession('error', 'Invalid user.', true);
// Forward to dashboard
return $this->response->redirect("/user");
}
$user->group_id = $this->view->groupId;
$user->first_name = $this->view->firstName;
$user->last_name = $this->view->lastName;
$user->username = $this->view->username;
$user->status = $this->view->status == 'on' ? 'active' : 'inactive';
$user->modified = date('Y-m-d H:i:s');
$user->modified_by = $this->userSession['email'];
if ($user->update() == false) {
$this->logger->log("Failed to save user", \Phalcon\Logger::ERROR);
foreach ($user->getMessages() as $message) {
$this->logger->log($message, \Phalcon\Logger::ERROR);
}
$this->getFlashSession('error', 'Sorry, we could not update the user record. Please try again.', true);
} else {
$this->getFlashSession('success', 'User record updated.', true);
// Forward to dashboard
return $this->response->redirect("/user");
}
}
}
} else {
// make sure you only edit the user to logged in customer
$user = Users::findFirst(array("id = :id:", "bind" => array('id' => $id)));
if (!empty($user)) {
$this->view->id = $user->id;
$this->view->groupId = $user->group_id;
$this->view->firstName = $user->first_name;
$this->view->lastName = $user->last_name;
$this->view->username = $user->username;
$this->view->status = $user->status == 'active' ? 'on' : 'off';
} else {
$this->getFlashSession('error', 'Invalid user.', true);
// Forward to dashboard
return $this->response->redirect("/user");
}
}
}
示例5: actionGroupBind
/**
* 绑定权限 用户组
*/
function actionGroupBind()
{
$this->_pathway->addStep('用户组绑定权限');
$id = $this->_context->id;
$group = Groups::find()->getById($id);
if ($this->_context->isPOST()) {
try {
//绑定角色
$role_ids = $this->_context->role_ids;
$role_ids = $role_ids != '' ? Q::normalize($role_ids) : '0';
$group->roles = Roles::find("id in (?)", $role_ids)->getAll();
//绑定分类
$category_ids = $this->_context->category_ids;
$category_ids = $category_ids != '' ? Q::normalize($category_ids) : '0';
$group->categorys = Category::find("id in (?)", $category_ids)->getAll();
//保存修改
$group->save();
} catch (QValidator_ValidateFailedException $ex) {
}
}
//获得绑定的角色编号
$role = Roles::find('enabled=1')->order('weight desc')->getAll();
$role_ids = array();
foreach ($group->roles as $v) {
$role_ids[] = $v->id;
}
//获得绑定的分类编号
$category = Category::find('enabled=1')->order('weight desc')->getAll();
$category_ids = array();
foreach ($group->categorys as $v) {
$category_ids[] = $v->id;
}
//将需要数据发送到视图
$this->_view['group'] = $group;
$this->_view['role'] = $role;
$this->_view['role_ids'] = $role_ids;
$this->_view['category'] = $category;
$this->_view['category_ids'] = $category_ids;
}
示例6: hasPermission
static function hasPermission($permission)
{
$users_group = DB::table('users_groups')->where("user_id", Auth::user()->id)->first();
$group = Groups::find($users_group->group_id);
if ($group->name == "admin") {
return true;
}
if ($group->name == "department-admin") {
$company_department_admin = DepartmentAdmins::where("user_id", Auth::user()->id)->first();
if (empty($company_department_admin)) {
Session::flash("error_msg", trans('msgs.you_are_not_connected_to_any_department'));
//Not connected to any department so no permissions available
return false;
}
$department = Department::find($company_department_admin->department_id);
$permissions = explode(",", $department->permissions);
if (in_array($permission, $permissions)) {
return true;
} else {
return false;
}
}
if ($group->name == "operator") {
$operator = User::find(Auth::user()->id);
$permissions = explode(",", $operator->permissions);
if (in_array($permission, $permissions)) {
return true;
} else {
return false;
}
}
}
示例7: actionPutout
function actionPutout()
{
$this->_pathway->addStep('媒资编目');
$id = $this->_context->id;
$file = Files::find()->getById($id);
if ($file->isNewRecord()) {
return '记录不存在或已删除';
}
if (!file_exists($file->path . $file->name . '.' . $file->ext)) {
return '文件不存在或已删除';
}
//保存编目信息
if ($this->_context->isPOST()) {
$file->level = $this->_context->level;
if (!isset($this->_context->groups) || in_array('all', $this->_context->groups)) {
$file->groups = 'all';
} else {
$file->groups = ',';
foreach ($this->_context->groups as $v) {
$file->groups .= $v . ',';
}
}
$file->is_download = $this->_context->is_download;
$file->status = $this->_context->status;
$file->putout_username = $this->_view['currentUser']['username'];
$file->putout_at = time();
try {
$file->save();
} catch (QDB_ActiveRecord_ValidateFailedException $ex) {
return '提交失败!';
}
//更新索引
$filesCounter = FilesCounter::find()->getById(1);
if ($filesCounter->isNewRecord()) {
$filesCounter = new FilesCounter();
$filesCounter->id = 1;
}
$filesCounter->file_id = $file->id();
try {
$filesCounter->save();
@exec(Q::ini('appini/search/sphinxDelta'));
} catch (QDB_ActiveRecord_ValidateFailedException $ex) {
return '更新索引失败!';
}
return '提交成功!';
}
$this->_view['file'] = $file;
$this->_view['levels'] = Levels::find('enabled=1')->getAll();
$this->_view['groups'] = Groups::find('enabled=1')->getAll();
}