예제 #1
0
파일: yaml.php 프로젝트: abbra/midcom
 private function load_objects($object)
 {
     $mc = midgard_parameter::new_collector('parentguid', $object->guid);
     $mc->add_constraint('domain', '=', $this->component);
     $mc->add_constraint('value', '<>', '');
     $mc->set_key_property('guid');
     $mc->add_value_property('name');
     $mc->add_value_property('value');
     $mc->execute();
     $guids = $mc->list_keys();
     foreach ($guids as $guid => $array) {
         $key = $mc->get_subkey($guid, 'name');
         if (!$this->exists($key)) {
             continue;
         }
         $this->objects[$key] = $mc->get_subkey($guid, 'value');
     }
 }
예제 #2
0
 /**
  * Helper function to read a parameter without loading the corresponding object.
  * This is primarily for improving performance, so the function does not check
  * for privileges.
  *
  * @param string $objectguid The object's GUID
  * @param string $domain The parameter's domain
  * @param string $name The parameter to look for
  */
 public static function get_by_objectguid($objectguid, $domain, $name)
 {
     static $parameter_cache = array();
     if (!isset($parameter_cache[$objectguid])) {
         $parameter_cache[$objectguid] = array();
     }
     if (isset($parameter_cache[$objectguid][$name])) {
         return $parameter_cache[$objectguid][$name];
     }
     $mc = midgard_parameter::new_collector('parentguid', $objectguid);
     $mc->set_key_property('value');
     $mc->add_constraint('name', '=', $name);
     $mc->add_constraint('domain', '=', $domain);
     $mc->set_limit(1);
     $mc->execute();
     $parameters = $mc->list_keys();
     if (count($parameters) == 0) {
         $parameter_cache[$objectguid][$name] = null;
         return $parameter_cache[$objectguid][$name];
     }
     $parameter_cache[$objectguid][$name] = key($parameters);
     return $parameter_cache[$objectguid][$name];
 }
예제 #3
0
 /**
  * Load configuration from a Midgard object
  */
 public function load_instance($component, midgardmvc_core_node $folder)
 {
     if (isset($this->configuration_for_instance["{$component}_{$folder->guid}"])) {
         // We have already loaded configuration for this component, keep it
         if (!empty($this->configuration_for_instance["{$component}_{$folder->guid}"])) {
             $this->configuration[$this->get_current_context()] = self::merge_configs($this->configuration[$this->get_current_context()], $this->configuration_for_instance["{$component}_{$folder->guid}"]);
         }
         return;
     }
     if (!$this->midgardmvc->dispatcher->get_midgard_connection()) {
         // No DB connection available, skip
         return;
     }
     $mc = midgard_parameter::new_collector('parentguid', $folder->guid);
     $mc->add_constraint('domain', '=', $component);
     // TODO: Parent components too via IN statement
     $mc->add_constraint('name', '=', 'configuration');
     $mc->add_constraint('value', '<>', '');
     $mc->set_key_property('guid');
     $mc->add_value_property('value');
     $mc->execute();
     $guids = $mc->list_keys();
     $config = array();
     foreach ($guids as $guid => $array) {
         $config = $this->unserialize($mc->get_subkey($guid, 'value'));
         if (!is_array($config)) {
             return;
         }
     }
     $this->configuration_for_instance["{$component}_{$folder->guid}"] = $config;
     if (empty($config)) {
         return;
     }
     $this->configuration[$this->get_current_context()] = self::merge_configs($this->configuration[$this->get_current_context()], $config);
 }
예제 #4
0
파일: dbobject.php 프로젝트: nemein/openpsa
 /**
  * List all parameters of an object.
  *
  * No event handlers are called here yet.
  *
  * @param midcom_core_dbaobject $object The DBA object we're working on
  * @return Array Parameter listing or false on failure.
  * @see list_parameters()
  */
 private static function _list_parameters_all(midcom_core_dbaobject $object)
 {
     if (!$object->guid) {
         return array();
     }
     if (!isset(self::$parameter_cache[$object->guid])) {
         self::$parameter_cache[$object->guid] = array();
     }
     if (isset(self::$parameter_cache[$object->guid]['__midcom_baseclasses_core_dbobject_all'])) {
         $copy = self::$parameter_cache[$object->guid];
         if (isset($copy['__midcom_baseclasses_core_dbobject_all'])) {
             // Clean up internal marker
             unset($copy['__midcom_baseclasses_core_dbobject_all']);
         }
         return $copy;
     }
     $mc = midgard_parameter::new_collector('parentguid', $object->guid);
     $mc->set_key_property('guid');
     $mc->add_value_property('domain');
     $mc->add_value_property('name');
     $mc->add_value_property('value');
     $mc->execute();
     $parameters = $mc->list_keys();
     if (count($parameters) == 0) {
         unset($mc);
         return self::$parameter_cache[$object->guid];
     }
     foreach ($parameters as $guid => $values) {
         $name = $mc->get_subkey($guid, 'name');
         $domain = $mc->get_subkey($guid, 'domain');
         if (!isset(self::$parameter_cache[$object->guid][$domain])) {
             self::$parameter_cache[$object->guid][$domain] = array();
         }
         self::$parameter_cache[$object->guid][$domain][$name] = $mc->get_subkey($guid, 'value');
     }
     unset($mc);
     // Flag that we have queried all domains for this object
     self::$parameter_cache[$object->guid]['__midcom_baseclasses_core_dbobject_all'] = array();
     $copy = self::$parameter_cache[$object->guid];
     if (isset($copy['__midcom_baseclasses_core_dbobject_all'])) {
         // Clean up internal marker
         unset($copy['__midcom_baseclasses_core_dbobject_all']);
     }
     return $copy;
 }