$cond = ' AND pub IN ' . XDB::formatArray($this->visibility);
}
$res = XDB::query('SELECT *
- FROM photo
+ FROM profile_photos
WHERE attachmime IN (\'jpeg\', \'png\')
- ' . $cond . ' AND uid = {?}',
+ ' . $cond . ' AND pid = {?}',
$this->id());
if ($res->numRows() > 0) {
$photo = $res->fetchOneAssoc();
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)
+ LEFT JOIN profile_photos AS ph ON (ph.pid = p.pid)
LEFT JOIN account_profiles AS ap ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', ap.perms))
WHERE p.pid IN ' . XDB::formatArray($pids) . '
GROUP BY p.pid
public function commit()
{
- require_once 'notifs.inc.php';
- XDB::execute('REPLACE INTO photo (uid, attachmime, attach, x, y)
+ //require_once 'notifs.inc.php';
+ XDB::execute('REPLACE INTO profile_photos (pid, attachmime, attach, x, y)
VALUES ({?},{?},{?},{?},{?})',
- $this->user->id(), $this->mimetype, $this->data, $this->x, $this->y);
- register_watch_op($this->user->id(), WATCH_FICHE, '', 'photo');
+ $this->user->profile()->id(), $this->mimetype, $this->data, $this->x, $this->y);
+ //register_watch_op($this->user->id(), WATCH_FICHE, '', 'photo');
return true;
}
} elseif (Env::v('suppr')) {
S::assert_xsrf_token();
- XDB::execute('DELETE FROM photo
- WHERE uid = {?}',
- S::v('uid'));
+ XDB::execute('DELETE FROM profile_photos
+ WHERE pid = {?}',
+ S::user()->profile()->id());
XDB::execute('DELETE FROM requests
WHERE user_id = {?} AND type="photo"',
S::v('uid'));
switch ($action) {
case "original":
- pl_cached_content_headers("image/jpeg");
- readfile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg");
+ PlImage::fromFile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg", "image/jpeg")->send();
exit;
case "new":
$mimetype = substr($_FILES['userfile']['type'], 6);
unlink($_FILES['userfile']['tmp_name']);
XDB::execute(
- "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
- $user->id(), $mimetype, $data, $x, $y);
+ "REPLACE INTO profile_photos SET pid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
+ $user->profile()->id(), $mimetype, $data, $x, $y);
break;
case "delete":
S::assert_xsrf_token();
- XDB::execute('DELETE FROM photo WHERE uid = {?}', $user->id());
+ XDB::execute('DELETE FROM profile_photos WHERE pid = {?}', $user->profile()->id());
break;
}
}
// Retreive photo informations
$res = XDB::query("SELECT pub
- FROM photo
- WHERE uid = {?}", $this->pid());
+ FROM profile_photos
+ WHERE pid = {?}", $this->pid());
$this->values['photo_pub'] = $res->fetchOneCell();
if ($this->owner) {
$this->pid(), $new_email);
}
if ($this->changed['photo_pub']) {
- XDB::execute("UPDATE photo
+ XDB::execute("UPDATE profile_photos
SET pub = {?}
- WHERE uid = {?}",
+ WHERE pid = {?}",
$this->values['photo_pub'], $this->pid());
}
if ($this->changed['yourself']) {
--- /dev/null
+CREATE TABLE profile_photos
+ LIKE photo;
+ INSERT INTO profile_photos
+ SELECT *
+ FROM photo;
+
+ ALTER TABLE profile_photos
+CHANGE COLUMN uid pid INT(6) not null;
+
+
+# vim:set ft=mysql: