protected function _checkWhitelistPrivileges($prefix, $resource, $newResource, $subResource = null, $connector = '_', $depth = -1, $subprivilege = '')
 {
     if ($subResource === NULL) {
         $subResource =& $newResource;
     }
     if (!$subprivilege) {
         $subprivilege = $prefix;
     }
     if (\App_Util_Array::isIterable($subResource)) {
         foreach ($subResource as $field => $value) {
             $privilege = $subprivilege . $connector . $field;
             if ($this->_checkProtectedField($resource, $newResource, $privilege, $prefix) && $depth != 0 && \App_Util_Array::isIterable($newResource, $field)) {
                 $this->_checkWhitelistPrivileges($prefix, $resource, $newResource, $subResource->{$field}, ':', $depth - 1, $privilege);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param $data \Application\Proto\Report\Service\KPIDataQuery\Response\ResponseData\CurrencyKPI
  * @return \Application\Model\Report\KpiStreamModel
  * @throws \Application\Exceptions\InvalidArgumentException
  */
 public function mapKpi($data)
 {
     $commonData = array();
     switch (true) {
         case $data instanceof CurrencyKPI:
             if ($data->getKpi()) {
                 $dataChild = $data->getKpi();
                 $list = $dataChild->getCustomerKpiList();
             } else {
                 if ($data->getKpiGroup()) {
                     $dataChild = $data->getKpiGroup();
                     $list = $dataChild->getGroupKpiList();
                 }
             }
             if ($data->getCurrency()) {
                 $commonData['currencyId'] = $data->getCurrency()->getId();
                 $commonData['currencyName'] = $data->getCurrency()->getName();
             }
             $commonData['serviceProviderId'] = $dataChild->getServiceProvider()->getId();
             $commonData['serviceProviderName'] = $dataChild->getServiceProvider()->getName();
             $commonData['dateMonthly'] = $dataChild->getDateMonthly();
             break;
         case $data instanceof GroupKPI:
             $dataChild = $data;
             $list = $data->getCustomerKpiList();
             $commonData['sectorId'] = $data->getSector()->getId();
             $commonData['sectorName'] = $data->getSector()->getName();
             break;
         case $data instanceof CustomerKPI:
             $dataChild = $data;
             $list = array();
             $commonData['customerId'] = $data->getCustomer()->getId();
             $commonData['customerName'] = $data->getCustomer()->getName();
             if ($data->getCrmId() !== null) {
                 $commonData['crmId'] = $data->getCrmId();
             }
             if ($data->getFiscalNumber() !== null) {
                 $commonData['fiscalNumber'] = $data->getFiscalNumber();
             }
             if ($data->getInvolvedBillingAccounts() !== null) {
                 $commonData['involvedBillingAccounts'] = $data->getInvolvedBillingAccounts();
             }
             break;
         default:
             throw new InvalidArgumentException('Invalid kpi data');
     }
     // Common common!
     $commonData['kpi'] = $dataChild->getKpi()->serialize(new \DrSlump\Protobuf\Codec\PhpArray());
     $commonData['kpi'] = parent::_mapEricssonModelToModel($commonData['kpi']);
     $result = new Report\KpiStreamModel(!\App_Util_Array::isIterable($list) ? array() : $list, $commonData);
     return $result;
 }
Exemplo n.º 3
0
 public function unsetFieldByPath($field, &$count = -1)
 {
     if ($count == 0) {
         return;
     }
     $keys = explode('.', $field, 2);
     if (empty($keys)) {
         return;
     }
     $newKey = array_shift($keys);
     if (!isset($this->{$newKey})) {
         return;
     }
     if (empty($keys)) {
         unset($this->{$newKey});
         return;
     }
     $nextkeys = explode('.', $keys[0], 2);
     $nextkey = array_shift($nextkeys);
     if (is_array($this->{$newKey})) {
         if (empty($nextkeys)) {
             unset($this->{$newKey});
             return;
         }
         if (!\App_Util_Array::isIterable($this->_data[$newKey])) {
             return;
         }
         $nextkey = array_shift($nextkeys);
         foreach ($this->_data[$newKey] as &$item) {
             \App_Util_Array::unsetItem($item, $nextkey, $count);
             $count--;
         }
         return;
     }
     \App_Util_Array::unsetItem($this->{$newKey}, array_shift($keys), $count);
 }