plugins/Newsboy.php
changeset 21 af40ef1982dd
parent 19 93c01ea4366b
child 22 7f0d9fa561f4
equal deleted inserted replaced
19:93c01ea4366b 21:af40ef1982dd
   315            ON ( u.username=l.author )
   315            ON ( u.username=l.author )
   316          LEFT JOIN '.table_prefix.'page_text AS t
   316          LEFT JOIN '.table_prefix.'page_text AS t
   317            ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   317            ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   318          WHERE p.namespace=\'NewsBoy\'
   318          WHERE p.namespace=\'NewsBoy\'
   319            AND l.action=\'create\'
   319            AND l.action=\'create\'
   320            AND p.urlname REGEXP \'^([0-9]+)$\'
   320            AND p.urlname '.(ENANO_DBLAYER == 'MYSQL'?'REGEXP':'~').' \'^([0-9]+)$\'
   321            AND p.visible=1
   321            AND p.visible=1
   322          GROUP BY p.urlname
   322          GROUP BY p.urlname, p.page_order, p.name, p.namespace, p.special, p.visible, p.comments_on, p.page_format, p.protected,
       
   323            p.wiki_mode, p.delvotes, p.password, p.delvote_ips, l.time_id, l.author, u.user_level, t.page_text
   323          ORDER BY urlname DESC
   324          ORDER BY urlname DESC
   324          LIMIT '.$limit.';';
   325          LIMIT '.$limit.';';
   325   
   326   
   326   $q = $db->sql_unbuffered_query($sql);
   327   $q = $db->sql_unbuffered_query($sql);
   327   
   328   
   447          LEFT JOIN '.table_prefix.'page_text AS t
   448          LEFT JOIN '.table_prefix.'page_text AS t
   448            ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   449            ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   449          LEFT JOIN '.table_prefix.'logs AS l
   450          LEFT JOIN '.table_prefix.'logs AS l
   450            ON ( l.page_id=p.urlname AND l.namespace=p.namespace )
   451            ON ( l.page_id=p.urlname AND l.namespace=p.namespace )
   451          LEFT JOIN '.table_prefix.'users AS u
   452          LEFT JOIN '.table_prefix.'users AS u
   452            ON ( u.username=l.author OR u.user_id=1 )
   453            ON ( u.username=l.author )
   453          WHERE p.namespace=\'NewsBoy\'
   454          WHERE p.namespace=\'NewsBoy\'
   454            AND l.action=\'create\'
   455            AND l.action=\'create\'
   455            AND p.urlname!=\'Announce\'
   456            AND p.urlname!=\'Announce\'
   456            AND p.visible=1
   457            AND p.visible=1
   457          GROUP BY p.urlname
   458          GROUP BY p.urlname, p.page_order, p.name, p.namespace, p.special, p.visible, p.comments_on, p.page_format, p.protected,
   458          ORDER BY urlname DESC
   459            p.wiki_mode, p.delvotes, p.password, p.delvote_ips, t.page_text, l.time_id, l.author, u.user_level
       
   460          ORDER BY p.urlname DESC
   459          LIMIT ' . ($num_articles + 1) . ';');
   461          LIMIT ' . ($num_articles + 1) . ';');
   460   if ( !$q )
   462   if ( !$q )
   461     $db->_die();
   463     $db->_die();
   462   
   464   
   463   if ( $row = $db->fetchrow($q) )
   465   if ( $row = $db->fetchrow($q) )
   582   $entries_per_page = 50;
   584   $entries_per_page = 50;
   583   
   585   
   584   $row_count = $entries_per_page + 1;
   586   $row_count = $entries_per_page + 1;
   585   
   587   
   586   // Determine number of total news entries
   588   // Determine number of total news entries
   587   $q = $db->sql_query('SELECT urlname FROM '.table_prefix.'pages WHERE namespace=\'NewsBoy\' AND urlname REGEXP \'^([0-9]+)$\' AND visible=1;');
   589   $q = $db->sql_query('SELECT urlname FROM '.table_prefix.'pages WHERE namespace=\'NewsBoy\' AND urlname '.(ENANO_DBLAYER == 'MYSQL'?'REGEXP':'~').' \'^([0-9]+)$\' AND visible=1;');
   588   if ( !$q )
   590   if ( !$q )
   589     $db->_die();
   591     $db->_die();
   590   $r = $db->fetchrow();
   592   $r = $db->fetchrow();
   591   $num_total = intval($db->numrows());
   593   $num_total = intval($db->numrows());
   592   $db->free_result();
   594   $db->free_result();
   601            ON ( l.page_id=p.urlname AND l.namespace=p.namespace )
   603            ON ( l.page_id=p.urlname AND l.namespace=p.namespace )
   602          LEFT JOIN '.table_prefix.'users AS u
   604          LEFT JOIN '.table_prefix.'users AS u
   603            ON ( u.username=l.author )
   605            ON ( u.username=l.author )
   604          WHERE p.namespace=\'NewsBoy\'
   606          WHERE p.namespace=\'NewsBoy\'
   605            AND l.action=\'create\'
   607            AND l.action=\'create\'
   606            AND p.urlname REGEXP \'^([0-9]+)$\'
   608            AND p.urlname '.(ENANO_DBLAYER == 'MYSQL'?'REGEXP':'~').' \'^([0-9]+)$\'
   607            AND p.visible=1
   609            AND p.visible=1
   608          GROUP BY p.urlname
   610          GROUP BY p.urlname, p.page_order, p.name, p.namespace, p.special, p.visible, p.comments_on, p.page_format, p.protected,
       
   611            p.wiki_mode, p.delvotes, p.password, p.delvote_ips, l.time_id, l.author, u.user_level
   609          ORDER BY urlname DESC;';
   612          ORDER BY urlname DESC;';
   610   
   613   
   611   $q = $db->sql_unbuffered_query($sql);
   614   $q = $db->sql_unbuffered_query($sql);
   612   
   615   
   613   if ( !$q )
   616   if ( !$q )
  1076         </tr>';
  1079         </tr>';
  1077         
  1080         
  1078     $row_class = 'row2';
  1081     $row_class = 'row2';
  1079     
  1082     
  1080     // List existing news entries
  1083     // List existing news entries
  1081     $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace="NewsBoy" AND urlname!="Announce" ORDER BY name ASC;');
  1084     $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'NewsBoy\' AND urlname!=\'Announce\' ORDER BY name ASC;');
  1082     
  1085     
  1083     if ( !$q )
  1086     if ( !$q )
  1084       $db->_die();
  1087       $db->_die();
  1085     
  1088     
  1086     if ( $row = $db->fetchrow($q) )
  1089     if ( $row = $db->fetchrow($q) )