/** 1.5 **/ public function onSearch($text, $phrase = '', $ordering = '', $areas = null) { $plugin = JPluginHelper::getPlugin('search', 'easyblog'); $params = EB::registry($plugin->params); if (!plgSearchEasyblog::exists()) { return array(); } if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) { return array(); } } $text = trim($text); if ($text == '') { return array(); } $result = plgSearchEasyblog::getResult($text, $phrase, $ordering); if (!$result) { return array(); } // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' ); foreach ($result as $row) { $row->section = plgSearchEasyblog::getCategory($row->category_id); $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section); $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $blog = EB::table('Blog'); $blog->bind($row); if ($blog->getImage()) { $row->image = $blog->getImage('frontpage'); } } return $result; }
/** * Search content (articles). * The SQL must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav. * * @param string $text Target search string. * @param string $phrase Matching option (possible values: exact|any|all). Default is "any". * @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest". * @param mixed $areas An array if the search it to be restricted to areas or null to search all areas. * * @return array Search results. * * @since 1.6 */ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $db = JFactory::getDbo(); if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $limit = $this->params->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } $rows = array(); //Search Contents. if ($limit > 0) { switch ($phrase) { case 'exact': $text = $db->quote('%' . $db->escape($text, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.vocabulary LIKE ' . $text; $wheres2[] = 'vocab_subject.subject LIKE ' . $text; $wheres2[] = 'vocab_category.category LIKE ' . $text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->quote('%' . $db->escape($word, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.vocabulary LIKE ' . $word; $wheres2[] = 'vocab_subject.subject LIKE ' . $word; $wheres2[] = 'vocab_category.category LIKE ' . $word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } switch ($ordering) { default: $order = 'a.id DESC'; break; } $query = $db->getQuery(true); $query->clear()->select(array('a.id', 'a.vocabulary AS title', '"" AS created', 'a.vocabulary AS text', '"Content" AS section', '1 AS browsernav'))->from('#__vocab_content AS a')->innerJoin('`#__vocab_subject` AS vocab_subject ON vocab_subject.id = a.subject')->innerJoin('`#__vocab_category` AS vocab_category ON vocab_category.id = a.category')->where('(' . $where . ')')->group('a.id')->order($order); $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach ($list as $key => $item) { $list[$key]->href = JRoute::_('index.php?option=com_vocab&view=content&id=' . $item->id, false, 2); } } $rows = array_merge($list, $rows); } return $rows; }
function canExecuteChannels(array $channelNames, array $groups, $skipInputCheck = false) { foreach ($channelNames as $channel) { if (!array_key_exists($channel, $this->channels)) { return false; } // At least one match is required if (count(array_intersect($groups, $this->channels[$channel]['groups'])) == 0) { return false; } // Checking against input if required (note that unlike normal groups, all must match) foreach ($this->channels[$channel]['groups'] as $g) { if ($skipInputCheck) { break; } if (preg_match('/\\$profilerequest\\:(\\w+)\\$/', $g, $matches)) { for ($i = 1, $count_matches = count($matches); $i < $count_matches; $i++) { if (empty($_REQUEST[$matches[$i]])) { return false; } else { $tocheck = str_replace($matches[0], $_REQUEST[$matches[$i]], $g); if (!in_array($tocheck, $groups)) { return false; } } } } } } return true; }
/** * @param mixed $content */ public function run(&$content) { /** * //真不知道说什么好。。。 * 这里 原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化 * so。。。。。 * */ if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') { } else { if (isset($_GET['m']) && strtolower($_GET['m']) == 'install') { return; } $data = S('hooks'); if (!$data) { $hooks = M('Hooks')->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('Addons')->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, $addons); } } } S('hooks', Hook::get()); } else { Hook::import($data, false); } } }
/** * Sort out protected archives * @param array * @return array */ protected function sortOutProtected($arrArchives) { if (BE_USER_LOGGED_IN || !is_array($arrArchives) || empty($arrArchives)) { return $arrArchives; } $this->import('FrontendUser', 'User'); $objArchive = $this->Database->execute("SELECT id, protected, groups FROM tl_news_archive WHERE id IN(" . implode(',', array_map('intval', $arrArchives)) . ")"); $arrArchives = array(); while ($objArchive->next()) { if ($objArchive->protected) { if (!FE_USER_LOGGED_IN) { continue; } $groups = deserialize($objArchive->groups); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { continue; } } $arrArchives[] = $objArchive->id; } return $arrArchives; }
/** * initialize method * * Merge settings and set Config.language to a valid locale * * @return void * @access public */ function initialize(&$Controller, $config = array()) { App::import('Vendor', 'Mi.MiCache'); $lang = MiCache::setting('Site.lang'); if (!$lang) { if (!defined('DEFAULT_LANGUAGE')) { return; } $lang = DEFAULT_LANGUAGE; } elseif (!defined('DEFAULT_LANGUAGE')) { define('DEFAULT_LANGUAGE', $lang); } Configure::write('Config.language', $lang); App::import('Core', 'I18n'); $I18n =& I18n::getInstance(); $I18n->domain = 'default_' . $lang; $I18n->__lang = $lang; $I18n->l10n->get($lang); if (!empty($Controller->plugin)) { $config['plugins'][] = Inflector::underscore($Controller->plugin); } if (!empty($config['plugins'])) { $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']); $Inst = App::getInstance(); foreach ($plugins as $path => $name) { $Inst->locales[] = $path . DS . 'locale' . DS; } } }
function getOnlineUsersInfo($sUserId, $bInit) { global $aXmlTemplates; $aSaved = getSavedUsers(); $aActive = getActiveUsers($sUserId); $aFriends = getFriends($sUserId); saveUsers($aActive); $sContents = ""; if ($bInit) { $aFullUsers = array_unique(array_merge($aActive['online'], $aFriends)); } else { $aFullUsers = array_diff($aActive['online'], $aSaved['online'], $aFriends); $aNewOfflineUsers = array_intersect($aSaved['online'], $aActive['offline']); $aNewOnlineUsers = array_intersect($aSaved['offline'], $aActive['online'], $aFriends); for ($i = 0; $i < count($aNewOfflineUsers); $i++) { $sContents .= parseXml($aXmlTemplates['user'], $aNewOfflineUsers[$i], FALSE_VAL); } for ($i = 0; $i < count($aNewOnlineUsers); $i++) { $sContents .= parseXml($aXmlTemplates['user'], $aNewOnlineUsers[$i], TRUE_VAL); } } $rResult = getUsersMedia($aFullUsers); if ($rResult != null) { for ($i = 0; $i < mysql_num_rows($rResult); $i++) { $aUser = mysql_fetch_assoc($rResult); $aUserInfo = getUserInfo($aUser['ID']); $sOnline = in_array($aUser['ID'], $aActive['online']) ? TRUE_VAL : FALSE_VAL; $sFriend = in_array($aUser['ID'], $aFriends) ? TRUE_VAL : FALSE_VAL; $sMusic = $aUser['CountMusic'] > 0 ? TRUE_VAL : FALSE_VAL; $sVideo = $aUser['CountVideo'] > 0 ? TRUE_VAL : FALSE_VAL; $sContents .= parseXml($aXmlTemplates['user'], $aUser['ID'], $aUserInfo['nick'], $aUserInfo['sex'], $aUserInfo['age'], $aUserInfo['photo'], $aUserInfo['profile'], $sOnline, $sFriend, $sMusic, $sVideo); } } return makeGroup($sContents, "users"); }
/** * testEnumConnectionObjects method * * @return void */ public function testEnumConnectionObjects() { $sources = ConnectionManager::enumConnectionObjects(); $this->assertTrue(count($sources) >= 1); $connections = array('default', 'test', 'test'); $this->assertTrue(count(array_intersect(array_keys($sources), $connections)) >= 1); }
public function info() { global $gb_json_api; $php = ''; if (!empty($gb_json_api->query->controller)) { return $gb_json_api->controller_info($gb_json_api->query->controller); } else { $dir = gb_json_api_dir(); if (file_exists("{$dir}/gb_json-api.php")) { $php = file_get_contents("{$dir}/gb_json-api.php"); } else { // Check one directory up, in case json-api.php was moved $dir = dirname($dir); if (file_exists("{$dir}/gb_json-api.php")) { $php = file_get_contents("{$dir}/gb_json-api.php"); } } if (preg_match('/^\\s*Version:\\s*(.+)$/m', $php, $matches)) { $version = $matches[1]; } else { $version = '(Unknown)'; } $active_controllers = explode(',', get_option('gb_json_api_controllers', 'core')); $controllers = array_intersect($gb_json_api->get_controllers(), $active_controllers); return array('gb_json_api_version' => $version, 'controllers' => array_values($controllers)); } }
function doGetProductIds() { if (!$this->filteringOnWheelSide() && !$this->filteringOnVehicleSide()) { return $this->productIdsMatchingVehicleSelection(); } $finder = new VF_Wheeladapter_Finder(); if ($this->filteringOnWheelSide() && $this->filteringOnVehicleSide()) { $productIds = $finder->getProductIds($this->wheelBolt(), $this->vehicleBolt()); } else { if (!$this->filteringOnWheelSide()) { $productIds = $finder->getProductIds(null, $this->vehicleBolt()); } else { if (!$this->filteringOnVehicleSide()) { $productIds = $finder->getProductIds($this->wheelBolt(), null); if ($this->wrappedFlexibleSearch->hasRequest()) { $productIds = array_intersect($productIds, $this->productIdsMatchingVehicleSelection()); } } } } if (array() == $productIds) { return array(0); } return $productIds; }
function plgSearchEvents($text, $phrase = '', $ordering = '', $areas = null) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php'; if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchEventsAreas()))) { return array(); } } // load plugin params info $plugin =& JPluginHelper::getPlugin('search', 'events'); $pluginParams = new JParameter($plugin->params); $limit = $pluginParams->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } $events = KService::get('com://admin/calendar.model.events')->sort('tbl.start_date')->direction('ASC')->limit($limit)->search($text)->getList(); $return = array(); foreach ($events as $event) { if (searchHelper::checkNoHTML($event, $text, array('title', 'description'))) { $event->text = $event->description; $event->origin = 'events'; $event->href = 'index.php?option=com_calendar&view=event&id=' . $event->id . '&slug=' . $event->slug; $event->section = JText::_('Events'); $return[] = $event->getData(); } } return $return; }
function p3_plugin_disclaimers($profile) { $disclaimed_plugins = array('jetpack', 'wordpress-seo'); if ($detected = array_intersect($disclaimed_plugins, $profile->get_raw_plugin_list())) { ?> <div class="updated inline"> <p><?php printf(__('Some plugins may show artificially high results. <a href="%s">More info</a>', 'p3-profiler'), admin_url('tools.php?page=p3-profiler&p3_action=help#q17')); ?> </p> <ul style="list-style: initial; margin-left: 1.5em;"> <?php foreach ($detected as $plugin) { ?> <li><?php echo $profile->get_plugin_name($plugin); ?> </li> <?php } ?> </ul> </div> <?php } }
/** @test */ public function methods() { $needed_methods = array('toArray'); $this->assertThat(array_unique(get_class_methods(__NAMESPACE__ . '\\DbIterator')), new \PHPUnit_Framework_Constraint_Callback(function ($class_methods) use($needed_methods) { return $needed_methods === array_intersect($needed_methods, $class_methods); })); }
protected function matchExtendsSingle($single, &$out_origin, &$out_rem) { $counts = array(); foreach ($single as $part) { if (!is_string($part)) { return false; } // hmm if (isset($this->extendsMap[$part])) { foreach ($this->extendsMap[$part] as $idx) { $counts[$idx] = isset($counts[$idx]) ? $counts[$idx] + 1 : 1; } } } foreach ($counts as $idx => $count) { list($target, $origin) = $this->extends[$idx]; // check count if ($count != count($target)) { continue; } // check if target is subset of single if (array_diff(array_intersect($single, $target), $target)) { continue; } $out_origin = $origin; $out_rem = array_diff($single, $target); return true; } return false; }
protected function getRecordForStore($values) { $value = array(); if ($values['type'] == 'text' || $values['type'] == 'textarea' || $values['type'] == 'date') { $default = $values['default']; } else { $default = array_intersect($values['values']['default'], array_keys($values['values']['options'])); if ($values['type'] == 'radio') { $default = $default[0]; } } if ($values['type'] == 'select') { $values['size'] = 1; } $recordForStore['title'] = $values['title']; $recordForStore['description'] = $values['description']; $recordForStore['sql'] = $values['sql']; $recordForStore['type'] = $values['type']; $recordForStore['validate_func'] = $values['validate_func']; $recordForStore['additional_fields'] = array('sql' => intval($values['sql']), 'sql_type' => $values['sql_type'], 'size' => $values['size'], 'default' => $default, 'options' => $values['values']['options'], 'cols' => $values['cols'], 'rows' => $values['rows']); $default_fields = array('type' => 1, 'default' => 1, 'values' => 1, 'size' => 1, 'title' => 1, 'description' => 1, 'validate_func' => 1, 'sql' => 1, 'sql_type' => 1, 'cols' => 1, 'rows' => 1); foreach ($values as $k => $v) { if (!isset($default_fields[$k]) && $k[0] != '_') { $recordForStore['additional_fields'][$k] = $v; } } return $recordForStore; }
/** @test */ public function methods() { $needed_methods = array('isValid', 'getRealValue'); $this->assertThat(array_unique(get_class_methods(__NAMESPACE__ . '\\Binding')), new \PHPUnit_Framework_Constraint_Callback(function ($class_methods) use($needed_methods) { return $needed_methods === array_intersect($needed_methods, $class_methods); })); }
public function testGetOptions() { $options = array('expand' => 'accountStore'); $accountStoreMappingWithDir = \Stormpath\Resource\AccountStoreMapping::get(self::$accountStoreMappingWithDir->href, $options); // testing the expansion $this->assertTrue(count(array_intersect(array('name', 'description', 'status'), $accountStoreMappingWithDir->accountStore->propertyNames)) == 3); }
public function testNormalizeToArray() { $normalized = ArrayUtil::normalizeToArray($this->arrayTemplate, $this->arrayOld); $tmplKeys = array_keys($this->arrayTemplate); $oldKeys = array_keys($this->arrayOld); $keepKeys = array_intersect($tmplKeys, $oldKeys); $newKeys = array_diff($tmplKeys, $oldKeys); $deleteKeys = array_diff($oldKeys, $tmplKeys); // All keys in the template must be present: foreach ($tmplKeys as $key) { $this->assertArrayHasKey($key, $normalized, "Array lost a key!"); } // All fields not specified must be removed: foreach ($deleteKeys as $key) { $this->assertArrayNotHasKey($key, $normalized); } // All new fields must inherit specified default values: foreach ($newKeys as $key) { $this->assertEquals($this->arrayTemplate[$key], $normalized[$key], "Didn't inherit default value!"); } // All fields must retain their original values, if they didn't need to // be initialized with default values: foreach ($keepKeys as $key) { $this->assertEquals($this->arrayOld[$key], $normalized[$key], "Array value changed when it shouldn't have!"); } }
/** * Execute command * * @param array $args * @param array $options */ public function execute(array $args, array $options = array()) { $this->prepare($options); $this->force = !empty($options['force']) || !empty($options['f']); $all = !empty($options['all']) || !empty($options['a']); if (!$this->databaseIsReady()) { exit(1); } if (empty($args) && !$all) { $this->writeerr("Specify which updates should be marked as done.\n"); return; } $updates = $this->dbvc()->getUpdates(); if (!$all) { $updates = array_intersect($updates, $args); } if (empty($updates)) { $this->writeln("Nothing to do"); return; } $this->dbvc()->db()->markUpdate($updates); if ($this->verbosity) { $this->writeln("Marked as run:", Colors::YELLOW); $this->writeln(" " . join("\n ", $updates)); } }
protected static function groupsCanGoPath($path) { $slice = array_filter(explode('/', $path)); $path = '/'; if (!empty($slice)) { $path .= array_shift($slice); } if (!empty($slice)) { $path .= '/' . array_shift($slice); } $foundNeedGroups = false; $needGroups = []; foreach (static::pathGroupsMapping() as $k => $v) { if ('/' . trim($k, '/') == $path) { $foundNeedGroups = true; $needGroups = $v; break; } } if (!$foundNeedGroups) { return false; } if (empty($needGroups)) { return true; } return !empty(array_intersect(static::getOnlineUserGroups(), $needGroups)); }
/** * Returns true if the product is available * ALMOST THE SAME AS THE PARENT, EXCEPT WE DON'T CHECK FOR PRICE * * @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection * * @return bool */ public function isAvailableForCollection(IsotopeProductCollection $objCollection) { if ($objCollection->isLocked()) { return true; } if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) { return false; } // Show to guests only if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) { return false; } // Protected product if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) { if ($objCollection->member == 0) { return false; } $groups = deserialize($this->arrData['groups']); $memberGroups = deserialize($objCollection->getRelated('member')->groups); if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) { return false; } } // Check that the product is in any page of the current site if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) { return false; } // Check if "advanced price" is available //if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) { // return false; //} return true; }
/** * Override of the set_cache method, works in exactly the same way except * the check for the max-age header in the response has been removed so that * Codebase API responses will always be cached, this breaks HTTP Cache * rules but is the cleanest way of enabling caching for all responses * within Kohana. * * @param Response $response * @return boolean */ public function set_cache(Response $response) { $headers = $response->headers()->getArrayCopy(); if ($cache_control = Arr::get($headers, 'cache-control')) { // Parse the cache control $cache_control = HTTP_Header::parse_cache_control($cache_control); // If the no-cache or no-store directive is set, return if (array_intersect($cache_control, array('no-cache', 'no-store'))) { return FALSE; } // Check for private cache and get out of here if invalid if (!$this->_allow_private_cache and in_array('private', $cache_control)) { if (!isset($cache_control['s-maxage'])) { return FALSE; } // If there is a s-maxage directive we can use that $cache_control['max-age'] = $cache_control['s-maxage']; } } /** * if the max-age cache control header is set to 0 in the response, set * it to 1 hour so the reponse will be cacheable */ $cache_control_header = $response->headers('Cache-Control'); $response->headers('Cache-Control', str_replace('max-age=0', 'max-age=3600', $cache_control_header)); if ($expires = Arr::get($headers, 'expires') and !isset($cache_control['max-age'])) { // Can't cache things that have expired already if (strtotime($expires) <= time()) { return FALSE; } } return TRUE; }
/** * {@inheritdoc} */ public function getValuesForChoices(array $choices) { $choices = $this->fixChoices($choices); // The choices are identical to the values, so we can just return them // to improve performance a little bit return $this->fixValues(array_intersect($choices, $this->getValues())); }
public function run(&$parms) { //安装时不执行 if (defined('BIND_MODULE') && BIND_MODULE === 'Install') { return; } $data = S('global_hooks'); if (!$data) { $hooks = M('Hooks', "common_")->getField('name,addons'); foreach ($hooks as $key => $value) { if ($value) { $map['status'] = 1; $names = explode(',', $value); $map['name'] = array('IN', $names); $data = M('Addons', "common_")->where($map)->getField('id,name'); if ($data) { $addons = array_intersect($names, $data); Hook::add($key, array_map('get_addon_class', $addons)); } } } S('global_hooks', Hook::get()); } else { Hook::import($data, false); } }
public function getGeneralFromAttributeSets(array $attributeSets) { $attributeSetIds = $this->_getIdsFromInput($attributeSets, 'attribute_set_id'); if (empty($attributeSetIds)) { return array(); } $attributes = array(); $isFirst = true; $idsParts = array_chunk($attributeSetIds, 50); foreach ($idsParts as $part) { $tempAttributes = $this->_getGeneralFromAttributeSets($part); if ($isFirst) { $attributes = $tempAttributes; $isFirst = false; continue; } if (!$isFirst && empty($attributes)) { return array(); } $attributes = array_intersect($attributes, $tempAttributes); } if (empty($attributes)) { return array(); } $attributesData = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter()->addFieldToFilter('main_table.attribute_id', array('in' => $attributes))->setOrder('frontend_label', Varien_Data_Collection_Db::SORT_ORDER_ASC)->toArray(); $resultAttributes = array(); foreach ($attributesData['items'] as $attribute) { $resultAttributes[] = array('code' => $attribute['attribute_code'], 'label' => $attribute['frontend_label']); } return $resultAttributes; }
function mytabs_blockShow($pageid, $tabid, $placement = '', $remove = '') { $block = array(); $visblocks = array(); $blocks_handler = xoops_getmodulehandler('pageblock', 'mytabs'); $blocks = $blocks_handler->getBlocks($pageid, $tabid, $placement, $remove); $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS); foreach (array_keys($blocks) as $key) { foreach ($blocks[$key] as $thisblock) { if ($thisblock->isVisible() && array_intersect($thisblock->getVar('groups'), $groups)) { $visblocks[] = $thisblock; } } } $count = count($visblocks); for ($i = 0; $i < $count; $i++) { $logger_name = $visblocks[$i]->getVar('title') . "(" . $visblocks[$i]->getVar('pageblockid') . ")"; $GLOBALS['xoopsLogger']->startTime($logger_name); $thisblock = $visblocks[$i]->render($GLOBALS['xoopsTpl'], $tabid . '_' . $visblocks[$i]->getVar('pageblockid')); if ($thisblock != false) { if (strlen($thisblock['title']) > 0) { if ($thisblock['title'][0] == '-') { $thisblock['title'] = ''; } } $block[] = $thisblock; } $GLOBALS['xoopsLogger']->stopTime($logger_name); } return $block; }
/** * Returns a list of entities with metadata */ public function getSources() { $sourcesDef = $this->aConfig->getArray('sources'); try { $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef); } catch (Exception $e) { throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage()); } #echo $exclude; exit; /* Find list of all available entities. */ $entities = array(); #echo '<pre>'; print_r($this->sets); exit; foreach ($sources as $source) { foreach ($this->sets as $set) { foreach ($source->getMetadataSet($set) as $entityId => $metadata) { if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) { SimpleSAML_Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']'); continue; } else { #echo('<pre>'); print_r($metadata); exit; } if (!array_key_exists($entityId, $entities)) { $entities[$entityId] = array(); } if (array_key_exists($set, $entities[$entityId])) { /* Entity already has metadata for the given set. */ continue; } $entities[$entityId][$set] = $metadata; } } } return $entities; }
/** * {@inheritdoc} */ public function initialize() { $checkInvalidArgument = array_intersect(array_keys($this->getOr(self::CONTEXT_KEY, [])), $this->reservedKeys); if (count($checkInvalidArgument)) { throw new \InvalidArgumentException(sprintf('Context of template "%s" includes reserved key(s) - (%s)', $this->get(self::TEMPLATE_KEY), implode(', ', array_values($checkInvalidArgument)))); } }
/** * Validates the current table to make sure that it won't * result in generated code that will not parse. * * This method may emit warnings for code which may cause problems * and will throw exceptions for errors that will definitely cause * problems. */ protected function validateModel() { parent::validateModel(); $table = $this->getTable(); // Check to see whether any generated foreign key names // will conflict with column names. $colPhpNames = array(); $fkPhpNames = array(); foreach ($table->getColumns() as $col) { $colPhpNames[] = $col->getPhpName(); } foreach ($table->getForeignKeys() as $fk) { $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false); } $intersect = array_intersect($colPhpNames, $fkPhpNames); if (!empty($intersect)) { throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); } // Check foreign keys to see if there are any foreign keys that // are also matched with an inversed referencing foreign key // (this is currently unsupported behavior) // see: http://propel.phpdb.org/trac/ticket/549 foreach ($table->getForeignKeys() as $fk) { if ($fk->isMatchedByInverseFK()) { throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)"); } } }
function d4p_bbt_is_role($setting_name) { global $gdbbpress_tools; $allowed = false; if (current_user_can('d4p_bbpt_'.$setting_name)) { $allowed = true; } else if (is_super_admin()) { $allowed = $gdbbpress_tools->o[$setting_name.'_super_admin'] == 1; } else if (is_user_logged_in()) { $roles = $gdbbpress_tools->o[$setting_name.'_roles']; if (is_null($roles)) { $allowed = true; } else if (is_array($roles)) { global $current_user; if (is_array($current_user->roles)) { $matched = array_intersect($current_user->roles, $roles); $allowed = !empty($matched); } } } return $allowed; }