Exemplo n.º 1
0
 /**
  * Return data after applying a blacklist
  * @param  array $list
  * @return array
  */
 public function blacklist(array $list)
 {
     $data = $this->_data;
     foreach ($list as $field) {
         \App_Util_Array::unsetItem($data, $field);
     }
     return $data;
 }
Exemplo n.º 2
0
 private function _map(array &$data, $map, $rev = false)
 {
     foreach ($map as $k1 => $k2) {
         list($fromKey, $toKey) = $rev ? array($k2, $k1) : array($k1, $k2);
         if ($fromKey !== '') {
             $v = App_Util_Array::getItem($data, $fromKey);
             if (!is_null($v)) {
                 App_Util_Array::unsetItem($data, $fromKey);
                 if ($toKey !== '') {
                     App_Util_Array::setItem($data, $toKey, $v);
                 }
             }
         }
     }
 }
 protected function _checkProtectedField($resource, $newResource, $privilege, $prefix)
 {
     try {
         $field = substr($privilege, strlen($prefix) + 1, strlen($privilege));
         $field = str_replace(':', '.', $field);
         if ($field !== "default" && \App_Util_Array::issetItem($newResource, $field)) {
             $this->_allowed($privilege, $resource);
         }
     } catch (Exception $e) {
         \App::log()->debug("User has no permission to {$prefix} {$field} in {$resource}");
         if ($this->getThrowExOnNotAllowed()) {
             throw $e;
         } else {
             // Clean privilege
             \App_Util_Array::unsetItem($newResource, $field);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * @param mixed $data Item object, usually Model instance
  */
 public function currentItem(&$data)
 {
     $params = $data->params->exportData();
     $paramsReturned = $params["params"];
     $reportType = $paramsReturned["reportType"];
     // Custom download report params
     switch ($reportType) {
         case ReportModel::KPI_MONTHLY:
             \App_Util_Array::unsetItem($paramsReturned, 'orgId');
             break;
         case ReportModel::SUBSCRIPTION_SNAPSHOT_DAILY:
             $date = \App_Util_Array::getItem($paramsReturned, 'dateDaily');
             \App_Util_Array::setItem($paramsReturned, 'date', $date);
             \App_Util_Array::unsetItem($paramsReturned, 'dateDaily');
             break;
     }
     $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper("formatDateTime");
     $paramsAllowed = array("orgId", "date", "start", "end", "billingAccount", "groupBy", "supervisionGroup", "showCommercialGroup", "showBillingAccount", "showSubscriptions", "showAggregators");
     $paramsFiltered = array_intersect_key($paramsReturned, array_flip($paramsAllowed));
     $newData = array("downloadReportId" => $data->id, "created" => $helper->direct($data->created), "expire" => $helper->direct($data->expire), "modified" => $helper->direct($data->modified), "status" => $data->status === \Core\Model\WatcherModel::STATUS_FINISHED && !$data->eventCount ? 'timeout' : $data->status, "params" => array($reportType => $paramsFiltered), "remove" => $helper->direct($data->remove));
     $data = $newData;
 }
 public function getAction()
 {
     parent::getAction();
     $type = \App_Util_Array::getItem($this->view->data, 'params.params.reportType');
     // Custom download report params
     switch ($type) {
         case ReportModel::KPI_MONTHLY:
             \App_Util_Array::unsetItem($this->view->data, 'params.params.orgId');
             break;
         case ReportModel::SUBSCRIPTION_SNAPSHOT_DAILY:
             $date = \App_Util_Array::getItem($this->view->data, 'params.params.dateDaily');
             \App_Util_Array::setItem($this->view->data, 'params.params.date', $date);
             \App_Util_Array::unsetItem($this->view->data, 'params.params.dateDaily');
             break;
     }
 }
Exemplo n.º 6
0
 public function testWildcardUnSetItemWithCount()
 {
     \App_Util_Array::setItem($this->_data, 'a.*.c', 'a');
     $count = 1;
     \App_Util_Array::unsetItem($this->_data, 'a.*.c', $count);
     $this->assertNull(\App_Util_Array::getItem($this->_data, 'a.b.c'));
     $this->assertNotNull(\App_Util_Array::getItem($this->_data, 'a.d.c'));
 }
Exemplo n.º 7
0
 protected function _mapEricssonModelToModel(array $data)
 {
     \App_Util_Array::changePropertyName($data, 'customer', 'customerData');
     $data = parent::_mapEricssonModelToModel($data);
     \App_Util_Array::changePropertyName($data, 'customerData.fiscalNumber', 'customerData.defaultBillingAccount.fiscalNumber');
     if (isset($data['customerData'])) {
         $data['customer'] = OrgCustomerMapper::getInstance()->mapToModel($data['customerData']);
         unset($data['customerData']);
     }
     if (isset($data['serviceProviderData'])) {
         $data['serviceProvider'] = OrgServiceProviderMapper::getInstance()->mapToModel($data['serviceProviderData']);
         unset($data['serviceProviderData']);
     }
     if (isset($data['billingAccountData'])) {
         $data['billingAccountName'] = $data['billingAccountData']['name'];
         if (isset($data['billingAccountData']['region'])) {
             $data['billingAccountRegion'] = $data['billingAccountData']['region'];
         }
         unset($data['billingAccountData']);
     }
     \App_Util_Array::changePropertyName($data, 'prebillBillingcycle', 'billingCycle');
     if (isset($data['billingCycle'])) {
         foreach ($data['billingCycle'] as &$bc) {
             $this->_mapReference($bc, 'billingAccount');
         }
     }
     $this->_mapReference($data, 'billingAccount');
     if (isset($data['datesData'])) {
         $data += $data['datesData'];
         unset($data['datesData']);
     }
     \App_Util_Array::changePropertiesNames($data, array('totalChargeData' => 'totalCharge', 'totalCharge.adjusts.adjustList' => 'totalCharge.adjusts', 'adjusts.adjustList' => 'adjusts', 'serviceGlobalCharges.basicServicesCustomerCharges' => 'serviceGlobalCharges.basicServices', 'serviceGlobalCharges.basicServices.commercialGroupData' => 'serviceGlobalCharges.basicServices.commercialGroup', 'serviceGlobalCharges.supplementaryServicesCustomerCharges' => 'serviceGlobalCharges.supplServices', 'subscriptionsChargesSummary.basicServices.commercialGroupData' => 'subscriptionsChargesSummary.basicServices.commercialGroup', 'subscriptionsChargesSummary.supplementaryServices' => 'subscriptionsChargesSummary.supplServices'));
     if (isset($data['serviceGlobalCharges']) && isset($data['serviceGlobalCharges']['basicServices']) && isset($data['serviceGlobalCharges']['basicServices']['commercialGroup'])) {
         foreach ($data['serviceGlobalCharges']['basicServices']['commercialGroup'] as &$item) {
             $this->_mapReference($item, 'aggregator');
         }
     }
     if (isset($data['subscriptionsChargesSummary']) && isset($data['subscriptionsChargesSummary']['basicServices']) && isset($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'])) {
         foreach ($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'] as &$item) {
             \App_Util_Array::changePropertiesNames($item, array('oneTimeFee.lifecycleStateChangeEvent' => 'oneTimeFee.lifecycleStatusChangeEvent', 'monthlyFee.activeStateRecurrentFee' => 'monthlyFee.activeStatusRecurrentFee', 'monthlyFee.deactivatedStateRecurrentFee' => 'monthlyFee.deactivatedStatusRecurrentFee', 'monthlyFee.activationReadyRecurrentFee' => 'monthlyFee.activationReadyStatusRecurrentFee', 'monthlyFee.activationPendingRecurrentFee' => 'monthlyFee.activationPendingStatusRecurrentFee'));
             $this->_mapReference($item, 'aggregator');
         }
     }
     if (!isset($data["published"])) {
         $data["published"] = isset($data["issuedDate"]) && $data["issuedDate"];
     }
     $customerDiscounts = \App_Util_Array::getItem($data, 'totalCharge.discounts.customer');
     if (empty($customerDiscounts)) {
         \App_Util_Array::unsetItem($data, 'totalCharge.discounts.customer');
     }
     return $data;
 }
Exemplo n.º 8
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);
 }