diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_icons.php | 55 | 
1 files changed, 48 insertions, 7 deletions
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 291f846999..fa1e324cc6 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -231,7 +231,7 @@ class acp_icons  					$data = $_images;  				} -				$colspan = (($mode == 'smilies') ? '7' : '5'); +				$colspan = (($mode == 'smilies') ? 7 : 5);  				$colspan += ($icon_id) ? 1 : 0;  				$colspan += ($action == 'add') ? 2 : 0; @@ -348,6 +348,25 @@ class acp_icons  					}  				} +				if ($mode == 'smilies' && $action == 'create') +				{ +					$smiley_count = $this->item_count($table); +					 +					$addable_smileys_count = sizeof($images); +					foreach ($images as $image) +					{ +						if (!isset($image_add[$image])) +						{ +							--$addable_smileys_count; +						} +					} +					 +					if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) +					{ +						trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); +					} +				} +  				$icons_updated = 0;  				$errors = array();  				foreach ($images as $image) @@ -495,7 +514,6 @@ class acp_icons  						}  					} -  					// The user has already selected a smilies_pak file  					if ($current == 'delete')  					{ @@ -541,6 +559,15 @@ class acp_icons  						$db->sql_freeresult($result);  					} +					if ($mode == 'smilies') +					{ +						$smiley_count = $this->item_count($table); +						if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) +						{ +							trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); +						} +					} +  					foreach ($pak_ary as $pak_entry)  					{  						$data = array(); @@ -837,11 +864,7 @@ class acp_icons  		$spacer = false;  		$pagination_start = request_var('start', 0); -		$sql = "SELECT COUNT(*) AS count -			FROM $table"; -		$result = $db->sql_query($sql); -		$item_count = (int) $db->sql_fetchfield('count'); -		$db->sql_freeresult($result); +		$item_count = $this->item_count($table);  		$sql = "SELECT *  			FROM $table @@ -877,6 +900,24 @@ class acp_icons  			generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)  		);  	} +	 +	/** +	 * Returns the count of smilies or icons in the database +	 * +	 * @param string $table The table of items to count. +	 * @return int number of items +	 */ +	/* private */ function item_count($table) +	{ +		global $db; + +		$sql = "SELECT COUNT(*) AS count +			FROM $table"; +		$result = $db->sql_query($sql); +		$item_count = (int) $db->sql_fetchfield('count'); +		$db->sql_freeresult($result); +		return $item_count; +	}  }  ?>
\ No newline at end of file  | 
