public static function validateString($field, $value, $error) { ProfileNdx_indexer_shared::sendToDbNdx(XenForo_Application::get('db'), 'preprocessedStatistic', array()); $data = $value->getNewData()['xf_option']['option_value']; if ($data == '') { return true; } $xfopt = explode(',', $data); $xfo = array(); foreach ($xfopt as $k => $v) { $xfo[$k] = trim($v); } $var = $xfo; unset($k); unset($v); unset($xfo); unset($xfopt); $valids = ProfileNdx_indexer_shared::getCustomUserFieldsArray(); $error = 'Failed when tried asserting the existance of these fields:'; $errors = array(); foreach ($var as $test) { if (!array_key_exists($test, $valids)) { $errors[] = ' <u><b>' . $test . '</b></u>,'; } } foreach ($errors as $e) { $error .= $e; } $error = rtrim($error, ","); if (count($errors) > 0) { throw new XenForo_Exception($error, true); } else { return true; } }
public function search($q) { if (trim($q) == '') { return array(); } $rawProfiles = ProfileNdx_indexer_shared::recoverFromDbNdx('usersProfiles'); $rawProfiles = $this->filterSearchInput($rawProfiles); $xfopt = XenForo_Application::get('options'); $xfopt = $xfopt->searchable; $xfopt = explode(',', $xfopt); $xfo = array(); foreach ($xfopt as $k => $v) { $xfo[$k] = trim($v); } $res = array(); $cfDic = ProfileNdx_indexer_shared::getCustomUserFieldsArray(); foreach ($rawProfiles as $userN => $info) { $match = array(); foreach ($info as $id => $label) { if (in_array($id, $xfo)) { $n = 0; $thisLab = $cfDic[$id]; if (!is_array($label)) { $label = array($label); } $searchable = array(); foreach ($label as $cufChng) { $d = ''; if (array_key_exists($id . '_choice_' . $cufChng, $cfDic)) { $d = $cfDic[$id . '_choice_' . $cufChng]; } else { $d = $cufChng; } $searchable[] = $d; } $n = $this->repeatingTimes($this->plainifyArrayOfStrings($searchable), $q); if ($n == 0) { continue; } $match[$thisLab] = $n; } } $match['Total'] = array_sum($match); if ($match['Total'] > 0) { arsort($match); $res[] = array($match, array($userN, $rawProfiles[$userN]['username'])); } } arsort($res); return $res; }