本文整理汇总了PHP中IPSLib::cleanIntArray方法的典型用法代码示例。如果您正苦于以下问题:PHP IPSLib::cleanIntArray方法的具体用法?PHP IPSLib::cleanIntArray怎么用?PHP IPSLib::cleanIntArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPSLib
的用法示例。
在下文中一共展示了IPSLib::cleanIntArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _moderate
/**
* Moderate
*
* @return @e void
*/
protected function _moderate()
{
$parentId = intval($this->request['parentId']);
$commentIds = is_array($_POST['commentIds']) ? IPSLib::cleanIntArray($_POST['commentIds']) : array();
$modact = trim($this->request['modact']);
if (count($commentIds)) {
try {
$this->_comments->moderate($modact, $parentId, $commentIds, $this->memberData);
$this->returnJsonArray(array('msg' => 'ok'));
} catch (Exception $error) {
if ($error->getMessage() == 'NO_PERMISSION') {
$this->returnJsonError($this->lang->words['ap_np_msg']);
} else {
$this->returnJsonError('Error ' . $error->getMessage() . ' line: ' . $error->getFile() . '.' . $error->getLine());
}
}
}
}
示例2: _remove
/**
* Remove log
*
* @return @e void [Outputs to screen]
*/
protected function _remove()
{
if ($this->request['type'] == 'all') {
$this->DB->delete('spam_service_log');
} else {
$ids = array();
foreach ($this->request as $k => $v) {
if (preg_match("/^id_(\\d+)\$/", $k, $match)) {
if ($this->request[$match[0]]) {
$ids[] = $match[1];
}
}
}
$ids = IPSLib::cleanIntArray($ids);
//-----------------------------------------
if (count($ids) < 1) {
$this->registry->output->showError($this->lang->words['erlog_noneselected'], 11115);
}
$this->DB->delete('spam_service_log', "id IN (" . implode(',', $ids) . ")");
}
$this->registry->output->silentRedirect($this->settings['base_url'] . "&{$this->form_code}");
}
示例3: processBatch
/**
* Process a batch. Genius.
* $options is an array of keys and values:
* process - INT - number of items to process in this batch
* @return int count of topics archived
*/
public function processBatch($options = array())
{
$restoreData = $this->getRestoreData();
$topics = array();
$forums = array();
$pids = array();
/* Fix up options */
$options['process'] = is_numeric($options['process']) && $options['process'] > 0 ? $options['process'] : 250;
if (!$restoreData['restore_min_tid'] && !$restoreData['restore_max_tid'] && !count($restoreData['restore_manual_tids'])) {
return false;
}
/* Any manually flagged? */
if (count($restoreData['restore_manual_tids'])) {
/* Select remaining Pids */
$pids = $this->engine->getPidsInTids(IPSLib::cleanIntArray(array_keys($restoreData['restore_manual_tids'])), $options['process']);
/* Did we complete topics? */
foreach ($restoreData['restore_manual_tids'] as $tid => $maxPid) {
if (in_array($maxPid, array_keys($pids))) {
$this->deleteManualId($tid);
}
}
/* All done? */
if (!count($pids)) {
$restoreData['restore_manual_tids'] = array();
$this->setRestoreData($restoreData);
}
/* Update process for below */
$options['process'] -= count($pids);
}
/* Now fetch the max/min if archiver is on */
if ($this->settings['archive_on'] && $options['process'] > 0 && $restoreData['restore_min_tid'] && $restoreData['restore_max_tid']) {
$date = IPS_UNIX_TIME_NOW - 86400 * intval($this->settings['archive_restore_days']);
$pids = $this->engine->getPidsBetweenTidsAndDate($restoreData['restore_min_tid'], $restoreData['restore_max_tid'], $date, $options['process']);
/* All done? */
if (!count($pids)) {
$restoreData['restore_min_tid'] = 0;
$restoreData['restore_max_tid'] = 0;
$this->setRestoreData($restoreData);
}
}
/* Process */
$this->restore($pids);
return count($pids);
}
示例4: stmExec
/**
* Multi-statement execute
*
* @access public
* @param mixed Id | Array of ids
* @return boolean
*/
public function stmExec($id)
{
if (count($this->stm) < 1) {
return false;
}
$final_array = array();
foreach ($this->stm as $real_array) {
foreach ($real_array as $k => $v) {
$final_array[$k] = $v;
}
}
if (is_array($id)) {
$id = IPSLib::cleanIntArray($id);
if (count($id) > 0) {
$this->DB->update('topics', $final_array, "tid IN(" . implode(",", $id) . ")");
} else {
return false;
}
} else {
if (intval($id) != "") {
$this->DB->update('topics', $final_array, "tid=" . intval($id));
} else {
return false;
}
}
return true;
}
示例5: delete
/**
* Deletes a cache
*
* @param mixed $relId Relationship ID or array of IDs
* @param integer $memberId Member ID
* @return @e void
*/
public function delete($relId, $memberId = null)
{
/* Possible future expansion */
if ($memberId === null) {
$where = '';
if (is_numeric($relId)) {
$where = "='" . classes_like_registry::getKey($relId) . "'";
} elseif (is_array($relId)) {
$relId = IPSLib::cleanIntArray($relId);
$keys = array();
foreach ($relId as $id) {
$keys[] = "'" . classes_like_registry::getKey($id) . "'";
}
if (!count($keys)) {
return null;
}
$where = " IN (" . implode(",", $keys) . ")";
}
$this->DB->delete('core_like_cache', 'like_cache_id ' . $where);
}
}
示例6: stmExec
/**
* Multi-statement execute
*
* @param mixed Id | Array of ids
* @return boolean
*/
public function stmExec($id)
{
if (count($this->stm) < 1) {
return false;
}
$final_array = array();
foreach ($this->stm as $real_array) {
foreach ($real_array as $k => $v) {
$final_array[$k] = $v;
}
}
if (isset($final_array['approved']) and $final_array['approved'] == -1) {
$this->_addToSoftDeleteLog($id);
}
if (is_array($id)) {
$id = IPSLib::cleanIntArray($id);
if (count($id) > 0) {
/* Ensure we don't moderate topics in archives */
$this->DB->update('topics', $final_array, $this->registry->class_forums->fetchTopicArchiveQuery(array('not', 'exclude')) . " AND tid IN(" . implode(",", $id) . ")");
} else {
return false;
}
} else {
if (intval($id) != "") {
$this->DB->update('topics', $final_array, $this->registry->class_forums->fetchTopicArchiveQuery(array('not', 'exclude')) . " AND tid=" . intval($id));
} else {
return false;
}
}
return true;
}
示例7: _memberDelete
/**
* Delete members [form+process]
*
* @access private
* @return void [Outputs to screen]
*/
private function _memberDelete()
{
//-----------------------------------------
// Check input
//-----------------------------------------
if (!$this->request['member_id']) {
$this->registry->output->global_message = $this->lang->words['m_nomember'];
$this->request['do'] = 'members_list';
$this->_memberList();
return;
}
//-----------------------------------------
// Single or more?
//-----------------------------------------
if (strstr($this->request['member_id'], ',')) {
$ids = explode(',', $this->request['member_id']);
} else {
$ids = array($this->request['member_id']);
}
$ids = IPSLib::cleanIntArray($ids);
/* Don't delete our selves */
if (in_array($this->memberData['member_id'], $ids)) {
$this->registry->output->global_message = $this->lang->words['m_nodeleteslefr'];
$this->request['do'] = 'members_list';
$this->_memberList();
return;
}
//-----------------------------------------
// Get accounts
//-----------------------------------------
$this->DB->build(array('select' => 'member_id, name, member_group_id, mgroup_others', 'from' => 'members', 'where' => 'member_id IN (' . implode(",", $ids) . ')'));
$this->DB->execute();
$names = array();
while ($r = $this->DB->fetch()) {
//-----------------------------------------
// r u trying to kill teh admin?
//-----------------------------------------
if (!$this->registry->getClass('class_permissions')->checkPermission('member_delete_admin')) {
if ($this->caches['group_cache'][$r['member_group_id']]['g_access_cp']) {
continue;
} else {
$other_mgroups = explode(',', IPSText::cleanPermString($r['mgroup_others']));
if (count($other_mgroups)) {
foreach ($other_mgroups as $other_mgroup) {
if ($this->caches['group_cache'][$other_mgroup]['g_access_cp']) {
continue;
}
}
}
}
}
$names[] = $r['name'];
}
//-----------------------------------------
// Check
//-----------------------------------------
if (!count($names)) {
$this->registry->output->global_message = $this->lang->words['m_nomember'];
$this->request['do'] = 'members_list';
$this->_memberList();
return;
}
//-----------------------------------------
// Delete
//-----------------------------------------
IPSMember::remove($ids, true);
//-----------------------------------------
// Clear "cookies"
//-----------------------------------------
ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array());
//-----------------------------------------
// Redirect
//-----------------------------------------
$page_query = "";
ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_deletedlog'], implode(",", $names)));
$this->registry->output->global_message = sprintf($this->lang->words['m_deletedlog'], implode(",", $names));
$this->request['do'] = 'members_list';
$this->_memberList();
}
示例8: _bulkRemoveAttachments
/**
* Bulk remove attachments
*
* @return @e void [Outputs to screen]
*/
protected function _bulkRemoveAttachments()
{
foreach ($_POST as $key => $value) {
if (preg_match("/^attach_(\\d+)\$/", $key, $match)) {
if ($this->request[$match[0]]) {
$ids[] = $match[1];
}
}
}
$ids = IPSLib::cleanIntArray($ids);
$attach_tid = array();
if (count($ids)) {
//-----------------------------------------
// Get attach details?
//-----------------------------------------
$this->DB->build(array('select' => 'a.*', 'from' => array('attachments' => 'a'), 'where' => "a.attach_rel_id > 0 AND a.attach_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'p.pid, p.topic_id', 'from' => array('posts' => 'p'), 'where' => "p.pid=a.attach_rel_id AND attach_rel_module='post'", 'type' => 'left'))));
$this->DB->execute();
while ($killmeh = $this->DB->fetch()) {
if ($killmeh['attach_location']) {
@unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_location']);
}
if ($killmeh['attach_thumb_location']) {
@unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_thumb_location']);
}
$attach_tid[$killmeh['topic_id']] = $killmeh['topic_id'];
}
$this->DB->delete('attachments', "attach_id IN(" . implode(",", $ids) . ")");
$this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['deleted_attachments'], implode(",", $ids)));
//-----------------------------------------
// Recount topic upload marker
//-----------------------------------------
require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
/*noLibHook*/
$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
$postlib = new $classToLoad($this->registry);
foreach ($attach_tid as $tid) {
if ($tid) {
$postlib->recountTopicAttachments($tid);
}
}
$this->registry->output->global_message = $this->lang->words['attachments_removed'];
} else {
$this->registry->output->global_message = $this->lang->words['noattach_to_remove'];
}
if ($this->request['return'] == 'stats') {
$this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=attachments§ion=stats');
} else {
if ($_POST['url']) {
foreach (explode('&', $_POST['url']) as $u) {
list($k, $v) = explode('=', $u);
$this->request[$k] = $v;
}
}
$this->_searchResults();
}
}
示例9: _multiManage
/**
* Action a report drop down
*
* @return @e void
*/
protected function _multiManage()
{
$merge_id = $this->request['sessionID'] = intval($this->request['merge_id']);
$mergeOption = trim($this->request['mergeOption']);
$items = is_array($_POST['changeIds']) ? IPSLib::cleanIntArray(array_keys($_POST['changeIds'])) : array();
/* Fetch session and check */
$session = $this->skinFunctions->fetchSession($merge_id);
if ($session === FALSE) {
$this->registry->output->showError($this->lang->words['sd_nosession']);
}
/* Got items? */
if (count($items)) {
/* Process. I love pointless comments */
switch ($mergeOption) {
case 'resolve_custom':
$this->skinFunctions->resolveConflict($items, 'custom');
break;
case 'resolve_new':
$this->skinFunctions->resolveConflict($items, 'new');
break;
case 'commit':
$this->skinFunctions->commit($items);
break;
case 'revert':
$this->skinFunctions->revert($items);
break;
}
}
/* Flush CDN */
$this->skinFunctions->flushipscdn();
/* Throw it out */
$this->registry->output->global_message = $this->lang->words['skindiff_okmsg'];
return $this->_viewReport();
}
示例10: _unlock
/**
* Unlock selected accounts
*
* @access private
* @return void [Outputs to screen]
*/
private function _unlock()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$ids = array();
//-----------------------------------------
// GET checkboxes
//-----------------------------------------
foreach ($this->request as $k => $v) {
if (preg_match("/^mid_(\\d+)\$/", $k, $match)) {
if ($v) {
$ids[] = $match[1];
}
}
}
$ids = IPSLib::cleanIntArray($ids);
//-----------------------------------------
// Check
//-----------------------------------------
if (count($ids) < 1) {
$this->registry->output->showError($this->lang->words['t_nolockloc'], 11251);
}
//-----------------------------------------
// Unlock
//-----------------------------------------
if ($this->request['type'] == 'unlock') {
foreach ($ids as $_id) {
try {
IPSMember::save($_id, array('core' => array('failed_logins' => '', 'failed_login_count' => 0)));
} catch (Exception $error) {
$this->registry->output->showError($error->getMessage(), 11247);
}
}
ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memunlocked']);
$this->registry->output->global_message = count($ids) . $this->lang->words['t_memunlocked'];
$this->_viewQueue('locked');
return;
} else {
if ($this->request['type'] == 'ban') {
try {
IPSMember::save($ids, array('core' => array('failed_logins' => '', 'failed_login_count' => 0, 'member_banned' => 1)));
} catch (Exception $error) {
$this->registry->output->showError($error->getMessage(), 11247);
}
ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_membanned']);
$this->registry->output->global_message = count($ids) . $this->lang->words['t_membanned'];
$this->_viewQueue('locked');
return;
} else {
if ($this->request['type'] == 'delete') {
IPSMember::remove($ids);
ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memdeleted']);
$this->registry->output->global_message = count($ids) . $this->lang->words['t_memdeleted'];
$this->_viewQueue('locked');
return;
}
}
}
}
示例11: banDelete
/**
* Delete a ban filter
*
* @return @e void
*/
public function banDelete()
{
/* INI */
$ids = array();
/* Loop through the request fields and find checked ban filters */
foreach ($this->request as $key => $value) {
if (preg_match('/^banid_(\\d+)$/', $key, $match)) {
if ($this->request[$match[0]]) {
$ids[] = $match[1];
}
}
}
/* Clean the array */
$ids = IPSLib::cleanIntArray($ids);
/* Delete any checked ban filters */
if (count($ids)) {
$this->DB->delete('banfilters', 'ban_id IN(' . implode(",", $ids) . ')');
}
/* Rebuild the cache */
$this->rebuildBanCache();
/* Bounce */
$this->registry->output->global_message = $this->lang->words['ban_removed'];
$this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . 'do=ban');
}
示例12: resolveConflict
/**
* Resolve Conflict Automatically
*
* @access public
* @param array Array of item (change_id) ids
* @param type Which wins? YOU DECIDE (custom/new)
* @return nufink
*/
public function resolveConflict($items, $type = 'new')
{
/* Basic check */
if (!count($items)) {
return false;
}
/* Fetch Data */
$this->DB->build(array('select' => '*', 'from' => 'skin_merge_changes', 'where' => 'change_id IN(' . implode(',', IPSLib::cleanIntArray($items)) . ')'));
$o = $this->DB->execute();
/* GO freakiNG LoOPy */
while ($row = $this->DB->fetch($o)) {
$text = $row['change_merge_content'];
/* Re-format */
preg_match_all("#<ips:conflict id=\"([0-9]+?)\">((?<!(</ips:conflict>)).+?)</ips:conflict>#s", $text, $matches);
if (is_array($matches) and count($matches)) {
foreach ($matches[1] as $index => $m) {
/* Yeah, I like readable code and copying and pasting evidently */
$_all = $matches[0][$index];
$_id = $matches[1][$index];
$_content = $matches[2][$index];
if ($_id != null and $_content) {
/* Save which block? */
if ($type == 'new') {
$_content = preg_replace("#(?:\n)?<ips:cblock type=\"original\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "", $_content);
$_content = preg_replace("#(?:\n)?<ips:cblock type=\"new\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "\n\\1", $_content);
} else {
$_content = preg_replace("#(?:\n)?<ips:cblock type=\"original\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "\n\\1", $_content);
$_content = preg_replace("#(?:\n)?<ips:cblock type=\"new\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "", $_content);
}
$text = str_replace($_all, $_content, $text);
}
}
/* Save to db */
$this->DB->update('skin_merge_changes', array('change_final_content' => $text), 'change_id=' . intval($row['change_id']));
}
}
return true;
}
示例13: banDelete
/**
* Delete a ban filter
*
* @access public
* @return void
*/
public function banDelete()
{
/* INI */
$ids = array();
/* Loop through the request fields and find checked ban filters */
foreach ($this->request as $key => $value) {
if (preg_match("/^id_(\\d+)\$/", $key, $match)) {
if ($this->request[$match[0]]) {
$ids[] = $match[1];
}
}
}
/* Clean the array */
$ids = IPSLib::cleanIntArray($ids);
/* Delete any checked ban filters */
if (count($ids)) {
$this->DB->delete('banfilters', 'ban_id IN(' . implode(",", $ids) . ')');
$this->DB->execute();
}
/* Rebuild the cache */
$this->rebuildBanCache();
/* Bounce */
$this->registry->output->global_message = $this->lang->words['ban_removed'];
$this->banOverview();
}
示例14: run
/**
* Perform the search
* @param array $tags
* @param array $options
*/
public function run(array $tags, array $options)
{
$where = array();
$order = !empty($options['sortKey']) ? $options['sortKey'] : 'tg.tag_meta_id';
$dir = !empty($options['sortOrder']) ? $options['sortOrder'] : 'desc';
$return = array();
/* Format query */
if (isset($options['meta_parent_id']) && (is_numeric($options['meta_parent_id']) || count($options['meta_parent_id']))) {
$where[] = is_array($options['meta_parent_id']) && count($options['meta_parent_id']) ? 'tg.tag_meta_parent_id IN (' . implode(',', IPSLib::cleanIntArray($options['meta_parent_id'])) . ')' : 'tg.tag_meta_parent_id=' . intval($options['meta_parent_id']);
}
if (isset($options['meta_id']) && (is_numeric($options['meta_id']) || count($options['meta_id']))) {
$where[] = is_array($options['meta_id']) && count($options['meta_id']) ? 'tg.tag_meta_id IN (' . implode(',', IPSLib::cleanIntArray($options['meta_id'])) . ')' : 'tg.tag_meta_id=' . intval($options['meta_id']);
}
if (isset($options['meta_app'])) {
$where[] = is_array($options['meta_app']) && count($options['meta_app']) ? 'tg.tag_meta_app IN (\'' . implode("','", $options['meta_app']) . '\')' : 'tg.tag_meta_app=\'' . $options['meta_app'] . '\'';
}
if (isset($options['meta_area'])) {
$where[] = is_array($options['meta_area']) && count($options['meta_area']) ? 'tg.tag_meta_area IN (\'' . implode("','", $options['meta_area']) . '\')' : 'tg.tag_meta_area=\'' . $options['meta_area'] . '\'';
}
if (!empty($options['not_meta_id'])) {
$where[] = is_array($options['not_meta_id']) && count($options['not_meta_id']) ? 'tg.tag_meta_id NOT IN (' . implode(",", $options['not_meta_id']) . ')' : 'tg.tag_meta_id !=' . intval($options['not_meta_id']);
}
if (isset($tags)) {
if (isset($options['match']) and $options['match'] == 'loose') {
$_tags = is_array($tags) ? $tags : array($tags);
$_t = array();
foreach ($_tags as $text) {
$_t[] = ' tg.tag_text LIKE \'%' . $this->DB->addSlashes($text) . '%\'';
}
if (count($_t)) {
$where[] = implode(" OR ", $_t);
}
} else {
if (is_array($tags)) {
$_t = $tags;
$tags = array();
foreach ($_t as $t) {
$tags[] = $this->DB->addSlashes($t);
}
}
$where[] = is_array($tags) ? 'tg.tag_text IN (\'' . implode("','", $tags) . '\')' : 'tg.tag_text=\'' . $this->DB->addSlashes($tags) . '\'';
}
}
$prefix = ips_DBRegistry::getPrefix();
/* Did we add in perm check? */
if (!empty($options['isViewable'])) {
if ($options['joins']) {
$select = array();
$join = '';
foreach ($options['joins'] as $j) {
foreach ($j['from'] as $name => $ref) {
$select[] = $j['select'];
$join .= ' LEFT JOIN ' . $prefix . $name . ' ' . $ref;
if ($j['where']) {
$join .= ' ON (' . $j['where'] . ')';
}
}
}
}
if (count($select)) {
$_select = ',' . implode(',', $select);
}
$options['limit'] = $options['limit'] > 0 && $options['limit'] < 5000 ? $options['limit'] : 250;
/* we need to make an exception if filtering by date */
if (class_exists('IPSSearchRegistry') && (IPSSearchRegistry::get('in.search_date_start') || IPSSearchRegistry::get('in.search_date_end'))) {
$options['limit'] = 10000000000.0;
}
$this->DB->allow_sub_select = true;
$this->DB->query('SELECT tg.* ' . $_select . ' FROM ' . $prefix . 'core_tags tg ' . $join . ' WHERE ' . implode(' AND ', $where) . ' AND tg.tag_aai_lookup IN (' . 'SELECT tag_perm_aai_lookup FROM ' . $prefix . 'core_tags_perms WHERE ' . $this->DB->buildWherePermission($this->member->perm_id_array, 'tag_perm_text') . ' AND tag_perm_visible=1 ' . ') ORDER BY ' . $order . ' ' . $dir . ' LIMIT 0,' . $options['limit']);
$this->DB->execute();
} else {
if (is_array($options['joins'])) {
$db = array('select' => 'tg.*', 'from' => array('core_tags' => 'tg'), 'where' => implode(' AND ', $where), 'add_join' => array($options['joins']), 'order' => $order . ' ' . $dir);
} else {
$db = array('select' => 'tg.*', 'from' => 'core_tags tg', 'where' => implode(' AND ', $where), 'order' => $order . ' ' . $dir);
}
if (!empty($options['limit']) || !empty($options['offset'])) {
$db['limit'] = array(intval($options['offset']), intval($options['limit']));
}
/* Fetch */
$this->DB->build($db);
$this->DB->execute();
}
/* Fetch data */
while ($row = $this->DB->fetch()) {
$return[$row['tag_id']] = $row;
}
return $return;
}
示例15: run
/**
* Perform the search
* @param array $tags
* @param array $options
*/
public function run(array $tags, array $options)
{
$order = !empty($options['sortKey']) ? $options['sortKey'] : 'search_id';
$dir = !empty($options['sortOrder']) ? $options['sortOrder'] : 'desc';
$return = array();
$query = '';
$searchIds = array();
/* Format query */
if (!empty($options['meta_parent_id'])) {
$this->sphinxClient->SetFilter('tag_meta_parent_id', is_array($options['meta_parent_id']) ? IPSLib::cleanIntArray($options['meta_parent_id']) : $options['meta_parent_id']);
}
if (!empty($options['meta_id'])) {
$this->sphinxClient->SetFilter('tag_meta_id', is_array($options['meta_id']) ? IPSLib::cleanIntArray($options['meta_id']) : $options['meta_id']);
}
if (isset($options['meta_app'])) {
$query .= ' @tag_meta_app ' . (is_array($options['meta_app']) ? implode("|", $options['meta_app']) : $options['meta_app']) . '';
}
if (isset($options['meta_area'])) {
if (is_array($options['meta_area'])) {
$_areas = array();
foreach ($options['meta_area'] as $v) {
$_areas[] = str_replace('-', '_', $v);
}
$options['meta_area'] = $_areas;
}
$query .= ' @tag_meta_area ' . (is_array($options['meta_area']) ? implode("|", $options['meta_area']) : str_replace('-', '_', $options['meta_area'])) . '';
}
if (!empty($options['not_meta_id'])) {
$this->sphinxClient->SetFilter('tag_meta_id', is_array($options['not_meta_id']) ? IPSLib::cleanIntArray($options['not_meta_id']) : array($options['not_meta_id']), true);
}
if (isset($tags)) {
if (is_array($tags)) {
foreach ($tags as $key => $tag) {
$tags[$key] = $this->sphinxClient->EscapeString($tag);
}
} else {
$tags = $this->sphinxClient->EscapeString($tags);
}
if (isset($options['match']) and $options['match'] == 'loose') {
$query .= ' @tag_text (' . (is_array($tags) ? implode(" | ", $tags) : $tags) . ')';
} else {
$query .= ' @tag_text "^' . (is_array($tags) ? implode('$" | "^', $tags) : $tags) . '$"';
}
}
/* Did we add in perm check? */
if (!empty($options['isViewable'])) {
$query .= ' @tag_perm_text ",' . implode('," | ",', $this->member->perm_id_array) . ',"';
$this->sphinxClient->SetFilter('tag_perm_visible', array(1));
}
/* Sort */
if ($dir == 'asc') {
$this->sphinxClient->SetSortMode(SPH_SORT_ATTR_ASC, str_replace('tg.', '', $order));
} else {
$this->sphinxClient->SetSortMode(SPH_SORT_ATTR_DESC, str_replace('tg.', '', $order));
}
/* Limit Results */
if (!empty($options['limit']) || !empty($options['offset'])) {
$this->sphinxClient->SetLimits(intval($options['offset']), intval($options['limit']));
}
/* run it */
$result = $this->sphinxClient->Query($query, $this->settings['sphinx_prefix'] . 'core_tags_search_main,' . $this->settings['sphinx_prefix'] . 'core_tags_search_delta');
$this->logSphinxWarnings();
/* Check matches and fetch data */
if (is_array($result['matches']) && count($result['matches'])) {
foreach ($result['matches'] as $res) {
$searchIds[] = $res['attrs']['search_id'];
}
}
if (count($searchIds)) {
/* Fetch */
if (count($options['joins'])) {
$this->DB->build(array('select' => 'tg.*', 'from' => array('core_tags' => 'tg'), 'where' => 'tg.tag_id IN(' . implode(",", $searchIds) . ')', 'add_join' => $options['joins'], 'order' => str_replace('search_id', 'tag_id', $order) . ' ' . $dir));
} else {
$this->DB->build(array('select' => '*', 'from' => 'core_tags', 'where' => 'tag_id IN(' . implode(",", $searchIds) . ')', 'add_join' => $options['joins'], 'order' => str_replace('search_id', 'tag_id', $order) . ' ' . $dir));
}
$this->DB->execute();
while ($row = $this->DB->fetch()) {
$return[$row['tag_id']] = $row;
}
}
return $return;
}