id: 78 name: testKnit description: 'Snippet to test the new classes' category: knit properties: 'a:0:{}' ----- /** * testKnit snippet for knit extra * * Copyright 2021 by Iris Hammer iris.hammer@justknit.de * Created on 10-04-2021 * * knit 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 2 of the License, or (at your option) any later * version. * * knit 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 * knit; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA * * @package knit */ /** * Description * ----------- * Snippet to test the new classes * * Variables * --------- * @var $modx modX * @var $scriptProperties array * * @package knit **/ $knit = $modx->getService('knit','Knit',$modx->getOption('knit.core_path',null,$modx->getOption('core_path').'components/knit/').'model/knit/',$scriptProperties); if (!($knit instanceof Knit)) return ''; /* setup default properties */ $tpl = $modx->getOption('tpl',$scriptProperties,'rowTpl'); $sort = $modx->getOption('sort',$scriptProperties,'last_name'); $dir = $modx->getOption('dir',$scriptProperties,'ASC'); //$calcs = $modx->getCollection('JustKnitCalcs'); $c = $modx->newQuery('JustKnitSubscriberMeta'); $c->sortby($sort,$dir); $subscribers = $modx->getCollection('JustKnitSubscriberMeta',$c); $output = ''; //$output = count($subscribers); foreach ($subscribers as $subscriber) { $subscriberArray = $subscriber->toArray(); $output .= $knit->getChunk($tpl,$subscriberArray); } $aboObj = $modx->getObject('modUserGroupSetting', array('namespace' => 'knit', 'group' => 3, 'key' => 'product_duration')); if ($aboObj) { $aboArr = $aboObj->toArray(); $duration = $aboArr['value']; $blockedafter = strtotime(date("Y-m-d") .'+'.$duration); $deletedafter = strtotime(date("Y-m-d") .'+'.$duration.'+1month'); } echo time().' val '.$duration.' block '.$blockedafter.' del '. $deletedafter. ' 1636262531'; //$output = count($subscribers); return $output;