. * */ define('APP_ROOT', '..'); include_once (APP_ROOT . "/inc/init.php"); SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printXML(_('La sesión no se ha iniciado o ha caducado'), 10); } $sk = SP_Common::parseParams('p', 'sk', FALSE); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printXML(_('CONSULTA INVÁLIDA')); } // Variables POST del formulario $frmSaveType = SP_Common::parseParams('p', 'type', 0); $frmAction = SP_Common::parseParams('p', 'action', 0); $frmItemId = SP_Common::parseParams('p', 'id', 0); if ($frmAction == 3) { SP_Users::checkUserAccess("acceditpass", $frmItemId) || die('
userId = $frmItemId; $objUser->userName = $frmUsrName; $objUser->userLogin = $frmUsrLogin; $objUser->userEmail = $frmUsrEmail; $objUser->userNotes = $frmUsrNotes; $objUser->userGroupId = $frmUsrGroup; $objUser->userProfileId = $frmUsrProfile; $objUser->userIsAdminApp = $frmAdminApp; $objUser->userIsAdminAcc = $frmAdminAcc; $objUser->userIsDisabled = $frmDisabled; $objUser->userPass = $frmUsrPass; switch ($objUser->checkUserExist()) { case 1: SP_Common::printXML(_('Login de usuario duplicado'), 2); break; case 2: SP_Common::printXML(_('Email de usuario duplicado'), 2); break; } if ($frmAction == 1) { if (!$frmUsrPass && !$frmUsrPassV) { SP_Common::printXML(_('La clave no puede estar en blanco'), 2); } if ($frmUsrPass != $frmUsrPassV) { SP_Common::printXML(_('Las claves no coinciden'), 2); } if ($objUser->manageUser("add")) { $message['action'] = _('Nuevo Usuario'); $message['text'][] = _('Nombre') . ': ' . $frmUsrName . ' (' . $frmUsrLogin . ')'; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Usuario creado'), 0); } SP_Common::printXML(_('Error al crear el usuario')); } elseif ($frmAction == 2) { if ($objUser->manageUser("update")) { $message['action'] = _('Modificar Usuario'); $message['text'][] = _('Nombre') . ': ' . $frmUsrName . ' (' . $frmUsrLogin . ')'; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Usuario actualizado'), 0); } SP_Common::printXML(_('Error al actualizar el usuario')); } // Cambio de clave } elseif ($frmAction == 3 && !SP_Config::getValue('demoenabled', 0)) { if (!$frmUsrPass || !$frmUsrPassV) { SP_Common::printXML(_('La clave no puede estar en blanco'), 2); } if ($frmUsrPass != $frmUsrPassV) { SP_Common::printXML(_('Las claves no coinciden'), 2); } $objUser->userId = $frmItemId; $objUser->userPass = $frmUsrPass; if ($objUser->manageUser("updatepass")) { $message['action'] = _('Modificar Clave Usuario'); $message['text'][] = _('Nombre') . ': ' . $frmUsrName . ' (' . $frmUsrLogin . ')'; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Clave actualizada'), 0); } SP_Common::printXML(_('Error al modificar la clave')); // Eliminar usuario } elseif ($frmAction == 4 && !SP_Config::getValue('demoenabled', 0)) { $objUser->userId = $frmItemId; if ($frmItemId == $_SESSION["uid"]) { SP_Common::printXML(_('No es posible eliminar, usuario en uso')); } if ($objUser->manageUser("delete")) { $message['action'] = _('Eliminar Usuario'); $message['text'][] = _('Login') . ': ' . $frmUsrName . ' (' . $frmUsrLogin . ')'; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Usuario eliminado'), 0); } SP_Common::printXML(_('Error al eliminar el usuario')); } SP_Common::printXML(_('No es una acción válida')); } elseif ($frmSaveType == 3 || $frmSaveType == 4) { // Variables POST del formulario $frmGrpName = ( isset($_POST["name"]) ) ? SP_Html::sanitize($_POST["name"]) : ""; $frmGrpDesc = ( isset($_POST["description"]) ) ? SP_Html::sanitize($_POST["description"]) : ""; // Nuevo grupo o editar if ($frmAction == 1 OR $frmAction == 2) { if (!$frmGrpName) { SP_Common::printXML(_('Es necesario un nombre de grupo'), 2); } $objUser->groupId = $frmItemId; $objUser->groupName = $frmGrpName; $objUser->groupDesc = $frmGrpDesc; if (!$objUser->checkGroupExist()) { SP_Common::printXML(_('Nombre de grupo duplicado'), 2); } if ($frmAction == 1) { if ($objUser->manageGroup("add")) { $message['action'] = _('Nuevo Grupo'); $message['text'][] = _('Nombre') . ': ' . $frmGrpName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Grupo creado'), 0); } else { SP_Common::printXML(_('Error al crear el grupo')); } } else if ($frmAction == 2) { if ($objUser->manageGroup("update")) { $message['action'] = _('Modificar Grupo'); $message['text'][] = _('Nombre') . ': ' . $frmGrpName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Grupo actualizado'), 0); } SP_Common::printXML(_('Error al actualizar el grupo')); } // Eliminar grupo } elseif ($frmAction == 4) { $objUser->groupId = $frmItemId; $resGroupUse = $objUser->checkGroupInUse(); if (is_string($resGroupUse)) { SP_Common::printXML(_('No es posible eliminar:Grupo en uso por') . ' ' . $resGroupUse); } else { if ($objUser->manageGroup("delete")) { $message['action'] = _('Eliminar Grupo'); $message['text'][] = _('Nombre') . ': ' . $frmGrpName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Grupo eliminado'), 0); } SP_Common::printXML(_('Error al eliminar el grupo')); } } SP_Common::printXML(_('No es una acción válida')); } elseif ($frmSaveType == 5 || $frmSaveType == 6) { $profileProp = array(); // Variables POST del formulario $frmProfileName = ( isset($_POST["profile_name"]) ) ? SP_Html::sanitize($_POST["profile_name"]) : ""; $objUser->profileId = $frmItemId; // Profile properties Array $profileProp["pAccView"] = SP_Common::parseParams('p', 'profile_accview', 0, FALSE, 1); $profileProp["pAccViewPass"] = SP_Common::parseParams('p', 'profile_accviewpass', 0, FALSE, 1); $profileProp["pAccViewHistory"] = SP_Common::parseParams('p', 'profile_accviewhistory', 0, FALSE, 1); $profileProp["pAccEdit"] = SP_Common::parseParams('p', 'profile_accedit', 0, FALSE, 1); $profileProp["pAccEditPass"] = SP_Common::parseParams('p', 'profile_acceditpass', 0, FALSE, 1); $profileProp["pAccAdd"] = SP_Common::parseParams('p', 'profile_accadd', 0, FALSE, 1); $profileProp["pAccDel"] = SP_Common::parseParams('p', 'profile_accdel', 0, FALSE, 1); $profileProp["pAccFiles"] = SP_Common::parseParams('p', 'profile_accfiles', 0, FALSE, 1); $profileProp["pConfig"] = SP_Common::parseParams('p', 'profile_config', 0, FALSE, 1); $profileProp["pConfigCat"] = SP_Common::parseParams('p', 'profile_configcat', 0, FALSE, 1); $profileProp["pConfigMpw"] = SP_Common::parseParams('p', 'profile_configmpw', 0, FALSE, 1); $profileProp["pConfigBack"] = SP_Common::parseParams('p', 'profile_configback', 0, FALSE, 1); $profileProp["pUsers"] = SP_Common::parseParams('p', 'profile_users', 0, FALSE, 1); $profileProp["pGroups"] = SP_Common::parseParams('p', 'profile_groups', 0, FALSE, 1); $profileProp["pProfiles"] = SP_Common::parseParams('p', 'profile_profiles', 0, FALSE, 1); $profileProp["pEventlog"] = SP_Common::parseParams('p', 'profile_eventlog', 0, FALSE, 1); // Nuevo perfil o editar if ($frmAction == 1 OR $frmAction == 2) { if (!$frmProfileName) { SP_Common::printXML(_('Es necesario un nombre de perfil'), 2); } $objUser->profileName = $frmProfileName; if (!$objUser->checkProfileExist()) { SP_Common::printXML(_('Nombre de perfil duplicado'), 2); } if ($frmAction == 1) { if ($objUser->manageProfiles("add", $profileProp)) { $message['action'] = _('Nuevo Perfil'); $message['text'][] = _('Nombre') . ': ' . $frmProfileName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Perfil creado'), 0); } SP_Common::printXML(_('Error al crear el perfil')); } else if ($frmAction == 2) { if ($objUser->manageProfiles("update", $profileProp)) { $message['action'] = _('Modificar Perfil'); $message['text'][] = _('Nombre') . ': ' . $frmProfileName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Perfil actualizado'), 0); } SP_Common::printXML(_('Error al actualizar el perfil')); } // Eliminar perfil } elseif ($frmAction == 4) { $resProfileUse = $objUser->checkProfileInUse(); if (is_string($resProfileUse)) { SP_Common::printXML(_('No es posible eliminar: Perfil en uso por') . ' ' . $resProfileUse); } else { if ($objUser->manageProfiles("delete")) { $message['action'] = _('Eliminar Perfil'); $message['text'][] = _('Nombre') . ': ' . $frmProfileName; SP_Common::wrLogInfo($message); SP_Common::sendEmail($message); SP_Common::printXML(_('Perfil eliminado'), 0); } SP_Common::printXML(_('Error al eliminar el perfil')); } } SP_Common::printXML(_('No es una acción válida')); }