$userAction = $defaultUserAction; if ($userId == 0) { $message .= '<p class="error">' . $errorMessages['delUser_noId'] . '</p>'; } else { if (!$user->getUserById($userId)) { $message .= '<p class="error">' . $errorMessages['delUser_noId'] . '</p>'; } if (!$user->deleteUser()) { $message .= '<p class="error">' . $errorMessages['delUser'] . '</p>'; } else { // Move the categories ownership to admin (id == 1) $categoryHelper = new PMF_Category_Helper(); $categoryHelper->moveOwnership($userId, 1); // Remove the user from groups if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) { $oPerm = PMF_Perm::selectPerm('medium'); $oPerm->removeFromAllGroups($userId); } $message .= '<p class="success">' . $successMessages['delUser'] . '</p>'; } $userError = $user->error(); if ($userError != "") { $message .= '<p>ERROR: ' . $userError . '</p>'; } } } // save new user if ($userAction == 'addsave') { $user = new PMF_User(); $message = ''; $messages = array();
$user->getUserById($userId); $response->setData($user->perm->getUserRights($userId)); break; case 'activate_user': $user->getUserById($userId); $user->setStatus('active'); echo json_encode($user->getStatus()); break; case 'delete_user': $user->getUserById($userId); if ($user->getStatus() == 'protected' || $userId == 1) { $message = '<p class="error">' . $PMF_LANG['ad_user_error_protectedAccount'] . '</p>'; } else { if (!$user->deleteUser()) { $message = $PMF_LANG['ad_user_error_delete']; } else { $category = new PMF_Category($faqConfig, [], false); $category->moveOwnership($userId, 1); // Remove the user from groups if ('medium' == $faqConfig->get('security.permLevel')) { $permissions = PMF_Perm::selectPerm('medium', $faqConfig); $permissions->removeFromAllGroups($userId); } $message = '<p class="success">' . $PMF_LANG['ad_user_deleted'] . '</p>'; } } $response->setData($message); break; } } $response->send();
$message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_user_error_noId']); } else { if (!$user->getUserById($userId)) { $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_user_error_noId']); } if (!$user->deleteUser()) { $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_user_error_delete']); } else { // Move the categories ownership to admin (id == 1) $oCat = new PMF_Category($faqConfig, [], false); $oCat->setUser($currentAdminUser); $oCat->setGroups($currentAdminGroups); $oCat->moveOwnership($userId, 1); // Remove the user from groups if ('medium' == $faqConfig->get('security.permLevel')) { $oPerm = PMF_Perm::selectPerm('medium', $faqConfig); $oPerm->removeFromAllGroups($userId); } $message .= sprintf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_user_deleted']); } $userError = $user->error(); if ($userError != "") { $message .= sprintf('<p class="alert alert-danger">%s</p>', $userError); } } } // save new user if ($userAction == 'addsave' && $user->perm->checkRight($user->getUserId(), 'adduser')) { $user = new PMF_User($faqConfig); $message = ''; $messages = [];
/** * Constructor * * @param PMF_Configuration $config * * @return PMF_User */ public function __construct(PMF_Configuration $config) { $this->config = $config; $perm = PMF_Perm::selectPerm($this->config->get('security.permLevel'), $this->config); if (!$this->addPerm($perm)) { return; } // authentication objects // always make a 'local' $auth object (see: $authData) $this->authContainer = []; $auth = new PMF_Auth($this->config); $authLocal = $auth->selectAuth($this->getAuthSource('name')); $authLocal->selectEncType($this->getAuthData('encType')); $authLocal->setReadOnly($this->getAuthData('readOnly')); if (!$this->addAuth($authLocal, $this->getAuthSource('type'))) { return; } // additionally, set given $auth objects if (count($auth) > 0) { foreach ($auth as $name => $authObject) { if (!$authObject instanceof PMF_Auth_Driver && !$this->addAuth($authObject, $name)) { break; } } } // user data object $this->userdata = new PMF_User_UserData($this->config); }
/** * Constructor * * @param PMF_Perm $perm Permission object * @param array $auth Authorization array * @return void */ public function __construct(PMF_Perm $perm = null, array $auth = array()) { $this->db = PMF_Db::getInstance(); if ($perm !== null) { if (!$this->addPerm($perm)) { return false; } } else { $permLevel = PMF_Configuration::getInstance()->get('security.permLevel'); $perm = PMF_Perm::selectPerm($permLevel); if (!$this->addPerm($perm)) { return false; } } // authentication objects // always make a 'local' $auth object (see: $auth_data) $this->auth_container = array(); $authLocal = PMF_Auth::selectAuth($this->auth_data['authSource']['name']); $authLocal->selectEncType($this->auth_data['encType']); $authLocal->setReadOnly($this->auth_data['readOnly']); if (!$this->addAuth($authLocal, $this->auth_data['authSource']['type'])) { return false; } // additionally, set given $auth objects if (count($auth) > 0) { foreach ($auth as $name => $auth_object) { if (!$this->addAuth($auth_object, $name)) { break; } } } // user data object $this->userdata = new PMF_User_UserData(); }
$userdata = $user->userdata->get('*'); $userdata['status'] = $user->getStatus(); $userdata['login'] = $user->getLogin(); print json_encode($userdata); break; case 'get_user_rights': $user->getUserById($userId); print json_encode($user->perm->getUserRights($userId)); break; case 'delete_user': $user->getUserById($userId); if ($user->getStatus() == 'protected' || $userId == 1) { $message = '<p class="error">' . $PMF_LANG['ad_user_error_protectedAccount'] . '</p>'; } else { if (!$user->deleteUser()) { $message = $PMF_LANG['ad_user_error_delete']; } else { $category = new PMF_Category(); $category->moveOwnership($userId, 1); // Remove the user from groups if ('medium' == PMF_Configuration::getInstance()->get('security.permLevel')) { $permissions = PMF_Perm::selectPerm('medium'); $permissions->removeFromAllGroups($userId); } $message = '<p class="success">' . $PMF_LANG['ad_user_deleted'] . '</p>'; } } print json_encode($message); break; } }