19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
45 function id($format =
'N')
47 return $this->getVar(
'groupid', $format);
53 function groupid($format =
'')
55 return $this->getVar(
'groupid', $format);
61 function name($format =
'')
63 return $this->getVar(
'name', $format);
69 function description($format =
'')
71 return $this->getVar(
'description', $format);
77 function group_type($format =
'')
79 return $this->getVar(
'group_type', $format);
123 $sql =
'SELECT * FROM ' . $this->db->prefix(
'groups') .
' WHERE groupid=' . $id;
127 $numrows = $this->db->getRowsNum(
$result);
130 $group->assignVars($this->db->fetchArray(
$result));
147 if (!is_a($group,
'xoopsgroup')) {
150 if (!$group->isDirty()) {
153 if (!$group->cleanVars()) {
156 foreach ($group->cleanVars as $k => $v) {
159 if ($group->isNew()) {
160 $groupid = $this->db->genId(
'group_groupid_seq');
161 $sql = sprintf(
"INSERT INTO %s (groupid, name, description, group_type) VALUES (%u, %s, %s, %s)", $this->db->prefix(
'groups'), $groupid, $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type));
163 $sql = sprintf(
"UPDATE %s SET name = %s, description = %s, group_type = %s WHERE groupid = %u", $this->db->prefix(
'groups'), $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type), $groupid);
168 if (empty($groupid)) {
169 $groupid = $this->db->getInsertId();
171 $group->assignVar(
'groupid', $groupid);
181 function delete(&$group)
186 if (!is_a($group,
'xoopsgroup')) {
189 $sql = sprintf(
"DELETE FROM %s WHERE groupid = %u", $this->db->prefix(
'groups'), $group->getVar(
'groupid'));
207 $sql =
'SELECT * FROM ' . $this->db->prefix(
'groups');
217 while ($myrow = $this->db->fetchArray(
$result)) {
219 $group->assignVars($myrow);
223 $ret[$myrow[
'groupid']] = & $group;
290 $sql =
'SELECT * FROM ' . $this->db->prefix(
'groups_users_link') .
' WHERE linkid=' . $id;
294 $numrows = $this->db->getRowsNum(
$result);
297 $mship->assignVars($this->db->fetchArray(
$result));
314 if (!is_a($mship,
'xoopsmembership')) {
317 if (!$mship->isDirty()) {
320 if (!$mship->cleanVars()) {
323 foreach ($mship->cleanVars as $k => $v) {
326 if ($mship->isNew()) {
327 $linkid = $this->db->genId(
'groups_users_link_linkid_seq');
328 $sql = sprintf(
"INSERT INTO %s (linkid, groupid, uid) VALUES (%u, %u, %u)", $this->db->prefix(
'groups_users_link'), $linkid, $groupid,
$uid);
330 $sql = sprintf(
"UPDATE %s SET groupid = %u, uid = %u WHERE linkid = %u", $this->db->prefix(
'groups_users_link'), $groupid,
$uid, $linkid);
335 if (empty($linkid)) {
336 $linkid = $this->db->getInsertId();
338 $mship->assignVar(
'linkid', $linkid);
348 function delete(&$mship)
353 if (!is_a($mship,
'xoopsmembership')) {
357 $sql = sprintf(
"DELETE FROM %s WHERE linkid = %u", $this->db->prefix(
'groups_users_link'), $groupm->getVar(
'linkid'));
375 $sql =
'SELECT * FROM ' . $this->db->prefix(
'groups_users_link');
385 while ($myrow = $this->db->fetchArray(
$result)) {
387 $mship->assignVars($myrow);
391 $ret[$myrow[
'linkid']] = & $mship;
406 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix(
'groups_users_link');
414 list ($count) = $this->db->fetchRow(
$result);
426 $sql =
'DELETE FROM ' . $this->db->prefix(
'groups_users_link');
447 $sql =
'SELECT groupid FROM ' . $this->db->prefix(
'groups_users_link') .
' WHERE uid=' . intval(
$uid);
452 while ($myrow = $this->db->fetchArray(
$result)) {
453 $ret[] = $myrow[
'groupid'];
471 $sql =
'SELECT uid FROM ' . $this->db->prefix(
'groups_users_link') .
' WHERE groupid=' . intval($groupid);
476 while ($myrow = $this->db->fetchArray(
$result)) {
477 $ret[] = $myrow[
'uid'];