Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Sentinel-7 / delete_old_sessions.php
Created March 31, 2021 07:23 — forked from andronex/delete_old_sessions.php
Удаление старых сессий в таблице MODX посредством плагина, а не настройками PHP.
<?php
/**
на событие OnMODXInit
*/
$rand = rand(1, 1000);
if ($rand === 1) {
$gcMaxlifetime = (integer) $modx->getOption('session_gc_maxlifetime', null, @ini_get('session.gc_maxlifetime'), true);
$access = time() - $gcMaxlifetime;
$modx->exec("
DELETE FROM {$modx->getTableName('modSession')} WHERE `access` < {$access};
<?php
/**
Класс оплаты в кредит или рассрочку для Тинькофф
*/
require_once MODX_CORE_PATH . 'components/minishop2/model/minishop2/mspaymenthandler.class.php';
class Tinkoff extends msPaymentHandler implements msPaymentInterface{
public $demo;
//плагин на событие msOnBeforeAddToCart.
$cartArray = $cart->get(); // Массив корзины
$cartStatus = $cart->status(); // Состояние корзины
$totalCount = $cartStatus['total_count']; // Общее количество товаров в корзине
foreach ($cartArray as &$cartProduct) { // Обрабатываем все товары корзины
if ($product = $modx->getObject('msProduct', $cartProduct['id'])) { // Получаем объект товара по его ID в корзине
$quanity = $product->get('count_prod)';
$cartQuantity = $cartProduct["count"];
if($cartQuantity > $quanity){
$cartProduct['count'] = $quanity;
@Sentinel-7
Sentinel-7 / createUser.php
Created February 12, 2021 15:48 — forked from andronex/createUser.php
Создание юзера и добавление его в группу (hook для FormIt MODX Revolution) - 2 способа + отдельным файлом с запросом Ajax
<?php
$allFormFields = $hook->getValues();
if(is_array($allFormFields)){
foreach($allFormFields as $k => $v){
if (filter_var($v, FILTER_VALIDATE_EMAIL)) {
$mail = trim($v);
}
}
if($mail){
@Sentinel-7
Sentinel-7 / getViewed.php
Last active December 29, 2020 16:51 — forked from shvind/gist:8273223
getViewed - Сниппет вывода просмотренных товаров для minishop2
<?php
$id = $modx->resource->id;
$tpls = explode(',', $modx->getOption('ms2_template_product_default'));
if (!isset($limit)) {$limit = 10;}
if (!isset($tpl)) {$tpl = 'tpl.msProducts.row';}
// Вносим ID просмотренных товаров
if (in_array($modx->resource->template, $tpls)) {
if (!isset($_SESSION['viewed'])) {
@Sentinel-7
Sentinel-7 / taggercustomfilter.class.php
Created December 16, 2020 19:33 — forked from sheronov/taggercustomfilter.class.php
Интеграция компонента Tagger с фильтрами в mFilter2 (компонент mSearch2) - Расширение класса фильтрации через системную настройку mse2_filters_handler_class
<?php
class taggerCustomFilter extends mse2FiltersHandler {
/**
* Retrieves values from Tagger table
*
* @param array $fields
* @param array $ids
*
* @return array
@Sentinel-7
Sentinel-7 / plugin.php
Created August 4, 2020 10:34 — forked from ig0r74/plugin.php
MODX убрать все type="text/javascript"
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$output = &$modx->resource->_output; // перехватываем содержимое страницы
$output = str_replace(' type="text/javascript"',"",$output);
break;
}
@Sentinel-7
Sentinel-7 / mfilter2_more_button.js
Last active August 4, 2020 10:31 — forked from ig0r74/mfilter2_more_button.js
MODX mFilter2 одновременное использование стандартной пагинации и подгрузки кнопкой
$('.btn_more_custom').click(function() {
var href = $('.mse2_pagination .page-item.active').next('.page-item').find('.page-link').attr('href');
if (typeof href !== "undefined") {
mSearch2.addPage();
}
});
$(document).on('mse2_load', function(e, data) {
if (typeof $('.mse2_pagination .page-item.active').next('.page-item').next('.page-item').find('.page-link').attr('href') === "undefined") {
$('.btn_more_custom').hide();
@Sentinel-7
Sentinel-7 / LoadLexicon.php
Created August 4, 2020 10:30 — forked from ig0r74/LoadLexicon.php
Localizator подгрузка лексиконов для mFilter2
<?php
$eventName = $modx->event->name;
switch($eventName) {
// case 'OnWebPageInit':
// if ($modx->context->get('key') == 'mgr') {return;}
// $modx->lexicon->load($modx->cultureKey . ':minishop2:default');
// break;
case 'OnParseDocument':
if ($modx->context->get('key') == 'mgr') {return;}
@Sentinel-7
Sentinel-7 / client_config
Created July 25, 2020 15:50 — forked from qwertik17/client_config
Add groups & fields for MODx ClientConfig
<?php
//СОЗДАНИЕ ИЛИ ОБНОВЛЕНИЕ ГРУПП
$groups = array(
array('id' => 1,'sortorder' => 1,'label' => 'Общие'),
array('id' => 2,'sortorder' => 2,'label' => 'Почта'),
array('id' => 3,'sortorder' => 3,'label' => 'Политика и куки'),
array('id' => 4,'sortorder' => 4,'label' => 'Социальные сети'),
);
foreach ($groups as $group)