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 @@ + +
+

+ +
+ + + + + + + +
+ +
+ + + + + + + +
+
+
+ +
+
\ No newline at end of file diff --git a/inc/themes/material-blue/account-details.inc b/inc/themes/material-blue/account-details.inc index 18cd4f7c..3df100b3 100644 --- a/inc/themes/material-blue/account-details.inc +++ b/inc/themes/material-blue/account-details.inc @@ -20,16 +20,17 @@ $userName) { - if ($userId != $accountData->account_userId) { - if (in_array($userId, $accountOtherUsers)) { - $accUsers[] = $userName; - } + $users = []; + + foreach ($accountOtherUsers as $otherUser) { + /** @var $otherUser \SP\DataModel\UserBasicData */ + if ($otherUser->getUserId() != $accountData->account_userId){ + $users[] = $otherUser->getUserName(); } } $usersEdit = ($accountData->account_otherUserEdit) ? '(+)' : ''; - echo $usersEdit . ' ' . implode(" | ", $accUsers); + echo $usersEdit . ' ' . implode(" | ", $users); ?> @@ -39,17 +40,18 @@ $groupName) { - if ($groupId != $accountData->account_userGroupId) { - if (in_array($groupId, $accountOtherGroups)) { - $accGroups[] = $groupName; - } + $groups = []; + + foreach ($accountOtherGroups as $otherGroup) { + /** @var $otherGroup \SP\DataModel\GroupData */ + if ($otherGroup->getUsergroupId() != $accountData->account_userGroupId) { + $groups[] = $otherGroup->getUsergroupName(); } } $groupsEdit = ($accountData->account_otherGroupEdit) ? '(+)' : ''; - echo $groupsEdit . ' ' . implode(" | ", $accGroups); + echo $groupsEdit . ' ' . implode(" | ", $groups); ?> diff --git a/inc/themes/material-blue/account.inc b/inc/themes/material-blue/account.inc index 047fc0ee..e4624583 100644 --- a/inc/themes/material-blue/account.inc +++ b/inc/themes/material-blue/account.inc @@ -28,7 +28,8 @@
-
@@ -50,7 +51,8 @@

- @@ -99,7 +101,8 @@
-
@@ -114,7 +117,8 @@
@@ -138,7 +142,8 @@
- @@ -148,119 +153,39 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + 0): ?> - + $name): ?> @@ -277,13 +202,83 @@ + + + + + + + + + + + + + + +
+ + +
+ +
+
- + @@ -314,13 +309,58 @@ diff --git a/inc/themes/material-blue/aux-customfields.inc b/inc/themes/material-blue/aux-customfields.inc index 8e3c2c57..178dd236 100644 --- a/inc/themes/material-blue/aux-customfields.inc +++ b/inc/themes/material-blue/aux-customfields.inc @@ -18,7 +18,7 @@ required) ? 'required' : ''; ?>> @@ -26,9 +26,9 @@ for="name; ?>">text; ?>
- type === \SP\Mgmt\CustomFields::TYPE_PASSWORD && !$showViewPass): ?> + type === \SP\Mgmt\CustomFields\CustomFields::TYPE_PASSWORD && !$showViewPass): ?> **** - type === \SP\Mgmt\CustomFields::TYPE_COLOR): ?> + type === \SP\Mgmt\CustomFields\CustomFields::TYPE_COLOR): ?> diff --git a/inc/themes/material-blue/config-site.inc b/inc/themes/material-blue/config-site.inc index c945e082..aed4d35a 100644 --- a/inc/themes/material-blue/config-site.inc +++ b/inc/themes/material-blue/config-site.inc @@ -21,7 +21,7 @@
- $langValue): ?> @@ -42,7 +42,7 @@ + + - + - + $name): ?> + $name): ?> @@ -200,7 +200,7 @@ - - ' . _('Deshabilitada') . ''; ?> + diff --git a/inc/themes/material-blue/preferences-site.inc b/inc/themes/material-blue/preferences-site.inc index ccd68002..0f83790e 100644 --- a/inc/themes/material-blue/preferences-site.inc +++ b/inc/themes/material-blue/preferences-site.inc @@ -13,7 +13,7 @@ - $langValue): ?> @@ -25,7 +25,7 @@ - + +

- + + + + + + star + - - - star +
'); } else { diff --git a/inc/themes/material-blue/tags.inc b/inc/themes/material-blue/tags.inc new file mode 100644 index 00000000..1d21111a --- /dev/null +++ b/inc/themes/material-blue/tags.inc @@ -0,0 +1,42 @@ + +
+

