Created
March 21, 2020 01:14
-
-
Save touol/751680730dbec7e44e2d6d896dabc337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var pdoFetch $pdoFetch */ | |
$pdoFetch = $modx->getService('pdoFetch'); | |
$pdoFetch->setConfig($scriptProperties); | |
$pdoFetch->addTime('pdoTools loaded'); | |
$allow_res_groups = $modx->getOption("allow_res_groups"); | |
$all = false; | |
$where = []; | |
if(!empty($allow_res_groups)){ | |
$allow_res_groups = explode(",",$allow_res_groups); | |
foreach($allow_res_groups as $k=>$arg){ | |
if($arg == "all"){ | |
$all = true; | |
unset($allow_res_groups[$k]); | |
} | |
} | |
$where = [ | |
'modResourceGroup.id:IN'=>$allow_res_groups, | |
]; | |
}else{ | |
$all = true; | |
} | |
$default = [ | |
'class'=>'modResourceGroup', | |
'where'=>$where, | |
'select'=>[ | |
'modResourceGroup'=>'id,name', | |
], | |
'return'=>'data', | |
'limit'=>0, | |
'showLog'=>0, | |
]; | |
$pdoFetch->config = array_merge($pdoFetch->config,$default); | |
$res_groups1 = $pdoFetch->run(); | |
$tid = (int)$_GET['tid']; | |
$res_groups = []; | |
if($all){ | |
$res_groups[0] = ['id'=>0, 'name'=>"Всем"]; | |
} | |
foreach($res_groups1 as $res_group){ | |
$res_group['selected'] = ""; | |
if($tid){ | |
if($rgr = $modx->getObject('modResourceGroupResource',[ | |
'document_group'=>$res_group['id'], | |
'document'=>$tid, | |
])){ | |
$res_group['selected'] = "selected"; | |
$all = false; | |
} | |
} | |
$res_groups[] = $res_group; | |
} | |
if($all){ | |
$res_groups[0]['selected'] = "selected"; | |
} | |
return $pdoFetch->getChunk('ticketResourceGroup',['res_groups'=>$res_groups]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment