***************************************************************************/
require('./connect.db.inc.php');
-require('user.func.inc.php');
ini_set('memory_limit', "16M");
$globals->debug = 0; // Do not store backtraces
$i = 0;
$n = $res->total();
while ($uid = $res->next()->fetchOneCell()) {
- user_reindex($uid);
+ Profile::rebuildSearchTokens($uid);
printf("\r%u / %u", ++$i, $n);
}
return $table[$type];
}
}
+
+ public static function rebuildSearchTokens($pid)
+ {
+ XDB::execute('DELETE FROM search_name
+ WHERE uid = {?}',
+ $pid);
+ $keys = XDB::iterator("SELECT CONCAT(n.particle, n.name) AS name, e.score,
+ FIND_IN_SET('public', e.flags) AS public
+ FROM profile_name AS n
+ INNER JOIN profile_name_enum AS e ON (n.typeid = e.id)
+ WHERE n.pid = {?}",
+ $pid);
+
+ foreach ($keys as $i => $key) {
+ if ($key['name'] == '') {
+ continue;
+ }
+ $toks = preg_split('/[ \'\-]+/', $key['name']);
+ $token = '';
+ $first = 5;
+ while ($toks) {
+ $token = strtolower(replace_accent(array_pop($toks) . $token));
+ $score = ($toks ? 0 : 10 + $first) * ($key['score'] / 10);
+ XDB::execute('REPLACE INTO search_name (token, uid, soundex, score, flags)
+ VALUES ({?}, {?}, {?}, {?}, {?})',
+ $token, $uid, soundex_fr($token), $score, $key['public']);
+ $first = 0;
+ }
+ }
+
+
+ }
}
/** Iterator over a set of Profiles
VALUES ({?}, 'alias', 'usage', {?})",
$new_alias, S::i('uid'));
}
- require_once('user.func.inc.php');
- user_reindex(S::i('uid'));
+ Profile::rebuildSearchTokens(S::i('uid'));
return $has_new;
}
}
// }}}
-// {{{ function _user_reindex
-
-function _user_reindex($uid, $keys)
-{
- foreach ($keys as $i => $key) {
- if ($key['name'] == '') {
- continue;
- }
- $toks = preg_split('/[ \'\-]+/', $key['name']);
- $token = "";
- $first = 5;
- while ($toks) {
- $token = strtolower(replace_accent(array_pop($toks) . $token));
- $score = ($toks ? 0 : 10 + $first) * ($key['score'] / 10);
- XDB::execute("REPLACE INTO search_name (token, uid, soundex, score, flags)
- VALUES ({?}, {?}, {?}, {?}, {?})",
- $token, $uid, soundex_fr($token), $score, $key['public']);
- $first = 0;
- }
- }
-}
-
-// }}}
-// {{{ function user_reindex
-
-function user_reindex($uid) {
- XDB::execute("DELETE FROM search_name
- WHERE uid = {?}",
- $uid);
- $res = XDB::iterator("SELECT CONCAT(n.particle, n.name) AS name, e.score,
- FIND_IN_SET('public', e.flags) AS public
- FROM profile_name AS n
- INNER JOIN profile_name_enum AS e ON (n.typeid = e.id)
- WHERE n.pid = {?}",
- $uid);
- _user_reindex($uid, $res);
-}
-
-// }}}
// {{{ function get_X_mat
function get_X_mat($ourmat)
{
return PL_FORBIDDEN;
}
- require_once('user.func.inc.php');
-
// Retrieve the pre-registration information using the url-provided
// authentication token.
if ($hash) {
}
// Add the registration email address as first and only redirection.
- require_once('emails.inc.php');
+ require_once 'emails.inc.php';
$user = User::getSilent($uid);
$redirect = new Redirect($user);
$redirect->add_email($email);
AXLetter::subscribe(S::user()->id());
break;
case 'imap':
- require_once 'emails.inc.php';
$user = S::user();
$storage = new EmailStorage($user, 'imap');
$storage->activate();
$mymail->send();
// Index the user, to allow her to appear in searches.
- require_once('user.func.inc.php');
- user_reindex($uid);
+ Profile::rebuildSearchTokens($uid);
// Notify other users which were watching for her arrival.
require_once 'notifs.inc.php';