bebeboutik/modules/categoryfamily/categoryfamily.php
Marion Muszynski f01129f45d fix require
2016-12-28 14:22:31 +01:00

52 lines
1.3 KiB
PHP
Executable File

<?php
require_once dirname(__FILE__).'/models/CategoryFamily.php';
class CategoryFamily extends Module {
public function __construct() {
$this->name = 'categoryfamily';
$this->tab = 'administration';
$this->author = 'Antadis';
$this->version = '1.0';
parent::__construct();
$this->displayName = $this->l('Category Family');
$this->description = $this->l('Associate Family to Category');
}
public function install() {
if(!parent::install() OR
!$this->registerHook('categoryAddition') OR
!$this->registerHook('categoryDeletion') OR
!$this->registerHook('categoryUpdate')) {
return FALSE;
}
return TRUE;
}
public function hookcategoryAddition($params) {
self::setAssociations($params['category'], Tools::getValue('family'));
}
public function hookcategoryDeletion($params) {
CategoryFamilyCore::deleteAssociations($params['category']->id);
}
public function hookcategoryUpdate($params) {
self::setAssociations($params['category'], Tools::getValue('family'));
}
public static function setAssociations($category, $family) {
if (!Validate::isLoadedObject($category)) {
return FALSE;
}
$family = Tools::getValue('family');
if (!empty($family)) {
CategoryFamilyCore::addAssociations($category->id, $family);
}
}
}