public function findAll($filters = array(), $options = array())
 {
     $data = array();
     if (OrganizationMapper::getTypeByOrgId(self::$organizationId) === OrgServiceProviderModel::ORG_TYPE) {
         if (isset($filters['filterList']) && $filters['filterList'] instanceof \App_ListFilter) {
             $data['filterList'] = $filters['filterList'];
         } else {
             $data['filterList'] = new \App_ListFilter();
         }
         $data['paging'] = $options;
         $itemData = $this->_findAllEricsson($data);
     } else {
         $itemData = $this->_findAllCustomerEricsson();
     }
     $items = array();
     foreach ($itemData['items'] as $id => $data) {
         $items[$id] = new Model\PreBillModel($data);
     }
     $result = new Model\ListResultModel();
     $result->setItems($items);
     if (isset($itemData['count'])) {
         $result->setCount($itemData['count']);
     }
     return $result;
 }
示例#2
0
 /**
  * User dependencies injection
  */
 public static function initUserAccount()
 {
     $ident = \Zend_Auth::getInstance()->getIdentity();
     // Transaction injection
     \App::get("trackingtoken");
     ProtoAbstractMapper::$accountingTransactionPrefix = 'Testing-';
     // User injection
     ProtoAbstractMapper::$accountingUserId = $ident['id'];
     ProtoAbstractMapper::$language = 'en';
     $user = \App::getUserLogged(null, true);
     $allowed = Zend_Controller_Action_HelperBroker::getStaticHelper('allowed');
     $allowed->setUser($user);
     AbstractMapper::$organizationId = $user->organizationId;
     // Org injection
     if (!empty($ident['orgId'])) {
         $org = OrgService::getInstance()->load($ident['orgId']);
         if (!$org) {
             $org = OrgModelFactory::factory(array('id' => $ident['orgId'], 'type' => OrganizationMapper::getTypeByOrgId($ident['orgId'])));
         }
         \App::getOrgUserLogged($org);
         AbstractMapper::$organizationId = $ident['orgId'];
     }
     WatcherMapper::getInstance()->destroySingleton();
 }
 /**
  * Validate that report organization is a customer
  *
  * @param array $params
  */
 protected function _validateCustomerOrg(array &$params, $type = null)
 {
     $orgId = \App::getOrgUserLogged()->id;
     switch (Mapper\OrganizationMapper::getTypeByOrgId($orgId)) {
         case Model\Organization\OrgCustomerModel::ORG_TYPE:
             $params[ReportFilterFields::ORGANIZATION] = $orgId;
             break;
         case Model\Organization\OrgServiceProviderModel::ORG_TYPE:
             $this->_validateMandatoryParams($params, array(ReportFilterFields::ORGANIZATION));
             break;
     }
     if (Mapper\OrganizationMapper::getTypeByOrgId($params[ReportFilterFields::ORGANIZATION]) !== Model\Organization\OrgCustomerModel::ORG_TYPE) {
         throw new InvalidArgumentException('Invalid parameter value: ' . ReportFilterFields::ORGANIZATION . '. Supported values are customer-xxxxx');
     }
 }
 protected function _constructProtoSubscriptionSnapshotReportEricsson($params, $proto)
 {
     $orgId = OrganizationMapper::cleanOrgId($params['orgId']);
     $orgType = OrganizationMapper::getTypeByOrgId($params['orgId']);
     switch ($orgType) {
         case OrgMasterModel::ORG_TYPE:
             $type = PbOrg\OrgType::MASTER;
             break;
         case OrgServiceProviderModel::ORG_TYPE:
             $type = PbOrg\OrgType::SERVICE_PROVIDER;
             break;
         case OrgCustomerModel::ORG_TYPE:
             $type = PbOrg\OrgType::CUSTOMER;
             break;
         default:
             throw new InvalidArgumentException("Invalid organization type " . $orgType);
     }
     $target = new PbReport\Target\DailySSTarget();
     $targetOrg = new PbOrg();
     $targetOrg->setType($type);
     $targetOrg->setId($orgId);
     $target->setOrganization($targetOrg);
     $proto->setTarget($target);
     $proto->setDateDaily($params['dateDaily']);
     return $proto;
 }
 /**
  * Returns true if and only if the assertion conditions are met
  *
  * This method is passed the ACL, Role, Resource, and privilege to which
  * the authorization query applies. If the $role, $resource, or $privilege
  * parameters are null, it means that the query applies to all Roles,
  * Resources, or privileges, respectively.
  *
  * @param  Zend_Acl                    $acl
  * @param  Zend_Acl_Role_Interface     $role
  * @param  Zend_Acl_Resource_Interface $resource
  * @param  string                      $privilege
  * @return boolean
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     // We need specific objects to check against each other
     if (NULL === $role || NULL === $resource) {
         return false;
     }
     // Ensure we're handled User models
     if (!$role instanceof UserModel) {
         throw new Exception('Role must be an instance of UserModel');
     }
     $orgId = $role->getOrganizationId();
     switch (true) {
         case $resource instanceof OrgModelAbstract:
             return $orgId === $resource->getId();
         case $resource instanceof UserModel:
         case $resource instanceof TemplateModel:
             return $orgId === $resource->getOrganizationId();
         case $resource instanceof Async\Model\AsyncResponse:
             $cOrgId = \Application\Model\Mapper\OrganizationMapper::cleanOrgId($orgId);
             return $orgId === $resource->getOrganizationId() || $cOrgId === $resource->getOrganizationId();
         case $resource instanceof Model\TariffPlanLifeCycleModel:
         case $resource instanceof Model\TariffPlanServicesModel:
         case $resource instanceof Model\RestrictionModel:
         case $resource instanceof Model\ServicePackModel:
             $orgType = Model\Mapper\OrganizationMapper::getTypeByOrgId($orgId);
             switch ($orgType) {
                 case Model\Organization\OrgServiceProviderModel::ORG_TYPE:
                     return $orgId === $resource->getServiceProviderId();
                 case Model\Organization\OrgCustomerModel::ORG_TYPE:
                     //                         $spList = Service\ServicePackService::getInstance()->listAll();
                     //                         foreach ($spList->getItems() as $sp) {
                     //                             if ($sp->getId() === $resource->getId()) {
                     //                                 return true;
                     //                             }
                     //                         }
                     /*
                      * There is no way to know if only one ServicePack is assigned to a customer,
                      * only retrieving all servicePacks assigned. It is too much slow. In Ericsson we trust.
                      */
                     return true;
                 default:
                     return false;
             }
         case $resource instanceof Model\SupplServicesModel:
             return $orgId === $resource->getServiceProviderId() || $orgId === $resource->getCustomerId();
         case $resource instanceof Model\CommercialGroupModel:
         case $resource instanceof Model\SupervisionGroupModel:
             return $orgId === $resource->getCustomerId();
         case $resource instanceof SimModel:
             /** @var $resource \Application\Model\SimModel */
             return $orgId === $resource->getMasterId() || $orgId === $resource->getServiceProviderCommercialId() || $orgId === $resource->getServiceProviderEnablerId() || $orgId === $resource->getAggregatorId() || $orgId === $resource->getCustomerId() || $orgId === $resource->getEndUserId();
         case $resource instanceof Model\ReportModel:
             $params = $resource->getParams();
             if (isset($params['orgId']) && !empty($params['orgId'])) {
                 return $orgId === $params['orgId'];
             } else {
                 return true;
             }
     }
     throw new Exception('Resource must be an instance of OrgModelAbstract, UserModel or SimModel');
 }
 /**
  * Maps a range message value.
  * @param  \App_ListFilter_Interface $filter
  * @return array
  */
 protected function _mapOrganizationValue(\App_ListFilter_Interface $filter, \App_ListFilter $filterList)
 {
     $orgTypeMap = array(OrgSuperModel::ORG_TYPE => Organization\OrgType::MASTER, OrgMasterModel::ORG_TYPE => Organization\OrgType::MASTER, OrgServiceProviderModel::ORG_TYPE => Organization\OrgType::SERVICE_PROVIDER, OrgCustomerModel::ORG_TYPE => Organization\OrgType::CUSTOMER);
     $data = array();
     switch (get_class($filter)) {
         case 'App_ListFilter_EqualFilter':
             $data['type'] = $orgTypeMap[OrganizationMapper::getTypeByOrgId($filter->getValue())];
             $data['id'] = OrganizationMapper::cleanOrgId($filter->getValue());
             break;
         default:
             return;
     }
     return $data;
 }
 protected function _createSubscriptionBaseTarget(\App_ListFilter $filterList)
 {
     $data = array();
     $proto = '\\Application\\Proto\\Report\\Target\\SubscriptionBaseTarget';
     $this->_setFilter($data, $filterList, ReportFilterFields::ORGANIZATION, $proto, 'id', true);
     $orgId = $filterList->getOneFilterByFieldName(ReportFilterFields::ORGANIZATION)->getValue();
     $filterOrgType = new \App_ListFilter_EqualFilter();
     $filterOrgType->setFieldName('type');
     $filterOrgType->setValue(OrganizationMapper::getTypeByOrgId($orgId));
     $filterList->addFilters(array($filterOrgType));
     $this->_setFilter($data, $filterList, 'type', $proto, 'type', true);
     return array('subscription_base' => $data);
 }
