aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migration/data/v310/notifications.php
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2014-04-13 21:15:14 +0200
committerOliver Schramm <oliver.schramm97@gmail.com>2014-04-13 21:15:14 +0200
commitface175471b5064117ca57ece53a3403e51e20ba (patch)
treea0954756c4e4c1d56f96e9a0cb3ee52e5ae5a4ce /phpBB/phpbb/db/migration/data/v310/notifications.php
parent02378e94e779bbd407ef86166884c00e32d152fc (diff)
downloadforums-face175471b5064117ca57ece53a3403e51e20ba.tar
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.gz
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.bz2
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.xz
forums-face175471b5064117ca57ece53a3403e51e20ba.zip
[ticket/10423] Move code into a function and add tests for it
PHPBB3-10423
Diffstat (limited to 'phpBB/phpbb/db/migration/data/v310/notifications.php')
0 files changed, 0 insertions, 0 deletions
#n140'>140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
<?php
/**
*
* @package avatar
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* Handles avatars selected from the board gallery
* @package avatars
*/
class phpbb_avatar_driver_local extends phpbb_avatar_driver
{
	/**
	* @inheritdoc
	*/
	public function get_data($row, $ignore_config = false)
	{
		if ($ignore_config || $this->config['allow_avatar_local'])
		{
			return array(
				'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
				'width' => $row['avatar_width'],
				'height' => $row['avatar_height'],
			);
		}
		else
		{
			return array(
				'src' => '',
				'width' => 0,
				'height' => 0,
			);
		}
	}
	
	/**
	* @inheritdoc
	*/
	public function prepare_form($template, $row, &$error)
	{
		$avatar_list = $this->get_avatar_list();
		$category = $this->request->variable('av_local_cat', '');

		$categories = array_keys($avatar_list);

		foreach ($categories as $cat)
		{
			if (!empty($avatar_list[$cat]))
			{
				$template->assign_block_vars('av_local_cats', array(
					'NAME' => $cat,
					'SELECTED' => ($cat == $category),
				));
			}
		}

		if (!empty($avatar_list[$category]))
		{
			$template->assign_vars(array(
				'AV_LOCAL_SHOW' => true,
			));

			$table_cols = isset($row['av_gallery_cols']) ? $row['av_gallery_cols'] : 4;
			$row_count = $col_count = $av_pos = 0;
			$av_count = sizeof($avatar_list[$category]);

			reset($avatar_list[$category]);

			while ($av_pos < $av_count)
			{
				$img = current($avatar_list[$category]);
				next($avatar_list[$category]);

				if ($col_count == 0)
				{
					++$row_count;
					$template->assign_block_vars('av_local_row', array(
					));
				}

				$template->assign_block_vars('av_local_row.av_local_col', array(
					'AVATAR_IMAGE'  => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'],
					'AVATAR_NAME' => $img['name'],
					'AVATAR_FILE' => $img['filename'],
				));

				$col_count = ($col_count + 1) % $table_cols;

				++$av_pos;
			}
		}

		return true;
	}
	
	/**
	* @inheritdoc
	*/
	public function process_form($template, $row, &$error)
	{
		$avatar_list = $this->get_avatar_list();
		$category = $this->request->variable('av_local_cat', '');

		$file = $this->request->variable('av_local_file', '');
		if (!isset($avatar_list[$category][urldecode($file)]))
		{
			$error[] = 'AVATAR_URL_NOT_FOUND';
			return false;
		}

		return array(
			'avatar' => $category . '/' . $file,
			'avatar_width' => $avatar_list[$category][urldecode($file)]['width'],
			'avatar_height' => $avatar_list[$category][urldecode($file)]['height'],
		);
	}

	/**
	* @TODO
	*/
	private function get_avatar_list()
	{
		$avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list');

		if (!$avatar_list)
		{
			$avatar_list = array();
			$path = $this->phpbb_root_path . $this->config['avatar_gallery_path'];

			$dh = @opendir($path);

			if ($dh)
			{