mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-23 00:36:52 +01:00
* [DEV] Items actions refactoring
* [DEV] Minor UI tweaks
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 Rubén Domínguez nuxsmin@syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Account\AccountFavorites;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
$sk = Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJson(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$actionId = Request::analyze('actionId', 0);
|
||||
$accountId = Request::analyze('accountId', 0);
|
||||
$userId = Session::getUserId();
|
||||
|
||||
if (!$accountId || !$actionId){
|
||||
Response::printJson(_('Acción Inválida'));
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_ACC_FAVORITES_ADD) {
|
||||
if (AccountFavorites::addFavorite($accountId, $userId)) {
|
||||
Response::printJson(_('Favorito añadido'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al añadir favorito'));
|
||||
} elseif ($actionId === ActionsInterface::ACTION_ACC_FAVORITES_DELETE) {
|
||||
if (AccountFavorites::deleteFavorite($accountId, $userId)) {
|
||||
Response::printJson(_('Favorito eliminado'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al eliminar favorito'));
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 Rubén Domínguez nuxsmin@syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Account\Account;
|
||||
use SP\Forms\AccountForm;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\CustomFields\CustomFieldsUtil;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
Response::printJson(_('La sesión no se ha iniciado o ha caducado'), 10);
|
||||
}
|
||||
|
||||
$sk = Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJson(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
// Variables POST del formulario
|
||||
$actionId = Request::analyze('actionId', 0);
|
||||
$accountId = Request::analyze('accountId', 0);
|
||||
$customerId = Request::analyze('customerId', 0);
|
||||
$categoryId = Request::analyze('categoryId', 0);
|
||||
$accountMainGroupId = Request::analyze('mainGroupId', 0);
|
||||
$accountName = Request::analyze('name');
|
||||
$accountLogin = Request::analyze('login');
|
||||
$accountPassword = Request::analyzeEncrypted('pass');
|
||||
$accountNotes = Request::analyze('notes');
|
||||
$accountUrl = Request::analyze('url');
|
||||
$accountPassDateChange = Request::analyze('passworddatechange_unix', 0);
|
||||
|
||||
// Checks
|
||||
$accountGroupEditEnabled = Request::analyze('groupEditEnabled', 0, false, 1);
|
||||
$accountUserEditEnabled = Request::analyze('userEditEnabled', 0, false, 1);
|
||||
$accountPrivateEnabled = Request::analyze('privateEnabled', 0, false, 1);
|
||||
|
||||
// Arrays
|
||||
$accountOtherGroups = Request::analyze('otherGroups', 0);
|
||||
$accountOtherUsers = Request::analyze('otherUsers', 0);
|
||||
$accountTags = Request::analyze('tags');
|
||||
$customFields = Request::analyze('customfield');
|
||||
|
||||
if ($accountMainGroupId === 0) {
|
||||
$accountMainGroupId = Session::getUserGroupId();
|
||||
}
|
||||
|
||||
$AccountData = new AccountExtData();
|
||||
$AccountData->setAccountId($accountId);
|
||||
$AccountData->setAccountName($accountName);
|
||||
$AccountData->setAccountCustomerId($customerId);
|
||||
$AccountData->setAccountCategoryId($categoryId);
|
||||
$AccountData->setAccountLogin($accountLogin);
|
||||
$AccountData->setAccountUrl($accountUrl);
|
||||
$AccountData->setAccountNotes($accountNotes);
|
||||
$AccountData->setAccountUserEditId(Session::getUserId());
|
||||
$AccountData->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
$AccountData->setAccountOtherGroupEdit($accountGroupEditEnabled);
|
||||
$AccountData->setAccountPass($accountPassword);
|
||||
$AccountData->setAccountIsPrivate($accountPrivateEnabled);
|
||||
$AccountData->setAccountPassDateChange($accountPassDateChange);
|
||||
|
||||
if (is_array($accountOtherUsers)) {
|
||||
$AccountData->setUsersId($accountOtherUsers);
|
||||
}
|
||||
|
||||
if (is_array($accountOtherGroups)) {
|
||||
$AccountData->setUserGroupsId($accountOtherGroups);
|
||||
}
|
||||
|
||||
if (is_array($accountTags)) {
|
||||
$AccountData->setTags($accountTags);
|
||||
}
|
||||
|
||||
try {
|
||||
$AccountForm = new AccountForm($AccountData);
|
||||
$AccountForm->validate($actionId);
|
||||
} catch (ValidationException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setId($accountId);
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_ACC);
|
||||
|
||||
$Account = new Account($AccountData);
|
||||
|
||||
switch ($actionId) {
|
||||
case ActionsInterface::ACTION_ACC_NEW:
|
||||
case ActionsInterface::ACTION_ACC_COPY:
|
||||
$AccountData->setAccountUserId(Session::getUserId());
|
||||
$AccountData->setAccountUserGroupId($accountMainGroupId);
|
||||
|
||||
// Crear cuenta
|
||||
if ($Account->createAccount()) {
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($AccountData->getAccountId());
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
|
||||
Response::printJson(_('Cuenta creada'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al crear la cuenta'), 0);
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT:
|
||||
// Cambiar el grupo principal si el usuario es Admin
|
||||
if (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc()) {
|
||||
$AccountData->setAccountUserGroupId($accountMainGroupId);
|
||||
}
|
||||
|
||||
// Actualizar cuenta
|
||||
if ($Account->updateAccount()) {
|
||||
if (is_array($customFields)) {
|
||||
CustomFieldsUtil::updateItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
|
||||
Response::printJson(_('Cuenta actualizada'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al modificar la cuenta'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_DELETE:
|
||||
// Eliminar cuenta
|
||||
if ($Account->deleteAccount()
|
||||
&& CustomField::getItem($CustomFieldData)->delete($accountId)
|
||||
) {
|
||||
Response::printJson(_('Cuenta eliminada'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al eliminar la cuenta'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT_PASS:
|
||||
// Actualizar clave de cuenta
|
||||
if ($Account->updateAccountPass()) {
|
||||
Response::printJson(_('Clave actualizada'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al actualizar la clave'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT_RESTORE:
|
||||
$AccountData->setAccountId(\SP\Account\AccountHistory::getAccountIdFromId($accountId));
|
||||
|
||||
if ($Account->restoreFromHistory($accountId)) {
|
||||
Response::printJson(_('Cuenta restaurada'), 0);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al restaurar cuenta'));
|
||||
|
||||
break;
|
||||
default:
|
||||
Response::printJson(_('Acción Inválida'));
|
||||
}
|
||||
@@ -23,36 +23,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Account\Account;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\DataModel\CustomFieldDefData;
|
||||
use SP\DataModel\GroupData;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\DataModel\PublicLinkData;
|
||||
use SP\DataModel\TagData;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\Controller\ItemActionController;
|
||||
use SP\Http\Request;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Response;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\CustomFields\CustomFieldDef;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\CustomFields\CustomFieldsUtil;
|
||||
use SP\Mgmt\Files\File;
|
||||
use SP\Mgmt\PublicLinks\PublicLink;
|
||||
use SP\Mgmt\Groups\Group;
|
||||
use SP\Mgmt\Profiles\Profile;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
use SP\Mgmt\Users\User;
|
||||
use SP\Mgmt\Users\UserUtil;
|
||||
use SP\Util\Checks;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
@@ -70,551 +44,5 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJson(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
// Variables POST del formulario
|
||||
$actionId = Request::analyze('actionId', 0);
|
||||
$itemId = Request::analyze('itemId', 0);
|
||||
$onCloseAction = Request::analyze('onCloseAction');
|
||||
$activeTab = Request::analyze('activeTab', 0);
|
||||
$customFields = Request::analyze('customfield');
|
||||
|
||||
// Acción al cerrar la vista
|
||||
$doActionOnClose = '';
|
||||
|
||||
$userLogin = UserUtil::getUserLoginById($itemId);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_USERS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_USR_USERS_EDITPASS
|
||||
|| $actionId === ActionsInterface::ACTION_USR_USERS_DELETE
|
||||
) {
|
||||
$isLdap = Request::analyze('isLdap', 0);
|
||||
$userPassR = Request::analyzeEncrypted('passR');
|
||||
|
||||
$UserData = new UserData();
|
||||
$UserData->setUserId($itemId);
|
||||
$UserData->setUserName(Request::analyze('name'));
|
||||
$UserData->setUserLogin(Request::analyze('login'));
|
||||
$UserData->setUserEmail(Request::analyze('email'));
|
||||
$UserData->setUserNotes(Request::analyze('notes'));
|
||||
$UserData->setUserGroupId(Request::analyze('groupid', 0));
|
||||
$UserData->setUserProfileId(Request::analyze('profileid', 0));
|
||||
$UserData->setUserIsAdminApp(Request::analyze('adminapp', false, false, true));
|
||||
$UserData->setUserIsAdminAcc(Request::analyze('adminacc', false, false, true));
|
||||
$UserData->setUserIsDisabled(Request::analyze('disabled', false, false, true));
|
||||
$UserData->setUserIsChangePass(Request::analyze('changepass', false, false, true));
|
||||
$UserData->setUserPass(Request::analyzeEncrypted('pass'));
|
||||
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setId($itemId);
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_USR_USERS);
|
||||
|
||||
// Nuevo usuario o editar
|
||||
if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_USERS_EDIT
|
||||
) {
|
||||
if (!$UserData->getUserName() && !$isLdap) {
|
||||
Response::printJson(_('Es necesario un nombre de usuario'), 2);
|
||||
} elseif (!$UserData->getUserLogin() && !$isLdap) {
|
||||
Response::printJson(_('Es necesario un login'), 2);
|
||||
} elseif (!$UserData->getUserProfileId()) {
|
||||
Response::printJson(_('Es necesario un perfil'), 2);
|
||||
} elseif (!$UserData->getUserGroupId()) {
|
||||
Response::printJson(_('Es necesario un grupo'), 2);
|
||||
} elseif (!$UserData->getUserEmail() && !$isLdap) {
|
||||
Response::printJson(_('Es necesario un email'), 2);
|
||||
} elseif (Checks::demoIsEnabled() && !Session::getUserIsAdminApp() && $UserData->getUserLogin() == 'demo') {
|
||||
Response::printJson(_('Ey, esto es una DEMO!!'));
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW) {
|
||||
if (!$UserData->getUserPass() || !$userPassR) {
|
||||
Response::printJson(_('La clave no puede estar en blanco'), 2);
|
||||
} elseif ($UserData->getUserPass() != $userPassR) {
|
||||
Response::printJson(_('Las claves no coinciden'), 2);
|
||||
}
|
||||
|
||||
try {
|
||||
User::getItem($UserData)->add();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($UserData->getUserId());
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e){
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Usuario creado'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_USERS_EDIT) {
|
||||
try {
|
||||
User::getItem($UserData)->update();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($UserData->getUserId());
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e){
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Usuario actualizado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_USERS_EDITPASS) {
|
||||
if (Checks::demoIsEnabled() && UserUtil::getUserLoginById($itemId) == 'demo') {
|
||||
Response::printJson(_('Ey, esto es una DEMO!!'));
|
||||
} elseif (!$UserData->getUserPass() || !$userPassR) {
|
||||
Response::printJson(_('La clave no puede estar en blanco'), 2);
|
||||
} elseif ($UserData->getUserPass() != $userPassR) {
|
||||
Response::printJson(_('Las claves no coinciden'), 2);
|
||||
}
|
||||
|
||||
try {
|
||||
User::getItem($UserData)->updatePass();
|
||||
} catch (SPException $e){
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Clave actualizada'), 0);
|
||||
|
||||
// Eliminar usuario
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_USERS_DELETE) {
|
||||
if (Checks::demoIsEnabled() && UserUtil::getUserLoginById($itemId) == 'demo') {
|
||||
Response::printJson(_('Ey, esto es una DEMO!!'));
|
||||
} elseif ($UserData->getUserId() == Session::getUserId()) {
|
||||
Response::printJson(_('No es posible eliminar, usuario en uso'));
|
||||
}
|
||||
|
||||
try {
|
||||
User::getItem()->delete($itemId);
|
||||
CustomField::getItem($CustomFieldData)->delete($itemId);
|
||||
} catch (SPException $e){
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Usuario eliminado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_GROUPS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_GROUPS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_USR_GROUPS_DELETE
|
||||
) {
|
||||
$GroupData = new GroupData();
|
||||
$GroupData->setUsergroupId($itemId);
|
||||
$GroupData->setUsergroupName(Request::analyze('name'));
|
||||
$GroupData->setUsergroupDescription(Request::analyze('description'));
|
||||
$GroupData->setUsers(Request::analyze('users', 0));
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setId($itemId);
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_USR_GROUPS);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_USR_GROUPS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_GROUPS_EDIT
|
||||
) {
|
||||
if (!$GroupData->getUsergroupName()) {
|
||||
Response::printJson(_('Es necesario un nombre de grupo'), 2);
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_USR_GROUPS_NEW) {
|
||||
try {
|
||||
Group::getItem($GroupData)->add();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($itemId); //FIXME
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
|
||||
Response::printJson(_('Grupo creado'), 0, $doActionOnClose);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_GROUPS_EDIT) {
|
||||
try {
|
||||
Group::getItem($GroupData)->update();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($itemId); //FIXME
|
||||
CustomFieldsUtil::updateItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
|
||||
Response::printJson(_('Grupo actualizado'), 0, $doActionOnClose);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_GROUPS_DELETE) {
|
||||
try {
|
||||
Group::getItem($GroupData)->delete($itemId);
|
||||
CustomField::getItem($CustomFieldData)->delete($itemId);
|
||||
|
||||
Response::printJson(_('Grupo eliminado'), 0, $doActionOnClose);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_PROFILES_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_PROFILES_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_USR_PROFILES_DELETE
|
||||
) {
|
||||
if ($actionId === ActionsInterface::ACTION_USR_PROFILES_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_USR_PROFILES_EDIT
|
||||
) {
|
||||
$ProfileData = new ProfileData();
|
||||
$ProfileData->setUserprofileName(Request::analyze('profile_name'));
|
||||
$ProfileData->setUserprofileId(Request::analyze('itemId', 0));
|
||||
$ProfileData->setAccAdd(Request::analyze('profile_accadd', 0, false, 1));
|
||||
$ProfileData->setAccView(Request::analyze('profile_accview', 0, false, 1));
|
||||
$ProfileData->setAccViewPass(Request::analyze('profile_accviewpass', 0, false, 1));
|
||||
$ProfileData->setAccViewHistory(Request::analyze('profile_accviewhistory', 0, false, 1));
|
||||
$ProfileData->setAccEdit(Request::analyze('profile_accedit', 0, false, 1));
|
||||
$ProfileData->setAccEditPass(Request::analyze('profile_acceditpass', 0, false, 1));
|
||||
$ProfileData->setAccDelete(Request::analyze('profile_accdel', 0, false, 1));
|
||||
$ProfileData->setAccFiles(Request::analyze('profile_accfiles', 0, false, 1));
|
||||
$ProfileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1));
|
||||
$ProfileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1));
|
||||
$ProfileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1));
|
||||
$ProfileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1));
|
||||
$ProfileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1));
|
||||
$ProfileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1));
|
||||
$ProfileData->setConfigImport(Request::analyze('profile_configimport', 0, false, 1));
|
||||
$ProfileData->setMgmCategories(Request::analyze('profile_categories', 0, false, 1));
|
||||
$ProfileData->setMgmCustomers(Request::analyze('profile_customers', 0, false, 1));
|
||||
$ProfileData->setMgmCustomFields(Request::analyze('profile_customfields', 0, false, 1));
|
||||
$ProfileData->setMgmUsers(Request::analyze('profile_users', 0, false, 1));
|
||||
$ProfileData->setMgmGroups(Request::analyze('profile_groups', 0, false, 1));
|
||||
$ProfileData->setMgmProfiles(Request::analyze('profile_profiles', 0, false, 1));
|
||||
$ProfileData->setMgmApiTokens(Request::analyze('profile_apitokens', 0, false, 1));
|
||||
$ProfileData->setMgmPublicLinks(Request::analyze('profile_publinks', 0, false, 1));
|
||||
$ProfileData->setEvl(Request::analyze('profile_eventlog', 0, false, 1));
|
||||
|
||||
if (!$ProfileData->getUserprofileName()) {
|
||||
Response::printJson(_('Es necesario un nombre de perfil'), 2);
|
||||
}
|
||||
|
||||
try {
|
||||
switch ($actionId) {
|
||||
case ActionsInterface::ACTION_USR_PROFILES_NEW:
|
||||
Profile::getItem($ProfileData)->add();
|
||||
Response::printJson(_('Perfil creado'), 0, $doActionOnClose);
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_EDIT:
|
||||
Profile::getItem($ProfileData)->update();
|
||||
Response::printJson(_('Perfil actualizado'), 0, $doActionOnClose);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_USR_PROFILES_DELETE) {
|
||||
try {
|
||||
Profile::getItem()->delete($itemId);
|
||||
Response::printJson(_('Perfil eliminado'), 0, $doActionOnClose);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE
|
||||
) {
|
||||
$CustomerData = new CustomerData();
|
||||
$CustomerData->setCustomerId($itemId);
|
||||
$CustomerData->setCustomerName(Request::analyze('name'));
|
||||
$CustomerData->setCustomerDescription(Request::analyze('description'));
|
||||
|
||||
$Customer = new Customer($CustomerData);
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setId($itemId);
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT
|
||||
) {
|
||||
if (!$CustomerData->getCustomerName()) {
|
||||
Response::printJson(_('Es necesario un nombre de cliente'), 2);
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_NEW) {
|
||||
try {
|
||||
$Customer->add();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($CustomerData->getCustomerId());
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Cliente creado'), 0, $doActionOnClose);
|
||||
} else if ($actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT) {
|
||||
try {
|
||||
$Customer->update();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
CustomFieldsUtil::updateItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Cliente actualizado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE) {
|
||||
try {
|
||||
$Customer->delete($itemId);
|
||||
CustomField::getItem($CustomFieldData)->delete($itemId);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Cliente eliminado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CATEGORIES_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CATEGORIES_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CATEGORIES_DELETE
|
||||
) {
|
||||
$CategoryData = new CategoryData();
|
||||
$CategoryData->setCategoryId($itemId);
|
||||
$CategoryData->setCategoryName(Request::analyze('name'));
|
||||
$CategoryData->setCategoryDescription(Request::analyze('description'));
|
||||
|
||||
$Category = new Category($CategoryData);
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setId($itemId);
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CATEGORIES_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CATEGORIES_EDIT
|
||||
) {
|
||||
if (!$CategoryData->getCategoryName()) {
|
||||
Response::printJson(_('Es necesario un nombre de categoría'), 2);
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CATEGORIES_NEW) {
|
||||
try {
|
||||
$Category->add();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
$CustomFieldData->setId($CategoryData->getCategoryId());
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Categoría creada'), 0, $doActionOnClose);
|
||||
} else if ($actionId === ActionsInterface::ACTION_MGM_CATEGORIES_EDIT) {
|
||||
try {
|
||||
$Category->update();
|
||||
|
||||
if (is_array($customFields)) {
|
||||
CustomFieldsUtil::updateItemCustomFields($customFields, $CustomFieldData);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Categoría actualizada'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CATEGORIES_DELETE) {
|
||||
try {
|
||||
$Category->delete($itemId);
|
||||
CustomField::getItem($CustomFieldData)->delete($itemId);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Categoría eliminada'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_APITOKENS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_APITOKENS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_APITOKENS_DELETE
|
||||
) {
|
||||
$ApiTokens = new \SP\Api\ApiTokens();
|
||||
$ApiTokens->setTokenId($itemId);
|
||||
$ApiTokens->setUserId(Request::analyze('users', 0));
|
||||
$ApiTokens->setActionId(Request::analyze('actions', 0));
|
||||
$ApiTokens->setRefreshToken(Request::analyze('refreshtoken', false, false, true));
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_APITOKENS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_APITOKENS_EDIT
|
||||
) {
|
||||
if ($ApiTokens->getUserId() === 0 || $ApiTokens->getActionId() === 0) {
|
||||
Response::printJson(_('Usuario o acción no indicado'), 2);
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_APITOKENS_NEW) {
|
||||
try {
|
||||
$ApiTokens->addToken();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Autorización creada'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_APITOKENS_EDIT) {
|
||||
try {
|
||||
$ApiTokens->updateToken();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Autorización actualizada'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_APITOKENS_DELETE) {
|
||||
try {
|
||||
$ApiTokens->deleteToken();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Autorización eliminada'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_DELETE
|
||||
) {
|
||||
$CustomFieldDefData = new CustomFieldDefData();
|
||||
$CustomFieldDefData->setId($itemId);
|
||||
$CustomFieldDefData->setName(Request::analyze('name'));
|
||||
$CustomFieldDefData->setType(Request::analyze('type', 0));
|
||||
$CustomFieldDefData->setModule(Request::analyze('module', 0));
|
||||
$CustomFieldDefData->setHelp(Request::analyze('help'));
|
||||
$CustomFieldDefData->setRequired(Request::analyze('required', false, false, true));
|
||||
|
||||
$CustomFieldDef = new CustomFieldDef($CustomFieldDefData);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT
|
||||
) {
|
||||
if (!$CustomFieldDefData->getName()) {
|
||||
Response::printJson(_('Nombre del campo no indicado'), 2);
|
||||
} elseif ($CustomFieldDefData->getType() === 0) {
|
||||
Response::printJson(_('Tipo del campo no indicado'), 2);
|
||||
} elseif ($CustomFieldDefData->getModule() === 0) {
|
||||
Response::printJson(_('Módulo del campo no indicado'), 2);
|
||||
}
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW) {
|
||||
try {
|
||||
$CustomFieldDef->add();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Campo creado'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT) {
|
||||
try {
|
||||
$CustomFieldDef->update();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Campo actualizado'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_CUSTOMFIELDS_DELETE) {
|
||||
try {
|
||||
$CustomFieldDef->delete($itemId);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Campo eliminado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_DELETE
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH
|
||||
) {
|
||||
$PublicLinkData = new PublicLinkData();
|
||||
$PublicLinkData->setItemId($itemId);
|
||||
$PublicLinkData->setTypeId(PublicLink::TYPE_ACCOUNT);
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW) {
|
||||
$doActionOnClose = "sysPassUtil.Common.doAction(" . ActionsInterface::ACTION_ACC_VIEW . ",'',$itemId);";
|
||||
|
||||
$PublicLinkData->setNotify(Request::analyze('notify', false, false, true));
|
||||
|
||||
try {
|
||||
PublicLink::getItem($PublicLinkData)->add();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Enlace creado'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_DELETE) {
|
||||
try {
|
||||
PublicLink::getItem()->delete($itemId);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Enlace eliminado'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH) {
|
||||
try {
|
||||
PublicLink::getItem($PublicLinkData)->update();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Enlace actualizado'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_TAGS_NEW
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_TAGS_EDIT
|
||||
|| $actionId === ActionsInterface::ACTION_MGM_TAGS_DELETE
|
||||
) {
|
||||
$TagData = new TagData();
|
||||
$TagData->setTagId($itemId);
|
||||
$TagData->setTagName(Request::analyze('name'));
|
||||
|
||||
if ($actionId === ActionsInterface::ACTION_MGM_TAGS_NEW) {
|
||||
try {
|
||||
Tag::getItem($TagData)->add();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Etiqueta creada'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_TAGS_DELETE) {
|
||||
try {
|
||||
Tag::getItem()->delete($itemId);
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage());
|
||||
}
|
||||
|
||||
Response::printJson(_('Etiqueta eliminada'), 0, $doActionOnClose);
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_TAGS_EDIT) {
|
||||
try {
|
||||
Tag::getItem($TagData)->update();
|
||||
} catch (SPException $e) {
|
||||
Response::printJson($e->getMessage(), 2);
|
||||
}
|
||||
|
||||
Response::printJson(_('Etiqueta actualizada'), 0, $doActionOnClose);
|
||||
}
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_FILES_DELETE) {
|
||||
// Verificamos que el ID sea numérico
|
||||
if ($itemId === 0) {
|
||||
Response::printJson(_('No es un ID de archivo válido'));
|
||||
} elseif (File::getItem()->delete($itemId)) {
|
||||
Response::printJson(_('Archivo eliminado'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al eliminar el archivo'));
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_ACCOUNTS_DELETE) {
|
||||
$Account = new Account(new AccountData($itemId));
|
||||
|
||||
// Eliminar cuenta
|
||||
if ($Account->deleteAccount()
|
||||
&& CustomField::getItem(new CustomFieldData(ActionsInterface::ACTION_ACC_NEW))->delete($itemId)
|
||||
) {
|
||||
Response::printJson(_('Cuenta eliminada'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
Response::printJson(_('Error al eliminar la cuenta'));
|
||||
} else {
|
||||
Response::printJson(_('Acción Inválida'));
|
||||
}
|
||||
$ItemAction = new ItemActionController();
|
||||
$ItemAction->doAction();
|
||||
@@ -64,16 +64,15 @@ class Account extends AccountBase implements AccountInterface
|
||||
*/
|
||||
public function updateAccount()
|
||||
{
|
||||
$Log = new Log(__FUNCTION__);
|
||||
$Log = new Log(_('Actualizar Cuenta'));
|
||||
|
||||
// Guardamos una copia de la cuenta en el histórico
|
||||
if (!AccountHistory::addHistory($this->accountData->getAccountId(), false)) {
|
||||
$Log->addDescription(_('Error al actualizar el historial'));
|
||||
$Log->writeLog();
|
||||
return false;
|
||||
}
|
||||
|
||||
$Log->setAction(_('Actualizar Cuenta'));
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al modificar la cuenta'));
|
||||
}
|
||||
|
||||
$GroupAccountsData = new GroupAccountsData();
|
||||
$GroupAccountsData->setAccgroupAccountId($this->accountData->getAccountId());
|
||||
@@ -150,7 +149,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
$Data->addParam($this->accountData->getAccountId(), 'accountId');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
return false;
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al modificar la cuenta'));
|
||||
}
|
||||
|
||||
$accountInfo = ['customer_name'];
|
||||
@@ -224,17 +223,19 @@ class Account extends AccountBase implements AccountInterface
|
||||
*
|
||||
* @param $id int El Id del registro en el histórico
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function restoreFromHistory($id)
|
||||
{
|
||||
$Log = new Log(__FUNCTION__);
|
||||
$Log = new Log(_('Restaurar Cuenta'));
|
||||
|
||||
// Guardamos una copia de la cuenta en el histórico
|
||||
if (!AccountHistory::addHistory($this->accountData->getAccountId(), false)) {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
$Log->addDescription(_('Error al actualizar el historial'));
|
||||
$Log->writeLog();
|
||||
return false;
|
||||
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al restaurar cuenta'));
|
||||
}
|
||||
|
||||
$query = /** @lang SQL */
|
||||
@@ -264,13 +265,12 @@ class Account extends AccountBase implements AccountInterface
|
||||
$Data->addParam($this->accountData->getAccountUserEditId(), 'accountUserEditId');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
return false;
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al restaurar cuenta'));
|
||||
}
|
||||
|
||||
$accountInfo = array('customer_name', 'account_name');
|
||||
$this->getAccountInfoById($accountInfo);
|
||||
|
||||
$Log->setAction(_('Restaurar Cuenta'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']);
|
||||
$Log->addDetails(Html::strongText(_('Cuenta')), sprintf('%s (%s)', $this->cacheParams['account_name'], $this->accountData->getAccountId()));
|
||||
|
||||
@@ -352,19 +352,19 @@ class Account extends AccountBase implements AccountInterface
|
||||
$Data->addParam($this->accountData->getAccountIV(), 'accountIV');
|
||||
$Data->addParam($this->accountData->getAccountNotes(), 'accountNotes');
|
||||
$Data->addParam($this->accountData->getAccountUserId(), 'accountUserId');
|
||||
$Data->addParam($this->accountData->getAccountUserGroupId(), 'accountUserGroupId');
|
||||
$Data->addParam($this->accountData->getAccountUserGroupId() ?: Session::getUserGroupId(), 'accountUserGroupId');
|
||||
$Data->addParam($this->accountData->getAccountOtherUserEdit(), 'accountOtherUserEdit');
|
||||
$Data->addParam($this->accountData->getAccountOtherGroupEdit(), 'accountOtherGroupEdit');
|
||||
$Data->addParam($this->accountData->getAccountIsPrivate(), 'accountIsPrivate');
|
||||
$Data->addParam($this->accountData->getAccountPassDateChange(), 'accountPassDateChange');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
return false;
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al crear la cuenta'));
|
||||
}
|
||||
|
||||
$this->accountData->setAccountId(DB::$lastId);
|
||||
|
||||
$Log = new Log(__FUNCTION__);
|
||||
$Log = new Log(_('Nueva Cuenta'));
|
||||
|
||||
try {
|
||||
if (is_array($this->accountData->getAccountUserGroupsId())) {
|
||||
@@ -396,7 +396,6 @@ class Account extends AccountBase implements AccountInterface
|
||||
$accountInfo = ['customer_name'];
|
||||
$this->getAccountInfoById($accountInfo);
|
||||
|
||||
$Log->setAction(_('Nueva Cuenta'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']);
|
||||
$Log->addDetails(Html::strongText(_('Cuenta')), sprintf('%s (%s)', $this->accountData->getAccountName(), $this->accountData->getAccountId()));
|
||||
$Log->writeLog();
|
||||
@@ -423,17 +422,23 @@ class Account extends AccountBase implements AccountInterface
|
||||
* Elimina los datos de una cuenta en la BBDD.
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function deleteAccount()
|
||||
{
|
||||
// FIXME
|
||||
$Log = new Log(_('Eliminar Cuenta'));
|
||||
|
||||
// Guardamos una copia de la cuenta en el histórico
|
||||
AccountHistory::addHistory($this->accountData->getAccountId(), true) || die (_('ERROR: Error en la operación.'));
|
||||
if (!AccountHistory::addHistory($this->accountData->getAccountId(), true)) {
|
||||
$Log->addDescription(_('Error al actualizar el historial'));
|
||||
$Log->writeLog();
|
||||
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al eliminar la cuenta'));
|
||||
}
|
||||
|
||||
$accountInfo = array('account_name,customer_name');
|
||||
$this->getAccountInfoById($accountInfo);
|
||||
|
||||
$Log = new Log(_('Eliminar Cuenta'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']);
|
||||
$Log->addDetails(Html::strongText(_('Cuenta')), sprintf('%s (%s)', $this->accountData->getAccountName(), $this->accountData->getAccountId()));
|
||||
|
||||
@@ -445,7 +450,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
$Data->addParam($this->accountData->getAccountId(), 'id');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
return false;
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al eliminar la cuenta'));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -625,7 +630,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
*/
|
||||
public function updateAccountPass($isMassive = false, $isRestore = false)
|
||||
{
|
||||
$Log = new Log(__FUNCTION__);
|
||||
$Log = new Log(_('Modificar Clave'));
|
||||
|
||||
// No actualizar el histórico si es por cambio de clave maestra o restauración
|
||||
if (!$isMassive
|
||||
@@ -635,7 +640,8 @@ class Account extends AccountBase implements AccountInterface
|
||||
// Guardamos una copia de la cuenta en el histórico
|
||||
$Log->addDescription(_('Error al actualizar el historial'));
|
||||
$Log->writeLog();
|
||||
return false;
|
||||
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al actualizar la clave'));
|
||||
}
|
||||
|
||||
$this->setPasswordEncrypted();
|
||||
@@ -660,7 +666,7 @@ class Account extends AccountBase implements AccountInterface
|
||||
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
return false;
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al actualizar la clave'));
|
||||
}
|
||||
|
||||
// No escribir en el log ni enviar correos si la actualización es
|
||||
@@ -669,7 +675,6 @@ class Account extends AccountBase implements AccountInterface
|
||||
$accountInfo = array('customer_name', 'account_name');
|
||||
$this->getAccountInfoById($accountInfo);
|
||||
|
||||
$Log->setAction(_('Modificar Clave'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), $this->cacheParams['customer_name']);
|
||||
$Log->addDetails(Html::strongText(_('Cuenta')), sprintf('%s (%s)', $this->cacheParams['account_name'], $this->accountData->getAccountId()));
|
||||
$Log->writeLog();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
namespace SP\Account;
|
||||
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
@@ -70,8 +71,8 @@ class AccountFavorites
|
||||
* Añadir una cuenta a la lista de favoritos
|
||||
*
|
||||
* @param $accountId int El Id de la cuenta
|
||||
* @param $userId int El Id del usuario
|
||||
* @return bool
|
||||
* @param $userId int El Id del usuario
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public static function addFavorite($accountId, $userId)
|
||||
{
|
||||
@@ -82,15 +83,17 @@ class AccountFavorites
|
||||
$Data->addParam($accountId, 'accountId');
|
||||
$Data->addParam($userId, 'userId');
|
||||
|
||||
return DB::getQuery($Data);
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al añadir favorito'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar una cuenta de la lista de favoritos
|
||||
*
|
||||
* @param $accountId int El Id de la cuenta
|
||||
* @param $userId int El Id del usuario
|
||||
* @return bool
|
||||
* @param $userId int El Id del usuario
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public static function deleteFavorite($accountId, $userId)
|
||||
{
|
||||
@@ -101,6 +104,8 @@ class AccountFavorites
|
||||
$Data->addParam($accountId, 'accountId');
|
||||
$Data->addParam($userId, 'userId');
|
||||
|
||||
return DB::getQuery($Data);
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al eliminar favorito'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,7 +520,7 @@ class AccountHistory extends AccountBase implements AccountInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'account_id');
|
||||
$Data->addParam(($isDelete === false) ? 1 : 0, 'isModify');
|
||||
$Data->addParam(($isDelete === true) ? 1 : 1, 'isDelete');
|
||||
$Data->addParam(($isDelete === true) ? 1 : 0, 'isDelete');
|
||||
$Data->addParam(ConfigDB::getValue('masterPwd'), 'masterPwd');
|
||||
|
||||
return DB::getQuery($Data);
|
||||
|
||||
@@ -38,11 +38,11 @@ use SP\Core\Init;
|
||||
use SP\Core\Template;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\DataModel\PublicLinkData;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\Groups\Group;
|
||||
use SP\Mgmt\Groups\GroupAccountsUtil;
|
||||
use SP\Mgmt\PublicLinks\PublicLink;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
use SP\Core\Session;
|
||||
@@ -466,10 +466,10 @@ class AccountController extends ControllerBase implements ActionsInterface
|
||||
/**
|
||||
* Obtener la vista de detalles de cuenta para enlaces públicos
|
||||
*
|
||||
* @param \SP\Mgmt\PublicLinks\PublicLink $PublicLink
|
||||
* @param PublicLinkData $PublicLinkData
|
||||
* @return bool
|
||||
*/
|
||||
public function getAccountFromLink(PublicLink $PublicLink)
|
||||
public function getAccountFromLink(PublicLinkData $PublicLinkData)
|
||||
{
|
||||
$this->setAction(self::ACTION_ACC_VIEW);
|
||||
|
||||
@@ -491,8 +491,8 @@ class AccountController extends ControllerBase implements ActionsInterface
|
||||
$this->Account->getAccountPassData();
|
||||
|
||||
// Desencriptar la clave de la cuenta
|
||||
$pass = Crypt::generateAesKey($PublicLink->getItemData()->getLinkHash());
|
||||
$masterPass = Crypt::getDecrypt($PublicLink->getItemData()->getPass(), $PublicLink->getItemData()->getPassIV(), $pass);
|
||||
$pass = Crypt::generateAesKey($PublicLinkData->getLinkHash());
|
||||
$masterPass = Crypt::getDecrypt($PublicLinkData->getPass(), $PublicLinkData->getPassIV(), $pass);
|
||||
$accountPass = Crypt::getDecrypt($this->Account->getAccountData()->getAccountPass(), $this->Account->getAccountData()->getAccountIV(), $masterPass);
|
||||
|
||||
if (Config::getConfig()->isPublinksImageEnabled()) {
|
||||
|
||||
@@ -592,9 +592,6 @@ class Grids implements ActionsInterface
|
||||
$GridActionDel->setTitle(_('Eliminar Perfil'));
|
||||
$GridActionDel->setIcon($this->icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('appMgmt/delete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
@@ -739,7 +736,7 @@ class Grids implements ActionsInterface
|
||||
$GridHeaders->addHeader(_('Visitas'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('publicLink_itemId');
|
||||
$GridData->setDataRowSourceId('publicLink_id');
|
||||
$GridData->addDataRowSource('accountName');
|
||||
$GridData->addDataRowSource('dateAdd');
|
||||
$GridData->addDataRowSource('dateExpire');
|
||||
|
||||
639
inc/SP/Controller/ItemActionController.class.php
Normal file
639
inc/SP/Controller/ItemActionController.class.php
Normal file
@@ -0,0 +1,639 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Controller;
|
||||
|
||||
use SP\Account\Account;
|
||||
use SP\Account\AccountFavorites;
|
||||
use SP\Account\AccountTags;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\DataModel\PublicLinkData;
|
||||
use SP\Forms\AccountForm;
|
||||
use SP\Forms\ApiTokenForm;
|
||||
use SP\Forms\CategoryForm;
|
||||
use SP\Forms\CustomerForm;
|
||||
use SP\Forms\CustomFieldDefForm;
|
||||
use SP\Forms\GroupForm;
|
||||
use SP\Forms\ProfileForm;
|
||||
use SP\Forms\TagForm;
|
||||
use SP\Forms\UserForm;
|
||||
use SP\Http\JsonResponse;
|
||||
use SP\Http\Request;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\CustomFields\CustomFieldDef;
|
||||
use SP\Mgmt\CustomFields\CustomFieldsUtil;
|
||||
use SP\Mgmt\Files\File;
|
||||
use SP\Mgmt\Groups\Group;
|
||||
use SP\Mgmt\Profiles\Profile;
|
||||
use SP\Mgmt\PublicLinks\PublicLink;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
use SP\Mgmt\Tags\TagSearch;
|
||||
use SP\Mgmt\Users\User;
|
||||
use SP\Util\Json;
|
||||
|
||||
/**
|
||||
* Class AjaxSaveController
|
||||
*
|
||||
* @package SP\Controller
|
||||
*/
|
||||
class ItemActionController
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $actionId;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $itemId;
|
||||
/**
|
||||
* @var JsonResponse
|
||||
*/
|
||||
protected $jsonResponse;
|
||||
/**
|
||||
* @var CustomFieldData
|
||||
*/
|
||||
protected $CustomFieldData;
|
||||
|
||||
/**
|
||||
* AjaxSaveController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->jsonResponse = new JsonResponse();
|
||||
|
||||
$this->analyzeRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar la petición HTTP y establecer las propiedades del elemento
|
||||
*/
|
||||
protected function analyzeRequest()
|
||||
{
|
||||
$this->itemId = Request::analyze('itemId', 0);
|
||||
$this->actionId = Request::analyze('actionId', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ejecutar la acción solicitada
|
||||
*/
|
||||
public function doAction()
|
||||
{
|
||||
try {
|
||||
if (!$this->itemId || !$this->actionId) {
|
||||
$this->invalidAction();
|
||||
}
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_USR_USERS_NEW:
|
||||
case ActionsInterface::ACTION_USR_USERS_EDIT:
|
||||
case ActionsInterface::ACTION_USR_USERS_EDITPASS:
|
||||
case ActionsInterface::ACTION_USR_USERS_DELETE:
|
||||
$this->userAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_NEW:
|
||||
case ActionsInterface::ACTION_USR_GROUPS_EDIT:
|
||||
case ActionsInterface::ACTION_USR_GROUPS_DELETE:
|
||||
$this->groupAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_NEW:
|
||||
case ActionsInterface::ACTION_USR_PROFILES_EDIT:
|
||||
case ActionsInterface::ACTION_USR_PROFILES_DELETE:
|
||||
$this->profileAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE:
|
||||
$this->customerAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_EDIT:
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_DELETE:
|
||||
$this->categoryAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_EDIT:
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_DELETE:
|
||||
$this->tokenAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_DELETE:
|
||||
$this->customFieldAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_DELETE:
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH:
|
||||
$this->publicLinkAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_TAGS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_TAGS_EDIT:
|
||||
case ActionsInterface::ACTION_MGM_TAGS_DELETE:
|
||||
$this->tagAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_FILES_DELETE:
|
||||
$this->fileAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_NEW:
|
||||
case ActionsInterface::ACTION_ACC_COPY:
|
||||
case ActionsInterface::ACTION_ACC_EDIT:
|
||||
case ActionsInterface::ACTION_ACC_EDIT_PASS:
|
||||
case ActionsInterface::ACTION_ACC_EDIT_RESTORE:
|
||||
case ActionsInterface::ACTION_ACC_DELETE:
|
||||
case ActionsInterface::ACTION_MGM_ACCOUNTS_DELETE:
|
||||
$this->accountAction();
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_FAVORITES_ADD:
|
||||
case ActionsInterface::ACTION_ACC_FAVORITES_DELETE:
|
||||
$this->favoriteAction();
|
||||
break;
|
||||
default:
|
||||
$this->invalidAction();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->jsonResponse->setDescription($e->getMessage());
|
||||
}
|
||||
|
||||
Json::returnJson($this->jsonResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre usuarios
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
protected function userAction()
|
||||
{
|
||||
$Form = new UserForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_USR_USERS);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_USR_USERS_NEW:
|
||||
User::getItem($Form->getItemData())->add();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Usuario creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDIT:
|
||||
User::getItem($Form->getItemData())->update();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Usuario actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_DELETE:
|
||||
User::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Usuario eliminado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDITPASS:
|
||||
User::getItem($Form->getItemData())->updatePass();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Clave actualizada'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guardar los datos de los campos personalizados del módulo
|
||||
*
|
||||
* @param $moduleId
|
||||
*/
|
||||
protected function setCustomFieldData($moduleId)
|
||||
{
|
||||
$this->CustomFieldData = new CustomFieldData();
|
||||
$this->CustomFieldData->setId($this->itemId);
|
||||
$this->CustomFieldData->setModule($moduleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guardar los datos de los campos personalizados del módulo
|
||||
*/
|
||||
protected function saveCustomFieldData()
|
||||
{
|
||||
$customFields = Request::analyze('customfield');
|
||||
|
||||
if (is_array($customFields)) {
|
||||
CustomFieldsUtil::addItemCustomFields($customFields, $this->CustomFieldData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar los datos de los campos personalizados del módulo
|
||||
*/
|
||||
protected function deleteCustomFieldData()
|
||||
{
|
||||
CustomField::getItem($this->CustomFieldData)->delete($this->itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre grupos
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function groupAction()
|
||||
{
|
||||
$Form = new GroupForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_USR_GROUPS);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_USR_GROUPS_NEW:
|
||||
Group::getItem($Form->getItemData())->add();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Grupo creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_EDIT:
|
||||
Group::getItem($Form->getItemData())->update();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Grupo actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_DELETE:
|
||||
Group::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Grupo eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre perfiles
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function profileAction()
|
||||
{
|
||||
$Form = new ProfileForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_USR_PROFILES);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_USR_PROFILES_NEW:
|
||||
Profile::getItem($Form->getItemData())->add();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Perfil creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_EDIT:
|
||||
Profile::getItem($Form->getItemData())->update();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Perfil actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_DELETE:
|
||||
Profile::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Perfil eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre clientes
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function customerAction()
|
||||
{
|
||||
$Form = new CustomerForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_NEW:
|
||||
Customer::getItem($Form->getItemData())->add();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cliente creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT:
|
||||
Customer::getItem($Form->getItemData())->update();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cliente actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE:
|
||||
Customer::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cliente eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre categorías
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function categoryAction()
|
||||
{
|
||||
$Form = new CategoryForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_NEW:
|
||||
Category::getItem($Form->getItemData())->add();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Categoría creada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_EDIT:
|
||||
Category::getItem($Form->getItemData())->update();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Categoría actualizada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_DELETE:
|
||||
Category::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Categoría eliminada'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre tokens API
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function tokenAction()
|
||||
{
|
||||
$Form = new ApiTokenForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_NEW:
|
||||
$Form->getItemData()->addToken();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Autorización creada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_EDIT:
|
||||
$Form->getItemData()->updateToken();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Autorización actualizada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_DELETE:
|
||||
$Form->getItemData()->deleteToken();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Autorización eliminada'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre campos personalizados
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function customFieldAction()
|
||||
{
|
||||
$Form = new CustomFieldDefForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW:
|
||||
CustomFieldDef::getItem($Form->getItemData())->add();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Campo creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT:
|
||||
CustomFieldDef::getItem($Form->getItemData())->update();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Campo actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_DELETE:
|
||||
CustomFieldDef::getItem()->delete($this->itemId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Campo eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre enlaces públicos
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function publicLinkAction()
|
||||
{
|
||||
$PublicLinkData = new PublicLinkData();
|
||||
$PublicLinkData->setItemId($this->itemId);
|
||||
$PublicLinkData->setTypeId(PublicLink::TYPE_ACCOUNT);
|
||||
$PublicLinkData->setNotify(Request::analyze('notify', false, false, true));
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW:
|
||||
PublicLink::getItem($PublicLinkData)->add();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH:
|
||||
PublicLink::getItem($PublicLinkData)->update();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_DELETE:
|
||||
PublicLink::getItem()->delete($PublicLinkData->getId());
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre etiquetas
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function tagAction()
|
||||
{
|
||||
$Form = new TagForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_TAGS_NEW:
|
||||
Tag::getItem($Form->getItemData())->add();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Etiqueta creada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_TAGS_EDIT:
|
||||
Tag::getItem($Form->getItemData())->update();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Etiqueta actualizada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_TAGS_DELETE:
|
||||
Tag::getItem()->delete($this->itemId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Etiqueta eliminada'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre archivos
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function fileAction()
|
||||
{
|
||||
File::getItem()->delete($this->itemId);
|
||||
$this->jsonResponse->setDescription(_('Archivo actualizado'));
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre cuentas
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
protected function accountAction()
|
||||
{
|
||||
$Form = new AccountForm($this->itemId);
|
||||
$Form->validate($this->actionId);
|
||||
|
||||
$this->setCustomFieldData(ActionsInterface::ACTION_ACC);
|
||||
|
||||
$Account = new Account($Form->getItemData());
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_ACC_NEW:
|
||||
case ActionsInterface::ACTION_ACC_COPY:
|
||||
$Form->getItemData()->setAccountUserId(Session::getUserId());
|
||||
|
||||
$Account->createAccount();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cuenta creada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT:
|
||||
$Account->updateAccount();
|
||||
$this->saveCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cuenta actualizada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT_PASS:
|
||||
$Account->updateAccountPass();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Clave actualizada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT_RESTORE:
|
||||
$Account->restoreFromHistory($this->itemId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cuenta restaurada'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_DELETE:
|
||||
$Account->deleteAccount();
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cuenta eliminada'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones sobre cuentas favoritas
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
private function favoriteAction()
|
||||
{
|
||||
$accountId = Request::analyze('accountId', 0);
|
||||
$userId = Session::getUserId();
|
||||
|
||||
if ($accountId === 0) {
|
||||
$this->invalidAction();
|
||||
}
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_ACC_FAVORITES_ADD:
|
||||
AccountFavorites::addFavorite($accountId, $userId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Favorito añadido'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_FAVORITES_DELETE:
|
||||
AccountFavorites::deleteFavorite($accountId, $userId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Favorito eliminado'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse->setStatus(0);
|
||||
}
|
||||
|
||||
protected function invalidAction()
|
||||
{
|
||||
$this->jsonResponse->setDescription(_('Acción Inválida'));
|
||||
}
|
||||
}
|
||||
@@ -411,6 +411,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
* Obtener la vista para mostrar un enlace publicado
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getPublicLink()
|
||||
{
|
||||
@@ -421,14 +422,14 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->assign('showLogo', true);
|
||||
|
||||
if (!$PublicLink
|
||||
|| time() > $PublicLink->getItemData()->getDateExpire()
|
||||
|| $PublicLink->getItemData()->getCountViews() >= $PublicLink->getItemData()->getMaxCountViews()
|
||||
|| time() > $PublicLink->getDateExpire()
|
||||
|| $PublicLink->getCountViews() >= $PublicLink->getMaxCountViews()
|
||||
) {
|
||||
$this->showError(self::ERR_PAGE_NO_PERMISSION, false);
|
||||
} else {
|
||||
$PublicLink->addLinkView();
|
||||
PublicLink::getItem($PublicLink)->addLinkView();
|
||||
|
||||
$controller = new AccountController($this->view, null, $PublicLink->getItemData()->getItemId());
|
||||
$controller = new AccountController($this->view, null, $PublicLink->getItemId());
|
||||
$controller->getAccountFromLink($PublicLink);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -26,7 +26,9 @@ namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\Core\Session;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -34,69 +36,120 @@ use SP\Http\Request;
|
||||
*
|
||||
* @package SP\Account
|
||||
*/
|
||||
class AccountForm
|
||||
class AccountForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var AccountData
|
||||
*/
|
||||
protected $AccountData;
|
||||
|
||||
/**
|
||||
* AccountForm constructor.
|
||||
*
|
||||
* @param $AccountData
|
||||
*/
|
||||
public function __construct($AccountData)
|
||||
{
|
||||
$this->AccountData = $AccountData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_ACC_EDIT_PASS:
|
||||
if (!$this->AccountData->getAccountPass()) {
|
||||
throw new ValidationException(_('Es necesaria una clave'));
|
||||
} elseif (Request::analyzeEncrypted('passR') !== $this->AccountData->getAccountPass()){
|
||||
throw new ValidationException(_('Las claves no coinciden'));
|
||||
}
|
||||
$this->checkPass();
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT:
|
||||
if (!$this->AccountData->getAccountName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cuenta'));
|
||||
} elseif (!$this->AccountData->getAccountCustomerId()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cliente'));
|
||||
} elseif (!$this->AccountData->getAccountLogin()) {
|
||||
throw new ValidationException(_('Es necesario un usuario'));
|
||||
} elseif (!$this->AccountData->getAccountCategoryId()) {
|
||||
throw new ValidationException(_('Es necesario una categoría'));
|
||||
}
|
||||
$this->checkCommon();
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_NEW:
|
||||
if (!$this->AccountData->getAccountName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cuenta'));
|
||||
} elseif (!$this->AccountData->getAccountCustomerId()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cliente'));
|
||||
} elseif (!$this->AccountData->getAccountLogin()) {
|
||||
throw new ValidationException(_('Es necesario un usuario'));
|
||||
} elseif (!$this->AccountData->getAccountPass()) {
|
||||
throw new ValidationException(_('Es necesaria una clave'));
|
||||
} elseif (Request::analyzeEncrypted('passR') !== $this->AccountData->getAccountPass()){
|
||||
throw new ValidationException(_('Las claves no coinciden'));
|
||||
}elseif (!$this->AccountData->getAccountCategoryId()) {
|
||||
throw new ValidationException(_('Es necesario una categoría'));
|
||||
}
|
||||
$this->checkCommon();
|
||||
$this->checkPass();
|
||||
break;
|
||||
default:
|
||||
if (!$this->AccountData->getAccountId()) {
|
||||
throw new ValidationException(_('Id inválido'));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkPass()
|
||||
{
|
||||
if (!$this->AccountData->getAccountPass()) {
|
||||
throw new ValidationException(_('Es necesaria una clave'));
|
||||
} elseif (Request::analyzeEncrypted('passR') !== $this->AccountData->getAccountPass()) {
|
||||
throw new ValidationException(_('Las claves no coinciden'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->AccountData->getAccountName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cuenta'));
|
||||
} elseif (!$this->AccountData->getAccountCustomerId()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cliente'));
|
||||
} elseif (!$this->AccountData->getAccountLogin()) {
|
||||
throw new ValidationException(_('Es necesario un usuario'));
|
||||
} elseif (!$this->AccountData->getAccountCategoryId()) {
|
||||
throw new ValidationException(_('Es necesario una categoría'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->AccountData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->AccountData = new AccountExtData();
|
||||
$this->AccountData->setAccountId($this->itemId);
|
||||
$this->AccountData->setAccountName(Request::analyze('name'));
|
||||
$this->AccountData->setAccountCustomerId(Request::analyze('customerId', 0));
|
||||
$this->AccountData->setAccountCategoryId(Request::analyze('categoryId', 0));
|
||||
$this->AccountData->setAccountLogin(Request::analyze('login'));
|
||||
$this->AccountData->setAccountUrl(Request::analyze('url'));
|
||||
$this->AccountData->setAccountNotes(Request::analyze('notes'));
|
||||
$this->AccountData->setAccountUserEditId(Session::getUserId());
|
||||
$this->AccountData->setAccountOtherUserEdit(Request::analyze('userEditEnabled', 0, false, 1));
|
||||
$this->AccountData->setAccountOtherGroupEdit(Request::analyze('groupEditEnabled', 0, false, 1));
|
||||
$this->AccountData->setAccountPass(Request::analyzeEncrypted('pass'));
|
||||
$this->AccountData->setAccountIsPrivate(Request::analyze('privateEnabled', 0, false, 1));
|
||||
$this->AccountData->setAccountPassDateChange(Request::analyze('passworddatechange_unix', 0));
|
||||
|
||||
// Arrays
|
||||
$accountOtherGroups = Request::analyze('otherGroups', 0);
|
||||
$accountOtherUsers = Request::analyze('otherUsers', 0);
|
||||
$accountTags = Request::analyze('tags');
|
||||
|
||||
if (is_array($accountOtherUsers)) {
|
||||
$this->AccountData->setUsersId($accountOtherUsers);
|
||||
}
|
||||
|
||||
if (is_array($accountOtherGroups)) {
|
||||
$this->AccountData->setUserGroupsId($accountOtherGroups);
|
||||
}
|
||||
|
||||
if (is_array($accountTags)) {
|
||||
$this->AccountData->setTags($accountTags);
|
||||
}
|
||||
|
||||
$accountMainGroupId = Request::analyze('mainGroupId', 0);
|
||||
|
||||
// Cambiar el grupo principal si el usuario es Admin
|
||||
if ($accountMainGroupId !== 0
|
||||
&& (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc())
|
||||
) {
|
||||
$this->AccountData->setAccountUserGroupId($accountMainGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
96
inc/SP/Forms/ApiTokenForm.class.php
Normal file
96
inc/SP/Forms/ApiTokenForm.class.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Api\ApiTokens;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class ApiTokenForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class ApiTokenForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var ApiTokens
|
||||
*/
|
||||
protected $ApiTokens;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if ($this->ApiTokens->getUserId() === 0) {
|
||||
throw new ValidationException(_('Usuario no indicado'));
|
||||
} elseif ($this->ApiTokens->getActionId() === 0) {
|
||||
throw new ValidationException(_('Acción no indicada'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->ApiTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->ApiTokens = new ApiTokens();
|
||||
$this->ApiTokens->setTokenId($this->itemId);
|
||||
$this->ApiTokens->setUserId(Request::analyze('users', 0));
|
||||
$this->ApiTokens->setActionId(Request::analyze('actions', 0));
|
||||
$this->ApiTokens->setRefreshToken(Request::analyze('refreshtoken', false, false, true));
|
||||
}
|
||||
}
|
||||
93
inc/SP/Forms/CategoryForm.class.php
Normal file
93
inc/SP/Forms/CategoryForm.class.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class CategoryForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class CategoryForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var CategoryData
|
||||
*/
|
||||
protected $CategoryData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->CategoryData->getCategoryName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de categoría'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->CategoryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->CategoryData = new CategoryData();
|
||||
$this->CategoryData->setCategoryId($this->itemId);
|
||||
$this->CategoryData->setCategoryName(Request::analyze('name'));
|
||||
$this->CategoryData->setCategoryDescription(Request::analyze('description'));
|
||||
}
|
||||
}
|
||||
100
inc/SP/Forms/CustomFieldDefForm.class.php
Normal file
100
inc/SP/Forms/CustomFieldDefForm.class.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\CustomFieldDefData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class CustomFieldDefForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class CustomFieldDefForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var CustomFieldDefData
|
||||
*/
|
||||
protected $CustomFieldDefData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->CustomFieldDefData->getName()) {
|
||||
throw new ValidationException(_('Nombre del campo no indicado'));
|
||||
} elseif ($this->CustomFieldDefData->getType() === 0) {
|
||||
throw new ValidationException(_('Tipo del campo no indicado'));
|
||||
} elseif ($this->CustomFieldDefData->getModule() === 0) {
|
||||
throw new ValidationException(_('Módulo del campo no indicado'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->CustomFieldDefData = new CustomFieldDefData();
|
||||
$this->CustomFieldDefData->setId($this->itemId);
|
||||
$this->CustomFieldDefData->setName(Request::analyze('name'));
|
||||
$this->CustomFieldDefData->setType(Request::analyze('type', 0));
|
||||
$this->CustomFieldDefData->setModule(Request::analyze('module', 0));
|
||||
$this->CustomFieldDefData->setHelp(Request::analyze('help'));
|
||||
$this->CustomFieldDefData->setRequired(Request::analyze('required', false, false, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->CustomFieldDefData;
|
||||
}
|
||||
}
|
||||
93
inc/SP/Forms/CustomerForm.class.php
Normal file
93
inc/SP/Forms/CustomerForm.class.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class CustomerForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class CustomerForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var CustomerData
|
||||
*/
|
||||
protected $CustomerData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->CustomerData->getCustomerName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de cliente'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->CustomerData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->CustomerData = new CustomerData();
|
||||
$this->CustomerData->setCustomerId($this->itemId);
|
||||
$this->CustomerData->setCustomerName(Request::analyze('name'));
|
||||
$this->CustomerData->setCustomerDescription(Request::analyze('description'));
|
||||
}
|
||||
}
|
||||
57
inc/SP/Forms/FormBase.class.php
Normal file
57
inc/SP/Forms/FormBase.class.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
/**
|
||||
* Class FormBase
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
abstract class FormBase
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $itemId;
|
||||
|
||||
/**
|
||||
* FormBase constructor.
|
||||
*
|
||||
* @param $itemId
|
||||
*/
|
||||
public function __construct($itemId)
|
||||
{
|
||||
$this->itemId = $itemId;
|
||||
|
||||
$this->analyzeRequestData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function analyzeRequestData();
|
||||
}
|
||||
47
inc/SP/Forms/FormInterface.class.php
Normal file
47
inc/SP/Forms/FormInterface.class.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
/**
|
||||
* Interface FormInterface
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
interface FormInterface
|
||||
{
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData();
|
||||
}
|
||||
94
inc/SP/Forms/GroupForm.class.php
Normal file
94
inc/SP/Forms/GroupForm.class.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\GroupData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class GroupForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class GroupForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var GroupData
|
||||
*/
|
||||
protected $GroupData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_USR_GROUPS_NEW:
|
||||
case ActionsInterface::ACTION_USR_GROUPS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->GroupData->getUsergroupName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de grupo'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->GroupData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->GroupData = new GroupData();
|
||||
$this->GroupData->setUsergroupId($this->itemId);
|
||||
$this->GroupData->setUsergroupName(Request::analyze('name'));
|
||||
$this->GroupData->setUsergroupDescription(Request::analyze('description'));
|
||||
$this->GroupData->setUsers(Request::analyze('users', 0));
|
||||
}
|
||||
}
|
||||
116
inc/SP/Forms/ProfileForm.class.php
Normal file
116
inc/SP/Forms/ProfileForm.class.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class ProfileForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class ProfileForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var ProfileData
|
||||
*/
|
||||
protected $ProfileData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_USR_PROFILES_NEW:
|
||||
case ActionsInterface::ACTION_USR_PROFILES_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->ProfileData->getUserprofileName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de perfil'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->ProfileData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->ProfileData = new ProfileData();
|
||||
$this->ProfileData->setUserprofileName(Request::analyze('profile_name'));
|
||||
$this->ProfileData->setUserprofileId(Request::analyze('itemId', 0));
|
||||
$this->ProfileData->setAccAdd(Request::analyze('profile_accadd', 0, false, 1));
|
||||
$this->ProfileData->setAccView(Request::analyze('profile_accview', 0, false, 1));
|
||||
$this->ProfileData->setAccViewPass(Request::analyze('profile_accviewpass', 0, false, 1));
|
||||
$this->ProfileData->setAccViewHistory(Request::analyze('profile_accviewhistory', 0, false, 1));
|
||||
$this->ProfileData->setAccEdit(Request::analyze('profile_accedit', 0, false, 1));
|
||||
$this->ProfileData->setAccEditPass(Request::analyze('profile_acceditpass', 0, false, 1));
|
||||
$this->ProfileData->setAccDelete(Request::analyze('profile_accdel', 0, false, 1));
|
||||
$this->ProfileData->setAccFiles(Request::analyze('profile_accfiles', 0, false, 1));
|
||||
$this->ProfileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1));
|
||||
$this->ProfileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1));
|
||||
$this->ProfileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1));
|
||||
$this->ProfileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1));
|
||||
$this->ProfileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1));
|
||||
$this->ProfileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1));
|
||||
$this->ProfileData->setConfigImport(Request::analyze('profile_configimport', 0, false, 1));
|
||||
$this->ProfileData->setMgmCategories(Request::analyze('profile_categories', 0, false, 1));
|
||||
$this->ProfileData->setMgmCustomers(Request::analyze('profile_customers', 0, false, 1));
|
||||
$this->ProfileData->setMgmCustomFields(Request::analyze('profile_customfields', 0, false, 1));
|
||||
$this->ProfileData->setMgmUsers(Request::analyze('profile_users', 0, false, 1));
|
||||
$this->ProfileData->setMgmGroups(Request::analyze('profile_groups', 0, false, 1));
|
||||
$this->ProfileData->setMgmProfiles(Request::analyze('profile_profiles', 0, false, 1));
|
||||
$this->ProfileData->setMgmApiTokens(Request::analyze('profile_apitokens', 0, false, 1));
|
||||
$this->ProfileData->setMgmPublicLinks(Request::analyze('profile_publinks', 0, false, 1));
|
||||
$this->ProfileData->setEvl(Request::analyze('profile_eventlog', 0, false, 1));
|
||||
}
|
||||
}
|
||||
62
inc/SP/Forms/PublicLinkForm.class.php
Normal file
62
inc/SP/Forms/PublicLinkForm.class.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\DataModel\PublicLinkData;
|
||||
|
||||
/**
|
||||
* Class PublicLinkForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class PublicLinkForm implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var PublicLinkData
|
||||
*/
|
||||
protected $PublicLinkData;
|
||||
|
||||
/**
|
||||
* CustomerForm constructor.
|
||||
*
|
||||
* @param PublicLinkData $PublicLinkData
|
||||
*/
|
||||
public function __construct(PublicLinkData $PublicLinkData)
|
||||
{
|
||||
$this->PublicLinkData = $PublicLinkData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
92
inc/SP/Forms/TagForm.class.php
Normal file
92
inc/SP/Forms/TagForm.class.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\DataModel\TagData;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
* Class TagForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class TagForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var TagData
|
||||
*/
|
||||
protected $TagData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_MGM_TAGS_NEW:
|
||||
case ActionsInterface::ACTION_MGM_TAGS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
if (!$this->TagData->getTagName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de etiqueta'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->TagData = new TagData();
|
||||
$this->TagData->setTagId($this->itemId);
|
||||
$this->TagData->setTagName(Request::analyze('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->TagData;
|
||||
}
|
||||
}
|
||||
154
inc/SP/Forms/UserForm.class.php
Normal file
154
inc/SP/Forms/UserForm.class.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Forms;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\ValidationException;
|
||||
use SP\Core\Session;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\Http\Request;
|
||||
use SP\Mgmt\Users\UserUtil;
|
||||
use SP\Util\Checks;
|
||||
|
||||
/**
|
||||
* Class UserForm
|
||||
*
|
||||
* @package SP\Forms
|
||||
*/
|
||||
class UserForm extends FormBase implements FormInterface
|
||||
{
|
||||
/**
|
||||
* @var UserData
|
||||
*/
|
||||
protected $UserData;
|
||||
|
||||
/**
|
||||
* Validar el formulario
|
||||
*
|
||||
* @param $action
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ValidationException
|
||||
*/
|
||||
public function validate($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case ActionsInterface::ACTION_USR_USERS_NEW:
|
||||
$this->checkCommon();
|
||||
$this->checkPass();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDIT:
|
||||
$this->checkCommon();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDITPASS:
|
||||
$this->checkPass();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_DELETE:
|
||||
$this->checkDelete();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkCommon()
|
||||
{
|
||||
$isLdap = Request::analyze('isLdap', 0);
|
||||
|
||||
if (!$isLdap && !$this->UserData->getUserName()) {
|
||||
throw new ValidationException(_('Es necesario un nombre de usuario'));
|
||||
} elseif (!$isLdap && !$this->UserData->getUserLogin()) {
|
||||
throw new ValidationException(_('Es necesario un login'));
|
||||
} elseif (!$this->UserData->getUserProfileId()) {
|
||||
throw new ValidationException(_('Es necesario un perfil'));
|
||||
} elseif (!$this->UserData->getUserGroupId()) {
|
||||
throw new ValidationException(_('Es necesario un grupo'));
|
||||
} elseif (!$isLdap && !$this->UserData->getUserEmail()) {
|
||||
throw new ValidationException(_('Es necesario un email'));
|
||||
} elseif (Checks::demoIsEnabled() && !Session::getUserIsAdminApp() && $this->UserData->getUserLogin() === 'demo') {
|
||||
throw new ValidationException(_('Ey, esto es una DEMO!!'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkPass()
|
||||
{
|
||||
$userPassR = Request::analyzeEncrypted('passR');
|
||||
|
||||
if (Checks::demoIsEnabled() && UserUtil::getUserLoginById($this->UserData->getUserId()) === 'demo') {
|
||||
throw new ValidationException(_('Ey, esto es una DEMO!!'));
|
||||
} elseif (!$userPassR || !$this->UserData->getUserPass()) {
|
||||
throw new ValidationException(_('La clave no puede estar en blanco'));
|
||||
} elseif ($this->UserData->getUserPass() !== $userPassR) {
|
||||
throw new ValidationException(_('Las claves no coinciden'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function checkDelete()
|
||||
{
|
||||
if (Checks::demoIsEnabled() && UserUtil::getUserLoginById($this->UserData->getUserId()) === 'demo') {
|
||||
throw new ValidationException(_('Ey, esto es una DEMO!!'));
|
||||
} elseif ($this->UserData->getUserId() === Session::getUserId()) {
|
||||
throw new ValidationException(_('No es posible eliminar, usuario en uso'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar los datos de la petición HTTP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function analyzeRequestData()
|
||||
{
|
||||
$this->UserData = new UserData();
|
||||
$this->UserData->setUserId($this->itemId);
|
||||
$this->UserData->setUserName(Request::analyze('name'));
|
||||
$this->UserData->setUserLogin(Request::analyze('login'));
|
||||
$this->UserData->setUserEmail(Request::analyze('email'));
|
||||
$this->UserData->setUserNotes(Request::analyze('notes'));
|
||||
$this->UserData->setUserGroupId(Request::analyze('groupid', 0));
|
||||
$this->UserData->setUserProfileId(Request::analyze('profileid', 0));
|
||||
$this->UserData->setUserIsAdminApp(Request::analyze('adminapp', 0, false, 1));
|
||||
$this->UserData->setUserIsAdminAcc(Request::analyze('adminacc', 0, false, 1));
|
||||
$this->UserData->setUserIsDisabled(Request::analyze('disabled', 0, false, 1));
|
||||
$this->UserData->setUserIsChangePass(Request::analyze('changepass', 0, false, 1));
|
||||
$this->UserData->setUserPass(Request::analyzeEncrypted('pass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return $this->UserData;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace SP\Import;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\Core\Crypt;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
@@ -131,7 +131,7 @@ abstract class CsvImportBase extends ImportBase
|
||||
list($accountName, $customerName, $categoryName, $url, $login, $password, $notes) = $fields;
|
||||
|
||||
// Obtener los ids de cliente, categoría y la clave encriptada
|
||||
$customerId = Customer::getItem(new CustomerData(null, $customerName))->add()->getItemData()->getCustomerId();
|
||||
$customerId = Customer::getItem(new CategoryData(null, $customerName))->add()->getItemData()->getCustomerId();
|
||||
$categoryId = Category::getItem(new CategoryData(null, $categoryName))->add();
|
||||
$pass = Crypt::encryptData($password);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace SP\Import;
|
||||
use SP\Account\Account;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Core\Session;
|
||||
@@ -247,7 +247,7 @@ abstract class ImportBase
|
||||
protected function addCustomer()
|
||||
{
|
||||
// FIXME: CustomerData en propiedad de la clase
|
||||
return Customer::getItem(new CustomerData(null, $this->getCustomerName(), $this->getCustomerDescription()))->add()->getItemData()->getCustomerId();
|
||||
return Customer::getItem(new CategoryData(null, $this->getCustomerName(), $this->getCustomerDescription()))->add()->getItemData()->getCustomerId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
namespace SP\Import;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Log\Log;
|
||||
use SP\Core\Session;
|
||||
@@ -280,7 +280,7 @@ class Migrate
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
try {
|
||||
Customer::getItem(new CustomerData(null, $customer))->add();
|
||||
Customer::getItem(new CategoryData(null, $customer))->add();
|
||||
$num++;
|
||||
} catch (SPException $e) {
|
||||
if ($e->getType() === SPException::SP_WARNING){
|
||||
|
||||
@@ -103,14 +103,10 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
public function delete($id)
|
||||
{
|
||||
if ($this->checkInUse($id)) {
|
||||
// FIXME
|
||||
throw new SPException(
|
||||
SPException::SP_WARNING,
|
||||
_('No es posible eliminar') . ';;' . _('Categoría en uso por')
|
||||
);
|
||||
throw new SPException(SPException::SP_WARNING, _('No es posible eliminar'));
|
||||
}
|
||||
|
||||
$oldCategory = $this->getById($this->itemData->getCategoryId());
|
||||
$oldCategory = $this->getById($id);
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'DELETE FROM categories WHERE category_id = ? LIMIT 1';
|
||||
|
||||
@@ -136,7 +136,7 @@ class CustomFieldsUtil
|
||||
* @param array $customFields
|
||||
* @param CustomFieldData $CustomFieldData
|
||||
*/
|
||||
public static function addItemCustomFields(array $customFields, CustomFieldData $CustomFieldData)
|
||||
public static function addItemCustomFields(array &$customFields, CustomFieldData $CustomFieldData)
|
||||
{
|
||||
foreach ($customFields as $id => $value) {
|
||||
$CustomFieldData->setDefinitionId($id);
|
||||
|
||||
@@ -124,11 +124,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
public function delete($id)
|
||||
{
|
||||
if ($this->checkInUse($id)) {
|
||||
// FIXME
|
||||
throw new SPException(
|
||||
SPException::SP_WARNING,
|
||||
_('No es posible eliminar') . ';;' . _('Cliente en uso por')
|
||||
);
|
||||
throw new SPException(SPException::SP_WARNING, _('No es posible eliminar'));
|
||||
}
|
||||
|
||||
$oldCustomer = $this->getById($id);
|
||||
@@ -138,7 +134,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCustomerId());
|
||||
$Data->addParam($id);
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al eliminar el cliente'));
|
||||
|
||||
@@ -57,6 +57,7 @@ abstract class CustomerBase extends ItemBase
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
*
|
||||
* @return CustomerData
|
||||
*/
|
||||
public function getItemData()
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
namespace SP\Mgmt\Files;
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\FileData;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
@@ -108,6 +109,7 @@ class File extends FileBase implements ItemInterface, ItemSelectInterface
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
@@ -129,18 +131,13 @@ class File extends FileBase implements ItemInterface, ItemSelectInterface
|
||||
$Log->addDetails(_('Tamaño'), $this->itemData->getRoundSize() . 'KB');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
$Log->addDescription(_('Error al eliminar el archivo'));
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
throw new SPException(SPException::SP_ERROR, $Log->getDescription());
|
||||
}
|
||||
|
||||
$Log->addDescription(_('Archivo eliminado'));
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,6 +59,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
* Incrementar el contador de visitas de un enlace
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function addLinkView()
|
||||
{
|
||||
@@ -80,7 +81,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return bool
|
||||
* @throws SPException
|
||||
*/
|
||||
public function update()
|
||||
@@ -97,11 +98,11 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$Data->addParam($this->itemData->getLinkHash());
|
||||
$Data->addParam($this->itemData->getItemId());
|
||||
|
||||
if (DB::getQuery($Data)) {
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al actualizar enlace'));
|
||||
}
|
||||
|
||||
return $this;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +237,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return PublicLinkListData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getById($id)
|
||||
@@ -268,11 +269,17 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$PublicLink = Util::castToClass($this->getDataModel(), $PublicLink);
|
||||
}
|
||||
|
||||
$PublicLink->setItemId($queryRes->getPublicLinkItemId());
|
||||
$PublicLinkListData = new PublicLinkListData();
|
||||
$PublicLinkListData->setPublicLinkItemId($queryRes->getPublicLinkItemId());
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLink->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLink->getUserId()));
|
||||
$PublicLinkListData->setNotify($PublicLink->isNotify() ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLink->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLink->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLink->getCountViews() . '/' . $PublicLink->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLink->getUseInfo());
|
||||
|
||||
$this->itemData = $PublicLink;
|
||||
|
||||
return $this;
|
||||
return $PublicLinkListData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,9 +318,9 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLinkData->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLinkData->getUserId()));
|
||||
$PublicLinkListData->setNotify(($PublicLinkData->isNotify()) ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date("Y-m-d H:i", $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date("Y-m-d H:i", $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setNotify($PublicLinkData->isNotify() ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLinkData->getCountViews() . '/' . $PublicLinkData->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLinkData->getUseInfo());
|
||||
|
||||
@@ -342,7 +349,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param $hash int
|
||||
* @return $this
|
||||
* @return PublicLinkData
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getByHash($hash)
|
||||
@@ -376,8 +383,6 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
$PublicLink->setItemId($queryRes->getPublicLinkItemId());
|
||||
|
||||
$this->itemData = $PublicLink;
|
||||
|
||||
return $this;
|
||||
return $PublicLink;
|
||||
}
|
||||
}
|
||||
@@ -86,10 +86,10 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->addParam($this->itemData->getUserNotes());
|
||||
$Data->addParam($this->itemData->getUserGroupId());
|
||||
$Data->addParam($this->itemData->getUserProfileId());
|
||||
$Data->addParam(intval($this->itemData->isUserIsAdminApp()));
|
||||
$Data->addParam(intval($this->itemData->isUserIsAdminAcc()));
|
||||
$Data->addParam(intval($this->itemData->isUserIsDisabled()));
|
||||
$Data->addParam(intval($this->itemData->isUserIsChangePass()));
|
||||
$Data->addParam($this->itemData->isUserIsAdminApp());
|
||||
$Data->addParam($this->itemData->isUserIsAdminAcc());
|
||||
$Data->addParam($this->itemData->isUserIsDisabled());
|
||||
$Data->addParam($this->itemData->isUserIsChangePass());
|
||||
$Data->addParam($passdata['pass']);
|
||||
$Data->addParam($passdata['salt']);
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@ ALTER TABLE `accUsers`
|
||||
ADD INDEX `fk_accUsers_users_id_idx` (`accuser_userId` ASC),
|
||||
DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE `accViewLinks`
|
||||
CHANGE COLUMN `accviewlinks_accountId` `accviewlinks_accountId` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
|
||||
CHANGE COLUMN `accviewlinks_userId` `accviewlinks_userId` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
|
||||
ADD INDEX `fk_accViewLinks_account_idx` (`accviewlinks_accountId` ASC),
|
||||
ADD INDEX `fk_accViewLinks_user_id_idx` (`accviewlinks_userId` ASC);
|
||||
|
||||
ALTER TABLE `accounts`
|
||||
CHANGE COLUMN `account_id` `account_id` SMALLINT(5) UNSIGNED NOT NULL,
|
||||
CHANGE COLUMN `account_userId` `account_userId` SMALLINT(5) UNSIGNED NOT NULL,
|
||||
@@ -145,18 +139,6 @@ REFERENCES `usrData` (`user_id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `accViewLinks`
|
||||
ADD CONSTRAINT `fk_accViewLinks_account_id`
|
||||
FOREIGN KEY (`accviewlinks_accountId`)
|
||||
REFERENCES `accounts` (`account_id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `fk_accViewLinks_user_id`
|
||||
FOREIGN KEY (`accviewlinks_userId`)
|
||||
REFERENCES `usrData` (`user_id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
ALTER TABLE `accounts`
|
||||
ADD CONSTRAINT `fk_accounts_categories_id`
|
||||
FOREIGN KEY (`account_categoryId`)
|
||||
|
||||
@@ -232,26 +232,6 @@ CREATE TABLE `accUsers` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
DROP TABLE IF EXISTS `accViewLinks`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `accViewLinks` (
|
||||
`accviewlinks_id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`accviewlinks_accountId` smallint(5) unsigned DEFAULT NULL,
|
||||
`accviewlinks_expireTime` int(10) unsigned DEFAULT NULL,
|
||||
`accviewlinks_expired` bit(1) DEFAULT b'0',
|
||||
`accviewlinks_userId` smallint(5) unsigned DEFAULT NULL,
|
||||
`accviewlinks_hash` varbinary(100) DEFAULT '',
|
||||
`accviewlinks_actionId` smallint(5) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`accviewlinks_id`),
|
||||
UNIQUE KEY `unique_accviewlinks_id` (`accviewlinks_id`),
|
||||
KEY `fk_accViewLinks_account_idx` (`accviewlinks_accountId`),
|
||||
KEY `fk_accViewLinks_user_id_idx` (`accviewlinks_userId`),
|
||||
CONSTRAINT `fk_accViewLinks_account_id` FOREIGN KEY (`accviewlinks_accountId`) REFERENCES `accounts` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_accViewLinks_user_id` FOREIGN KEY (`accviewlinks_userId`) REFERENCES `usrData` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
DROP TABLE IF EXISTS `authTokens`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
|
||||
@@ -97,6 +97,11 @@
|
||||
#content #data-search .account-info {
|
||||
padding: .5em 0 .5em 0;
|
||||
text-align: left;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
#content #data-search .account-info:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#content #data-search .account-actions {
|
||||
@@ -125,6 +130,11 @@
|
||||
|
||||
#content #data-search .tags-box span.tag {
|
||||
cursor: pointer;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
#content #data-search .tags-box span.tag:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#content #data-search .account-info img,#content #data-search .account-actions img{width:24px;height:24px;margin:0 .5em}#content #data-search{text-align:center;padding:.5em 0;width:100%;margin:0 auto}#content #data-search .account-label{display:flex;justify-content:space-between;flex-wrap:wrap;width:100%;min-height:8em;height:auto;text-align:left;margin:0 auto .5em;color:#696969;background-color:#fcfcfc;padding:0 .5em}#content #data-search .account-label .label-row-up,#content #data-search .account-label .label-row-down{display:flex;flex-wrap:wrap;min-height:3em;height:auto;width:100%;padding:.5em 0}#content #data-search .account-label .label-row-down{height:3em}#content #data-search .account-label .label-left{display:flex;flex-wrap:wrap;align-items:center}#content #data-search .account-label .label-right{display:flex;flex-wrap:wrap;width:15em}#content #data-search .account-label .label-right>div{width:15em}#content #data-search .account-label .label-field{width:15em;min-height:3em;height:auto}#content #data-search .account-label .field-customer{width:20em}#content #data-search .account-label .field-name{padding:.3em .2em;color:#b9b9b9;display:none}#content #data-search .account-label .field-text{width:14em;padding:.3em .3em;word-wrap:break-word}#content #data-search .account-label .header .field-name{color:white;font-weight:bold}#content #data-search .account-label .field-text a{color:#4895fa}#content #data-search .account-label .no-link,#content #data-search .account-label .no-link a{color:white;font-weight:bold}#content #data-search .account-info{padding:.5em 0 .5em 0;text-align:left}#content #data-search .account-actions{align-self:baseline;padding:.5em 0;text-align:right;border-top:1px solid #c9c9c9}#content .actions-optional{display:none}#content #data-search .account-spacer{float:left;clear:left;height:2em;width:20%}#content #data-search .tags-box{display:inline-block}#content #data-search .tags-box span.tag{cursor:pointer}@media screen and (max-width:1000px){#content #data-search .account-label .label-field{width:100%}#content #data-search .account-label .field-name{display:block;text-align:left;border-bottom:1px solid #d9d9d9}#content #data-search .account-label .label-right,#content #data-search .account-label .label-right>div{width:100%}}
|
||||
#content #data-search .account-info img,#content #data-search .account-actions img{width:24px;height:24px;margin:0 .5em}#content #data-search{text-align:center;padding:.5em 0;width:100%;margin:0 auto}#content #data-search .account-label{display:flex;justify-content:space-between;flex-wrap:wrap;width:100%;min-height:8em;height:auto;text-align:left;margin:0 auto .5em;color:#696969;background-color:#fcfcfc;padding:0 .5em}#content #data-search .account-label .label-row-up,#content #data-search .account-label .label-row-down{display:flex;flex-wrap:wrap;min-height:3em;height:auto;width:100%;padding:.5em 0}#content #data-search .account-label .label-row-down{height:3em}#content #data-search .account-label .label-left{display:flex;flex-wrap:wrap;align-items:center}#content #data-search .account-label .label-right{display:flex;flex-wrap:wrap;width:15em}#content #data-search .account-label .label-right>div{width:15em}#content #data-search .account-label .label-field{width:15em;min-height:3em;height:auto}#content #data-search .account-label .field-customer{width:20em}#content #data-search .account-label .field-name{padding:.3em .2em;color:#b9b9b9;display:none}#content #data-search .account-label .field-text{width:14em;padding:.3em .3em;word-wrap:break-word}#content #data-search .account-label .header .field-name{color:white;font-weight:bold}#content #data-search .account-label .field-text a{color:#4895fa}#content #data-search .account-label .no-link,#content #data-search .account-label .no-link a{color:white;font-weight:bold}#content #data-search .account-info{padding:.5em 0 .5em 0;text-align:left;opacity:.3}#content #data-search .account-info:hover{opacity:1}#content #data-search .account-actions{align-self:baseline;padding:.5em 0;text-align:right;border-top:1px solid #c9c9c9}#content .actions-optional{display:none}#content #data-search .account-spacer{float:left;clear:left;height:2em;width:20%}#content #data-search .tags-box{display:inline-block}#content #data-search .tags-box span.tag{cursor:pointer;opacity:.3}#content #data-search .tags-box span.tag:hover{opacity:1}@media screen and (max-width:1000px){#content #data-search .account-label .label-field{width:100%}#content #data-search .account-label .field-name{display:block;text-align:left;border-bottom:1px solid #d9d9d9}#content #data-search .account-label .label-right,#content #data-search .account-label .label-right>div{width:100%}}
|
||||
@@ -1150,7 +1150,7 @@ footer img {
|
||||
.header-grey {
|
||||
background-color: #607d8b;
|
||||
color: #fff;
|
||||
height: 2em;
|
||||
min-height: 2em;
|
||||
}
|
||||
|
||||
.no-background {
|
||||
|
||||
2
inc/themes/material-blue/css/styles.min.css
vendored
2
inc/themes/material-blue/css/styles.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -1,42 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $link SP\DataModel\PublicLinkListData
|
||||
*/
|
||||
?>
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<table class="fancydata">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Cuenta'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_account; ?></td>
|
||||
<td class="valField"><?php echo $link->getAccountName(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Fecha Creación'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_dateAdd; ?></td>
|
||||
<td class="valField"><?php echo $link->getDateAdd(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Fecha Caducidad'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_dateExpire; ?></td>
|
||||
<td class="valField"><?php echo $link->getDateExpire(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Usuario'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_user; ?></td>
|
||||
<td class="valField"><?php echo $link->getUserLogin(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Notificar'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_notify; ?></td>
|
||||
<td class="valField"><?php echo $link->getNotify(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Visitas'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_views; ?></td>
|
||||
<td class="valField"><?php echo $link->getCountViews(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Uso'); ?></td>
|
||||
<td class="valField">
|
||||
<?php foreach ($link->publicLink_useInfo as $useInfo): ?>
|
||||
<?php foreach ($link->getUseInfo() as $useInfo): ?>
|
||||
<div class="link-use-info"><?php echo $useInfo['who'], ' - ' , date('Y-m-d H:i', $useInfo['time']); ?></div>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Hash'); ?></td>
|
||||
<td class="valField"><?php echo $link->publicLink_hash; ?></td>
|
||||
<td class="valField"><?php echo $link->getPublicLinkHash(); ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -56,9 +56,9 @@ sysPass.Actions = function (Common) {
|
||||
file: "/ajax/ajax_filesMgmt.php",
|
||||
link: "/ajax/ajax_appMgmtSave.php",
|
||||
account: {
|
||||
save: "/ajax/ajax_accSave.php",
|
||||
save: "/ajax/ajax_appMgmtSave.php",
|
||||
showPass: "/ajax/ajax_accViewPass.php",
|
||||
saveFavorite: "/ajax/ajax_accFavorites.php",
|
||||
saveFavorite: "/ajax/ajax_appMgmtSave.php",
|
||||
request: "/ajax/ajax_sendRequest.php",
|
||||
getFiles: "/ajax/ajax_accGetFiles.php",
|
||||
search: "/ajax/ajax_accSearch.php"
|
||||
@@ -596,13 +596,15 @@ sysPass.Actions = function (Common) {
|
||||
var opts = Common.appRequests().getRequestOpts();
|
||||
opts.url = ajaxUrl.account.save;
|
||||
opts.data = {
|
||||
accountid: $obj.data("item-id"),
|
||||
itemId: $obj.data("item-id"),
|
||||
actionId: $obj.data("action-id"),
|
||||
sk: Common.sk.get()
|
||||
};
|
||||
|
||||
Common.appRequests().getActionCall(opts, function (json) {
|
||||
Common.msg.out(json);
|
||||
|
||||
account.search();
|
||||
});
|
||||
}, function (e) {
|
||||
e.preventDefault();
|
||||
@@ -722,7 +724,7 @@ sysPass.Actions = function (Common) {
|
||||
|
||||
var data = {
|
||||
actionId: isOn ? $obj.data("action-id-off") : $obj.data("action-id-on"),
|
||||
accountId: $obj.data("item-id"),
|
||||
itemId: $obj.data("item-id"),
|
||||
sk: Common.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
|
||||
26
js/app-actions.min.js
vendored
26
js/app-actions.min.js
vendored
@@ -2,32 +2,32 @@ var $jscomp={scope:{},findInternal:function(c,d,g){c instanceof String&&(c=Strin
|
||||
$jscomp.getGlobal=function(c){return"undefined"!=typeof window&&window===c?c:"undefined"!=typeof global?global:c};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(c,d,g,e){if(d){g=$jscomp.global;c=c.split(".");for(e=0;e<c.length-1;e++){var f=c[e];f in g||(g[f]={});g=g[f]}c=c[c.length-1];e=g[c];d=d(e);d!=e&&null!=d&&$jscomp.defineProperty(g,c,{configurable:!0,writable:!0,value:d})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(c,g){return $jscomp.findInternal(this,c,g).v}},"es6-impl","es3");
|
||||
sysPass.Actions=function(c){var d=c.log,g,e={doAction:"/ajax/ajax_getContent.php",updateItems:"/ajax/ajax_getItems.php",user:{savePreferences:"/ajax/ajax_userPrefsSave.php",password:"/ajax/ajax_usrpass.php",passreset:"/ajax/ajax_passReset.php"},main:{login:"/ajax/ajax_doLogin.php",install:"/ajax/ajax_install.php",twofa:"/ajax/ajax_2fa.php",getUpdates:"/ajax/ajax_checkUpds.php"},checks:"/ajax/ajax_checkConnection.php",config:{save:"/ajax/ajax_configSave.php","export":"/ajax/ajax_export.php","import":"/ajax/ajax_import.php"},
|
||||
file:"/ajax/ajax_filesMgmt.php",link:"/ajax/ajax_appMgmtSave.php",account:{save:"/ajax/ajax_accSave.php",showPass:"/ajax/ajax_accViewPass.php",saveFavorite:"/ajax/ajax_accFavorites.php",request:"/ajax/ajax_sendRequest.php",getFiles:"/ajax/ajax_accGetFiles.php",search:"/ajax/ajax_accSearch.php"},appMgmt:{show:"/ajax/ajax_appMgmtData.php",save:"/ajax/ajax_appMgmtSave.php",search:"/ajax/ajax_appMgmtSearch.php"},eventlog:"/ajax/ajax_eventlog.php",wiki:{show:"/ajax/ajax_wiki.php"}},f=function(a){a={actionId:a.actionId,
|
||||
itemId:"undefined"!==typeof a.itemId?a.itemId:0,isAjax:1};var b=c.appRequests().getRequestOpts();b.url=e.doAction;b.type="html";b.addHistory=!0;b.data=a;c.appRequests().getActionCall(b,function(a){$("#content").html(a)})},l=function(a){d.info("updateItems");var b=$("#"+a.data("item-dst"))[0].selectize;b.clearOptions();b.load(function(b){var h=c.appRequests().getRequestOpts();h.url=e.updateItems;h.method="get";h.data={sk:c.sk.get(),itemType:a.data("item-type")};c.appRequests().getActionCall(h,function(a){b(a.items)})})},
|
||||
m=function(a,b){$.fancybox(b,{padding:[0,0,0,0],afterClose:function(){a.data("item-dst")&&l(a)},beforeShow:function(){c.appTriggers().views.common("#fancyContainer")}})},p={logout:function(){var a=window.location.search;c.redirect(0<a.length?"index.php"+a+"&logout=1":"index.php?logout=1")},login:function(a){d.info("main:login");var b=c.appRequests().getRequestOpts();b.url=e.main.login;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){switch(b.status){case 0:c.redirect(b.data.url);break;
|
||||
case 2:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();$("#mpass").prop("disabled",!1);$("#smpass").val("").show();break;default:c.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){d.info("main:install");var b=c.appRequests().getRequestOpts();b.url=e.main.install;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},
|
||||
file:"/ajax/ajax_filesMgmt.php",link:"/ajax/ajax_appMgmtSave.php",account:{save:"/ajax/ajax_appMgmtSave.php",showPass:"/ajax/ajax_accViewPass.php",saveFavorite:"/ajax/ajax_appMgmtSave.php",request:"/ajax/ajax_sendRequest.php",getFiles:"/ajax/ajax_accGetFiles.php",search:"/ajax/ajax_accSearch.php"},appMgmt:{show:"/ajax/ajax_appMgmtData.php",save:"/ajax/ajax_appMgmtSave.php",search:"/ajax/ajax_appMgmtSearch.php"},eventlog:"/ajax/ajax_eventlog.php",wiki:{show:"/ajax/ajax_wiki.php"}},f=function(a){a=
|
||||
{actionId:a.actionId,itemId:"undefined"!==typeof a.itemId?a.itemId:0,isAjax:1};var b=c.appRequests().getRequestOpts();b.url=e.doAction;b.type="html";b.addHistory=!0;b.data=a;c.appRequests().getActionCall(b,function(a){$("#content").html(a)})},l=function(a){d.info("updateItems");var b=$("#"+a.data("item-dst"))[0].selectize;b.clearOptions();b.load(function(b){var h=c.appRequests().getRequestOpts();h.url=e.updateItems;h.method="get";h.data={sk:c.sk.get(),itemType:a.data("item-type")};c.appRequests().getActionCall(h,
|
||||
function(a){b(a.items)})})},n=function(a,b){$.fancybox(b,{padding:[0,0,0,0],afterClose:function(){a.data("item-dst")&&l(a)},beforeShow:function(){c.appTriggers().views.common("#fancyContainer")}})},p={logout:function(){var a=window.location.search;c.redirect(0<a.length?"index.php"+a+"&logout=1":"index.php?logout=1")},login:function(a){d.info("main:login");var b=c.appRequests().getRequestOpts();b.url=e.main.login;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){switch(b.status){case 0:c.redirect(b.data.url);
|
||||
break;case 2:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();$("#mpass").prop("disabled",!1);$("#smpass").val("").show();break;default:c.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){d.info("main:install");var b=c.appRequests().getRequestOpts();b.url=e.main.install;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},
|
||||
2E3)})},twofa:function(a){d.info("main:twofa");var b=c.appRequests().getRequestOpts();b.url=e.main.twofa;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},2E3)})},getUpdates:function(a){d.info("main:getUpdates");a=c.appRequests().getRequestOpts();a.type="html";a.method="get";a.timeout=1E4;a.useLoading=!1;a.url=e.main.getUpdates;c.appRequests().getActionCall(a,function(a){$("#updates").html(a);"undefined"!==typeof componentHandler&&
|
||||
componentHandler.upgradeDom()},function(){$("#updates").html("!")})}},n={show:function(a){d.info("account:show");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},showHistory:function(a){d.info("account:showHistory");f({actionId:a["action-id"],itemId:a["item-id"]})},edit:function(a){d.info("account:edit");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},"delete":function(a){d.info("account:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[3]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,
|
||||
function(b){b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data={accountid:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},function(a){a.preventDefault();alertify.error(c.config().LANG[44])})},showpass:function(a){d.info("account:showpass");var b=c.appRequests().getRequestOpts();b.url=e.account.showPass;b.data={accountid:a.data("item-id"),isHistory:a.data("history"),isAjax:1};c.appRequests().getActionCall(b,function(a){if(10===
|
||||
a.status)doLogout();else{var b;$("<div></div>").dialog({modal:!0,title:c.config().LANG[47],width:"auto",open:function(){b=$(this);var h,d="";h='<button class="dialog-clip-user-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-user-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+c.config().LANG[33]+"</span></button>";var e='<button class="dialog-clip-pass-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-pass-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+
|
||||
componentHandler.upgradeDom()},function(){$("#updates").html("!")})}},m={show:function(a){d.info("account:show");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},showHistory:function(a){d.info("account:showHistory");f({actionId:a["action-id"],itemId:a["item-id"]})},edit:function(a){d.info("account:edit");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},"delete":function(a){d.info("account:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[3]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,
|
||||
function(b){b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);m.search()})},function(a){a.preventDefault();alertify.error(c.config().LANG[44])})},showpass:function(a){d.info("account:showpass");var b=c.appRequests().getRequestOpts();b.url=e.account.showPass;b.data={accountid:a.data("item-id"),isHistory:a.data("history"),isAjax:1};c.appRequests().getActionCall(b,
|
||||
function(a){if(10===a.status)doLogout();else{var b;$("<div></div>").dialog({modal:!0,title:c.config().LANG[47],width:"auto",open:function(){b=$(this);var h,d="";h='<button class="dialog-clip-user-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-user-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+c.config().LANG[33]+"</span></button>";var e='<button class="dialog-clip-pass-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" data-clipboard-target=".dialog-pass-text"><span class="ui-button-icon-primary ui-icon ui-icon-clipboard"></span><span class="ui-button-text">'+
|
||||
c.config().LANG[34]+"</span></button>",d=a.useimage,f='<p class="dialog-user-text">'+a.acclogin+"</p>";0===a.status?(0===d?d='<p class="dialog-pass-text">'+a.accpass+"</p>":(d='<img class="dialog-pass-text" src="data:image/png;base64,'+a.accpass+'" />',e=""),h=f+d+'<div class="dialog-buttons">'+h+e+"</div>"):(h='<span class="altTxtRed">'+a.description+"</span>",b.dialog("option","buttons",[{text:"Ok",icons:{primary:"ui-icon-close"},click:function(){b.dialog("close")}}]));b.html(h);b.dialog("option",
|
||||
"position","center");b.parent().on("mouseleave",function(){clearTimeout(g);g=setTimeout(function(){b.dialog("close")},3E4)})},close:function(){clearTimeout(g);b.dialog("destroy")}})}})},copypass:function(a){d.info("account:copypass");var b=c.appRequests().getRequestOpts();b.url=e.account.showPass;b.async=!1;b.data={accountid:a.data("item-id"),isHistory:a.data("history"),isAjax:1};return c.appRequests().getActionCall(b)},copy:function(a){d.info("account:copy");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},
|
||||
savefavorite:function(a,b){d.info("account:saveFavorite");var h="on"===a.data("status"),f={actionId:h?a.data("action-id-off"):a.data("action-id-on"),accountId:a.data("item-id"),sk:c.sk.get(),isAjax:1},g=c.appRequests().getRequestOpts();g.url=e.account.saveFavorite;g.data=f;c.appRequests().getActionCall(g,function(d){c.msg.out(d);0===d.status&&(a.data("status",h?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=c.appRequests().getRequestOpts();b.url=e.account.request;
|
||||
b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var c=$("#frmSearch");c.find('input[name="skey"]').val(a.data("key"));c.find('input[name="sorder"]').val(a.data("dir"));c.find('input[name="start"]').val(a.data("start"));n.search()},editpass:function(a){d.info("account:editpass");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},restore:function(a){d.info("account:restore");
|
||||
savefavorite:function(a,b){d.info("account:saveFavorite");var h="on"===a.data("status"),f={actionId:h?a.data("action-id-off"):a.data("action-id-on"),itemId:a.data("item-id"),sk:c.sk.get(),isAjax:1},g=c.appRequests().getRequestOpts();g.url=e.account.saveFavorite;g.data=f;c.appRequests().getActionCall(g,function(d){c.msg.out(d);0===d.status&&(a.data("status",h?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=c.appRequests().getRequestOpts();b.url=e.account.request;
|
||||
b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var c=$("#frmSearch");c.find('input[name="skey"]').val(a.data("key"));c.find('input[name="sorder"]').val(a.data("dir"));c.find('input[name="start"]').val(a.data("start"));m.search()},editpass:function(a){d.info("account:editpass");f({actionId:a.data("action-id"),itemId:a.data("item-id")})},restore:function(a){d.info("account:restore");
|
||||
f({actionId:a.data("action-id"),itemId:a.data("item-id")})},getfiles:function(a){d.info("account:getfiles");var b=c.appRequests().getRequestOpts();b.method="get";b.type="html";b.url=e.account.getFiles;b.data={id:a.data("item-id"),del:a.data("delete"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(c){a.html(c)})},search:function(){d.info("account:search");var a=$("#frmSearch");a.find("input[name='sk']").val(c.sk.get());a.find("input[name='skey']").val();a.find("input[name='sorder']").val();
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.account.search;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){10===a.status&&c.msg.out(a);c.sk.set(a.sk);$("#res-content").html(a.html)})},save:function(a){d.info("account:save");var b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},k={refreshTab:!0,show:function(a){d.info("appMgmt:show");a.data("item-dst")&&(k.refreshTab=!1);var b=c.appRequests().getRequestOpts();
|
||||
b.type="html";b.url=e.appMgmt.show;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(c){m(a,c)})},"delete":function(a){d.info("appMgmt:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[12]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={itemId:a.data("item-id"),
|
||||
b.type="html";b.url=e.appMgmt.show;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(c){n(a,c)})},"delete":function(a){d.info("appMgmt:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[12]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={itemId:a.data("item-id"),
|
||||
actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},function(a){a.preventDefault();c.msg.error(c.config().LANG[44])})},save:function(a){d.info("appMgmt:save");var b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&(!0===k.refreshTab&&f({actionId:a.data("nextaction-id"),
|
||||
itemId:a.data("activetab")}),k.refreshTab=!0,$.fancybox.close())})},search:function(a){d.info("appMgmt:search");var b=$(a.data("target")),h=c.appRequests().getRequestOpts();h.url=e.appMgmt.search;h.data=a.serialize();c.appRequests().getActionCall(h,function(h){0===h.status?(b.html(h.html),a.find("[name='sk']").val(h.sk)):b.html(c.msg.html.error(h.description))})},nav:function(a){d.info("appMgmt:nav");var b=$("#"+a.data("action-form"));b.find("[name='start']").val(a.data("start"));b.find("[name='count']").val(a.data("count"));
|
||||
b.find("[name='sk']").val(c.sk.get());k.search(b)}};return{doAction:f,appMgmt:k,account:n,file:{view:function(a){d.info("file:view");var b=c.appRequests().getRequestOpts();b.url=e.file;b.type="html";b.data={fileId:a.data("item-id"),sk:c.sk.get(),actionId:a.data("action-id")};c.appRequests().getActionCall(b,function(b){"undefined"!==typeof b.status&&1===b.status?c.msg.out(b):b?m(a,b):c.msg.error(c.config().LANG[14])})},download:function(a){d.info("file:download");a={fileId:a.data("item-id"),sk:c.sk.get(),
|
||||
b.find("[name='sk']").val(c.sk.get());k.search(b)}};return{doAction:f,appMgmt:k,account:m,file:{view:function(a){d.info("file:view");var b=c.appRequests().getRequestOpts();b.url=e.file;b.type="html";b.data={fileId:a.data("item-id"),sk:c.sk.get(),actionId:a.data("action-id")};c.appRequests().getActionCall(b,function(b){"undefined"!==typeof b.status&&1===b.status?c.msg.out(b):b?n(a,b):c.msg.error(c.config().LANG[14])})},download:function(a){d.info("file:download");a={fileId:a.data("item-id"),sk:c.sk.get(),
|
||||
actionId:a.data("action-id")};$.fileDownload(c.config().APP_ROOT+e.file,{httpMethod:"POST",data:a})},"delete":function(a){d.info("file:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[15]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,function(b){b=c.appRequests().getRequestOpts();b.url=e.file;b.data={fileId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&
|
||||
(a=$("#list-account-files"),n.getfiles(a))})},function(a){a.preventDefault();alertify.error(c.config().LANG[44])})}},checks:{ldap:function(a){d.info("checks:ldap");a=$(a.data("src"));var b=a.find("[name='ldap_bindpass']").val();a={type:"ldap",ldap_server:a.find("[name='ldap_server']").val(),ldap_base:a.find("[name='ldap_base']").val(),ldap_group:a.find("[name='ldap_group']").val(),ldap_binduser:a.find("[name='ldap_binduser']").val(),ldap_bindpass:""!==c.config().PK?c.config().crypt.encrypt(b):b,sk:c.sk.get(),
|
||||
(a=$("#list-account-files"),m.getfiles(a))})},function(a){a.preventDefault();alertify.error(c.config().LANG[44])})}},checks:{ldap:function(a){d.info("checks:ldap");a=$(a.data("src"));var b=a.find("[name='ldap_bindpass']").val();a={type:"ldap",ldap_server:a.find("[name='ldap_server']").val(),ldap_base:a.find("[name='ldap_base']").val(),ldap_group:a.find("[name='ldap_group']").val(),ldap_binduser:a.find("[name='ldap_binduser']").val(),ldap_bindpass:""!==c.config().PK?c.config().crypt.encrypt(b):b,sk:c.sk.get(),
|
||||
isAjax:1};b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},wiki:function(a){d.info("checks:wiki");a=$(a.data("src"));a={type:"dokuwiki",dokuwiki_url:a.find("[name='dokuwiki_url']").val(),dokuwiki_user:a.find("[name='dokuwiki_user']").val(),dokuwiki_pass:a.find("[name='dokuwiki_pass']").val(),isAjax:1,sk:c.sk.get()};var b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a;c.appRequests().getActionCall(b,function(a){c.msg.out(a);
|
||||
0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){d.info("config:save");var b=c.appRequests().getRequestOpts();b.url=e.config.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},backup:function(a){d.info("config:backup");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"export":function(a){d.info("config:export");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"import":function(a){d.info("config:import");
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.config["import"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},main:p,user:{savePreferences:function(a){d.info("user:savePreferences");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){window.location.replace("index.php")},
|
||||
2E3)})},saveSecurity:function(a){d.info("user:saveSecurity");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},password:function(a){d.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=e.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(b){0===b.length?p.logout():
|
||||
m(a,b)})},passreset:function(a){d.info("user:passreset");var b=c.appRequests().getRequestOpts();b.url=e.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},link:{save:function(a){d.info("link:save");var b=c.appRequests().getRequestOpts();b.url=e.link;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};alertify.okBtn(c.config().LANG[40]).cancelBtn(c.config().LANG[41]).confirm(c.config().LANG[48],function(a){a.preventDefault();
|
||||
n(a,b)})},passreset:function(a){d.info("user:passreset");var b=c.appRequests().getRequestOpts();b.url=e.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},link:{save:function(a){d.info("link:save");var b=c.appRequests().getRequestOpts();b.url=e.link;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};alertify.okBtn(c.config().LANG[40]).cancelBtn(c.config().LANG[41]).confirm(c.config().LANG[48],function(a){a.preventDefault();
|
||||
b.data.notify=1;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},function(a){a.preventDefault();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})})},refresh:function(a){d.info("link:refresh");a={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};var b=c.appRequests().getRequestOpts();b.url=e.link;b.data=a;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},eventlog:{nav:function(a){if("undefined"===typeof a.data("start"))return!1;
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.type="html";b.data={start:a.data("start"),current:a.data("current")};c.appRequests().getActionCall(b,function(a){$("#content").html(a);c.scrollUp()})},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.data={clear:1,sk:c.sk.get(),isAjax:1};
|
||||
c.appRequests().getActionCall(b,function(b){c.msg.out(b);0==b.status&&f({actionId:a.data("nextaction-id")})})},function(a){a.preventDefault();c.msg.error(c.config().LANG[44])})}},ajaxUrl:e}};
|
||||
|
||||
Reference in New Issue
Block a user