* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\feed;
/**
* Abstract class for feeds displaying attachments
*/
abstract class attachments_base extends base
{
/**
* Attachments that may be displayed
*/
protected $attachments = array();
/**
* Retrieve the list of attachments that may be displayed
*
* @param array $post_ids Specify for which post IDs to fetch the attachments (optional)
* @param array $topic_ids Specify for which topic IDs to fetch the attachments (optional)
*/
protected function fetch_attachments($post_ids = array(), $topic_ids = array())
{
$sql_array = array(
'SELECT' => 'a.*',
'FROM' => array(
ATTACHMENTS_TABLE => 'a'
),
'WHERE' => 'a.in_message = 0 ',
'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC',
);
if (!empty($post_ids))
{
$sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.post_msg_id', $post_ids);
}
else if (!empty($topic_ids))
{
if (isset($this->topic_id))
{
$topic_ids[] = $this->topic_id;
}
$sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.topic_id', $topic_ids);
}
else if (isset($this->topic_id))
{
$sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id;
}
else if (isset($this->forum_id))
{
$sql_array['LEFT_JOIN'] = array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'a.topic_id = t.topic_id',
)
);
$sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id;
}
else
{
// Do not allow querying the full attachments table
throw new \RuntimeException($this->user->lang('INVALID_FEED_ATTACHMENTS'));
}
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
// Set attachments in feed items
while ($row = $this->db->sql_fetchrow($result))
{
$this->attachments[$row['post_msg_id']][] = $row;
}
$this->db->sql_freeresult($result);
}
/**
* Get attachments related to a given post
*
* @param $post_id int Post id
* @return mixed Attachments related to $post_id
*/
public function get_attachments($post_id)
{
return $this->attachments[$post_id];
}
}
h'>topic/MDK92-branch
Mageia Installer and base platform for many utilities
#!/usr/bin/perl
# Copyright (C) 1999-2004 MandrakeSoft (pixel@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use interactive;
use network::drakfirewall;
my $in = 'interactive'->vnew('su');
network::drakfirewall::main($in, undef);
$in->exit;