public function getFaceById($face_id, $full = false)
{
$sql = 'SELECT face_id, image_id, gallery_id, face_name';
if ($full) {
$sql .= ', face_x1, face_y1, face_x2, face_y2, face_signature';
}
$sql .= ' FROM ansel_faces WHERE face_id = ?';
try {
$face = $GLOBALS['ansel_db']->selectOne($sql, array((int) $face_id));
} catch (Horde_Db_Exception $e) {
throw new Ansel_Exception($e);
}
if (empty($face)) {
throw new Horde_Exception_NotFound('Face does not exist');
}
if ($full && $GLOBALS['conf']['faces']['search'] && function_exists('puzzle_uncompress_cvec')) {
$columns = $GLOBALS['ansel_db']->columns('ansel_faces');
$face['face_signature'] = puzzle_uncompress_cvec($columns['face_signature']->binaryToString($face['face_signature']));
}
if (empty($face['face_name'])) {
$face['galleries'][$face['gallery_id']][] = $face['image_id'];
return $face;
}
$sql = 'SELECT gallery_id, image_id FROM ansel_faces WHERE face_name = ?';
try {
$galleries = $GLOBALS['ansel_db']->selectAll($sql, array($face['face_name']));
} catch (Horde_Db_Exception $e) {
throw new Ansel_Exception($e);
}
if (empty($galleries)) {
throw new Horde_Exception_NotFound('Face does not exist');
}
foreach ($galleries as $gallery) {
$face['galleries'][$gallery['gallery_id']][] = $gallery['image_id'];
}
return $face;
}