$Profile->setMgmProfiles(SP\Request::analyze('profile_profiles', 0, false, 1)); $Profile->setMgmApiTokens(SP\Request::analyze('profile_apitokens', 0, false, 1)); $Profile->setEvl(SP\Request::analyze('profile_eventlog', 0, false, 1)); if ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_EDIT) { if (!$Profile->getName()) { SP\Response::printJSON(_('Es necesario un nombre de perfil'), 2); } elseif (SP\Profile::checkProfileExist($Profile->getId(), $Profile->getName())) { SP\Response::printJSON(_('Nombre de perfil duplicado'), 2); } if ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_NEW) { if ($Profile->profileAdd()) { SP\Response::printJSON(_('Perfil creado'), 0, $doActionOnClose); } SP\Response::printJSON(_('Error al crear el perfil')); } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_EDIT) { if ($Profile->profileUpdate()) { SP\Response::printJSON(_('Perfil actualizado'), 0, $doActionOnClose); } SP\Response::printJSON(_('Error al actualizar el perfil')); } } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_DELETE) { $resProfileUse = SP\Profile::checkProfileInUse($Profile->getId()); if ($resProfileUse['users'] > 0) { $uses[] = _('Usuarios') . " (" . $resProfileUse['users'] . ")"; SP\Response::printJSON(_('No es posible eliminar') . ';;' . _('Perfil en uso por:') . ';;' . implode(';;', $uses)); } else { if ($Profile->profileDelete()) { SP\Response::printJSON(_('Perfil eliminado'), 0, $doActionOnClose); } SP\Response::printJSON(_('Error al eliminar el perfil')); }