From: Florent Bruneau Date: Thu, 18 Oct 2007 19:34:34 +0000 (+0200) Subject: List updated fields in carnet notification (only rss and panel for now, X-Git-Tag: xorg/0.9.16~270 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=a2a1c2f29234ccc08ec5bce5987c521354a0da7a;p=platal.git List updated fields in carnet notification (only rss and panel for now, email may come later) Signed-off-by: Florent Bruneau --- diff --git a/ChangeLog b/ChangeLog index 7447afb..8a290eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ ================================================================================ VERSION 0.9.16 XX XX 2007 +New: + + * Carnet: + - List updated fields in notifications -FRU + ================================================================================ VERSION 0.9.15 08 10 2007 diff --git a/include/notifs.inc.php b/include/notifs.inc.php index b77bd34..4daeaf6 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -39,9 +39,13 @@ function register_watch_op($uid, $cid, $date='', $info='') if (empty($date)) { $date = date('Y-m-d'); }; - XDB::execute('REPLACE INTO watch_ops (uid,cid,known,date,info) VALUES({?},{?},NOW(),{?},{?})', - $uid, $cid, $date, $info); + XDB::execute('REPLACE INTO watch_ops (uid,cid,known,date,info) + VALUES ({?}, {?}, NOW(), {?}, {?})', + $uid, $cid, $date, $info); if($cid == WATCH_FICHE) { + if ($info) { + register_profile_update($uid, $info); + } XDB::execute('UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id={?}', $uid); } elseif($cid == WATCH_INSCR) { XDB::execute('REPLACE INTO contacts (uid,contact) @@ -153,6 +157,51 @@ function getNbNotifs() } // }}} +// {{{ + +global $prf_desc; +$prf_desc = array('nom' => 'Son patronyme', + 'freetext' => 'Le texte libre', + 'mobile' => 'Son numéro de téléphone portable', + 'nationalite' => 'Sa nationalité', + 'nick' => 'Son surnom', + 'web' => 'L\'adresse de son site web', + 'appli1' => 'Son école d\'application', + 'appli2' => 'Son école de post-application', + 'addresses' => 'Ses adresses', + 'section' => 'Sa section sportive', + 'binets' => 'La liste de ses binets', + 'medals' => 'Ses décorations', + 'cv' => 'Son Curriculum Vitae', + 'jobs' => 'Ses informations professionnelles', + 'photo' => 'Sa photographie'); + +function get_profile_change_details($event, $limit) { + global $prf_desc; + $res = XDB::iterRow("SELECT field + FROM watch_profile + WHERE uid = {?} AND ts > {?} + ORDER BY ts DESC", + $event['uid'], $limit); + if ($res->total() > 0) { + $data = array(); + while (list($field) = $res->next()) { + $data[] .= $prf_desc[$field]; + } + return ''; + } + return null; +} + +// }}} +// {{{ function register_profile_update + +function register_profile_update($uid, $field) { + XDB::execute("REPLACE INTO watch_profile (uid, ts, field) + VALUES ({?}, NOW(), {?})", + $uid, $field); +} + // {{{ class AllNotifs class AllNotifs @@ -208,6 +257,9 @@ class Notifs // depuis la semaine dernière, meme ceux sans surveillance, ordonnés $res = select_notifs(false, $uid, $lastweek); while($tmp = $res->next()) { + if ($tmp['cid'] == WATCH_FICHE) { + $tmp['data'] = get_profile_change_details($tmp, $lastweek); + } $this->_data[$tmp['cid']][$tmp['promo']][] = $tmp; } diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index 7e65dc5..3331509 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -100,7 +100,11 @@ class MedalReq extends Validate public function commit () { - return XDB::execute('REPLACE INTO profile_medals_sub VALUES({?}, {?}, {?})', $this->uid, $this->mid, $this->gid); + require_once 'notifs.inc.php'; + register_watch_op($this->uid, WATCH_FICHE, 'medals'); + return XDB::execute('REPLACE INTO profile_medals_sub + VALUES ({?}, {?}, {?})', + $this->uid, $this->mid, $this->gid); } // }}} diff --git a/include/validations/nomusage.inc.php b/include/validations/nomusage.inc.php index 5c01b0c..ffca658 100644 --- a/include/validations/nomusage.inc.php +++ b/include/validations/nomusage.inc.php @@ -103,6 +103,8 @@ class UsageReq extends Validate public function commit() { + require_once 'notifs.inc.php'; + register_watch_op($this->uid, WATCH_FICHE, 'nom'); require_once('user.func.inc.php'); $this->bestalias = set_new_usage($this->uid, $this->nom_usage, $this->alias); return true; diff --git a/include/validations/photos.inc.php b/include/validations/photos.inc.php index c62cff7..40f2cc1 100644 --- a/include/validations/photos.inc.php +++ b/include/validations/photos.inc.php @@ -137,11 +137,11 @@ class PhotoReq extends Validate public function commit() { + require_once 'notifs.inc.php'; XDB::execute('REPLACE INTO photo (uid, attachmime, attach, x, y) VALUES ({?},{?},{?},{?},{?})', $this->uid, $this->mimetype, $this->data, $this->x, $this->y); - require_once('notifs.inc.php'); - register_watch_op($this->uid, WATCH_FICHE); + register_watch_op($this->uid, WATCH_FICHE, 'photo'); return true; } diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 0717bb6..d879104 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -172,6 +172,7 @@ class ProfileAddresses extends ProfilePage { parent::__construct($wiz); $this->settings['addresses'] = new ProfileAddress(); + $this->watched['addresses'] = true; } protected function _fetchData() diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index ab1d9fd..de68fd6 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -92,6 +92,7 @@ class ProfileDecos extends ProfilePage parent::__construct($wiz); $this->settings['medals'] = new ProfileDeco(); $this->settings['medals_pub'] = new ProfilePub(); + $this->watched['medals'] = true; } protected function _fetchData() diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index f106838..11d3076 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -117,6 +117,8 @@ class ProfileGeneral extends ProfilePage $this->settings['appli1'] = $this->settings['appli2'] = new ProfileAppli(); + $this->watched= array('nom' => true, 'freetext' => true, 'mobile' => true, 'web' => true, + 'appli1' => true, 'appli2' => true, 'nationalite' => true, 'nick' => true); } protected function _fetchData() diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php index 83d89f3..42165ed 100644 --- a/modules/profile/groups.inc.php +++ b/modules/profile/groups.inc.php @@ -103,6 +103,7 @@ class ProfileGroups extends ProfilePage parent::__construct($wiz); $this->settings['section'] = new ProfileSection(); $this->settings['binets'] = new ProfileGroup('binets', 'user_id', 'binet_id'); + $this->watched['section'] = $this->watched['binets'] = true; } public function _prepare(PlatalPage &$page, $id) diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index e7e4321..1ea4d5d 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -130,6 +130,7 @@ class ProfileJobs extends ProfilePage parent::__construct($wiz); $this->settings['cv'] = null; $this->settings['jobs'] = new ProfileJob(); + $this->watched['cv'] = $this->watched['jobs'] = true; } protected function _fetchData() diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 96344b8..c11793f 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -201,6 +201,7 @@ abstract class ProfilePage implements PlWizardPage protected $settings = array(); // A set ProfileSetting objects protected $errors = array(); // A set of boolean with the value check errors protected $changed = array(); // A set of boolean indicating wether the value has been changed + protected $watched = array(); // A set of boolean indicating the fields that are watched public $orig = array(); public $values = array(); @@ -240,10 +241,14 @@ abstract class ProfilePage implements PlWizardPage protected function saveData() { + require_once 'notifs.inc.php'; foreach ($this->settings as $field=>&$setting) { if (!is_null($setting) && $this->changed[$field]) { $setting->save($this, $field, $this->values[$field]); } + if ($this->changed[$field] && @$this->watched[$field]) { + register_profile_update(S::i('uid'), $field); + } } $this->_saveData(); @@ -251,7 +256,6 @@ abstract class ProfilePage implements PlWizardPage XDB::execute('REPLACE INTO user_changes SET user_id = {?}', S::v('uid')); if (!S::has('suid')) { - require_once 'notifs.inc.php'; register_watch_op(S::i('uid'), WATCH_FICHE); } global $platal; diff --git a/templates/carnet/panel.tpl b/templates/carnet/panel.tpl index f11f063..64d80f2 100644 --- a/templates/carnet/panel.tpl +++ b/templates/carnet/panel.tpl @@ -62,7 +62,7 @@ Il faut pour cela se rendre sur la page de configuration {foreach from=$c key=p item=promo} {section name=row loop=$promo} $smarty.session.watch_last ) || ( $promo[row].date eq $today ) }style="font-weight: bold"{/if}> - {if $smarty.section.row.first}{$p}{/if} + {if $smarty.section.row.first}{$p}{/if} {if $promo[row].inscrit} @@ -76,9 +76,12 @@ Il faut pour cela se rendre sur la page de configuration {$promo[row].prenom} {$promo[row].nom} {/if} - + {$promo[row].date|date_format} + {if $promo[row].data} + {$promo[row].data|smarty:nodefaults} + {/if} {/section} {/foreach} diff --git a/templates/carnet/rss.tpl b/templates/carnet/rss.tpl index 6dbf65d..f2a53d0 100644 --- a/templates/carnet/rss.tpl +++ b/templates/carnet/rss.tpl @@ -42,6 +42,7 @@ {#globals.baseurl#}/profile/private/{$x.bestalias} carnet{$x.known}{$cid}{$x.bestalias} {$x.data}
{/if} {if !$x.contact and !$x.dcd}
{icon name=add title="Ajouter" full=true} Ajouter à mes contacts diff --git a/upgrade/0.9.16/00_profile.sql b/upgrade/0.9.16/00_profile.sql new file mode 100644 index 0000000..3afd0a8 --- /dev/null +++ b/upgrade/0.9.16/00_profile.sql @@ -0,0 +1,10 @@ +create table watch_profile ( + uid int(5) unsigned not null, + ts timestamp not null default CURRENT_TIMESTAMP, + field enum('nom', 'freetext', 'mobile', 'nationalite', 'nick', 'web', 'appli1', 'appli2', + 'addresses', 'section', 'binets', 'medals', 'cv', 'jobs', 'photo'), + + primary key field (uid, field) +) charset=utf8; + +# vim:set syntax=mysql: diff --git a/upgrade/0.9.16/update.sh b/upgrade/0.9.16/update.sh new file mode 100755 index 0000000..de82fc0 --- /dev/null +++ b/upgrade/0.9.16/update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +. ../inc/pervasive.sh + +mailman_stop +mailman_templates +mailman_start + + +########################################################### +for sql in *.sql +do + echo -n $sql + $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR" + echo . +done + +########################################################### + +echo "we will now upgrade the search table (this may be a long operation) + +please hit ^D to continue +" + +cat + +pushd ../../bin +./search.rebuild_db.php +popd + +########################################################### +