Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/joomla4/waitlist_notify.zip

PK�,�[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�,�[]K_��waitlist_notify.phpnu�[���<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashopWaitlist_notify extends JPlugin
{
	var $message = '';

	function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	function onHikashopCronTrigger(&$messages) {
		$pluginsClass = hikashop_get('class.plugins');
		$plugin =
$pluginsClass->getByName('hikashop','waitlist_notify');
		if(empty($plugin->params['period'])){
			$plugin->params['period'] = 7200;
		}
		$this->period = $plugin->params['period'];
		if(!empty($plugin->params['last_cron_update']) &&
$plugin->params['last_cron_update']+$plugin->params['period']>time()){
			return true;
		}
		$plugin->params['last_cron_update']=time();
		$pluginsClass->save($plugin);
		$this->checkWaitlists();
		if(!empty($this->message)){
			$messages[] = $this->message;
		}
		return true;
	}

	function checkWaitlists() {
		$config =& hikashop_config();
		$app = JFactory::getApplication();
		$db = JFactory::getDBO();

		$waitlist_send_limit =
$config->get('product_waitlist_send_limit', 5);
		$query='SELECT a.*, b.* FROM
'.hikashop_table('waitlist').' AS a '.
			' INNER JOIN '.hikashop_table('product').' AS b
ON (a.product_id = b.product_id)'.
			' LEFT JOIN '.hikashop_table('product').' AS c
ON (c.product_id = b.product_parent_id)'.
			' WHERE (b.product_quantity > 0) OR (b.product_quantity = -1 AND
b.product_type = '.$db->Quote('main').') '.
			'   OR (b.product_type =
'.$db->Quote('variant').' AND b.product_quantity =
-1 AND (c.product_quantity > 0 OR c.product_quantity = -1))'.
			' ORDER BY a.product_id ASC, a.date ASC;';
		$db->setQuery($query);
		$notifies = $db->loadObjectList();
		if(empty($notifies)) {
			$this->message = 'Waitlist notifies checked (empty)';
			$app->enqueueMessage($this->message);
			return true;
		}

		$cpt = 0;
		$infos = null;
		$sends = array();
		foreach($notifies as $notify) {
			if( !isset($sends[$notify->product_id]) ) {
				$sends[$notify->product_id] = array();
			}

			$c = count($sends[$notify->product_id]);
			if( $c >= $notify->product_quantity &&
$notify->product_quantity >= 0 )
				continue;
			if( $c >= $waitlist_send_limit && $waitlist_send_limit > 0
)
				continue;

			if(!empty($notify->language)) {
				$reload = $this->_setLocale($notify->language);
			}

			if($notify->product_type == 'variant') {
				if(!isset($productClass))
					$productClass = hikashop_get('class.product');

				$db->setQuery('SELECT * FROM
'.hikashop_table('variant').' AS a LEFT JOIN
'.hikashop_table('characteristic') .' AS b ON
a.variant_characteristic_id=b.characteristic_id WHERE
a.variant_product_id='.(int)$notify->product_id.' ORDER BY
a.ordering');
				$notify->characteristics = $db->loadObjectList();

				$parentProduct =
$productClass->get((int)$notify->product_parent_id);
				$productClass->checkVariant($notify, $parentProduct);
			}

			if(!isset($mailClass))
				$mailClass = hikashop_get('class.mail');

			$sends[$notify->product_id][] = $notify->waitlist_id;

			$mail = $mailClass->get('waitlist_notification', $notify);
			$mail->subject = JText::sprintf($mail->subject, HIKASHOP_LIVE);
			$mail->dst_email = $notify->email;
			$mail->dst_name = $notify->name;
			$mailClass->sendMail($mail);

			$query = 'DELETE FROM
'.hikashop_table('waitlist').' WHERE waitlist_id =
'.(int)$notify->waitlist_id.';';
			$db->setQuery($query);
			$db->execute();

			$cpt++;
		}

		$this->message = 'Waitlist notifies checked (' . (int)$cpt .
')';
		$app->enqueueMessage($this->message);

		if(!empty($this->oldLocale))
			$this->_setLocale($this->oldLocale);
		return true;
	}

	function _setLocale($locale){
		$config = JFactory::getConfig();
		$oldLang = $config->get('language');

		if($oldLang == $locale)
			return false;

		if(!isset($this->oldLocale))
			$this->oldLocale = $oldLang;
		$config->set('language',$locale);

		$debug = $config->get('debug');

		$lang = JFactory::getLanguage();
		$override_path =
hikashop_getLanguagePath(JPATH_ROOT).DS.'overrides'.DS.$locale.'.override.ini';
		$lang->load(HIKASHOP_COMPONENT, JPATH_SITE, $locale, true );
		if(file_exists($override_path))
			hikashop_loadTranslationFile($override_path);

		return true;
	}
}
PK�,�[��ywaitlist_notify.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5"
method="upgrade" group="hikashop">
	<name>Hikashop WaitList notification Plugin</name>
	<creationDate>12 février 2021</creationDate>
	<version>4.4.1</version>
	<author>Hikashop</author>
	<authorEmail>dev@hikashop.com</authorEmail>
	<authorUrl>http://www.hikashop.com</authorUrl>
	<copyright>(C) 2010-2021 HIKARI SOFTWARE. All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>This plugin enables you to notify some customers when
produts are not more out of stock.</description>
	<files>
		<filename
plugin="waitlist_notify">waitlist_notify.php</filename>
	</files>
	<params addpath="/components/com_hikashop/params">
		<param name="period" type="text"
size="50" default="7200" label="PERIOD"
description="WAITLIST_NOTIFY_PERIOD" />
		<param name="last_cron_update" type="text"
size="50" default="1274903175"
label="HIKA_LAST_UPDATE"
description="PRODUCTS_LAST_UPDATE" />
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikashop/fields">
			<fieldset name="basic">
				<field
					name="period"
					type="text"
					label="PERIOD"
					size="50"
					default="7200"
					description="WAITLIST_NOTIFY_PERIOD" />
				<field
					name="last_cron_update"
					type="text"
					label="HIKA_LAST_UPDATE"
					size="50"
					default="1274903175"
					description="PRODUCTS_LAST_UPDATE" />
			</fieldset>
		</fields>
	</config>
</extension>
PK�,�[�#o,,
index.htmlnu�[���PK�,�[]K_��fwaitlist_notify.phpnu�[���PK�,�[��ySwaitlist_notify.xmlnu�[���PK��