public function getMainAddress()
{
- $addr = $this->getAddresses(self::ADDRESS_PERSO | self::ADDRESS_MAIN);
- if (count($addr) == 0) {
- return null;
+ $main = $this->getAddresses(self::ADDRESS_MAIN);
+ $perso = $this->getAddresses(self::ADDRESS_PERSO);
+
+ if (count($main)) {
+ return array_pop($main);
+ } else if (count($perso)) {
+ return array_pop($perso);
} else {
- return array_pop($addr);
+ return null;
}
}
}
}
- public static function rebuildSearchTokens($pids)
+ public static function rebuildSearchTokens($pids, $transaction = true)
{
if (!is_array($pids)) {
$pids = array($pids);
$eltScore, $key['public']);
}
}
- XDB::startTransaction();
+ if ($transaction) {
+ XDB::startTransaction();
+ }
XDB::execute('DELETE FROM search_name
WHERE pid IN {?}',
$pids);
XDB::rawExecute('INSERT INTO search_name (token, pid, soundex, score, flags)
VALUES ' . implode(', ', $names));
}
- XDB::commit();
+ if ($transaction) {
+ XDB::commit();
+ }
}
/** The school identifier consists of 6 digits. The first 3 represent the