function saveVoicemail($arrProp) { $exitoVM = true; $pVM = new paloVoicemail($this->_DB); $existVM = $pVM->existVoicemail($arrProp['exten'], $arrProp['domain']); if ($arrProp['create_vm'] == "yes") { if ($existVM == false) { $arrVoicemail["context"] = "default"; } $arrVoicemail['organization_domain'] = $arrProp['domain']; $arrVoicemail['mailbox'] = $arrProp['exten']; $arrVoicemail["password"] = isset($arrProp["vmpassword"]) ? $arrProp["vmpassword"] : null; $arrVoicemail["email"] = isset($arrProp["vmemail"]) ? $arrProp["vmemail"] : null; $arrVoicemail["attach"] = isset($arrProp["vmattach"]) ? $arrProp["vmattach"] : null; $arrVoicemail["saycid"] = isset($arrProp["vmsaycid"]) ? $arrProp["vmsaycid"] : null; $arrVoicemail["envelope"] = isset($arrProp["vmenvelope"]) ? $arrProp["vmenvelope"] : null; $arrVoicemail["deletevoicemail"] = isset($arrProp["vmdelete"]) ? $arrProp["vmdelete"] : null; $arrVoicemail["language"] = isset($arrProp["language"]) ? $arrProp["language"] : null; if ($existVM) { $exitoVM = $pVM->updateParameters($arrVoicemail); } else { $pVM->setVoicemailProp($arrVoicemail, $arrProp['domain']); $exitoVM = $pVM->createVoicemail(); } } else { if ($existVM) { $exitoVM = $pVM->deletefromDB($arrProp['exten'], $arrProp['domain']); } } if (!$exitoVM) { $this->errMsg = _tr("Error setting voicemail parameters") . $pVM->errMsg; return false; } return true; }
function deleteExtension($extension) { //validamos que la instacia del objeto haya sido creada correctamente if (!$this->validatePaloDevice()) { return false; } $query = "Select id, organization_domain, exten, device, tech, voicemail, elxweb_device from extension where exten=? and organization_domain=?"; $result = $this->tecnologia->getFirstResultQuery($query, array($extension, $this->domain), true, "Don't exist extension {$extension}. "); if ($result == false && $this->tecnologia->errMsg != "Don't exist extension {$extension}. ") { $this->errMsg = "Extension can't be deleted. " . $this->tecnologia->errMsg; return false; } else { if (is_array($result) && count($result) > 0) { //se borra el voicemail asociado a la extension if (isset($result["voicemail"]) && $result["voicemail"] != "novm") { $pVoicemail = new paloVoicemail($this->tecnologia->_DB); $dvoicemial = $pVoicemail->deletefromDB($result["exten"], $this->domain); } $device = $result["device"]; $tech = $result["tech"]; if ($tech == "sip") { $this->tecnologia = new paloSip($this->tecnologia->_DB); } elseif ($tech == "iax2") { $this->tecnologia = new paloIax($this->tecnologia->_DB); } if (!$this->tecnologia->deletefromDB($device)) { $this->errMsg = "Device {$device} can not be deleted. " . $this->tecnologia->errMsg; return false; } if (!empty($result["elxweb_device"])) { $query = "DELETE FROM im WHERE device=? and organization_domain=?"; $exito = $this->tecnologia->executeQuery($query, array($result["elxweb_device"], $this->domain)); if (!$exito) { $this->errMsg = "Extension can't be deleted. " . $this->tecnologia->errMsg; return false; } if ($tech == "sip") { if (!$this->tecnologia->deletefromDB($result["elxweb_device"])) { $this->errMsg = "Device {$device} can not be deleted. " . $this->tecnologia->errMsg; return false; } } } $dquery = "delete from extension where device=? and tech=? and organization_domain=?"; $exito = $this->tecnologia->executeQuery($dquery, array($device, $tech, $this->domain)); if (!$exito) { $this->errMsg = "Extension can't be deleted. " . $this->tecnologia->errMsg; return false; } //borramos las entradas dentro de astDB $this->deleteAstDBExt($extension, $tech); } } return true; }