+ +
+ + + + + + + +
+
+ + +
+
+ + + + + + + +
+
+
+ +
+
\ No newline at end of file diff --git a/inc/themes/material-blue/tokens.inc b/inc/themes/material-blue/tokens.inc index 8b019d4f..79de8a43 100644 --- a/inc/themes/material-blue/tokens.inc +++ b/inc/themes/material-blue/tokens.inc @@ -8,7 +8,7 @@ - + $name): ?> authtoken_actionId) ? 'selected' : ''; ?> diff --git a/inc/themes/material-blue/users.inc b/inc/themes/material-blue/users.inc index 684ee5db..bb9ad28c 100644 --- a/inc/themes/material-blue/users.inc +++ b/inc/themes/material-blue/users.inc @@ -47,7 +47,7 @@ > - + $name): ?> diff --git a/inc/themes/material-blue/wiki.inc b/inc/themes/material-blue/wiki.inc index 521080cb..36e2e15a 100644 --- a/inc/themes/material-blue/wiki.inc +++ b/inc/themes/material-blue/wiki.inc @@ -287,30 +287,10 @@ \ No newline at end of file diff --git a/js/chosen.jquery.min.js b/js/chosen.jquery.min.js deleted file mode 100644 index 22e38658..00000000 --- a/js/chosen.jquery.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/* Chosen v1.4.2 | (c) 2011-2015 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */ -(function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),title:a.title?a.title:void 0,children:0,disabled:a.disabled,classes:a.className}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,title:a.title?a.title:void 0,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,group_label:null!=b?this.parsed[b].label:null,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.choice_label=function(a){return this.include_group_label_in_selected&&null!=a.group_label?""+a.group_label+""+a.html:a.html},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(c)));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):"":""},AbstractChosen.prototype.result_add_group=function(a){var b,c;return a.search_match||a.group_match?a.active_options>0?(b=[],b.push("group-result"),a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),b.search_text=b.group?b.label:b.html,(!b.group||this.group_search)&&(b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+""+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+""+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d instanceof Chosen?d.destroy():d instanceof Chosen||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("
",c),this.is_multiple?this.container.html('
    '):this.container.html(''+this.default_text+'
      '),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},Chosen.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){return a.container_mousedown(b),b.preventDefault()}),this.container.bind("touchend.chosen",function(b){return a.container_mouseup(b),b.preventDefault()}),this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=a.originalEvent.deltaY||-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("
    • ",{"class":"search-choice"}).html(""+this.choice_label(b)+""),b.disabled?c.addClass("search-choice-disabled"):(d=a("",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(this.choice_label(c)),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,a.preventDefault(),this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after(''),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return a("
      ").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('
    • '+this.results_none_found+' ""
    • '),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("
      ",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}).call(this); \ No newline at end of file diff --git a/js/functions.js b/js/functions.js index d71d61c7..d520b3e0 100644 --- a/js/functions.js +++ b/js/functions.js @@ -186,27 +186,18 @@ sysPass.Util.Common = function () { } document.frmSearch.search.value = ""; - $('#frmSearch').find('select').prop('selectedIndex', 0).trigger("chosen:updated"); + $('#frmSearch').find('select').each(function(){ + $(this)[0].selectize.clear(); + }); $('#frmSearch').find('input[name="start"], input[name="skey"], input[name="sorder"]').val(0); $('#frmSearch').find('input[name="searchfav"]').val(0).change(); order.key = 0; order.dir = 0; }; - // Funcion para crear un desplegable con opciones - var mkChosen = function (options) { - $('#' + options.id).chosen({ - allow_single_deselect: true, - placeholder_text_single: options.placeholder, - disable_search_threshold: 10, - no_results_text: options.noresults, - width: "200px" - }); - }; - // Función para la búsqueda de cuentas mediante filtros var accSearch = function (continous, event) { - var lenTxtSearch = $('#txtSearch').val().length; + var lenTxtSearch = $('#search').val().length; if (typeof event !== 'undefined' && ((event.keyCode < 48 && event.keyCode !== 13) || (event.keyCode > 105 && event.keyCode < 123))) { @@ -1225,74 +1216,38 @@ sysPass.Util.Common = function () { }; // Detectar los campos select y añadir funciones - var chosenDetect = function () { - var selectWidth = "250px"; - var searchTreshold = 10; + var selectDetect = function () { + $(".sel-chosen-usergroup").selectize(); - $(".sel-chosen-usergroup").chosen({ - placeholder_text_single: LANG[21], - placeholder_text_multiple: LANG[21], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth - }); + $(".sel-chosen-user").selectize(); - $(".sel-chosen-user").chosen({ - placeholder_text_single: LANG[22], - placeholder_text_multiple: LANG[22], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth - }); - - $(".sel-chosen-profile").chosen({ - placeholder_text_single: LANG[23], - placeholder_text_multiple: LANG[23], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth - }); + $(".sel-chosen-profile").selectize(); $(".sel-chosen-customer").each(function () { - var deselect = $(this).hasClass('sel-chosen-deselect'); + var plugins = ($(this).hasClass('sel-chosen-deselect')) ? {'clear_selection': {title: LANG[51]}} : {}; - $(this).chosen({ - allow_single_deselect: deselect, - placeholder_text_single: LANG[24], - placeholder_text_multiple: LANG[24], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth + $(this).selectize({ + plugins: plugins }); }); $(".sel-chosen-category").each(function () { - var deselect = $(this).hasClass('sel-chosen-deselect'); + var plugins = ($(this).hasClass('sel-chosen-deselect')) ? {'clear_selection': {title: LANG[51]}} : {}; - $(this).chosen({ - allow_single_deselect: deselect, - placeholder_text_single: LANG[25], - placeholder_text_multiple: LANG[25], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth + $(this).selectize({ + plugins: plugins }); }); $(".sel-chosen-action").each(function () { - var deselect = $(this).hasClass('sel-chosen-deselect'); + var plugins = ($(this).hasClass('sel-chosen-deselect')) ? {'clear_selection': {title: LANG[51]}} : {}; - $(this).chosen({ - allow_single_deselect: deselect, - placeholder_text_single: LANG[39], - placeholder_text_multiple: LANG[39], - disable_search_threshold: searchTreshold, - no_results_text: LANG[26], - width: selectWidth + $(this).selectize({ + plugins: plugins }); }); - $(".sel-chosen-ns").chosen({disable_search: true, width: selectWidth}); + $(".sel-chosen-ns").selectize(); }; /** @@ -1476,7 +1431,7 @@ sysPass.Util.Common = function () { checkUpds: checkUpds, clearEventlog: clearEventlog, clearSearch: clearSearch, - chosenDetect: chosenDetect, + chosenDetect: selectDetect, configMgmt: configMgmt, delAccount: delAccount, delFile: delFile, diff --git a/js/functions.min.js b/js/functions.min.js index 8d87a74c..8abf3a31 100644 --- a/js/functions.min.js +++ b/js/functions.min.js @@ -1 +1 @@ -var sysPass=sysPass||{};sysPass.createNS=function(d){var e=d.split(".");var c=sysPass;if(e[0]==="sysPass"){e=e.slice(1)}for(var a=0;a105&&event.keyCode<123))){return}if(lenTxtSearch<3&&continous===1&&lenTxtSearch>window.lastlen&&event.keyCode!==13){return}window.lastlen=lenTxtSearch;$("#frmSearch").find('input[name="start"]').val(0);doSearch()};var searchSort=function(skey,dir,start){if(typeof skey==="undefined"||typeof start==="undefined"){return false}$("#frmSearch").find('input[name="skey"]').val(skey);$("#frmSearch").find('input[name="sorder"]').val(dir);$("#frmSearch").find('input[name="start"]').val(start);doSearch()};var doSearch=function(){var frmData=$("#frmSearch").serialize();$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_search.php",data:frmData,success:function(json){$("#resBuscar").html(json.html);if(typeof json.sk!=="undefined"){$("#frmSearch").find(":input[name='sk']").val(json.sk)}},error:function(){$("#resBuscar").html(resMsg("nofancyerror"))}})};var showSearchOrder=function(){if(order.key){$("#search-sort-"+order.key).addClass("filterOn");if(order.dir===0){$("#search-sort-"+order.key).append('')}else{$("#search-sort-"+order.key).append('')}}};var navLog=function(start,current){if(typeof start==="undefined"){return false}$.ajax({type:"POST",dataType:"html",url:APP_ROOT+"/ajax/ajax_eventlog.php",data:{start:start,current:current},success:function(response){$("#content").html(response);scrollUp()},error:function(){$("#content").html(resMsg("nofancyerror"))}})};var viewPass=function(id,show,history){$.ajax({type:"POST",url:APP_ROOT+"/ajax/ajax_viewpass.php",dataType:"json",async:false,data:{accountid:id,full:show,isHistory:history,isAjax:1},success:function(json){if(json.status===10){doLogout();return}if(show==false){$("#clip-pass-text").html(json.accpass);passToClip=1;return}$("
      ").dialog({modal:true,title:LANG[47],width:"auto",open:function(){var thisDialog=$(this);var content;var pass="";var clipboardUserButton='";var clipboardPassButton='";var useImage=json.useimage;var user='

      '+json.acclogin+"

      ";if(json.status===0){if(useImage===0){pass='

      '+json.accpass+"

      "}else{pass='';clipboardPassButton=""}content=user+pass+'
      '+clipboardUserButton+clipboardPassButton+"
      "}else{content=''+json.description+"";thisDialog.dialog("option","buttons",[{text:"Ok",icons:{primary:"ui-icon-close"},click:function(){thisDialog.dialog("close")}}])}thisDialog.html(content);thisDialog.dialog("option","position","center");thisDialog.parent().on("mouseleave",function(){clearTimeout(timeout);timeout=setTimeout(function(){thisDialog.dialog("close")},30000)})},close:function(){clearTimeout(timeout);$(this).dialog("destroy")}})}})};var getUrlVars=function(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var i=0;i"+LANG[13]+"

      ";resMsg("error",txt)}}});return false};var doLogout=function(){var url=window.location.search;if(url.length>0){location.href="index.php"+url+"&logout=1"}else{location.href="index.php?logout=1"}};var checkLogout=function(){var session=getUrlVars()["session"];if(session===0){resMsg("warn",LANG[2],"","location.search = ''")}};var redirect=function(url){location.href=url};var saveAccount=function(frm){var data=$("#"+frm).serialize();var id=$('input[name="accountid"]').val();var action=$('input[name="next"]').val();$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_accountSave.php",data:data,success:function(json){var status=json.status;var description=json.description;if(status===0){resMsg("ok",description);if(action&&id){doAction(action,1,id)}else{if(action){doAction(action,1)}}}else{if(status===10){doLogout()}else{resMsg("error",description)}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var delAccount=function(id,action,sk){var data={accountid:id,actionId:action,sk:sk};var atext='

      '+LANG[3]+"

      ";var url="/ajax/ajax_accountSave.php";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var sendRequest=function(){var url="/ajax/ajax_sendRequest.php";var data=$("#frmRequestModify").serialize();sendAjax(data,url)};var configMgmt=function(action,obj){var url;switch(action){case"config":url="/ajax/ajax_configSave.php";break;case"export":url="/ajax/ajax_backup.php";break;case"import":url="/ajax/ajax_migrate.php";break;case"preferences":url="/ajax/ajax_userPrefsSave.php";break;default:return}var data=$(obj).serialize();sendAjax(data,url)};var downFile=function(id,sk,actionId,download){var data={fileId:id,sk:sk,actionId:actionId};if(typeof download==="undefined"){$.ajax({type:"POST",cache:false,url:APP_ROOT+"/ajax/ajax_files.php",data:data,success:function(response){if(typeof response.status!=="undefined"&&response.status===1){resMsg("error",response.description);return}if(response){$.fancybox(response,{padding:[10,10,10,10]});setTimeout(function(){$.fancybox.update()},1000)}else{resMsg("error",LANG[14])}}})}else{if(download===true){$.fileDownload(APP_ROOT+"/ajax/ajax_files.php",{httpMethod:"POST",data:data})}}};var viewFile=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var data={fileId:itemId,sk:sk,actionId:actionId};$.ajax({type:"POST",cache:false,url:APP_ROOT+"/ajax/ajax_files.php",data:data,success:function(response){if(typeof response.status!=="undefined"&&response.status===1){resMsg("error",response.description);return}if(response){$.fancybox(response,{padding:[10,10,10,10]});setTimeout(function(){$.fancybox.update()},1000)}else{resMsg("error",LANG[14])}}})};var getFiles=function(id,isDel,sk){var data={id:id,del:isDel,sk:sk};$.ajax({type:"GET",cache:false,url:APP_ROOT+"/ajax/ajax_getFiles.php",data:data,success:function(response){$("#downFiles").html(response)}})};var delFile=function(id,sk,accountId,actionId){var atext='

      '+LANG[15]+"

      ";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){var data={fileId:id,actionId:actionId,sk:sk};$.post(APP_ROOT+"/ajax/ajax_files.php",data,function(data){if(data.status===0){var url=APP_ROOT+"/ajax/ajax_getFiles.php?id="+accountId+"&del=1&isAjax=1&sk="+sk;$("#downFiles").load(url);resMsg("ok",data.description)}else{resMsg("error",data.description)}})},function(e){e.preventDefault();alertify.error(LANG[44])})};var fileUpload=function(opts){var options={targetId:"",url:""};var requestDoneAction,requestData={},beforeSendAction;var setFn={setRequestDoneAction:function(a){requestDoneAction=a},setRequestData:function(d){requestData=d},setBeforeSendAction:function(a){beforeSendAction=a}};options=opts;if(typeof options.targetId==="undefined"||options.targetId===""){return setFn}var dropzone=document.getElementById(options.targetId);var sendFile=function(file){if(typeof options.url==="undefined"||options.url===""){return false}var fd=new FormData();fd.append("inFile",file);fd.append("isAjax",1);Object.keys(requestData).forEach(function(key){fd.append(key,requestData[key])});$.ajax({type:"POST",dataType:"json",cache:false,processData:false,contentType:false,url:APP_ROOT+options.url,data:fd,success:function(json){var status=json.status;var description=json.description;if(status===0){if(typeof requestDoneAction==="function"){requestDoneAction()}resMsg("ok",description)}else{if(status===10){doLogout()}else{resMsg("error",description)}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var checkFileSize=function(size){return(size/1000>MAX_FILE_SIZE)};var checkFileExtension=function(name){var file_exts_ok=dropzone.getAttribute("data-files-ext").toLowerCase().split(",");for(var i=0;i<=file_exts_ok.length;i++){if(name.indexOf(file_exts_ok[i])!==-1){return true}}return false};var handleFiles=function(filesArray){if(filesArray.length>5){resMsg("error",LANG[17]+" (Max: 5)");return}for(var i=0;i"+file.name+" (Max: "+MAX_FILE_SIZE+")")}else{if(!checkFileExtension(file.name)){resMsg("error",LANG[19]+"
      "+file.name)}else{sendFile(filesArray[i])}}}};var init=function(){dropzone.ondragover=dropzone.ondragenter=function(event){event.stopPropagation();event.preventDefault()};dropzone.ondrop=function(event){event.stopPropagation();event.preventDefault();if(typeof beforeSendAction==="function"){beforeSendAction()}handleFiles(event.dataTransfer.files)};var fallback=initForm(false);dropzone.onclick=function(){fallback.click()}};var initForm=function(display){var form=document.getElementById("fileUploadForm");var formTags=form.getElementsByTagName("input");form.style.display=(display===false)?"none":"";if(formTags[0].type==="file"){formTags[0].addEventListener("change",function(){if(typeof beforeSendAction==="function"){beforeSendAction()}handleFiles(this.files)},false)}return formTags[0]};if(window.File&&window.FileList&&window.FileReader){init()}else{initForm(true)}return setFn};var sendAjax=function(data,url){$.ajax({type:"POST",dataType:"json",url:APP_ROOT+url,data:data,success:function(json){var status=json.status;var description=json.description;var action=json.action;switch(status){case 0:$.fancybox.close();resMsg("ok",description,undefined,action);break;case 1:$.fancybox.close();$(":input[type=password]").val("");resMsg("error",description,undefined,action);break;case 2:$("#resFancyAccion").html(''+description+"").show();break;case 3:$.fancybox.close();resMsg("warn",description,undefined,action);break;case 10:doLogout();break;default:return}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var usrUpdPass=function(object,actionId,sk){var userId=$(object).attr("data-itemid");var data={userId:userId,actionId:actionId,sk:sk,isAjax:1};$.ajax({type:"GET",cache:false,url:APP_ROOT+"/ajax/ajax_usrpass.php",data:data,success:function(data){if(data.length===0){doLogout()}else{$.fancybox(data,{padding:0})}}})};var appMgmtData=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,isAjax:1};var url=APP_ROOT+"/ajax/ajax_appMgmtData.php";$.ajax({type:"POST",dataType:"html",url:url,data:data,success:function(response){$.fancybox(response,{padding:[0,10,10,10]})},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var appMgmtDelete=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var nextActionId=$(obj).attr("data-nextactionid");var atext='

      '+LANG[12]+"

      ";var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,onCloseAction:nextActionId};alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var appMgmtSave=function(frmId){var url="/ajax/ajax_appMgmtSave.php";var data=$("#"+frmId).serialize();sendAjax(data,url)};var appMgmtSearch=function(form){var targetId=form.elements.target.value;var data=$(form).serialize();appMgmtSearchAjax(data,targetId);return false};var appMgmtNav=function(formId,count,start){var form=$("#"+formId);var targetId=form.find("[name=target]").val();var sk=form.find("[name=sk]").val();var data=form.serialize()+"&sk="+sk+"&start="+start+"&count="+count;appMgmtSearchAjax(data,targetId);return false};var appMgmtSearchAjax=function(data,targetId){$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_appMgmtSearch.php",data:data,success:function(json){if(json.status===0){$("#"+targetId).html(json.html);$("form").find("[name=sk]").val(json.sk)}else{$("#"+targetId).html(resMsg("nofancyerror",json.description))}},error:function(){$("#"+targetId).html(resMsg("nofancyerror","error"))}})};var linksMgmtSave=function(itemId,actionId,sk){var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,isAjax:1};alertify.okBtn(LANG[40]).cancelBtn(LANG[41]).confirm(LANG[48],function(e){$.extend(data,{notify:1});sendAjax(data,url)},function(e){e.preventDefault();sendAjax(data,url)})};var linksMgmtRefresh=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var nextActionId=$(obj).attr("data-nextactionid");var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,onCloseAction:nextActionId};sendAjax(data,url)};var checkUpds=function(){$.ajax({type:"GET",dataType:"html",url:APP_ROOT+"/ajax/ajax_checkUpds.php",timeout:10000,success:function(response){$("#updates").html(response);if(typeof componentHandler!=="undefined"){componentHandler.upgradeDom()}},error:function(jqXHR,textStatus,errorThrown){$("#updates").html("!")}})};var clearEventlog=function(sk){var atext='

      '+LANG[20]+"

      ";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){var data={clear:1,sk:sk,isAjax:1};var url="/ajax/ajax_eventlog.php";sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var showOptional=function(me){$(me).hide();var actions=$(me).parent().children(".actions-optional");actions.show(250)};var getTime=function(){var t=new Date();return t.getTime()};var checkPassLevel=function(password,dst){passwordData.passLength=password.length;outputResult(zxcvbn(password),dst)};var outputResult=function(level,dstId){var complexity,selector=".passLevel-"+dstId;var score=level.score;complexity=$(selector);complexity.show();complexity.removeClass("weak good strong strongest");if(passwordData.passLength===0){complexity.attr("title","").empty()}else{if(passwordData.passLength");switch(type){case"ok":alertify.closeLogOnClick(true).delay(15000).success(txt);break;case"error":alertify.closeLogOnClick(true).delay(15000).error(txt);break;case"warn":alertify.delay(30000).log(txt);break;case"nofancyerror":html='

      Oops...
      '+LANG[1]+"
      "+txt+"

      ";return html;default:alertify.error(txt);break}if(typeof action!=="undefined"){eval(action)}};var checkLdapConn=function(formId){var form="#"+formId;var ldapBindPass=$(form).find("[name=ldap_bindpass]").val();var data={type:"ldap",ldap_server:$(form).find("[name=ldap_server]").val(),ldap_base:$(form).find("[name=ldap_base]").val(),ldap_group:$(form).find("[name=ldap_group]").val(),ldap_binduser:$(form).find("[name=ldap_binduser]").val(),ldap_bindpass:(PK!=="")?encrypt.encrypt(ldapBindPass):ldapBindPass,isAjax:1,sk:$(form).find("[name=sk]").val()};sendAjax(data,"/ajax/ajax_checkConnection.php")};var checkDokuWikiConn=function(formId){var form="#"+formId;var data={type:"dokuwiki",dokuwiki_url:$(form).find("[name=dokuwiki_url]").val(),dokuwiki_user:$(form).find("[name=dokuwiki_user]").val(),dokuwiki_pass:$(form).find("[name=dokuwiki_pass]").val(),isAjax:1,sk:$(form).find("[name=sk]").val()};$.ajax({type:"POST",url:APP_ROOT+"/ajax/ajax_checkConnection.php",data:data,success:function(response){if(response.status===1){resMsg("error",response.description)}else{if(response.status===0){resMsg("ok",response.description);$("#dokuWikiResCheck").html(response.data)}}}})};var goLogin=function(){setTimeout(function(){location.href="index.php"},2000)};var getBrowser=function(){var browser;var ua=navigator.userAgent;var re=new RegExp("(MSIE|Firefox)[ /]?([0-9]{1,}[.0-9]{0,})","i");if(re.exec(ua)!==null){browser=RegExp.$1}return browser};var chosenDetect=function(){var selectWidth="250px";var searchTreshold=10;$(".sel-chosen-usergroup").chosen({placeholder_text_single:LANG[21],placeholder_text_multiple:LANG[21],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth});$(".sel-chosen-user").chosen({placeholder_text_single:LANG[22],placeholder_text_multiple:LANG[22],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth});$(".sel-chosen-profile").chosen({placeholder_text_single:LANG[23],placeholder_text_multiple:LANG[23],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth});$(".sel-chosen-customer").each(function(){var deselect=$(this).hasClass("sel-chosen-deselect");$(this).chosen({allow_single_deselect:deselect,placeholder_text_single:LANG[24],placeholder_text_multiple:LANG[24],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth})});$(".sel-chosen-category").each(function(){var deselect=$(this).hasClass("sel-chosen-deselect");$(this).chosen({allow_single_deselect:deselect,placeholder_text_single:LANG[25],placeholder_text_multiple:LANG[25],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth})});$(".sel-chosen-action").each(function(){var deselect=$(this).hasClass("sel-chosen-deselect");$(this).chosen({allow_single_deselect:deselect,placeholder_text_single:LANG[39],placeholder_text_multiple:LANG[39],disable_search_threshold:searchTreshold,no_results_text:LANG[26],width:selectWidth})});$(".sel-chosen-ns").chosen({disable_search:true,width:selectWidth})};var checkboxDetect=function(container){$(container).find(".checkbox").button({icons:{primary:"ui-icon-transferthick-e-w"}}).click(function(){if($(this).prop("checked")===true){$(this).button("option","label",LANG[40])}else{$(this).button("option","label",LANG[41])}})};var encryptFormValue=function(inputId){var input=$(inputId);var curValue=input.val();var nextName=inputId+"-encrypted";var nextInput=input.next(':input[name="'+nextName+'"]');if((curValue!==""&&nextInput.attr("name")!==nextName)||(curValue!==""&&nextInput.attr("name")===nextName&&parseInt(input.next().val())!==curValue.length)){var passEncrypted=encrypt.encrypt(curValue);input.val(passEncrypted);if(nextInput.length>0){nextInput.val(passEncrypted.length)}else{input.after('')}}};var initializeClipboard=function(){var clipboard=new Clipboard(".clip-pass-button",{text:function(trigger){sysPassUtil.Common.viewPass(trigger.getAttribute("data-account-id"),0);return $("#clip-pass-text").html()}});clipboard.on("success",function(e){sysPassUtil.Common.resMsg("ok",LANG[45])});clipboard.on("error",function(e){sysPassUtil.Common.resMsg("error",LANG[46])});var clipboardPass=new Clipboard(".dialog-clip-pass-button");var clipboardUser=new Clipboard(".dialog-clip-user-button");clipboardPass.on("success",function(e){$(".dialog-pass-text").addClass("dialog-clip-pass-copy round");e.clearSelection()});clipboardUser.on("success",function(e){e.clearSelection()})};var bindPassEncrypt=function(){$("body").delegate(":input[type=password]","blur",function(e){if($(this).hasClass("passwordfield__no-pki")){return}var id=$(this).attr("id");encryptFormValue("#"+id)});$("body").delegate(":input[type=password]","keypress",function(e){if(e.keyCode===13){e.preventDefault();var form=$(this).closest("form");var id=$(this).attr("id");encryptFormValue("#"+id);form.submit()}})};var viewWiki=function(pageName,actionId,sk){var data={pageName:pageName,actionId:actionId,sk:sk,isAjax:1};var url=APP_ROOT+"/ajax/ajax_wiki.php";$.ajax({type:"POST",dataType:"html",url:url,data:data,success:function(response){$.fancybox(response,{padding:[0,10,10,10]})},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var accMgmtFavorites=function(obj){var data={actionId:$(obj).data("status")==="on"?$(obj).data("actionid-off"):$(obj).data("actionid-on"),accountId:$(obj).data("accountid"),sk:$(obj).data("sk"),isAjax:1};$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_accFavorites.php",data:data,success:function(response){if(response.status===0){resMsg("ok",response.description);if($(obj).data("status")==="on"){$(obj).data("status","off");$(obj).removeClass("fg-orange80");$(obj).attr("title",LANG[49]);$(obj).html("star_border")}else{if($(obj).data("status")==="off"){$(obj).data("status","on");$(obj).addClass("fg-orange80");$(obj).attr("title",LANG[50]);$(obj).html("star")}}}else{if(response.status===0){resMsg("error",response.description);return true}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt);return false}})};return{accSearch:accSearch,accGridAction:accGridAction,accGridViewPass:accGridViewPass,accMgmtFavorites:accMgmtFavorites,appMgmtData:appMgmtData,appMgmtNav:appMgmtNav,appMgmtSave:appMgmtSave,appMgmtSearch:appMgmtSearch,appMgmtDelete:appMgmtDelete,checkboxDetect:checkboxDetect,checkDokuWikiConn:checkDokuWikiConn,checkLdapConn:checkLdapConn,checkPassLevel:checkPassLevel,checkUpds:checkUpds,clearEventlog:clearEventlog,clearSearch:clearSearch,chosenDetect:chosenDetect,configMgmt:configMgmt,delAccount:delAccount,delFile:delFile,doAction:doAction,doLogin:doLogin,doLogout:doLogout,downFile:downFile,encryptFormValue:encryptFormValue,fileUpload:fileUpload,getFiles:getFiles,linksMgmtSave:linksMgmtSave,linksMgmtRefresh:linksMgmtRefresh,navLog:navLog,outputResult:outputResult,redirect:redirect,resMsg:resMsg,scrollUp:scrollUp,searchSort:searchSort,saveAccount:saveAccount,sendAjax:sendAjax,sendRequest:sendRequest,setContentSize:setContentSize,showOptional:showOptional,showSearchOrder:showSearchOrder,usrUpdPass:usrUpdPass,viewFile:viewFile,viewPass:viewPass,viewWiki:viewWiki,passwordData:passwordData,passToClip:passToClip,APP_ROOT:APP_ROOT,LANG:LANG,PK:PK}}; \ No newline at end of file +var sysPass=sysPass||{};sysPass.createNS=function(d){var e=d.split(".");var c=sysPass;if(e[0]==="sysPass"){e=e.slice(1)}for(var a=0;a105&&event.keyCode<123))){return}if(lenTxtSearch<3&&continous===1&&lenTxtSearch>window.lastlen&&event.keyCode!==13){return}window.lastlen=lenTxtSearch;$("#frmSearch").find('input[name="start"]').val(0);doSearch()};var searchSort=function(skey,dir,start){if(typeof skey==="undefined"||typeof start==="undefined"){return false}$("#frmSearch").find('input[name="skey"]').val(skey);$("#frmSearch").find('input[name="sorder"]').val(dir);$("#frmSearch").find('input[name="start"]').val(start);doSearch()};var doSearch=function(){var frmData=$("#frmSearch").serialize();$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_search.php",data:frmData,success:function(json){$("#resBuscar").html(json.html);if(typeof json.sk!=="undefined"){$("#frmSearch").find(":input[name='sk']").val(json.sk)}},error:function(){$("#resBuscar").html(resMsg("nofancyerror"))}})};var showSearchOrder=function(){if(order.key){$("#search-sort-"+order.key).addClass("filterOn");if(order.dir===0){$("#search-sort-"+order.key).append('')}else{$("#search-sort-"+order.key).append('')}}};var navLog=function(start,current){if(typeof start==="undefined"){return false}$.ajax({type:"POST",dataType:"html",url:APP_ROOT+"/ajax/ajax_eventlog.php",data:{start:start,current:current},success:function(response){$("#content").html(response);scrollUp()},error:function(){$("#content").html(resMsg("nofancyerror"))}})};var viewPass=function(id,show,history){$.ajax({type:"POST",url:APP_ROOT+"/ajax/ajax_viewpass.php",dataType:"json",async:false,data:{accountid:id,full:show,isHistory:history,isAjax:1},success:function(json){if(json.status===10){doLogout();return}if(show==false){$("#clip-pass-text").html(json.accpass);passToClip=1;return}$("
      ").dialog({modal:true,title:LANG[47],width:"auto",open:function(){var thisDialog=$(this);var content;var pass="";var clipboardUserButton='";var clipboardPassButton='";var useImage=json.useimage;var user='

      '+json.acclogin+"

      ";if(json.status===0){if(useImage===0){pass='

      '+json.accpass+"

      "}else{pass='';clipboardPassButton=""}content=user+pass+'
      '+clipboardUserButton+clipboardPassButton+"
      "}else{content=''+json.description+"";thisDialog.dialog("option","buttons",[{text:"Ok",icons:{primary:"ui-icon-close"},click:function(){thisDialog.dialog("close")}}])}thisDialog.html(content);thisDialog.dialog("option","position","center");thisDialog.parent().on("mouseleave",function(){clearTimeout(timeout);timeout=setTimeout(function(){thisDialog.dialog("close")},30000)})},close:function(){clearTimeout(timeout);$(this).dialog("destroy")}})}})};var getUrlVars=function(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var i=0;i"+LANG[13]+"

      ";resMsg("error",txt)}}});return false};var doLogout=function(){var url=window.location.search;if(url.length>0){location.href="index.php"+url+"&logout=1"}else{location.href="index.php?logout=1"}};var checkLogout=function(){var session=getUrlVars()["session"];if(session===0){resMsg("warn",LANG[2],"","location.search = ''")}};var redirect=function(url){location.href=url};var saveAccount=function(frm){var data=$("#"+frm).serialize();var id=$('input[name="accountid"]').val();var action=$('input[name="next"]').val();$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_accountSave.php",data:data,success:function(json){var status=json.status;var description=json.description;if(status===0){resMsg("ok",description);if(action&&id){doAction(action,1,id)}else{if(action){doAction(action,1)}}}else{if(status===10){doLogout()}else{resMsg("error",description)}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var delAccount=function(id,action,sk){var data={accountid:id,actionId:action,sk:sk};var atext='

      '+LANG[3]+"

      ";var url="/ajax/ajax_accountSave.php";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var sendRequest=function(){var url="/ajax/ajax_sendRequest.php";var data=$("#frmRequestModify").serialize();sendAjax(data,url)};var configMgmt=function(action,obj){var url;switch(action){case"config":url="/ajax/ajax_configSave.php";break;case"export":url="/ajax/ajax_backup.php";break;case"import":url="/ajax/ajax_migrate.php";break;case"preferences":url="/ajax/ajax_userPrefsSave.php";break;default:return}var data=$(obj).serialize();sendAjax(data,url)};var downFile=function(id,sk,actionId,download){var data={fileId:id,sk:sk,actionId:actionId};if(typeof download==="undefined"){$.ajax({type:"POST",cache:false,url:APP_ROOT+"/ajax/ajax_files.php",data:data,success:function(response){if(typeof response.status!=="undefined"&&response.status===1){resMsg("error",response.description);return}if(response){$.fancybox(response,{padding:[10,10,10,10]});setTimeout(function(){$.fancybox.update()},1000)}else{resMsg("error",LANG[14])}}})}else{if(download===true){$.fileDownload(APP_ROOT+"/ajax/ajax_files.php",{httpMethod:"POST",data:data})}}};var viewFile=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var data={fileId:itemId,sk:sk,actionId:actionId};$.ajax({type:"POST",cache:false,url:APP_ROOT+"/ajax/ajax_files.php",data:data,success:function(response){if(typeof response.status!=="undefined"&&response.status===1){resMsg("error",response.description);return}if(response){$.fancybox(response,{padding:[10,10,10,10]});setTimeout(function(){$.fancybox.update()},1000)}else{resMsg("error",LANG[14])}}})};var getFiles=function(id,isDel,sk){var data={id:id,del:isDel,sk:sk};$.ajax({type:"GET",cache:false,url:APP_ROOT+"/ajax/ajax_getFiles.php",data:data,success:function(response){$("#downFiles").html(response)}})};var delFile=function(id,sk,accountId,actionId){var atext='

      '+LANG[15]+"

      ";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){var data={fileId:id,actionId:actionId,sk:sk};$.post(APP_ROOT+"/ajax/ajax_files.php",data,function(data){if(data.status===0){var url=APP_ROOT+"/ajax/ajax_getFiles.php?id="+accountId+"&del=1&isAjax=1&sk="+sk;$("#downFiles").load(url);resMsg("ok",data.description)}else{resMsg("error",data.description)}})},function(e){e.preventDefault();alertify.error(LANG[44])})};var fileUpload=function(opts){var options={targetId:"",url:""};var requestDoneAction,requestData={},beforeSendAction;var setFn={setRequestDoneAction:function(a){requestDoneAction=a},setRequestData:function(d){requestData=d},setBeforeSendAction:function(a){beforeSendAction=a}};options=opts;if(typeof options.targetId==="undefined"||options.targetId===""){return setFn}var dropzone=document.getElementById(options.targetId);var sendFile=function(file){if(typeof options.url==="undefined"||options.url===""){return false}var fd=new FormData();fd.append("inFile",file);fd.append("isAjax",1);Object.keys(requestData).forEach(function(key){fd.append(key,requestData[key])});$.ajax({type:"POST",dataType:"json",cache:false,processData:false,contentType:false,url:APP_ROOT+options.url,data:fd,success:function(json){var status=json.status;var description=json.description;if(status===0){if(typeof requestDoneAction==="function"){requestDoneAction()}resMsg("ok",description)}else{if(status===10){doLogout()}else{resMsg("error",description)}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var checkFileSize=function(size){return(size/1000>MAX_FILE_SIZE)};var checkFileExtension=function(name){var file_exts_ok=dropzone.getAttribute("data-files-ext").toLowerCase().split(",");for(var i=0;i<=file_exts_ok.length;i++){if(name.indexOf(file_exts_ok[i])!==-1){return true}}return false};var handleFiles=function(filesArray){if(filesArray.length>5){resMsg("error",LANG[17]+" (Max: 5)");return}for(var i=0;i"+file.name+" (Max: "+MAX_FILE_SIZE+")")}else{if(!checkFileExtension(file.name)){resMsg("error",LANG[19]+"
      "+file.name)}else{sendFile(filesArray[i])}}}};var init=function(){dropzone.ondragover=dropzone.ondragenter=function(event){event.stopPropagation();event.preventDefault()};dropzone.ondrop=function(event){event.stopPropagation();event.preventDefault();if(typeof beforeSendAction==="function"){beforeSendAction()}handleFiles(event.dataTransfer.files)};var fallback=initForm(false);dropzone.onclick=function(){fallback.click()}};var initForm=function(display){var form=document.getElementById("fileUploadForm");var formTags=form.getElementsByTagName("input");form.style.display=(display===false)?"none":"";if(formTags[0].type==="file"){formTags[0].addEventListener("change",function(){if(typeof beforeSendAction==="function"){beforeSendAction()}handleFiles(this.files)},false)}return formTags[0]};if(window.File&&window.FileList&&window.FileReader){init()}else{initForm(true)}return setFn};var sendAjax=function(data,url){$.ajax({type:"POST",dataType:"json",url:APP_ROOT+url,data:data,success:function(json){var status=json.status;var description=json.description;var action=json.action;switch(status){case 0:$.fancybox.close();resMsg("ok",description,undefined,action);break;case 1:$.fancybox.close();$(":input[type=password]").val("");resMsg("error",description,undefined,action);break;case 2:$("#resFancyAccion").html(''+description+"").show();break;case 3:$.fancybox.close();resMsg("warn",description,undefined,action);break;case 10:doLogout();break;default:return}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var usrUpdPass=function(object,actionId,sk){var userId=$(object).attr("data-itemid");var data={userId:userId,actionId:actionId,sk:sk,isAjax:1};$.ajax({type:"GET",cache:false,url:APP_ROOT+"/ajax/ajax_usrpass.php",data:data,success:function(data){if(data.length===0){doLogout()}else{$.fancybox(data,{padding:0})}}})};var appMgmtData=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,isAjax:1};var url=APP_ROOT+"/ajax/ajax_appMgmtData.php";$.ajax({type:"POST",dataType:"html",url:url,data:data,success:function(response){$.fancybox(response,{padding:[0,10,10,10]})},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var appMgmtDelete=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var nextActionId=$(obj).attr("data-nextactionid");var atext='

      '+LANG[12]+"

      ";var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,onCloseAction:nextActionId};alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var appMgmtSave=function(frmId){var url="/ajax/ajax_appMgmtSave.php";var data=$("#"+frmId).serialize();sendAjax(data,url)};var appMgmtSearch=function(form){var targetId=form.elements.target.value;var data=$(form).serialize();appMgmtSearchAjax(data,targetId);return false};var appMgmtNav=function(formId,count,start){var form=$("#"+formId);var targetId=form.find("[name=target]").val();var sk=form.find("[name=sk]").val();var data=form.serialize()+"&sk="+sk+"&start="+start+"&count="+count;appMgmtSearchAjax(data,targetId);return false};var appMgmtSearchAjax=function(data,targetId){$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_appMgmtSearch.php",data:data,success:function(json){if(json.status===0){$("#"+targetId).html(json.html);$("form").find("[name=sk]").val(json.sk)}else{$("#"+targetId).html(resMsg("nofancyerror",json.description))}},error:function(){$("#"+targetId).html(resMsg("nofancyerror","error"))}})};var linksMgmtSave=function(itemId,actionId,sk){var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,isAjax:1};alertify.okBtn(LANG[40]).cancelBtn(LANG[41]).confirm(LANG[48],function(e){$.extend(data,{notify:1});sendAjax(data,url)},function(e){e.preventDefault();sendAjax(data,url)})};var linksMgmtRefresh=function(obj,actionId,sk){var itemId=$(obj).attr("data-itemid");var activeTab=$(obj).attr("data-activetab");var nextActionId=$(obj).attr("data-nextactionid");var url="/ajax/ajax_appMgmtSave.php";var data={itemId:itemId,actionId:actionId,sk:sk,activeTab:activeTab,onCloseAction:nextActionId};sendAjax(data,url)};var checkUpds=function(){$.ajax({type:"GET",dataType:"html",url:APP_ROOT+"/ajax/ajax_checkUpds.php",timeout:10000,success:function(response){$("#updates").html(response);if(typeof componentHandler!=="undefined"){componentHandler.upgradeDom()}},error:function(jqXHR,textStatus,errorThrown){$("#updates").html("!")}})};var clearEventlog=function(sk){var atext='

      '+LANG[20]+"

      ";alertify.okBtn(LANG[43]).cancelBtn(LANG[44]).confirm(atext,function(e){var data={clear:1,sk:sk,isAjax:1};var url="/ajax/ajax_eventlog.php";sendAjax(data,url)},function(e){e.preventDefault();alertify.error(LANG[44])})};var showOptional=function(me){$(me).hide();var actions=$(me).parent().children(".actions-optional");actions.show(250)};var getTime=function(){var t=new Date();return t.getTime()};var checkPassLevel=function(password,dst){passwordData.passLength=password.length;outputResult(zxcvbn(password),dst)};var outputResult=function(level,dstId){var complexity,selector=".passLevel-"+dstId;var score=level.score;complexity=$(selector);complexity.show();complexity.removeClass("weak good strong strongest");if(passwordData.passLength===0){complexity.attr("title","").empty()}else{if(passwordData.passLength");switch(type){case"ok":alertify.closeLogOnClick(true).delay(15000).success(txt);break;case"error":alertify.closeLogOnClick(true).delay(15000).error(txt);break;case"warn":alertify.delay(30000).log(txt);break;case"nofancyerror":html='

      Oops...
      '+LANG[1]+"
      "+txt+"

      ";return html;default:alertify.error(txt);break}if(typeof action!=="undefined"){eval(action)}};var checkLdapConn=function(formId){var form="#"+formId;var ldapBindPass=$(form).find("[name=ldap_bindpass]").val();var data={type:"ldap",ldap_server:$(form).find("[name=ldap_server]").val(),ldap_base:$(form).find("[name=ldap_base]").val(),ldap_group:$(form).find("[name=ldap_group]").val(),ldap_binduser:$(form).find("[name=ldap_binduser]").val(),ldap_bindpass:(PK!=="")?encrypt.encrypt(ldapBindPass):ldapBindPass,isAjax:1,sk:$(form).find("[name=sk]").val()};sendAjax(data,"/ajax/ajax_checkConnection.php")};var checkDokuWikiConn=function(formId){var form="#"+formId;var data={type:"dokuwiki",dokuwiki_url:$(form).find("[name=dokuwiki_url]").val(),dokuwiki_user:$(form).find("[name=dokuwiki_user]").val(),dokuwiki_pass:$(form).find("[name=dokuwiki_pass]").val(),isAjax:1,sk:$(form).find("[name=sk]").val()};$.ajax({type:"POST",url:APP_ROOT+"/ajax/ajax_checkConnection.php",data:data,success:function(response){if(response.status===1){resMsg("error",response.description)}else{if(response.status===0){resMsg("ok",response.description);$("#dokuWikiResCheck").html(response.data)}}}})};var goLogin=function(){setTimeout(function(){location.href="index.php"},2000)};var getBrowser=function(){var browser;var ua=navigator.userAgent;var re=new RegExp("(MSIE|Firefox)[ /]?([0-9]{1,}[.0-9]{0,})","i");if(re.exec(ua)!==null){browser=RegExp.$1}return browser};var selectDetect=function(){$(".sel-chosen-usergroup").selectize();$(".sel-chosen-user").selectize();$(".sel-chosen-profile").selectize();$(".sel-chosen-customer").each(function(){var plugins=($(this).hasClass("sel-chosen-deselect"))?{clear_selection:{title:LANG[51]}}:{};$(this).selectize({plugins:plugins})});$(".sel-chosen-category").each(function(){var plugins=($(this).hasClass("sel-chosen-deselect"))?{clear_selection:{title:LANG[51]}}:{};$(this).selectize({plugins:plugins})});$(".sel-chosen-action").each(function(){var plugins=($(this).hasClass("sel-chosen-deselect"))?{clear_selection:{title:LANG[51]}}:{};$(this).selectize({plugins:plugins})});$(".sel-chosen-ns").selectize()};var checkboxDetect=function(container){$(container).find(".checkbox").button({icons:{primary:"ui-icon-transferthick-e-w"}}).click(function(){if($(this).prop("checked")===true){$(this).button("option","label",LANG[40])}else{$(this).button("option","label",LANG[41])}})};var encryptFormValue=function(inputId){var input=$(inputId);var curValue=input.val();var nextName=inputId+"-encrypted";var nextInput=input.next(':input[name="'+nextName+'"]');if((curValue!==""&&nextInput.attr("name")!==nextName)||(curValue!==""&&nextInput.attr("name")===nextName&&parseInt(input.next().val())!==curValue.length)){var passEncrypted=encrypt.encrypt(curValue);input.val(passEncrypted);if(nextInput.length>0){nextInput.val(passEncrypted.length)}else{input.after('')}}};var initializeClipboard=function(){var clipboard=new Clipboard(".clip-pass-button",{text:function(trigger){sysPassUtil.Common.viewPass(trigger.getAttribute("data-account-id"),0);return $("#clip-pass-text").html()}});clipboard.on("success",function(e){sysPassUtil.Common.resMsg("ok",LANG[45])});clipboard.on("error",function(e){sysPassUtil.Common.resMsg("error",LANG[46])});var clipboardPass=new Clipboard(".dialog-clip-pass-button");var clipboardUser=new Clipboard(".dialog-clip-user-button");clipboardPass.on("success",function(e){$(".dialog-pass-text").addClass("dialog-clip-pass-copy round");e.clearSelection()});clipboardUser.on("success",function(e){e.clearSelection()})};var bindPassEncrypt=function(){$("body").delegate(":input[type=password]","blur",function(e){if($(this).hasClass("passwordfield__no-pki")){return}var id=$(this).attr("id");encryptFormValue("#"+id)});$("body").delegate(":input[type=password]","keypress",function(e){if(e.keyCode===13){e.preventDefault();var form=$(this).closest("form");var id=$(this).attr("id");encryptFormValue("#"+id);form.submit()}})};var viewWiki=function(pageName,actionId,sk){var data={pageName:pageName,actionId:actionId,sk:sk,isAjax:1};var url=APP_ROOT+"/ajax/ajax_wiki.php";$.ajax({type:"POST",dataType:"html",url:url,data:data,success:function(response){$.fancybox(response,{padding:[0,10,10,10]})},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt)}})};var accMgmtFavorites=function(obj){var data={actionId:$(obj).data("status")==="on"?$(obj).data("actionid-off"):$(obj).data("actionid-on"),accountId:$(obj).data("accountid"),sk:$(obj).data("sk"),isAjax:1};$.ajax({type:"POST",dataType:"json",url:APP_ROOT+"/ajax/ajax_accFavorites.php",data:data,success:function(response){if(response.status===0){resMsg("ok",response.description);if($(obj).data("status")==="on"){$(obj).data("status","off");$(obj).removeClass("fg-orange80");$(obj).attr("title",LANG[49]);$(obj).html("star_border")}else{if($(obj).data("status")==="off"){$(obj).data("status","on");$(obj).addClass("fg-orange80");$(obj).attr("title",LANG[50]);$(obj).html("star")}}}else{if(response.status===0){resMsg("error",response.description);return true}}},error:function(jqXHR,textStatus,errorThrown){var txt=LANG[1]+"

      "+errorThrown+textStatus+"

      ";resMsg("error",txt);return false}})};return{accSearch:accSearch,accGridAction:accGridAction,accGridViewPass:accGridViewPass,accMgmtFavorites:accMgmtFavorites,appMgmtData:appMgmtData,appMgmtNav:appMgmtNav,appMgmtSave:appMgmtSave,appMgmtSearch:appMgmtSearch,appMgmtDelete:appMgmtDelete,checkboxDetect:checkboxDetect,checkDokuWikiConn:checkDokuWikiConn,checkLdapConn:checkLdapConn,checkPassLevel:checkPassLevel,checkUpds:checkUpds,clearEventlog:clearEventlog,clearSearch:clearSearch,chosenDetect:selectDetect,configMgmt:configMgmt,delAccount:delAccount,delFile:delFile,doAction:doAction,doLogin:doLogin,doLogout:doLogout,downFile:downFile,encryptFormValue:encryptFormValue,fileUpload:fileUpload,getFiles:getFiles,linksMgmtSave:linksMgmtSave,linksMgmtRefresh:linksMgmtRefresh,navLog:navLog,outputResult:outputResult,redirect:redirect,resMsg:resMsg,scrollUp:scrollUp,searchSort:searchSort,saveAccount:saveAccount,sendAjax:sendAjax,sendRequest:sendRequest,setContentSize:setContentSize,showOptional:showOptional,showSearchOrder:showSearchOrder,usrUpdPass:usrUpdPass,viewFile:viewFile,viewPass:viewPass,viewWiki:viewWiki,passwordData:passwordData,passToClip:passToClip,APP_ROOT:APP_ROOT,LANG:LANG,PK:PK}}; \ No newline at end of file diff --git a/js/js.php b/js/js.php index 7e3a7ef1..0ed1be11 100644 --- a/js/js.php +++ b/js/js.php @@ -40,11 +40,12 @@ if (!$file) { $Minify->addFile('jquery-ui.min.js'); $Minify->addFile('jquery.fancybox.pack.js'); $Minify->addFile('jquery.powertip.min.js'); - $Minify->addFile('chosen.jquery.min.js'); $Minify->addFile('alertify.min.js'); $Minify->addFile('jquery.fileDownload.min.js'); $Minify->addFile('jquery.tagsinput.min.js'); $Minify->addFile('clipboard.min.js'); + $Minify->addFile('selectize.min.js'); + $Minify->addFile('selectize-plugins.min.js'); $Minify->addFile('zxcvbn-async.min.js'); $Minify->addFile('jsencrypt.min.js'); $Minify->addFile('functions.min.js'); diff --git a/js/selectize.min.js b/js/selectize.min.js new file mode 100644 index 00000000..977b4891 --- /dev/null +++ b/js/selectize.min.js @@ -0,0 +1 @@ +(function(a,b){if(typeof define==="function"&&define.amd){define("sifter",b)}else{if(typeof exports==="object"){module.exports=b()}else{a.Sifter=b()}}}(this,function(){var g=function(i,j){this.items=i;this.settings=j||{diacritics:true}};g.prototype.tokenize=function(m){m=b(String(m||"").toLowerCase());if(!m||!m.length){return[]}var j,q,l,k;var o=[];var p=m.split(/ +/);for(j=0,q=p.length;j0){p.items.push({score:j,id:s})}})}else{o.iterator(o.items,function(r,s){p.items.push({score:1,id:s})})}i=o.getSortFunction(p,q);if(i){p.items.sort(i)}p.total=p.items.length;if(typeof q.limit==="number"){p.items=p.items.slice(0,q.limit)}return p};var e=function(j,i){if(typeof j==="number"&&typeof i==="number"){return j>i?1:(ji){return 1}if(i>j){return -1}return 0};var h=function(l,j){var p,q,m,o;for(p=1,q=arguments.length;p=0&&T.data.length>0){var X=T.data.match(P);var W=document.createElement("span");W.className="highlight";var U=T.splitText(Y);var R=U.splitText(X[0].length);var S=U.cloneNode(true);W.appendChild(S);U.parentNode.replaceChild(W,U);Z=1}}else{if(T.nodeType===1&&T.childNodes&&!/(script|style)/i.test(T.tagName)){for(var V=0;V/g,">").replace(/"/g,""")};var e=function(N){return(N+"").replace(/\$/g,"$$$$")};var r={};r.before=function(N,Q,P){var O=N[Q];N[Q]=function(){P.apply(N,arguments);return O.apply(N,arguments)}};r.after=function(N,Q,P){var O=N[Q];N[Q]=function(){var R=O.apply(N,arguments);P.apply(N,arguments);return R}};var q=function(N){var O=false;return function(){if(O){return}O=true;N.apply(this,arguments)}};var f=function(O,N){var P;return function(){var Q=this;var R=arguments;window.clearTimeout(P);P=window.setTimeout(function(){O.apply(Q,R)},N)}};var a=function(N,P,R){var Q;var O=N.trigger;var S={};N.trigger=function(){var T=arguments[0];if(P.indexOf(T)!==-1){S[T]=arguments}else{return O.apply(N,arguments)}};R.apply(N,[]);N.trigger=O;for(Q in S){if(S.hasOwnProperty(Q)){O.apply(N,S[Q])}}};var z=function(Q,P,N,O){Q.on(P,N,function(R){var S=R.target;while(S&&S.parentNode!==Q[0]){S=S.parentNode}R.currentTarget=S;return O.apply(this,[R])})};var k=function(P){var O={};if("selectionStart" in P){O.start=P.selectionStart;O.length=P.selectionEnd-O.start}else{if(document.selection){P.focus();var Q=document.selection.createRange();var N=document.selection.createRange().text.length;Q.moveStart("character",-P.value.length);O.start=Q.text.length-N;O.length=N}}return O};var m=function(Q,R,O){var N,S,P={};if(O){for(N=0,S=O.length;N").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(Q).appendTo("body");m(P,O,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var N=O.width();O.remove();return N};var J=function(P){var N=null;var O=function(T,Z){var X,Y,U,W,Q;var R,S,V;T=T||window.event||{};Z=Z||{};if(T.metaKey||T.altKey){return}if(!Z.force&&P.data("grow")===false){return}X=P.val();if(T.type&&T.type.toLowerCase()==="keydown"){Y=T.keyCode;U=((Y>=97&&Y<=122)||(Y>=65&&Y<=90)||(Y>=48&&Y<=57)||Y===32);if(Y===p||Y===n){V=k(P[0]);if(V.length){X=X.substring(0,V.start)+X.substring(V.start+V.length)}else{if(Y===n&&V.start){X=X.substring(0,V.start-1)+X.substring(V.start+1)}else{if(Y===p&&typeof V.start!=="undefined"){X=X.substring(0,V.start)+X.substring(V.start+1)}}}}else{if(U){R=T.shiftKey;S=String.fromCharCode(T.keyCode);if(R){S=S.toUpperCase()}else{S=S.toLowerCase()}X+=S}}}W=P.attr("placeholder");if(!X&&W){X=W}Q=I(X,P)+4;if(Q!==N){N=Q;P.width(Q);P.triggerHandler("resize")}};P.on("keydown keyup update blur",O);O()};var c=function(S,P){var U,Q,N,O,T,V=this;T=S[0];T.selectize=V;var R=window.getComputedStyle&&window.getComputedStyle(T,null);O=R?R.getPropertyValue("direction"):T.currentStyle&&T.currentStyle.direction;O=O||S.parents("[dir]:first").attr("dir")||"";u.extend(V,{order:0,settings:P,$input:S,tabIndex:S.attr("tabindex")||"",tagType:T.tagName.toLowerCase()==="select"?j:g,rtl:/rtl/i.test(O),eventNS:".selectize"+(++c.count),highlightedValue:null,isOpen:false,isDisabled:false,isRequired:S.is("[required]"),isInvalid:false,isLocked:false,isFocused:false,isInputHidden:false,isSetup:false,isShiftDown:false,isCmdDown:false,isCtrlDown:false,ignoreFocus:false,ignoreBlur:false,ignoreHover:false,hasOptions:false,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:P.loadThrottle===null?V.onSearchChange:f(V.onSearchChange,P.loadThrottle)});V.sifter=new l(this.options,{diacritics:P.diacritics});if(V.settings.options){for(Q=0,N=V.settings.options.length;Q").addClass(Z.wrapperClass).addClass(aa).addClass(ae);ab=u("
      ").addClass(Z.inputClass).addClass("items").appendTo(X);O=u('').appendTo(ab).attr("tabindex",P.is(":disabled")?"-1":T.tabIndex);Y=u(Z.dropdownParent||X);Q=u("
      ").addClass(Z.dropdownClass).addClass(ae).hide().appendTo(Y);U=u("
      ").addClass(Z.dropdownContentClass).appendTo(Q);if(T.settings.copyClassesToDropdown){Q.addClass(aa)}X.css({width:P[0].style.width});if(T.plugins.names.length){V="plugin-"+T.plugins.names.join(" plugin-");X.addClass(V);Q.addClass(V)}if((Z.maxItems===null||Z.maxItems>1)&&T.tagType===j){P.attr("multiple","multiple")}if(T.settings.placeholder){O.attr("placeholder",Z.placeholder)}if(!T.settings.splitOn&&T.settings.delimiter){var N=T.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");T.settings.splitOn=new RegExp("\\s*"+N+"+\\s*")}if(P.attr("autocorrect")){O.attr("autocorrect",P.attr("autocorrect"))}if(P.attr("autocapitalize")){O.attr("autocapitalize",P.attr("autocapitalize"))}T.$wrapper=X;T.$control=ab;T.$control_input=O;T.$dropdown=Q;T.$dropdown_content=U;Q.on("mouseenter","[data-selectable]",function(){return T.onOptionHover.apply(T,arguments)});Q.on("mousedown click","[data-selectable]",function(){return T.onOptionSelect.apply(T,arguments)});z(ab,"mousedown","*:not(input)",function(){return T.onItemSelect.apply(T,arguments)});J(O);ab.on({mousedown:function(){return T.onMouseDown.apply(T,arguments)},click:function(){return T.onClick.apply(T,arguments)}});O.on({mousedown:function(af){af.stopPropagation()},keydown:function(){return T.onKeyDown.apply(T,arguments)},keyup:function(){return T.onKeyUp.apply(T,arguments)},keypress:function(){return T.onKeyPress.apply(T,arguments)},resize:function(){T.positionDropdown.apply(T,[])},blur:function(){return T.onBlur.apply(T,arguments)},focus:function(){T.ignoreBlur=false;return T.onFocus.apply(T,arguments)},paste:function(){return T.onPaste.apply(T,arguments)}});ad.on("keydown"+W,function(af){T.isCmdDown=af[b?"metaKey":"ctrlKey"];T.isCtrlDown=af[b?"altKey":"ctrlKey"];T.isShiftDown=af.shiftKey});ad.on("keyup"+W,function(af){if(af.keyCode===d){T.isCtrlDown=false}if(af.keyCode===i){T.isShiftDown=false}if(af.keyCode===H){T.isCmdDown=false}});ad.on("mousedown"+W,function(af){if(T.isFocused){if(af.target===T.$dropdown[0]||af.target.parentNode===T.$dropdown[0]){return false}if(!T.$control.has(af.target).length&&af.target!==T.$control[0]){T.blur(af.target)}}});S.on(["scroll"+W,"resize"+W].join(" "),function(){if(T.isOpen){T.positionDropdown.apply(T,arguments)}});S.on("mousemove"+W,function(){T.ignoreHover=false});this.revertSettings={$children:P.children().detach(),tabindex:P.attr("tabindex")};P.attr("tabindex",-1).hide().after(T.$wrapper);if(u.isArray(Z.items)){T.setValue(Z.items);delete Z.items}if(B){P.on("invalid"+W,function(af){af.preventDefault();T.isInvalid=true;T.refreshState()})}T.updateOriginalInput();T.refreshItems();T.refreshState();T.updatePlaceholder();T.isSetup=true;if(P.is(":disabled")){T.disable()}T.on("change",this.onChange);P.data("selectize",T);P.addClass("selectized");T.trigger("initialize");if(Z.preload===true){T.onSearchChange("")}},setupTemplates:function(){var O=this;var N=O.settings.labelField;var P=O.settings.optgroupLabelField;var Q={optgroup:function(R){return'
      '+R.html+"
      "},optgroup_header:function(S,R){return'
      '+R(S[P])+"
      "},option:function(S,R){return'
      '+R(S[N])+"
      "},item:function(S,R){return'
      '+R(S[N])+"
      "},option_create:function(S,R){return'
      Add '+R(S.input)+"
      "}};O.settings.render=u.extend({},Q,O.settings.render)},setupCallbacks:function(){var N,O,P={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(N in P){if(P.hasOwnProperty(N)){O=this.settings[P[N]];if(O){this.on(N,O)}}}},onClick:function(O){var N=this;if(!N.isFocused){N.focus();O.preventDefault()}},onMouseDown:function(Q){var O=this;var P=Q.isDefaultPrevented();var N=u(Q.target);if(O.isFocused){if(Q.target!==O.$control_input[0]){if(O.settings.mode==="single"){O.isOpen?O.close():O.open()}else{if(!P){O.setActiveItem(null)}}return false}}else{if(!P){window.setTimeout(function(){O.focus()},0)}}},onChange:function(){this.$input.trigger("change")},onPaste:function(O){var N=this;if(N.isFull()||N.isInputHidden||N.isLocked){O.preventDefault()}else{if(N.settings.splitOn){setTimeout(function(){var P=u.trim(N.$control_input.val()||"").split(N.settings.splitOn);for(var Q=0,R=P.length;QP){O=N;N=P;P=O}for(Q=N;Q<=P;Q++){W=X.$control[0].childNodes[Q];if(X.$activeItems.indexOf(W)===-1){u(W).addClass("active");X.$activeItems.push(W)}}S.preventDefault()}else{if((R==="mousedown"&&X.isCtrlDown)||(R==="keydown"&&this.isShiftDown)){if(U.hasClass("active")){V=X.$activeItems.indexOf(U[0]);X.$activeItems.splice(V,1);U.removeClass("active")}else{X.$activeItems.push(U.addClass("active")[0])}}else{u(X.$activeItems).removeClass("active");X.$activeItems=[U.addClass("active")[0]]}}X.hideInput();if(!this.isFocused){X.focus()}},setActiveOption:function(N,T,P){var O,U,S;var R,Q;var V=this;if(V.$activeOption){V.$activeOption.removeClass("active")}V.$activeOption=null;N=u(N);if(!N.length){return}V.$activeOption=N.addClass("active");if(T||!M(T)){O=V.$dropdown_content.height();U=V.$activeOption.outerHeight(true);T=V.$dropdown_content.scrollTop()||0;S=V.$activeOption.offset().top-V.$dropdown_content.offset().top+T;R=S;Q=S-O+U;if(S+U>O+T){V.$dropdown_content.stop().animate({scrollTop:Q},P?V.settings.scrollDuration:0)}else{if(S=0;Q--){if(T.items.indexOf(x(V.items[Q].id))!==-1){V.items.splice(Q,1)}}}return V},refreshOptions:function(X){var ae,ad,ac,aa,ah,N,T,af,P,ab,R,ag,S;var Q,W,Y;if(typeof X==="undefined"){X=true}var V=this;var O=u.trim(V.$control_input.val());var Z=V.search(O);var U=V.$dropdown_content;var ai=V.$activeOption&&x(V.$activeOption.attr("data-value"));aa=Z.items.length;if(typeof V.settings.maxOptions==="number"){aa=Math.min(aa,V.settings.maxOptions)}ah={};N=[];for(ae=0;ae0||S;if(V.hasOptions){if(Z.items.length>0){W=ai&&V.getOption(ai);if(W&&W.length){Q=W}else{if(V.settings.mode==="single"&&V.items.length){Q=V.getOption(V.items[0])}}if(!Q||!Q.length){if(Y&&!V.settings.addPrecedence){Q=V.getAdjacentOption(Y,1)}else{Q=U.find("[data-selectable]:first")}}}else{Q=Y}V.setActiveOption(Q);if(X&&!V.isOpen){V.open()}}else{V.setActiveOption(null);if(X&&V.isOpen){V.close()}}},addOption:function(Q){var O,R,P,N=this;if(u.isArray(Q)){for(O=0,R=Q.length;O=0&&O0);N.$control_input.data("grow",!O&&!P)},isFull:function(){return this.settings.maxItems!==null&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(R){var Q,S,P,O,N=this;R=R||{};if(N.tagType===j){P=[];for(Q=0,S=N.items.length;Q'+C(O)+"")}if(!P.length&&!this.$input.attr("multiple")){P.push('')}N.$input.html(P.join(""))}else{N.$input.val(N.getValue());N.$input.attr("value",N.$input.val())}if(N.isSetup){if(!R.silent){N.trigger("change",N.$input.val())}}},updatePlaceholder:function(){if(!this.settings.placeholder){return}var N=this.$control_input;if(this.items.length){N.removeAttr("placeholder")}else{N.attr("placeholder",this.settings.placeholder)}N.triggerHandler("update",{force:true})},open:function(){var N=this;if(N.isLocked||N.isOpen||(N.settings.mode==="multi"&&N.isFull())){return}N.focus();N.isOpen=true;N.refreshState();N.$dropdown.css({visibility:"hidden",display:"block"});N.positionDropdown();N.$dropdown.css({visibility:"visible"});N.trigger("dropdown_open",N.$dropdown)},close:function(){var N=this;var O=N.isOpen;if(N.settings.mode==="single"&&N.items.length){N.hideInput()}N.isOpen=false;N.$dropdown.hide();N.setActiveOption(null);N.refreshState();if(O){N.trigger("dropdown_close",N.$dropdown)}},positionDropdown:function(){var N=this.$control;var O=this.settings.dropdownParent==="body"?N.offset():N.position();O.top+=N.outerHeight(true);this.$dropdown.css({width:N.outerWidth(),top:O.top,left:O.left})},clear:function(O){var N=this;if(!N.items.length){return}N.$control.children(":not(input)").remove();N.items=[];N.lastQuery=null;N.setCaret(0);N.setActiveItem(null);N.updatePlaceholder();N.updateOriginalInput({silent:O});N.refreshState();N.showInput();N.trigger("clear")},insertAtCaret:function(N){var O=Math.min(this.caretPos,this.items.length);if(O===0){this.$control.prepend(N)}else{u(this.$control[0].childNodes[O]).before(N)}this.setCaret(O+1)},deleteSelection:function(Q){var O,N,U,V,W,S,R,T,P;var X=this;U=(Q&&Q.keyCode===n)?-1:1;V=k(X.$control_input[0]);if(X.$activeOption&&!X.settings.hideSelected){R=X.getAdjacentOption(X.$activeOption,-1).attr("data-value")}W=[];if(X.$activeItems.length){P=X.$control.children(".active:"+(U>0?"last":"first"));S=X.$control.children(":not(input)").index(P);if(U>0){S++}for(O=0,N=X.$activeItems.length;O0&&V.start===X.$control_input.val().length){W.push(X.items[X.caretPos])}}}}if(!W.length||(typeof X.settings.onDelete==="function"&&X.settings.onDelete.apply(X,[W])===false)){return false}if(typeof S!=="undefined"){X.setCaret(S)}while(W.length){X.removeItem(W.pop())}X.showInput();X.positionDropdown();X.refreshOptions(true);if(R){T=X.getOption(R);if(T.length){X.setActiveOption(T)}}return true},advanceSelection:function(R,O){var P,S,T,U,Q,N;var V=this;if(R===0){return}if(V.rtl){R*=-1}P=R>0?"last":"first";S=k(V.$control_input[0]);if(V.isFocused&&!V.isInputHidden){U=V.$control_input.val().length;Q=R<0?S.start===0&&S.length===0:S.start===U;if(Q&&!U){V.advanceCaret(R,O)}}else{N=V.$control.children(".active:"+P);if(N.length){T=V.$control.children(":not(input)").index(N);V.setActiveItem(null);V.setCaret(R>0?T+1:T)}}},advanceCaret:function(R,Q){var N=this,P,O;if(R===0){return}P=R>0?"next":"prev";if(N.isShiftDown){O=N.$control_input[P]();if(O.length){N.hideInput();N.setActiveItem(O);Q&&Q.preventDefault()}}else{N.setCaret(N.caretPos+R)}},setCaret:function(Q){var O=this;if(O.settings.mode==="single"){Q=O.items.length}else{Q=Math.max(0,Math.min(O.items.length,Q))}if(!O.isPending){var P,T,R,N,S;N=O.$control.children(":not(input)");for(P=0,T=N.length;P
      ')}},O);N.setup=(function(){var P=N.setup;return function(){P.apply(N,arguments);N.$dropdown_header=u(O.html(O));N.$dropdown.prepend(N.$dropdown_header)}})()});c.define("optgroup_columns",function(P){var O=this;P=u.extend({equalizeWidth:true,equalizeHeight:true},P);this.getAdjacentOption=function(U,T){var R=U.closest("[data-group]").find("[data-selectable]");var S=R.index(U)+T;return S>=0&&S
      ';T=T.firstChild;S.body.appendChild(T);R=N.width=T.offsetWidth-T.clientWidth;S.body.removeChild(T)}return R};var Q=function(){var S,X,R,T,W,V,U;U=u("[data-group]",O.$dropdown_content);X=U.length;if(!X||!O.$dropdown_content.width()){return}if(P.equalizeHeight){R=0;for(S=0;S1){W=V-T*(X-1);U.eq(X-1).css({width:W})}}};if(P.equalizeHeight||P.equalizeWidth){r.after(this,"positionDropdown",Q);r.after(this,"refreshOptions",Q)}});c.define("remove_button",function(P){if(this.settings.mode==="single"){return}P=u.extend({label:"×",title:"Remove",className:"remove",append:true},P);var O=this;var Q=''+P.label+"";var N=function(R,S){var T=R.search(/(<\/[^>]+>\s*)$/);return R.substring(0,T)+S+R.substring(T)};this.setup=(function(){var R=O.setup;return function(){if(P.append){var S=O.settings.render.item;O.settings.render.item=function(T){return N(S.apply(this,arguments),Q)}}R.apply(this,arguments);this.$control.on("click","."+P.className,function(U){U.preventDefault();if(O.isLocked){return}var T=u(U.currentTarget).parent();O.setActiveItem(T);if(O.deleteSelection()){O.setCaret(O.items.length)}})}})()});c.define("restore_on_backspace",function(O){var N=this;O.text=O.text||function(P){return P[this.settings.labelField]};this.onKeyDown=(function(){var P=N.onKeyDown;return function(S){var Q,R;if(S.keyCode===n&&this.$control_input.val()===""&&!this.$activeItems.length){Q=this.caretPos-1;if(Q>=0&&Q _('Clave de Cuenta'), 48 => _('Recibir notificaciones?'), 49 => _('Marcar Favorito'), - 50 => _('Eliminar Favorito') + 50 => _('Eliminar Favorito'), + 51 => _('Limpiar Selección'), ); \ No newline at end of file