Lines Matching +full:join +full:- +full:group -(+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
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']
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']
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']);
164 $data = $this->selectUser($user);
171 $data['grps'] = $this->selectUserGroups($data);
184 * The new user HAS TO be added to the default group by this
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);
222 $allgroups = $this->selectGroups();
223 foreach ($grps as $group) {
224 if (!isset($allgroups[$group])) {
225 $ok = $this->addGroup($group);
229 $allgroups = $this->selectGroups();
232 foreach ($grps as $group) {
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);
296 $allgroups = $this->selectGroups();
299 foreach ($oldgroups as $group) {
300 if (!in_array($group, $changes['grps']) && isset($allgroups[$group])) {
301 $ok = $this->leaveGroup($olddata, $allgroups[$group]);
308 foreach ($changes['grps'] as $group) {
309 if (!isset($allgroups[$group])) {
310 $ok = $this->addGroup($group);
315 // reload group info
316 if ($added > 0) $allgroups = $this->selectGroups();
319 foreach ($changes['grps'] as $group) {
320 if (!in_array($group, $oldgroups)) {
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)
371 if (isset($filter['grps'])) $filter['group'] = $filter['grps'];
372 foreach (['user', 'name', 'mail', 'group'] as $key) {
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__);
410 if (isset($filter['grps'])) $filter['group'] = $filter['grps'];
411 foreach (['user', 'name', 'mail', 'group'] as $key) {
419 $result = $this->query($this->getConf('count-users'), $filter);
421 $this->debugMsg("Statement did not return 'count' attribute", -1, __LINE__);
427 * Create a new group with the given name
429 * @param string $group
432 public function addGroup($group)
434 $sql = $this->getConf('insert-group');
436 $result = $this->query($sql, [':group' => $group]);
437 $this->clearGroupCache();
453 $groups = array_keys($this->selectGroups());
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__);
506 * Delete a user after removing all their group memberships
513 $this->pdo->beginTransaction();
515 $userdata = $this->getUserData($user);
517 $allgroups = $this->selectGroups();
519 // remove group memberships (ignore errors)
520 foreach ($userdata['grps'] as $group) {
521 if (isset($allgroups[$group])) {
522 $this->leaveGroup($userdata, $allgroups[$group]);
526 $ok = $this->query($this->getConf('delete-user'), $userdata);
529 $this->pdo->commit();
533 $this->pdo->rollBack();
541 * @return array|bool list of group names, false on error
546 $sql = $this->getConf('select-user-groups');
547 $result = $this->query($sql, $userdata);
553 if (!isset($row['group'])) {
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__);
575 if ($this->groupcache) return $this->groupcache;
577 $sql = $this->getConf('select-groups');
578 $result = $this->query($sql);
584 if (!isset($row['group'])) {
585 $this->debugMsg("No 'group' field returned from select-groups statement", -1, __LINE__);
589 // relayout result with group name as key
590 $group = $row['group'];
591 $groups[$group] = $row;
594 $this->debugMsg("select-groups statement did not return a list of result", -1, __LINE__);
602 * Remove all entries from the group cache
606 $this->groupcache = null;
610 * Adds the user to the group
613 * @param array $groupdata all the group data
619 $sql = $this->getConf('join-group');
620 $result = $this->query($sql, $data);
626 * Removes the user from the group
629 * @param array $groupdata all the group 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();
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);