diff --git a/ajax/ajax_accountSave.php b/ajax/ajax_accountSave.php
index c26e742a..fedf2396 100644
--- a/ajax/ajax_accountSave.php
+++ b/ajax/ajax_accountSave.php
@@ -24,7 +24,8 @@
*/
use SP\Account\Account;
-use SP\Account\AccountData;
+use SP\Account\AccountTags;
+use SP\DataModel\AccountData;
use SP\Core\ActionsInterface;
use SP\Core\Crypt;
use SP\Core\Init;
@@ -33,8 +34,8 @@ use SP\Core\SessionUtil;
use SP\Core\SPException;
use SP\Http\Request;
use SP\Http\Response;
-use SP\Mgmt\Customer;
-use SP\Mgmt\CustomFields;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\CustomFields\CustomFields;
define('APP_ROOT', '..');
@@ -72,6 +73,7 @@ $accountMainGroupId = Request::analyze('mainGroupId', 0);
$accountChangesHash = Request::analyze('hash');
$customFieldsHash = Request::analyze('hashcf');
$customFields = Request::analyze('customfield');
+$tags = Request::analyze('tags');
// Datos del Usuario
$currentUserId = Session::getUserId();
@@ -139,7 +141,6 @@ if ($actionId == ActionsInterface::ACTION_ACC_NEW
}
}
-
$AccountData = new AccountData();
$AccountData->setAccountId($accountId);
$AccountData->setAccountName($accountName);
@@ -153,6 +154,10 @@ $AccountData->setAccountUserGroupsId($accountOtherGroups);
$AccountData->setAccountOtherUserEdit($accountUserEditEnabled);
$AccountData->setAccountOtherGroupEdit($accountGroupEditEnabled);
+if (is_array($tags)) {
+ $AccountData->setTags($tags);
+}
+
$Account = new Account($AccountData);
switch ($actionId) {
@@ -212,7 +217,7 @@ switch ($actionId) {
// Comprobar si han habido cambios
if ($accountChangesHash == $Account->calcChangesHash()
- && \SP\Mgmt\CustomFieldsUtil::checkHash($customFields, $customFieldsHash)
+ && \SP\Mgmt\CustomFields\CustomFieldsUtil::checkHash($customFields, $customFieldsHash)
) {
Response::printJSON(_('Sin cambios'), 0);
}
@@ -220,7 +225,7 @@ switch ($actionId) {
// Actualizar cuenta
if ($Account->updateAccount()) {
if (is_array($customFields)) {
- \SP\Mgmt\CustomFieldsUtil::updateCustonFields($customFields, $accountId);
+ \SP\Mgmt\CustomFields\CustomFieldsUtil::updateCustonFields($customFields, $accountId);
}
Response::printJSON(_('Cuenta actualizada'), 0);
diff --git a/ajax/ajax_appMgmtData.php b/ajax/ajax_appMgmtData.php
index a0f0d146..0a1ffd72 100644
--- a/ajax/ajax_appMgmtData.php
+++ b/ajax/ajax_appMgmtData.php
@@ -189,6 +189,18 @@ switch ($actionId) {
$Controller = new AccItemMgmt($Tpl);
$Controller->getPublicLink();
break;
+ case ActionsInterface::ACTION_MGM_TAGS_NEW:
+ $Tpl->assign('header', _('Nueva Etiqueta'));
+ $Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
+ $Controller = new AppItemMgmt($Tpl);
+ $Controller->getTag();
+ break;
+ case ActionsInterface::ACTION_MGM_TAGS_EDIT:
+ $Tpl->assign('header', _('Editar Etiqueta'));
+ $Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
+ $Controller = new AppItemMgmt($Tpl);
+ $Controller->getTag();
+ break;
default :
exit();
break;
diff --git a/ajax/ajax_appMgmtSave.php b/ajax/ajax_appMgmtSave.php
index 8218dfa8..132501f1 100644
--- a/ajax/ajax_appMgmtSave.php
+++ b/ajax/ajax_appMgmtSave.php
@@ -24,22 +24,22 @@
*/
use SP\Account\Account;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Core\ActionsInterface;
use SP\Core\Session;
use SP\Core\SPException;
use SP\Http\Request;
use SP\Core\SessionUtil;
use SP\Http\Response;
-use SP\Mgmt\Category;
-use SP\Mgmt\Customer;
-use SP\Mgmt\CustomFieldDef;
-use SP\Mgmt\CustomFields;
-use SP\Mgmt\Files;
-use SP\Mgmt\PublicLink;
-use SP\Mgmt\User\Groups;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Categories\Category;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\CustomFields\CustomFieldDef;
+use SP\Mgmt\CustomFields\CustomFields;
+use SP\Mgmt\Files\Files;
+use SP\Mgmt\PublicLinks\PublicLink;
+use SP\Mgmt\Groups\Groups;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Users\UserUtil;
use SP\Util\Checks;
define('APP_ROOT', '..');
@@ -78,7 +78,7 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
$isLdap = Request::analyze('isLdap', 0);
$userPassR = Request::analyzeEncrypted('passR');
- $User = new \SP\Mgmt\User\User();
+ $User = new \SP\Mgmt\Users\User();
$User->setUserId($itemId);
$User->setUserName(Request::analyze('name'));
$User->setUserLogin(Request::analyze('login'));
@@ -583,6 +583,40 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
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 \SP\DataModel\TagData($itemId, Request::analyze('name'));
+
+ if ($actionId === ActionsInterface::ACTION_MGM_TAGS_NEW) {
+ try {
+ $Tag = new \SP\Mgmt\Tags\Tags();
+ $Tag->addTag($TagData);
+ } catch (SPException $e) {
+ Response::printJSON($e->getMessage());
+ }
+
+ Response::printJSON(_('Etiqueta creada'), 0, $doActionOnClose);
+ } elseif ($actionId === ActionsInterface::ACTION_MGM_TAGS_DELETE) {
+ try {
+ $Tag = new \SP\Mgmt\Tags\Tags();
+ $Tag->deleteTag($TagData);
+ } catch (SPException $e) {
+ Response::printJSON($e->getMessage());
+ }
+
+ Response::printJSON(_('Etiqueta eliminada'), 0, $doActionOnClose);
+ } elseif ($actionId === ActionsInterface::ACTION_MGM_TAGS_EDIT) {
+ try {
+ $Tag = new \SP\Mgmt\Tags\Tags();
+ $Tag->updateTag($TagData);
+ } catch (SPException $e) {
+ Response::printJSON($e->getMessage());
+ }
+
+ Response::printJSON(_('Etiqueta actualizada'), 0, $doActionOnClose);
+ }
} elseif ($actionId === ActionsInterface::ACTION_MGM_FILES_DELETE) {
// Verificamos que el ID sea numérico
if ($itemId === 0) {
diff --git a/ajax/ajax_appMgmtSearch.php b/ajax/ajax_appMgmtSearch.php
index 73dd5d0e..ee0d0caf 100644
--- a/ajax/ajax_appMgmtSearch.php
+++ b/ajax/ajax_appMgmtSearch.php
@@ -97,6 +97,10 @@ switch ($actionId) {
$Controller = new AppItemsMgmtSearch($Tpl);
$Controller->getAccounts($search, $limitStart, $limitCount);
break;
+ case \SP\Core\ActionsInterface::ACTION_MGM_TAGS_SEARCH:
+ $Controller = new AppItemsMgmtSearch($Tpl);
+ $Controller->getTags($search, $limitStart, $limitCount);
+ break;
default:
Response::printJSON(_('Acción Inválida'));
break;
diff --git a/ajax/ajax_configSave.php b/ajax/ajax_configSave.php
index 160abbfc..b814c8c7 100644
--- a/ajax/ajax_configSave.php
+++ b/ajax/ajax_configSave.php
@@ -39,8 +39,8 @@ use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Mgmt\CustomFields;
-use SP\Mgmt\User\UserPass;
+use SP\Mgmt\CustomFields\CustomFields;
+use SP\Mgmt\Users\UserPass;
use SP\Util\Checks;
define('APP_ROOT', '..');
diff --git a/ajax/ajax_doLogin.php b/ajax/ajax_doLogin.php
index b74da676..d750da7e 100644
--- a/ajax/ajax_doLogin.php
+++ b/ajax/ajax_doLogin.php
@@ -34,13 +34,13 @@ use SP\Core\Themes;
use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Log;
-use SP\Mgmt\User\Groups;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\User;
-use SP\Mgmt\User\UserLdap;
-use SP\Mgmt\User\UserPass;
-use SP\Mgmt\User\UserPassRecover;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Groups\Groups;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Users\User;
+use SP\Mgmt\Users\UserLdap;
+use SP\Mgmt\Users\UserPass;
+use SP\Mgmt\Users\UserPassRecover;
+use SP\Mgmt\Users\UserUtil;
define('APP_ROOT', '..');
@@ -209,7 +209,7 @@ if ($User->getUserMPass()) {
Response::printJSON(_('Error interno'));
}
-$UserPrefs = \SP\Mgmt\User\UserPreferences::getPreferences($User->getUserId());
+$UserPrefs = \SP\Mgmt\Users\UserPreferences::getPreferences($User->getUserId());
Language::setLanguage(true);
Themes::setTheme(true);
Session::setUserPreferences($UserPrefs);
diff --git a/ajax/ajax_files.php b/ajax/ajax_files.php
index 9127673c..0ca276df 100644
--- a/ajax/ajax_files.php
+++ b/ajax/ajax_files.php
@@ -32,7 +32,7 @@ use SP\Html\Html;
use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Log;
-use SP\Mgmt\Files;
+use SP\Mgmt\Files\Files;
use SP\Util\Checks;
use SP\Util\Util;
diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php
index 6d03a6cf..72b0b908 100644
--- a/ajax/ajax_getContent.php
+++ b/ajax/ajax_getContent.php
@@ -148,6 +148,7 @@ switch ($actionId) {
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS:
case ActionsInterface::ACTION_MGM_FILES:
case ActionsInterface::ACTION_MGM_ACCOUNTS:
+ case ActionsInterface::ACTION_MGM_TAGS:
$Controller = new \SP\Controller\AppItemsMgmt($Tpl);
$Controller->useTabs();
$Controller->getCategories();
@@ -155,6 +156,7 @@ switch ($actionId) {
$Controller->getCustomFields();
$Controller->getFiles();
$Controller->getAccounts();
+ $Controller->getTags();
break;
case ActionsInterface::ACTION_CFG:
case ActionsInterface::ACTION_CFG_GENERAL:
diff --git a/ajax/ajax_passReset.php b/ajax/ajax_passReset.php
index 135c1d9e..b077a095 100644
--- a/ajax/ajax_passReset.php
+++ b/ajax/ajax_passReset.php
@@ -30,9 +30,9 @@ use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Mgmt\User\UserPass;
-use SP\Mgmt\User\UserPassRecover;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserPass;
+use SP\Mgmt\Users\UserPassRecover;
+use SP\Mgmt\Users\UserUtil;
define('APP_ROOT', '..');
diff --git a/ajax/ajax_sendRequest.php b/ajax/ajax_sendRequest.php
index 81a00b71..d73ff2c6 100644
--- a/ajax/ajax_sendRequest.php
+++ b/ajax/ajax_sendRequest.php
@@ -33,7 +33,7 @@ use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Util\Checks;
define('APP_ROOT', '..');
diff --git a/ajax/ajax_userPrefsSave.php b/ajax/ajax_userPrefsSave.php
index 9e580fd1..93bcbabc 100644
--- a/ajax/ajax_userPrefsSave.php
+++ b/ajax/ajax_userPrefsSave.php
@@ -31,8 +31,8 @@ use SP\Core\Themes;
use SP\Http\Request;
use SP\Core\SessionUtil;
use SP\Http\Response;
-use SP\Mgmt\User\UserPreferences;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserPreferences;
+use SP\Mgmt\Users\UserUtil;
use SP\Util\Checks;
use SP\Util\Util;
diff --git a/ajax/ajax_viewpass.php b/ajax/ajax_viewpass.php
index 56cc3835..86f29605 100644
--- a/ajax/ajax_viewpass.php
+++ b/ajax/ajax_viewpass.php
@@ -24,7 +24,7 @@
*/
use SP\Account\Account;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Account\AccountHistory;
use SP\Core\Acl;
use SP\Core\Crypt;
@@ -32,7 +32,7 @@ use SP\Core\Init;
use SP\Http\Request;
use SP\Http\Response;
use SP\Log\Log;
-use SP\Mgmt\User\UserPass;
+use SP\Mgmt\Users\UserPass;
use SP\Util\Checks;
define('APP_ROOT', '..');
diff --git a/css/chosen-custom.min.css b/css/chosen-custom.min.css
deleted file mode 100644
index e61eb364..00000000
--- a/css/chosen-custom.min.css
+++ /dev/null
@@ -1,11 +0,0 @@
-/*!
-Chosen, a Select Box Enhancer for jQuery and Prototype
-by Patrick Filler for Harvest, http://getharvest.com
-
-Version 1.4.2
-Full source at https://github.com/harvesthq/chosen
-Copyright (c) 2011-2015 Harvest http://getharvest.com
-
-MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
-This file is generated by `grunt build`, do not edit it by hand.
-*/.chosen-container .chosen-results li.highlighted{background-color:#536dfe;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#879bff),color-stop(90%,#536dfe));background-image:-webkit-linear-gradient(#879bff 20%,#536dfe 90%);background-image:-moz-linear-gradient(#879bff 20%,#536dfe 90%);background-image:-o-linear-gradient(#879bff 20%,#536dfe 90%);background-image:linear-gradient(#879bff 20%,#536dfe 90%);color:#fff}.chosen-container-active .chosen-single{border:1px solid rgba(83,109,254,.8);box-shadow:0 0 5px rgba(0,0,0,0.3)}.chosen-container-active .chosen-choices{border:1px solid rgba(83,109,254,.8);box-shadow:0 0 5px rgba(0,0,0,0.3)}
\ No newline at end of file
diff --git a/css/chosen-sprite.png b/css/chosen-sprite.png
deleted file mode 100644
index c57da70b..00000000
Binary files a/css/chosen-sprite.png and /dev/null differ
diff --git a/css/chosen-sprite@2x.png b/css/chosen-sprite@2x.png
deleted file mode 100644
index 6b505452..00000000
Binary files a/css/chosen-sprite@2x.png and /dev/null differ
diff --git a/css/chosen.min.css b/css/chosen.min.css
deleted file mode 100644
index 5ca6159c..00000000
--- a/css/chosen.min.css
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Chosen v1.4.2 | (c) 2011-2015 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
-
-.chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;zoom:1;*display:inline;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container .search-choice .group-name,.chosen-container .chosen-single .group-name{margin-right:4px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:400;color:#999}.chosen-container .search-choice .group-name:after,.chosen-container .chosen-single .group-name:after{content:":";padding-left:2px;vertical-align:top}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:25px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{color:#444;position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;word-wrap:break-word;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{color:#777;display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;margin:0;padding:0 5px;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:0;height:25px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#999;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 5px 3px 0;padding:3px 20px 3px 5px;border:1px solid #aaa;max-width:100%;border-radius:3px;background-color:#eee;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-size:100% 19px;background-repeat:repeat-x;background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice span{word-wrap:break-word}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#222!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi),only screen and (min-resolution:1.5dppx){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
\ No newline at end of file
diff --git a/css/css.php b/css/css.php
index 5d5af08c..f6043408 100644
--- a/css/css.php
+++ b/css/css.php
@@ -39,8 +39,6 @@ if (!$file) {
$Minify->addFile('reset.min.css');
$Minify->addFile('jquery-ui.min.css');
$Minify->addFile('jquery-ui.structure.min.css');
- $Minify->addFile('chosen.min.css');
- $Minify->addFile('chosen-custom.min.css');
$Minify->addFile('alertify.min.css');
$Minify->addFile('jquery.tagsinput.min.css');
$Minify->addFile('jquery.fancybox.min.css');
diff --git a/css/fonts.min.css b/css/fonts.min.css
index 590da618..bf83d485 100644
--- a/css/fonts.min.css
+++ b/css/fonts.min.css
@@ -1 +1 @@
-@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url("MaterialIcons-Regular.eot");src:local('Material Icons'),local('MaterialIcons-Regular'),url("MaterialIcons-Regular.woff2") format('woff2'),url("MaterialIcons-Regular.woff") format('woff'),url("MaterialIcons-Regular.ttf") format('truetype')}
\ No newline at end of file
+@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url("fonts/MaterialIcons-Regular.eot");src:local('Material Icons'),local('MaterialIcons-Regular'),url("fonts/MaterialIcons-Regular.woff2") format('woff2'),url("fonts/MaterialIcons-Regular.woff") format('woff'),url("fonts/MaterialIcons-Regular.ttf") format('truetype')}
\ No newline at end of file
diff --git a/css/MaterialIcons-Regular.eot b/css/fonts/MaterialIcons-Regular.eot
similarity index 100%
rename from css/MaterialIcons-Regular.eot
rename to css/fonts/MaterialIcons-Regular.eot
diff --git a/css/MaterialIcons-Regular.ttf b/css/fonts/MaterialIcons-Regular.ttf
similarity index 100%
rename from css/MaterialIcons-Regular.ttf
rename to css/fonts/MaterialIcons-Regular.ttf
diff --git a/css/MaterialIcons-Regular.woff b/css/fonts/MaterialIcons-Regular.woff
similarity index 100%
rename from css/MaterialIcons-Regular.woff
rename to css/fonts/MaterialIcons-Regular.woff
diff --git a/css/MaterialIcons-Regular.woff2 b/css/fonts/MaterialIcons-Regular.woff2
similarity index 100%
rename from css/MaterialIcons-Regular.woff2
rename to css/fonts/MaterialIcons-Regular.woff2
diff --git a/inc/Base.php b/inc/Base.php
index 8eb0a917..03aa5112 100644
--- a/inc/Base.php
+++ b/inc/Base.php
@@ -42,8 +42,11 @@ require 'SplClassLoader.php';
$ClassLoader = new SplClassLoader();
$ClassLoader->setFileExtension('.class.php');
$ClassLoader->addExcluded('SP\\Profile');
+$ClassLoader->addExcluded('SP\\Mgmt\\User\\Profile');
$ClassLoader->addExcluded('SP\\UserPreferences');
+$ClassLoader->addExcluded('SP\\Mgmt\\User\\UserPreferences');
$ClassLoader->addExcluded('SP\\CustomFieldDef');
+$ClassLoader->addExcluded('SP\\Mgmt\\CustomFieldDef');
$ClassLoader->addExcluded('SP\\PublicLink');
$ClassLoader->register();
diff --git a/inc/SP/Account/Account.class.php b/inc/SP/Account/Account.class.php
index 5af81ecd..9d49f141 100644
--- a/inc/SP/Account/Account.class.php
+++ b/inc/SP/Account/Account.class.php
@@ -28,8 +28,8 @@ namespace SP\Account;
use SP\Core\Crypt;
use SP\Storage\DB;
use SP\Log\Email;
-use SP\Mgmt\Files;
-use SP\Mgmt\User\Groups;
+use SP\Mgmt\Files\Files;
+use SP\Mgmt\Groups\Groups;
use SP\Html\Html;
use SP\Log\Log;
use SP\Core\Session;
@@ -67,7 +67,7 @@ class Account extends AccountBase implements AccountInterface
$Log->setAction(_('Actualizar Cuenta'));
- if (!Groups::updateGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) {
+ if (!GroupAccounts::updateGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) {
$Log->addDescription(_('Error al actualizar los grupos secundarios'));
$Log->writeLog();
$Log->resetDescription();
@@ -79,6 +79,11 @@ class Account extends AccountBase implements AccountInterface
$Log->resetDescription();
}
+ if (is_array($this->accountData->getTags())) {
+ $AccountTags = new AccountTags();
+ $AccountTags->addTags($this->accountData);
+ }
+
$Data = new QueryData();
if ($this->accountData->getAccountUserGroupId()) {
@@ -306,7 +311,7 @@ class Account extends AccountBase implements AccountInterface
// Obtener los usuarios y grupos secundarios
$this->accountData->setAccountUsersId(UserAccounts::getUsersForAccount($this->accountData->getAccountId()));
- $this->accountData->setAccountUserGroupsId(Groups::getGroupsForAccount($this->accountData->getAccountId()));
+ $this->accountData->setAccountUserGroupsId(GroupAccounts::getGroupsForAccount($this->accountData->getAccountId()));
$this->accountData->setAccountName($queryRes->account_name);
$this->accountData->setAccountCategoryId($queryRes->account_categoryId);
@@ -321,6 +326,8 @@ class Account extends AccountBase implements AccountInterface
$this->accountData->setAccountUserGroupId($queryRes->account_userGroupId);
$this->accountData->setAccountOtherUserEdit($queryRes->account_otherUserEdit);
$this->accountData->setAccountOtherGroupEdit($queryRes->account_otherGroupEdit);
+ $this->accountData->setTags(AccountTags::getTags($this->accountData));
+
$this->setAccountModHash($this->calcChangesHash());
return $queryRes;
@@ -372,7 +379,7 @@ class Account extends AccountBase implements AccountInterface
$Log = new Log(__FUNCTION__);
if (is_array($this->accountData->getAccountUserGroupsId())) {
- if (!Groups::addGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) {
+ if (!GroupAccounts::addGroupsForAccount($this->accountData->getAccountId(), $this->accountData->getAccountUserGroupsId())) {
$Log->addDescription(_('Error al actualizar los grupos secundarios'));
$Log->writeLog();
$Log->resetDescription();
@@ -387,6 +394,11 @@ class Account extends AccountBase implements AccountInterface
}
}
+ if (is_array($this->accountData->getTags())) {
+ $AccountTags = new AccountTags();
+ $AccountTags->addTags($this->accountData);
+ }
+
$accountInfo = array('customer_name');
$this->getAccountInfoById($accountInfo);
@@ -428,7 +440,7 @@ class Account extends AccountBase implements AccountInterface
return false;
}
- if (!Groups::deleteGroupsForAccount($this->accountData->getAccountId())) {
+ if (!GroupAccounts::deleteGroupsForAccount($this->accountData->getAccountId())) {
$Log->setLogLevel(Log::ERROR);
$Log->addDescription(_('Error al eliminar grupos asociados a la cuenta'));
}
diff --git a/inc/SP/Account/AccountBase.class.php b/inc/SP/Account/AccountBase.class.php
index 26b9a3e8..f0cad0dc 100644
--- a/inc/SP/Account/AccountBase.class.php
+++ b/inc/SP/Account/AccountBase.class.php
@@ -25,7 +25,8 @@
namespace SP\Account;
-use SP\Mgmt\User\Groups;
+use SP\DataModel\AccountData;
+use SP\Mgmt\Groups\Groups;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
@@ -118,16 +119,6 @@ abstract class AccountBase
$this->accountData->setAccountId($accId);
return $this->accountData;
-
-// return array(
-// 'id' => $accId,
-// 'user_id' => $this->accountData->getAccountUserId(),
-// 'group_id' => $this->accountData->getAccountUserGroupId(),
-// 'users_id' => $this->accountData->getAccountUsersId(),
-// 'groups_id' => $this->accountData->getAccountUserGroupsId(),
-// 'otheruser_edit' => $this->accountData->getAccountOtherUserEdit(),
-// 'othergroup_edit' => $this->accountData->getAccountOtherGroupEdit()
-// );
}
/**
@@ -174,7 +165,7 @@ abstract class AccountBase
if (!isset($cacheUserGroups[$accId])
|| time() > $cacheUserGroups['expires']
) {
- $cacheUserGroups[$accId] = Groups::getGroupsForAccount($accId);
+ $cacheUserGroups[$accId] = GroupAccounts::getGroupsForAccount($accId);
$cacheUserGroups['expires'] = time() + self::CACHE_EXPIRE_TIME;
}
@@ -227,6 +218,7 @@ abstract class AccountBase
$this->accountData->getAccountLogin() .
$this->accountData->getAccountUrl() .
$this->accountData->getAccountNotes() .
+ implode('', array_keys($this->accountData->getTags())) .
(int)$this->accountData->getAccountOtherUserEdit() .
(int)$this->accountData->getAccountOtherGroupEdit() .
(int)$users .
diff --git a/inc/SP/Account/AccountSearch.class.php b/inc/SP/Account/AccountSearch.class.php
index 1eb56d67..fbca5eb1 100644
--- a/inc/SP/Account/AccountSearch.class.php
+++ b/inc/SP/Account/AccountSearch.class.php
@@ -28,11 +28,12 @@ namespace SP\Account;
use SP\Config\Config;
use SP\Core\Acl;
use SP\Core\ActionsInterface;
+use SP\DataModel\AccountData;
use SP\Storage\DB;
-use SP\Mgmt\User\Groups;
+use SP\Mgmt\Groups\Groups;
use SP\Html\Html;
use SP\Core\Session;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\QueryData;
use SP\Util\Checks;
@@ -261,6 +262,122 @@ class AccountSearch
$this->limitCount = $limitCount;
}
+ /**
+ * Obtiene el número de cuentas que un usuario puede ver.
+ *
+ * @return false|int con el número de registros
+ */
+ public function getAccountMax()
+ {
+ $Data = new QueryData();
+
+ if (!Session::getUserIsAdminApp() && !Session::getUserIsAdminAcc()) {
+ $query = 'SELECT COUNT(DISTINCT account_id) as numacc '
+ . 'FROM accounts '
+ . 'LEFT JOIN accGroups ON account_id = accgroup_accountId '
+ . 'WHERE account_userGroupId = :userGroupId '
+ . 'OR account_userId = :userId '
+ . 'OR accgroup_groupId = :groupId';
+
+ $Data->addParam(Session::getUserGroupId(), 'userGroupId');
+ $Data->addParam(Session::getUserGroupId(), 'groupId');
+ $Data->addParam(Session::getUserId(), 'userId');
+ } else {
+ $query = "SELECT COUNT(*) as numacc FROM accounts";
+ }
+
+ $Data->setQuery($query);
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return false;
+ }
+
+ return $queryRes->numacc;
+ }
+
+ /**
+ * Procesar los resultados de la búsqueda y crear la variable que contiene los datos de cada cuenta
+ * a mostrar.
+ *
+ * @return array
+ */
+ public function processSearchResults()
+ {
+ if (!$results = $this->getAccounts()) {
+ return [];
+ }
+
+ // Variables de configuración
+ $maxTextLength = (Checks::resultsCardsIsEnabled()) ? 40 : 60;
+
+ $favorites = AccountFavorites::getFavorites(Session::getUserId());
+
+ $Account = new Account(new AccountData());
+ $accountsData['count'] = self::$queryNumRows;
+
+ foreach ($results as $account) {
+ $Account->getAccountData()->setAccountId($account->account_id);
+ $Account->getAccountData()->setAccountUserId($account->account_userId);
+ $Account->getAccountData()->setAccountUsersId($Account->getUsersAccount());
+ $Account->getAccountData()->setAccountUserGroupId($account->account_userGroupId);
+ $Account->getAccountData()->setAccountUserGroupsId($Account->getGroupsAccount());
+ $Account->getAccountData()->setAccountOtherUserEdit($account->account_otherUserEdit);
+ $Account->getAccountData()->setAccountOtherGroupEdit($account->account_otherGroupEdit);
+
+ // Obtener los datos de la cuenta para aplicar las ACL
+ $accountAclData = $Account->getAccountDataForACL();
+
+ $AccountSearchData = new AccountsSearchData();
+ $AccountSearchData->setTextMaxLength($maxTextLength);
+ $AccountSearchData->setId($account->account_id);
+ $AccountSearchData->setName($account->account_name);
+ $AccountSearchData->setLogin($account->account_login);
+ $AccountSearchData->setCategoryName($account->category_name);
+ $AccountSearchData->setCustomerName($account->customer_name);
+ $AccountSearchData->setCustomerLink((AccountsSearchData::$wikiEnabled) ? Config::getConfig()->getWikiSearchurl() . $account->customer_name : '');
+ $AccountSearchData->setColor($this->pickAccountColor($account->account_customerId));
+ $AccountSearchData->setUrl($account->account_url);
+ $AccountSearchData->setFavorite(in_array($account->account_id, $favorites));
+ $AccountSearchData->setTags(AccountTags::getTags($Account->getAccountData()));
+ $AccountSearchData->setNumFiles((Checks::fileIsEnabled()) ? $account->num_files : 0);
+ $AccountSearchData->setShowView(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_VIEW, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW));
+ $AccountSearchData->setShowViewPass(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_VIEW_PASS, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW_PASS));
+ $AccountSearchData->setShowEdit(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_EDIT, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_EDIT));
+ $AccountSearchData->setShowCopy(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_COPY, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_COPY));
+ $AccountSearchData->setShowDelete(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_DELETE, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_DELETE));
+
+ // Obtenemos datos si el usuario tiene acceso a los datos de la cuenta
+ if ($AccountSearchData->isShow()) {
+ $secondaryAccesses = sprintf('(G) %s*
', $account->usergroup_name);
+
+ foreach (GroupAccounts::getGroupsInfoForAccount($account->account_id) as $group) {
+ $secondaryAccesses .= sprintf('(G) %s
', $group->getUsergroupName());
+ }
+
+ foreach (UserAccounts::getUsersInfoForAccount($account->account_id) as $user) {
+ $secondaryAccesses .= sprintf('(U) %s
', $user->getUserLogin());
+ }
+
+ $AccountSearchData->setAccesses($secondaryAccesses);
+
+ $accountNotes = '';
+
+ if ($account->account_notes) {
+ $accountNotes = (strlen($account->account_notes) > 300) ? substr($account->account_notes, 0, 300) . "..." : $account->account_notes;
+ $accountNotes = nl2br(wordwrap(htmlspecialchars($accountNotes), 50, '
', true));
+ }
+
+ $AccountSearchData->setNotes($accountNotes);
+ }
+
+ $accountsData[] = $AccountSearchData;
+ }
+
+ return $accountsData;
+ }
+
/**
* Obtener las cuentas de una búsqueda.
*
@@ -270,10 +387,10 @@ class AccountSearch
{
$isAdmin = (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc());
- $arrFilterCommon = array();
- $arrFilterSelect = array();
- $arrFilterUser = array();
- $arrQueryWhere = array();
+ $arrFilterCommon = [];
+ $arrFilterSelect = [];
+ $arrFilterUser = [];
+ $arrQueryWhere = [];
$queryLimit = '';
$Data = new QueryData();
@@ -283,10 +400,7 @@ class AccountSearch
$stringFilters = $this->analyzeQueryString();
if ($stringFilters !== false) {
- $i = 0;
-
foreach ($stringFilters as $column => $value) {
- $parameter = 'P_' . $column . $i;
$rel = '=';
if (preg_match('/name/i', $column)) {
@@ -294,40 +408,44 @@ class AccountSearch
$value = '%' . $value . '%';
}
- $arrFilterCommon[] = $column . ' ' . $rel . ' :' . $parameter;
+ $arrFilterCommon[] = $column . ' ' . $rel . ' ?';
- $Data->addParam($value, $parameter);
- $i++;
+ $Data->addParam($value);
}
} else {
- $arrFilterCommon[] = 'account_name LIKE :name';
- $arrFilterCommon[] = 'account_login LIKE :login';
- $arrFilterCommon[] = 'account_url LIKE :url';
- $arrFilterCommon[] = 'account_notes LIKE :notes';
+ $txtSearch = '%' . $this->txtSearch . '%';
+
+ $arrFilterCommon[] = 'account_name LIKE ?';
+ $Data->addParam($txtSearch);
+
+ $arrFilterCommon[] = 'account_login LIKE ?';
+ $Data->addParam($txtSearch);
+
+ $arrFilterCommon[] = 'account_url LIKE ?';
+ $Data->addParam($txtSearch);
+
+ $arrFilterCommon[] = 'account_notes LIKE ?';
+ $Data->addParam($txtSearch);
- $Data->addParam('%' . $this->txtSearch . '%', 'name');
- $Data->addParam('%' . $this->txtSearch . '%', 'login');
- $Data->addParam('%' . $this->txtSearch . '%', 'url');
- $Data->addParam('%' . $this->txtSearch . '%', 'notes');
}
}
if ($this->categoryId !== 0) {
- $arrFilterSelect[] = 'category_id = :categoryId';
+ $arrFilterSelect[] = 'category_id = ?';
- $Data->addParam($this->categoryId, 'categoryId');
+ $Data->addParam($this->categoryId);
}
if ($this->customerId !== 0) {
- $arrFilterSelect[] = 'account_customerId = :customerId';
+ $arrFilterSelect[] = 'account_customerId = ?';
- $Data->addParam($this->customerId, 'customerId');
+ $Data->addParam($this->customerId);
}
if ($this->searchFavorites === true) {
- $arrFilterSelect[] = 'accFavorites.accfavorite_userId = :favUserId';
+ $arrFilterSelect[] = 'accFavorites.accfavorite_userId = ?';
- $Data->addParam(Session::getUserId(), 'favUserId');
+ $Data->addParam(Session::getUserId());
}
if (count($arrFilterCommon) > 0) {
@@ -339,30 +457,34 @@ class AccountSearch
}
if (!$isAdmin && !$this->globalSearch) {
- $subQueryGroupsA = '(SELECT user_groupId FROM usrData WHERE user_id = :userIduA UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = :userIdgA)';
- $subQueryGroupsB = '(SELECT user_groupId FROM usrData WHERE user_id = :userIduB UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = :userIdgB)';
+ $subQueryGroups = '(SELECT user_groupId FROM usrData WHERE user_id = ? UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = ?)';
- $arrFilterUser[] = 'account_userGroupId IN ' . $subQueryGroupsA;
- $arrFilterUser[] = 'accgroup_groupId IN ' . $subQueryGroupsB;
- $arrFilterUser[] = 'account_userId = :userId';
- $arrFilterUser[] = 'accuser_userId = :accuser_userId';
+ // Buscar el grupo principal de la cuenta en los grupos del usuario
+ $arrFilterUser[] = 'account_userGroupId IN ' . $subQueryGroups;
+ $Data->addParam(Session::getUserId());
+ $Data->addParam(Session::getUserId());
- // Usuario/Grupo principal de la cuenta
- $Data->addParam(Session::getUserId(), 'userId');
- $Data->addParam(Session::getUserId(), 'accuser_userId');
- $Data->addParam(Session::getUserId(), 'userIduA');
- $Data->addParam(Session::getUserId(), 'userIduB');
- $Data->addParam(Session::getUserId(), 'userIdgA');
- $Data->addParam(Session::getUserId(), 'userIdgB');
+ // Buscar los grupos secundarios de la cuenta en los grupos del usuario
+ $arrFilterUser[] = 'accgroup_groupId IN ' . $subQueryGroups;
+ $Data->addParam(Session::getUserId());
+ $Data->addParam(Session::getUserId());
+
+ // Comprobar el usuario principal de la cuenta con el usuario actual
+ $arrFilterUser[] = 'account_userId = ?';
+ $Data->addParam(Session::getUserId());
+
+ // Comprobar los usuarios secundarios de la cuenta con el usuario actual
+ $arrFilterUser[] = 'accuser_userId = ?';
+ $Data->addParam(Session::getUserId());
$arrQueryWhere[] = '(' . implode(' OR ', $arrFilterUser) . ')';
}
if ($this->limitCount > 0) {
- $queryLimit = 'LIMIT :limitStart,:limitCount';
+ $queryLimit = 'LIMIT ?, ?';
- $Data->addParam($this->limitStart, 'limitStart');
- $Data->addParam($this->limitCount, 'limitCount');
+ $Data->addParam($this->limitStart);
+ $Data->addParam($this->limitCount);
}
if (count($arrQueryWhere) === 1) {
@@ -373,33 +495,33 @@ class AccountSearch
$queryWhere = '';
}
- $query = 'SELECT DISTINCT ' .
- 'account_id,' .
- 'account_customerId,' .
- 'category_name,' .
- 'account_name,' .
- 'account_login,' .
- 'account_url,' .
- 'account_notes,' .
- 'account_userId,' .
- 'account_userGroupId,' .
- 'BIN(account_otherUserEdit) AS account_otherUserEdit,' .
- 'BIN(account_otherGroupEdit) AS account_otherGroupEdit,' .
- 'usergroup_name,' .
- 'customer_name,' .
- 'count(accfile_id) as num_files ' .
- 'FROM accounts ' .
- 'LEFT JOIN accFiles ON account_id = accfile_accountId ' .
- 'LEFT JOIN categories ON account_categoryId = category_id ' .
- 'LEFT JOIN usrGroups ug ON account_userGroupId = usergroup_id ' .
- 'LEFT JOIN customers ON customer_id = account_customerId ' .
- 'LEFT JOIN accUsers ON accuser_accountId = account_id ' .
- 'LEFT JOIN accGroups ON accgroup_accountId = account_id ' .
- 'LEFT JOIN accFavorites ON accfavorite_accountId = account_id ' .
- $queryWhere . ' ' .
- 'GROUP BY account_id ' .
- $this->getOrderString() . ' ' .
- $queryLimit;
+ $query = 'SELECT DISTINCT account_id,
+ account_customerId,
+ category_name,
+ account_name,
+ account_login,
+ account_url,
+ account_notes,
+ account_userId,
+ account_userGroupId,
+ BIN(account_otherUserEdit) AS account_otherUserEdit,
+ BIN(account_otherGroupEdit) AS account_otherGroupEdit,
+ usergroup_name,
+ customer_name,
+ count(accfile_id) as num_files
+ FROM accounts
+ LEFT JOIN accFiles ON account_id = accfile_accountId
+ LEFT JOIN categories ON account_categoryId = category_id
+ LEFT JOIN usrGroups ug ON account_userGroupId = usergroup_id
+ LEFT JOIN customers ON customer_id = account_customerId
+ LEFT JOIN accUsers ON accuser_accountId = account_id
+ LEFT JOIN accGroups ON accgroup_accountId = account_id
+ LEFT JOIN accFavorites ON accfavorite_accountId = account_id
+ LEFT JOIN accTags ON acctag_accountId = account_id
+ LEFT JOIN tags ON tag_id = acctag_tagId
+ ' . $queryWhere . '
+ GROUP BY account_id
+ ' . $this->getOrderString() . ' ' . $queryLimit;
$Data->setQuery($query);
@@ -433,7 +555,7 @@ class AccountSearch
*/
private function analyzeQueryString()
{
- preg_match('/:(user|group|file)\s(.*)/i', $this->txtSearch, $filters);
+ preg_match('/(user|group|file|tag):(.*)/i', $this->txtSearch, $filters);
if (!is_array($filters) || count($filters) === 0) {
return false;
@@ -441,21 +563,26 @@ class AccountSearch
switch ($filters[1]) {
case 'user':
- return array(
+ return [
'account_userId' => UserUtil::getUserIdByLogin(Html::sanitize($filters[2])),
'accuser_userId' => UserUtil::getUserIdByLogin(Html::sanitize($filters[2]))
- );
+ ];
break;
case 'group':
- return array(
+ return [
'account_userGroupId' => Groups::getGroupIdByName(Html::sanitize($filters[2])),
'accgroup_groupId' => Groups::getGroupIdByName(Html::sanitize($filters[2]))
- );
+ ];
break;
case 'file':
- return array(
+ return [
'accfile_name' => Html::sanitize($filters[2])
- );
+ ];
+ break;
+ case 'tag':
+ return [
+ 'tag_name' => Html::sanitize($filters[2])
+ ];
break;
default:
return false;
@@ -532,129 +659,6 @@ class AccountSearch
$this->sortKey = $sortKey;
}
- /**
- * Obtiene el número de cuentas que un usuario puede ver.
- *
- * @return false|int con el número de registros
- */
- public function getAccountMax()
- {
- $Data = new QueryData();
-
- if (!Session::getUserIsAdminApp() && !Session::getUserIsAdminAcc()) {
- $query = 'SELECT COUNT(DISTINCT account_id) as numacc '
- . 'FROM accounts '
- . 'LEFT JOIN accGroups ON account_id = accgroup_accountId '
- . 'WHERE account_userGroupId = :userGroupId '
- . 'OR account_userId = :userId '
- . 'OR accgroup_groupId = :groupId';
-
- $Data->addParam(Session::getUserGroupId(), 'userGroupId');
- $Data->addParam(Session::getUserGroupId(), 'groupId');
- $Data->addParam(Session::getUserId(), 'userId');
- } else {
- $query = "SELECT COUNT(*) as numacc FROM accounts";
- }
-
- $Data->setQuery($query);
-
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false) {
- return false;
- }
-
- return $queryRes->numacc;
- }
-
- /**
- * Procesar los resultados de la búsqueda y crear la variable que contiene los datos de cada cuenta
- * a mostrar.
- *
- * @param &$results array Con los resultados de la búsqueda
- * @return array
- */
- public function processSearchResults(&$results)
- {
- if (!$results){
- return array();
- }
-
- // Variables de configuración
- $maxTextLength = (Checks::resultsCardsIsEnabled()) ? 40 : 60;
-
- $favorites = AccountFavorites::getFavorites(Session::getUserId());
-
- $Account = new Account(new AccountData());
- $accountsData['count'] = AccountSearch::$queryNumRows;
-
- foreach ($results as $account) {
- $Account->getAccountData()->setAccountId($account->account_id);
- $Account->getAccountData()->setAccountUserId($account->account_userId);
- $Account->getAccountData()->setAccountUsersId($Account->getUsersAccount());
- $Account->getAccountData()->setAccountUserGroupId($account->account_userGroupId);
- $Account->getAccountData()->setAccountUserGroupsId($Account->getGroupsAccount());
- $Account->getAccountData()->setAccountOtherUserEdit($account->account_otherUserEdit);
- $Account->getAccountData()->setAccountOtherGroupEdit($account->account_otherGroupEdit);
-
- // Obtener los datos de la cuenta para aplicar las ACL
- $accountAclData = $Account->getAccountDataForACL();
-
- $AccountSearchData = new AccountsSearchData();
- $AccountSearchData->setTextMaxLength($maxTextLength);
- $AccountSearchData->setId($account->account_id);
- $AccountSearchData->setName($account->account_name);
- $AccountSearchData->setLogin($account->account_login);
- $AccountSearchData->setCategoryName($account->category_name);
- $AccountSearchData->setCustomerName($account->customer_name);
- $AccountSearchData->setCustomerLink((AccountsSearchData::$wikiEnabled) ? Config::getConfig()->getWikiSearchurl() . $account->customer_name : '');
- $AccountSearchData->setColor($this->pickAccountColor($account->account_customerId));
- $AccountSearchData->setUrl($account->account_url);
- $AccountSearchData->setFavorite(in_array($account->account_id, $favorites));
- $AccountSearchData->setNumFiles((Checks::fileIsEnabled()) ? $account->num_files : 0);
- $AccountSearchData->setShowView(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_VIEW, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW));
- $AccountSearchData->setShowViewPass(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_VIEW_PASS, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW_PASS));
- $AccountSearchData->setShowEdit(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_EDIT, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_EDIT));
- $AccountSearchData->setShowCopy(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_COPY, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_COPY));
- $AccountSearchData->setShowDelete(Acl::checkAccountAccess(ActionsInterface::ACTION_ACC_DELETE, $accountAclData) && Acl::checkUserAccess(ActionsInterface::ACTION_ACC_DELETE));
-
- // Obtenemos datos si el usuario tiene acceso a los datos de la cuenta
- if ($AccountSearchData->isShow()) {
- $secondaryGroups = Groups::getGroupsNameForAccount($account->account_id);
- $secondaryUsers = UserAccounts::getUsersNameForAccount($account->account_id);
-
- $secondaryAccesses = sprintf('(G) %s*
', $account->usergroup_name);
-
- if ($secondaryGroups) {
- foreach ($secondaryGroups as $group) {
- $secondaryAccesses .= sprintf('(G) %s
', $group);
- }
- }
-
- if ($secondaryUsers) {
- foreach ($secondaryUsers as $user) {
- $secondaryAccesses .= sprintf('(U) %s
', $user);
- }
- }
-
- $AccountSearchData->setAccesses($secondaryAccesses);
-
- $accountNotes = '';
-
- if ($account->account_notes) {
- $accountNotes = (strlen($account->account_notes) > 300) ? substr($account->account_notes, 0, 300) . "..." : $account->account_notes;
- $accountNotes = nl2br(wordwrap(htmlspecialchars($accountNotes), 50, '
', true));
- }
-
- $AccountSearchData->setNotes($accountNotes);
- }
-
- $accountsData[] = $AccountSearchData;
- }
-
- return $accountsData;
- }
-
/**
* Seleccionar un color para la cuenta
*
diff --git a/inc/SP/Account/AccountTags.class.php b/inc/SP/Account/AccountTags.class.php
new file mode 100644
index 00000000..e7df8c14
--- /dev/null
+++ b/inc/SP/Account/AccountTags.class.php
@@ -0,0 +1,122 @@
+.
+ *
+ */
+
+namespace SP\Account;
+
+use SP\Core\SPException;
+use SP\DataModel\AccountData;
+use SP\Storage\DB;
+use SP\Storage\QueryData;
+
+defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
+
+/**
+ * Class AccountTags
+ *
+ * @package SP\Account
+ */
+class AccountTags
+{
+ /**
+ * Devolver las etiquetas de una cuenta
+ *
+ * @param AccountData $accountData
+ * @return array
+ */
+ public static function getTags(AccountData $accountData)
+ {
+ $query = 'SELECT tag_id, tag_name
+ FROM accTags
+ JOIN tags ON tag_id = acctag_tagId
+ WHERE acctag_accountId = :id
+ ORDER BY tag_name';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($accountData->getAccountId(), 'id');
+
+ DB::setReturnArray();
+
+ $tags = [];
+
+ foreach (DB::getResults($Data) as $tag) {
+ $tags[$tag->tag_id] = $tag->tag_name;
+ }
+
+ return $tags;
+ }
+
+ /**
+ * Actualizar las etiquetas de una cuenta
+ *
+ * @param AccountData $accountData
+ * @return bool
+ * @throws SPException
+ */
+ public function addTags(AccountData $accountData)
+ {
+ if (!$this->deleteTags($accountData)) {
+ throw new SPException(SPException::SP_WARNING, _('Error al eliminar las etiquetas de la cuenta'));
+ }
+
+ if (count($accountData->getTags()) === 0){
+ return true;
+ }
+
+ $values = [];
+
+ $Data = new QueryData();
+
+ foreach ($accountData->getTags() as $tag) {
+ $Data->addParam($accountData->getAccountId());
+ $Data->addParam($tag);
+
+ $values[] = '(?, ?)';
+ }
+
+ $query = 'INSERT INTO accTags (acctag_accountId, acctag_tagId) VALUES ' . implode(',', $values);
+
+ $Data->setQuery($query);
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * Eliminar las etiquetas de una cuenta
+ *
+ * @param AccountData $accountData
+ * @return bool
+ */
+ public function deleteTags(AccountData $accountData)
+ {
+ $query = 'DELETE FROM accTags WHERE acctag_accountId = :id';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($accountData->getAccountId(), 'id');
+
+ return DB::getQuery($Data);
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Account/AccountsSearchData.class.php b/inc/SP/Account/AccountsSearchData.class.php
index d116e5e9..a48cae51 100644
--- a/inc/SP/Account/AccountsSearchData.class.php
+++ b/inc/SP/Account/AccountsSearchData.class.php
@@ -53,54 +53,56 @@ class AccountsSearchData
public static $isDemoMode = false;
/** @var int */
- private $_id = 0;
+ private $id = 0;
/** @var string */
- private $_name;
+ private $name;
/** @var string */
- private $_login;
+ private $login;
/** @var string */
- private $_category_name;
+ private $category_name;
/** @var string */
- private $_customer_name;
+ private $customer_name;
/** @var string */
- private $_customer_link;
+ private $customer_link;
/** @var string */
- private $_color;
+ private $color;
/** @var string */
- private $_link;
+ private $link;
/** @var string */
- private $_url;
+ private $url;
/** @var string */
- private $_url_short;
+ private $url_short;
/** @var bool */
- private $_url_islink = false;
+ private $url_islink = false;
/** @var string */
- private $_notes;
+ private $notes;
/** @var string */
- private $_accesses;
+ private $accesses;
/** @var string */
- private $_numFiles;
+ private $numFiles;
/** @var bool */
- private $_favorite = false;
+ private $favorite = false;
/** @var bool */
- private $_showView = false;
+ private $showView = false;
/** @var bool */
- private $_showViewPass = false;
+ private $showViewPass = false;
/** @var bool */
- private $_showEdit = false;
+ private $showEdit = false;
/** @var bool */
- private $_showCopy = false;
+ private $showCopy = false;
/** @var bool */
- private $_showDelete = false;
+ private $showDelete = false;
/** @var int */
- private $_textMaxLength = 60;
+ private $textMaxLength = 60;
+ /** @var array */
+ private $tags =[];
/**
* @return boolean
*/
public function isFavorite()
{
- return $this->_favorite;
+ return $this->favorite;
}
/**
@@ -108,7 +110,7 @@ class AccountsSearchData
*/
public function setFavorite($favorite)
{
- $this->_favorite = $favorite;
+ $this->favorite = $favorite;
}
/**
@@ -125,7 +127,7 @@ class AccountsSearchData
*/
public function isShow()
{
- return ($this->_showView || $this->_showEdit || $this->_showViewPass || $this->_showCopy || $this->_showDelete);
+ return ($this->showView || $this->showEdit || $this->showViewPass || $this->showCopy || $this->showDelete);
}
/**
@@ -141,7 +143,7 @@ class AccountsSearchData
*/
public function isShowViewPass()
{
- return $this->_showViewPass;
+ return $this->showViewPass;
}
/**
@@ -149,7 +151,7 @@ class AccountsSearchData
*/
public function setShowViewPass($showViewPass)
{
- $this->_showViewPass = $showViewPass;
+ $this->showViewPass = $showViewPass;
}
/**
@@ -158,7 +160,7 @@ class AccountsSearchData
public function isShowOptional()
{
return (!AccountsSearchData::$optionalActions
- && ($this->_showEdit || $this->_showViewPass || $this->_showCopy || $this->_showDelete));
+ && ($this->showEdit || $this->showViewPass || $this->showCopy || $this->showDelete));
}
/**
@@ -166,7 +168,7 @@ class AccountsSearchData
*/
public function setTextMaxLength($textMaxLength)
{
- $this->_textMaxLength = $textMaxLength;
+ $this->textMaxLength = $textMaxLength;
}
/**
@@ -174,7 +176,7 @@ class AccountsSearchData
*/
public function getUrlShort()
{
- return $this->_url_short;
+ return $this->url_short;
}
/**
@@ -182,7 +184,7 @@ class AccountsSearchData
*/
public function isUrlIslink()
{
- return $this->_url_islink;
+ return $this->url_islink;
}
/**
@@ -190,7 +192,7 @@ class AccountsSearchData
*/
public function getId()
{
- return $this->_id;
+ return $this->id;
}
/**
@@ -198,7 +200,7 @@ class AccountsSearchData
*/
public function setId($id)
{
- $this->_id = $id;
+ $this->id = $id;
}
/**
@@ -206,7 +208,7 @@ class AccountsSearchData
*/
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/**
@@ -214,7 +216,7 @@ class AccountsSearchData
*/
public function setName($name)
{
- $this->_name = $name;
+ $this->name = $name;
}
/**
@@ -222,7 +224,7 @@ class AccountsSearchData
*/
public function getLogin()
{
- return $this->_login;
+ return $this->login;
}
/**
@@ -230,7 +232,7 @@ class AccountsSearchData
*/
public function setLogin($login)
{
- $this->_login = Html::truncate($login, $this->_textMaxLength);
+ $this->login = Html::truncate($login, $this->textMaxLength);
}
/**
@@ -238,7 +240,7 @@ class AccountsSearchData
*/
public function getCategoryName()
{
- return $this->_category_name;
+ return $this->category_name;
}
/**
@@ -246,7 +248,7 @@ class AccountsSearchData
*/
public function setCategoryName($category_name)
{
- $this->_category_name = $category_name;
+ $this->category_name = $category_name;
}
/**
@@ -254,7 +256,7 @@ class AccountsSearchData
*/
public function getCustomerName()
{
- return $this->_customer_name;
+ return $this->customer_name;
}
/**
@@ -262,7 +264,7 @@ class AccountsSearchData
*/
public function setCustomerName($customer_name)
{
- $this->_customer_name = Html::truncate($customer_name, $this->_textMaxLength);
+ $this->customer_name = Html::truncate($customer_name, $this->textMaxLength);
}
/**
@@ -270,7 +272,7 @@ class AccountsSearchData
*/
public function getCustomerLink()
{
- return $this->_customer_link;
+ return $this->customer_link;
}
/**
@@ -278,7 +280,7 @@ class AccountsSearchData
*/
public function setCustomerLink($customer_link)
{
- $this->_customer_link = $customer_link;
+ $this->customer_link = $customer_link;
}
/**
@@ -286,7 +288,7 @@ class AccountsSearchData
*/
public function getColor()
{
- return $this->_color;
+ return $this->color;
}
/**
@@ -294,7 +296,7 @@ class AccountsSearchData
*/
public function setColor($color)
{
- $this->_color = $color;
+ $this->color = $color;
}
/**
@@ -302,7 +304,7 @@ class AccountsSearchData
*/
public function getLink()
{
- return $this->_link;
+ return $this->link;
}
/**
@@ -310,7 +312,7 @@ class AccountsSearchData
*/
public function setLink($link)
{
- $this->_link = $link;
+ $this->link = $link;
}
/**
@@ -318,7 +320,7 @@ class AccountsSearchData
*/
public function getUrl()
{
- return $this->_url;
+ return $this->url;
}
/**
@@ -326,9 +328,9 @@ class AccountsSearchData
*/
public function setUrl($url)
{
- $this->_url = $url;
- $this->_url_short = Html::truncate($url, $this->_textMaxLength);
- $this->_url_islink = preg_match("#^https?://.*#i", $url);
+ $this->url = $url;
+ $this->url_short = Html::truncate($url, $this->textMaxLength);
+ $this->url_islink = preg_match("#^https?://.*#i", $url);
}
/**
@@ -336,7 +338,7 @@ class AccountsSearchData
*/
public function getNotes()
{
- return $this->_notes;
+ return $this->notes;
}
/**
@@ -344,7 +346,7 @@ class AccountsSearchData
*/
public function setNotes($notes)
{
- $this->_notes = $notes;
+ $this->notes = $notes;
}
/**
@@ -352,7 +354,7 @@ class AccountsSearchData
*/
public function getAccesses()
{
- return $this->_accesses;
+ return $this->accesses;
}
/**
@@ -360,7 +362,7 @@ class AccountsSearchData
*/
public function setAccesses($accesses)
{
- $this->_accesses = $accesses;
+ $this->accesses = $accesses;
}
/**
@@ -368,7 +370,7 @@ class AccountsSearchData
*/
public function getNumFiles()
{
- return $this->_numFiles;
+ return $this->numFiles;
}
/**
@@ -376,7 +378,7 @@ class AccountsSearchData
*/
public function setNumFiles($numFiles)
{
- $this->_numFiles = $numFiles;
+ $this->numFiles = $numFiles;
}
/**
@@ -384,7 +386,7 @@ class AccountsSearchData
*/
public function isShowView()
{
- return $this->_showView;
+ return $this->showView;
}
/**
@@ -392,7 +394,7 @@ class AccountsSearchData
*/
public function setShowView($showView)
{
- $this->_showView = $showView;
+ $this->showView = $showView;
}
/**
@@ -400,7 +402,7 @@ class AccountsSearchData
*/
public function isShowEdit()
{
- return $this->_showEdit;
+ return $this->showEdit;
}
/**
@@ -408,7 +410,7 @@ class AccountsSearchData
*/
public function setShowEdit($showEdit)
{
- $this->_showEdit = $showEdit;
+ $this->showEdit = $showEdit;
}
/**
@@ -416,7 +418,7 @@ class AccountsSearchData
*/
public function isShowCopy()
{
- return $this->_showCopy;
+ return $this->showCopy;
}
/**
@@ -424,7 +426,7 @@ class AccountsSearchData
*/
public function setShowCopy($showCopy)
{
- $this->_showCopy = $showCopy;
+ $this->showCopy = $showCopy;
}
/**
@@ -432,7 +434,7 @@ class AccountsSearchData
*/
public function isShowDelete()
{
- return $this->_showDelete;
+ return $this->showDelete;
}
/**
@@ -440,6 +442,22 @@ class AccountsSearchData
*/
public function setShowDelete($showDelete)
{
- $this->_showDelete = $showDelete;
+ $this->showDelete = $showDelete;
+ }
+
+ /**
+ * @return array
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ /**
+ * @param array $tags
+ */
+ public function setTags($tags)
+ {
+ $this->tags = $tags;
}
}
\ No newline at end of file
diff --git a/inc/SP/Account/GroupAccounts.class.php b/inc/SP/Account/GroupAccounts.class.php
new file mode 100644
index 00000000..720c1815
--- /dev/null
+++ b/inc/SP/Account/GroupAccounts.class.php
@@ -0,0 +1,218 @@
+.
+ *
+ */
+
+namespace SP\Account;
+
+use SP\DataModel\GroupData;
+use SP\Storage\DB;
+use SP\Storage\QueryData;
+
+/**
+ * Class GroupAccounts
+ *
+ * @package SP\Account
+ */
+class GroupAccounts
+{
+
+ /**
+ * Obtiene el listado con el nombre de los grupos de una cuenta.
+ *
+ * @param int $accountId con el Id de la cuenta
+ * @return GroupData[]
+ */
+ public static function getGroupsInfoForAccount($accountId)
+ {
+ $query = 'SELECT usergroup_id,
+ usergroup_name
+ FROM accGroups
+ JOIN usrGroups ON accgroup_groupId = usergroup_id
+ WHERE accgroup_accountId = :id
+ ORDER BY usergroup_name';
+
+ $Data = new QueryData();
+ $Data->setMapClassName('\SP\DataModel\GroupData');
+ $Data->setQuery($query);
+ $Data->addParam($accountId, 'id');
+
+ DB::setReturnArray();
+
+ return DB::getResults($Data);
+ }
+
+ /**
+ * Actualizar la asociación de grupos con cuentas.
+ *
+ * @param int $accountId con el Id de la cuenta
+ * @param array $groupsId con los grupos de la cuenta
+ * @return bool
+ */
+ public static function updateGroupsForAccount($accountId, $groupsId)
+ {
+ if (self::deleteGroupsForAccount($accountId, $groupsId)) {
+ return self::addGroupsForAccount($accountId, $groupsId);
+ }
+
+ return false;
+ }
+
+ /**
+ * Eliminar la asociación de grupos con cuentas.
+ *
+ * @param int $accountId con el Id de la cuenta
+ * @param array $groupsId opcional con los grupos de la cuenta
+ * @return bool
+ */
+ public static function deleteGroupsForAccount($accountId, $groupsId = null)
+ {
+ $queryExcluded = '';
+
+ // Excluimos los grupos actuales
+ if (is_array($groupsId)) {
+ array_map('intval', $groupsId);
+
+ $queryExcluded = 'AND accgroup_groupId NOT IN (' . implode(',', $groupsId) . ')';
+ }
+
+ $query = 'DELETE FROM accGroups WHERE accgroup_accountId = :id ' . $queryExcluded;
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($accountId, 'id');
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * Crear asociación de grupos con cuentas.
+ *
+ * @param int $accountId con el Id de la cuenta
+ * @param array $groupsId con los grupos de la cuenta
+ * @return bool
+ */
+ public static function addGroupsForAccount($accountId, $groupsId)
+ {
+ if (!is_array($groupsId)) {
+ return true;
+ }
+
+ $values = '';
+
+ // Obtenemos los grupos actuales
+ $groupsExcluded = self::getGroupsForAccount($accountId);
+
+ foreach ($groupsId as $groupId) {
+ // Excluimos los grupos actuales
+ if (isset($groupsExcluded) && is_array($groupsExcluded) && in_array($groupId, $groupsExcluded)) {
+ continue;
+ }
+
+ $values[] = '(' . (int)$accountId . ',' . (int)$groupId . ')';
+ }
+
+ if (!is_array($values)) {
+ return true;
+ }
+
+ $query = 'INSERT INTO accGroups (accgroup_accountId, accgroup_groupId) VALUES ' . implode(',', $values);
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * Obtiene el listado de grupos de una cuenta.
+ *
+ * @param int $accountId con el Id de la cuenta
+ * @return false|array con el Id de grupo
+ */
+ public static function getGroupsForAccount($accountId)
+ {
+ $query = 'SELECT accgroup_groupId FROM accGroups WHERE accgroup_accountId = :id';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($accountId, 'id');
+
+ DB::setReturnArray();
+
+ $groups = [];
+
+ foreach (DB::getResults($Data) as $group) {
+ $groups[] = (int)$group->accgroup_groupId;
+ }
+
+ return $groups;
+ }
+
+ /**
+ * Obtener los grupos de usuarios de una búsqueda
+ *
+ * @param $limitCount
+ * @param int $limitStart
+ * @param string $search
+ * @return array
+ */
+ public static function getGroupsMgmtSearch($limitCount, $limitStart = 0, $search = '')
+ {
+ $query = 'SELECT usergroup_id,'
+ . 'usergroup_name,'
+ . 'usergroup_description '
+ . 'FROM usrGroups';
+
+ $Data = new QueryData();
+
+ if (!empty($search)) {
+ $search = '%' . $search . '%';
+ $query .= ' WHERE usergroup_name LIKE ? OR usergroup_description LIKE ?';
+
+ $Data->addParam($search);
+ $Data->addParam($search);
+ }
+
+ $query .= ' ORDER BY usergroup_name';
+ $query .= ' LIMIT ?, ?';
+
+ $Data->addParam($limitStart);
+ $Data->addParam($limitCount);
+
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+ DB::setFullRowCount();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ $queryRes['count'] = DB::$lastNumRows;
+
+ return $queryRes;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Account/UserAccounts.class.php b/inc/SP/Account/UserAccounts.class.php
index 098ffce7..4b877106 100644
--- a/inc/SP/Account/UserAccounts.class.php
+++ b/inc/SP/Account/UserAccounts.class.php
@@ -25,6 +25,7 @@
namespace SP\Account;
+use SP\DataModel\UserBasicData;
use SP\Storage\DB;
use SP\Storage\QueryData;
@@ -134,13 +135,9 @@ class UserAccounts
DB::setReturnArray();
- $queryRes = DB::getResults($Data);
+ $users = [];
- if ($queryRes === false) {
- return array();
- }
-
- foreach ($queryRes as $user) {
+ foreach (DB::getResults($Data) as $user) {
$users[] = (int)$user->accuser_userId;
}
@@ -151,34 +148,25 @@ class UserAccounts
* Obtiene el listado con el nombre de los usuarios de una cuenta.
*
* @param int $accountId con el id de la cuenta
- * @return false|array con los nombres de los usuarios ordenados
+ * @return UserBasicData[]
*/
- public static function getUsersNameForAccount($accountId)
+ public static function getUsersInfoForAccount($accountId)
{
- $query = 'SELECT user_id,'
- . 'user_login '
- . 'FROM accUsers '
- . 'JOIN usrData ON user_Id = accuser_userId '
- . 'WHERE accuser_accountId = :id';
+ $query = 'SELECT user_id,
+ user_login,
+ user_name
+ FROM accUsers
+ JOIN usrData ON user_Id = accuser_userId
+ WHERE accuser_accountId = :id
+ ORDER BY user_login';
$Data = new QueryData();
+ $Data->setMapClassName('SP\DataModel\UserBasicData');
$Data->setQuery($query);
$Data->addParam($accountId, 'id');
DB::setReturnArray();
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false) {
- return false;
- }
-
- foreach ($queryRes as $users) {
- $usersName[$users->user_id] = $users->user_login;
- }
-
- asort($usersName, SORT_STRING);
-
- return $usersName;
+ return DB::getResults($Data);
}
}
\ No newline at end of file
diff --git a/inc/SP/Api/ApiBase.class.php b/inc/SP/Api/ApiBase.class.php
index 29dc1c8d..3bd5c873 100644
--- a/inc/SP/Api/ApiBase.class.php
+++ b/inc/SP/Api/ApiBase.class.php
@@ -32,9 +32,9 @@ use SP\Core\Acl;
use SP\Core\Session;
use SP\Core\SessionUtil;
use SP\Core\SPException;
-use SP\Mgmt\User\User;
-use SP\Mgmt\User\UserPass;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\User;
+use SP\Mgmt\Users\UserPass;
+use SP\Mgmt\Users\UserUtil;
use SP\Util\Json;
/**
diff --git a/inc/SP/Api/ApiTokens.class.php b/inc/SP/Api/ApiTokens.class.php
index 407a6574..1a0ea5df 100644
--- a/inc/SP/Api/ApiTokens.class.php
+++ b/inc/SP/Api/ApiTokens.class.php
@@ -35,7 +35,7 @@ use SP\Html\Html;
use SP\Log\Log;
use SP\Core\Session;
use SP\Core\SPException;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\QueryData;
/**
diff --git a/inc/SP/Api/SyspassApi.class.php b/inc/SP/Api/SyspassApi.class.php
index 29c9c5bd..2de5a4ec 100644
--- a/inc/SP/Api/SyspassApi.class.php
+++ b/inc/SP/Api/SyspassApi.class.php
@@ -26,7 +26,7 @@
namespace SP\Api;
use SP\Account\Account;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Account\AccountSearch;
use SP\Core\Acl;
use SP\Core\ActionsInterface;
diff --git a/inc/SP/Auth/Auth.class.php b/inc/SP/Auth/Auth.class.php
index 3e5af755..653877c7 100644
--- a/inc/SP/Auth/Auth.class.php
+++ b/inc/SP/Auth/Auth.class.php
@@ -32,10 +32,10 @@ use SP\Log\Email;
use SP\Html\Html;
use SP\Core\Init;
use SP\Log\Log;
-use SP\Mgmt\User\UserLdap;
-use SP\Mgmt\User\UserMigrate;
-use SP\Mgmt\User\UserPassRecover;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserLdap;
+use SP\Mgmt\Users\UserMigrate;
+use SP\Mgmt\Users\UserPassRecover;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\QueryData;
use SP\Util\Checks;
use SP\Util\Util;
diff --git a/inc/SP/Auth/Auth2FA.class.php b/inc/SP/Auth/Auth2FA.class.php
index 4ac1fe31..3a5736ac 100644
--- a/inc/SP/Auth/Auth2FA.class.php
+++ b/inc/SP/Auth/Auth2FA.class.php
@@ -28,7 +28,7 @@ namespace SP\Auth;
use Exts\Google2FA;
use Exts\Base2n;
use SP\Core\SPException;
-use SP\Mgmt\User\UserPass;
+use SP\Mgmt\Users\UserPass;
use SP\Util\Util;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Config/ConfigData.class.php b/inc/SP/Config/ConfigData.class.php
index 70ce8fb2..eb0b751f 100644
--- a/inc/SP/Config/ConfigData.class.php
+++ b/inc/SP/Config/ConfigData.class.php
@@ -1316,7 +1316,7 @@ class ConfigData implements JsonSerializable
*/
public function getWikiFilter()
{
- return is_array($this->wikiFilter) ? $this->wikiFilter : array();
+ return is_array($this->wikiFilter) ? $this->wikiFilter : [];
}
/**
diff --git a/inc/SP/Controller/AccItemMgmt.class.php b/inc/SP/Controller/AccItemMgmt.class.php
index ab6400de..fc522fdd 100644
--- a/inc/SP/Controller/AccItemMgmt.class.php
+++ b/inc/SP/Controller/AccItemMgmt.class.php
@@ -33,12 +33,12 @@ use SP\Core\Session;
use SP\Core\SessionUtil;
use SP\Core\Template;
use SP\Log\Log;
-use SP\Mgmt\CustomFields;
-use SP\Mgmt\PublicLinkUtil;
-use SP\Mgmt\User\Groups;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\ProfileUtil;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\CustomFields\CustomFields;
+use SP\Mgmt\PublicLinks\PublicLinkUtil;
+use SP\Mgmt\Groups\Groups;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Profiles\ProfileUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\DBUtil;
use SP\Util\Checks;
diff --git a/inc/SP/Controller/AccItemsMgmt.class.php b/inc/SP/Controller/AccItemsMgmt.class.php
index 2e73b447..3bfac197 100644
--- a/inc/SP/Controller/AccItemsMgmt.class.php
+++ b/inc/SP/Controller/AccItemsMgmt.class.php
@@ -27,14 +27,15 @@ namespace SP\Controller;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
+use SP\Account\GroupAccounts;
use SP\Api\ApiTokensUtil;
use SP\Config\Config;
use SP\Core\ActionsInterface;
-use SP\Mgmt\PublicLinkUtil;
-use SP\Mgmt\User\Groups;
+use SP\Mgmt\PublicLinks\PublicLinkUtil;
+use SP\Mgmt\Groups\Groups;
use SP\Core\Template;
-use SP\Mgmt\User\ProfileUtil;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Profiles\ProfileUtil;
+use SP\Mgmt\Users\UserUtil;
/**
* Clase encargada de de preparar la presentación de las vistas de gestión de accesos
@@ -91,7 +92,7 @@ class AccItemsMgmt extends GridTabController implements ActionsInterface
}
$Grid = $this->Grids->getGroupsGrid();
- $Grid->getData()->setData(Groups::getGroupsMgmtSearch($this->_limitCount));
+ $Grid->getData()->setData(GroupAccounts::getGroupsMgmtSearch($this->_limitCount));
$Grid->updatePager();
$Grid->getPager()->setOnClickArgs($this->_limitCount);
diff --git a/inc/SP/Controller/AccItemsMgmtSearch.class.php b/inc/SP/Controller/AccItemsMgmtSearch.class.php
index b65601a8..3b22f117 100644
--- a/inc/SP/Controller/AccItemsMgmtSearch.class.php
+++ b/inc/SP/Controller/AccItemsMgmtSearch.class.php
@@ -27,12 +27,13 @@ namespace SP\Controller;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
+use SP\Account\GroupAccounts;
use SP\Api\ApiTokensUtil;
use SP\Core\ActionsInterface;
-use SP\Mgmt\PublicLinkUtil;
-use SP\Mgmt\User\Groups;
-use SP\Mgmt\User\ProfileUtil;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\PublicLinks\PublicLinkUtil;
+use SP\Mgmt\Groups\Groups;
+use SP\Mgmt\Profiles\ProfileUtil;
+use SP\Mgmt\Users\UserUtil;
/**
* Class AccItemsMgmtSearch para la gestión de búsquedas de items de accesos
@@ -86,7 +87,7 @@ class AccItemsMgmtSearch extends GridItemsSearch implements ActionsInterface
$this->view->addTemplate('datagrid-rows');
$Grid = $this->_grids->getGroupsGrid();
- $Grid->getData()->setData(Groups::getGroupsMgmtSearch($limitCount, $limitStart, $search));
+ $Grid->getData()->setData(GroupAccounts::getGroupsMgmtSearch($limitCount, $limitStart, $search));
$Grid->updatePager();
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
diff --git a/inc/SP/Controller/Account.class.php b/inc/SP/Controller/Account.class.php
index 40f282f4..7c5a9786 100644
--- a/inc/SP/Controller/Account.class.php
+++ b/inc/SP/Controller/Account.class.php
@@ -27,25 +27,28 @@ namespace SP\Controller;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
-use SP\Account\AccountData;
-use SP\Account\AccountHistory;
+use SP\Account\GroupAccounts;
+use SP\DataModel\AccountData;
use SP\Core\Acl;
use SP\Config\Config;
use SP\Core\ActionsInterface;
use SP\Core\Crypt;
use SP\Core\Init;
use SP\Core\Template;
-use SP\Mgmt\PublicLink;
-use SP\Mgmt\CustomFields;
-use SP\Mgmt\User\Groups;
+use SP\Mgmt\Groups\GroupsUtil;
+use SP\Mgmt\PublicLinks\PublicLink;
+use SP\Mgmt\CustomFields\CustomFields;
+use SP\Mgmt\Tags\Tags;
use SP\Core\Session;
use SP\Core\SessionUtil;
use SP\Core\SPException;
use SP\Account\UserAccounts;
-use SP\Mgmt\User\UserPass;
+use SP\Mgmt\Users\UserPass;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\DBUtil;
use SP\Util\Checks;
use SP\Util\ImageUtil;
+use SP\Util\Json;
/**
* Clase encargada de preparar la presentación de las vistas de una cuenta
@@ -59,7 +62,7 @@ class Account extends Controller implements ActionsInterface
*/
protected $action;
/**
- * @var Account|AccountHistory instancia para el manejo de datos de una cuenta
+ * @var \SP\Account\Account|\SP\Account\AccountHistory instancia para el manejo de datos de una cuenta
*/
private $account;
/**
@@ -166,10 +169,10 @@ class Account extends Controller implements ActionsInterface
if ($this->isGotData()) {
$this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory());
- $this->view->assign('accountOtherUsers', $this->getAccount()->getAccountData()->getAccountUsersId());
- $this->view->assign('accountOtherUsersName', UserAccounts::getUsersNameForAccount($this->getId()));
- $this->view->assign('accountOtherGroups', $this->getAccount()->getAccountData()->getAccountUserGroupsId());
- $this->view->assign('accountOtherGroupsName', \SP\Mgmt\User\Groups::getGroupsNameForAccount($this->getId()));
+ $this->view->assign('accountOtherUsers', UserAccounts::getUsersInfoForAccount($this->getId()));
+ $this->view->assign('accountOtherGroups', GroupAccounts::getGroupsInfoForAccount($this->getId()));
+ $this->view->assign('accountTags', $this->getAccount()->getAccountData()->getTags());
+ $this->view->assign('accountTagsJson', Json::getJson(array_keys($this->getAccount()->getAccountData()->getTags())));
$this->view->assign('changesHash', $this->getAccount()->getAccountModHash());
$this->view->assign('chkUserEdit', ($this->getAccount()->getAccountData()->getAccountOtherUserEdit()) ? 'checked' : '');
$this->view->assign('chkGroupEdit', ($this->getAccount()->getAccountData()->getAccountOtherGroupEdit()) ? 'checked' : '');
@@ -186,10 +189,11 @@ class Account extends Controller implements ActionsInterface
$this->view->assign('accountParentId', Session::getLastAcountId());
$this->view->assign('categories', DBUtil::getValuesForSelect('categories', 'category_id', 'category_name'));
$this->view->assign('customers', DBUtil::getValuesForSelect('customers', 'customer_id', 'customer_name'));
- $this->view->assign('otherUsers', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
- $this->view->assign('otherGroups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
-
-
+ $this->view->assign('otherUsers', UserUtil::getUsersLogin());
+ $this->view->assign('otherUsersJson', Json::getJson($this->view->otherUsers));
+ $this->view->assign('otherGroups', GroupsUtil::getGroupsName());
+ $this->view->assign('otherGroupsJson', Json::getJson($this->view->otherGroups));
+ $this->view->assign('tagsJson', Json::getJson(Tags::getTags()));
}
/**
@@ -217,7 +221,7 @@ class Account extends Controller implements ActionsInterface
}
/**
- * @return Account|AccountHistory
+ * @return \SP\Account\Account|\SP\Account\AccountHistory
*/
private function getAccount()
{
@@ -302,7 +306,6 @@ class Account extends Controller implements ActionsInterface
$this->view->assign('accountData', $this->getAccount()->getData());
$this->view->assign('gotData', true);
-// $this->setAccountDetails();
$this->setGotData(true);
Session::setLastAcountId($this->getId());
@@ -460,7 +463,6 @@ class Account extends Controller implements ActionsInterface
$this->view->assign('accountData', $this->getAccount()->getData());
$this->view->assign('gotData', true);
-// $this->setAccountDetails();
$this->setGotData(true);
Session::setLastAcountId(Session::getAccountParentId());
@@ -510,7 +512,7 @@ class Account extends Controller implements ActionsInterface
/**
* Obtener la vista de detalles de cuenta para enlaces públicos
*
- * @param PublicLink $PublicLink
+ * @param \SP\Mgmt\PublicLinks\PublicLink $PublicLink
* @return bool
*/
public function getAccountFromLink(PublicLink $PublicLink)
@@ -545,13 +547,4 @@ class Account extends Controller implements ActionsInterface
$this->view->assign('accountPass', $accountPass);
}
-
- /**
- * Establecer variables que contienen la información detallada de la cuenta.
- */
- private function setAccountDetails()
- {
- $this->account->getAccountData()->setAccountUsersId(UserAccounts::getUsersForAccount($this->getId()));
- $this->account->getAccountData()->setAccountUserGroupsId(Groups::getGroupsForAccount($this->getId()));
- }
}
\ No newline at end of file
diff --git a/inc/SP/Controller/AccountsSearch.class.php b/inc/SP/Controller/AccountsSearch.class.php
index a66a12c3..1236e2f2 100644
--- a/inc/SP/Controller/AccountsSearch.class.php
+++ b/inc/SP/Controller/AccountsSearch.class.php
@@ -167,8 +167,6 @@ class AccountsSearch extends Controller implements ActionsInterface
$Search->setCustomerId($this->view->searchCustomer);
$Search->setSearchFavorites($this->view->searchFavorites);
- $resQuery = $Search->getAccounts();
-
$this->filterOn = ($this->_sortKey > 1
|| $this->view->searchCustomer
|| $this->view->searchCategory
@@ -185,12 +183,16 @@ class AccountsSearch extends Controller implements ActionsInterface
AccountsSearchData::$isDemoMode = Checks::demoIsEnabled();
if (AccountsSearchData::$wikiEnabled) {
- $this->view->assign('wikiFilter', implode('|', Config::getConfig()->getWikiFilter()));
+ $wikiFilter = array_map(function ($value) {
+ return preg_quote($value);
+ }, Config::getConfig()->getWikiFilter());
+
+ $this->view->assign('wikiFilter', implode('|', $wikiFilter));
$this->view->assign('wikiPageUrl', Config::getConfig()->getWikiPageurl());
}
$Grid = $this->getGrid();
- $Grid->getData()->setData($Search->processSearchResults($resQuery));
+ $Grid->getData()->setData($Search->processSearchResults());
$Grid->updatePager();
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
diff --git a/inc/SP/Controller/AppItemMgmt.class.php b/inc/SP/Controller/AppItemMgmt.class.php
index 3b16ee44..f6a7b23f 100644
--- a/inc/SP/Controller/AppItemMgmt.class.php
+++ b/inc/SP/Controller/AppItemMgmt.class.php
@@ -30,12 +30,14 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
use SP\Core\ActionsInterface;
use SP\Core\Template;
use SP\Http\Request;
-use SP\Mgmt\Category;
-use SP\Mgmt\Customer;
-use SP\Mgmt\CustomFieldDef;
-use SP\Mgmt\CustomFields;
+use SP\Mgmt\Categories\Category;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\CustomFields\CustomFieldDef;
+use SP\Mgmt\CustomFields\CustomFields;
use SP\Core\SessionUtil;
-use SP\Mgmt\Files;
+use SP\Mgmt\Files\Files;
+use SP\DataModel\TagData;
+use SP\Mgmt\Tags\Tags;
use SP\Util\Checks;
use SP\Util\Util;
@@ -132,7 +134,7 @@ class AppItemMgmt extends Controller implements ActionsInterface
$field = (is_object($customField)) ? unserialize($customField->customfielddef_field) : null;
if (is_object($field) && get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFields\CustomFieldDef', $field);
}
$this->view->assign('gotData', ($customField && $field instanceof CustomFieldDef));
@@ -141,4 +143,16 @@ class AppItemMgmt extends Controller implements ActionsInterface
$this->view->assign('types', CustomFieldDef::getFieldsTypes());
$this->view->assign('modules', CustomFieldDef::getFieldsModules());
}
+
+ /**
+ * Obtener los datos para la ficha de categoría
+ */
+ public function getTag()
+ {
+ $this->_module = self::ACTION_MGM_TAGS;
+ $this->view->addTemplate('tags');
+
+ $Tag = new Tags();
+ $this->view->assign('tag', $Tag->getTag(new TagData($this->view->itemId)));
+ }
}
diff --git a/inc/SP/Controller/AppItemsMgmt.class.php b/inc/SP/Controller/AppItemsMgmt.class.php
index da6e9af9..5538b79e 100644
--- a/inc/SP/Controller/AppItemsMgmt.class.php
+++ b/inc/SP/Controller/AppItemsMgmt.class.php
@@ -32,11 +32,12 @@ use SP\Config\Config;
use SP\Core\ActionsInterface;
use SP\Core\Template;
use SP\Http\Request;
-use SP\Mgmt\Category;
-use SP\Mgmt\Customer;
-use SP\Mgmt\CustomFieldDef;
+use SP\Mgmt\Categories\Category;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\CustomFields\CustomFieldDef;
use SP\Core\SessionUtil;
-use SP\Mgmt\Files;
+use SP\Mgmt\Files\Files;
+use SP\Mgmt\Tags\Tags;
/**
* Clase encargada de preparar la presentación de las vistas de gestión de cuentas
@@ -177,4 +178,23 @@ class AppItemsMgmt extends GridTabController implements ActionsInterface
$this->view->append('tabs', $Grid);
}
+
+ /**
+ * Obtener los datos para la pestaña de etiquetas
+ */
+ public function getTags()
+ {
+ $this->setAction(self::ACTION_MGM_TAGS);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $Grid = $this->Grids->getTagsGrid();
+ $Grid->getData()->setData(Tags::getTagsMgmtSearch($this->limitCount));
+ $Grid->updatePager();
+ $Grid->getPager()->setOnClickArgs($this->limitCount);
+
+ $this->view->append('tabs', $Grid);
+ }
}
diff --git a/inc/SP/Controller/AppItemsMgmtSearch.class.php b/inc/SP/Controller/AppItemsMgmtSearch.class.php
index 50ccc8ec..cf933885 100644
--- a/inc/SP/Controller/AppItemsMgmtSearch.class.php
+++ b/inc/SP/Controller/AppItemsMgmtSearch.class.php
@@ -29,10 +29,11 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
use SP\Account\AccountUtil;
use SP\Core\ActionsInterface;
-use SP\Mgmt\Category;
-use SP\Mgmt\Customer;
-use SP\Mgmt\CustomFieldDef;
-use SP\Mgmt\Files;
+use SP\Mgmt\Categories\Category;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\CustomFields\CustomFieldDef;
+use SP\Mgmt\Files\Files;
+use SP\Mgmt\Tags\Tags;
/**
* Class ItemsMgmt para las buśquedas en los listados de elementos de gestión
@@ -175,4 +176,31 @@ class AppItemsMgmtSearch extends GridItemsSearch implements ActionsInterface
$this->view->assign('data', $Grid);
$this->view->assign('actionId', self::ACTION_MGM);
}
+
+ /**
+ * Obtener las etiquetas de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @param int $limitStart
+ * @param int $limitCount
+ */
+ public function getTags($search, $limitStart, $limitCount)
+ {
+ $this->setAction(self::ACTION_MGM_TAGS_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $Grid = $this->_grids->getTagsGrid();
+ $Grid->getData()->setData(Tags::getTagsMgmtSearch($limitCount, $limitStart, $search));
+ $Grid->updatePager();
+
+ $this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
+
+ $this->view->assign('data', $Grid);
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
}
diff --git a/inc/SP/Controller/ConfigMgmt.class.php b/inc/SP/Controller/ConfigMgmt.class.php
index e6939e03..1077557b 100644
--- a/inc/SP/Controller/ConfigMgmt.class.php
+++ b/inc/SP/Controller/ConfigMgmt.class.php
@@ -328,7 +328,7 @@ class ConfigMgmt extends Controller implements ActionsInterface
$this->view->assign('mailPass', $this->Config->getMailPass());
$this->view->assign('currentMailSecurity', $this->Config->getMailSecurity());
$this->view->assign('mailFrom', $this->Config->getMailFrom());
- $this->view->assign('mailSecurity', array('SSL', 'TLS'));
+ $this->view->assign('mailSecurity', ['SSL', 'TLS']);
$this->view->assign('actionId', $this->getAction(), 'mail');
$this->view->append('tabs', array('title' => _('Correo')));
diff --git a/inc/SP/Controller/Grids.class.php b/inc/SP/Controller/Grids.class.php
index 32df6a16..1473dfbb 100644
--- a/inc/SP/Controller/Grids.class.php
+++ b/inc/SP/Controller/Grids.class.php
@@ -853,6 +853,78 @@ class Grids implements ActionsInterface
return $Grid;
}
+
+ /**
+ * @return DataGridTab
+ */
+ public function getTagsGrid()
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_TAGS_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchTag');
+ $GridActionSearch->setTitle(_('Buscar Etiqueta'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+
+ $GridActionNew = new DataGridAction();
+ $GridActionNew->setId(self::ACTION_MGM_TAGS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
+ $GridActionNew->setName(_('Nueva Etiqueta'));
+ $GridActionNew->setTitle(_('Nueva Etiqueta'));
+ $GridActionNew->setIcon($this->icons->getIconAdd());
+ $GridActionNew->setSkip(true);
+ $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
+ $GridActionNew->setOnClickArgs('this');
+ $GridActionNew->setOnClickArgs(self::ACTION_MGM_TAGS_NEW);
+ $GridActionNew->setOnClickArgs($this->sk);
+
+ $GridActionEdit = new DataGridAction();
+ $GridActionEdit->setId(self::ACTION_MGM_TAGS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
+ $GridActionEdit->setName(_('Editar Etiqueta'));
+ $GridActionEdit->setTitle(_('Editar Etiqueta'));
+ $GridActionEdit->setIcon($this->icons->getIconEdit());
+ $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
+ $GridActionEdit->setOnClickArgs('this');
+ $GridActionEdit->setOnClickArgs(self::ACTION_MGM_TAGS_EDIT);
+ $GridActionEdit->setOnClickArgs($this->sk);
+
+ $GridActionDel = new DataGridAction();
+ $GridActionDel->setId(self::ACTION_MGM_TAGS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
+ $GridActionDel->setName(_('Eliminar Etiqueta'));
+ $GridActionDel->setTitle(_('Eliminar Etiqueta'));
+ $GridActionDel->setIcon($this->icons->getIconDelete());
+ $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
+ $GridActionDel->setOnClickArgs('this');
+ $GridActionDel->setOnClickArgs(self::ACTION_MGM_TAGS_DELETE);
+ $GridActionDel->setOnClickArgs($this->sk);
+
+ $GridHeaders = new DataGridHeader();
+ $GridHeaders->addHeader(_('Nombre'));
+
+ $GridData = new DataGridData();
+ $GridData->setDataRowSourceId('tag_id');
+ $GridData->addDataRowSource('tag_name');
+
+ $Grid = new DataGridTab();
+ $Grid->setId('tblTags');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
+ $Grid->setDataActions($GridActionSearch);
+ $Grid->setDataActions($GridActionNew);
+ $Grid->setDataActions($GridActionEdit);
+ $Grid->setDataActions($GridActionDel);
+ $Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridActionSearch));
+ $Grid->setData($GridData);
+ $Grid->setTitle(_('Gestión de Etiquetas'));
+ $Grid->setTime(round(microtime() - $this->queryTimeStart, 5));
+
+ return $Grid;
+ }
+
/**
* @param boolean $filter
*/
diff --git a/inc/SP/Controller/Main.class.php b/inc/SP/Controller/Main.class.php
index ceeb019b..9d9defe6 100644
--- a/inc/SP/Controller/Main.class.php
+++ b/inc/SP/Controller/Main.class.php
@@ -32,7 +32,7 @@ use SP\Core\Init;
use SP\Core\Installer;
use SP\Core\Template;
use SP\Html\Html;
-use SP\Mgmt\PublicLink;
+use SP\Mgmt\PublicLinks\PublicLink;
use SP\Http\Request;
use SP\Core\Session;
use SP\Core\SessionUtil;
diff --git a/inc/SP/Controller/UsersPrefs.class.php b/inc/SP/Controller/UsersPrefs.class.php
index 71963477..92244bf2 100644
--- a/inc/SP/Controller/UsersPrefs.class.php
+++ b/inc/SP/Controller/UsersPrefs.class.php
@@ -34,7 +34,7 @@ use SP\Core\Language;
use SP\Core\Session;
use SP\Core\SessionUtil;
use SP\Core\Themes;
-use SP\Mgmt\User\UserPreferences;
+use SP\Mgmt\Users\UserPreferences;
/**
diff --git a/inc/SP/Core/Acl.class.php b/inc/SP/Core/Acl.class.php
index 3e5b27f6..b9676fd4 100644
--- a/inc/SP/Core/Acl.class.php
+++ b/inc/SP/Core/Acl.class.php
@@ -26,9 +26,9 @@
namespace SP\Core;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Controller;
-use SP\Mgmt\User\Groups;
+use SP\Mgmt\Groups\Groups;
use SP\Log\Log;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/ActionsInterface.class.php b/inc/SP/Core/ActionsInterface.class.php
index a5428d5c..77bf0d74 100644
--- a/inc/SP/Core/ActionsInterface.class.php
+++ b/inc/SP/Core/ActionsInterface.class.php
@@ -30,7 +30,8 @@ namespace SP\Core;
*
* @package Controller
*/
-interface ActionsInterface {
+interface ActionsInterface
+{
const ACTION_ACC_SEARCH = 1;
const ACTION_ACC = 10;
const ACTION_ACC_VIEW = 100;
@@ -96,9 +97,15 @@ interface ActionsInterface {
const ACTION_MGM_ACCOUNTS_VIEW = 671;
const ACTION_MGM_ACCOUNTS_DELETE = 673;
const ACTION_MGM_ACCOUNTS_SEARCH = 675;
+ const ACTION_MGM_TAGS = 68;
+ const ACTION_MGM_TAGS_NEW = 680;
+ const ACTION_MGM_TAGS_VIEW = 681;
+ const ACTION_MGM_TAGS_EDIT = 682;
+ const ACTION_MGM_TAGS_DELETE = 683;
+ const ACTION_MGM_TAGS_SEARCH = 685;
const ACTION_USR = 70;
const ACTION_USR_USERS = 71;
- const ACTION_USR_USERS_VIEW= 710;
+ const ACTION_USR_USERS_VIEW = 710;
const ACTION_USR_USERS_NEW = 711;
const ACTION_USR_USERS_EDIT = 712;
const ACTION_USR_USERS_DELETE = 713;
diff --git a/inc/SP/Core/Init.class.php b/inc/SP/Core/Init.class.php
index 8791673d..cafc8583 100644
--- a/inc/SP/Core/Init.class.php
+++ b/inc/SP/Core/Init.class.php
@@ -32,7 +32,7 @@ use SP\Controller;
use SP\Http\Request;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Mgmt\User\ProfileUtil;
+use SP\Mgmt\Profiles\ProfileUtil;
use SP\Storage\DBUtil;
use SP\Util\Checks;
use SP\Util\Util;
diff --git a/inc/SP/Core/Installer.class.php b/inc/SP/Core/Installer.class.php
index 987b1bef..f02e12c4 100644
--- a/inc/SP/Core/Installer.class.php
+++ b/inc/SP/Core/Installer.class.php
@@ -30,9 +30,9 @@ use PDO;
use PDOException;
use SP\Config\Config;
use SP\Config\ConfigDB;
-use SP\Mgmt\User\Groups;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\User;
+use SP\Mgmt\Groups\Groups;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Users\User;
use SP\Util\Util;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/Language.class.php b/inc/SP/Core/Language.class.php
index da2e564b..9a37ec87 100644
--- a/inc/SP/Core/Language.class.php
+++ b/inc/SP/Core/Language.class.php
@@ -26,7 +26,7 @@
namespace SP\Core;
use SP\Config\Config;
-use SP\Mgmt\User\UserPreferences;
+use SP\Mgmt\Users\UserPreferences;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/Session.class.php b/inc/SP/Core/Session.class.php
index 6a5f294d..8cf64e59 100644
--- a/inc/SP/Core/Session.class.php
+++ b/inc/SP/Core/Session.class.php
@@ -28,8 +28,8 @@ namespace SP\Core;
use SP\Account;
use SP\Config\ConfigData;
use SP\Mgmt;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\UserPreferences;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Users\UserPreferences;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
@@ -287,9 +287,9 @@ class Session
/**
* Establece el objeto de perfil de usuario en la sesión.
*
- * @param \SP\Mgmt\User\Profile $profile
+ * @param \SP\Mgmt\Profiles\Profile $profile
*/
- public static function setUserProfile(Mgmt\User\Profile $profile)
+ public static function setUserProfile(Mgmt\Profiles\Profile $profile)
{
self::setSessionKey('usrprofile', $profile);
}
@@ -643,9 +643,9 @@ class Session
/**
* Establece el objeto de preferencias de usuario en la sesión.
*
- * @param \SP\Mgmt\User\UserPreferences $preferences
+ * @param \SP\Mgmt\Users\UserPreferences $preferences
*/
- public static function setUserPreferences(Mgmt\User\UserPreferences $preferences)
+ public static function setUserPreferences(Mgmt\Users\UserPreferences $preferences)
{
self::setSessionKey('userpreferences', $preferences);
}
diff --git a/inc/SP/Core/SessionUtil.class.php b/inc/SP/Core/SessionUtil.class.php
index d8ad3b93..96c2b81a 100644
--- a/inc/SP/Core/SessionUtil.class.php
+++ b/inc/SP/Core/SessionUtil.class.php
@@ -25,9 +25,9 @@
namespace SP\Core;
-use SP\Mgmt\User\Profile;
-use SP\Mgmt\User\ProfileUtil;
-use SP\Mgmt\User\User;
+use SP\Mgmt\Profiles\Profile;
+use SP\Mgmt\Profiles\ProfileUtil;
+use SP\Mgmt\Users\User;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/Themes.class.php b/inc/SP/Core/Themes.class.php
index 87098443..fc5fdb0f 100644
--- a/inc/SP/Core/Themes.class.php
+++ b/inc/SP/Core/Themes.class.php
@@ -26,7 +26,7 @@
namespace SP\Core;
use SP\Config\Config;
-use SP\Mgmt\User\UserPreferences;
+use SP\Mgmt\Users\UserPreferences;
use Theme\Icons;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/Upgrade.class.php b/inc/SP/Core/Upgrade.class.php
index 021a1e68..4e7580aa 100644
--- a/inc/SP/Core/Upgrade.class.php
+++ b/inc/SP/Core/Upgrade.class.php
@@ -30,9 +30,9 @@ use SP\Config\Config;
use SP\Config\ConfigData;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Mgmt\User\Profile;
+use SP\Mgmt\Profiles\Profile;
use SP\Storage\DB;
-use SP\Mgmt\User\UserMigrate;
+use SP\Mgmt\Users\UserMigrate;
use SP\Storage\QueryData;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Core/XmlExport.class.php b/inc/SP/Core/XmlExport.class.php
index c86b14be..250ff34b 100644
--- a/inc/SP/Core/XmlExport.class.php
+++ b/inc/SP/Core/XmlExport.class.php
@@ -28,9 +28,9 @@ namespace SP\Core;
use SP\Account\AccountUtil;
use SP\Config\Config;
use SP\Log\Email;
-use SP\Mgmt\Customer;
+use SP\Mgmt\Customers\Customer;
use SP\Log\Log;
-use SP\Mgmt\Category;
+use SP\Mgmt\Categories\Category;
use SP\Util\Util;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Account/AccountData.class.php b/inc/SP/DataModel/AccountData.class.php
similarity index 96%
rename from inc/SP/Account/AccountData.class.php
rename to inc/SP/DataModel/AccountData.class.php
index f99c624f..3661be45 100644
--- a/inc/SP/Account/AccountData.class.php
+++ b/inc/SP/DataModel/AccountData.class.php
@@ -23,7 +23,8 @@
*
*/
-namespace SP\Account;
+namespace SP\DataModel;
+
use JsonSerializable;
use SP\Util\Json;
@@ -114,6 +115,10 @@ class AccountData implements JsonSerializable
* @var bool
*/
private $isDeleted = false;
+ /**
+ * @var array
+ */
+ private $tags = [];
/**
* AccountData constructor.
@@ -462,4 +467,20 @@ class AccountData implements JsonSerializable
return Json::safeJson($data);
}
+
+ /**
+ * @return array
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ /**
+ * @param array $tags
+ */
+ public function setTags(array $tags)
+ {
+ $this->tags = $tags;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/DataModel/GroupData.class.php b/inc/SP/DataModel/GroupData.class.php
new file mode 100644
index 00000000..88c58f9e
--- /dev/null
+++ b/inc/SP/DataModel/GroupData.class.php
@@ -0,0 +1,71 @@
+.
+ *
+ */
+
+namespace SP\DataModel;
+
+/**
+ * Class GroupData
+ *
+ * @package SP\DataModel
+ */
+class GroupData
+{
+ /**
+ * @var int
+ */
+ public $usergroup_id = 0;
+ /**
+ * @var string
+ */
+ public $usergroup_name = '';
+ /**
+ * @var string
+ */
+ public $usergroup_description = '';
+
+ /**
+ * @return int
+ */
+ public function getUsergroupId()
+ {
+ return $this->usergroup_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUsergroupName()
+ {
+ return $this->usergroup_name;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUsergroupDescription()
+ {
+ return $this->usergroup_description;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/DataModel/TagData.class.php b/inc/SP/DataModel/TagData.class.php
new file mode 100644
index 00000000..d00220d5
--- /dev/null
+++ b/inc/SP/DataModel/TagData.class.php
@@ -0,0 +1,109 @@
+.
+ *
+ */
+
+namespace SP\DataModel;
+
+defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
+
+/**
+ * Class TagData
+ *
+ * @package SP\Mgmt\Tags
+ */
+class TagData
+{
+ /**
+ * @var int
+ */
+ public $tag_id = 0;
+ /**
+ * @var string
+ */
+ public $tag_name = '';
+ /**
+ * @var string
+ */
+ public $tag_hash = '';
+
+ /**
+ * TagData constructor.
+ *
+ * @param int $tag_id
+ * @param string $tag_name
+ */
+ public function __construct($tag_id = 0, $tag_name = '')
+ {
+ $this->tag_id = $tag_id;
+ $this->tag_name = $tag_name;
+ }
+
+ /**
+ * @return int
+ */
+ public function getTagId()
+ {
+ return $this->tag_id;
+ }
+
+ /**
+ * @param int $tag_id
+ */
+ public function setTagId($tag_id)
+ {
+ $this->tag_id = $tag_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTagName()
+ {
+ return $this->tag_name;
+ }
+
+ /**
+ * @param string $tag_name
+ */
+ public function setTagName($tag_name)
+ {
+ $this->tag_name = $tag_name;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTagHash()
+ {
+ return $this->tag_hash;
+ }
+
+ /**
+ * @param string $tag_hash
+ */
+ public function setTagHash($tag_hash)
+ {
+ $this->tag_hash = $tag_hash;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/DataModel/UserBasicData.class.php b/inc/SP/DataModel/UserBasicData.class.php
new file mode 100644
index 00000000..a5ebaf73
--- /dev/null
+++ b/inc/SP/DataModel/UserBasicData.class.php
@@ -0,0 +1,71 @@
+.
+ *
+ */
+
+namespace SP\DataModel;
+
+/**
+ * Class UserBasicData
+ *
+ * @package SP\DataModel
+ */
+class UserBasicData
+{
+ /**
+ * @var int
+ */
+ public $user_id = 0;
+ /**
+ * @var string
+ */
+ public $user_login = '';
+ /**
+ * @var string
+ */
+ public $user_name = '';
+
+ /**
+ * @return int
+ */
+ public function getUserId()
+ {
+ return $this->user_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUserLogin()
+ {
+ return $this->user_login;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUserName()
+ {
+ return $this->user_name;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Html/Minify.class.php b/inc/SP/Html/Minify.class.php
index 50ceff09..f306c49b 100644
--- a/inc/SP/Html/Minify.class.php
+++ b/inc/SP/Html/Minify.class.php
@@ -78,7 +78,7 @@ class Minify
* Método que devuelve un recurso CSS o JS comprimido. Si coincide el ETAG se
* devuelve el código HTTP/304
*
- * @param bool $disableMinify Deshabilitar minimizar
+ * @param bool $disableMinify Deshabilitar minimizar
*/
public function getMinified($disableMinify = false)
{
@@ -122,7 +122,8 @@ class Minify
$data = Util::getDataFromUrl($file['name']);
echo '/* URL: ' . $file['name'] . ' */' . PHP_EOL;
echo $data;
- } catch (SPException $e){ }
+ } catch (SPException $e) {
+ }
continue;
}
@@ -130,22 +131,22 @@ class Minify
if (!file_exists($filePath)) {
echo '/* ERROR: FILE NOT FOUND: ' . $file['name'] . ' */' . PHP_EOL;
error_log('File not found: ' . $filePath);
- continue;
- }
-
- if ($file['min'] === true && $disableMinify === false) {
- echo '/* MINIFIED FILE: ' . $file['name'] . ' */' . PHP_EOL;
- if ($this->type === self::FILETYPE_JS) {
- echo $this->jsCompress(file_get_contents($filePath));
- } elseif ($this->type === self::FILETYPE_CSS) {
- echo CssMin::minify(file_get_contents($filePath));
- }
} else {
- echo '/* FILE: ' . $file['name'] . ' */' . PHP_EOL;
- echo file_get_contents($filePath);
- }
- echo PHP_EOL;
+ if ($file['min'] === true && $disableMinify === false) {
+ echo '/* MINIFIED FILE: ' . $file['name'] . ' */' . PHP_EOL;
+ if ($this->type === self::FILETYPE_JS) {
+ echo $this->jsCompress(file_get_contents($filePath));
+ } elseif ($this->type === self::FILETYPE_CSS) {
+ echo CssMin::minify(file_get_contents($filePath));
+ }
+ } else {
+ echo '/* FILE: ' . $file['name'] . ' */' . PHP_EOL;
+ echo file_get_contents($filePath);
+ }
+
+ echo PHP_EOL;
+ }
}
ob_end_flush();
@@ -166,7 +167,7 @@ class Minify
}
$filePath = $file['base'] . DIRECTORY_SEPARATOR . $file['name'];
- $md5Sum .= md5_file($filePath);
+ $md5Sum .= (file_exists($filePath)) ? md5_file($filePath) : '';
}
return md5($md5Sum);
@@ -213,7 +214,7 @@ class Minify
if (strrpos($file, ',')) {
$files = explode(',', $file);
- foreach ($files as $file){
+ foreach ($files as $file) {
$this->files[] = array(
'base' => $this->base,
'name' => $file,
@@ -229,14 +230,6 @@ class Minify
}
}
- /**
- * @param int $type
- */
- public function setType($type)
- {
- $this->type = $type;
- }
-
/**
* Comprobar si es necesario reducir
*
@@ -247,4 +240,12 @@ class Minify
{
return !preg_match('/\.(min|pack)\./', $file);
}
+
+ /**
+ * @param int $type
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Import/CsvImportBase.class.php b/inc/SP/Import/CsvImportBase.class.php
index d9aa4a16..33b52fc3 100644
--- a/inc/SP/Import/CsvImportBase.class.php
+++ b/inc/SP/Import/CsvImportBase.class.php
@@ -25,11 +25,11 @@
namespace SP\Import;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Core\Crypt;
-use SP\Mgmt\Customer;
+use SP\Mgmt\Customers\Customer;
use SP\Log\Log;
-use SP\Mgmt\Category;
+use SP\Mgmt\Categories\Category;
use SP\Core\SPException;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Import/ImportBase.class.php b/inc/SP/Import/ImportBase.class.php
index de6cba5d..50c014d0 100644
--- a/inc/SP/Import/ImportBase.class.php
+++ b/inc/SP/Import/ImportBase.class.php
@@ -26,9 +26,9 @@
namespace SP\Import;
use SP\Account\Account;
-use SP\Account\AccountData;
-use SP\Mgmt\Customer;
-use SP\Mgmt\Category;
+use SP\DataModel\AccountData;
+use SP\Mgmt\Customers\Customer;
+use SP\Mgmt\Categories\Category;
use SP\Core\Session;
use SP\Core\SPException;
@@ -144,7 +144,7 @@ abstract class ImportBase
/**
* Añadir una cuenta desde un archivo importado.
*
- * @param AccountData $AccountData
+ * @param \SP\DataModel\AccountData $AccountData
* @return bool
*/
protected function addAccount(AccountData $AccountData)
diff --git a/inc/SP/Import/KeepassImport.class.php b/inc/SP/Import/KeepassImport.class.php
index fab42be7..0497f8e9 100644
--- a/inc/SP/Import/KeepassImport.class.php
+++ b/inc/SP/Import/KeepassImport.class.php
@@ -26,7 +26,7 @@
namespace SP\Import;
use SimpleXMLElement;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Core\Crypt;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Import/KeepassXImport.class.php b/inc/SP/Import/KeepassXImport.class.php
index fb065630..02dff65a 100644
--- a/inc/SP/Import/KeepassXImport.class.php
+++ b/inc/SP/Import/KeepassXImport.class.php
@@ -26,7 +26,7 @@
namespace SP\Import;
use SimpleXMLElement;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Core\Crypt;
use SP\Core\SPException;
diff --git a/inc/SP/Import/Migrate.class.php b/inc/SP/Import/Migrate.class.php
index d60c0879..fe3eef9b 100644
--- a/inc/SP/Import/Migrate.class.php
+++ b/inc/SP/Import/Migrate.class.php
@@ -26,7 +26,7 @@
namespace SP\Import;
use SP\Config\Config;
-use SP\Mgmt\Customer;
+use SP\Mgmt\Customers\Customer;
use SP\Log\Log;
use SP\Core\Session;
use SP\Core\SPException;
diff --git a/inc/SP/Import/SyspassImport.class.php b/inc/SP/Import/SyspassImport.class.php
index c57e74d1..431e6c3f 100644
--- a/inc/SP/Import/SyspassImport.class.php
+++ b/inc/SP/Import/SyspassImport.class.php
@@ -25,7 +25,7 @@
namespace SP\Import;
-use SP\Account\AccountData;
+use SP\DataModel\AccountData;
use SP\Core\Crypt;
use SP\Core\SPException;
diff --git a/inc/SP/Mgmt/Category.class.php b/inc/SP/Mgmt/Categories/Category.class.php
similarity index 99%
rename from inc/SP/Mgmt/Category.class.php
rename to inc/SP/Mgmt/Categories/Category.class.php
index c0ef2bdb..938389ba 100644
--- a/inc/SP/Mgmt/Category.class.php
+++ b/inc/SP/Mgmt/Categories/Category.class.php
@@ -24,7 +24,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\Categories;
use SP\Log\Email;
use SP\Storage\DB;
diff --git a/inc/SP/Mgmt/CustomFieldDef.class.php b/inc/SP/Mgmt/CustomFields/CustomFieldDef.class.php
similarity index 97%
rename from inc/SP/Mgmt/CustomFieldDef.class.php
rename to inc/SP/Mgmt/CustomFields/CustomFieldDef.class.php
index 255b4904..7cf3c893 100644
--- a/inc/SP/Mgmt/CustomFieldDef.class.php
+++ b/inc/SP/Mgmt/CustomFields/CustomFieldDef.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\CustomFields;
use SP\Storage\DB;
use SP\Storage\QueryData;
@@ -111,7 +111,7 @@ class CustomFieldDef extends CustomFieldsBase
$field = unserialize($customField->customfielddef_field);
if (get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFieldDef', $field);
}
if (empty($search)
@@ -225,7 +225,7 @@ class CustomFieldDef extends CustomFieldsBase
$field = unserialize($customField->customfielddef_field);
if (get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFieldDef', $field);
}
$attribs = new \stdClass();
diff --git a/inc/SP/Mgmt/CustomFields.class.php b/inc/SP/Mgmt/CustomFields/CustomFields.class.php
similarity index 97%
rename from inc/SP/Mgmt/CustomFields.class.php
rename to inc/SP/Mgmt/CustomFields/CustomFields.class.php
index cda83d03..7032d766 100644
--- a/inc/SP/Mgmt/CustomFields.class.php
+++ b/inc/SP/Mgmt/CustomFields/CustomFields.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\CustomFields;
use SP\Core\Crypt;
use SP\Storage\DB;
@@ -65,7 +65,7 @@ class CustomFields extends CustomFieldsBase
$field = unserialize($fieldDef->customfielddef_field);
if (get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFieldDef', $field);
}
$this->id = $customFieldDefId;
@@ -98,7 +98,7 @@ class CustomFields extends CustomFieldsBase
$queryRes = DB::getResults($Data);
if ($queryRes === false) {
- return array();
+ return array('hash' => '');
}
$customFields = array();
@@ -110,7 +110,7 @@ class CustomFields extends CustomFieldsBase
$field = unserialize($customField->customfielddef_field);
if (get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFieldDef', $field);
}
$attribs = new \stdClass();
@@ -166,7 +166,7 @@ class CustomFields extends CustomFieldsBase
$queryRes = DB::getResults($Data);
if ($queryRes === false) {
- return array();
+ return array('hash' => '');
}
$queryMerge = array_merge($queryRes, self::getCustomFieldsNoData($moduleId, $itemId));
@@ -181,7 +181,7 @@ class CustomFields extends CustomFieldsBase
$field = unserialize($customField->customfielddef_field);
if (get_class($field) === '__PHP_Incomplete_Class') {
- $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ $field = Util::castToClass('SP\Mgmt\CustomFields\CustomFieldDef', $field);
}
$attribs = new \stdClass();
diff --git a/inc/SP/Mgmt/CustomFieldsBase.class.php b/inc/SP/Mgmt/CustomFields/CustomFieldsBase.class.php
similarity index 99%
rename from inc/SP/Mgmt/CustomFieldsBase.class.php
rename to inc/SP/Mgmt/CustomFields/CustomFieldsBase.class.php
index e77ebd18..70d96d7e 100644
--- a/inc/SP/Mgmt/CustomFieldsBase.class.php
+++ b/inc/SP/Mgmt/CustomFields/CustomFieldsBase.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\CustomFields;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Mgmt/CustomFieldsUtil.class.php b/inc/SP/Mgmt/CustomFields/CustomFieldsUtil.class.php
similarity index 98%
rename from inc/SP/Mgmt/CustomFieldsUtil.class.php
rename to inc/SP/Mgmt/CustomFields/CustomFieldsUtil.class.php
index 2b7d9aa3..b031b771 100644
--- a/inc/SP/Mgmt/CustomFieldsUtil.class.php
+++ b/inc/SP/Mgmt/CustomFields/CustomFieldsUtil.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\CustomFields;
/**
* Class CustomFieldsUtil utilidades para los campos personalizados
diff --git a/inc/SP/Mgmt/Customer.class.php b/inc/SP/Mgmt/Customers/Customer.class.php
similarity index 99%
rename from inc/SP/Mgmt/Customer.class.php
rename to inc/SP/Mgmt/Customers/Customer.class.php
index 4763f92a..8ca1c447 100644
--- a/inc/SP/Mgmt/Customer.class.php
+++ b/inc/SP/Mgmt/Customers/Customer.class.php
@@ -24,7 +24,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\Customers;
use SP\Log\Email;
use SP\Storage\DB;
diff --git a/inc/SP/Mgmt/Files.class.php b/inc/SP/Mgmt/Files/Files.class.php
similarity index 99%
rename from inc/SP/Mgmt/Files.class.php
rename to inc/SP/Mgmt/Files/Files.class.php
index e4e2eef0..ca588e90 100644
--- a/inc/SP/Mgmt/Files.class.php
+++ b/inc/SP/Mgmt/Files/Files.class.php
@@ -24,7 +24,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\Files;
use SP\Account\AccountUtil;
use SP\Storage\QueryData;
diff --git a/inc/SP/Mgmt/User/Groups.class.php b/inc/SP/Mgmt/Groups/Groups.class.php
similarity index 71%
rename from inc/SP/Mgmt/User/Groups.class.php
rename to inc/SP/Mgmt/Groups/Groups.class.php
index 8c7eb625..d76c7f4f 100644
--- a/inc/SP/Mgmt/User/Groups.class.php
+++ b/inc/SP/Mgmt/Groups/Groups.class.php
@@ -24,7 +24,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Groups;
use SP\Html\Html;
use SP\Log\Email;
@@ -476,196 +476,5 @@ class Groups
return DB::$lastNumRows;
}
- /**
- * Obtiene el listado con el nombre de los grupos de una cuenta.
- *
- * @param int $accountId con el Id de la cuenta
- * @return false|array con los nombres de los grupos ordenados
- */
- public static function getGroupsNameForAccount($accountId)
- {
- $query = 'SELECT usergroup_id,'
- . 'usergroup_name '
- . 'FROM accGroups '
- . 'JOIN usrGroups ON accgroup_groupId = usergroup_id '
- . 'WHERE accgroup_accountId = :id';
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($accountId, 'id');
-
- DB::setReturnArray();
-
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false) {
- return false;
- }
-
- foreach ($queryRes as $groups) {
- $groupsName[$groups->usergroup_id] = $groups->usergroup_name;
- }
-
- asort($groupsName, SORT_STRING);
-
- return $groupsName;
- }
-
- /**
- * Actualizar la asociación de grupos con cuentas.
- *
- * @param int $accountId con el Id de la cuenta
- * @param array $groupsId con los grupos de la cuenta
- * @return bool
- */
- public static function updateGroupsForAccount($accountId, $groupsId)
- {
- if (self::deleteGroupsForAccount($accountId, $groupsId)) {
- return self::addGroupsForAccount($accountId, $groupsId);
- }
-
- return false;
- }
-
- /**
- * Eliminar la asociación de grupos con cuentas.
- *
- * @param int $accountId con el Id de la cuenta
- * @param array $groupsId opcional con los grupos de la cuenta
- * @return bool
- */
- public static function deleteGroupsForAccount($accountId, $groupsId = null)
- {
- $queryExcluded = '';
-
- // Excluimos los grupos actuales
- if (is_array($groupsId)) {
- array_map('intval', $groupsId);
-
- $queryExcluded = 'AND accgroup_groupId NOT IN (' . implode(',', $groupsId) . ')';
- }
-
- $query = 'DELETE FROM accGroups WHERE accgroup_accountId = :id ' . $queryExcluded;
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($accountId, 'id');
-
- return DB::getQuery($Data);
- }
-
- /**
- * Crear asociación de grupos con cuentas.
- *
- * @param int $accountId con el Id de la cuenta
- * @param array $groupsId con los grupos de la cuenta
- * @return bool
- */
- public static function addGroupsForAccount($accountId, $groupsId)
- {
- if (!is_array($groupsId)) {
- return true;
- }
-
- $values = '';
-
- // Obtenemos los grupos actuales
- $groupsExcluded = self::getGroupsForAccount($accountId);
-
- foreach ($groupsId as $groupId) {
- // Excluimos los grupos actuales
- if (isset($groupsExcluded) && is_array($groupsExcluded) && in_array($groupId, $groupsExcluded)) {
- continue;
- }
-
- $values[] = '(' . (int)$accountId . ',' . (int)$groupId . ')';
- }
-
- if (!is_array($values)) {
- return true;
- }
-
- $query = 'INSERT INTO accGroups (accgroup_accountId, accgroup_groupId) VALUES ' . implode(',', $values);
-
- $Data = new QueryData();
- $Data->setQuery($query);
-
- return DB::getQuery($Data);
- }
-
- /**
- * Obtiene el listado de grupos de una cuenta.
- *
- * @param int $accountId con el Id de la cuenta
- * @return false|array con el Id de grupo
- */
- public static function getGroupsForAccount($accountId)
- {
- $query = 'SELECT accgroup_groupId FROM accGroups WHERE accgroup_accountId = :id';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($accountId, 'id');
-
- DB::setReturnArray();
-
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false) {
- return array();
- }
-
- foreach ($queryRes as $group) {
- $groups[] = (int)$group->accgroup_groupId;
- }
-
- return $groups;
- }
-
- /**
- * Obtener los grupos de usuarios de una búsqueda
- *
- * @param $limitCount
- * @param int $limitStart
- * @param string $search
- * @return array
- */
- public static function getGroupsMgmtSearch($limitCount, $limitStart = 0, $search = '')
- {
- $query = 'SELECT usergroup_id,'
- . 'usergroup_name,'
- . 'usergroup_description '
- . 'FROM usrGroups';
-
- $Data = new QueryData();
-
- if (!empty($search)) {
- $search = '%' . $search . '%';
- $query .= ' WHERE usergroup_name LIKE ? OR usergroup_description LIKE ?';
-
- $Data->addParam($search);
- $Data->addParam($search);
- }
-
- $query .= ' ORDER BY usergroup_name';
- $query .= ' LIMIT ?, ?';
-
- $Data->addParam($limitStart);
- $Data->addParam($limitCount);
-
- $Data->setQuery($query);
-
- DB::setReturnArray();
- DB::setFullRowCount();
-
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false) {
- return array();
- }
-
- $queryRes['count'] = DB::$lastNumRows;
-
- return $queryRes;
- }
}
diff --git a/inc/SP/Mgmt/Groups/GroupsUtil.class.php b/inc/SP/Mgmt/Groups/GroupsUtil.class.php
new file mode 100644
index 00000000..63ce8a53
--- /dev/null
+++ b/inc/SP/Mgmt/Groups/GroupsUtil.class.php
@@ -0,0 +1,56 @@
+.
+ *
+ */
+
+namespace SP\Mgmt\Groups;
+
+
+use SP\Storage\DB;
+use SP\Storage\QueryData;
+
+/**
+ * Class GroupsUtil
+ *
+ * @package SP\Mgmt\Groups
+ */
+class GroupsUtil
+{
+ /**
+ * Obtener el id y nombre de los grupos disponibles
+ *
+ * @return array
+ */
+ public static function getGroupsName()
+ {
+ $query = 'SELECT usergroup_id, usergroup_name FROM usrGroups ORDER BY usergroup_name';
+
+ $Data = new QueryData();
+ $Data->setMapClassName('\SP\DataModel\GroupData');
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+
+ return DB::getResults($Data);
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Mgmt/User/Profile.class.php b/inc/SP/Mgmt/Profiles/Profile.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/Profile.class.php
rename to inc/SP/Mgmt/Profiles/Profile.class.php
index 992a85bd..072a70b3 100644
--- a/inc/SP/Mgmt/User/Profile.class.php
+++ b/inc/SP/Mgmt/Profiles/Profile.class.php
@@ -24,7 +24,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Profiles;
use SP\Log\Email;
use SP\Log\Log;
diff --git a/inc/SP/Mgmt/User/ProfileBase.class.php b/inc/SP/Mgmt/Profiles/ProfileBase.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/ProfileBase.class.php
rename to inc/SP/Mgmt/Profiles/ProfileBase.class.php
index c92bd28c..d2abce4c 100644
--- a/inc/SP/Mgmt/User/ProfileBase.class.php
+++ b/inc/SP/Mgmt/Profiles/ProfileBase.class.php
@@ -23,16 +23,13 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Profiles;
use SP\Html\Html;
use SP\Log\Email;
use SP\Log\Log;
-use SP\Core\SPException;
use SP\Storage\DB;
use SP\Storage\QueryData;
-use SP\Util\Checks;
-use SP\Util\Util;
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
diff --git a/inc/SP/Mgmt/User/ProfileUtil.class.php b/inc/SP/Mgmt/Profiles/ProfileUtil.class.php
similarity index 97%
rename from inc/SP/Mgmt/User/ProfileUtil.class.php
rename to inc/SP/Mgmt/Profiles/ProfileUtil.class.php
index 50c4287e..4e7956bc 100644
--- a/inc/SP/Mgmt/User/ProfileUtil.class.php
+++ b/inc/SP/Mgmt/Profiles/ProfileUtil.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Profiles;
use SP\Core\SPException;
use SP\Storage\DB;
@@ -116,7 +116,7 @@ class ProfileUtil
$profile = unserialize($queryRes->userprofile_profile);
if (get_class($profile) === '__PHP_Incomplete_Class') {
- return Util::castToClass('SP\Mgmt\User\Profile', $profile);
+ return Util::castToClass('SP\Mgmt\Profiles\Profile', $profile);
}
return $profile;
diff --git a/inc/SP/Mgmt/PublicLink.class.php b/inc/SP/Mgmt/PublicLinks/PublicLink.class.php
similarity index 99%
rename from inc/SP/Mgmt/PublicLink.class.php
rename to inc/SP/Mgmt/PublicLinks/PublicLink.class.php
index c038d09b..59cd03c8 100644
--- a/inc/SP/Mgmt/PublicLink.class.php
+++ b/inc/SP/Mgmt/PublicLinks/PublicLink.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\PublicLinks;
use SP\Account\AccountUtil;
use SP\Config\Config;
@@ -33,7 +33,7 @@ use SP\Log\Log;
use SP\Core\Session;
use SP\Core\SPException;
use SP\Storage\DB;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\QueryData;
use SP\Util\Util;
diff --git a/inc/SP/Mgmt/PublicLinkBase.class.php b/inc/SP/Mgmt/PublicLinks/PublicLinkBase.class.php
similarity index 99%
rename from inc/SP/Mgmt/PublicLinkBase.class.php
rename to inc/SP/Mgmt/PublicLinks/PublicLinkBase.class.php
index 8a98a89d..2b25002c 100644
--- a/inc/SP/Mgmt/PublicLinkBase.class.php
+++ b/inc/SP/Mgmt/PublicLinks/PublicLinkBase.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\PublicLinks;
use SP\Config\Config;
use SP\Core\Crypt;
diff --git a/inc/SP/Mgmt/PublicLinkUtil.class.php b/inc/SP/Mgmt/PublicLinks/PublicLinkUtil.class.php
similarity index 97%
rename from inc/SP/Mgmt/PublicLinkUtil.class.php
rename to inc/SP/Mgmt/PublicLinks/PublicLinkUtil.class.php
index 07948992..2c6cd4d6 100644
--- a/inc/SP/Mgmt/PublicLinkUtil.class.php
+++ b/inc/SP/Mgmt/PublicLinks/PublicLinkUtil.class.php
@@ -23,11 +23,11 @@
*
*/
-namespace SP\Mgmt;
+namespace SP\Mgmt\PublicLinks;
use SP\Account\AccountUtil;
use SP\Storage\DB;
-use SP\Mgmt\User\UserUtil;
+use SP\Mgmt\Users\UserUtil;
use SP\Storage\QueryData;
use SP\Util\Util;
@@ -76,7 +76,7 @@ class PublicLinkUtil
$PublicLink = unserialize($data->publicLink_linkData);
if (get_class($PublicLink) === '__PHP_Incomplete_Class') {
- $PublicLink = Util::castToClass('SP\Mgmt\PublicLink', $PublicLink);
+ $PublicLink = Util::castToClass('SP\Mgmt\PublicLinks\PublicLink', $PublicLink);
}
$link = new \stdClass();
@@ -133,7 +133,7 @@ class PublicLinkUtil
$PublicLink = unserialize($data->publicLink_linkData);
if (get_class($PublicLink) === '__PHP_Incomplete_Class') {
- $PublicLink = Util::castToClass('SP\Mgmt\PublicLink', $PublicLink);
+ $PublicLink = Util::castToClass('SP\Mgmt\PublicLinks\PublicLink', $PublicLink);
}
$link = new \stdClass();
diff --git a/inc/SP/Mgmt/Tags/Tags.class.php b/inc/SP/Mgmt/Tags/Tags.class.php
new file mode 100644
index 00000000..d197cdca
--- /dev/null
+++ b/inc/SP/Mgmt/Tags/Tags.class.php
@@ -0,0 +1,198 @@
+.
+ *
+ */
+
+namespace SP\Mgmt\Tags;
+
+use SP\DataModel\TagData;
+use SP\Storage\DB;
+use SP\Storage\DBUtil;
+use SP\Storage\QueryData;
+
+defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
+
+/**
+ * Class Tags
+ *
+ * @package SP\Mgmt\Tags
+ */
+class Tags
+{
+ /**
+ * Obtiene el listado de etiquetas mediante una búsqueda
+ *
+ * @param int $limitCount
+ * @param int $limitStart
+ * @param string $search La cadena de búsqueda
+ * @return array con el id de categoria como clave y en nombre como valor
+ */
+ public static function getTagsMgmtSearch($limitCount, $limitStart = 0, $search = "")
+ {
+ $query = 'SELECT tag_id, tag_name FROM tags';
+
+ $Data = new QueryData();
+
+ if (!empty($search)) {
+ $query .= ' WHERE tag_name LIKE ? ';
+ $Data->addParam('%' . $search . '%');
+ }
+
+ $query .= ' ORDER BY tag_name';
+ $query .= ' LIMIT ?,?';
+
+ $Data->addParam($limitStart);
+ $Data->addParam($limitCount);
+
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+ DB::setFullRowCount();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ $queryRes['count'] = DB::$lastNumRows;
+
+ return $queryRes;
+ }
+
+ /**
+ * Devolver los tags disponibles
+ *
+ * @return TagData[]
+ */
+ public static function getTags()
+ {
+ $query = 'SELECT tag_id, tag_name FROM tags';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->setMapClassName('SP\DataModel\TagData');
+
+ DB::setReturnArray();
+
+ return DB::getResults($Data);
+ }
+
+ /**
+ * Devolver los tags disponibles
+ *
+ * @return TagData[]
+ */
+ public static function getTagsForJson()
+ {
+ $query = 'SELECT tag_id, tag_name FROM tags ORDER BY tag_name';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+
+ return DB::getResults($Data);
+ }
+
+ /**
+ * @param TagData $tag
+ * @return TagData
+ */
+ public function getTag(TagData $tag)
+ {
+ if (!$tag->getTagId()) {
+ return $tag;
+ }
+
+ $query = 'SELECT tag_id, tag_name FROM tags WHERE tag_id = :id LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($tag->getTagId(), 'id');
+ $Data->setMapClassName('SP\DataModel\TagData');
+
+ return DB::getResults($Data);
+ }
+
+ /**
+ * @param TagData $tag
+ * @return bool
+ */
+ public function addTag(TagData $tag)
+ {
+ $query = 'INSERT INTO tags SET tag_name = :name, tag_hash = :hash';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($tag->getTagName(), 'name');
+ $Data->addParam($this->getTagHash($tag), 'hash');
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * @param TagData $tag
+ * @return bool
+ */
+ public function deleteTag(TagData $tag)
+ {
+ $query = 'DELETE FROM tags WHERE tag_id = :id LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($tag->getTagId(), 'id');
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * @param TagData $tag
+ * @return bool
+ */
+ public function updateTag(TagData $tag)
+ {
+ $query = 'UPDATE tags SET tag_name = :name, tag_hash = :hash WHERE tag_id = :id LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($tag->getTagId(), 'id');
+ $Data->addParam($tag->getTagName(), 'name');
+ $Data->addParam($this->getTagHash($tag), 'hash');
+
+ return DB::getQuery($Data);
+ }
+
+ /**
+ * Formatear el nombre de la etiqueta y devolver un hash
+ *
+ * @param TagData $tag
+ * @return string
+ */
+ public function getTagHash(TagData $tag)
+ {
+ $charsSrc = array(".", " ", "_", ", ", "-", ";", "'", "\"", ":", "(", ")", "|", "/");
+
+ return sha1(strtolower(str_replace($charsSrc, '', DBUtil::escape($tag->getTagName()))));
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Mgmt/User/User.class.php b/inc/SP/Mgmt/Users/User.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/User.class.php
rename to inc/SP/Mgmt/Users/User.class.php
index 37c85f1f..ac4d842b 100644
--- a/inc/SP/Mgmt/User/User.class.php
+++ b/inc/SP/Mgmt/Users/User.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Config\ConfigDB;
use SP\Core\Crypt;
diff --git a/inc/SP/Mgmt/User/UserBase.class.php b/inc/SP/Mgmt/Users/UserBase.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/UserBase.class.php
rename to inc/SP/Mgmt/Users/UserBase.class.php
index 701fd500..ddb924a9 100644
--- a/inc/SP/Mgmt/User/UserBase.class.php
+++ b/inc/SP/Mgmt/Users/UserBase.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Auth\Auth;
use SP\Html\Html;
diff --git a/inc/SP/Mgmt/User/UserLdap.class.php b/inc/SP/Mgmt/Users/UserLdap.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/UserLdap.class.php
rename to inc/SP/Mgmt/Users/UserLdap.class.php
index 1d52f0e3..197271a9 100644
--- a/inc/SP/Mgmt/User/UserLdap.class.php
+++ b/inc/SP/Mgmt/Users/UserLdap.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Config\Config;
use SP\Log\Email;
diff --git a/inc/SP/Mgmt/User/UserMigrate.class.php b/inc/SP/Mgmt/Users/UserMigrate.class.php
similarity index 98%
rename from inc/SP/Mgmt/User/UserMigrate.class.php
rename to inc/SP/Mgmt/Users/UserMigrate.class.php
index 1d74f53e..b62e9208 100644
--- a/inc/SP/Mgmt/User/UserMigrate.class.php
+++ b/inc/SP/Mgmt/Users/UserMigrate.class.php
@@ -23,10 +23,11 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Log\Email;
use SP\Log\Log;
+use SP\Mgmt\Groups\Groups;
use SP\Storage\DB;
use SP\Storage\QueryData;
diff --git a/inc/SP/Mgmt/User/UserPass.class.php b/inc/SP/Mgmt/Users/UserPass.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/UserPass.class.php
rename to inc/SP/Mgmt/Users/UserPass.class.php
index 702b15d6..9c7e5076 100644
--- a/inc/SP/Mgmt/User/UserPass.class.php
+++ b/inc/SP/Mgmt/Users/UserPass.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Config\ConfigDB;
use SP\Core\Crypt;
diff --git a/inc/SP/Mgmt/User/UserPassRecover.class.php b/inc/SP/Mgmt/Users/UserPassRecover.class.php
similarity index 99%
rename from inc/SP/Mgmt/User/UserPassRecover.class.php
rename to inc/SP/Mgmt/Users/UserPassRecover.class.php
index c4f27330..76cf146f 100644
--- a/inc/SP/Mgmt/User/UserPassRecover.class.php
+++ b/inc/SP/Mgmt/Users/UserPassRecover.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Storage\DB;
use SP\Storage\QueryData;
diff --git a/inc/SP/Mgmt/User/UserPreferences.class.php b/inc/SP/Mgmt/Users/UserPreferences.class.php
similarity index 98%
rename from inc/SP/Mgmt/User/UserPreferences.class.php
rename to inc/SP/Mgmt/Users/UserPreferences.class.php
index 54c07349..7b7fc953 100644
--- a/inc/SP/Mgmt/User/UserPreferences.class.php
+++ b/inc/SP/Mgmt/Users/UserPreferences.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Core\SPException;
use SP\Storage\DB;
@@ -106,7 +106,7 @@ class UserPreferences
$preferences = unserialize($queryRes->user_preferences);
if (get_class($preferences) === '__PHP_Incomplete_Class') {
- return Util::castToClass('SP\Mgmt\User\UserPreferences', $preferences);
+ return Util::castToClass('SP\Mgmt\Users\UserPreferences', $preferences);
}
return $preferences;
diff --git a/inc/SP/Mgmt/User/UserUtil.class.php b/inc/SP/Mgmt/Users/UserUtil.class.php
similarity index 95%
rename from inc/SP/Mgmt/User/UserUtil.class.php
rename to inc/SP/Mgmt/Users/UserUtil.class.php
index 9cc955c7..2e7692ca 100644
--- a/inc/SP/Mgmt/User/UserUtil.class.php
+++ b/inc/SP/Mgmt/Users/UserUtil.class.php
@@ -23,7 +23,7 @@
*
*/
-namespace SP\Mgmt\User;
+namespace SP\Mgmt\Users;
use SP\Core\Session;
use SP\Storage\DB;
@@ -350,4 +350,23 @@ class UserUtil
return $queryRes;
}
+
+ /**
+ * Obtener el id y login de los usuarios disponibles
+ *
+ * @return string con el email del usuario
+ */
+ public static function getUsersLogin()
+ {
+ $query = 'SELECT user_id, user_login, user_name FROM usrData ORDER BY user_login';
+
+ $Data = new QueryData();
+ $Data->setMapClassName('\SP\DataModel\UserBasicData');
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+
+ return DB::getResults($Data);
+ }
+
}
\ No newline at end of file
diff --git a/inc/SP/Storage/DB.class.php b/inc/SP/Storage/DB.class.php
index f8096244..eebdae99 100644
--- a/inc/SP/Storage/DB.class.php
+++ b/inc/SP/Storage/DB.class.php
@@ -103,7 +103,7 @@ class DB
*/
public static function getResults(QueryData $queryData)
{
- if (empty($queryData->getQuery())) {
+ if ($queryData->getQuery() === '') {
self::resetVars();
return false;
}
@@ -122,10 +122,15 @@ class DB
&& get_class($doQuery) === "PDOStatement"
) {
return $doQuery;
- } elseif ($db->numRows == 0) {
- self::resetVars();
- return false;
- } elseif ($db->numRows == 1 && self::$retArray === false) {
+ } elseif ($db->numRows === 0) {
+ if (self::$retArray){
+ self::resetVars();
+ return [];
+ } else {
+ self::resetVars();
+ return false;
+ }
+ } elseif ($db->numRows === 1 && self::$retArray === false) {
self::resetVars();
return $db->lastResult[0];
}
@@ -168,7 +173,11 @@ class DB
if ($isSelect) {
if (!$getRawData) {
$this->numFields = $queryRes->columnCount();
- $this->lastResult = $queryRes->fetchAll(PDO::FETCH_OBJ);
+ if ($queryData->getMapClassName()) {
+ $this->lastResult = $queryRes->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, $queryData->getMapClassName());
+ } else {
+ $this->lastResult = $queryRes->fetchAll(PDO::FETCH_OBJ);
+ }
} else {
return $queryRes;
}
@@ -255,15 +264,15 @@ class DB
*/
private function getFullRowCount(QueryData $queryData)
{
- if (empty($queryData->getQuery())) {
+ if ($queryData->getQuery() === '') {
return 0;
}
$num = 0;
$patterns = array(
'/(LIMIT|ORDER BY|GROUP BY).*/i',
- '/SELECT DISTINCT\s([\w_]+),.* FROM/iU',
- '/SELECT [\w_]+,.* FROM/iU',
+ '/SELECT DISTINCT\s([\w_]+),[\s\S]*? FROM/i',
+ '/SELECT [\w_]+,[\s\S]*? FROM/i',
);
$replace = array('', 'SELECT COUNT(DISTINCT \1) FROM', 'SELECT COUNT(*) FROM', '');
@@ -277,14 +286,8 @@ class DB
try {
/** @var $db PDO */
$db = Factory::getDBStorage()->getConnection();
-
- if (!is_array($queryData->getParams())) {
- $queryRes = $db->query($query);
- $num = intval($queryRes->fetchColumn());
- } elseif ($queryRes = $this->prepareQueryData($queryData, true)) {
- $num = intval($queryRes->fetchColumn());
- }
-
+ $queryRes = (is_array($queryData->getParams())) ? $this->prepareQueryData($queryData, true) : $db->query($query);
+ $num = intval($queryRes->fetchColumn());
$queryRes->closeCursor();
return $num;
diff --git a/inc/SP/Storage/QueryData.class.php b/inc/SP/Storage/QueryData.class.php
index dfd90a85..e113909e 100644
--- a/inc/SP/Storage/QueryData.class.php
+++ b/inc/SP/Storage/QueryData.class.php
@@ -40,6 +40,10 @@ class QueryData
* @var string
*/
protected $query = '';
+ /**
+ * @var string
+ */
+ protected $mapClassName = '';
/**
* @param $value
@@ -77,4 +81,20 @@ class QueryData
{
$this->query = $query;
}
+
+ /**
+ * @return string
+ */
+ public function getMapClassName()
+ {
+ return $this->mapClassName;
+ }
+
+ /**
+ * @param string $mapClassName
+ */
+ public function setMapClassName($mapClassName)
+ {
+ $this->mapClassName = $mapClassName;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Storage/XmlHandler.class.php b/inc/SP/Storage/XmlHandler.class.php
index ce1ae81e..7b5387b5 100644
--- a/inc/SP/Storage/XmlHandler.class.php
+++ b/inc/SP/Storage/XmlHandler.class.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link http://syspass.org
- * @copyright 2012-2015 Rubén Domínguez nuxsmin@$syspass.org
+ * @copyright 2012-2015 Rubén Domínguez nuxsmin@syspass.org
*
* This file is part of sysPass.
*
@@ -26,12 +26,13 @@
namespace SP\Storage;
use DOMDocument;
+use DOMElement;
+use DOMNode;
+use DOMNodeList;
use ReflectionObject;
-use SP\Core\SPException;
/**
* Class XmlHandler para manejo básico de documentos XML
- *
* @package SMD\Storage
*/
class XmlHandler implements FileStorageInterface
@@ -48,10 +49,13 @@ class XmlHandler implements FileStorageInterface
* @var DOMDocument
*/
private $Dom;
+ /**
+ * @var DOMElement
+ */
+ private $root;
/**
* XmlHandler constructor.
- *
* @param $file
*/
public function __construct($file)
@@ -73,37 +77,19 @@ class XmlHandler implements FileStorageInterface
*
* @param string $tag
* @return bool|void
- * @throws SPException
+ * @throws \Exception
*/
public function load($tag = 'root')
{
if (!$this->checkSourceFile()) {
- throw new SPException(
- SPException::SP_CRITICAL,
- _('No es posible leer el archivo'),
- $this->file
- );
+ throw new \Exception(sprintf('No es posible leer/escribir el archivo: %s', $this->file));
}
- $this->items = [];
+ $this->items = array();
$this->Dom->load($this->file);
$nodes = $this->Dom->getElementsByTagName($tag)->item(0)->childNodes;
-
- foreach ($nodes as $node) {
- /** @var $node \DOMNode */
- if (is_object($node->childNodes) && $node->childNodes->length > 1) {
- foreach ($node->childNodes as $child) {
- /** @var $child \DOMNode */
-
- if ($child->nodeType == XML_ELEMENT_NODE) {
- $this->items[$node->nodeName][] = $child->nodeValue;
- }
- }
- } else {
- $this->items[$node->nodeName] = $node->nodeValue;
- }
- }
+ $this->items = $this->readChildNodes($nodes);
return $this;
}
@@ -115,7 +101,39 @@ class XmlHandler implements FileStorageInterface
*/
protected function checkSourceFile()
{
- return is_writable($this->file);
+ return (is_writable($this->file) && filesize($this->file) > 0);
+ }
+
+ /**
+ * Leer de forma recursiva los nodos hijos y devolver un array multidimensional
+ *
+ * @param DOMNodeList $NodeList
+ * @return array
+ */
+ protected function readChildNodes(DOMNodeList $NodeList)
+ {
+ $nodes = array();
+
+ foreach ($NodeList as $node) {
+ /** @var $node DOMNode */
+ if (is_object($node->childNodes) && $node->childNodes->length > 1) {
+ if ($node->nodeName === 'item') {
+ $nodes[] = $this->readChildNodes($node->childNodes);
+ } else {
+ $nodes[$node->nodeName] = $this->readChildNodes($node->childNodes);
+ }
+ } elseif ($node->nodeType === XML_ELEMENT_NODE) {
+ $val = (is_numeric($node->nodeValue)) ? intval($node->nodeValue) : $node->nodeValue;
+
+ if ($node->nodeName === 'item') {
+ $nodes[] = $val;
+ } else {
+ $nodes[$node->nodeName] = $val;
+ }
+ }
+ }
+
+ return $nodes;
}
/**
@@ -134,72 +152,99 @@ class XmlHandler implements FileStorageInterface
*
* @param string $tag
* @return bool|void
- * @throws SPException
+ * @throws \Exception
*/
public function save($tag = 'root')
{
if (is_null($this->items)) {
- throw new SPException(SPException::SP_WARNING, _('No hay elementos para guardar'));
+ throw new \Exception('No hay elementos para guardar');
}
$this->Dom->formatOutput = true;
- $root = $this->Dom->createElement($tag);
- $this->Dom->appendChild($root);
-
- foreach ($this->analyzeItems() as $key => $value) {
- $keyNode = $this->Dom->createElement($key);
-
- if (is_array($value)) {
- foreach ($value as $arrayVal) {
- $arrayNode = $this->Dom->createElement('item');
- $arrayNode->appendChild($this->Dom->createTextNode(trim($arrayVal)));
- $keyNode->appendChild($arrayNode);
- }
- } else {
- $keyNode->appendChild($this->Dom->createTextNode($value));
- }
-
- $root->appendChild($keyNode);
- }
-
+ $this->root = $this->Dom->createElement($tag);
+ $this->Dom->appendChild($this->root);
+ $this->writeChildNodes($this->items, $this->root);
$this->Dom->save($this->file);
return $this;
}
+ /**
+ * Crear los nodos hijos recursivamente a partir de un array multidimensional
+ *
+ * @param mixed $items
+ * @param DOMNode $Node
+ * @param null $type
+ */
+ protected function writeChildNodes($items, DOMNode $Node, $type = null)
+ {
+ foreach ($this->analyzeItems($items) as $key => $value) {
+ if (is_int($key)) {
+ $newNode = $this->Dom->createElement('item');
+ $newNode->setAttribute('type', $type);
+ } else {
+ $newNode = $this->Dom->createElement($key);
+ }
+
+ if (is_array($value) || is_object($value)) {
+ if (is_object($value)) {
+ $newNode->setAttribute('class', get_class($value));
+ $newNode->appendChild($this->Dom->createTextNode(base64_encode(serialize($value))));
+ } else {
+ $this->writeChildNodes($value, $newNode, $key);
+ }
+ } else {
+ $newNode->appendChild($this->Dom->createTextNode(trim($value)));
+ }
+
+ $Node->appendChild($newNode);
+ }
+ }
+
/**
* Analizar el tipo de elementos
*
- * @return array|mixed
+ * @param mixed $items
+ * @param bool $serialize
+ * @return array
*/
- protected function analyzeItems()
+ protected function analyzeItems($items, $serialize = false)
{
- if (is_array($this->items)) {
- ksort($this->items);
+ if (is_array($items)) {
+ ksort($items);
- return $this->items;
- } elseif (is_object($this->items)) {
- return $this->analyzeObject();
+ return $items;
+ } elseif (is_object($items)) {
+
+ return ($serialize) ? serialize($items) : $this->analyzeObject($items);
}
- return [];
+ return array();
}
/**
* Analizar un elemento del tipo objeto
*
+ * @param $object
* @return array
*/
- protected function analyzeObject()
+ protected function analyzeObject($object)
{
- $items = [];
- $Reflection = new ReflectionObject($this->items);
+ $items = array();
+ $Reflection = new ReflectionObject($object);
foreach ($Reflection->getProperties() as $property) {
$property->setAccessible(true);
- $items[$property->getName()] = $property->getValue($this->items);
+ $value = $property->getValue($object);
+
+ if (is_numeric($value) || is_bool($value)){
+ $items[$property->getName()] = (int)$value;
+ } else {
+ $items[$property->getName()] = $value;
+ }
+
$property->setAccessible(false);
}
diff --git a/inc/SP/Util/Json.class.php b/inc/SP/Util/Json.class.php
index bf86f241..de3287b6 100644
--- a/inc/SP/Util/Json.class.php
+++ b/inc/SP/Util/Json.class.php
@@ -41,7 +41,7 @@ class Json
* @return string
* @throws SPException
*/
- public static function getJson(&$data)
+ public static function getJson($data)
{
$json = json_encode(self::safeJson($data));
diff --git a/inc/SP/Util/Util.class.php b/inc/SP/Util/Util.class.php
index 165ef8db..81c391e5 100644
--- a/inc/SP/Util/Util.class.php
+++ b/inc/SP/Util/Util.class.php
@@ -431,7 +431,7 @@ class Util
{
return unserialize(preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen($class) . ':"' . $class . '"', serialize($object)));
}
-
+
/**
* Devuelve la última función llamada tras un error
*
diff --git a/inc/dbstructure.sql b/inc/dbstructure.sql
index 58d14666..d1aa59a3 100644
--- a/inc/dbstructure.sql
+++ b/inc/dbstructure.sql
@@ -1,249 +1,287 @@
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+/*!40103 SET @OLD_TIME_ZONE = @@TIME_ZONE */;
+/*!40103 SET TIME_ZONE = '+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS = @@UNIQUE_CHECKS, UNIQUE_CHECKS = 0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0 */;
+/*!40101 SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES = @@SQL_NOTES, SQL_NOTES = 0 */;
CREATE TABLE `accFiles` (
- `accfile_id` int(11) NOT NULL AUTO_INCREMENT,
- `accfile_accountId` smallint(5) unsigned NOT NULL,
- `accfile_name` varchar(100) NOT NULL,
- `accfile_type` varchar(100) NOT NULL,
- `accfile_size` int(11) NOT NULL,
- `accfile_content` mediumblob NOT NULL,
- `accfile_extension` varchar(10) NOT NULL,
- `accFile_thumb` mediumblob,
+ `accfile_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `accfile_accountId` SMALLINT(5) UNSIGNED NOT NULL,
+ `accfile_name` VARCHAR(100) NOT NULL,
+ `accfile_type` VARCHAR(100) NOT NULL,
+ `accfile_size` INT(11) NOT NULL,
+ `accfile_content` MEDIUMBLOB NOT NULL,
+ `accfile_extension` VARCHAR(10) NOT NULL,
+ `accFile_thumb` MEDIUMBLOB,
PRIMARY KEY (`accfile_id`),
KEY `IDX_accountId` (`accfile_accountId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `accGroups` (
- `accgroup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `accgroup_accountId` int(10) unsigned NOT NULL,
- `accgroup_groupId` int(10) unsigned NOT NULL,
+ `accgroup_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `accgroup_accountId` INT(10) UNSIGNED NOT NULL,
+ `accgroup_groupId` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`accgroup_id`),
KEY `IDX_accountId` (`accgroup_accountId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `accHistory` (
- `acchistory_id` int(11) NOT NULL AUTO_INCREMENT,
- `acchistory_accountId` smallint(5) unsigned NOT NULL,
- `acchistory_userGroupId` tinyint(3) unsigned NOT NULL,
- `acchistory_userId` tinyint(3) unsigned NOT NULL,
- `acchistory_userEditId` tinyint(3) unsigned NOT NULL,
- `acchistory_customerId` tinyint(3) unsigned NOT NULL,
- `acchistory_name` varchar(255) NOT NULL,
- `acchistory_categoryId` tinyint(3) unsigned NOT NULL,
- `acchistory_login` varchar(50) NOT NULL,
- `acchistory_url` varchar(255) DEFAULT NULL,
- `acchistory_pass` varbinary(255) NOT NULL,
- `acchistory_IV` varbinary(32) NOT NULL,
- `acchistory_notes` text NOT NULL,
- `acchistory_countView` int(10) unsigned NOT NULL DEFAULT '0',
- `acchistory_countDecrypt` int(10) unsigned NOT NULL DEFAULT '0',
- `acchistory_dateAdd` datetime NOT NULL,
- `acchistory_dateEdit` datetime NOT NULL,
- `acchistory_isModify` bit(1) DEFAULT NULL,
- `acchistory_isDeleted` bit(1) DEFAULT NULL,
- `acchistory_mPassHash` varbinary(255) NOT NULL,
- `accHistory_otherUserEdit` bit(1) DEFAULT b'0',
- `accHistory_otherGroupEdit` bit(1) DEFAULT b'0',
+ `acchistory_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `acchistory_accountId` SMALLINT(5) UNSIGNED NOT NULL,
+ `acchistory_userGroupId` TINYINT(3) UNSIGNED NOT NULL,
+ `acchistory_userId` TINYINT(3) UNSIGNED NOT NULL,
+ `acchistory_userEditId` TINYINT(3) UNSIGNED NOT NULL,
+ `acchistory_customerId` TINYINT(3) UNSIGNED NOT NULL,
+ `acchistory_name` VARCHAR(255) NOT NULL,
+ `acchistory_categoryId` TINYINT(3) UNSIGNED NOT NULL,
+ `acchistory_login` VARCHAR(50) NOT NULL,
+ `acchistory_url` VARCHAR(255) DEFAULT NULL,
+ `acchistory_pass` VARBINARY(255) NOT NULL,
+ `acchistory_IV` VARBINARY(32) NOT NULL,
+ `acchistory_notes` TEXT NOT NULL,
+ `acchistory_countView` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `acchistory_countDecrypt` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `acchistory_dateAdd` DATETIME NOT NULL,
+ `acchistory_dateEdit` DATETIME NOT NULL,
+ `acchistory_isModify` BIT(1) DEFAULT NULL,
+ `acchistory_isDeleted` BIT(1) DEFAULT NULL,
+ `acchistory_mPassHash` VARBINARY(255) NOT NULL,
+ `accHistory_otherUserEdit` BIT(1) DEFAULT b'0',
+ `accHistory_otherGroupEdit` BIT(1) DEFAULT b'0',
PRIMARY KEY (`acchistory_id`),
KEY `IDX_accountId` (`acchistory_accountId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `accUsers` (
- `accuser_id` int(11) NOT NULL AUTO_INCREMENT,
- `accuser_accountId` int(10) unsigned NOT NULL,
- `accuser_userId` int(10) unsigned NOT NULL,
+ `accuser_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `accuser_accountId` INT(10) UNSIGNED NOT NULL,
+ `accuser_userId` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`accuser_id`),
KEY `idx_account` (`accuser_accountId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `accViewLinks` (
- `accviewlinks_id` int(10) unsigned NOT NULL DEFAULT '0',
- `accviewlinks_accountId` int(10) unsigned DEFAULT NULL,
- `accviewlinks_expireTime` int(10) unsigned DEFAULT NULL,
- `accviewlinks_expired` bit(1) DEFAULT b'0',
- `accviewlinks_userId` int(10) unsigned DEFAULT NULL,
- `accviewlinks_hash` varbinary(100) DEFAULT '',
- `accviewlinks_actionId` smallint(5) unsigned DEFAULT NULL,
+ `accviewlinks_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `accviewlinks_accountId` INT(10) UNSIGNED DEFAULT NULL,
+ `accviewlinks_expireTime` INT(10) UNSIGNED DEFAULT NULL,
+ `accviewlinks_expired` BIT(1) DEFAULT b'0',
+ `accviewlinks_userId` INT(10) 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`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = latin1;
CREATE TABLE `accounts` (
- `account_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `account_userGroupId` tinyint(3) unsigned NOT NULL,
- `account_userId` tinyint(3) unsigned NOT NULL,
- `account_userEditId` tinyint(3) unsigned NOT NULL,
- `account_customerId` int(10) unsigned NOT NULL,
- `account_name` varchar(50) NOT NULL,
- `account_categoryId` tinyint(3) unsigned NOT NULL,
- `account_login` varchar(50) DEFAULT NULL,
- `account_url` varchar(255) DEFAULT NULL,
- `account_pass` varbinary(255) NOT NULL,
- `account_IV` varbinary(32) NOT NULL,
- `account_notes` text,
- `account_countView` int(10) unsigned NOT NULL DEFAULT '0',
- `account_countDecrypt` int(10) unsigned NOT NULL DEFAULT '0',
- `account_dateAdd` datetime NOT NULL,
- `account_dateEdit` datetime NOT NULL,
- `account_otherGroupEdit` bit(1) DEFAULT b'0',
- `account_otherUserEdit` bit(1) DEFAULT b'0',
+ `account_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `account_userGroupId` TINYINT(3) UNSIGNED NOT NULL,
+ `account_userId` TINYINT(3) UNSIGNED NOT NULL,
+ `account_userEditId` TINYINT(3) UNSIGNED NOT NULL,
+ `account_customerId` INT(10) UNSIGNED NOT NULL,
+ `account_name` VARCHAR(50) NOT NULL,
+ `account_categoryId` TINYINT(3) UNSIGNED NOT NULL,
+ `account_login` VARCHAR(50) DEFAULT NULL,
+ `account_url` VARCHAR(255) DEFAULT NULL,
+ `account_pass` VARBINARY(255) NOT NULL,
+ `account_IV` VARBINARY(32) NOT NULL,
+ `account_notes` TEXT,
+ `account_countView` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `account_countDecrypt` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `account_dateAdd` DATETIME NOT NULL,
+ `account_dateEdit` DATETIME NOT NULL,
+ `account_otherGroupEdit` BIT(1) DEFAULT b'0',
+ `account_otherUserEdit` BIT(1) DEFAULT b'0',
PRIMARY KEY (`account_id`),
KEY `IDX_categoryId` (`account_categoryId`),
- KEY `IDX_userId` (`account_userGroupId`,`account_userId`),
+ KEY `IDX_userId` (`account_userGroupId`, `account_userId`),
KEY `IDX_customerId` (`account_customerId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `authTokens` (
- `authtoken_id` int(11) NOT NULL AUTO_INCREMENT,
- `authtoken_userId` int(11) NOT NULL,
- `authtoken_token` varbinary(100) NOT NULL,
- `authtoken_actionId` smallint(5) unsigned NOT NULL,
- `authtoken_createdBy` smallint(5) unsigned NOT NULL,
- `authtoken_startDate` int(10) unsigned NOT NULL,
+ `authtoken_id` INT(11) NOT NULL AUTO_INCREMENT,
+ `authtoken_userId` INT(11) NOT NULL,
+ `authtoken_token` VARBINARY(100) NOT NULL,
+ `authtoken_actionId` SMALLINT(5) UNSIGNED NOT NULL,
+ `authtoken_createdBy` SMALLINT(5) UNSIGNED NOT NULL,
+ `authtoken_startDate` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`authtoken_id`),
UNIQUE KEY `unique_authtoken_id` (`authtoken_id`),
- KEY `IDX_checkToken` (`authtoken_userId`,`authtoken_actionId`,`authtoken_token`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ KEY `IDX_checkToken` (`authtoken_userId`, `authtoken_actionId`, `authtoken_token`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `categories` (
- `category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `category_name` varchar(50) NOT NULL,
- `category_description` varchar(255) DEFAULT NULL,
+ `category_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `category_name` VARCHAR(50) NOT NULL,
+ `category_description` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`category_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `config` (
- `config_parameter` varchar(50) NOT NULL,
- `config_value` varchar(2000) NOT NULL,
+ `config_parameter` VARCHAR(50) NOT NULL,
+ `config_value` VARCHAR(2000) NOT NULL,
UNIQUE KEY `vacParameter` (`config_parameter`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `customers` (
- `customer_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `customer_name` varchar(100) NOT NULL,
- `customer_hash` varbinary(40) NOT NULL,
- `customer_description` varchar(255) DEFAULT NULL,
+ `customer_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `customer_name` VARCHAR(100) NOT NULL,
+ `customer_hash` VARBINARY(40) NOT NULL,
+ `customer_description` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`customer_id`),
- KEY `IDX_name` (`customer_name`,`customer_hash`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ KEY `IDX_name` (`customer_name`, `customer_hash`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `customFieldsDef` (
- `customfielddef_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `customfielddef_module` smallint(5) unsigned NOT NULL,
- `customfielddef_field` blob NOT NULL,
+ `customfielddef_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `customfielddef_module` SMALLINT(5) UNSIGNED NOT NULL,
+ `customfielddef_field` BLOB NOT NULL,
PRIMARY KEY (`customfielddef_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `customFieldsData` (
- `customfielddata_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `customfielddata_moduleId` smallint(5) unsigned NOT NULL,
- `customfielddata_itemId` int(10) unsigned NOT NULL,
- `customfielddata_defId` int(10) unsigned NOT NULL,
- `customfielddata_data` longblob,
- `customfielddata_iv` varbinary(128) DEFAULT NULL,
+ `customfielddata_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `customfielddata_moduleId` SMALLINT(5) UNSIGNED NOT NULL,
+ `customfielddata_itemId` INT(10) UNSIGNED NOT NULL,
+ `customfielddata_defId` INT(10) UNSIGNED NOT NULL,
+ `customfielddata_data` LONGBLOB,
+ `customfielddata_iv` VARBINARY(128) DEFAULT NULL,
PRIMARY KEY (`customfielddata_id`),
KEY `IDX_DEFID` (`customfielddata_defId`),
- KEY `IDX_DELETE` (`customfielddata_itemId`,`customfielddata_moduleId`),
- KEY `IDX_UPDATE` (`customfielddata_moduleId`,`customfielddata_itemId`,`customfielddata_defId`),
+ KEY `IDX_DELETE` (`customfielddata_itemId`, `customfielddata_moduleId`),
+ KEY `IDX_UPDATE` (`customfielddata_moduleId`, `customfielddata_itemId`, `customfielddata_defId`),
KEY `IDX_ITEM` (`customfielddata_itemId`),
KEY `IDX_MODULE` (`customfielddata_moduleId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `log` (
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `log_date` int(10) unsigned NOT NULL,
- `log_login` varchar(25) NOT NULL,
- `log_userId` tinyint(3) unsigned NOT NULL,
- `log_ipAddress` varchar(45) NOT NULL,
- `log_action` varchar(50) NOT NULL,
- `log_description` text NOT NULL,
- `log_level` varchar(20) NOT NULL,
+ `log_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `log_date` INT(10) UNSIGNED NOT NULL,
+ `log_login` VARCHAR(25) NOT NULL,
+ `log_userId` TINYINT(3) UNSIGNED NOT NULL,
+ `log_ipAddress` VARCHAR(45) NOT NULL,
+ `log_action` VARCHAR(50) NOT NULL,
+ `log_description` TEXT NOT NULL,
+ `log_level` VARCHAR(20) NOT NULL,
PRIMARY KEY (`log_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `usrData` (
- `user_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `user_name` varchar(80) NOT NULL,
- `user_groupId` tinyint(3) unsigned NOT NULL,
- `user_secGroupId` tinyint(3) unsigned DEFAULT NULL,
- `user_login` varchar(50) NOT NULL,
- `user_pass` varbinary(255) NOT NULL,
- `user_mPass` varbinary(255) DEFAULT NULL,
- `user_mIV` varbinary(32) NOT NULL,
- `user_email` varchar(80) DEFAULT NULL,
- `user_notes` text,
- `user_count` int(10) unsigned NOT NULL DEFAULT '0',
- `user_profileId` tinyint(4) NOT NULL,
- `user_lastLogin` datetime DEFAULT NULL,
- `user_lastUpdate` datetime DEFAULT NULL,
- `user_lastUpdateMPass` int(11) unsigned NOT NULL DEFAULT '0',
- `user_isAdminApp` bit(1) NOT NULL DEFAULT b'0',
- `user_isAdminAcc` bit(1) NOT NULL DEFAULT b'0',
- `user_isLdap` bit(1) NOT NULL DEFAULT b'0',
- `user_isDisabled` bit(1) NOT NULL DEFAULT b'0',
- `user_hashSalt` varbinary(128) NOT NULL,
- `user_isMigrate` bit(1) DEFAULT b'0',
- `user_isChangePass` bit(1) DEFAULT b'0',
- `user_preferences` blob,
+ `user_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `user_name` VARCHAR(80) NOT NULL,
+ `user_groupId` TINYINT(3) UNSIGNED NOT NULL,
+ `user_secGroupId` TINYINT(3) UNSIGNED DEFAULT NULL,
+ `user_login` VARCHAR(50) NOT NULL,
+ `user_pass` VARBINARY(255) NOT NULL,
+ `user_mPass` VARBINARY(255) DEFAULT NULL,
+ `user_mIV` VARBINARY(32) NOT NULL,
+ `user_email` VARCHAR(80) DEFAULT NULL,
+ `user_notes` TEXT,
+ `user_count` INT(10) UNSIGNED NOT NULL DEFAULT '0',
+ `user_profileId` TINYINT(4) NOT NULL,
+ `user_lastLogin` DATETIME DEFAULT NULL,
+ `user_lastUpdate` DATETIME DEFAULT NULL,
+ `user_lastUpdateMPass` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `user_isAdminApp` BIT(1) NOT NULL DEFAULT b'0',
+ `user_isAdminAcc` BIT(1) NOT NULL DEFAULT b'0',
+ `user_isLdap` BIT(1) NOT NULL DEFAULT b'0',
+ `user_isDisabled` BIT(1) NOT NULL DEFAULT b'0',
+ `user_hashSalt` VARBINARY(128) NOT NULL,
+ `user_isMigrate` BIT(1) DEFAULT b'0',
+ `user_isChangePass` BIT(1) DEFAULT b'0',
+ `user_preferences` BLOB,
PRIMARY KEY (`user_id`),
UNIQUE KEY `IDX_login` (`user_login`),
KEY `IDX_pass` (`user_pass`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `usrGroups` (
- `usergroup_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `usergroup_name` varchar(50) NOT NULL,
- `usergroup_description` varchar(255) DEFAULT NULL,
+ `usergroup_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `usergroup_name` VARCHAR(50) NOT NULL,
+ `usergroup_description` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`usergroup_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `usrPassRecover` (
- `userpassr_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `userpassr_userId` smallint(5) unsigned NOT NULL,
- `userpassr_hash` varbinary(40) NOT NULL,
- `userpassr_date` int(10) unsigned NOT NULL,
- `userpassr_used` bit(1) NOT NULL,
+ `userpassr_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `userpassr_userId` SMALLINT(5) UNSIGNED NOT NULL,
+ `userpassr_hash` VARBINARY(40) NOT NULL,
+ `userpassr_date` INT(10) UNSIGNED NOT NULL,
+ `userpassr_used` BIT(1) NOT NULL,
PRIMARY KEY (`userpassr_id`),
- KEY `IDX_userId` (`userpassr_userId`,`userpassr_date`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ KEY `IDX_userId` (`userpassr_userId`, `userpassr_date`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `usrProfiles` (
- `userprofile_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `userprofile_name` varchar(45) NOT NULL,
- `userProfile_profile` blob NOT NULL,
+ `userprofile_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `userprofile_name` VARCHAR(45) NOT NULL,
+ `userProfile_profile` BLOB NOT NULL,
PRIMARY KEY (`userprofile_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `usrToGroups` (
- `usertogroup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `usertogroup_userId` int(10) unsigned NOT NULL,
- `usertogroup_groupId` int(10) unsigned NOT NULL,
+ `usertogroup_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `usertogroup_userId` INT(10) UNSIGNED NOT NULL,
+ `usertogroup_groupId` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`usertogroup_id`),
KEY `IDX_usertogroup_userId` (`usertogroup_userId`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
-CREATE TABLE `publicLinks`(
- `publicLink_id` INT NOT NULL AUTO_INCREMENT,
- `publicLink_itemId` INT,
- `publicLink_hash` VARBINARY(100) NOT NULL,
+CREATE TABLE `publicLinks` (
+ `publicLink_id` INT NOT NULL AUTO_INCREMENT,
+ `publicLink_itemId` INT,
+ `publicLink_hash` VARBINARY(100) NOT NULL,
`publicLink_linkData` LONGBLOB,
PRIMARY KEY (`publicLink_id`),
KEY `IDX_itemId` (`publicLink_itemId`),
UNIQUE KEY `IDX_hash` (`publicLink_hash`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
CREATE TABLE `accFavorites` (
`accfavorite_accountId` SMALLINT UNSIGNED NOT NULL,
- `accfavorite_userId` SMALLINT UNSIGNED NOT NULL,
+ `accfavorite_userId` SMALLINT UNSIGNED NOT NULL,
INDEX `fk_accFavorites_accounts_idx` (`accfavorite_accountId` ASC),
INDEX `fk_accFavorites_users_idx` (`accfavorite_userId` ASC),
INDEX `search_idx` (`accfavorite_accountId` ASC, `accfavorite_userId` ASC),
@@ -257,13 +295,35 @@ CREATE TABLE `accFavorites` (
REFERENCES `usrData` (`user_id`)
ON DELETE CASCADE
ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
+CREATE TABLE `tags` (
+ `tag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `tag_name` VARCHAR(45) NOT NULL,
+ `tag_hash` BINARY(20) NOT NULL,
+ PRIMARY KEY (`tag_id`),
+ INDEX `IDX_name` (`tag_name` ASC),
+ UNIQUE INDEX `tag_hash_UNIQUE` (`tag_hash` ASC)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+;
+
+CREATE TABLE `accTags` (
+ `acctag_accountId` INT UNSIGNED NOT NULL,
+ `acctag_tagId` INT UNSIGNED NOT NULL,
+ INDEX `IDX_id` (`acctag_accountId` ASC, `acctag_tagId` ASC)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+/*!40103 SET TIME_ZONE = @OLD_TIME_ZONE */;
+/*!40101 SET SQL_MODE = @OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS = @OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS = @OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES = @OLD_SQL_NOTES */;
\ No newline at end of file
diff --git a/inc/themes/classic/aux-customfields.inc b/inc/themes/classic/aux-customfields.inc
index 70e3de1f..962abc18 100644
--- a/inc/themes/classic/aux-customfields.inc
+++ b/inc/themes/classic/aux-customfields.inc
@@ -17,12 +17,12 @@
required) ? 'required' : ''; ?>>
- type === \SP\Mgmt\CustomFields::TYPE_PASSWORD && !$showViewPass): ?>
+ type === \SP\Mgmt\CustomFields\CustomFields::TYPE_PASSWORD && !$showViewPass): ?>
****
value; ?>
diff --git a/inc/themes/classic/tags.inc b/inc/themes/classic/tags.inc
new file mode 100644
index 00000000..9abfe361
--- /dev/null
+++ b/inc/themes/classic/tags.inc
@@ -0,0 +1,34 @@
+
+
| + | + + + | +
| + |
+ |
+