/** * convert objects with user data to ldap data array * * @param Tinebase_Model_FullUser $_user * @param array $_ldapData the data to be written to ldap */ protected function _group2ldap(Tinebase_Model_Group $_group, array &$_ldapData) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ENCRYPT ' . print_r($_ldapData, true)); } if (isset($_ldapData['objectclass'])) { $_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass)); } if (isset($_ldapData['gidnumber'])) { $gidNumber = $_ldapData['gidnumber']; } else { $gidNumber = $this->_getGidNumber($_group->getId()); } // when we try to add a group, $_group has no id which leads to Tinebase_Exception_InvalidArgument in $this->_getGroupMetaData try { $metaData = $this->_getGroupMetaData($_group); } catch (Tinebase_Exception_InvalidArgument $teia) { $metaData = array(); } if (!isset($metaData['sambasid'])) { $_ldapData['sambasid'] = $this->_options[Tinebase_Group_Ldap::PLUGIN_SAMBA]['sid'] . '-' . (2 * $gidNumber + 1001); $_ldapData['sambagrouptype'] = 2; } $_ldapData['displayname'] = $_group->name; }
/** * Get all articles and return them as array * @param \DataContainer * @return array */ public function getAllArticles(\DataContainer $dc) { $user = \BackendUser::getInstance(); $pids = array(); $articles = array(); // Limit pages to the user's pagemounts if ($user->isAdmin) { $objArticle = \Database::getInstance()->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid ORDER BY parent, a.sorting"); } else { foreach ($user->pagemounts as $id) { $pids[] = $id; $pids = array_merge($pids, \Database::getInstance()->getChildRecords($id, 'tl_page')); } if (empty($pids)) { return $articles; } $objArticle = \Database::getInstance()->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(" . implode(',', array_map('intval', array_unique($pids))) . ") ORDER BY parent, a.sorting"); } // Edit the result if ($objArticle->numRows) { \Controller::loadLanguageFile('tl_article'); while ($objArticle->next()) { $key = $objArticle->parent . ' (ID ' . $objArticle->pid . ')'; $articles[$key][$objArticle->id] = $objArticle->title . ' (' . ($GLOBALS['TL_LANG']['tl_article'][$objArticle->inColumn] ?: $objArticle->inColumn) . ', ID ' . $objArticle->id . ')'; } } return $articles; }
function index() { $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS; $files = \GCore\Libs\Folder::getFiles($path, true); $strings = array(); //function to prepare strings $prepare = function ($str) { /*$path = \GCore\C::get('GCORE_FRONT_PATH'); if(strpos($str, $path) !== false AND strpos($str, $path) == 0){ return '//'.str_replace($path, '', $str); }*/ $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : ''; return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";'; }; foreach ($files as $file) { if (substr($file, -4, 4) == '.php') { // AND strpos($file, DS.'extensions'.DS) === TRUE){ //$strings[] = $file; $file_code = file_get_contents($file); preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs); if (!empty($langs[2])) { $strings = array_merge($strings, $langs[2]); } } } $strings = array_unique($strings); $strings = array_map($prepare, $strings); echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>'; }
/** * Assumes that value is not *, and creates an array of valid numbers that * the string represents. Returns an array. */ function expand_ranges($str) { if (strstr($str, ",")) { $arParts = explode(',', $str); foreach ($arParts as $part) { if (strstr($part, '-')) { $arRange = explode('-', $part); for ($i = $arRange[0]; $i <= $arRange[1]; $i++) { $ret[] = $i; } } else { $ret[] = $part; } } } elseif (strstr($str, '-')) { $arRange = explode('-', $str); for ($i = $arRange[0]; $i <= $arRange[1]; $i++) { $ret[] = $i; } } else { $ret[] = $str; } $ret = array_unique($ret); sort($ret); return $ret; }
protected function _buildTags($tagString) { $new = array_unique(array_map('trim', explode(',', $tagString))); $out = []; $query = $this->_table->Tags->find()->contain('TaggedTags')->where(['Tags.tag IN' => $new]); $query->matching('TaggedTags', function ($q) { return $q->where(['TaggedTags.model' => $this->name()]); }); /* foreach ($query as $tag){ debug($tag);die; }*/ // Remove existing tags from the list of new tags. foreach ($query->extract('tag') as $existing) { $index = array_search($existing, $new); if ($index !== false) { unset($new[$index]); } } // Add existing tags. foreach ($query as $tag) { $tag['count'] = $tag['count'] + 1; $out[] = $tag; } // Add new tags. foreach ($new as $tag) { $out[] = $this->_table->Tags->newEntity(['tag' => $tag, 'count' => 1]); //$out->_joinData = []; //debug ($out); } return $out; }
/** * Define the repeated tags in XML file so we can set an index * * @param array $array * @return array */ function xml_tags($array) { $repeats_temp = array(); $repeats_count = array(); $repeats = array(); if (is_array($array)) { $n = count($array) - 1; for ($i = 0; $i < $n; $i++) { $idn = $array[$i]['tag'] . $array[$i]['level']; if (in_array($idn, $repeats_temp)) { $repeats_count[array_search($idn, $repeats_temp)] += 1; } else { array_push($repeats_temp, $idn); $repeats_count[array_search($idn, $repeats_temp)] = 1; } } } $n = count($repeats_count); for ($i = 0; $i < $n; $i++) { if ($repeats_count[$i] > 1) { array_push($repeats, $repeats_temp[$i]); } } unset($repeats_temp); unset($repeats_count); return array_unique($repeats); }
/** * Rebuild index data by entities * * * @param int|array $processIds * @return $this * @throws \Exception */ public function reindexEntities($processIds) { $connection = $this->getConnection(); $this->clearTemporaryIndexTable(); if (!is_array($processIds)) { $processIds = [$processIds]; } $parentIds = $this->getRelationsByChild($processIds); if ($parentIds) { $processIds = array_unique(array_merge($processIds, $parentIds)); } $childIds = $this->getRelationsByParent($processIds); if ($childIds) { $processIds = array_unique(array_merge($processIds, $childIds)); } $this->_prepareIndex($processIds); $this->_prepareRelationIndex($processIds); $this->_removeNotVisibleEntityFromIndex(); $connection->beginTransaction(); try { // remove old index $where = $connection->quoteInto('entity_id IN(?)', $processIds); $connection->delete($this->getMainTable(), $where); // insert new index $this->insertFromTable($this->getIdxTable(), $this->getMainTable()); $connection->commit(); } catch (\Exception $e) { $connection->rollBack(); throw $e; } return $this; }
public function lists($model = null, $page = 0, $templateFile = '', $order = 'id desc') { $isAjax = I('isAjax'); $isRadio = I('isRadio'); // 获取模型信息 is_array($model) || ($model = $this->getModel($model)); $list_data = $this->_get_model_list($model, $page, $order); if (!empty($list_data['list_data'])) { $coupon_ids = array_unique(getSubByKey($list_data['list_data'], 'coupon_id')); $map['id'] = array('in', $coupon_ids); $list = M('coupon')->where($map)->field('id,title')->select(); $couponArr = makeKeyVal($list); foreach ($list_data['list_data'] as &$v) { $v['coupon_name'] = $couponArr[$v['coupon_id']]; } } if ($isAjax) { $this->assign('isRadio', $isRadio); $this->assign($list_data); $this->display('ajax_lists_data'); } else { $this->assign($list_data); $templateFile || ($templateFile = $model['template_list'] ? $model['template_list'] : ''); $this->display($templateFile); } }
function __SLEGetTransport($arFields, $arCurrentUserSubscribe) { if (array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N"]; } if (array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N"]; } $bHasLogEventCreatedBy = CSocNetLogTools::HasLogEventCreatedBy($arFields["EVENT_ID"]); if ($bHasLogEventCreatedBy) { if ($arFields["EVENT_ID"]) { if (array_key_exists("U_" . $arFields["USER_ID"] . "_all_N_Y", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"]["U_" . $arFields["USER_ID"] . "_all_N_Y"]; } elseif (array_key_exists("U_" . $arFields["USER_ID"] . "_all_Y_Y", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"]["U_" . $arFields["USER_ID"] . "_all_Y_Y"]; } } } if (!array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"]) && !array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) { if (array_key_exists($arFields["ENTITY_TYPE"] . "_0_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_0_" . $arFields["EVENT_ID"] . "_N_N"]; } elseif (array_key_exists($arFields["ENTITY_TYPE"] . "_0_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) { $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_0_all_N_N"]; } else { $arTransport[] = "N"; } } $arTransport = array_unique($arTransport); usort($arTransport, "__SLTransportSort"); return $arTransport; }
/** * 绑定角色与权限的对应关系 * @param $roleId 角色ID * @param $pids 权限ID列表 * @param $loginUser \liuxy\admin\models\AdminUser */ public static function bind($roleId, $pids, $loginUser) { self::deteteAll(['role_id' => $roleId]); if (!empty($pids)) { $pids = explode(',', $pids); $pids = array_unique($pids); foreach ($pids as $pid) { if (!empty($pid)) { $item = new RolePermission(); $item->isNewRecord = true; $item->role_id = $roleId; $item->permission_id = $pid; $item->insert_by = $loginUser->username; $item->insert(); if ($item->hasErrors()) { Yii::error(VarDumper::dumpAsString($item->getErrors()), __METHOD__); } unset($item); } } /** * 清理角色下所对应用户的权限 */ foreach (AdminUserRole::find()->where(['role_id' => $roleId])->all() as $userRole) { AdminUser::clearPermission($userRole['user_id']); } } }
/** * Get all product ids in a category (and its children) * * @param int $category_id * @return array */ public function get_products_in_category($category_id) { $term_ids = get_term_children($category_id, 'product_cat'); $term_ids[] = $category_id; $product_ids = get_objects_in_term($term_ids, 'product_cat'); return array_unique(apply_filters('woocommerce_report_sales_by_category_get_products_in_category', $product_ids, $category_id)); }
/** * {@inheritDoc} */ public function check($value, $schema = null, JsonPointer $path = null, $i = null) { // Verify minItems if (isset($schema->minItems) && count($value) < $schema->minItems) { $this->addError($path, "There must be a minimum of " . $schema->minItems . " items in the array", 'minItems', array('minItems' => $schema->minItems)); } // Verify maxItems if (isset($schema->maxItems) && count($value) > $schema->maxItems) { $this->addError($path, "There must be a maximum of " . $schema->maxItems . " items in the array", 'maxItems', array('maxItems' => $schema->maxItems)); } // Verify uniqueItems if (isset($schema->uniqueItems) && $schema->uniqueItems) { $unique = $value; if (is_array($value) && count($value)) { $unique = array_map(function ($e) { return var_export($e, true); }, $value); } if (count(array_unique($unique)) != count($value)) { $this->addError($path, "There are no duplicates allowed in the array", 'uniqueItems'); } } // Verify items if (isset($schema->items)) { $this->validateItems($value, $schema, $path, $i); } }
/** * copy values from one array to another, usually from a superglobal into $GLOBALS * * @uses $GLOBALS['_import_blacklist'] * @uses preg_replace() * @uses array_keys() * @uses array_unique() * @uses stripslashes() * @param array $array values from * @param array $target values to * @param boolean $sanitize prevent importing key names in $_import_blacklist */ function PMA_recursive_extract($array, &$target, $sanitize = true) { if (!is_array($array)) { return false; } if ($sanitize) { $valid_variables = preg_replace($GLOBALS['_import_blacklist'], '', array_keys($array)); $valid_variables = array_unique($valid_variables); } else { $valid_variables = array_keys($array); } foreach ($valid_variables as $key) { if (strlen($key) === 0) { continue; } if (is_array($array[$key])) { // there could be a variable coming from a cookie of // another application, with the same name as this array unset($target[$key]); PMA_recursive_extract($array[$key], $target[$key], false); } else { $target[$key] = $array[$key]; } } return true; }
protected function afterSave($resultRecords, $occur_date) { // \DB::enableQueryLog(); $tankDataValue = TankDataValue::getTableName(); $tank = Tank::getTableName(); $columns = [\DB::raw("sum(BEGIN_VOL) \tas\tBEGIN_VOL"), \DB::raw("sum(END_VOL) \t\t\tas\tEND_VOL"), \DB::raw("sum(BEGIN_LEVEL) \t\tas\tBEGIN_LEVEL"), \DB::raw("sum(END_LEVEL) \t\tas\tEND_LEVEL"), \DB::raw("sum(TANK_GRS_VOL) \t\tas\tGRS_VOL"), \DB::raw("sum(TANK_NET_VOL) \t\tas\tNET_VOL"), \DB::raw("sum(AVAIL_SHIPPING_VOL) as\tAVAIL_SHIPPING_VOL")]; $attributes = ['OCCUR_DATE' => $occur_date]; $storage_ids = []; foreach ($resultRecords as $mdlName => $records) { // $mdl = "App\Models\\".$mdlName; // $mdlRecords = $mdl::with('Tank')->whereIn(); foreach ($records as $mdlRecord) { $storageID = $mdlRecord->getStorageId(); if ($storageID) { $storage_ids[] = $storageID; } } } $storage_ids = array_unique($storage_ids); foreach ($storage_ids as $storage_id) { $values = TankDataValue::join($tank, function ($query) use($tankDataValue, $tank, $storage_id) { $query->on("{$tank}.ID", '=', "{$tankDataValue}.TANK_ID")->where("{$tank}.STORAGE_ID", '=', $storage_id); })->whereDate('OCCUR_DATE', '=', $occur_date)->select($columns)->first(); $attributes['STORAGE_ID'] = $storage_id; $values = $values->toArray(); $values['STORAGE_ID'] = $storage_id; $values['OCCUR_DATE'] = $occur_date; StorageDataValue::updateOrCreate($attributes, $values); } // \Log::info(\DB::getQueryLog()); }
/** * Get categories for a specific user. * * @param bool|array|int $ids The category ids to load. * @param mixed $user The user id to load. * * @return KunenaForumCategoryUser[] */ static public function getCategories($ids = false, $user = null) { $user = KunenaUserHelper::get($user); if ($ids === false) { // Get categories which are seen by current user $ids = KunenaForumCategoryHelper::getCategories(); } elseif (!is_array ($ids) ) { $ids = array($ids); } // Convert category objects into ids foreach ($ids as $i => $id) { if ($id instanceof KunenaForumCategory) $ids[$i] = $id->id; } $ids = array_unique($ids); self::loadCategories($ids, $user); $list = array (); foreach ( $ids as $id ) { if (!empty(self::$_instances [$user->userid][$id])) { $list [$id] = self::$_instances [$user->userid][$id]; } } return $list; }
/** * Add the required JS */ protected function setUp() { parent::setUp(); $this->addScript('//cdnjs.cloudflare.com/ajax/libs/jeditable.js/1.7.3/jeditable.min.js'); $this->addScript($this->path('resource/scripts/classes/Display.class.js')); $this->addScript($this->path('resource/scripts/classes/Application.class.js')); $this->addScript($this->path('resource/scripts/classes/DisplayManager.class.js')); $this->addScript($this->path('resource/scripts/controllers/setup_roles.controller.js')); $this->addCss($this->path('resource/styles/displaymanager.css')); //add all of the JazzeePage scripts for display $types = $this->_em->getRepository('\\Jazzee\\Entity\\PageType')->findAll(); $scripts = array(); $scripts[] = $this->path('resource/scripts/page_types/JazzeePage.js'); foreach ($types as $type) { $class = $type->getClass(); $scripts[] = $this->path($class::pageBuilderScriptPath()); } //add all of the Jazzee element scripts for data rendering $this->addScript($this->path('resource/scripts/element_types/JazzeeElement.js')); $types = $this->_em->getRepository('\\Jazzee\\Entity\\ElementType')->findAll(); $scripts[] = $this->path(\Jazzee\Interfaces\Element::PAGEBUILDER_SCRIPT); $scripts[] = $this->path('resource/scripts/element_types/List.js'); $scripts[] = $this->path('resource/scripts/element_types/FileInput.js'); foreach ($types as $type) { $class = $type->getClass(); $scripts[] = $this->path($class::PAGEBUILDER_SCRIPT); } $scripts = array_unique($scripts); foreach ($scripts as $path) { $this->addScript($path); } }
/** * Delete files in the deleted directory if they are not referenced in the * filearchive table. This needs to be done in the repo because it needs to * interleave database locks with file operations, which is potentially a * remote operation. * @return FileRepoStatus */ function cleanupDeletedBatch($storageKeys) { $root = $this->getZonePath('deleted'); $dbw = $this->getMasterDB(); $status = $this->newGood(); $storageKeys = array_unique($storageKeys); foreach ($storageKeys as $key) { $hashPath = $this->getDeletedHashPath($key); $path = "{$root}/{$hashPath}{$key}"; $dbw->begin(); $inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE')); if (!$inuse) { $sha1 = substr($key, 0, strcspn($key, '.')); $ext = substr($key, strcspn($key, '.') + 1); $ext = File::normalizeExtension($ext); $inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, 'oi_archive_name ' . $dbw->buildLike($dbw->anyString(), ".{$ext}"), $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE')); } if (!$inuse) { wfDebug(__METHOD__ . ": deleting {$key}\n"); if (!@unlink($path)) { $status->error('undelete-cleanup-error', $path); $status->failCount++; } } else { wfDebug(__METHOD__ . ": {$key} still in use\n"); $status->successCount++; } $dbw->commit(); } return $status; }
/** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { $comparison = PHP_CodeSniffer_Tokens::$comparisonTokens; $operators = PHP_CodeSniffer_Tokens::$operators; $assignment = PHP_CodeSniffer_Tokens::$assignmentTokens; return array_unique(array_merge($comparison, $operators, $assignment)); }
/** * @return email_liste as an array */ public function explodeEmailsListe() { //var_dump($this->emails_liste)."<br>"; $this->emails_liste = array_unique(preg_split("/[\\s,]+/", $this->emails_liste)); //$this->emails_liste = preg_split("/[\s,]+/", $this->emails_liste); //var_dump($this->emails_liste)."<br>"; }
function parse($data_str, $query) { $translate = array('fax-no' => 'fax', 'e-mail' => 'email', 'nic-hdl-br' => 'handle', 'nic-hdl' => 'handle', 'person' => 'name', 'netname' => 'name', 'descr' => 'desc', 'country' => 'address.country'); $contacts = array('owner-c' => 'owner', 'tech-c' => 'tech', 'abuse-c' => 'abuse', 'admin-c' => 'admin'); $r = generic_parser_a($data_str, $translate, $contacts, 'network'); unset($r['network']['owner']); unset($r['network']['ownerid']); unset($r['network']['responsible']); unset($r['network']['address']); unset($r['network']['phone']); unset($r['network']['aut-num']); unset($r['network']['nsstat']); unset($r['network']['nslastaa']); unset($r['network']['inetrev']); if (!empty($r['network']['aut-num'])) { $r['network']['handle'] = $r['network']['aut-num']; } if (is_array($r['network']['nserver'])) { $r['network']['nserver'] = array_unique($r['network']['nserver']); } $r = array('regrinfo' => $r); $r['regyinfo']['type'] = 'ip'; $r['regyinfo']['registrar'] = 'Latin American and Caribbean IP address Regional Registry'; return $r; }
public function run() { $username = $this->getInput('username', 'post'); $ds = $this->_getPermissionsDs(); if ($username) { $user = Wekit::load('user.PwUser')->getUserByName($username); $uid = isset($user['uid']) ? $user['uid'] : 0; if ($uid < 1) { $this->showError("permission.design.uid.empty"); } } Wind::import('SRV:design.srv.vo.PwDesignPermissionsSo'); $vo = new PwDesignPermissionsSo(); if ($uid) { $vo->setUid($uid); } $_tmp = $ds->searchPermissions($vo); $_gids = $_uids = array(); foreach ($_tmp as $v) { $_uids[] = $v['uid']; } array_unique($_uids); $users = Wekit::load('user.PwUser')->fetchUserByUid($_uids, PwUser::FETCH_MAIN); foreach ($users as &$user) { $user['gid'] = $user['groupid'] == 0 ? $user['memberid'] : $user['groupid']; $_gids[] = $user['gid']; } array_unique($_gids); $groups = Wekit::load('usergroup.PwUserGroups')->fetchGroup($_gids); $this->setOutput($users, 'users'); $this->setOutput($groups, 'groups'); }
public function dump_export_data() { foreach ($this->exporter->get('artefacts') as $artefact) { if (in_array($artefact->get('artefacttype'), PluginArtefactFile::get_artefact_types())) { $this->artefactdata[$artefact->get('id')] = $artefact; } } // Grab all parent folders of all artefacts selected so we can export // the files in their correct folder location if ($this->exporter->get('artefactexportmode') != PluginExport::EXPORT_ALL_ARTEFACTS && $this->artefactdata) { $folderids = array(); foreach (array_keys($this->artefactdata) as $artefactid) { $folderids = array_merge($folderids, array_keys(artefact_get_parents_for_cache($artefactid))); } $folderids = array_unique($folderids); foreach ($folderids as $folderid) { if (!isset($this->artefactdata[$folderid])) { $artefact = artefact_instance_from_id($folderid); // We grabbed all parents of the artefacts in the export, // but not all parents are folders if ($artefact->get('artefacttype') == 'folder') { $this->artefactdata[$folderid] = $artefact; } } } } $this->populate_profileicons(); $this->create_index_for_directory($this->fileroot, 0, null); $this->populate_filedir($this->fileroot, 0, null); }
function __construct($options = array()) { $options = $this->apply_prefix($options); $this->options = $options; foreach ($options as $tpl) { foreach ($tpl as $key => $value) { foreach ($value as $is => $cpt) { if ($is == "if") { $this->templates[$key] = array(); foreach (array_keys($cpt) as $c) { // array_push( $this->templates[$key], call_user_func($c)); $this->templates[$key][$c] = $c; } foreach ($cpt as $k => $v) { $this->templates[$key][$k] = $v; foreach ($v as $vv) { // array_push( $this->templates[$key], call_user_func_array($k,array($vv))); array_push($this->templates[$key][$k], $vv); } $this->templates[$key][$k] = array_unique($this->templates[$key][$k]); } } } } } add_filter("template_include", array($this, "template_include")); add_filter('pre_get_posts', array($this, 'pre_get_posts')); }
/** * Get Test Files * * @param null $directory * @param null $excludes * @return array */ public static function getTestFiles($directory = null, $excludes = null) { if (is_array($directory)) { $files = array(); foreach ($directory as $d) { $files = array_merge($files, self::getTestFiles($d, $excludes)); } return array_unique($files); } if ($excludes !== null) { $excludes = self::getTestFiles((array) $excludes); } if ($directory === null || $directory !== realpath($directory)) { $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS; $directory = str_replace(DS . DS, DS, $basePath . $directory); } $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); $files = array(); while ($it->valid()) { if (!$it->isDot()) { $file = $it->key(); if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) { $files[] = $file; } } $it->next(); } return $files; }
function get_group_names() { if (!isset($GLOBALS['TT2_GNAMES'])) { $sql = "SELECT `groups` FROM `user` WHERE `is_closed` = 0 "; $groupstring = '|'; if ($data = get_data($sql)) { foreach ($data as $item) { if (strlen(trim($item['groups'])) > 1) { $groupstring = $groupstring . strtoupper($item['groups']) . '|'; } } } if ($groupstring == '|') { $groups = null; } else { $groups = explode('|', trim($groupstring, '|')); } $groups = array_unique($groups); foreach ($groups as $k => $v) { if (strlen(trim($v)) < 1) { unset($groups[$k]); } } $GLOBALS['TT2_GNAMES'] = $groups; } return $GLOBALS['TT2_GNAMES']; }
/** * Filter * * @return void */ public function filter() { /* * Variable qui contient la chaine de recherche */ if (is_array($this->terms)) { $stringSearch = implode(' ', $this->terms); } else { $stringSearch = $this->terms; } /* * On divise en mots (séparé par des espace) */ $words = preg_split('`\\s+`', $stringSearch, -1, PREG_SPLIT_NO_EMPTY); if (count($words) > 1) { array_unshift($words, $stringSearch); } $words = array_unique($words); $conds = []; foreach ($words as $index => $word) { foreach ($this->columns as $colName) { $cond = $this->queryBuilder->expr()->like($colName, ':word_' . ($index + 1)); $this->queryBuilder->setParameter('word_' . ($index + 1), '%' . $word . '%'); $conds[] = $cond; } } $this->queryBuilder->andWhere(implode(' OR ', $conds)); }
/** Gets the ID's of the units that someone would use locally based on the passed in system type */ function getLocalUnitIDs($system) { global $g_rb_units; $units = array(); foreach ($g_rb_units['static'] as $key) { $units[] = $key; } // Unit types if (isset($g_rb_units[$system]["wet"])) { foreach ($g_rb_units[$system]["wet"] as $key => $val) { $units[] = $key; } } // Wet volume units if (isset($g_rb_units[$system]["dry"])) { foreach ($g_rb_units[$system]["dry"] as $key => $val) { $units[] = $key; } } // Dry volume units if (isset($g_rb_units[$system]["volume"])) { foreach ($g_rb_units[$system]["volume"] as $key => $val) { $units[] = $key; } } // volume units foreach ($g_rb_units[$system]["mass"] as $key => $val) { $units[] = $key; } // Mass units $units = array_unique($units); // remove duplicates (dry/wet units could be duplicated in the units structure return $units; }
/** * Generate SQL from Rule * @param string $rule Rule to generate SQL for * @return string */ function GenSQL($rule) { $tmp = explode(" ", $rule); $tables = array(); foreach ($tmp as $opt) { if (strstr($opt, '%') && strstr($opt, '.')) { $tmpp = explode(".", $opt, 2); $tmpp[0] = str_replace("%", "", $tmpp[0]); $tables[] = mres(str_replace("(", "", $tmpp[0])); $rule = str_replace($opt, $tmpp[0] . '.' . $tmpp[1], $rule); } } $tables = array_unique($tables); $x = sizeof($tables); $i = 0; $join = ""; while ($i < $x) { if (isset($tables[$i + 1])) { $join .= $tables[$i] . ".device_id = " . $tables[$i + 1] . ".device_id && "; } $i++; } $sql = "SELECT * FROM " . implode(",", $tables) . " WHERE (" . $join . "" . str_replace("(", "", $tables[0]) . ".device_id = ?) && (" . str_replace(array("%", "@", "!~", "~"), array("", "%", "NOT LIKE", "LIKE"), $rule) . ")"; return $sql; }
public function test(CqmPatient $patient, $beginDate, $endDate) { // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months) $date_array = array(); foreach ($this->getApplicableEncounters() as $encType) { $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate); $date_array = array_merge($date_array, $dates); } // sort array to get the most recent encounter first $date_array = array_unique($date_array); rsort($date_array); // go through each unique date from most recent foreach ($date_array as $date) { // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable $date = date('Y-m-d 23:59:59', strtotime($date)); $beginMinus24Months = strtotime('-24 month', strtotime($date)); $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months); // this is basically a check to see if the patient is an reported as an active smoker on their last encounter if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) { return true; } else { if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) { return false; } else { // nothing reported during this date period, so move on to next encounter } } } return false; }
public function getTaxaFilterList() { $returnArr = array(); $sql = "SELECT DISTINCT nt.UnitName1, ts.Family "; if ($this->clid && $this->clType == "static") { $sql .= "FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID " . "WHERE (cltl.CLID = " . $this->clid . ") "; } else { if ($this->dynClid) { $sql .= "FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmdyncltaxalink dcltl ON nt.TID = dcltl.TID " . "WHERE (dcltl.dynclid = " . $this->dynClid . ") "; } else { $sql .= "FROM (((taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) " . "INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID) " . "INNER JOIN fmchecklists cl ON cltl.CLID = cl.CLID) " . "INNER JOIN fmchklstprojlink clpl ON cl.CLID = clpl.clid " . "WHERE (clpl.pid = " . $this->pid . ") "; } } $sql .= 'AND (ts.taxauthid = 1)'; //echo $sql.'<br/>'; exit; $result = $this->keyCon->query($sql); while ($row = $result->fetch_object()) { $genus = $row->UnitName1; $family = $row->Family; if ($genus) { $returnArr[] = $genus; } if ($family) { $returnArr[] = $family; } } $result->free(); $returnArr = array_unique($returnArr); natcasesort($returnArr); array_unshift($returnArr, "--------------------------"); array_unshift($returnArr, "All Species"); return $returnArr; }