/** * Load extra attributes and keywords from $GLOBALS['cgp_user']['user']['field'] and $GLOBALS['cgp_user']['user']['category'] * @access public **/ public static function init() { if (self::$initialized) { return; } self::$initialized = true; $extra_fields = $GLOBALS['cgp_user']['user']['field']; if (is_array($extra_fields)) { foreach ($extra_fields as $fieldname => $properties) { if (!isset(self::$allowed_attributes[$fieldname])) { $type = $properties['type'] == 'text' || $properties['type'] == 'textarea' ? 'string' : $properties['type']; if (!in_array($type, array('boolean', 'date', 'integer', 'password', 'string'))) { $type = 'string'; } self::$allowed_attributes[$fieldname] = array('type' => $type); if ($type == 'string' && !in_array("%{$fieldname}%", self::$allowed_keywords)) { self::$allowed_keywords[] = "%{$fieldname}%"; } } } } $extra_categories = $GLOBALS['cgp_user']['user']['category']; if (is_array($extra_categories)) { foreach ($extra_categories as $fieldname => $properties) { if (!isset(self::$allowed_attributes[$fieldname])) { self::$allowed_attributes[$fieldname] = array('type' => 'category'); //categories can't be used as keywords } } } }