Table editor fills the new entry form with the default values of the fields
[platal.git] / modules / banana / banana.inc.php
index f897c40..1442220 100644 (file)
@@ -27,7 +27,7 @@ function hook_formatDisplayHeader($_header, $_text) {
         $id = $banana->post->headers['x-org-id'];
         $_text = formatFrom($_text);
         return $_text . ' <a href="profile/' . $id . '" class="popup2" title="' . $id . '">'
-             . '<img src="images/loupe.gif" alt="fiche" title="fiche" /></a>';
+             . '<img src="images/icons/user_suit.gif" title="fiche" alt="" /></a>';
     }
 }
 
@@ -37,13 +37,29 @@ function hook_checkcancel($_headers) {
 
 function hook_shortcuts()
 {
-    return Array('profile' => array('<a href="banana/profile">Préférences</a>',
+    return array('profile' => array('<a href="banana/profile">Préférences</a>',
                                     'Préférences'));
 }
 
+function hook_browsingAction()
+{
+    global $platal, $banana;
+    $page = $banana->state['page'];
+    if ((@$page != 'message' && @$page != 'group' && @$page != 'forums') 
+        || $banana->profile['autoup']) {
+        return null;
+    }
+    return '<p class="center" style="padding: 0; margin: 0 0 1em 0">'
+         . '<a href=\'javascript:dynpostkv("' . $platal->path . '", "updateall", ' . time() . ')\'>'
+         . 'Marquer tous les messages comme lus'
+         . '</a>'
+         . '</p>';
+}
+
 function hook_makeLink($params) {
-    $base = 'banana';
-    if ($params['subscribe'] == 1) {
+    global $globals;
+    $base = $globals->baseurl . '/banana';
+    if (@$params['subscribe'] == 1) {
         return $base . '/subscription';
     }
     if (isset($params['xface'])) {
@@ -59,9 +75,9 @@ function hook_makeLink($params) {
         return $base . '/from/' . $params['first'];
     }
     if (isset($params['artid'])) {
-        if ($params['action'] == 'new') {
+        if (@$params['action'] == 'new') {
             $base .= '/reply';
-        } elseif ($params['action'] == 'cancel') {
+        } elseif (@$params['action'] == 'cancel') {
             $base .= '/cancel';
         } else {
             $base .= '/read';
@@ -69,7 +85,7 @@ function hook_makeLink($params) {
         return $base . '/' . $params['artid'];
     }
 
-    if ($params['action'] == 'new') {
+    if (@$params['action'] == 'new') {
         return $base . '/new';
     }
     return $base;
@@ -95,9 +111,9 @@ function hook_getSubject(&$subject)
         $subject = $matches[1];
         global $banana;
         if ($banana->state['group'] == $matches[2]) {
-            return ' [=> ' . $matches[2] . ']';
+            return ' [=>&nbsp;' . $matches[2] . ']';
         } else {
-            return ' [=> ' . makeHREF(Array('group' => $matches[2]), $matches[2]) . ']';
+            return ' [=>&nbsp;' . makeHREF(array('group' => $matches[2]), $matches[2]) . ']';
         }
     }
     return null;
@@ -105,8 +121,10 @@ function hook_getSubject(&$subject)
 
 class PlatalBanana extends Banana
 {
-    var $profile    = Array( 'name' => '', 'sig'  => '', 'org'  => 'Utilisateur de Polytechnique.org',
-            'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale'  => 'fr_FR', 'subscribe' => array());
+    var $profile    = array('name' => '', 'sig'  => '',
+                            'org'  => 'Utilisateur de Polytechnique.org',
+                            'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 
+                            'locale'  => 'fr_FR', 'subscribe' => array());
     var $can_attach = false;
 
     function PlatalBanana()
@@ -133,7 +151,8 @@ class PlatalBanana extends Banana
         $this->profile['lastnews']  = S::v('banana_last');
 
         if ($maj) {
-            XDB::execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
+            XDB::execute("UPDATE auth_user_quick SET banana_last=FROM_UNIXTIME({?}) WHERE user_id={?}",
+                         time(), $uid);
         }
 
         $req = XDB::query("
@@ -156,10 +175,14 @@ class PlatalBanana extends Banana
     {
         global $banana;
 
-        if (Get::v('banana') == 'updateall'
-                || (!is_null($params) && isset($params['banana']) && $params['banana'] == 'updateall')) {
-            XDB::execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), S::v('uid'));
-            $_SESSION['banana_last'] = time();
+        $time = null;
+        if (!is_null($params) && isset($params['updateall'])) {
+            $time = (int)$params['updateall'];
+        }
+        if (!is_null($time)) {
+            XDB::execute('UPDATE auth_user_quick SET banana_last=FROM_UNIXTIME({?}) WHERE user_id={?}',
+                         $time, S::v('uid'));
+            $_SESSION['banana_last'] = $time;
         }
         return Banana::run('PlatalBanana', $params);
     }
@@ -169,7 +192,7 @@ class PlatalBanana extends Banana
         global $globals;
         $uid = S::v('uid');
 
-        $this->profile['subscribe'] = Array();
+        $this->profile['subscribe'] = array();
         XDB::execute("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid={?}", $uid);
         if (!count($_POST['subscribe'])) {
             return true;
@@ -184,11 +207,12 @@ class PlatalBanana extends Banana
         $diff = array_diff($_POST['subscribe'], array_keys($fids));
         foreach ($diff as $g) {
             XDB::execute("INSERT INTO {$globals->banana->table_prefix}list (nom) VALUES ({?})", $g);
-            $fids[$g] = mysql_insert_id();
+            $fids[$g] = XDB::insertId();
         }
 
         foreach ($_POST['subscribe'] as $g) {
-            XDB::execute("INSERT INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES ({?},{?})", $fids[$g], $uid);
+            XDB::execute("INSERT INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES ({?},{?})",
+                         $fids[$g], $uid);
             $this->profile['subscribe'][] = $g;
         }
     }