/** * Route shutdown hook -- Check for router exceptions * * @param Zend_Controller_Request_Abstract $request */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $auth = Zend_Auth::getInstance(); $orgService = \Application\Service\OrgService::getInstance(); $identity = $auth->getIdentity(); //Bypass other auth methods if ($identity['authType'] != App_Controller_Plugin_Auth::AUTH_TYPE_AUTH_TOKEN) { return; } $front = Zend_Controller_Front::getInstance(); $bs = $front->getParam('bootstrap'); // Fetch logs and apply the token to them $multilog = $bs->getPluginResource('multiplelog'); if (empty($identity['impersonation']) || empty($identity['impersonation']['orgId'])) { return; } $orgId = $identity['impersonation']['orgId']; $userSrv = UserService::getInstance(); \App::log()->info($identity['username'] . " is running as " . $orgId . " admin"); $user = $userSrv->loadByUsername($identity['username']); $userSrv->generateImpersonatedUser($user, $identity['impersonation']); foreach ($multilog->getLogs() as $log) { $log->setEventItem('impersonated', "as {$orgId} admin"); $log->setEventItem('impersonatedOrgId', "{$orgId}"); $log->setEventItem('username', $identity['username'] . " as {$orgId} admin"); } // Application\Model\Mapper\ProtoAbstractMapper::$accountingUserId .= "_impersonated"; Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $orgId; App_ListFilter::addDefaultExtraData('impersonated_org', $orgId); $org = OrgService::getInstance()->load($orgId); \App::getOrgUserLogged($org); }
function deleteOrg($id) { global $orgService; global $notErased; \Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $id; try { $orgService->delete($id); printf("Organization %s was deleted. ", $id) . PHP_EOL; } catch (\Exception $ex) { $notErased[$id] = $ex->getMessage(); } }
public static function generateToken($userName, $orgId, $language = 'en') { // Get tracking token $tracking = self::_getResource("trackingtoken"); if (!$tracking) { return; } // Fetch logs and apply the token to them $multilog = self::_getResource('multiplelog'); foreach ($multilog->getLogs() as $log) { $log->setEventItem('token', $tracking->getToken()); } //TODO Why is it here??? // Refactor: move it to helper Application\Model\Mapper\ProtoAbstractMapper::$accountingTransactionPrefix = $tracking->getToken() . '-'; Application\Model\Mapper\ProtoAbstractMapper::$accountingUserId = $userName; Application\Model\Mapper\ProtoAbstractMapper::$language = $language; Application\Model\Mapper\AbstractMapper::$organizationId = $orgId; App_ListFilter::addDefaultExtraData('user', $userName); }
public function imsiAction() { if (!$this->getRequest()->isPost()) { throw new AppEx\ForbiddenException("Files action must be a post request."); } $this->_commercialGroupService = CommercialGroupService::getInstance(); $data = $this->_helper->requestData(true); $imsiList = array(); if (isset($data['IMSI'])) { foreach ($data['IMSI'] as $id) { try { if (empty($id)) { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_MISSING_PARAMETER_CODE, 'IMSI'); continue; } if (!is_numeric($id)) { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_REQUEST_VALUES_INCORRECT_CODE, 'IMSI'); continue; } $sim = $this->_simService->load($id, \App::getOrgUserLogged(), 'imsi'); if (is_null($sim)) { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_IMSI_NOT_FOUND_CODE, 'IMSI'); continue; } $simOrgId = $sim->getServiceProviderCommercialId(); $backupOrgId = Application\Model\Mapper\ProtoAbstractMapper::$organizationId; $comGroupid = $sim->getCommercialGroupId(); Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $simOrgId; $comm = $this->_commercialGroupService->load($comGroupid); Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $backupOrgId; $spId = $comm->getServicePackId(); if ($spId) { $st = $this->_service->loadByServicePack($spId); if ($st) { $imsi = array('IMSI' => $id, 'RESULT' => SteeringListService::RESULT_SUCCESS_CODE, 'DESCRIPTION' => SteeringListService::RESULT_SUCCESS_DESC); if (isset($st->resId)) { $imsi['RSP_ID'] = $st->resId; } if (isset($st->steeringType)) { $imsi['STEERING_TYPE'] = $this->_getSteeringType($st->steeringType); } $logistics = $sim->getLogistics(); if (isset($logistics)) { $imsi['CARD_TYPE'] = $logistics; } $imsi['MSISDN'] = isset($sim->msisdn) ? $sim->msisdn : 'UNKNOWN'; $imsiList[] = $imsi; continue; } else { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_REQUEST_VALUES_INCORRECT_CODE, 'IMSI'); continue; } } else { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_INTERNAL_ERROR_CODE, 'IMSI'); continue; } } catch (Exception $ex) { $imsiList[] = $this->_getNotSuccessCase($id, SteeringListService::RESULT_INTERNAL_ERROR_CODE, 'IMSI'); continue; } } } $this->view->IMSI_RES = $imsiList; }
$id_to_delete = $id . "_" . $org->getId(); if ($user_extra["_id"] == $id_to_delete) { $db->user_extra->remove(array("_id" => "{$id_to_delete}")); echo "removed " . "{$id_to_delete}" . " from user_extra \n"; } } } //apiId $id_org = substr($org->getId(), 9, 33); $apiId_count = $db->apiId->count(); $db->apiId->remove(array("orgId" => "{$id_org}")); $apiId_count_borrado = $db->apiId->count(); if ($apiId_count_borrado != $apiId_count) { echo "removed " . $id_org . " from apiId \n"; } Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $org->getId(); //removing org try { $orgSrv->delete($org->getId()); echo "removing org " . $org->getId() . "\n"; } catch (Exception $e) { echo 'AN ERROR HAS OCCURRED:' . PHP_EOL; echo $e->getMessage() . PHP_EOL; } } } else { echo "organization " . $name . " not exists\n"; } $users_ids = null; } } catch (Exception $e) {