use dba;
require_once 'boot.php';
+require_once 'include/dba.php';
require_once 'include/text.php';
/**
// all the old members are gone, but the group remains so we don't break any security
// access lists. What we're doing here is reviving the dead group, but old content which
// was restricted to this group may now be seen by the new group members.
- $group = dba::select('group', ['deleted'], ['id' => $gid], ['limit' => 1]);
+ $group = dba::selectFirst('group', ['deleted'], ['id' => $gid]);
if (DBM::is_result($group) && $group['deleted']) {
dba::update('group', ['deleted' => 0], ['gid' => $gid]);
notice(t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
* @param int $cid
* @return array
*/
- private static function getIdsByContactId($cid)
+ public static function getIdsByContactId($cid)
{
$condition = ['contact-id' => $cid];
$stmt = dba::select('group_member', ['gid'], $condition);
return false;
}
- $group = dba::select('group', ['id'], ['uid' => $uid, 'name' => $name], ['limit' => 1]);
+ $group = dba::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
if (DBM::is_result($group)) {
return $group['id'];
}
/**
* @brief Mark a group as deleted
*
- * @param type $gid
+ * @param int $gid
* @return boolean
*/
public static function remove($gid) {
return false;
}
+ $group = dba::selectFirst('group', ['uid'], ['gid' => $gid]);
+ if (!DBM::is_result($group)) {
+ return false;
+ }
+
// remove group from default posting lists
- $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
if (DBM::is_result($user)) {
$change = false;
}
if ($change) {
- dba::update('user', $user, ['uid' => $uid]);
+ dba::update('user', $user, ['uid' => $group['uid']]);
}
}
*
* @deprecated Use Group::remove instead
*
- * @param type $uid
- * @param type $name
- * @return type
+ * @param int $uid
+ * @param string $name
+ * @return bool
*/
public static function removeByName($uid, $name) {
$return = false;
$label = t('Default privacy group for new contacts');
}
- $o = replace_macros(get_markup_template('group_selection.tpl'), array(
+ $o = replace_macros(get_markup_template('group_selection.tpl'), [
'$label' => $label,
'$groups' => $display_groups
- ));
+ ]);
return $o;
}
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
- $member_of = array();
+ $member_of = [];
if ($cid) {
$member_of = self::getIdsByContactId($cid);
}