XOOPS  2.6.0
membership.php
Go to the documentation of this file.
1 <?php
23 
32 {
36  public function __construct()
37  {
38  $this->initVar('linkid', XOBJ_DTYPE_INT, null, false);
39  $this->initVar('groupid', XOBJ_DTYPE_INT, null, false);
40  $this->initVar('uid', XOBJ_DTYPE_INT, null, false);
41  }
42 
48  public function id($format = 'n')
49  {
50  return $this->linkid($format);
51  }
52 
58  public function linkid($format = '')
59  {
60  return $this->getVar('linkid', $format);
61  }
62 
68  public function uid($format = '')
69  {
70  return $this->getVar('uid', $format);
71  }
72 
73 }
74 
86 {
92  public function __construct(Connection $db = null)
93  {
94  parent::__construct($db, 'groups_users_link', 'XoopsMembership', 'linkid', 'groupid');
95  }
96 
104  public function getGroupsByUser($uid)
105  {
106  $ret = array();
107  $qb = $this->db2->createXoopsQueryBuilder();
108  $eb = $qb->expr();
109  $qb ->select('groupid')
110  ->fromPrefix('groups_users_link', 'g')
111  ->where($eb->eq('g.uid', ':uid'))
112  ->setParameter(':uid', $uid, \PDO::PARAM_INT);
113  $result = $qb->execute();
114  while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
115  $ret[] = $myrow['groupid'];
116  }
117 
118  return $ret;
119  }
120 
130  public function getUsersByGroup($groupid, $limit = 0, $start = 0)
131  {
132  $ret = array();
133  $qb = $this->db2->createXoopsQueryBuilder();
134  $eb = $qb->expr();
135  $qb ->select('uid')
136  ->fromPrefix('groups_users_link', 'g')
137  ->where($eb->eq('g.groupid', ':gid'))
138  ->setParameter(':gid', $groupid, \PDO::PARAM_INT);
139  if ($limit!=0 || $start!=0) {
140  $qb->setFirstResult($start)
141  ->setMaxResults($limit);
142  }
143  $result = $qb->execute();
144  while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
145  $ret[] = $myrow['uid'];
146  }
147 
148  return $ret;
149  }
150 }
id($format= 'n')
Definition: membership.php:48
$result
Definition: pda.php:33
uid($format= '')
Definition: membership.php:68
linkid($format= '')
Definition: membership.php:58
getVar($key, $format= 's')
if(!$xoops->isUser()) $uid
Definition: index.php:31
$limit
Definition: findusers.php:202
__construct(Connection $db=null)
Definition: membership.php:92
$start
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
getUsersByGroup($groupid, $limit=0, $start=0)
Definition: membership.php:130