本文整理汇总了PHP中Roles::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::fetchAll方法的具体用法?PHP Roles::fetchAll怎么用?PHP Roles::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::fetchAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
function editAction()
{
$request = new Bolts_Request($this->getRequest());
$roles_table = new Roles();
$role = null;
if ($request->has('id')) {
if (!is_null($request->id)) {
$role = $roles_table->fetchRow($roles_table->select()->where("id = ?", $request->id));
if (!is_null($role)) {
// we do not edit the guest role
if ($role->shortname == "guest") {
$this->_redirect("/bolts/role");
}
$this->view->role = $role->toArray();
$this->view->role_tree = $roles_table->getRoleTree(null, $role->id);
$this->view->inherited_ids = $roles_table->getInheritedRoles($role->id);
}
}
}
if (is_null($role)) {
$this->view->role_tree = $roles_table->getRoleTree();
}
if ($this->getRequest()->isPost()) {
$errors = array();
if ($request->has('inherit_role')) {
$parents = array();
foreach ($request->inherit_role as $inherit_role) {
$parents = array_merge($parents, $roles_table->getAllAncestors($inherit_role));
}
$inherit_ids = array();
foreach ($request->inherit_role as $inherit_role) {
if (!in_array($inherit_role, $parents)) {
$inherit_ids[] = $inherit_role;
}
}
}
if ($request->has('shortname')) {
$shortname = $request->shortname;
if (!Bolts_Validate::checkLength($request->shortname, 1, 255)) {
$errors[] = $this->_T("Shortname must be between 1 and 255 chars.");
}
} else {
$errors[] = $this->_T("Shortname is a requried field.");
}
$description = $request->description;
$isadmin = (int) $request->checkbox('isadmin');
if (count($errors) == 0) {
$data = array('shortname' => $shortname, 'description' => $description, 'isadmin' => $isadmin);
//If we have an id, this is an update.
$id = (int) $this->_request->getPost('id');
if ($id != 0) {
$where = 'id = ' . $id;
$roles_table->update($data, $where);
} else {
//We don't, this is an insert.
$id = $roles_table->insert($data);
}
$roles_table->removeInheritedRole($id);
foreach ($inherit_ids as $in_id) {
$roles_table->setInheritedRole($id, $in_id);
}
$this->_redirect("/bolts/role");
} else {
$this->view->errors = $errors;
}
}
if ($request->has('id')) {
// this is an edit
$id = $request->id;
if ($id > 0) {
$this->view->role = $roles_table->fetchRow('id = ' . $id)->toArray();
}
$this->view->inherited_ids = $roles_table->getInheritedRoles($id);
} else {
foreach ($roles_table->fetchAll()->toArray() as $role) {
$role_choices[$role['id']] = $role['shortname'];
}
$this->view->role_choices = $role_choices;
}
}
示例2: editAction
function editAction()
{
$errors = array();
$users_table = new Users();
$users_roles_table = new UsersRoles();
$request = new Bolts_Request($this->getRequest());
$countries_table = new Countries();
$this->view->countries = $countries_table->getCountriesArray('Choose a country...');
$roles_table = new Roles();
$roles = $roles_table->fetchAll(NULL, "shortname ASC");
$arRoles = array();
foreach ($roles as $role) {
if (!strpos($role->shortname, "-base")) {
$arRoles[$role->id] = $role->description;
}
}
$this->view->roles = $arRoles;
$is_new = true;
$user = array();
if ($request->has('username')) {
$obUser = $users_table->fetchByUsername($request->username);
if (!is_null($obUser)) {
$is_new = false;
$user_roles = $users_roles_table->fetchAll($users_roles_table->select()->where("username = ?", $obUser->username));
if (count($user_roles) > 0) {
$tmp_selected = array();
foreach ($user_roles as $user_role) {
$tmp_selected[] = $user_role->role_id;
}
$this->view->selected_roles = $tmp_selected;
}
$user = $obUser->toArray();
}
}
$this->view->is_new = $is_new;
if ($is_new) {
// defaults for form fields
$user['username'] = "";
$user['full_name'] = "";
$user['aboutme'] = "";
}
$pre_render = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_render", array('user' => $user, 'request' => $this->_request));
// FILTER HOOK
$user = $pre_render['user'];
foreach ($pre_render as $key => $value) {
if ($key != "user") {
$this->view->{$key} = $value;
}
}
// $tags = unserialize($user['tags']);
if ($this->getRequest()->isPost()) {
$errors = array();
$request->stripTags(array('full_name', 'email', 'newpassword', 'confirm'));
// $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm', 'aboutme'));
$user['username'] = $request->username;
$user['email'] = $request->email;
$user['password'] = $request->newpassword;
$user['confirm'] = $request->confirm;
$user['full_name'] = $request->full_name;
$user['birthday'] = $birthday = strtotime($request->Birthday_Day . $request->Birthday_Month . $request->Birthday_Year);
$user['gender'] = $request->gender;
$user['country_code'] = $request->country_code;
$user['aboutme'] = $request->aboutme;
// validate username
$username_validator = new Zend_Validate();
$username_validator->addValidator(new Zend_Validate_StringLength(1, Bolts_Registry::get('username_length')));
$username_validator->addValidator(new Zend_Validate_Alnum());
if (!$username_validator->isValid($user['username'])) {
$show_username = "'" . $user['username'] . "'";
if (trim($user['username']) == "") {
$show_username = "[" . $this->_T("empty") . "]";
}
$errors[] = $this->_T("%s isn't a valid username. (Between %d and %d characters, only letters and numbers)", array($show_username, 1, Bolts_Registry::get('username_length')));
}
if ($is_new) {
$user_where = $users_table->getAdapter()->quoteInto('username = ?', $user['username']);
if ($users_table->getCountByWhereClause($user_where) > 0) {
$errors[] = $this->_T("The username '%s' is already in use", $user['username']);
}
}
// validate email
if (!Bolts_Validate::checkEmail($user['email'])) {
$errors[] = $this->_T("Email is not valid");
}
// check to see if email is in use already by someone else
if ($users_table->isEmailInUse($user['email'], $user['username'])) {
$errors[] = $this->_T("Email already in use");
}
// if password isn't blank, validate it
if ($user['password'] != "") {
if (!Bolts_Validate::checkLength($user['password'], 6, Bolts_Registry::get('password_length'))) {
$errors[] = $this->_T("Password must be between 6 and 32 characters");
}
// if password is set, make sure it matches confirm
if ($user['password'] != $user['confirm']) {
$errors[] = $this->_T("Passwords don't match");
}
}
// convert birthday_ts to mysql date
$birthday = date("Y-m-d H:i:s", $user['birthday']);
//.........这里部分代码省略.........
示例3: findRolesCandidats
function findRolesCandidats($annee)
{
$t = new Roles();
$db = $t->getAdapter();
$s = $t->select()->setIntegrityCheck(false)->from('unite_role')->join('unite_type', 'unite_type.id = unite_role.type', array())->join('unite', 'unite.type = unite_type.id', array())->joinLeft('appartenance', 'appartenance.role = unite_role.id AND ' . 'appartenance.unite = unite.id AND ' . ('(' . $db->quoteInto('appartenance.debut < ?', Strass_Controller_Action_Helper_Annee::dateFin($annee)) . ' AND ' . $db->quoteInto('(appartenance.fin IS NULL OR appartenance.fin < ?)', Strass_Controller_Action_Helper_Annee::dateFin($annee)) . ')'), array())->where('unite.id = ?', $this->id)->where('appartenance.id IS NULL');
return $t->fetchAll($s);
}
示例4: findRolesCandidats
function findRolesCandidats($unite, $filter_current = true)
{
$t = new Roles();
$db = $t->getAdapter();
$s = $t->select()->setIntegrityCheck(false)->from('unite_role')->join('unite_type', 'unite_type.id = unite_role.type', array())->join('unite', 'unite.type = unite_type.id', array())->where('unite.id = ?', $unite->id);
if ($filter_current) {
$s->joinLeft('appartenance', 'appartenance.role = unite_role.id AND ' . 'appartenance.unite = unite.id AND ' . $db->quoteInto('appartenance.individu', $this->id), array())->where('appartenance.id IS NULL');
}
return $t->fetchAll($s);
}
示例5: adminAction
function adminAction()
{
$this->view->individu = $individu = $this->_helper->Individu();
$this->assert(null, $individu, 'admin', "Vous n'avez pas le droit d'administrer " . "l'inscription de cet individu.");
$this->metas(array('DC.Title' => 'Administrer ' . $individu->getFullname()));
$this->actions->append("Éditer la fiche", array('controller' => 'individus', 'action' => 'editer'), array(null, $individu));
$as = $individu->findAppartenances(null, 'debut DESC');
if (!$as->count()) {
$this->view->apps = null;
} else {
$this->view->apps = $m = new Wtk_Form_Model('apps');
$tu = new Unites();
$us = $tu->fetchAll(null);
$eu = array();
foreach ($us as $u) {
$eu[$u->id] = mb_substr($u->getFullName(), 0, 32);
}
$tr = new Roles();
$rs = $tr->fetchAll(null, 'ordre');
$er = array();
foreach ($rs as $r) {
$er[$r->id] = substr($r->slug, 0, 7);
}
$i = $m->addTable('appartenances', "Appartenances", array('unite' => array('Enum', 'Unité', $eu), 'role' => array('Enum', 'Role', $er), 'titre' => array('String', 'Titre'), 'debut' => array('Date', 'Début'), 'clore' => array('Bool', 'Clore', false), 'fin' => array('Date', 'Fin')));
foreach ($as as $a) {
$i->addRow($a->unite, $a->role, $a->titre, $a->debut, (bool) $a->fin, $a->fin);
}
$m->addNewSubmission('enregistrer', 'Enregistrer');
if ($m->validate()) {
$t = new Appartenances();
$db = $t->getAdapter();
$db->beginTransaction();
try {
foreach ($as as $a) {
$a->delete();
}
foreach ($i as $row) {
$data = array('individu' => $individu->id, 'unite' => $row->unite, 'role' => $row->role, 'titre' => $row->titre, 'debut' => $row->debut);
if ($row->clore) {
$data['fin'] = $row->fin;
} else {
$data['fin'] = null;
}
$t->insert($data);
}
$this->logger->info("Inscription éditée", $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug), true));
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug));
}
}
}
示例6: browseAction
public function browseAction()
{
$form = new Modules_Admin_Controllers_Users_Browse_Form();
$cache = Zend_Registry::get('cache');
$roles = $cache->load(md5(UNIQUE_HASH . 'roles'));
if ($roles === false) {
$rolesTable = new Roles();
$roles = $rolesTable->fetchAll();
$cache->save($roles, md5(UNIQUE_HASH . 'roles'));
}
foreach ($roles as $role) {
if ($role->id != 1) {
$form->getElement('role')->addMultiOption($role->id, $role->name);
}
}
$router = $this->getFrontController()->getRouter();
if ($page = (int) $this->getRequest()->getParam('page')) {
$router->setGlobalParam('page', $page);
}
if ($belongs = (int) $this->getRequest()->getParam('belongs')) {
$router->setGlobalParam('belongs', $belongs);
}
if ($role = $this->getRequest()->getParam('role')) {
$router->setGlobalParam('role', $role);
}
if ($order = $this->getRequest()->getParam('order')) {
$router->setGlobalParam('order', $order);
}
if ($sort = $this->getRequest()->getParam('sort')) {
$router->setGlobalParam('sort', $sort);
}
$form->getElement('role')->setValue($role);
$form->getElement('belongs')->setValue($belongs);
$this->view->form = $form;
$usersTable = new Users();
#fetching the data from table
$select = $usersTable->select()->from(array('u' => 'users'));
$select->setIntegrityCheck(false);
$select->where('u.id > ?', 1);
if ($role) {
if ($belongs) {
$select->join(array('ur' => 'users_roles'), 'ur.user=u.id AND ur.role=' . (int) $role);
} else {
$select->joinLeft(array('ur' => 'users_roles'), 'ur.user=u.id AND ur.role=' . (int) $role);
$select->where('ur.role is null');
}
}
switch ($sort) {
case 'desc':
$sort = 'DESC';
break;
default:
$sort = 'ASC';
}
switch ($order) {
case 'username':
$select->order('u.email ' . $sort);
break;
case 'email':
$select->order('u.email ' . $sort);
break;
case 'dateOfRegistration':
$select->order('u.registered_timestamp ' . $sort);
break;
}
$this->view->usersPaginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$this->view->usersPaginator->setItemCountPerPage(50);
$this->view->usersPaginator->setCurrentPageNumber($page);
}