public function loadSubModels(ServicePackModel $service) { $lcService = LifeCycleService::getInstance(); if ($service->getLifeCycleId() && ($item = $lcService->load($service->getLifeCycleId()))) { $service->setLifeCycle($item); } $restricService = RestrictionService::getInstance(); if ($service->getRestrictionsId() && ($item = $restricService->load($service->getRestrictionsId()))) { $steeringListService = SteeringListService::getInstance(); if ($steeringModel = $steeringListService->loadByServicePack($service->id)) { $item->steering = $steeringModel; $steeringListService->reorderOperators($steeringModel, $item); } else { $contractService = ContractService::getInstance(); $contracts = $contractService->getContractsByServiceType('csrm')->getItems(); if (!empty($contracts)) { // Fallback: if there should be a steering list, we will make it $item->steering = new SteeringListModel(); $item->steering->steeringType = SteeringListModel::TYPE_BOTH; $item->steering->useCustomOrder = false; $steeringListService->applySteering($item, $service->id); } } $service->setRestrictions($item); } $tariffService = TariffPlanService::getInstance(); if ($service->getTariffPlanServicesId() && ($item = $tariffService->load(TariffPlanService::TYPE_SERVICES, $service->getTariffPlanServicesId()))) { $service->setTariffPlanServices($item); } if ($service->getTariffPlanLifeCycleId() && $service->getLifeCycleId() && ($item = $tariffService->load(TariffPlanService::TYPE_LIFECYCLE, $service->getTariffPlanLifeCycleId()))) { $service->setTariffPlanLifeCycle($item); } }
/** * Validate element value * * If a translation adapter is registered, any error messages will be * translated according to the current locale, using the given error code; * if no matching translation is found, the original message will be * utilized. * * Note: The *filtered* value is validated. * * @param array $data * @param mixed $context * @return boolean */ public function isValid($data, $context = null, $removeNotPresentFields = false) { if (!($data instanceof RestrictionModel || $this->_acceptArrayAsModel && is_array($data))) { $this->_messages = array(); $this->_messages[self::NOT_RESTRICTIONS] = $this->_messageTemplatesUser[self::NOT_RESTRICTIONS]; return false; } if (!parent::isValid($data, $context, $removeNotPresentFields)) { return false; } if (!$data instanceof RestrictionModel) { $data = new RestrictionModel($data); } $contracts = ContractService::getInstance()->getContractsByServiceType('csrm')->getItems(); if (!empty($contracts)) { $validator = new \Zend_Validate_NotEmpty(); } else { $validator = new \App_Validate_Empty(); } if (!$validator->isValid($data->steering)) { $this->_messages['steering'] = $validator->getMessages(); return false; } // If Voice HOME = SMS HOME, roaming is linked if ($data->getVoice() && $data->getVoice()->getMo() && $data->getSms() && $data->getSms()->getMo() && $data->getVoice()->getMo()->getHome() === $data->getSms()->getMo()->getHome() && $data->getVoice()->getMo()->getRoaming() !== $data->getSms()->getMo()->getRoaming()) { $this->_messages = array(); $this->_messages[self::NOT_SYNC_VOICE_SMS_ROAMING] = $this->_messageTemplatesUser[self::NOT_SYNC_VOICE_SMS_ROAMING]; return false; } // https://jira.tid.es/browse/GLOBALPORTAL-115352 // if ($data->getSms() && $data->getSms()->getMo() && // // If HOME is disabled and Roaming Enabled // (($data->getSms()->getMo()->getHome() && !$data->getSms()->getMo()->getRoaming()) || // // If HOME is enabled and Roaming !== International // (isset($data->getSms()->getMo()->roaming) && // $data->getSms()->getMo()->getRoaming() !== $data->getSms()->getMo()->getInternational()))) { // $this->_messages = array(); // $this->_messages[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE] = // $this->_messageTemplatesUser[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE]; // return false; // } // Validate leading/commercial OB $org = \App::getOrgUserLogged(); $orgProvider = OrgService::getInstance()->getParentByType($org->id, OrgServiceProviderModel::ORG_TYPE); if ($orgProvider && \Application\Service\OrgService::getInstance()->isCommercial($orgProvider)) { $validator = new RestrictionsCommercialValidate(); if (!$validator->isValid($data, $context, $removeNotPresentFields)) { $this->_messages = $validator->getMessages(); return false; } } return true; }
/** * Performs an authentication attempt * * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed * @return Zend_Auth_Result */ public function authenticate() { if (empty($this->_request) || empty($this->_response)) { throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling authenticate method'); } try { $token = $this->_getAuthToken(); $serviceSession = ServiceSessionService::getInstance()->checkToken($token); $fakeUserId = $serviceSession->originServiceId; $orgId = ''; if ($serviceSession->contractId) { $contract = ContractService::getInstance()->load($serviceSession->contractId); if (empty($contract)) { throw new InvalidArgumentException("Invalid contract id '{$serviceSession->contractId}'"); } $orgId = $contract->organizationId; } \Application\Model\Mapper\ProtoAbstractMapper::$accountingTransactionPrefix = $this->_prefix; \Application\Model\Mapper\ProtoAbstractMapper::$accountingUserId = '3rdParty_' . $fakeUserId; \Application\Model\Mapper\AbstractMapper::$organizationId = $orgId; $orgSrv = \Application\Service\OrgService::getInstance(); $organization = $orgSrv->load($orgId); if (empty($organization)) { throw new NotFoundException("Org '{$orgId}' not found"); } \Application\Model\Mapper\ProtoAbstractMapper::$language = $organization->defaultLanguage; $result = array('id' => $fakeUserId, 'username' => '3rdParty_' . $serviceSession->originServiceId, 'token' => $token, 'orgId' => $orgId, 'role' => 'admin', 'authType' => App_Controller_Plugin_Auth::AUTH_TYPE_THIRD_PARTY, 'serviceId' => $serviceSession->originServiceId, 'contractId' => $serviceSession->contractId, 'monetaryDataAccess' => false); return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result); } catch (Exception $e) { \App::log()->err($e->getMessage()); } if (!empty($token)) { \App::log()->warn("3rd party token authentication failed: TOKEN => " . $token); } else { \App::log()->warn("3rd party token authentication failed: NO TOKEN "); } return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null); }
public function getDefaultOrder() { $contractService = ContractService::getInstance(); $contracts = $contractService->getContractsByServiceType('csrm')->getItems(); if (empty($contracts)) { return; } $entities = $contractService->getEntitiesByContract($contracts[0]->id); if (empty($entities)) { return; } $steeringList = array(); foreach ($entities as $value) { if (isset($value["name"]) && $value["name"] == "steeringList") { $steeringList = $value["data"]; break; } } if (empty($steeringList)) { return; } return isset($steeringList['defaultOrder']) ? $steeringList['defaultOrder'] : array(); }
public function setUp() { $this->_service = ContractService::getInstance(); }