function deleteUserOrganization($idUser) { $pACL = new paloACL($this->_DB); $pEmail = new paloEmail($this->_DB); $pFax = new paloFax($this->_DB); $Exito = false; //1)se comprueba de que el ID de USUARIO se un numero //2)se verifica que exista dicho usuario //3)se recompila los datos del usuario de las tablas acl_user y user_properties //4)se elimina al usuario de la base //5)se elimina la extension de uso del usuario y la extension de fax //6)se trata de eliminar la cuenta de fax //7)se elimina el buzon de correo if (!preg_match('/^[[:digit:]]+$/', "{$idUser}")) { $this->errMsg = _tr("User ID is not numeric"); return false; } else { $arrUser = $pACL->getUsers($idUser); if ($arrUser === false || count($arrUser) == 0) { $this->errMsg = _tr("User dosen't exist"); return false; } } $idDomain = $arrUser[0][4]; $query = "Select domain from organization where id=?"; $getDomain = $this->_DB->getFirstRowQuery($query, false, array($idDomain)); if ($getDomain == false) { $this->errMsg = $this->_DB->errMsg; return false; } $pDevice = new paloDevice($getDomain[0], "sip", $this->_DB); $arrExten = $pDevice->getExtension($arrUser[0][5]); $faxList = $pFax->getFaxList($arrUser[0][6], $getDomain[0]); $arrFaxExten = $faxList[0]; $this->_DB->beginTransaction(); //tomamos un backup de las extensiones que se van a eliminar de la base astDB por si algo sale mal //y ahi que restaurar la extension $arrExt = $pDevice->backupAstDBEXT($arrUser[0][5]); if ($pDevice->deleteExtension($arrUser[0][5])) { if ($pFax->deleteFaxByUser($idUser)) { if ($pACL->deleteUser($idUser)) { if ($pEmail->deleteAccount($arrUser[0][1])) { $Exito = true; $this->_DB->commit(); $pDevice->tecnologia->prunePeer($arrExten["device"], $arrExten["tech"]); $pDevice->tecnologia->prunePeer($arrFaxExten["device"], $arrFaxExten["tech"]); $pFax->restartService(); } else { $this->errMsg = _tr("Email Account cannot be deleted") . $pEmail->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]); } } else { $this->errMsg = $pACL->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]); } } else { $this->errMsg = _tr("Fax cannot be deleted") . $pFax->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); } } else { $this->errMsg = _tr("User Extension can't be deleted") . $pDevice->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); } return $Exito; }
function editFaxExten($arrProp) { require_once "libs/paloSantoPBX.class.php"; $errorData = array(); $errorBoolean = false; $arrProp['idUser'] = $this->idUser; if ($arrProp['clid_name'] == '') { $errorData['field'][] = "CID_NAME"; $errorBoolean = true; } if ($arrProp['clid_number'] == '') { $errorData['field'][] = "CID_NUMBER"; $errorBoolean = true; } elseif (!preg_match('/^[0-9]+$/', $arrProp['clid_number'])) { $errorData['field'][] = "CID_NUMBER"; $errorBoolean = true; } if ($arrProp['country_code'] == '') { $errorData['field'][] = "COUNTRY_CODE"; $errorBoolean = true; } elseif (!preg_match('/^[0-9]+$/', $arrProp['country_code'])) { $errorData['field'][] = "COUNTRY_CODE"; $errorBoolean = true; } if ($arrProp['area_code'] == '') { $errorData['field'][] = "AREA_CODE"; $errorBoolean = true; } elseif (!preg_match('/^[0-9]+$/', $arrProp['area_code'])) { $errorData['field'][] = "AREA_CODE"; $errorBoolean = true; } if ($arrProp['fax_subject'] == '') { $errorData['field'][] = "FAX_SUBJECT"; $errorBoolean = true; } if ($arrProp['fax_content'] == '') { $errorData['field'][] = "FAX_CONTENT"; $errorBoolean = true; } if ($errorBoolean) { $errorData['stringError'] = "Some fields are wrong"; $this->errMsg = $errorData; return false; } $pMyFax = new paloFax($this->_DB); if (!$pMyFax->editFaxToUser($arrProp)) { $this->errMsg = array('stringError' => $pMyFax->errMsg); return false; } if (!$pMyFax->restartService()) { $this->errMsg = $pMyFax->errMsg; } return true; }