Lines Matching +full:select +full:- +full:groups -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

10  * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
22 /** @var null|array The list of all groups */
33 $this->debugMsg('PDO extension for PHP not found.', -1, __LINE__);
34 $this->success = false;
38 if (!$this->getConf('dsn')) {
39 $this->debugMsg('No DSN specified', -1, __LINE__);
40 $this->success = false;
45 $this->pdo = new PDO(
46 $this->getConf('dsn'),
47 $this->getConf('user'),
48 conf_decodeString($this->getConf('pass')),
56 $this->debugMsg($e);
57 msg($this->getLang('connectfail'), -1);
58 $this->success = false;
63 $this->cando['addUser'] = $this->checkConfig(
64 ['select-user', 'select-user-groups', 'select-groups', 'insert-user', 'insert-group', 'join-group']
68 $this->cando['delUser'] = $this->checkConfig(
69 ['select-user', 'select-user-groups', 'select-groups', 'leave-group', 'delete-user']
73 $this->cando['modLogin'] = $this->checkConfig(
74 ['select-user', 'select-user-groups', 'update-user-login']
78 $this->cando['modPass'] = $this->checkConfig(
79 ['select-user', 'select-user-groups', 'update-user-pass']
83 $this->cando['modName'] = $this->checkConfig(
84 ['select-user', 'select-user-groups', 'update-user-info:name']
88 $this->cando['modMail'] = $this->checkConfig(
89 ['select-user', 'select-user-groups', 'update-user-info:mail']
92 // can groups be changed?
93 $this->cando['modGroups'] = $this->checkConfig(
94 ['select-user', 'select-user-groups', 'select-groups', 'leave-group', 'join-group', 'insert-group']
98 $this->cando['getUsers'] = $this->checkConfig(
99 ['list-users']
103 $this->cando['getUserCount'] = $this->checkConfig(
104 ['count-users']
107 // can a list of available groups be retrieved?
108 $this->cando['getGroups'] = $this->checkConfig(
109 ['select-groups']
112 $this->success = true;
125 $userdata = $this->selectUser($user);
129 if ($this->checkConfig(['check-pass'])) {
132 $result = $this->query($this->getConf('check-pass'), $userdata);
141 return $passhash->verify_hash($pass, $userdata['hash']);
156 * grps array list of groups the user is in
159 * @param bool $requireGroups whether or not the returned data must include groups
164 $data = $this->selectUser($user);
171 $data['grps'] = $this->selectUserGroups($data);
200 if (($info = $this->getUserData($user, false)) !== false) {
201 msg($this->getLang('userexists'), -1);
213 $this->pdo->beginTransaction();
216 $ok = $this->query($this->getConf('insert-user'), $userdata);
218 $userdata = $this->getUserData($user, false);
221 // create all groups that do not exist, the refetch the groups
222 $allgroups = $this->selectGroups();
225 $ok = $this->addGroup($group);
229 $allgroups = $this->selectGroups();
231 // add user to the groups
233 $ok = $this->joinGroup($userdata, $allgroups[$group]);
237 $this->pdo->commit();
242 $this->pdo->rollBack();
243 $this->debugMsg('Transaction rolled back', 0, __LINE__);
244 msg($this->getLang('writefail'), -1);
258 $this->pdo->beginTransaction();
260 $olddata = $this->getUserData($user);
266 if ($this->getUserData($changes['user'], false)) goto FAIL;
270 $ok = $this->query($this->getConf('update-user-login'), $params);
280 $ok = $this->query($this->getConf('update-user-pass'), $params);
290 $ok = $this->query($this->getConf('update-user-info'), $params);
294 // changing groups?
296 $allgroups = $this->selectGroups();
298 // remove membership for previous groups
301 $ok = $this->leaveGroup($olddata, $allgroups[$group]);
306 // create all new groups that are missing
310 $ok = $this->addGroup($group);
316 if ($added > 0) $allgroups = $this->selectGroups();
318 // add membership for new groups
321 $ok = $this->joinGroup($olddata, $allgroups[$group]);
328 $this->pdo->commit();
333 $this->pdo->rollBack();
334 $this->debugMsg('Transaction rolled back', 0, __LINE__);
335 msg($this->getLang('writefail'), -1);
351 if ($this->deleteUser($user)) $count++;
366 public function retrieveUsers($start = 0, $limit = -1, $filter = null)
383 $result = $this->query($this->getConf('list-users'), $filter);
389 $this->debugMsg("list-users statement did not return 'user' attribute", -1, __LINE__);
392 $users[] = $this->getUserData($row['user']);
395 $this->debugMsg("list-users statement did not return a list of result", -1, __LINE__);
419 $result = $this->query($this->getConf('count-users'), $filter);
421 $this->debugMsg("Statement did not return 'count' attribute", -1, __LINE__);
434 $sql = $this->getConf('insert-group');
436 $result = $this->query($sql, [':group' => $group]);
437 $this->clearGroupCache();
443 * Retrieve groups
453 $groups = array_keys($this->selectGroups());
454 if ($groups === false) return [];
457 return array_splice($groups, $start);
459 return array_splice($groups, $start, $limit);
464 * Select data of a specified user
471 $sql = $this->getConf('select-user');
473 $result = $this->query($sql, [':user' => $user]);
477 $this->debugMsg('Found more than one matching user', -1, __LINE__);
485 $this->debugMsg("Statement did not return 'user' attribute", -1, __LINE__);
488 if (!isset($data['hash']) && !isset($data['clear']) && !$this->checkConfig(['check-pass'])) {
489 $this->debugMsg("Statement did not return 'clear' or 'hash' attribute", -1, __LINE__);
493 $this->debugMsg("Statement did not return 'name' attribute", -1, __LINE__);
497 $this->debugMsg("Statement did not return 'mail' attribute", -1, __LINE__);
513 $this->pdo->beginTransaction();
515 $userdata = $this->getUserData($user);
517 $allgroups = $this->selectGroups();
522 $this->leaveGroup($userdata, $allgroups[$group]);
526 $ok = $this->query($this->getConf('delete-user'), $userdata);
529 $this->pdo->commit();
533 $this->pdo->rollBack();
538 * Select all groups of a user
546 $sql = $this->getConf('select-user-groups');
547 $result = $this->query($sql, $userdata);
550 $groups = [$conf['defaultgroup']]; // always add default config
554 $this->debugMsg("No 'group' field returned in select-user-groups statement", -1, __LINE__);
557 $groups[] = $row['group'];
560 $this->debugMsg("select-user-groups statement did not return a list of result", -1, __LINE__);
563 $groups = array_unique($groups);
564 Sort::sort($groups);
565 return $groups;
569 * Select all available groups
571 * @return array|bool list of all available groups and their properties
575 if ($this->groupcache) return $this->groupcache;
577 $sql = $this->getConf('select-groups');
578 $result = $this->query($sql);
581 $groups = [];
585 $this->debugMsg("No 'group' field returned from select-groups statement", -1, __LINE__);
591 $groups[$group] = $row;
594 $this->debugMsg("select-groups statement did not return a list of result", -1, __LINE__);
597 Sort::ksort($groups);
598 return $groups;
606 $this->groupcache = null;
619 $sql = $this->getConf('join-group');
620 $result = $this->query($sql, $data);
635 $sql = $this->getConf('leave-group');
636 $result = $this->query($sql, $data);
652 $this->debugMsg('No SQL query given', -1, __LINE__);
658 $sth = $this->pdo->prepare($sql);
661 // prepare parameters - we only use those that exist in the SQL
669 $sth->bindValue($key, $value, PDO::PARAM_INT);
671 $sth->bindValue($key, $value);
676 $sth->execute();
681 if (str_starts_with(strtolower($currentsql), 'select')) {
682 $result = $sth->fetchAll();
684 $result = $sth->rowCount();
691 $hasnextrowset = $sth->nextRowset(); // run next rowset
693 $hasnextrowset = false; // driver does not support multi-rowset, should be executed in one time
700 $dsql = $this->debugSQL($sql, $params, !defined('DOKU_UNITTEST'));
701 $this->debugMsg($e, -1, $line);
702 $this->debugMsg("SQL: <pre>$dsql</pre>", -1, $line);
704 $sth->closeCursor();
718 if (!$this->getConf('debug')) return;
720 $err = -1;
721 $msg = $message->getMessage();
722 if (!$line) $line = $message->getLine();
747 $sql = trim($this->getConf($key));
772 $val = $this->pdo->quote($val, PDO::PARAM_INT);
774 $val = $this->pdo->quote($val, PDO::PARAM_BOOL);
778 $val = $this->pdo->quote($val);