function display($tpl = null) { //redirect user to dealtoday page if use already subscription if (JRequest::getVar('CS_SESSION_LOCATIONID', '', 'COOKIE')) { JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_enmasse&controller=deal&task=today')); } // get pagameters $app = JFactory::getApplication(); $params = $app->getParams(); $parameters = new JObject(); $parameters->module_id = $params->get('subscribe_module_id'); $parameters->params = $params; //------------------------ //gemerate integration class $integrateFileName = EnmasseHelper::getSubscriptionClassFromSetting() . '.class.php'; $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrateFileName; $integrationObject = new $integrationClass(); // assign data which get from integration class to view $data = $integrationObject->getViewData($parameters); $data->module->user = 0; $this->assignRef('data', $data); $this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "theme" . DS . EnmasseHelper::getThemeFromSetting() . DS . "tmpl" . DS); $this->_layout = "subscription"; parent::display($tpl); }
function dealSetLocationCookie() { $locationId = JRequest::getInt('locationId', null); $email = JRequest::getVar('email'); $oMenu = JFactory::getApplication()->getMenu(); $oItem = $oMenu->getItems('link', 'index.php?option=com_enmasse&view=dealtoday', true); ////////// Integration with ACY Mailing ////////// $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); $acy_path = JPATH_SITE . DS . 'components' . DS . 'com_acymailing'; if (file_exists($acy_path)) { if ($integrationClass == 'acystarter' || $integrationClass == 'acyenterprise') { require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrationClass . ".class.php"; if ($integrationClass == 'acystarter') { $acy = new acystarter(); } elseif ($integrationClass == 'acyenterprise') { $acy = new acyenterprise(); } $acy->updateSubscriptionList($locationId, $email); } } ///////////////////////////////////////////////// if (!empty($locationId)) { //set cookie locationId with lifetime is 365 days $dtLifeTime = time() + 365 * 24 * 60 * 60; setcookie(self::CS_SESSION_LOCATIONID, $locationId, $dtLifeTime, '/'); $oDeal = JModel::getInstance('deal', 'enmasseModel')->getDealMaxSoldQtyFromLocation($locationId); if ($oDeal->id) { JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_enmasse&controller=deal&task=view&id=' . $oDeal->id . '&Itemid=' . $oItem->id, false)); } } $link = JRoute::_('index.php?option=com_enmasse&controller=deal&task=today&Itemid=' . $oItem->id, false); JFactory::getApplication()->redirect($link); }
function display($tpl = null) { $task = JRequest::getWord('task'); if ($task == 'edit') { TOOLBAR_enmasse::_LOCATION_NEW(); $cid = JRequest::getVar('cid', array(0), '', 'array'); $row = JModel::getInstance('location', 'enmasseModel')->getById($cid[0]); $this->assignRef('location', $row); } elseif ($task == 'add') { TOOLBAR_enmasse::_LOCATION_NEW(); } else { /// load pagination $pagination =& $this->get('Pagination'); $state =& $this->get('state'); // get order values $order['order_dir'] = $state->get('filter_order_dir'); $order['order'] = $state->get('filter_order'); TOOLBAR_enmasse::_SMENU(); $nNumberOfLocations = JModel::getInstance('location', 'enmasseModel')->countAll(); if ($nNumberOfLocations == 0) { TOOLBAR_enmasse::_LOCATION_EMPTY(); } else { //------------------------ //gemerate integration class $integrateFileName = EnmasseHelper::getSubscriptionClassFromSetting() . '.class.php'; $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrateFileName; $integrationObject = new $integrationClass(); $integrationObject->addMenu(); TOOLBAR_enmasse::_LOCATION(); } $locationList = JModel::getInstance('location', 'enmasseModel')->search(); $this->assignRef('locationList', $locationList); $this->assignRef('pagination', $pagination); $this->assignRef('order', $order); } parent::display($tpl); }
function save() { $data = JRequest::get('post'); $data['name'] = trim($data['name']); $data['slug_name'] = EnmasseHelper::seoUrl($data['name']); $data['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $data['highlight'] = JRequest::getVar('highlight', '', 'post', 'string', JREQUEST_ALLOWRAW); $data['terms'] = JRequest::getVar('terms', '', 'post', 'string', JREQUEST_ALLOWRAW); if ($data['slug_name'] == '_' || $data['slug_name'] == '') { $now = str_replace(":", " ", DatetimeWrapper::getDatetimeOfNow()); $data['slug_name'] = EnmasseHelper::seoUrl($now); } $model = JModel::getInstance('deal', 'enmasseModel'); //--------------------------------------------------------------- // if edit deal if ($data['id'] > 0) { //---get deal data $deal = JModel::getInstance('deal', 'enmasseModel')->getById($data['id']); // get sold coupon qty for deal $soldCouponList = JModel::getInstance('invty', 'enmasseModel')->getSoldCouponByPdtId($deal->id); //if from unlimited to limited if ($deal->max_coupon_qty < 0) { if ($data['max_coupon_qty'] > 0) { if ($data['max_coupon_qty'] <= count($soldCouponList)) { $msg = JText::_('MSG_CURRENT_SOLD_GRATER_THAN_MODIFIED_COUPON'); JFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=deal&task=edit&cid=' . $data['id'], $msg); } else { $numOfAddCoupon = $data['max_coupon_qty'] - count($soldCouponList); } } } else { //---------------- if change from limited to unlimited if ($data['max_coupon_qty'] < 0) { $unlimit = true; } else { if ($data['max_coupon_qty'] < $deal->max_coupon_qty) { //---------------------- if new coupon qty <= the sold coupon qty if ($data['max_coupon_qty'] <= count($soldCouponList)) { $msg = JText::_('MSG_CURRENT_SOLD_GRATER_THAN_MODIFIED_COUPON'); JFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=deal&task=edit&cid=' . $data['id'], $msg); } else { $numOfRemoveCoupon = $deal->max_coupon_qty - $data['max_coupon_qty']; } } else { if ($data['max_coupon_qty'] > $deal->max_coupon_qty) { $numOfAddCoupon = $data['max_coupon_qty'] - $deal->max_coupon_qty; } } } } } //------------------------ //gemerate integration class $integrateFileName = EnmasseHelper::getSubscriptionClassFromSetting() . '.class.php'; $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrateFileName; $integrationObject = new $integrationClass(); // store data $row = $model->store($data); if ($row->success) { if ($data['id'] == 0) { $integrationObject->integration($row, 'newDeal'); } //-------------------------------------- // store location and category JModel::getInstance('dealCategory', 'enmasseModel')->store($row->id, $data['pdt_cat_id']); JModel::getInstance('dealLocation', 'enmasseModel')->store($row->id, $data['location_id']); // if is new deal and limited the coupon then create coupon in invty if ($data['id'] == 0 && $row->max_coupon_qty > 0) { for ($i = 0; $i < $row->max_coupon_qty; $i++) { $name = $i + 1; JModel::getInstance('invty', 'enmasseModel')->generateCouponFreeStatus($row->id, $name, 'Free'); } } else { if ($data['id'] != 0) { if (!empty($numOfRemoveCoupon)) { $freeCouponList = JModel::getInstance('invty', 'enmasseModel')->getCouponFreeByPdtID($data['id']); // removed the coupons from invty for ($i = 0; $i < $numOfRemoveCoupon; $i++) { JModel::getInstance('invty', 'enmasseModel')->removeById($freeCouponList[$i]->id); } } else { if (!empty($numOfAddCoupon)) { // add more coupon to invty for ($i = 0; $i < $numOfAddCoupon; $i++) { $name = $i + 1; JModel::getInstance('invty', 'enmasseModel')->generateCouponFreeStatus($data['id'], $name, 'Free'); } } else { if ($unlimit) { //remove all free coupon JModel::getInstance('invty', 'enmasseModel')->removeCouponByPdtIdAndStatus($data['id'], 'Free'); } } } } } $msg = JText::_('SAVE_SUCCESS_MSG'); $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller'), $msg); } else { $msg = JText::_('SAVE_ERROR_MSG') . ": " . $model->getError(); if ($data['id'] == null) { $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=add', $msg, 'error'); } else { $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=edit&cid[0]=' . $data['id'], $msg, 'error'); } } }
/*------------------------------------------------------------------------ # En Masse - Social Buying Extension 2010 # ------------------------------------------------------------------------ # By Matamko.com # Copyright (C) 2010 Matamko.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.matamko.com # Technical Support: Visit our forum at www.matamko.com -------------------------------------------------------------------------*/ require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "EnmasseHelper.class.php"; $theme = EnmasseHelper::getThemeFromSetting(); // getting data from view $data = $this->data; // getting class for subscription $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); $sub_page = JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . "sub_page.php"; $oMenu = JFactory::getApplication()->getMenu(); $oItem = $oMenu->getItems('link', 'index.php?option=com_enmasse&view=dealtoday', true); $sRedirectLink = JRoute::_('index.php?option=com_enmasse&controller=deal&task=today&Itemid=' . $oItem->id, false); if (!$sub_page) { JFactory::getApplication()->redirect($sRedirectLink, $msg); exit; } JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/jquery-1.6.2.min.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.core.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.widget.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.mouse.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.button.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.dialog.js'); JFactory::getDocument()->addScript('components/com_enmasse/theme/js/jquery/ui/jquery.ui.position.js');
function updateAcyList() { global $mainframe; $version = new JVersion(); $joomla = $version->getShortVersion(); if (substr($joomla, 0, 3) >= 1.6) { $mainframe = JFactory::getApplication(); } // define variable $cid from GET $cid = JRequest::getVar('cid', array(), '', 'array'); JArrayHelper::toInteger($cid); // Check there is/are item that will be changed. //If not, show the error. $error = false; $msg; if (count($cid) < 1) { $msg = JText::_('NO_ITEM_SELECTED'); $error = true; } else { // Prepare sql statement, if cid more than one, // it will be "cid1, cid2, cid3, ..." $cids = implode(',', $cid); $query = "SELECT * FROM #__enmasse_location where id IN ( " . $cids . " )"; // Initialize variables $db = JFactory::getDBO(); // Execute query $db->setQuery($query); $locationList = $db->loadObjectList(); if ($db->getErrorNum()) { $msg = $db->getErrorMsg(); $error = true; } else { //------------------------ //gemerate integration class $integrateFileName = EnmasseHelper::getSubscriptionClassFromSetting() . '.class.php'; $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting(); require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrateFileName; $integrationObject = new $integrationClass(); foreach ($locationList as $item) { $item->oldname = $item->name; $integrationObject->insertEnmasseLocation($item); } $msg = JText::_("ACY_LOCATION_UPDATED"); } } // After all, redirect to front page $link = JRoute::_("index.php?option=com_enmasse&controller=" . JRequest::getVar('controller'), false); if ($error) { JFactory::getApplication()->redirect($link, $msg, 'error'); } else { JFactory::getApplication()->redirect($link, $msg); } }