name = 'blockwishlist';
$this->tab = 'Blocks';
$this->version = 0.2;
parent::__construct();
$this->displayName = $this->l('Wishlist block');
$this->description = $this->l('Adds a block containing the customer\'s wishlists');
}
public function install()
{
if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE))
return (false);
else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE))
return (false);
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$sql = preg_split("/;\s*[\r\n]+/", $sql);
foreach ($sql AS $query)
if($query)
if(!Db::getInstance()->Execute(trim($query)))
return false;
if (!parent::install() OR
!$this->registerHook('rightColumn') OR
!$this->registerHook('productActions') OR
!$this->registerHook('cart') OR
!$this->registerHook('customerAccount') OR
!$this->registerHook('header') OR
!$this->registerHook('adminCustomers') OR
!Configuration::updateValue('PS_BLOCK_WISHLIST_ACTIVATED', 1)
)
return false;
/* This hook is optional */
$this->registerHook('myAccountBlock');
return true;
}
public function uninstall()
{
return (Configuration::deleteByName('PS_BLOCK_WISHLIST_ACTIVATED') AND
Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'wishlist') AND
Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'wishlist_email') AND
Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'wishlist_product') AND
Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'wishlist_product_cart') AND
parent::uninstall());
}
public function getContent()
{
$this->_html = '
'.$this->displayName.'
';
if (Tools::isSubmit('submitSettings'))
{
$activated = Tools::getValue('activated');
if ($activated != 0 AND $activated != 1)
$this->_html .= '
';
}
public function hookAdminCustomers($params)
{
require_once(dirname(__FILE__).'/WishList.php');
$customer = new Customer(intval($params['id_customer']));
if (!Validate::isLoadedObject($customer))
die (Tools::displayError());
$this->_html = '
'.$this->l('Wishlists').'
';
$wishlists = WishList::getByIdCustomer(intval($customer->id));
if (!sizeof($wishlists))
$this->_html .= $customer->lastname.' '.$customer->firstname.' '.$this->l('had no wishlist');
else
{
$this->_html .= ' ';
return $this->_html;
}
}
/*
* Display Error from controler
*/
public function errorLogged()
{
return $this->l('You need to be logged to manage your wishlist');
}
}
?>