Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

functions_mcp.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 18.19 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  if (!defined('IN_PHPBB'))
018  {
019      exit;
020  }
021   
022  /**
023  * Functions used to generate additional URL paramters
024  */
025  function phpbb_module__url($mode, &$module_row)
026  {
027      return phpbb_extra_url();
028  }
029   
030  function phpbb_module_notes_url($mode, &$module_row)
031  {
032      if ($mode == 'front')
033      {
034          return '';
035      }
036   
037      global $user_id;
038      return ($user_id) ? "&amp;u=$user_id" : '';
039  }
040   
041  function phpbb_module_warn_url($mode, &$module_row)
042  {
043      if ($mode == 'front' || $mode == 'list')
044      {
045          global $forum_id;
046   
047          return ($forum_id) ? "&amp;f=$forum_id" : '';
048      }
049   
050      if ($mode == 'warn_post')
051      {
052          global $forum_id, $post_id;
053   
054          $url_extra = ($forum_id) ? "&amp;f=$forum_id" : '';
055          $url_extra .= ($post_id) ? "&amp;p=$post_id" : '';
056   
057          return $url_extra;
058      }
059      else
060      {
061          global $user_id;
062   
063          return ($user_id) ? "&amp;u=$user_id" : '';
064      }
065  }
066   
067  function phpbb_module_main_url($mode, &$module_row)
068  {
069      return phpbb_extra_url();
070  }
071   
072  function phpbb_module_logs_url($mode, &$module_row)
073  {
074      return phpbb_extra_url();
075  }
076   
077  function phpbb_module_ban_url($mode, &$module_row)
078  {
079      return phpbb_extra_url();
080  }
081   
082  function phpbb_module_queue_url($mode, &$module_row)
083  {
084      return phpbb_extra_url();
085  }
086   
087  function phpbb_module_reports_url($mode, &$module_row)
088  {
089      return phpbb_extra_url();
090  }
091   
092  function phpbb_extra_url()
093  {
094      global $forum_id, $topic_id, $post_id, $report_id, $user_id;
095   
096      $url_extra = '';
097      $url_extra .= ($forum_id) ? "&amp;f=$forum_id" : '';
098      $url_extra .= ($topic_id) ? "&amp;t=$topic_id" : '';
099      $url_extra .= ($post_id) ? "&amp;p=$post_id" : '';
100      $url_extra .= ($user_id) ? "&amp;u=$user_id" : '';
101      $url_extra .= ($report_id) ? "&amp;r=$report_id" : '';
102   
103      return $url_extra;
104  }
105   
106  /**
107  * Get simple topic data
108  */
109  function phpbb_get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
110  {
111      global $auth, $db, $config, $user;
112      static $rowset = array();
113   
114      $topics = array();
115   
116      if (!sizeof($topic_ids))
117      {
118          return array();
119      }
120   
121      // cache might not contain read tracking info, so we can't use it if read
122      // tracking information is requested
123      if (!$read_tracking)
124      {
125          $cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
126          $topic_ids = array_diff($topic_ids, array_keys($rowset));
127      }
128      else
129      {
130          $cache_topic_ids = array();
131      }
132   
133      if (sizeof($topic_ids))
134      {
135          $sql_array = array(
136              'SELECT'    => 't.*, f.*',
137   
138              'FROM'        => array(
139                  TOPICS_TABLE    => 't',
140              ),
141   
142              'LEFT_JOIN'    => array(
143                  array(
144                      'FROM'    => array(FORUMS_TABLE => 'f'),
145                      'ON'    => 'f.forum_id = t.forum_id'
146                  )
147              ),
148   
149              'WHERE'        => $db->sql_in_set('t.topic_id', $topic_ids)
150          );
151   
152          if ($read_tracking && $config['load_db_lastread'])
153          {
154              $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
155   
156              $sql_array['LEFT_JOIN'][] = array(
157                  'FROM'    => array(TOPICS_TRACK_TABLE => 'tt'),
158                  'ON'    => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
159              );
160   
161              $sql_array['LEFT_JOIN'][] = array(
162                  'FROM'    => array(FORUMS_TRACK_TABLE => 'ft'),
163                  'ON'    => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
164              );
165          }
166   
167          $sql = $db->sql_build_query('SELECT', $sql_array);
168          $result = $db->sql_query($sql);
169   
170          while ($row = $db->sql_fetchrow($result))
171          {
172              $rowset[$row['topic_id']] = $row;
173   
174              if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
175              {
176                  continue;
177              }
178   
179              $topics[$row['topic_id']] = $row;
180          }
181          $db->sql_freeresult($result);
182      }
183   
184      foreach ($cache_topic_ids as $id)
185      {
186          if (!$acl_list || $auth->acl_gets($acl_list, $rowset[$id]['forum_id']))
187          {
188              $topics[$id] = $rowset[$id];
189          }
190      }
191   
192      return $topics;
193  }
194   
195  /**
196  * Get simple post data
197  */
198  function phpbb_get_post_data($post_ids, $acl_list = false, $read_tracking = false)
199  {
200      global $db, $auth, $config, $user;
201   
202      $rowset = array();
203   
204      if (!sizeof($post_ids))
205      {
206          return array();
207      }
208   
209      $sql_array = array(
210          'SELECT'    => 'p.*, u.*, t.*, f.*',
211   
212          'FROM'        => array(
213              USERS_TABLE        => 'u',
214              POSTS_TABLE        => 'p',
215              TOPICS_TABLE    => 't',
216          ),
217   
218          'LEFT_JOIN'    => array(
219              array(
220                  'FROM'    => array(FORUMS_TABLE => 'f'),
221                  'ON'    => 'f.forum_id = t.forum_id'
222              )
223          ),
224   
225          'WHERE'        => $db->sql_in_set('p.post_id', $post_ids) . '
226              AND u.user_id = p.poster_id
227              AND t.topic_id = p.topic_id',
228      );
229   
230      if ($read_tracking && $config['load_db_lastread'])
231      {
232          $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
233   
234          $sql_array['LEFT_JOIN'][] = array(
235              'FROM'    => array(TOPICS_TRACK_TABLE => 'tt'),
236              'ON'    => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
237          );
238   
239          $sql_array['LEFT_JOIN'][] = array(
240              'FROM'    => array(FORUMS_TRACK_TABLE => 'ft'),
241              'ON'    => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
242          );
243      }
244   
245      $sql = $db->sql_build_query('SELECT', $sql_array);
246      $result = $db->sql_query($sql);
247      unset($sql_array);
248   
249      while ($row = $db->sql_fetchrow($result))
250      {
251          if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
252          {
253              continue;
254          }
255   
256          if ($row['post_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
257          {
258              // Moderators without the permission to approve post should at least not see them. ;)
259              continue;
260          }
261   
262          $rowset[$row['post_id']] = $row;
263      }
264      $db->sql_freeresult($result);
265   
266      return $rowset;
267  }
268   
269  /**
270  * Get simple forum data
271  */
272  function phpbb_get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
273  {
274      global $auth, $db, $user, $config, $phpbb_container;
275   
276      $rowset = array();
277   
278      if (!is_array($forum_id))
279      {
280          $forum_id = array($forum_id);
281      }
282   
283      if (!sizeof($forum_id))
284      {
285          return array();
286      }
287   
288      if ($read_tracking && $config['load_db_lastread'])
289      {
290          $read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
291              AND ft.forum_id = f.forum_id)';
292          $read_tracking_select = ', ft.mark_time';
293      }
294      else
295      {
296          $read_tracking_join = $read_tracking_select = '';
297      }
298   
299      $sql = "SELECT f.* $read_tracking_select
300          FROM " . FORUMS_TABLE . " f$read_tracking_join
301          WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
302      $result = $db->sql_query($sql);
303   
304      $phpbb_content_visibility = $phpbb_container->get('content.visibility');
305   
306      while ($row = $db->sql_fetchrow($result))
307      {
308          if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
309          {
310              continue;
311          }
312   
313          $row['forum_topics_approved'] = $phpbb_content_visibility->get_count('forum_topics', $row, $row['forum_id']);
314   
315          $rowset[$row['forum_id']] = $row;
316      }
317      $db->sql_freeresult($result);
318   
319      return $rowset;
320  }
321   
322  /**
323  * Get simple pm data
324  */
325  function phpbb_get_pm_data($pm_ids)
326  {
327      global $db;
328   
329      $rowset = array();
330   
331      if (!sizeof($pm_ids))
332      {
333          return array();
334      }
335   
336      $sql_array = array(
337          'SELECT'    => 'p.*, u.*',
338   
339          'FROM'        => array(
340              USERS_TABLE            => 'u',
341              PRIVMSGS_TABLE        => 'p',
342          ),
343   
344          'WHERE'        => $db->sql_in_set('p.msg_id', $pm_ids) . '
345              AND u.user_id = p.author_id',
346      );
347   
348      $sql = $db->sql_build_query('SELECT', $sql_array);
349      $result = $db->sql_query($sql);
350      unset($sql_array);
351   
352      while ($row = $db->sql_fetchrow($result))
353      {
354          $rowset[$row['msg_id']] = $row;
355      }
356      $db->sql_freeresult($result);
357   
358      return $rowset;
359  }
360   
361  /**
362  * sorting in mcp
363  *
364  * @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
365  *
366  * $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
367  * $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
368  */
369  function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
370  {
371      global $db, $user, $auth, $template;
372   
373      $sort_days = request_var('st', 0);
374      $min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
375   
376      switch ($mode)
377      {
378          case 'viewforum':
379              $type = 'topics';
380              $default_key = 't';
381              $default_dir = 'd';
382   
383              $sql = 'SELECT COUNT(topic_id) AS total
384                  FROM ' . TOPICS_TABLE . "
385                  $where_sql forum_id = $forum_id
386                      AND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
387                      AND topic_last_post_time >= $min_time";
388   
389              if (!$auth->acl_get('m_approve', $forum_id))
390              {
391                  $sql .= 'AND topic_visibility = ' . ITEM_APPROVED;
392              }
393              break;
394   
395          case 'viewtopic':
396              $type = 'posts';
397              $default_key = 't';
398              $default_dir = 'a';
399   
400              $sql = 'SELECT COUNT(post_id) AS total
401                  FROM ' . POSTS_TABLE . "
402                  $where_sql topic_id = $topic_id
403                      AND post_time >= $min_time";
404   
405              if (!$auth->acl_get('m_approve', $forum_id))
406              {
407                  $sql .= 'AND post_visibility = ' . ITEM_APPROVED;
408              }
409              break;
410   
411          case 'unapproved_posts':
412          case 'deleted_posts':
413              $visibility_const = ($mode == 'unapproved_posts') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
414              $type = 'posts';
415              $default_key = 't';
416              $default_dir = 'd';
417              $where_sql .= ($topic_id) ? ' p.topic_id = ' . $topic_id . ' AND' : '';
418   
419              $sql = 'SELECT COUNT(p.post_id) AS total
420                  FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
421                  $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
422                      AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) .'
423                      AND t.topic_id = p.topic_id
424                      AND t.topic_visibility <> p.post_visibility';
425   
426              if ($min_time)
427              {
428                  $sql .= ' AND post_time >= ' . $min_time;
429              }
430              break;
431   
432          case 'unapproved_topics':
433          case 'deleted_topics':
434              $visibility_const = ($mode == 'unapproved_topics') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
435              $type = 'topics';
436              $default_key = 't';
437              $default_dir = 'd';
438   
439              $sql = 'SELECT COUNT(topic_id) AS total
440                  FROM ' . TOPICS_TABLE . "
441                  $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
442                      AND ' . $db->sql_in_set('topic_visibility', $visibility_const);
443   
444              if ($min_time)
445              {
446                  $sql .= ' AND topic_time >= ' . $min_time;
447              }
448              break;
449   
450          case 'pm_reports':
451          case 'pm_reports_closed':
452          case 'reports':
453          case 'reports_closed':
454              $pm = (strpos($mode, 'pm_') === 0) ? true : false;
455   
456              $type = ($pm) ? 'pm_reports' : 'reports';
457              $default_key = 't';
458              $default_dir = 'd';
459              $limit_time_sql = ($min_time) ? "AND r.report_time >= $min_time" : '';
460   
461              if ($topic_id)
462              {
463                  $where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
464              }
465              else if ($forum_id)
466              {
467                  $where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
468              }
469              else if (!$pm)
470              {
471                  $where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
472              }
473   
474              if ($mode == 'reports' || $mode == 'pm_reports')
475              {
476                  $where_sql .= ' r.report_closed = 0 AND ';
477              }
478              else
479              {
480                  $where_sql .= ' r.report_closed = 1 AND ';
481              }
482   
483              if ($pm)
484              {
485                  $sql = 'SELECT COUNT(r.report_id) AS total
486                      FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p
487                      $where_sql r.post_id = 0
488                          AND p.msg_id = r.pm_id
489                          $limit_time_sql";
490              }
491              else
492              {
493                  $sql = 'SELECT COUNT(r.report_id) AS total
494                      FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p
495                      $where_sql r.pm_id = 0
496                          AND p.post_id = r.post_id
497                          $limit_time_sql";
498              }
499              break;
500   
501          case 'viewlogs':
502              $type = 'logs';
503              $default_key = 't';
504              $default_dir = 'd';
505   
506              $sql = 'SELECT COUNT(log_id) AS total
507                  FROM ' . LOG_TABLE . "
508                  $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
509                      AND log_time >= ' . $min_time . '
510                      AND log_type = ' . LOG_MOD;
511              break;
512      }
513   
514      $sort_key = request_var('sk', $default_key);
515      $sort_dir = request_var('sd', $default_dir);
516      $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
517   
518      switch ($type)
519      {
520          case 'topics':
521              $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
522              $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
523   
524              $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views');
525              $limit_time_sql = ($min_time) ? "AND t.topic_last_post_time >= $min_time" : '';
526              break;
527   
528          case 'posts':
529              $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
530              $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
531              $sort_by_sql = array('a' => 'u.username_clean', 't' => array('p.post_time', 'p.post_id'), 's' => 'p.post_subject');
532              $limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
533              break;
534   
535          case 'reports':
536              $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
537              $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
538              $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => array('p.post_time', 'p.post_id'), 't' => 'r.report_time', 's' => 'p.post_subject');
539              break;
540   
541          case 'pm_reports':
542              $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
543              $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
544              $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
545              break;
546   
547          case 'logs':
548              $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
549              $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
550   
551              $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
552              $limit_time_sql = ($min_time) ? "AND l.log_time >= $min_time" : '';
553              break;
554      }
555   
556      if (!isset($sort_by_sql[$sort_key]))
557      {
558          $sort_key = $default_key;
559      }
560   
561      $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC';
562   
563      if (is_array($sort_by_sql[$sort_key]))
564      {
565          $sort_order_sql = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
566      }
567      else
568      {
569          $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . $direction;
570      }
571   
572      $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
573      gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
574   
575      $template->assign_vars(array(
576              'S_SELECT_SORT_DIR'        => $s_sort_dir,
577              'S_SELECT_SORT_KEY'        => $s_sort_key,
578              'S_SELECT_SORT_DAYS'    => $s_limit_days)
579      );
580   
581      if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_topics', 'deleted_posts')) || $where_sql != 'WHERE')
582      {
583          $result = $db->sql_query($sql);
584          $total = (int) $db->sql_fetchfield('total');
585          $db->sql_freeresult($result);
586      }
587      else
588      {
589          $total = -1;
590      }
591  }
592   
593  /**
594  * Validate ids
595  *
596  * @param    array    &$ids            The relevant ids to check
597  * @param    string    $table            The table to find the ids in
598  * @param    string    $sql_id            The ids relevant column name
599  * @param    array    $acl_list        A list of permissions the user need to have
600  * @param    mixed    $singe_forum    Limit to one forum id (int) or the first forum found (true)
601  *
602  * @return    mixed    False if no ids were able to be retrieved, true if at least one id left.
603  *                    Additionally, this value can be the forum_id assigned if $single_forum was set.
604  *                    Therefore checking the result for with !== false is the best method.
605  */
606  function phpbb_check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false)
607  {
608      global $db, $auth;
609   
610      if (!is_array($ids) || empty($ids))
611      {
612          return false;
613      }
614   
615      $sql = "SELECT $sql_id, forum_id FROM $table
616          WHERE " . $db->sql_in_set($sql_id, $ids);
617      $result = $db->sql_query($sql);
618   
619      $ids = array();
620      $forum_id = false;
621   
622      while ($row = $db->sql_fetchrow($result))
623      {
624          if ($acl_list && $row['forum_id'] && !$auth->acl_gets($acl_list, $row['forum_id']))
625          {
626              continue;
627          }
628   
629          if ($acl_list && !$row['forum_id'] && !$auth->acl_getf_global($acl_list))
630          {
631              continue;
632          }
633   
634          // Limit forum? If not, just assign the id.
635          if ($single_forum === false)
636          {
637              $ids[] = $row[$sql_id];
638              continue;
639          }
640   
641          // Limit forum to a specific forum id?
642          // This can get really tricky, because we do not want to create a failure on global topics. :)
643          if ($row['forum_id'])
644          {
645              if ($single_forum !== true && $row['forum_id'] == (int) $single_forum)
646              {
647                  $forum_id = (int) $single_forum;
648              }
649              else if ($forum_id === false)
650              {
651                  $forum_id = $row['forum_id'];
652              }
653   
654              if ($row['forum_id'] == $forum_id)
655              {
656                  $ids[] = $row[$sql_id];
657              }
658          }
659          else
660          {
661              // Always add a global topic
662              $ids[] = $row[$sql_id];
663          }
664      }
665      $db->sql_freeresult($result);
666   
667      if (!sizeof($ids))
668      {
669          return false;
670      }
671   
672      // If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id)
673   
674      return ($single_forum === false) ? true : (int) $forum_id;
675  }
676