id: 80 name: getPermission description: 'Snippet to get permission of User to edit/create Calcs' category: knit properties: 'a:0:{}' ----- /** * getPermission 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 ''; // $subscriber = $modx->getService('subscription','KnitSubscription',$modx->getOption('knit.core_path',null,$modx->getOption('core_path').'components/knit/').'model/knit/',$scriptProperties); $modx->lexicon->load('knit:default'); $resID = $modx->resource->get('id'); $res = $modx->getObject('modResource', array('id' => $resID)); $loggedIn = $modx->user->hasSessionContext($modx->context->get('key')); //$query->where(array('width:LIKE' => '%15%')); $c = $modx->newQuery('modUserGroup'); $c->where(array('name:LIKE' => 'jk%')); $jkGroups = $modx->getCollection('modUserGroup',$c ); /* Check for UserGroups */ if ($loggedIn) { $user = $modx->getObject('modUser', array('id' => $modx->user->get('id'))); foreach ($jkGroups as $jkGroup) { if ($user->isMember($jkGroup->get('name'))) { $_SESSION['uG'] = $jkGroup->get('name'); } } } /* set $_SESSION */ //if (!isset($_SESSION['np_doc_to_edit'])) { if ($loggedIn) { $userID = $modx->user->get('id'); // $output = $output.'user '.$userID; $user = $modx->getObject('modUser', array('id' => $userID)); $calcs = $modx->getCollection('JustKnitCalcs', array('ressource_id' => $resID, 'ccreatedby' => $userID)); foreach ($calcs as $calc) { $calcArray = $calc->toArray(); echo '
' . print_r($calcArray, 1) . '
'; $modx->toPlaceholders($calcArray,'kc-'.$calcArray['id']); $dims = $modx->getCollection('JustKnitDims', array('ressource_id' => $resID, 'calcedby' => $userID, 'calc_id' => $calcArray['id'])); foreach ($dims as $dim) { $dimArray = $dim->toArray(); echo '
' . print_r($dimArray, 1) . '
'; $modx->toPlaceholders($dimArray,'kc-'.$calcArray['id'].'.kd-'.$dimArray['id']); } } // foreach ($calcs as $key => $fields) { // } } // $output .= count($calcs); // $modx->setPlaceholders(array( 'name' => 'John', 'email' => 'jdoe@gmail.com',),'my.'); // $modx->setPlaceholder($ph, $name); $session = $_SESSION; $product = $_SESSION['modx.knit.user.config']; // die settings aus der Usergroup //echo 'modx.knit.user.config'. $product['product_name'] ; echo '
' . print_r($session, 1) . '
'; /*foreach ($session as $sess => $v) { return '
' . print_r($fields, 1) . '
'; } */ return $output;