From 4fe8dab08d246a816b20845d9675bfe6de9ed351 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Dec 2017 13:45:54 -0500 Subject: [PATCH] Remove include/group.php --- include/api.php | 1 - include/follow.php | 2 - include/group.php | 396 -------------------------------------- include/items.php | 1 - mod/contactgroup.php | 2 - mod/contacts.php | 1 - mod/dfrn_confirm.php | 1 - mod/dfrn_request.php | 1 - mod/group.php | 1 - mod/network.php | 1 - mod/nogroup.php | 1 - mod/ping.php | 1 - mod/settings.php | 2 - mod/update_display.php | 1 - mod/update_network.php | 1 - src/Model/User.php | 1 - src/Protocol/Diaspora.php | 1 - src/Worker/Delivery.php | 2 - src/Worker/Notifier.php | 2 - 19 files changed, 419 deletions(-) delete mode 100644 include/group.php diff --git a/include/api.php b/include/api.php index 70e11416da..8a29c82dd8 100644 --- a/include/api.php +++ b/include/api.php @@ -42,7 +42,6 @@ require_once 'include/html2bbcode.php'; require_once 'mod/wall_upload.php'; require_once 'mod/proxy.php'; require_once 'include/message.php'; -require_once 'include/group.php'; require_once 'include/like.php'; require_once 'include/plaintext.php'; diff --git a/include/follow.php b/include/follow.php index 539768b74c..c9e81f7b37 100644 --- a/include/follow.php +++ b/include/follow.php @@ -16,8 +16,6 @@ use Friendica\Protocol\OStatus; use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; -require_once 'include/group.php'; - function update_contact($id) { /* Warning: Never ever fetch the public key via Probe::uri and write it into the contacts. diff --git a/include/group.php b/include/group.php deleted file mode 100644 index 6e7348c4e2..0000000000 --- a/include/group.php +++ /dev/null @@ -1,396 +0,0 @@ -may apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL); - } - return true; - } - $r = dba::insert('group', array('uid' => $uid, 'name' => $name)); - $ret = $r; - } - return $ret; -} - - -function group_rmv($uid,$name) { - $ret = false; - if (x($uid) && x($name)) { - $r = q("SELECT id FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", - intval($uid), - dbesc($name) - ); - if (DBM::is_result($r)) - $group_id = $r[0]['id']; - if (! $group_id) - return false; - - // remove group from default posting lists - $r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1", - intval($uid) - ); - if ($r) { - $user_info = $r[0]; - $change = false; - - if ($user_info['def_gid'] == $group_id) { - $user_info['def_gid'] = 0; - $change = true; - } - if (strpos($user_info['allow_gid'], '<' . $group_id . '>') !== false) { - $user_info['allow_gid'] = str_replace('<' . $group_id . '>', '', $user_info['allow_gid']); - $change = true; - } - if (strpos($user_info['deny_gid'], '<' . $group_id . '>') !== false) { - $user_info['deny_gid'] = str_replace('<' . $group_id . '>', '', $user_info['deny_gid']); - $change = true; - } - - if ($change) { - q("UPDATE user SET def_gid = %d, allow_gid = '%s', deny_gid = '%s' WHERE uid = %d", - intval($user_info['def_gid']), - dbesc($user_info['allow_gid']), - dbesc($user_info['deny_gid']), - intval($uid) - ); - } - } - - // remove all members - dba::delete('group_member', array('uid' => $uid, 'pid' => $group_id)); - - // remove group - $r = q("UPDATE `group` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s'", - intval($uid), - dbesc($name) - ); - - $ret = $r; - - } - - return $ret; -} - -function group_byname($uid,$name) { - if ((! $uid) || (! strlen($name))) - return false; - $r = q("SELECT * FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", - intval($uid), - dbesc($name) - ); - if (DBM::is_result($r)) - return $r[0]['id']; - return false; -} - -function group_rmv_member($uid, $name, $member) { - $gid = group_byname($uid, $name); - - if (!$gid) { - return false; - } - - if (!($uid && $gid && $member)) { - return false; - } - - $r = dba::delete('group_member', array('uid' => $uid, 'gid' => $gid, 'contact-id' => $member)); - return $r; -} - - -function group_add_member($uid,$name,$member,$gid = 0) { - if (! $gid) - $gid = group_byname($uid,$name); - if ((! $gid) || (! $uid) || (! $member)) - return false; - - $r = q("SELECT * FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d LIMIT 1", - intval($uid), - intval($gid), - intval($member) - ); - if (DBM::is_result($r)) - return true; // You might question this, but - // we indicate success because the group member was in fact created - // -- It was just created at another time - if (! DBM::is_result($r)) { - $r = dba::insert('group_member', array('uid' => $uid, 'gid' => $gid, 'contact-id' => $member)); - } - return $r; -} - -function group_get_members($gid) { - $ret = array(); - if (intval($gid)) { - $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d AND - NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` - ORDER BY `contact`.`name` ASC ", - intval($gid), - intval(local_user()) - ); - if (DBM::is_result($r)) - $ret = $r; - } - return $ret; -} - -function group_public_members($gid) { - $ret = 0; - if (intval($gid)) { - $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d - AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", - intval($gid), - intval(local_user()), - dbesc(NETWORK_OSTATUS) - ); - if (DBM::is_result($r)) - $ret = count($r); - } - return $ret; -} - - -function mini_group_select($uid,$gid = 0, $label = "") { - - $grps = array(); - $o = ''; - - $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", - intval($uid) - ); - $grps[] = array('name' => '', 'id' => '0', 'selected' => ''); - if (DBM::is_result($r)) { - foreach ($r as $rr) { - $grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : '')); - } - - } - logger('groups: ' . print_r($grps,true)); - - if ($label == "") - $label = t('Default privacy group for new contacts'); - - $o = replace_macros(get_markup_template('group_selection.tpl'), array( - '$label' => $label, - '$groups' => $grps - )); - return $o; -} - - -/** - * @brief Create group sidebar widget - * - * @param string $every - * @param string $each - * @param string $editmode - * 'standard' => include link 'Edit groups' - * 'extended' => include link 'Create new group' - * 'full' => include link 'Create new group' and provide for each group a link to edit this group - * @param int $group_id - * @param int $cid - * @return string - */ -function group_side($every="contacts",$each="group",$editmode = "standard", $group_id = 0, $cid = 0) { - - $o = ''; - - if (! local_user()) - return ''; - - $groups = array(); - - $groups[] = array( - 'text' => t('Everybody'), - 'id' => 0, - 'selected' => (($group_id == 0) ? 'group-selected' : ''), - 'href' => $every, - ); - - - - $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", - intval($_SESSION['uid']) - ); - $member_of = array(); - if ($cid) { - $member_of = groups_containing(local_user(),$cid); - } - - if (DBM::is_result($r)) { - foreach ($r as $rr) { - $selected = (($group_id == $rr['id']) ? ' group-selected' : ''); - - if ($editmode == "full") { - $groupedit = array( - 'href' => "group/".$rr['id'], - 'title' => t('edit'), - ); - } else { - $groupedit = null; - } - - $groups[] = array( - 'id' => $rr['id'], - 'cid' => $cid, - 'text' => $rr['name'], - 'selected' => $selected, - 'href' => $each."/".$rr['id'], - 'edit' => $groupedit, - 'ismember' => in_array($rr['id'],$member_of), - ); - } - } - - - $tpl = get_markup_template("group_side.tpl"); - $o = replace_macros($tpl, array( - '$title' => t('Groups'), - 'newgroup' => (($editmode == "extended") || ($editmode == "full") ? 1 : ''), - '$editgroupstext' => t('Edit groups'), - 'grouppage' => "group/", - '$edittext' => t('Edit group'), - '$createtext' => t('Create a new group'), - '$creategroup' => t('Group Name: '), - '$form_security_token' => get_form_security_token("group_edit"), - '$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''), - '$groups' => $groups, - '$add' => t('add'), - )); - - - return $o; -} - -function expand_groups($a,$check_dead = false, $use_gcontact = false) { - if (! (is_array($a) && count($a))) - return array(); - $groups = implode(',', $a); - $groups = dbesc($groups); - - if ($use_gcontact) - $r = q("SELECT `gcontact`.`id` AS `contact-id` FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl` - WHERE `gid` IN ($groups)"); - else - $r = q("SELECT `contact-id` FROM `group_member` WHERE `gid` IN ( $groups )"); - - - $ret = array(); - if (DBM::is_result($r)) - foreach ($r as $rr) - $ret[] = $rr['contact-id']; - if ($check_dead && !$use_gcontact) { - require_once('include/acl_selectors.php'); - $ret = prune_deadguys($ret); - } - return $ret; -} - - -function member_of($c) { - - $r = q("SELECT `group`.`name`, `group`.`id` FROM `group` INNER JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ", - intval($c) - ); - - return $r; - -} - -function groups_containing($uid,$c) { - - $r = q("SELECT `gid` FROM `group_member` WHERE `uid` = %d AND `group_member`.`contact-id` = %d ", - intval($uid), - intval($c) - ); - - $ret = array(); - if (DBM::is_result($r)) { - foreach ($r as $rr) { - $ret[] = $rr['gid']; - } - } - - return $ret; -} -/** - * @brief count unread group items - * - * Count unread items of each groups - * - * @return array - * 'id' => group id - * 'name' => group name - * 'count' => counted unseen group items - * - */ -function groups_count_unseen() { - - $r = q("SELECT `group`.`id`, `group`.`name`, - (SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`) - WHERE `uid` = %d AND `unseen` AND - `contact-id` IN (SELECT `contact-id` FROM `group_member` - WHERE `group_member`.`gid` = `group`.`id` AND `group_member`.`uid` = %d)) AS `count` - FROM `group` WHERE `group`.`uid` = %d;", - intval(local_user()), - intval(local_user()), - intval(local_user()) - ); - - return $r; -} - -/** - * @brief Returns the default group for a given user and network - * - * @param int $uid User id - * @param string $network network name - * - * @return int group id - */ -function get_default_group($uid, $network = "") { - - $default_group = 0; - - if ($network == NETWORK_OSTATUS) - $default_group = PConfig::get($uid, "ostatus", "default_group"); - - if ($default_group != 0) - return $default_group; - - $g = q("SELECT `def_gid` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid)); - if ($g && intval($g[0]["def_gid"])) - $default_group = $g[0]["def_gid"]; - - return $default_group; -} diff --git a/include/items.php b/include/items.php index 834cf888a1..9f3f4ab30e 100644 --- a/include/items.php +++ b/include/items.php @@ -29,7 +29,6 @@ require_once 'include/plaintext.php'; require_once 'include/feed.php'; require_once 'mod/share.php'; require_once 'include/enotify.php'; -require_once 'include/group.php'; function construct_verb($item) { if ($item['verb']) { diff --git a/mod/contactgroup.php b/mod/contactgroup.php index 887cf4dbaa..96b65fd403 100644 --- a/mod/contactgroup.php +++ b/mod/contactgroup.php @@ -2,8 +2,6 @@ use Friendica\App; use Friendica\Database\DBM; - -require_once('include/group.php'); use Friendica\Model\Contact; use Friendica\Model\Group; diff --git a/mod/contacts.php b/mod/contacts.php index 3bb7b4f82c..fd1d6776cc 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -32,7 +32,6 @@ function contacts_init(App $a) { } } - require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if ($_GET['nets'] == "all") { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index f4d5c1b867..112ee34ab3 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -31,7 +31,6 @@ use Friendica\Network\Probe; use Friendica\Protocol\Diaspora; require_once 'include/enotify.php'; -require_once 'include/group.php'; function dfrn_confirm_post(App $a, $handsfree = null) { diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index eef2deb133..ec67586561 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -21,7 +21,6 @@ use Friendica\Model\User; use Friendica\Network\Probe; require_once 'include/enotify.php'; -require_once 'include/group.php'; function dfrn_request_init(App $a) { diff --git a/mod/group.php b/mod/group.php index 545ccea2c7..ba7c24c56a 100644 --- a/mod/group.php +++ b/mod/group.php @@ -15,7 +15,6 @@ use Friendica\Model\Group; function group_init(App $a) { if (local_user()) { - require_once 'include/group.php'; $a->page['aside'] = Group::sidebarWidget('contacts', 'group', 'extended', (($a->argc > 1) ? intval($a->argv[1]) : 0)); } } diff --git a/mod/network.php b/mod/network.php index e1e98a2d2d..552625c2af 100644 --- a/mod/network.php +++ b/mod/network.php @@ -13,7 +13,6 @@ use Friendica\Model\Contact; use Friendica\Model\Group; require_once 'include/conversation.php'; -require_once 'include/group.php'; require_once 'include/contact_widgets.php'; require_once 'include/items.php'; require_once 'include/acl_selectors.php'; diff --git a/mod/nogroup.php b/mod/nogroup.php index 72cf037304..d80b6d3dbd 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -15,7 +15,6 @@ function nogroup_init(App $a) return; } - require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (! x($a->page, 'aside')) { diff --git a/mod/ping.php b/mod/ping.php index 59f6589eb2..930ed54ff9 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -15,7 +15,6 @@ use Friendica\Util\XML; require_once 'include/datetime.php'; require_once 'include/bbcode.php'; -require_once 'include/group.php'; require_once 'mod/proxy.php'; require_once 'include/enotify.php'; diff --git a/mod/settings.php b/mod/settings.php index 764356b4c4..e3d650e089 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -14,8 +14,6 @@ use Friendica\Model\Group; use Friendica\Model\User; use Friendica\Protocol\Email; -require_once 'include/group.php'; - function get_theme_config_file($theme) { $a = get_app(); $base_theme = $a->theme_info['extends']; diff --git a/mod/update_display.php b/mod/update_display.php index b9294d7558..00109202ed 100644 --- a/mod/update_display.php +++ b/mod/update_display.php @@ -5,7 +5,6 @@ use Friendica\App; use Friendica\Core\PConfig; -require_once("include/group.php"); require_once "mod/display.php"; function update_display_content(App $a) diff --git a/mod/update_network.php b/mod/update_network.php index 25b87bc2ae..3a5741f6ac 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -5,7 +5,6 @@ use Friendica\App; use Friendica\Core\PConfig; -require_once("include/group.php"); require_once "mod/network.php"; function update_network_content(App $a) diff --git a/src/Model/User.php b/src/Model/User.php index 5a3200b024..25aa2401e7 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -21,7 +21,6 @@ use dba; require_once 'boot.php'; require_once 'include/crypto.php'; require_once 'include/enotify.php'; -require_once 'include/group.php'; require_once 'include/network.php'; require_once 'library/openid.php'; require_once 'include/pgettext.php'; diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 3ef55443c2..b56f59dad6 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -29,7 +29,6 @@ use SimpleXMLElement; require_once 'include/items.php'; require_once 'include/bb2diaspora.php'; -require_once 'include/group.php'; require_once 'include/datetime.php'; require_once 'include/queue_fn.php'; diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index c20bb8d8f8..9ed9a06c17 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -159,8 +159,6 @@ class Delivery { $public_message = true; if (!($mail || $fsuggest || $relocate)) { - require_once 'include/group.php'; - $parent = $items[0]; // This is IMPORTANT!!!! diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index fb806be954..7494780444 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -208,8 +208,6 @@ class Notifier { $slap = OStatus::salmon($target_item, $owner); - require_once 'include/group.php'; - $parent = $items[0]; $thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", -- 2.39.5