* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6844 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class ContactCore extends ObjectModel { public $id; /** @var string Name */ public $name; /** @var string e-mail */ public $email; /** @var string Detailed description */ public $description; public $customer_service; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'contact', 'primary' => 'id_contact', 'multilang' => true, 'fields' => array( 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'size' => 128), 'customer_service' => array('type' => 'FILL_ME', 'validate' => 'isBool'), 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), ), ); public function getFields() { $this->validateFields(); $fields['email'] = pSQL($this->email); $fields['customer_service'] = (int)$this->customer_service; return $fields; } /** * Check then return multilingual fields for database interaction * * @return array Multilingual fields */ public function getTranslationsFieldsChild() { $this->validateFieldsLang(); return $this->getTranslationsFields(array('name', 'description')); } /** * Return available contacts * * @param integer $id_lang Language ID * @param Context * @return array Contacts */ public static function getContacts($id_lang, Shop $shop = null) { if (!$shop) $shop = Context::getContext()->shop; $sql = 'SELECT * FROM `'._DB_PREFIX_.'contact` c '.$shop->addSqlAssociation('contact', 'c', false).' LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`) WHERE cl.`id_lang` = '.(int)$id_lang.' ORDER BY `name` ASC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } /** * Return available categories contacts * @return array Contacts */ public static function getCategoriesContacts() { return Db::getInstance()->executeS(' SELECT cl.* FROM '._DB_PREFIX_.'contact ct LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.(int)Context::getContext()->language->id.') WHERE ct.customer_service = 1 '); } }