insideManager()) { return ''; # don't go any further when inside manager } if (!isset ($groups)) { return $debug ? '
Error: No Group Specified
' : ''; } if (!isset ($chunk)) { return $debug ? 'Error: No Chunk Specified
' : ''; } # check if default is set, if not sets value $default = (isset($default))? $default : ''; # turn comma-delimited list of groups into an array $groups = explode(',', $groups); if (!class_exists('MemberCheck')) { class MemberCheck { var $allGroups = NULL; var $debug; function getInstance($debug) { static $instance; if (!isset ($instance)) { $instance = new MemberCheck($debug); } return $instance; } function MemberCheck($debug = false) { global $modx; $this->debug = $debug; if ($debug) { $this->allGroups = array (); $tableName = $modx->getFullTableName('webgroup_names'); $sql = "SELECT name FROM $tableName"; if ($rs = $modx->db->query($sql)) { while ($row = $modx->db->getRow($rs)) { array_push($this->allGroups, stripslashes($row['name'])); } } } } function isValidGroup($groupName) { $isValid = !(array_search($groupName, $this->allGroups) === false); return $isValid; } function getMemberChunk(& $groups, $chunk, $default) { global $modx; $o = ''; if (is_array($groups)) { for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); if ($this->debug) { if (!$this->isValidGroup($groups[$i])) { return "The group " . $groups[$i] . " could not be found...
"; } } } $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chunk); $defaultcheck = $modx->getChunk($default); if ( $check ) { $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "The chunk $chunk not found...
" : ''; } else { if ($defaultcheck && (strlen($default) >= 1)) { $o .= ($defaultcheck) ? $defaultcheck : ''; } if (!$defaultcheck && (strlen($default) >= 1)) { $o .= $this->debug ? "The default chunk $default not found...
" : ''; } } } else { $o .= "No valid group names were specified!
"; } return $o; } } } $memberCheck = MemberCheck :: getInstance($debug); if (!isset ($ph)) { return $memberCheck->getMemberChunk($groups, $chunk, $default); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk, $default)); return ''; } ?>