<?php

/**
 * Roundcube plugin to bring back the logo to inbox link
 */
class logo_mod extends rcube_plugin
{

	/**
	 * Initialization method of the plugin.
	 * 
	 * Register all hooks and scripts
	 */
	public function init()
	{
		/* Add a link to the inbox on logo */
		$this->add_hook('template_object_logo', array($this, 'addLogoLink2Inbox'));
	}

	/**
	 * Add a link to the logo to go back to the inbox
	 * 
	 * @param array $args Array of arguments from the template render hook
	 * @return array Modified logo image tag with a anchor to the inbox
	 */
	public function addLogoLink2Inbox($args)
	{
		$rcmail = rcmail::get_instance();
		if (!($rcmail->output instanceof rcube_template)) {
			return $args;
		}

		/* @var $output rcube_template */
		$output = $rcmail->output;
		$buttonArgs = array(
			'command' => 'mail',
			'type' => 'image',
			'image' => $args['src'],
			'alt' => $args['alt'],
			'border' => $args['border'],
			'id' => $args['id'],
			'name' => $args['name'],
		);
		$args['content'] = $output->button($buttonArgs);
		return $args;
	}

}