User::canEdit takes user permissions into account.
[platal.git] / modules / xnetevents.php
index 972bd4b..9db873e 100644 (file)
@@ -394,12 +394,12 @@ class XnetEventsModule extends PLModule
             );
 
             $trivial = array('intitule', 'descriptif', 'noinvite',
-                             'show_participants', 'accept_nonmembre', 'organisateur_uid');
+                             'show_participants', 'accept_nonmembre', 'uid');
             foreach ($trivial as $k) {
                 $evt[$k] = Post::v($k);
             }
             if (!$eid) {
-                $evt['organisateur_uid'] = S::v('uid');
+                $evt['uid'] = S::v('uid');
             }
 
             if (Post::v('deadline')) {
@@ -411,17 +411,17 @@ class XnetEventsModule extends PLModule
             }
 
             // Store the modifications in the database
-            XDB::execute('REPLACE INTO group_events
-                SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
-                    paiement_id = {?}, descriptif = {?}, debut = {?},
-                    fin = {?}, show_participants = {?}, short_name = {?},
-                    deadline_inscription = {?}, noinvite = {?},
-                    accept_nonmembre = {?}',
-                    $evt['eid'], $evt['asso_id'], $evt['organisateur_uid'],
-                    $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
-                    $evt['debut'], $evt['fin'], $evt['show_participants'],
-                    $evt['short_name'], $evt['deadline_inscription'],
-                    $evt['noinvite'], $evt['accept_nonmembre']);
+            XDB::execute('REPLACE INTO  group_events
+                                   SET  eid = {?}, asso_id = {?}, uid = {?}, intitule = {?},
+                                        paiement_id = {?}, descriptif = {?}, debut = {?},
+                                        fin = {?}, show_participants = {?}, short_name = {?},
+                                        deadline_inscription = {?}, noinvite = {?},
+                                        accept_nonmembre = {?}',
+                         $evt['eid'], $evt['asso_id'], $evt['uid'],
+                         $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
+                         $evt['debut'], $evt['fin'], $evt['show_participants'],
+                         $evt['short_name'], $evt['deadline_inscription'],
+                         $evt['noinvite'], $evt['accept_nonmembre']);
 
             // if new event, get its id
             if (!$eid) {
@@ -487,7 +487,7 @@ class XnetEventsModule extends PLModule
         // when modifying an old event retreive the old datas
         if ($eid) {
             $res = XDB::query(
-                    "SELECT  eid, intitule, descriptif, debut, fin, organisateur_uid,
+                    "SELECT  eid, intitule, descriptif, debut, fin, uid,
                              show_participants, paiement_id, short_name,
                              deadline_inscription, noinvite, accept_nonmembre
                        FROM  group_events
@@ -621,9 +621,9 @@ class XnetEventsModule extends PLModule
                                               WHERE  p.eid = {?} AND p2.eid IS NULL
                                            GROUP BY  p.uid', $evt['eid']);
 
-        $ofs   = Env::i('offset');
-        $tot   = (Env::v('initiale') ? $tot : $nb_tot);
-        $nbp   = ceil($tot / NB_PER_PAGE);
+        $ofs = Env::i('offset');
+        $tot = (is_null($evt['nb_tot']) ? $evt['nb'] : $evt['nb_tot']);
+        $nbp = ceil($tot / NB_PER_PAGE);
         if ($nbp > 1) {
             $links = array();
             if ($ofs) {
@@ -632,7 +632,7 @@ class XnetEventsModule extends PLModule
             for ($i = 1 ; $i <= $nbp; $i++) {
                 $links[(string)$i] = $i - 1;
             }
-            if ($ofs < $nbp) {
+            if ($ofs < $nbp - 1) {
                 $links['suivant'] = $ofs+1;
             }
             $page->assign('links', $links);
@@ -641,7 +641,7 @@ class XnetEventsModule extends PLModule
         $page->assign('absents', $absents);
         $page->assign('participants',
                       get_event_participants($evt, $item_id, UserFilter::sortByName(),
-                                             new PLLimit(NB_PER_PAGE), $ofs * NB_PER_PAGE));
+                                             NB_PER_PAGE, $ofs * NB_PER_PAGE));
     }
 }