* @since Beta 4.0 **/ class groups extends admin { /** * Group Controls * * @author Jason Warner * @since Beta 4.0 * @return string HTML **/ function execute() { $this->set_title('Group Controls'); if (!isset($this->get['s'])) { $this->get['s'] = ''; } switch ($this->get['s']) { case 'add': $this->tree($this->lang->groups_create); if (!isset($this->post['submit'])) { return $this->message($this->lang->groups_create, "
{$this->lang->groups_create_new} {$this->lang->groups_based_on} " . $this->list_groups(USER_MEMBER) . "
"); } else { if (!isset($this->post['user_group'])) { $this->post['user_group'] = USER_MEMBER; } if (!isset($this->post['group_name']) || (trim($this->post['group_name']) == '')) { return $this->message($this->lang->groups_create, $this->lang->groups_no_name); } $copying = $this->db->fetch('SELECT group_perms FROM groups WHERE group_id=%d', $this->post['user_group']); $this->db->query("INSERT INTO groups (group_name, group_perms) VALUES ('%s', '%s')", $this->format($this->post['group_name'], FORMAT_HTMLCHARS), $copying['group_perms']); return $this->message($this->lang->groups_create, $this->lang->groups_created); } break; case 'edit': $this->tree($this->lang->groups_edit); if (!isset($this->post['submit'])) { if (!isset($this->post['choose_group'])) { return $this->message($this->lang->groups_edit, "
{$this->lang->groups_to_edit}: " . $this->list_groups(-1, 'group') . "

"); } else { if (!isset($this->post['group'])) { return $this->message($this->lang->groups_edit, $this->lang->groups_no_group); } $this->post['group'] = intval($this->post['group']); $old = $this->db->fetch('SELECT group_name, group_type FROM groups WHERE group_id=%d', $this->post['group']); if ($old['group_type'] == '') { $old['group_type'] = 'CUSTOM'; } $oldGroupName = $this->format($old['group_name'], FORMAT_HTMLCHARS); return eval($this->template('ADMIN_GROUP_EDIT')); } } else { if (!isset($this->post['group'])) { return $this->message($this->lang->groups_edit, $this->lang->groups_no_group); } $this->post['group'] = intval($this->post['group']); if (!isset($this->post['group_name']) || (trim($this->post['group_name']) == '')) { return $this->message($this->lang->groups_edit, $this->lang->groups_no_name); } $this->db->query("UPDATE groups SET group_name='%s' WHERE group_id=%d", $this->format($this->post['group_name'], FORMAT_HTMLCHARS), $this->post['group']); return $this->message($this->lang->groups_edit, $this->lang->groups_edited); } break; case 'delete': $this->tree($this->lang->groups_delete); $test = $this->db->fetch("SELECT group_id FROM groups WHERE group_type=''"); if (!$test) { return $this->message($this->lang->groups_delete, $this->lang->groups_no_delete); } if (!isset($this->post['submit'])) { return $this->message($this->lang->groups_delete, "
{$this->lang->groups_the} " . $this->list_groups(-1, 'old_group', true) . " {$this->lang->groups_will_be}
{$this->lang->groups_will_become} " . $this->list_groups(USER_MEMBER, 'new_group') . "




{$this->lang->groups_only_custom}

"); } else { if (!isset($this->post['old_group']) || !isset($this->post['confirm'])) { return $this->message($this->lang->groups_delete, $this->lang->groups_no_action); } if (!isset($this->post['new_group'])) { $this->post['new_group'] = USER_MEMBER; } $this->db->query("DELETE FROM groups WHERE group_id=%d AND group_type=''", $this->post['old_group']); $this->db->query('UPDATE users SET user_group=%d WHERE user_group=%d', $this->post['new_group'], $this->post['old_group']); return $this->message($this->lang->groups_delete, $this->lang->groups_deleted); } break; } } } ?>