From f280f651c1ea4059896655b132ddaec1e39cbd1b Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Fri, 26 Feb 2010 22:50:57 +0100 Subject: [PATCH] announces.user_id -> announces.uid Signed-off-by: Florent Bruneau --- include/validations/evts.inc.php | 2 +- modules/events.php | 10 +++++----- modules/events/feed.inc.php | 2 +- modules/gadgets.php | 4 ++-- templates/events/admin.tpl | 2 +- templates/events/index.tpl | 2 +- upgrade/account/20_naming_convention.sql | 6 ++++++ 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index c269587..bb2ebb5 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -135,7 +135,7 @@ class EvtReq extends Validate public function commit() { if (XDB::execute("INSERT INTO announces - SET user_id = {?}, creation_date=NOW(), titre={?}, texte={?}, + SET uid = {?}, creation_date=NOW(), titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", $this->user->id(), $this->titre, $this->texte, $this->peremption, $this->pmin, $this->pmax)) { diff --git a/modules/events.php b/modules/events.php index a9dc2d5..98d4a37 100644 --- a/modules/events.php +++ b/modules/events.php @@ -143,22 +143,22 @@ class EventsModule extends PLModule // Unhide the requested event, and reload the page to display it. if ($action == 'unread' && $eid) { XDB::execute('DELETE FROM announce_read - WHERE evt_id = {?} AND user_id = {?}', + WHERE evt_id = {?} AND uid = {?}', $eid, S::v('uid')); pl_redirect('events#newsid'.$eid); } // Fetch the events to display, along with their metadata. $array = array(); - $it = XDB::iterator("SELECT e.id, e.titre, e.texte, e.post_id, e.user_id, + $it = XDB::iterator("SELECT e.id, e.titre, e.texte, e.post_id, e.uid, p.x, p.y, p.attach IS NOT NULL AS img, FIND_IN_SET('wiki', e.flags) AS wiki, FIND_IN_SET('important', e.flags) AS important, e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY) AS news, e.peremption < DATE_ADD(CURDATE(), INTERVAL 2 DAY) AS end, - ev.user_id IS NULL AS nonlu, e.promo_min, e.promo_max + ev.uid IS NULL AS nonlu, e.promo_min, e.promo_max FROM announces AS e LEFT JOIN announce_photos AS p ON (e.id = p.eid) - LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) + LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?}) WHERE FIND_IN_SET('valide', e.flags) AND peremption >= NOW() ORDER BY important DESC, news DESC, end DESC, e.peremption, e.creation_date DESC", S::i('uid')); @@ -452,7 +452,7 @@ class EventsModule extends PLModule } $pid = ($eid && $action == 'preview') ? $eid : -1; - $sql = "SELECT e.id, e.titre, e.texte,e.id = $pid AS preview, e.user_id, + $sql = "SELECT e.id, e.titre, e.texte,e.id = $pid AS preview, e.uid, DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, e.promo_min, e.promo_max, diff --git a/modules/events/feed.inc.php b/modules/events/feed.inc.php index 2d9b966..524ff32 100644 --- a/modules/events/feed.inc.php +++ b/modules/events/feed.inc.php @@ -47,7 +47,7 @@ class EventFeed extends PlFeed global $globals; $events = XDB::iterator('SELECT e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, p.attachmime IS NOT NULL AS photo, FIND_IN_SET(\'wiki\', e.flags) AS wiki, - e.user_id, e.promo_min, e.promo_max + e.uid, e.promo_min, e.promo_max FROM announces AS e LEFT JOIN announce_photos AS p ON (p.eid = e.id) WHERE FIND_IN_SET("valide", e.flags) AND peremption >= NOW()'); diff --git a/modules/gadgets.php b/modules/gadgets.php index 40651cd..d769a9d 100644 --- a/modules/gadgets.php +++ b/modules/gadgets.php @@ -45,9 +45,9 @@ class GadgetsModule extends PLModule $events = XDB::iterator('SELECT SQL_CALC_FOUND_ROWS e.id, e.titre, UNIX_TIMESTAMP(e.creation_date) AS creation_date, IF(u.nom_usage = "", u.nom, u.nom_usage) AS nom, u.prenom, u.promo, - ev.user_id IS NULL AS nonlu, e.user_id + ev.user_id IS NULL AS nonlu, e.uid FROM announces AS e - LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) + LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?}) WHERE FIND_IN_SET("valide", e.flags) AND peremption >= NOW() ORDER BY e.creation_date DESC', S::i('uid')); $page->assign('event_count', XDB::query("SELECT FOUND_ROWS()")->fetchOneCell()); diff --git a/templates/events/admin.tpl b/templates/events/admin.tpl index 8bd9026..9513349 100644 --- a/templates/events/admin.tpl +++ b/templates/events/admin.tpl @@ -60,7 +60,7 @@ {$ev.titre}
{if !$ev.fvalide}{/if} - Proposée par {profile user=$ev.user_id promo=true sex=false} + Proposée par {profile user=$ev.uid promo=true sex=false} {if !$ev.fvalide}{/if}{$ev.peremption}{if !$ev.fvalide}{/if} diff --git a/templates/events/index.tpl b/templates/events/index.tpl index b4e32d0..5a5744c 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -189,7 +189,7 @@ Bienvenue {$smarty.session.display_name}{if $birthday} Sommaire - Annonce proposée par {profile user=$ev.user_id sex=false promo=true} + Annonce proposée par {profile user=$ev.uid sex=false promo=true} diff --git a/upgrade/account/20_naming_convention.sql b/upgrade/account/20_naming_convention.sql index 3dfadf4..977897d 100644 --- a/upgrade/account/20_naming_convention.sql +++ b/upgrade/account/20_naming_convention.sql @@ -20,6 +20,12 @@ CHANGE COLUMN cle pkey VARCHAR(5) NOT NULL; ALTER TABLE aliases CHANGE COLUMN id uid INT(11) not null; +# announces + ALTER TABLE announces +CHANGE COLUMN user_id uid INT(11) not null; + ALTER TABLE announce_read +CHANGE COLUMN user_id uid INT(11) not null; + # profile ALTER TABLE profile_photos CHANGE COLUMN uid pid INT(11) not null; -- 2.1.4