示例#8
0
 public function getTypeById($id)
 {
     return \Application\Model\Mapper\OrganizationMapper::getTypeByOrgId($id);
 }
 protected function _prepareExternalRequest()
 {
     $ident = \Zend_Auth::getInstance()->getIdentity();
     if ($ident['authType'] === \App_Controller_Plugin_Auth::AUTH_TYPE_EXTERNAL) {
         $orgType = \Application\Model\Mapper\OrganizationMapper::getTypeByOrgId($ident['orgId']);
         if ($orgType === \Application\Model\Organization\OrgServiceProviderModel::ORG_TYPE) {
             $appId = '9876543210';
             // provider
         } else {
             $appId = '1234567890';
             // customer
         }
         $this->getRequest()->setHeader('TransactionInfo', 'appid="' . $appId . '"');
     }
 }
 /**
  * Creates a organization proto message from organizationId
  *
  * @param \Application\Proto\Organization $orgId
  */
 protected function _createOrganization($orgId)
 {
     $orgTypeMap = array(OrgSuperModel::ORG_TYPE => Organization\OrgType::MASTER, OrgMasterModel::ORG_TYPE => Organization\OrgType::MASTER, OrgServiceProviderModel::ORG_TYPE => Organization\OrgType::SERVICE_PROVIDER, OrgCustomerModel::ORG_TYPE => Organization\OrgType::CUSTOMER, OrgAggregatorModel::ORG_TYPE => Organization\OrgType::AGGREGATOR);
     $type = OrganizationMapper::getTypeByOrgId($orgId);
     if (!isset($orgTypeMap[$type])) {
         return null;
     }
     $orgType = $orgTypeMap[$type];
     if ($type != OrgSuperModel::ORG_TYPE) {
         $orgId = OrganizationMapper::cleanOrgId($orgId);
     } else {
         $orgId = substr($orgId, 0, 32);
         if (strlen($orgId) < 32) {
             $orgId .= str_repeat('0', 32 - strlen($orgId));
         }
     }
     $org = new Organization();
     $org->setType($orgType);
     $org->setId($orgId);
     return $org;
 }