id: 81 name: getMembershipData description: 'Snippet to get permission of User to edit/create Calcs' category: knit properties: 'a:0:{}' ----- /** * getMembershipData snippet for knit extra * * Copyright 2021 by Iris Hammer iris.hammer@justknit.de * Created on 10-13-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 get permission of User to edit/create Calcs * * Variables * --------- * @var $modx modX * @var $scriptProperties array * * @package knit **/ $output = ''; $config =& $scriptProperties; $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 ''; $modx->lexicon->load('knit:default'); $loggedIn = $modx->user->hasSessionContext($modx->context->get('key')); $email = isset($_GET['email']) && !empty($_GET['email']) ? $_GET['email'] : ''; //echo '
' . $email . ''; $email = urldecode($email); //echo 'decode:
' . $email . ''; //echo 'encode:
' . urlencode($email) . ''; if ($loggedIn) { $user = $modx->getObject('modUser', array('id' => $modx->user->get('id'))); } else if ($email !=='') { $user = $modx->getObject('modUser', array('username' => $email)); } else { return ''; } $output = $user->toArray(); //echo '
' . print_r($output, 1) . ''; $modx->setPlaceholders($output); $profile = $modx->getObject('modUserProfile',array('internalKey' => $user->get('id'))); $output = $profile->toArray(); //echo '
' . print_r($output, 1) . ''; $modx->setPlaceholders($output); $subscribermeta = $modx->getObject('JustKnitSubscriberMeta',array('subscriber_id' => $user->get('id'))); $output = $subscribermeta->toArray(); //echo '
' . print_r($output, 1) . ''; $modx->setPlaceholders($output); $subscription = $modx->getObject('JustKnitSubscription',array('subscriber_id' => $user->get('id'), 'order_id' => $subscribermeta->get('active_order'))); $output = $subscription->toArray(); //echo '
' . print_r($output, 1) . ''; $modx->setPlaceholders($output); $modx->setPlaceholder('loggedIn',$loggedIn); $properties = $_GET; $modx->log( modX::LOG_LEVEL_ERROR,'[JustKnit] $properties '. print_r($properties, 1)); return '';