protected function _processSection(&$section, $data, $value)
 {
     if (is_string($data)) {
         $data = explode(',', $data);
         array_walk($data, function (&$item) {
             trim($item);
         });
         foreach ($data as $item) {
             App_Util_Array::setItem($section, $item, $value);
         }
     }
 }
Exemplo n.º 2
0
 protected function _filterData($data)
 {
     if (!empty($this->_allowedFields)) {
         $newData = array();
         foreach ($this->_allowedFields as $field) {
             if ($value = \App_Util_Array::getItem($data, $field)) {
                 \App_Util_Array::setItem($newData, $field, $value);
             }
         }
         $data = $newData;
     }
     return $data;
 }
Exemplo n.º 3
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 _mapEricssonModelToModel(array $data)
 {
     if (isset($data['data'])) {
         $data = $data['data'];
     }
     if (isset($data['service_provider_configuration'])) {
         $data = array_pop($data['service_provider_configuration']);
     }
     if (isset($data['properties'])) {
         $data = $data['properties'];
     }
     $newData = array();
     foreach ($data as $keyValue) {
         \App_Util_Array::setItem($newData, $keyValue['key'], $keyValue['bool_value']);
     }
     return $newData;
 }
Exemplo n.º 5
0
 public function flatAcl(App_Acl $acl, $ns)
 {
     \App::log()->notice("Creating new permission map for namespace '{$ns}'...");
     $roles = $acl->getRoles();
     $resPrivs = $acl->getAllPrivileges();
     $resourcesResult = array();
     $permissionResult = array();
     foreach ($roles as $role) {
         // Divide roles into role-orgType
         $aRole = array_map('strrev', explode('-', strrev($role), 2));
         if (count($aRole) != 2) {
             \App::log()->notice("Ignoring role {$role}...");
             continue;
         }
         list($thisOrgType, $roleName) = $aRole;
         if ($roleName == 'org' || !in_array($thisOrgType, array('super', 'master', 'provider', 'customer', 'aggregator', 'enduser'))) {
             \App::log()->notice("Ignoring role {$role}...");
             continue;
         }
         \App::log()->notice("Creating permission map for {$role}...");
         $allowed = $acl->getAllowedMapForRole($role);
         foreach ($resPrivs as $resource => $privs) {
             \App::log()->notice("Creating resource '{$resource}' for {$role}...");
             foreach ($privs as $priv) {
                 $isAllowed = in_array($priv, isset($allowed[$resource]) ? $allowed[$resource] : array());
                 if (!$isAllowed) {
                     continue;
                 }
                 // Getting an App_Acl_Assert_Combine instance!
                 $as = $acl->getAssert($role, $resource, $priv);
                 $asserts = $as ? $as->getAsserts() : array();
                 if (!in_array($resource, $resourcesResult)) {
                     $resourcesResult[] = $resource;
                 }
                 \App_Util_Array::setItem($permissionResult, $role . '.' . $resource . '.' . $priv, $asserts);
             }
             \App::log()->notice("Resource created!");
         }
         \App::log()->notice("Permission map for {$role} created!");
     }
     return array('resources' => $resourcesResult, 'permissions' => $permissionResult);
 }
Exemplo n.º 6
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.º 8
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'));
 }