return $ret;
}
+ /**
+ * Get the currently loaded user data info from $this->userData
+ *
+ * @return array|bool
+ */
+ public function getAllUserData() {
+ return $this->userData;
+ }
+
/**
* return the isSignedIn status.
*
*/
protected function _loadUser() {
if(!empty($this->userID)) {
- $queryStr = "SELECT u.`id`, u.`baseGroupId`,u.`protected`,u.`password`,u.`login`,
+ $queryStr = "SELECT u.`id`, u.`baseGroupId`,u.`protected`,u.`password`,u.`login`,u.`name`,
+ u.`apiToken`,u.`apiTokenValidDate`,
g.name AS groupName, g.description AS groupDescription, g.id AS groupId
FROM `".DB_PREFIX."_user` AS u
LEFT JOIN `".DB_PREFIX."_user2group` AS u2g ON u2g.fk_user_id = u.id
$this->userData['protected'] = $result['protected'];
$this->userData['password'] = $result['password'];
$this->userData['login'] = $result['login'];
+ $this->userData['name'] = $result['name'];
+ $this->userData['apiToken'] = $result['apiToken'];
+ $this->userData['apiTokenValidDate'] = $result['apiTokenValidDate'];
$this->userData['groups'][$result['groupId']] = array(
'groupName' => $result['groupName'],
);
}
+ $this->userData['baseGroupName'] = $this->userData['groups'][$this->userData['baseGroupId']]['groupName'];
+
$this->userData['isRoot'] = false;
$grIds = array_keys($this->userData['groups']);
if(in_array(ADMIN_GROUP_ID,$grIds)) {
$active = "0";
}
- $_password = password_hash($password, PASSWORD_DEFAULT);
-
-
-
$queryStr = "UPDATE `".DB_PREFIX . "_user`
SET `name` = '".$this->_DB->real_escape_string($username)."',
`login` = '".$this->_DB->real_escape_string($login)."',
`active` = '".$this->_DB->real_escape_string($active)."',
`baseGroupId` = '".$this->_DB->real_escape_string($group)."'";
- if(Summoner::validate($password,'text')) {
+ if(Summoner::validate($password)) {
+ $_password = password_hash($password, PASSWORD_DEFAULT);
$queryStr .= ", `password` = '".$this->_DB->real_escape_string($_password)."'";
}
if($refreshApiToken === true) {
</div>
</div>
<div class="uk-margin">
- <label class="uk-form-label" for="group">Additional groups</label>
+ <label class="uk-form-label" for="additionalgroups">Additional groups</label>
<div class="uk-form-controls">
<select class="uk-select" id="additionalgroups" name="fdata[additionalgroups]">
<option value="">To be done</option>
--- /dev/null
+<h3 class="uk-h3">Manage your profile</h3>
+<div class="uk-grid-small uk-grid-row-small uk-grid-row-small" uk-grid>
+ <div class="uk-width-1-2">
+ <form class="uk-form-horizontal uk-margin-small" method="post">
+ <div class="uk-margin">
+ <label class="uk-form-label" for="username">Username</label>
+ <div class="uk-form-controls">
+ <input class="uk-input" id="username" type="text" autocomplete="off" name="fdata[username]"
+ value="<?php echo Summoner::ifset($TemplateData['editData'], 'name'); ?>">
+ </div>
+ </div>
+ <div class="uk-margin">
+ <label class="uk-form-label" for="password">Password</label>
+ <div class="uk-form-controls">
+ <input class="uk-input" id="password" type="password" autocomplete="off" name="fdata[password]">
+ </div>
+ </div>
+ <div class="uk-margin">
+ <label class="uk-form-label" for="group">Main group</label>
+ <div class="uk-form-controls">
+ <input class="uk-input" id="group" type="text" name="fdata[group]" disabled
+ value="<?php echo Summoner::ifset($TemplateData['editData'], 'baseGroupName'); ?>"
+ >
+ </div>
+ </div>
+ <div class="uk-margin">
+ <label class="uk-form-label" for="additionalGroups">Additional groups</label>
+ <div class="uk-form-controls">
+ <input class="uk-input" id="additionalGroups" type="text" name="fdata[additionalGroups]" disabled
+ value="To be done"
+ >
+ </div>
+ </div>
+ <div class="uk-margin">
+ <div class="uk-form-label">Create API Token</div>
+ <div class="uk-form-controls uk-form-controls-text">
+ <label>
+ <input class="uk-checkbox" type="checkbox" name="fdata[refreshApiToken]" value="1"><br />
+ Valid until: <?php echo Summoner::ifset($TemplateData['editData'], 'apiTokenValidDate'); ?><br />
+ Key: <?php echo Summoner::ifset($TemplateData['editData'], 'apiToken'); ?>
+ </label>
+ </div>
+ </div>
+ <div class="uk-margin">
+ <button class="uk-button uk-button-primary" type="submit" name="submitForm">
+ Save
+ </button>
+ </div>
+ </form>
+ </div>
+</div>
--- /dev/null
+<?php
+/**
+ * Bibliotheca
+ *
+ * Copyright 2018-2021 Johannes Keßler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+require_once 'lib/possessed.class.php';
+$Possessed = new Possessed($DB);
+
+$TemplateData['editData'] = $Doomguy->getAllUserData();
+
+if(!empty($TemplateData['editData'])) {
+ if(isset($_POST['submitForm'])) {
+ $fdata = $_POST['fdata'];
+ if(!empty($fdata)) {
+ $_username = trim($fdata['username']);
+ $_password = trim($fdata['password']);
+ $refreshApi = false;
+ if(isset($fdata['refreshApiToken'])) {
+ $refreshApi = true;
+ }
+ $do = $Possessed->updateUser($Doomguy->param('id'), $_username, $Doomguy->param('login'),
+ $_password, $Doomguy->param('baseGroupId'), true, $refreshApi);
+ if ($do === true) {
+ $TemplateData['refresh'] = 'index.php?p=profile';
+ } else {
+ $TemplateData['message']['content'] = "Your profile could not be updated.";
+ $TemplateData['message']['status'] = "error";
+ }
+ }
+ }
+}
+else {
+ $TemplateData['message']['content'] = "Something went wrong. See logs for more details.";
+ $TemplateData['message']['status'] = "error";
+}