function getGroupName($gid) { global $db; $gid = getGroupId($gid); $gid = sotf_Utils::magicQuotes($gid); $id = $db->getOne("SELECT name FROM sotf_groups WHERE id = '{$gid}'"); if (DB::isError($id)) { raiseError($id); } return $id; }
function updateGroup($groupId, $groupName, $description, $type, $db) { // creates a group and adds the current user to it strip_tags($groupName); strip_tags($description); strip_tags($type); $qString = 'UPDATE groups SET name = :name, description = :description, projectType = :type WHERE id = :groupId'; $stm = $db->prepare($qString); if ($stm->execute(array(':name' => $groupName, ':description' => $description, ':type' => $type, ':groupId' => $groupId))) { if (addToGroup($userId, $db, getGroupId($groupName, $db), true)) { echo "<meta http-equiv='REFRESH' content='0;url=/?page=group'>"; } else { echo 'couldnt add to group!'; } } else { print_r($stm->errorInfo()); } }
if (!empty($userGroup)) { $grps = $modx->getCollection('modUserGroup'); foreach ($grps as $grp) { /** @var $grp modUserGroup */ if ($grp->get('id') == $userGroup) { continue; } $temp[] = $grp->get('id'); } if (!empty($temp)) { $props['exclude'] = implode(',', $temp); } } elseif (!empty($exGroups)) { $exGroups = explode(',', $exGroups); foreach ($exGroups as $exGroup) { $v = getGroupId($exGroup); if (!empty($v)) { $temp[] = $v; } } if (!empty($temp)) { $props['exclude'] = implode(',', $temp); } } unset($exGroups, $exGroup, $grps, $grp, $v, $temp); } /* @var $response modProcessorResponse */ $response = $modx->runProcessor($action, $props); if ($response->isError()) { if ($response->hasFieldErrors()) { $fieldErrors = $response->getAllErrors();
$defaultCommands = array_unique(array_merge($defaultCommands, array_keys($commandPriceIni), array_values($commandAliasIni), array_keys($commandCooldown))); sort($defaultCommands); foreach ($defaultCommands as $command) { if (array_key_exists($command, $commandAliasIni) || array_key_exists($command, $customCommandsIni)) { continue; } $commandAliases = []; foreach ($commandAliasIni as $alias => $originalCommand) { if ($originalCommand == $command) { $commandAliases[] = '!' . $alias; } } if (array_key_exists($command, $commandPermIni)) { $perm = $groups[getGroupId($commandPermIni[$command])]; } elseif (array_key_exists($command . '_recursive', $commandPermIni)) { $perm = $groups[getGroupId($commandPermIni[$command . '_recursive'])] . '+'; } else { $perm = '(not set in permcom)'; } if (array_key_exists($command, $commandPriceIni) && $commandPriceIni[$command] != '') { if (intval($commandPriceIni[$command]) < 1 || intval($commandPriceIni[$command]) > 1) { $price = $commandPriceIni[$command] . ' ' . $pointNames[0]; } else { $price = $commandPriceIni[$command] . ' ' . $pointNames[1]; } } else { $price = '0 ' . $pointNames[0]; } if (array_key_exists($command, $commandCooldown)) { $cooldown = $functions->secondsToTime(intval($commandCooldown[$command])); } else {
function testGetGroupId() { include 'groupHandler.php'; echo getGroupId('Group Name', $db); }
function process_following_group($con, $uiid, $groupname) { $groupid = getGroupId($con, $groupname); if ($groupid == 0) { return "Please input group name."; } $sql = "SELECT id FROM bpgroupfollow where uiid=" . $uiid . " and groupid=" . $groupid; if (!($result = mysqli_query($con, $sql))) { echo "Error description: " . mysqli_error($con); } $id = 0; $responseMessage = ""; if ($row = $result->fetch_assoc()) { $id = $row["id"]; } if ($id > 0) { return "You have already followed the group."; } $sql = "INSERT INTO bpgroupfollow ( uiid, groupid ) VALUES ('" . $uiid . "','" . $groupid . "' )"; if (!mysqli_query($con, $sql)) { //echo("Error description: " . mysqli_error($con)); $responseMessage = "error in follow a group: " . mysqli_error($con); } else { $responseMessage = "following group " . $groupid . " succeed."; } return $responseMessage; }
function getGroupPermissions($objectId, $gid) { global $db; $gid = getGroupId($gid); $retval = $db->getCol("SELECT p.permission FROM sotf_group_permissions u, sotf_permissions p WHERE u.object_id='{$objectId}' AND u.group_id='{$gid}' AND p.id = u.permission_id"); if (DB::isError($retval)) { raiseError($retval); } return $retval; }