diff --git a/css/fonts/NotoSans-Regular-webfont.ttf b/css/fonts/NotoSans-Regular-webfont.ttf new file mode 100644 index 00000000..d8fe1937 Binary files /dev/null and b/css/fonts/NotoSans-Regular-webfont.ttf differ diff --git a/inc/SP/Controller/ItemShowController.class.php b/inc/SP/Controller/ItemShowController.class.php index 4c379ea1..f02cbd35 100644 --- a/inc/SP/Controller/ItemShowController.class.php +++ b/inc/SP/Controller/ItemShowController.class.php @@ -27,12 +27,18 @@ namespace SP\Controller; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); +use SP\Account\Account; +use SP\Account\AccountHistory; use SP\Api\ApiTokensUtil; +use SP\Core\Acl; use SP\Core\ActionsInterface; +use SP\Core\Crypt; +use SP\Core\Exceptions\ItemException; use SP\Core\Init; use SP\Core\Session; use SP\Core\SessionUtil; use SP\Core\Template; +use SP\DataModel\AccountExtData; use SP\DataModel\CategoryData; use SP\DataModel\CustomerData; use SP\DataModel\CustomFieldData; @@ -41,7 +47,6 @@ use SP\DataModel\GroupData; use SP\DataModel\ProfileData; use SP\DataModel\TagData; use SP\DataModel\UserData; -use SP\Http\JsonResponse; use SP\Http\Request; use SP\Log\Log; use SP\Mgmt\Categories\Category; @@ -51,14 +56,15 @@ use SP\Mgmt\CustomFields\CustomFieldDef; use SP\Mgmt\CustomFields\CustomFieldTypes; use SP\Mgmt\Files\FileUtil; use SP\Mgmt\Groups\GroupUsers; -use SP\Mgmt\ItemSelectInterface; use SP\Mgmt\PublicLinks\PublicLink; use SP\Mgmt\Groups\Group; use SP\Mgmt\Profiles\Profile; use SP\Mgmt\Profiles\ProfileUtil; use SP\Mgmt\Tags\Tag; use SP\Mgmt\Users\User; +use SP\Mgmt\Users\UserPass; use SP\Util\Checks; +use SP\Util\ImageUtil; use SP\Util\Json; use SP\Util\Util; @@ -224,11 +230,17 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite $this->view->assign('header', _('Editar Etiqueta')); $this->getTag(); break; + case self::ACTION_ACC_VIEW_PASS: + $this->view->assign('header', _('Clave de Cuenta')); + $this->getAccountPass(); + break; default: $this->invalidAction(); } - $this->jsonResponse->setData(['html' => $this->render()]); + if (count($this->jsonResponse->getData()) === 0) { + $this->jsonResponse->setData(['html' => $this->render()]); + } } catch (\Exception $e) { $this->jsonResponse->setDescription($e->getMessage()); } @@ -241,7 +253,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite * * @throws \SP\Core\Exceptions\SPException */ - public function getUser() + protected function getUser() { $this->module = self::ACTION_USR_USERS; $this->view->addTemplate('users'); @@ -260,7 +272,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener la lista de campos personalizados y sus valores */ - private function getCustomFieldsForItem() + protected function getCustomFieldsForItem() { $this->view->assign('customFields', CustomField::getItem(new CustomFieldData($this->module))->getById($this->itemId)); } @@ -268,7 +280,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Inicializar la vista de cambio de clave de usuario */ - public function getUserPass() + protected function getUserPass() { $this->module = self::ACTION_USR_USERS; $this->setAction(self::ACTION_USR_USERS_EDITPASS); @@ -287,7 +299,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de grupo */ - public function getGroup() + protected function getGroup() { $this->module = self::ACTION_USR_GROUPS; $this->view->addTemplate('groups'); @@ -304,7 +316,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de perfil */ - public function getProfile() + protected function getProfile() { $this->module = self::ACTION_USR_PROFILES; $this->view->addTemplate('profiles'); @@ -325,7 +337,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de cliente */ - public function getCustomer() + protected function getCustomer() { $this->module = self::ACTION_MGM_CUSTOMERS; $this->view->addTemplate('customers'); @@ -339,7 +351,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de categoría */ - public function getCategory() + protected function getCategory() { $this->module = self::ACTION_MGM_CATEGORIES; $this->view->addTemplate('categories'); @@ -353,7 +365,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de tokens de API */ - public function getToken() + protected function getToken() { $this->module = self::ACTION_MGM_APITOKENS; $this->view->addTemplate('tokens'); @@ -376,7 +388,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la ficha de campo personalizado */ - public function getCustomField() + protected function getCustomField() { $this->module = self::ACTION_MGM_CUSTOMFIELDS; $this->view->addTemplate('customfields'); @@ -396,7 +408,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite * * @throws \SP\Core\Exceptions\SPException */ - public function getPublicLink() + protected function getPublicLink() { $this->module = self::ACTION_MGM_PUBLICLINKS; $this->view->addTemplate('publiclinks'); @@ -413,7 +425,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite * * @throws \SP\Core\Exceptions\SPException */ - public function getTag() + protected function getTag() { $this->module = self::ACTION_MGM_TAGS; $this->view->addTemplate('tags'); @@ -426,7 +438,7 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite /** * Obtener los datos para la vista de archivos de una cuenta */ - public function getAccountFiles() + protected function getAccountFiles() { $this->setAction(self::ACTION_ACC_FILES); @@ -442,4 +454,82 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite $this->jsonResponse->setStatus(0); } + + /** + * Mostrar la clave de una cuenta + * + * @throws ItemException + */ + public function getAccountPass() + { + $this->setAction(self::ACTION_ACC_VIEW_PASS); + + $isHistory = Request::analyze('isHistory', false); + $isFull = Request::analyze('isFull', false); + + $AccountData = new AccountExtData(); + + if (!$isHistory) { + $AccountData->setAccountId($this->itemId); + $Account = new Account($AccountData); + } else { + $Account = new AccountHistory($AccountData); + $Account->setId($this->itemId); + } + + $Account->getAccountPassData(); + + if ($isHistory && !$Account->checkAccountMPass()) { + throw new ItemException(_('La clave maestra no coincide')); + } + + $Acl = new Acl(Acl::ACTION_ACC_VIEW_PASS); + $Acl->setAccountData($Account->getAccountDataForACL()); + + if (!Acl::checkUserAccess(Acl::ACTION_ACC_VIEW_PASS) || !$Acl->checkAccountAccess()) { + throw new ItemException(_('No tiene permisos para acceder a esta cuenta')); + } elseif (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) { + throw new ItemException(_('Clave maestra actualizada') . '
' . _('Reinicie la sesión para cambiarla')); + } + + $accountClearPass = Crypt::getDecrypt($AccountData->getAccountPass(), $AccountData->getAccountIV()); + + if (!$isHistory) { + $Account->incrementDecryptCounter(); + + $log = new Log(_('Ver Clave')); + $log->addDetails(_('ID'), $this->itemId); + $log->addDetails(_('Cuenta'), $AccountData->getCustomerName() . ' / ' . $AccountData->getAccountName()); + $log->writeLog(); + } + + $useImage = (int)Checks::accountPassToImageIsEnabled(); + + if (!$useImage) { + $pass = $isFull ? htmlentities(trim($accountClearPass)) : trim($accountClearPass); + } else { + $pass = ImageUtil::convertText($accountClearPass); + } + + $this->jsonResponse->setStatus(0); + + if ($isFull) { + $this->view->addTemplate('viewpass', 'account'); + + $this->view->assign('login', $AccountData->getAccountLogin()); + $this->view->assign('pass', $pass); + $this->view->assign('isImage', $useImage); + + return; + } + + $data = [ + 'acclogin' => $AccountData->getAccountLogin(), + 'accpass' => $pass, + 'useimage' => $useImage + ]; + + $this->jsonResponse->setCsrf($this->view->sk); + $this->jsonResponse->setData($data); + } } \ No newline at end of file diff --git a/inc/SP/Core/Exceptions/ItemException.class.php b/inc/SP/Core/Exceptions/ItemException.class.php new file mode 100644 index 00000000..34958263 --- /dev/null +++ b/inc/SP/Core/Exceptions/ItemException.class.php @@ -0,0 +1,36 @@ +. + */ + +namespace SP\Core\Exceptions; + + +/** + * Class ItemException + * + * @package SP\Core\Exceptions + */ +class ItemException extends \Exception +{ + +} \ No newline at end of file diff --git a/inc/SP/Util/ImageUtil.class.php b/inc/SP/Util/ImageUtil.class.php index 73139b1f..6e08bf1d 100644 --- a/inc/SP/Util/ImageUtil.class.php +++ b/inc/SP/Util/ImageUtil.class.php @@ -65,7 +65,7 @@ class ImageUtil imagefilledrectangle($im, 0, 0, strlen($text) * 20, 29, $bgColor); // Ruta de la fuente - $font = Init::$SERVERROOT . '/imgs/NotoSansUI-Regular.ttf'; + $font = Init::$SERVERROOT . '/css/fonts/NotoSans-Regular-webfont.ttf'; // Sombra // imagettftext($im, 14, 0, 13, 23, $shadowColor, $font, $text); diff --git a/inc/themes/material-blue/css/styles.css b/inc/themes/material-blue/css/styles.css index ee06ac34..7e7cae42 100644 --- a/inc/themes/material-blue/css/styles.css +++ b/inc/themes/material-blue/css/styles.css @@ -263,7 +263,8 @@ pre, code, samp, kbd { margin: 0 } -#content td.descField, #fancyContainer td.descField { +#content td.descField, +#fancyContainer td.descField { text-align: right; padding-right: 20px; width: 25%; @@ -921,12 +922,41 @@ pre, code, samp, kbd { } #fancyContainer { - width: auto; + min-width: 25em; max-width: 50em; margin: 5em auto; padding: 0; background-color: #fff; - border-radius: 5px; +} + +#fancyContainer > h2 { + width: 100%; + font-size: 18px; + color: white; + background-color: #607d8b; + margin: 0 0 1em 0; + padding: .5em 0; + line-height: 1em; +} + +#fancyContainer > table { + width: 100%; + padding-bottom: 1em; +} + +#fancyContainer select { + width: 220px +} + +#fancyContainer #resFancyAccion { + display: none +} + +#fancyContainer #resCheck { + display: inline-block; + width: 80%; + height: 4em; + padding: 1em 0 } #fancyContainer.image { @@ -947,20 +977,6 @@ pre, code, samp, kbd { padding: .5em; } -#fancyContainer > h2 { - width: 100%; - font-size: 18px; - color: white; - background-color: #607d8b; - margin: 0 0 1em 0; - padding: .5em 0; - line-height: 1em; -} - -#fancyContainer select { - width: 220px -} - #fancyContainer.help { min-height: 100px; background-color: #f5f5f5 @@ -972,17 +988,6 @@ pre, code, samp, kbd { line-height: 2em } -#fancyContainer #resFancyAccion { - display: none -} - -#fancyContainer #resCheck { - display: inline-block; - width: 80%; - height: 4em; - padding: 1em 0 -} - #debug { float: left; text-align: left @@ -1365,10 +1370,9 @@ footer img { line-height: 2.5em } -.dialog-clip-pass-copy { +.dialog-clip-copy { background-color: #ecfde4; color: green; - border: #dbfdcb 1px solid } .help-box { @@ -1665,6 +1669,18 @@ fieldset.warning a { display: none; } +.center { + text-align: center !important; +} + +.right { + text-align: right !important; +} + +.left { + text-align: left !important; +} + @media screen and (max-width: 1000px) { #content #searchbox { position: relative; diff --git a/inc/themes/material-blue/views/account/account-editpass.inc b/inc/themes/material-blue/views/account/account-editpass.inc index 94c12e7a..bbdf7914 100644 --- a/inc/themes/material-blue/views/account/account-editpass.inc +++ b/inc/themes/material-blue/views/account/account-editpass.inc @@ -1,113 +1,119 @@ -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
- date_range -
- - - - - -
- - - +
+
+ +
- +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ date_range +
+ + + + + +
+
    +
  • + +
  • +
  • + +
  • +
+
+
+
diff --git a/inc/themes/material-blue/views/main/body-footer.inc b/inc/themes/material-blue/views/main/body-footer.inc index acf0b958..34990708 100644 --- a/inc/themes/material-blue/views/main/body-footer.inc +++ b/inc/themes/material-blue/views/main/body-footer.inc @@ -3,12 +3,11 @@