/** * * @return AppKitPrincipalTarget */ public function getTargetObject() { if ($this->target_class && class_exists($this->target_class)) { if ($this->target_object === null) { $this->target_object = AppKit::getInstance($this->target_class); } return $this->target_object; } throw new AppKitDoctrineException('Class %s for target not found!', $this->target_class); }
public function replaceKey($content) { $content = trim($content); if (preg_match('@\\$\\{([^\\}]+)\\}@', $content)) { return $this->parser->parseData($content); } elseif (strstr($content, '::')) { if (defined($content)) { $content = AppKit::getConstant($content); } } return $content; }
/** * Initiates the IcingaApiConnection * @return boolean * @throws IcingaApiException * @author mhein */ private function initConnection() { $c = $this->configData; $type = AppKit::getConstant($c['api_type']); // if (!$type) throw new AppKitModelException('Could not get api_type \'%s\' for connection', $c['api_type']); $capi = array(); foreach ($c as $ckey => $cdata) { if (strpos($ckey, 'config_') === 0) { $capi[substr($ckey, 7)] = $cdata; } } $this->apiData = IcingaApiConstants::getConnection($type, $capi); return true; }
protected function applyCredentials(IcingaDoctrine_Query &$query) { AppKitLogger::verbose("Parsing credentials: %s", $this->view["credentials"]); foreach (array("host", "service") as $affects) { // add a group for all credential WHERE statements if (!empty($this->view["credentials"])) { $query->addDqlQueryPart("where", "[[CREDSTART]]", true); } foreach ($this->view["credentials"] as $credentialDefinition) { if (!isset($credentialDefinition["affects"])) { AppKit::error("Missing definition of \"affects\" in credential %s!", $credentialDefinition["name"]); } if ($credentialDefinition["affects"] != $affects) { continue; } switch ($credentialDefinition["type"]) { case "auto": throw new AppKitModelException('Auto credential is deprecated'); break; case "custom": AppKitLogger::verbose("Applying custom credential %s (%s)", $credentialDefinition["name"], $credentialDefinition["dql"]); $this->applyCustomCredential($credentialDefinition["dql"], $query, $this->getCredentialValues($credentialDefinition["name"])); break; case "dql": AppKitLogger::verbose("Applying dql credentials %s (%s)", $credentialDefinition["name"]); $this->applyDQLCalls($query, $credentialDefinition["calls"], $this->getCredentialValues($credentialDefinition["name"])); break; default: $extender = $this->getContext()->getModel("Views.Extender." . ucfirst($credentialDefinition["type"]) . "Extender", "Api"); $extender->extend($query, $credentialDefinition["params"]); } } // end the group if (!empty($this->view["credentials"])) { $query->addDqlQueryPart("where", "[[CREDEND]]", true); } } $query->replaceCredentialMarkers(); }
/** * Detects constants within parameter names and resolve values * @param string $name * @return mixed */ private function rewriteParamName($name) { if (strstr($name, '::')) { if (defined($name)) { $name = AppKit::getConstant($name); } } return $name; }
private function buildDataSource() { if ($this->api_search === null) { $params = $this->getTemplate()->getSectionParams('datasource'); $search = $this->getApi()->createSearch(); // our query target $search->setSearchTarget(AppKit::getConstant($params->getParameter('target'))); if ($params->getParameter('filterPresets')) { foreach ($params->getParameter('filterPresets') as $type => $preset) { $searchGroup = $search->createFilterGroup($type); $this->createFilter($preset, $searchGroup, $search); $this->conditions[] = $searchGroup; } } // setting the orders // Order by // Overwrite default orders foreach ($this->collectOrders() as $order) { $search->setSearchOrder($order[0], $order[1]); } // Restrictions if (is_array($this->conditions) && count($this->conditions) > 0) { foreach ($this->conditions as $condition) { if ($condition instanceof IcingaApiSearchFilter) { $search->setSearchFilter($condition['field'], $condition['val'], $condition['op']); } else { $search->setSearchFilter($condition); } } } $this->setPrivileges($search); // Clone our count query if ($params->getParameter('countmode', null) !== 'none') { $this->api_count = clone $search; } // Groupby fields $gbf = $this->getGroupByFields(); if (is_array($gbf) && count($gbf) > 0) { $search->setSearchGroup($gbf); } // the result columns $search->setResultColumns($this->collectColumns()); // limits if (is_numeric($this->pager_limit) && is_numeric($this->pager_start)) { $search->setSearchLimit($this->pager_start, $this->pager_limit); } elseif ($params->getParameter('limit', null)) { $search->setSearchLimit(0, $params->getParameter('limit')); } $this->api_search =& $search; } return true; }