return $this->getUF(true, $extra_cond, $sort);
}
+ public function getLogo($fallback = true)
+ {
+ if (!empty($this->logo)) {
+ return PlImage::fromData($this->logo, $this->logo_mime);
+ } else if ($fallback) {
+ return PlImage::fromFile(dirname(__FILE__).'/../htdocs/images/dflt_carre.jpg', 'image/jpeg');
+ }
+ return null;
+ }
+
static public function get($id)
{
if (!$id) {
}
+ /* Photo
+ */
+ public function getPhoto($fallback = true)
+ {
+ /* TODO: migrate photo table to profile_photo, change uid to pid
+ */
+ $cond = '';
+ if ($this->visibility) {
+ $cond = ' AND pub IN ' . XDB::formatArray($this->visibility);
+ }
+ $res = XDB::query('SELECT *
+ FROM photo
+ WHERE attachmime IN (\'jpeg\', \'png\')
+ ' . $cond . ' AND uid = {?}',
+ $this->id());
+ if ($res->numRows() > 0) {
+ $photo = $res->fetchOneAssoc();
+ return PlImage::fromData($photo['attach'], 'image/' . $photo['attachmime'],
+ $photo['x'], $photo['y']);
+ } else if ($fallback) {
+ return PlImage::fromFile(dirname(__FILE__).'/../htdocs/images/none.png',
+ 'image/png');
+ }
+ return null;
+ }
+
/* Addresses
*/
public function getAddresses($flags, $limit = null)
IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_usual,
IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_usual,
pd.promo AS promo, pd.short_name, pd.directory_name AS full_name,
- pp.display_tel AS mobile, pp.pub AS mobile_pub
+ pp.display_tel AS mobile, pp.pub AS mobile_pub, ph.pub AS photo_pub
FROM profiles AS p
INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
INNER JOIN profile_education AS pe ON (pe.uid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
LEFT JOIN profile_name AS pn_n ON (pn_n.pid = p.pid
AND pn_n.typeid = ' . self::getNameTypeId('nickname', true) . ')
LEFT JOIN profile_phones AS pp ON (pp.uid = p.pid AND pp.link_type = \'user\' AND tel_type = \'mobile\')
+ LEFT JOIN photo AS ph ON (ph.uid = p.pid)
WHERE p.pid IN ' . XDB::formatArray($pids) . '
GROUP BY p.pid');
}
public function getUIDs($limit = null)
{
- return $this->getUIDList(null, self::defaultLimit($limit));
+ $limit = self::defaultLimit($limit);
+ return $this->getUIDList(null, $limit);
}
public function getPIDs($limit = null)
{
- return $this->getPIDList(null, self::defaultLimit($limit));
+ $limit = self::defaultLimit($limit);
+ return $this->getPIDList(null, $limit);
}
public function getUsers($limit = null)
-Subproject commit e1746810b6aeaba3332ff99acdbf7ff3c2e9ada6
+Subproject commit 6f58e0613a47d9eeb5004c992e6c59b7cf9ec0ea
$ok = false;
if ($wp) {
- $res = XDB::query("SELECT * FROM photo WHERE attachmime IN ('jpeg', 'png') AND uid={?}",
- $profile->pid);
- if ($i = $res->numRows()) {
+ $photo = $profile->getPhoto(false);
+ if ($photo) {
$old2 = clone $self;
- $photo = $res->fetchOneAssoc();
- $width = $photo['x'] * 20/$photo['y'];
- $GLOBALS['p' . $profile->pid] = $photo['attach'];
-
+ $width = $photo->width() * 20 / $photo->height();
$_x = $self->getX();
$_y = $self->getY();
$self->Cell(0, 20, '', '', 0, '', 1);
error_reporting(0);
- $self->Image("var://p" . $profile->pid, $_x, $_y, $width, 20, $photo['attachmime']);
+ $mime = explode('/', $photo->mimeType());
+ $self->Image($photo->path(), $_x, $_y, $width, 20, $mime[1]);
error_reporting($self->report);
if ($self->error) {
} else {
$self->setX($_x);
$self->Cell($width, 20, '', "T");
- $h = 20 / $self->wordwrap($nom, 90-$width);
+ $h = 20 / $self->wordwrap($nom, 90 - $width);
$self->MultiCell(0, $h, $nom, 'T', 'C');
$ok = true;
}
}
// Retrieve the photo and its mime type.
- $photo_data = null;
- $photo_type = null;
-
if ($req && S::logged()) {
include 'validations.inc.php';
$myphoto = PhotoReq::get_request($user->id());
- if ($myphoto) {
- $photo_data = $myphoto->data;
- $photo_type = $myphoto->mimetype;
- }
+ $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype);
} else {
- $res = XDB::query(
- "SELECT attachmime, attach, pub
- FROM photo
- WHERE uid = {?}", $user->id());
- list($photo_type, $photo_data, $photo_pub) = $res->fetchOneRow();
- if ($photo_pub != 'public' && !S::logged()) {
- $photo_type = $photo_data = null;
- }
+ $photo = $user->profile()->getPhoto(true);
}
// Display the photo, or a default one when not available.
- if ($photo_type && $photo_data != null) {
- pl_cached_dynamic_content_headers("image/$photo_type");
- echo $photo_data;
- } else {
- pl_cached_dynamic_content_headers("image/png");
- echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
- }
- exit;
+ $photo->send();
}
function handler_medal(&$page, $mid)
function handler_logo(&$page)
{
global $globals;
-
- $res = XDB::query("SELECT logo, logo_mime
- FROM groups
- WHERE id = {?}",
- $globals->asso('id'));
- list($logo, $logo_mime) = $res->fetchOneRow();
-
- pl_cached_dynamic_content_headers(empty($logo) ? "image/jpeg" : $logo_mime);
- exit;
+ $globals->asso()->getLogo()->send();
}
function handler_site(&$page)