Remove include/group.php

This commit is contained in:
Hypolite Petovan 2017-12-09 13:45:54 -05:00
parent abdecd2b2f
commit 4fe8dab08d
19 changed files with 0 additions and 419 deletions

View file

@ -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';

View file

@ -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.

View file

@ -1,396 +0,0 @@
<?php
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
function group_add($uid,$name) {
$ret = false;
if (x($uid) && x($name)) {
$r = group_byname($uid,$name); // check for dups
if ($r !== false) {
// This could be a problem.
// Let's assume we've just created a group which we once deleted
// 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.
$z = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1",
intval($r)
);
if (count($z) && $z[0]['deleted']) {
$r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s'",
intval($uid),
dbesc($name)
);
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);
}
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;
}

View file

@ -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']) {

View file

@ -2,8 +2,6 @@
use Friendica\App;
use Friendica\Database\DBM;
require_once('include/group.php');
use Friendica\Model\Contact;
use Friendica\Model\Group;

View file

@ -32,7 +32,6 @@ function contacts_init(App $a) {
}
}
require_once 'include/group.php';
require_once 'include/contact_widgets.php';
if ($_GET['nets'] == "all") {

View file

@ -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) {

View file

@ -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)
{

View file

@ -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));
}
}

View file

@ -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';

View file

@ -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')) {

View file

@ -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';

View file

@ -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'];

View file

@ -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)

View file

@ -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)

View file

@ -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';

View file

@ -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';

View file

@ -159,8 +159,6 @@ class Delivery {
$public_message = true;
if (!($mail || $fsuggest || $relocate)) {
require_once 'include/group.php';
$parent = $items[0];
// This is IMPORTANT!!!!

View file

@ -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",