/**
  * Bootstraps session
  *
  * @param Uni_Application_Bootstrap $bootS
  * @return void
  */
 public static function initSession($bootS)
 {
     if (Fox::getMode() != Uni_Controller_Action::MODE_INSTALL) {
         session_set_cookie_params(0);
         if (!Fox::isDatabaseSession()) {
             Zend_Session::start(array('save_path' => APPLICATION_PATH . '/../var/sessions'));
         } else {
             $config = array('name' => Fox::getTableName('core_session'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
             Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
             Zend_Session::start();
         }
     }
 }
 /**
  * Get menu items in the menu group
  * 
  * @param string $key
  * @return array 
  */
 public function getMenuItemsByGroup($key)
 {
     $select = $this->getAdapter()->select()->from(array('mi' => $this->_name), '*')->where('mi.status=' . self::STATUS_ENABLED)->join(array('mg' => Fox::getTableName($this->_menuGroup)), 'mg.key = "' . addslashes($key) . '" AND find_in_set(mg.id, mi.menu_group)', 'mg.id')->order('mi.sort_order ASC');
     return $this->getAdapter()->fetchAll($select);
 }
 /**
  * Get attribute set for entity
  * 
  * @param string $entityTypeCode
  * @return array 
  */
 public function getAttributeSetByEntity($entityTypeCode)
 {
     $select = $this->getAdapter()->select()->from(array('a' => $this->_name))->join(array('e' => Fox::getTableName($this->_entityType)), 'a.entity_type_id=e.id', FALSE)->where('e.entity_type_code=?', $entityTypeCode);
     return $this->getAdapter()->fetchRow($select);
 }
 *
 * Class Fox_Member_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Member
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_set_id` tinyint(4) unsigned NOT NULL,\n  `first_name` varchar(255) NOT NULL,\n  `last_name` varchar(255) NOT NULL,\n  `email_id` varchar(255) NOT NULL,\n  `join_date` datetime NOT NULL,\n  `password` varchar(255) NOT NULL,\n  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0=>Blocked 1=>Active 2=>not confirm',\n  `member_image` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `attribute_set_id` (`attribute_set_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity') . "\n  ADD CONSTRAINT `member_entity_ibfk_1` FOREIGN KEY (`attribute_set_id`) REFERENCES " . Fox::getTableName('eav_attribute_set') . " (`id`);\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity_date') . " (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `entity_id` int(10) unsigned NOT NULL,\n  `value` date DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_id_2` (`attribute_id`,`entity_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `entity_id` (`entity_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity_date') . "\n  ADD CONSTRAINT `member_entity_datetime_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `member_entity_datetime_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity_decimal') . " (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `entity_id` int(10) unsigned NOT NULL,\n  `value` decimal(12,2) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_id_2` (`attribute_id`,`entity_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `entity_id` (`entity_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity_decimal') . "\n  ADD CONSTRAINT `member_entity_decimal_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `member_entity_decimal_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity_int') . " (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `entity_id` int(10) unsigned NOT NULL,\n  `value` int(11) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_id_2` (`attribute_id`,`entity_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `entity_id` (`entity_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity_int') . "\n  ADD CONSTRAINT `member_entity_int_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `member_entity_int_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity_text') . " (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `entity_id` int(10) unsigned NOT NULL,\n  `value` text,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_id_2` (`attribute_id`,`entity_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `entity_id` (`entity_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity_text') . "\n  ADD CONSTRAINT `member_entity_text_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `member_entity_text_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_entity_varchar') . " (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `entity_id` int(10) unsigned NOT NULL,\n  `value` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_id_2` (`attribute_id`,`entity_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `entity_id` (`entity_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('member_entity_varchar') . "\n  ADD CONSTRAINT `member_entity_varchar_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `member_entity_varchar_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_forget_password_entity') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `mem_id` varchar(255) NOT NULL,\n  `code` varchar(255) NOT NULL,\n  `created_on` datetime NOT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `code` (`code`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\nALTER TABLE " . Fox::getTableName('member_forget_password_entity') . "  ADD CONSTRAINT `member_forget_password_entity_ibfk_1` FOREIGN KEY (`mem_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('member_verification_entity') . " (\n  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n  `mem_id` int(11) unsigned NOT NULL,\n  `verification_code` varchar(255) NOT NULL,\n  PRIMARY KEY (`id`),\n  KEY `mem_id` (`mem_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\nALTER TABLE " . Fox::getTableName('member_verification_entity') . "\n  ADD CONSTRAINT `member_forget_password_entity_ibfk_1` FOREIGN KEY (`mem_id`) REFERENCES " . Fox::getTableName('member_entity') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->insertRecord(Fox::getTableName('eav_entity_type'), array('id' => '1', 'entity_type_code' => 'member'));
$installer->insertRecord(Fox::getTableName('eav_attribute_set'), array('id' => '1', 'entity_type_id' => '1', 'attribute_set_name' => 'Member'));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_group'), array('id' => '1', 'entity_type_id' => '1', 'group_name' => 'Personal Details', 'sort_order' => '0'));
$installer->insertRecord(Fox::getTableName('eav_attribute_group'), array('id' => '1', 'attribute_set_id' => '1', 'attribute_group_name' => 'Personal Details', 'sort_order' => '0'));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '1', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'first_name', 'data_type' => 'varchar', 'input_type' => 'text', 'frontend_label' => 'First Name', 'validation' => '', 'is_required' => '1', 'is_editable' => '1', 'is_backend_editable' => '1', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '2', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'last_name', 'data_type' => 'varchar', 'input_type' => 'text', 'frontend_label' => 'Last Name', 'validation' => '', 'is_required' => '1', 'is_editable' => '1', 'is_backend_editable' => '1', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '3', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'email_id', 'data_type' => 'varchar', 'input_type' => 'text', 'frontend_label' => 'Email ID', 'validation' => 'email', 'is_required' => '1', 'is_editable' => '0', 'is_backend_editable' => '0', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '4', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'password', 'data_type' => 'varchar', 'input_type' => 'password', 'frontend_label' => 'Password', 'validation' => '', 'is_required' => '1', 'is_editable' => '0', 'is_backend_editable' => '0', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '5', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'confirm_password', 'data_type' => 'varchar', 'input_type' => 'password', 'frontend_label' => 'Confirm Password', 'validation' => '', 'is_required' => '1', 'is_editable' => '0', 'is_backend_editable' => '0', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '6', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'member_image', 'data_type' => 'varchar', 'input_type' => 'file', 'frontend_label' => 'Upload Image', 'validation' => 'image', 'is_required' => '0', 'is_editable' => '0', 'is_backend_editable' => '0', 'is_visible_on_frontend' => '0', 'default_value' => '', 'position' => '0', 'source_model' => ''));
$installer->insertRecord(Fox::getTableName('eav_entity_metadata_attribute'), array('id' => '7', 'entity_type_id' => '1', 'group_id' => '1', 'attribute_code' => 'id', 'data_type' => 'int', 'input_type' => 'hidden', 'frontend_label' => '', 'validation' => '', 'is_required' => '0', 'is_editable' => '0', 'is_backend_editable' => '1', 'is_visible_on_frontend' => '1', 'default_value' => '', 'position' => '0', 'source_model' => ''));
 * Zendfox Framework
 *
 * LICENSE
 *
 * This file is part of Zendfox.
 *
 * Zendfox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Cms_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Cms
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\n    CREATE TABLE IF NOT EXISTS " . Fox::getTableName('contact_request') . " (\n`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(100) NOT NULL,\n  `email` varchar(100) NOT NULL,\n  `subject` varchar(255) NOT NULL,\n  `message` text NOT NULL,\n  `status` tinyint(4) NOT NULL COMMENT '0=>unread,1=>read,2=>replied',\n  `contact_date` datetime NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
 * Class Fox_Core_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Core
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('core_module') . " (\n  `name` varchar(80) NOT NULL,\n  `package` varchar(80) NOT NULL,\n  `namespace` varchar(80) NOT NULL,\n  `version` varchar(80) NOT NULL,\n  `sql_version` varchar(80) NOT NULL,\n  `status` tinyint(1) NOT NULL COMMENT '0=>Disabled 1=>Enabled',\n  PRIMARY KEY (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n");
$installer->runSetup("                \nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('core_preferences') . " (\n  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) NOT NULL,\n  `value` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `name` (`name`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->runSetup("                \nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('core_cache') . " (\n  `cache_type` varchar(100) NOT NULL,\n  `cache_code` varchar(25) NOT NULL,\n  `description` varchar(255) DEFAULT NULL,\n  `status` tinyint(1) NOT NULL COMMENT '0=>Disabled 1=>Enabled',\n  PRIMARY KEY (`cache_code`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n");
$installer->insertRecord(Fox::getTableName('core_cache'), array('cache_type' => 'Layouts', 'cache_code' => Fox_Core_Model_Cache::CACHE_CODE_LAYOUT, 'description' => 'Layout Files', 'status' => '0'));
$installer->insertRecord(Fox::getTableName('core_cache'), array('cache_type' => 'Preferences', 'cache_code' => Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE, 'description' => 'Preferences Collection Data', 'status' => '0'));
$installer->runSetup("                \nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('core_session') . " (\n  `id` char(32) NOT NULL DEFAULT '',\n  `modified` int(11) DEFAULT NULL,\n  `lifetime` int(11) DEFAULT NULL,\n  `data` text,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n");
$installer->runSetup("                \nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('core_email_template') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) NOT NULL,\n  `subject` varchar(255) NOT NULL,\n  `content` text NOT NULL,\n  `created_date` datetime NOT NULL,\n  `modified_date` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '1', 'name' => 'Account Registration Confirmation Link', 'subject' => 'Account Registration Confirmation Link', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a href="{{url}}"> <img style="margin-bottom: 0px;" src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Your e-mail {{email}} must be confirmed before using it to log in to our store.</p><p style="font-size: 12px; line-height: 16px; margin: 0 0 8px 0;">To confirm the e-mail and instantly log in, please, use <a style="color: #1e7ec8;" href="{{link}}">this confirmation link</a>. This link is valid only once.</p><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0 0 16px 0; padding: 13px 18px; background: #eaf3f6;">Use the following values when prompted to log in:<br /> <strong>E-mail:</strong> {{email}}<br /> <strong>Password:</strong>{{password}}</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '2', 'name' => 'Account Registration Welcome', 'subject' => 'Account Registration Welcome', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a href="{{webisteName}}"><img style="margin-bottom: 0px;" src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Welcome to {{websiteName}}. To log in just click <a style="color: #1e7ec8;" href="{{url=member/account/login}}">Login</a> and then enter your e-mail address and password.</p><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">Use the following when prompted to log in: <br /> <strong>E-mail</strong>: {{email}} <br /> <strong>Password</strong>: {{password}}</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '3', 'name' => 'Member Forgot Password', 'subject' => 'Forgot Account Password', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="font-size: 12px; line-height: 16px; margin: 0;">To change your password <a style="color: #1e7ec8;" href="{{link}}">Click Here</a></p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '4', 'name' => 'Account Registration Confirmed', 'subject' => 'Account Registration Confirmed', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">Welcome to {{websiteName}}. To log in to our site just click <a style="color: #1e7ec8;" href="{{url=member/account}}">Login</a> and provide your credentials</p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again, <br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '5', 'name' => 'Account Password Changed', 'subject' => 'Account Password Changed', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a href="{{webisteName}}"><img style="margin-bottom: 0px;" src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Your password was successfully changed.</p><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">Use the following when prompted to log in: <br /> <strong>E-mail</strong>: {{email}} <br /> <strong>Password</strong>: {{password}}</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '6', 'name' => 'Contact Us', 'subject' => 'Contact Us request send by {{name}}', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a href="{{url}}"> <img style="margin-bottom: 0px;" src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Below are the details of Contact Request:</h1></td></tr><tr><td valign="top"><div style="background: #FFFFFF; margin: 10px 0 20px 0;"><fieldset style="border: 1px solid #EEEEEE;"><legend style="background: #eaf3f6; border: 1px solid #EEEEEE; color: #000000; font-size: 12px; font-weight: bold; padding: 0 8px;">Contact Information</legend><table style="width: 100%;" border="0" cellspacing="0" cellpadding="5"><tbody><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Name</td><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{name}}</td></tr><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Email</td><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{email}}</td></tr><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Subject</td><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{subject}}</td></tr><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">Message</td><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{message}}</td></tr></tbody></table></fieldset></div></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '7', 'name' => 'Contact Us Reply', 'subject' => 'Reply To: {{subject}}', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a href="{{url}}"> <img style="margin-bottom: 0px;" src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Hello {{name}},</h1></td></tr><tr><td valign="top"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="5"><tbody><tr><td style="font-size: 12px; line-height: 16px;" colspan="2"><strong>Thank you for contacting us.</strong></td></tr><tr><td style="font-size: 12px; line-height: 16px;" colspan="2">Below is the reply to your query:</td></tr><tr><td style="font-size: 12px; line-height: 16px;" colspan="2"><div style="background: #FFFFFF; margin: 10px 0 20px 0;"><fieldset style="border: 1px solid #EEEEEE;"><legend style="background: #eaf3f6; border: 1px solid #EEEEEE; color: #000000; font-size: 12px; font-weight: bold; padding: 0 8px;">Reply</legend><table style="width: 100%;" border="0" cellspacing="0" cellpadding="5"><tbody><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{reply}}</td></tr></tbody></table></fieldset></div><div style="background: #FFFFFF; margin: 20px 0;"><fieldset style="border: 1px solid #EEEEEE;"><legend style="background: #eaf3f6; border: 1px solid #EEEEEE; color: #000000; font-size: 12px; font-weight: bold; padding: 0 8px;">Query</legend><table style="width: 100%;" border="0" cellspacing="0" cellpadding="5"><tbody><tr><td style="font-size: 12px; line-height: 16px; margin: 0 0 16px 0;">{{message}}</td></tr></tbody></table></fieldset></div></td></tr></tbody></table></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><p style="font-size: 12px; margin: 0;">Kind Regards<br /> <strong>{{websiteName}}</strong></p></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '8', 'name' => 'Admin Forgot Password', 'subject' => 'Forgot Account Password', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear {{name}},</h1><p style="font-size: 12px; line-height: 16px; margin: 0 0 8px 0;">&nbsp;</p><p style="font-size: 12px; line-height: 16px; margin: 0;">To change your password <a href="{{link}}">Click Here</a></p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again<br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '9', 'name' => 'Newsletter Subscription Confirmation', 'subject' => 'Newsletter Subscription Confirmation', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Thank you for subscribing to our newsletters.</h1><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">To begin receiving the newsletters, you must first confirm your subscription by <a style="color: #1e7ec8;" href="{{link}}">Clicking Here</a></p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again, <br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '10', 'name' => 'Newsletter Subscription Success', 'subject' => 'Newsletter Subscription Success', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">You have successfully subscribed for our newsletters.</h1><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">If you do not want to recieve newsletters from our site, you can unsubscribe anytime by <a title="Unsubscribe" href="{{unsubscribe_link}}">clicking here</a>.</p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again, <br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('core_email_template'), array('id' => '11', 'name' => 'Newsletter Unsubscription Success', 'subject' => 'Newsletter Unsubscription Success', 'content' => '<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;"><table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px 0 20px 0;" align="center" valign="top"><table style="border: 1px solid #e0e0e0; width: 650px;" border="0" cellspacing="0" cellpadding="7" bgcolor="FFFFFF"><tbody><tr><td valign="top"><a style="color: #1e7ec8;" href="{{url}}"><img src="{{themeUrl=images/logo_email.jpg}}" alt="{{websiteName}}" border="0" /></a></td></tr><tr><td valign="top"><h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Newsletter unsubscription was successful.</h1><p style="border: 1px solid #E0E0E0; font-size: 12px; line-height: 16px; margin: 0; padding: 13px 18px; background: #eaf3f6;">You will be no longer able to get newsletter from our website.</p><p>&nbsp;</p></td></tr><tr><td style="background: #dfedf1; text-align: center;" align="center"><center><p style="font-size: 12px; margin: 0;">Thank you again, <br /> <strong>{{websiteName}}</strong></p></center></td></tr></tbody></table></td></tr></tbody></table></div>', 'created_date' => gmdate('Y-m-d H:i:s'), 'modified_date' => gmdate('Y-m-d H:i:s')));
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_role_resource') . " (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `resource` text NOT NULL,\n  `resource_path` varchar(150) DEFAULT NULL,\n  `action` text COMMENT '-1=>All Actions',\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  `module` varchar(255) NOT NULL,\n  `display_in_tree` tinyint(1) NOT NULL DEFAULT '1',\n  PRIMARY KEY (`id`),\n  KEY `module` (`module`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\nALTER TABLE " . Fox::getTableName('admin_role_resource') . "\n  ADD CONSTRAINT `admin_role_resource_ibfk_1` FOREIGN KEY (`module`) REFERENCES " . Fox::getTableName('core_module') . " (`name`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_role_resource_category') . " (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `name` varchar(100) NOT NULL,\n  `parent_id` int(11) NOT NULL DEFAULT '0',\n  `resource_ids` text,\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  `module` varchar(255) NOT NULL,\n  `access_all` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `parent_id_path` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `module` (`module`),\n  KEY `parent_id` (`parent_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\nALTER TABLE " . Fox::getTableName('admin_role_resource_category') . "\n  ADD CONSTRAINT `admin_role_resource_category_ibfk_1` FOREIGN KEY (`module`) REFERENCES " . Fox::getTableName('core_module') . " (`name`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
 * This file is part of Zendfox.
 *
 * Zendfox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Admin_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Admin
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_analytics') . " (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `date_value` date NOT NULL,\n  `total_results` int(11) NOT NULL,\n  `page_views` int(11) NOT NULL,\n  `total_visits` int(11) NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_role') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(60) NOT NULL,\n  `resource_ids` text NOT NULL COMMENT 'Comma Seperated Resource Ids',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->insertRecord(Fox::getTableName('admin_role'), array('id' => '1', 'name' => 'Administrator', 'resource_ids' => '-1'));
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_user') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `firstname` varchar(100) NOT NULL,\n  `lastname` varchar(100) NOT NULL,\n  `email` varchar(255) NOT NULL,\n  `contact` varchar(15) DEFAULT NULL,\n  `username` varchar(50) NOT NULL,\n  `password` varchar(255) NOT NULL,\n  `role_id` int(10) unsigned NOT NULL,\n  `status` tinyint(4) NOT NULL COMMENT '0=>Blocked 1=>Active',\n  PRIMARY KEY (`id`),\n  KEY `role_id` (`role_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n                \nALTER TABLE " . Fox::getTableName('admin_user') . "\n  ADD CONSTRAINT `admin_user_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES " . Fox::getTableName('admin_role') . " (`id`);\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('admin_forget_password_entity') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `user_id` int(10) unsigned NOT NULL,\n  `code` varchar(255) NOT NULL,\n  `created_on` datetime NOT NULL,\n  PRIMARY KEY (`id`),\n  KEY `user_id` (`user_id`),\n  KEY `code` (`code`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\nALTER TABLE " . Fox::getTableName('`admin_forget_password_entity`') . "\n  ADD CONSTRAINT `admin_forget_password_entity_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES " . Fox::getTableName('admin_user') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
 /**
  * Loads record and sets data in the model for passed criteria
  *
  * @param string $value
  * @param string $field
  * @return object|NULL 
  */
 public function load($value, $field = NULL)
 {
     $condition = '';
     if (is_array($value)) {
         foreach ($value as $key => $val) {
             $condition .= $condition != '' ? " AND {$key}='{$val}'" : "{$key}='{$val}'";
         }
     } else {
         $condition = ($field ? $field : $this->primary) . '=' . "'{$value}'";
     }
     $record = $this->fetchRow($condition);
     if ($record) {
         $mainData = $record->toArray();
         $metaData = array();
         $attrSetId = $mainData[$this->_eav_field];
         $eav_entity_prefix = $this->getEavEntityPrefix();
         $aidRows = $this->getAdapter()->fetchAll("SELECT at.attribute_code AS attribute_code, at.id AS attribute_id, at.data_type as data_type FROM " . Fox::getTableName('eav_attribute') . " at JOIN " . Fox::getTableName('eav_entity_attribute') . " ea ON (ea.attribute_id=at.id) WHERE ea.attribute_set_id='{$attrSetId}'");
         foreach ($aidRows as $aidRow) {
             $attrAlias = 'eav_' . $aidRow['data_type'];
             $metaData['select'][] = '(SELECT `value` FROM ' . $eav_entity_prefix . '_' . $aidRow['data_type'] . '  WHERE ' . $eav_entity_prefix . '_' . $aidRow['data_type'] . ".entity_id=main.id AND " . $eav_entity_prefix . '_' . $aidRow['data_type'] . '.attribute_id=\'' . $aidRow['attribute_id'] . '\') AS ' . $aidRow['attribute_code'];
         }
         if (!empty($metaData)) {
             $select = $this->select()->from(array('main' => $this->_name), $metaData['select'])->where($this->primary . '=?', $mainData[$this->primary]);
             $eavData = $this->fetchRow($select);
             if ($eavData) {
                 $mainData = array_merge($mainData, $eavData->toArray());
             }
         }
         return $this->setData($mainData);
     }
     return NULL;
 }
 * Zendfox Framework
 *
 * LICENSE
 *
 * This file is part of Zendfox.
 *
 * Zendfox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Cms_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Cms
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\n    CREATE TABLE IF NOT EXISTS " . Fox::getTableName('backup_report') . " (\n   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n  `file_name` varchar(100) NOT NULL,\n  `file_size` int(11) NOT NULL,\n  `backup_date` datetime NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
 *
 * This file is part of Zendfox.
 *
 * Zendfox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_News_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_News
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('news_entity') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `title` varchar(255) NOT NULL,\n  `content` text NOT NULL,\n  `date_from` datetime DEFAULT NULL,\n  `date_to` datetime DEFAULT NULL,\n  `sort_order` int(10) unsigned NOT NULL,\n  `status` tinyint(4) NOT NULL COMMENT '0=>Disabled 1=>Enabled',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->insertRecord(Fox::getTableName('news_entity'), array('id' => '1', 'title' => 'News Title 1', 'content' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.', 'sort_order' => '1', 'status' => '1'));
$installer->insertRecord(Fox::getTableName('news_entity'), array('id' => '2', 'title' => 'News Title 2', 'content' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.', 'sort_order' => '1', 'status' => '1'));
$installer->insertRecord(Fox::getTableName('news_entity'), array('id' => '3', 'title' => 'News Title 3', 'content' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.', 'sort_order' => '1', 'status' => '1'));
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Cms_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Cms
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\n    CREATE TABLE IF NOT EXISTS " . Fox::getTableName('cms_block') . " (\n  `id` mediumint(9) NOT NULL AUTO_INCREMENT,\n  `title` varchar(255) NOT NULL,\n  `identifier_key` varchar(150) NOT NULL,\n  `content` text NOT NULL,\n  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0=>Disabled 1=>Enabled',\n  `created_on` datetime NOT NULL,\n  `modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `identifier_key` (`identifier_key`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n");
$installer->insertRecord(Fox::getTableName('cms_block'), array('id' => '1', 'title' => 'Footer Content', 'identifier_key' => 'footer-content', 'content' => 'Powered By: Zendfox (WAF)', 'status' => '1', 'created_on' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_block'), array('id' => '2', 'title' => 'Footer Links', 'identifier_key' => 'footer-links', 'content' => '<p><a class="noneBack" href="{{getUrl(\'\')}}">Home</a> <a href="{{getUrl(\'about\')}}">About Us</a><a href="{{getUrl(\'need-help\')}}">Need Help? </a> <a href="{{getUrl(\'contact\')}}">Contact Us</a><a href="{{getUrl(\'privacy-policy\')}}">Privacy Policy</a><a class="last" href="{{getUrl(\'terms\')}}">Terms of Service</a></p>', 'status' => '1', 'created_on' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_block'), array('id' => '3', 'title' => 'Left Template', 'identifier_key' => 'template-block', 'content' => '<div class="left_cont top1 gradient"><div class="zend-template-content"><ul><li class="template-image">&nbsp;</li><li class="get-text">Get Zendfox<br /> Customizable Templates</li><li class="click-button"><a href="#">Click Here</a></li></ul></div></div>', 'status' => '1', 'created_on' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_block'), array('id' => '4', 'title' => 'Left Menu', 'identifier_key' => 'left-menu-block', 'content' => '<div class="left_cont top2 gradient">    <h2 class="sub-heading">Left Menu Title</h2>    <div class="left-list">        <ul>            <li><a href="#">Demo Menu 1</a></li>            <li><a href="#">Demo Menu 2</a></li>            <li><a href="#">Demo Menu 3</a></li>            <li><a href="#">Demo Menu 4</a></li>            <li><a href="#">Demo Menu 5</a></li>            <li><a href="#">Demo Menu 6</a></li>            <li><a href="#">Demo Menu 7</a></li>            <li><a href="#">Demo Menu 8</a></li>            <li><a href="#">Demo Menu 9</a></li>            <li><a href="#">Demo Menu 10</a></li>            <li><a href="#">Demo Menu 11</a></li>                    </ul>    </div></div>', 'status' => '1', 'created_on' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_block'), array('id' => '5', 'title' => 'Right Menu', 'identifier_key' => 'right-menu-block', 'content' => '<div class="left_cont top2 gradient">    <h2 class="sub-heading">Right Menu Title</h2>    <div class="left-list">        <ul>            <li><a href="#">Demo Menu 1</a></li>            <li><a href="#">Demo Menu 2</a></li>            <li><a href="#">Demo Menu 3</a></li>            <li><a href="#">Demo Menu 4</a></li>            <li><a href="#">Demo Menu 5</a></li>            <li><a href="#">Demo Menu 6</a></li>            <li><a href="#">Demo Menu 7</a></li>            <li><a href="#">Demo Menu 8</a></li>            <li><a href="#">Demo Menu 9</a></li>            <li><a href="#">Demo Menu 10</a></li>            <li><a href="#">Demo Menu 11</a></li>                    </ul>    </div></div>', 'status' => '1', 'created_on' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->runSetup("\n    CREATE TABLE IF NOT EXISTS " . Fox::getTableName('cms_page') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `title` tinytext NOT NULL,\n  `url_key` varchar(255) NOT NULL,\n  `content` text NOT NULL,\n  `layout` varchar(100) NOT NULL,\n  `layout_update` text NULL,\n  `meta_keywords` tinytext NULL,\n  `meta_description` tinytext NULL,\n  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0=>Inactive,1=>Active,100=>Deleted',\n  `created` datetime NOT NULL COMMENT 'Creation Date and time',\n  `modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `url_key` (`url_key`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n");
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '1', 'title' => '404 Not Found!', 'url_key' => 'no-page-404', 'content' => '<div class="oops"><h1>Oooops!! <span class="go-back"><a onclick="history.go(-1);" href="#">Go back</a>&nbsp; to the previous page</span></h1><div class="not-found"><div class="logo-img"><img src="{{themeUrl(\'images/fox-logo.png\')}}" alt="Zendfox Logo" /></div><h2>404-Page Not Found!</h2><h3>Sorry, <span class="page-request">The page you requested was not found on server.</span></h3><h4>Suggestions:</h4><ul><li>Please make sure the spelling is correct.</li></ul></div></div>', 'layout' => 'one-column', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '2', 'title' => 'Home', 'url_key' => 'home', 'content' => '<div class="banner_wrap">{{view key="home-banner" class="core/template" tpl="fox/html/banner"}}</div><div class="msgbox">{{view key="messages" class="core/template" tpl="fox/html/messages"}}</div><div class="title_bar"><h2>Home <span>Page</span></h2></div><div class="home_content_wrap"><div class="home_content_left"><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p></div></div>', 'layout' => 'three-columns', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '3', 'title' => 'About Us', 'url_key' => 'about', 'content' => '<div class="title_bar"><h2>About <span>Us</span></h2></div><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p>', 'layout' => 'three-columns', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '4', 'title' => 'Privacy Policy', 'url_key' => 'privacy-policy', 'content' => '<div class="title_bar"><h2>Privacy <span>Policy</span></h2></div><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p>', 'layout' => 'three-columns', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '5', 'title' => 'Terms of Service', 'url_key' => 'terms', 'content' => '<div class="title_bar"><h2>Terms of <span>Service</span></h2></div><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p>', 'layout' => 'three-columns', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
$installer->insertRecord(Fox::getTableName('cms_page'), array('id' => '6', 'title' => 'Need Help?', 'url_key' => 'need-help', 'content' => '<div class="title_bar"><h2>Need <span>Help?</span></h2></div><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.</p>', 'layout' => 'three-columns', 'layout_update' => '', 'meta_keywords' => '', 'meta_description' => '', 'status' => '1', 'created' => date('Y-m-d H:i:s'), 'modified_on' => date('Y-m-d H:i:s')));
 *
 * LICENSE
 *
 * This file is part of Zendfox.
 *
 * Zendfox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Newsletter_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Newsletter
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('newsletter_subscriber') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) DEFAULT NULL,\n  `email` varchar(255) NOT NULL,\n  `status` tinyint(4) NOT NULL COMMENT '0->unsusbcribe,1->confirm,2->subscribe',\n  `code` varchar(50) NOT NULL,\n   PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('newsletter_template') . " (\n  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) NOT NULL,\n  `subject` varchar(255) NOT NULL,\n  `sender_name` varchar(255) NOT NULL,\n  `sender_email` varchar(255) NOT NULL,\n  `content` text NOT NULL,\n  `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `update_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>Not Sent 1=>Sent',\n  `last_sent` datetime DEFAULT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Eav_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Eav
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_entity_type') . " (\n  `id` tinyint(4) unsigned NOT NULL AUTO_INCREMENT,\n  `entity_type_code` varchar(100) NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_attribute_set') . " (\n  `id` tinyint(4) unsigned NOT NULL AUTO_INCREMENT,\n  `entity_type_id` tinyint(4) unsigned NOT NULL,\n  `attribute_set_name` varchar(100) NOT NULL,\n  PRIMARY KEY (`id`),\n  KEY `entity_type_id` (`entity_type_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('eav_attribute_set') . "\n  ADD CONSTRAINT `eav_attribute_set_ibfk_1` FOREIGN KEY (`entity_type_id`) REFERENCES " . Fox::getTableName('eav_entity_type') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_attribute') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `entity_type_id` tinyint(4) unsigned NOT NULL,\n  `attribute_code` varchar(150) NOT NULL,\n  `data_type` varchar(30) NOT NULL,\n  `input_type` varchar(30) NOT NULL,\n  `frontend_label` varchar(150) NOT NULL,\n  `validation` varchar(100) DEFAULT NULL,\n  `is_editable` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `is_backend_editable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0=>No, 1=>Yes',\n  `is_visible_on_frontend` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `is_required` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `is_user_defined` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=>System 1=>User',\n  `default_value` text,\n  `is_unique` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `position` int(11) NOT NULL DEFAULT '0',\n  `source_model` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `attribute_code` (`attribute_code`),\n  KEY `entity_type_id` (`entity_type_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('eav_attribute') . "\n  ADD CONSTRAINT `eav_attribute_ibfk_1` FOREIGN KEY (`entity_type_id`) REFERENCES " . Fox::getTableName('eav_entity_type') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_attribute_group') . " (\n  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_set_id` tinyint(4) unsigned NOT NULL,\n  `attribute_group_name` varchar(100) NOT NULL,\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`),\n  KEY `attribute_set_id` (`attribute_set_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('eav_attribute_group') . "\n  ADD CONSTRAINT `eav_attribute_group_ibfk_1` FOREIGN KEY (`attribute_set_id`) REFERENCES " . Fox::getTableName('eav_attribute_set') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_attribute_option') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  `label` varchar(255) DEFAULT NULL,\n  `value` varchar(255) DEFAULT NULL,\n  `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  PRIMARY KEY (`id`),\n  KEY `attribute_id` (`attribute_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('eav_attribute_option') . "\n  ADD CONSTRAINT `eav_attribute_option_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_entity_metadata_group') . " (\n  `id` tinyint(4) unsigned NOT NULL AUTO_INCREMENT,\n  `entity_type_id` tinyint(4) unsigned NOT NULL,\n  `group_name` varchar(255) NOT NULL,\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`),\n  KEY `entity_type_id` (`entity_type_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\nALTER TABLE " . Fox::getTableName('eav_entity_metadata_group') . "\n  ADD CONSTRAINT `eav_entity_metadata_group_ibfk_1` FOREIGN KEY (`entity_type_id`) REFERENCES " . Fox::getTableName('eav_entity_type') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_entity_metadata_attribute') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `entity_type_id` tinyint(4) unsigned NOT NULL,\n  `group_id` tinyint(4) unsigned NOT NULL,\n  `attribute_code` varchar(150) NOT NULL,\n  `data_type` varchar(30) NOT NULL,\n  `input_type` varchar(30) NOT NULL,\n  `frontend_label` varchar(150) NOT NULL,\n  `validation` varchar(100) DEFAULT NULL,\n  `is_required` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `is_editable` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `is_backend_editable` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No, 1=>Yes',\n  `is_visible_on_frontend` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0=>No 1=>Yes',\n  `default_value` text,\n  `position` int(11) NOT NULL DEFAULT '0',\n  `source_model` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `group_id` (`group_id`),\n  KEY `entity_type_id` (`entity_type_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\nALTER TABLE " . Fox::getTableName('eav_entity_metadata_attribute') . "\n  ADD CONSTRAINT `eav_entity_metadata_attribute_ibfk_1` FOREIGN KEY (`entity_type_id`) REFERENCES " . Fox::getTableName('eav_entity_type') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `eav_entity_metadata_attribute_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES " . Fox::getTableName('eav_entity_metadata_group') . " (`id`);\n");
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('eav_entity_attribute') . " (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `attribute_set_id` tinyint(4) unsigned NOT NULL,\n  `attribute_group_id` smallint(5) unsigned NOT NULL,\n  `attribute_id` int(10) unsigned NOT NULL,\n  `sort_order` int(11) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`),\n  KEY `attribute_set_id` (`attribute_set_id`),\n  KEY `attribute_id` (`attribute_id`),\n  KEY `attribute_group_id` (`attribute_group_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\nALTER TABLE " . Fox::getTableName('eav_entity_attribute') . "\n  ADD CONSTRAINT `eav_entity_attribute_ibfk_1` FOREIGN KEY (`attribute_id`) REFERENCES " . Fox::getTableName('eav_attribute') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `eav_entity_attribute_ibfk_2` FOREIGN KEY (`attribute_set_id`) REFERENCES " . Fox::getTableName('eav_attribute_set') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  ADD CONSTRAINT `eav_entity_attribute_ibfk_3` FOREIGN KEY (`attribute_group_id`) REFERENCES " . Fox::getTableName('eav_attribute_group') . " (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
 *
 * Zendfox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Zendfox in the file LICENSE.txt.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Class Fox_Navigation_Setup_Sql
 * 
 * @uses Uni_Core_Setup_Abstract
 * @category    Fox
 * @package     Fox_Navigation
 * @author      Zendfox Team of Unicode Systems <*****@*****.**>
 * @copyright   Copyright (c) 2011 Unicode Systems. (http://www.unicodesystems.in)
 * @license     http://www.gnu.org/licenses/  GNU General Public License
 */
$installer = $this;
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('navigation_menu_group') . " (\n  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(100) NOT NULL,\n  `sort_order` int(11) NOT NULL,\n  `key` varchar(100) NOT NULL,\n  `description` varchar(255) DEFAULT NULL,\n  `status` tinyint(1) NOT NULL COMMENT '0=>Disable 1=>Enable',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->insertRecord(Fox::getTableName('navigation_menu_group'), array('id' => '1', 'name' => 'Header Menu', 'sort_order' => '0', 'key' => 'HEADER', 'description' => 'Header Menu', 'status' => '1'));
$installer->insertRecord(Fox::getTableName('navigation_menu_group'), array('id' => '2', 'name' => 'Left Menu', 'sort_order' => '1', 'key' => 'LEFT', 'description' => 'Member Menus', 'status' => '1'));
$installer->runSetup("\nCREATE TABLE IF NOT EXISTS " . Fox::getTableName('navigation_menu_item') . " (\n `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n  `title` varchar(100) NOT NULL,\n  `link` varchar(255) NOT NULL,\n  `open_window` varchar(20) NOT NULL,\n  `sort_order` int(11) NOT NULL,\n  `status` tinyint(1) NOT NULL COMMENT '0=>Disabled 1=>Enabled',\n  `menu_group` varchar(255) NOT NULL,\n  `style_class` varchar(100) DEFAULT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n");
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '1', 'title' => 'Home', 'link' => '', 'open_window' => '_self', 'sort_order' => '1', 'status' => '1', 'menu_group' => '1', 'style_class' => 'home'));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '2', 'title' => 'About Us', 'link' => 'about', 'open_window' => '_self', 'sort_order' => '2', 'status' => '1', 'menu_group' => '1', 'style_class' => ''));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '3', 'title' => 'Contact Us', 'link' => 'contact', 'open_window' => '_self', 'sort_order' => '3', 'status' => '1', 'menu_group' => '1', 'style_class' => ''));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '4', 'title' => 'View Profile', 'link' => 'member/account/profile', 'open_window' => '_self', 'sort_order' => '1', 'status' => '1', 'menu_group' => '2', 'style_class' => ''));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '5', 'title' => 'Edit Profile', 'link' => 'member/account/edit-profile', 'open_window' => '_self', 'sort_order' => '2', 'status' => '1', 'menu_group' => '2', 'style_class' => ''));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '6', 'title' => 'Change Password', 'link' => 'member/account/change-password', 'open_window' => '_self', 'sort_order' => '3', 'status' => '1', 'menu_group' => '2', 'style_class' => ''));
$installer->insertRecord(Fox::getTableName('navigation_menu_item'), array('id' => '7', 'title' => 'News', 'link' => 'news', 'open_window' => '_self', 'sort_order' => '4', 'status' => '1', 'menu_group' => '1', 'style_class' => ''));
 /**
  * Get unused attributes
  * 
  * @param int $attributeSetId
  * @param int $entityTypeId
  * @return Uni_Core_Model_Collection 
  */
 public function getUnassignedAttributes($attributeSetId, $entityTypeId)
 {
     return $this->getCollection('entity_type_id=' . $entityTypeId . ' AND id NOT IN(SELECT e.attribute_id FROM ' . Fox::getTableName($this->entityAttribute) . ' e WHERE e.attribute_set_id=' . $attributeSetId . ')');
 }