Fix wrong uses of dba::select
- Improve negative conditions
This commit is contained in:
parent
4fe8dab08d
commit
3ea9060259
|
@ -209,7 +209,7 @@ class Group extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function addMember($gid, $cid)
|
public static function addMember($gid, $cid)
|
||||||
{
|
{
|
||||||
if (!($gid && $cid)) {
|
if (!$gid || !$cid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +233,7 @@ class Group extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function removeMember($gid, $cid)
|
public static function removeMember($gid, $cid)
|
||||||
{
|
{
|
||||||
if (!$gid) {
|
if (!$gid || !$cid) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($gid && $cid)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +271,7 @@ class Group extends BaseObject
|
||||||
*/
|
*/
|
||||||
public static function expand($group_ids, $check_dead = false, $use_gcontact = false)
|
public static function expand($group_ids, $check_dead = false, $use_gcontact = false)
|
||||||
{
|
{
|
||||||
if (!(is_array($group_ids) && count($group_ids))) {
|
if (!is_array($group_ids) || !count($group_ids)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,12 +288,10 @@ class Group extends BaseObject
|
||||||
$stmt = dba::select('group_member', ['contact-id'], $condition_array);
|
$stmt = dba::select('group_member', ['contact-id'], $condition_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = array();
|
$return = [];
|
||||||
if (DBM::is_result($stmt)) {
|
|
||||||
while($group_member = dba::fetch($stmt)) {
|
while($group_member = dba::fetch($stmt)) {
|
||||||
$return[] = $group_member['contact-id'];
|
$return[] = $group_member['contact-id'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($check_dead && !$use_gcontact) {
|
if ($check_dead && !$use_gcontact) {
|
||||||
require_once 'include/acl_selectors.php';
|
require_once 'include/acl_selectors.php';
|
||||||
|
@ -318,7 +312,7 @@ class Group extends BaseObject
|
||||||
{
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$groups = dba::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name' => 'ASC']]);
|
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name' => 'ASC']]);
|
||||||
|
|
||||||
$display_groups = [
|
$display_groups = [
|
||||||
[
|
[
|
||||||
|
@ -327,7 +321,7 @@ class Group extends BaseObject
|
||||||
'selected' => ''
|
'selected' => ''
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
foreach ($groups as $group) {
|
while ($group = dba::fetch($stmt)) {
|
||||||
$display_groups[] = [
|
$display_groups[] = [
|
||||||
'name' => $group['name'],
|
'name' => $group['name'],
|
||||||
'id' => $group['id'],
|
'id' => $group['id'],
|
||||||
|
@ -377,15 +371,14 @@ class Group extends BaseObject
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$groups = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name' => 'ASC']]);
|
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name' => 'ASC']]);
|
||||||
|
|
||||||
$member_of = array();
|
$member_of = array();
|
||||||
if ($cid) {
|
if ($cid) {
|
||||||
$member_of = self::getByContactIdForUserId(local_user(), $cid);
|
$member_of = self::getByContactIdForUserId(local_user(), $cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBM::is_result($groups)) {
|
while ($group = dba::fetch($stmt)) {
|
||||||
foreach ($groups as $group) {
|
|
||||||
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
||||||
|
|
||||||
if ($editmode == 'full') {
|
if ($editmode == 'full') {
|
||||||
|
@ -407,7 +400,6 @@ class Group extends BaseObject
|
||||||
'ismember' => in_array($group['id'], $member_of),
|
'ismember' => in_array($group['id'], $member_of),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$tpl = get_markup_template('group_side.tpl');
|
$tpl = get_markup_template('group_side.tpl');
|
||||||
$o = replace_macros($tpl, [
|
$o = replace_macros($tpl, [
|
||||||
|
|
Loading…
Reference in a new issue