当前位置: 首页>>代码示例>>PHP>>正文


PHP group_get_members函数代码示例

本文整理汇总了PHP中group_get_members函数的典型用法代码示例。如果您正苦于以下问题:PHP group_get_members函数的具体用法?PHP group_get_members怎么用?PHP group_get_members使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了group_get_members函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: contactgroup_content

function contactgroup_content(&$a)
{
    if (!local_user()) {
        killme();
    }
    if (argc() > 2 && intval(argv(1)) && argv(2)) {
        $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d ) limit 1", dbesc(argv(2)), intval(local_user()), intval(ABOOK_FLAG_SELF));
        if ($r) {
            $change = $r[0]['abook_xchan'];
        }
    }
    if (argc() > 1 && intval(argv(1))) {
        $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_user()));
        if (!$r) {
            killme();
        }
        $group = $r[0];
        $members = group_get_members($group['id']);
        $preselected = array();
        if (count($members)) {
            foreach ($members as $member) {
                $preselected[] = $member['xchan_hash'];
            }
        }
        if ($change) {
            if (in_array($change, $preselected)) {
                group_rmv_member(local_user(), $group['name'], $change);
            } else {
                group_add_member(local_user(), $group['name'], $change);
            }
        }
    }
    killme();
}
开发者ID:Mauru,项目名称:red,代码行数:34,代码来源:contactgroup.php

示例2: get

 function get()
 {
     if (!local_channel()) {
         killme();
     }
     if (argc() > 2 && intval(argv(1)) && argv(2)) {
         $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", dbesc(base64url_decode(argv(2))), intval(local_channel()));
         if ($r) {
             $change = $r[0]['abook_xchan'];
         }
     }
     if (argc() > 1 && intval(argv(1))) {
         $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_channel()));
         if (!$r) {
             killme();
         }
         $group = $r[0];
         $members = group_get_members($group['id']);
         $preselected = array();
         if (count($members)) {
             foreach ($members as $member) {
                 $preselected[] = $member['xchan_hash'];
             }
         }
         if ($change) {
             if (in_array($change, $preselected)) {
                 group_rmv_member(local_channel(), $group['gname'], $change);
             } else {
                 group_add_member(local_channel(), $group['gname'], $change);
             }
         }
     }
     killme();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:34,代码来源:Contactgroup.php

示例3: contactgroup_content

function contactgroup_content(&$a)
{
    if (!local_user()) {
        killme();
    }
    if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
        $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($a->argv[2]), intval(local_user()));
        if (count($r)) {
            $change = intval($a->argv[2]);
        }
    }
    if ($a->argc > 1 && intval($a->argv[1])) {
        $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            killme();
        }
        $group = $r[0];
        $members = group_get_members($group['id']);
        $preselected = array();
        if (count($members)) {
            foreach ($members as $member) {
                $preselected[] = $member['id'];
            }
        }
        if ($change) {
            if (in_array($change, $preselected)) {
                group_rmv_member(local_user(), $group['name'], $change);
            } else {
                group_add_member(local_user(), $group['name'], $change);
            }
        }
    }
    killme();
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:34,代码来源:contactgroup.php

示例4: get

 function get()
 {
     $change = false;
     logger('mod_group: ' . \App::$cmd, LOGGER_DEBUG);
     if (!local_channel()) {
         notice(t('Permission denied') . EOL);
         return;
     }
     // Switch to text mode interface if we have more than 'n' contacts or group members
     $switchtotext = get_pconfig(local_channel(), 'system', 'groupedit_image_limit');
     if ($switchtotext === false) {
         $switchtotext = get_config('system', 'groupedit_image_limit');
     }
     if ($switchtotext === false) {
         $switchtotext = 400;
     }
     $tpl = get_markup_template('group_edit.tpl');
     $context = array('$submit' => t('Submit'));
     if (argc() == 2 && argv(1) === 'new') {
         return replace_macros($tpl, $context + array('$title' => t('Create a group of channels.'), '$gname' => array('groupname', t('Privacy group name: '), '', ''), '$gid' => 'new', '$public' => array('public', t('Members are visible to other channels'), false, ''), '$form_security_token' => get_form_security_token("group_edit")));
     }
     if (argc() == 3 && argv(1) === 'drop') {
         check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
         if (intval(argv(2))) {
             $r = q("SELECT `name` FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(argv(2)), intval(local_channel()));
             if ($r) {
                 $result = group_rmv(local_channel(), $r[0]['gname']);
             }
             if ($result) {
                 info(t('Privacy group removed.') . EOL);
             } else {
                 notice(t('Unable to remove privacy group.') . EOL);
             }
         }
         goaway(z_root() . '/group');
         // NOTREACHED
     }
     if (argc() > 2 && intval(argv(1)) && argv(2)) {
         check_form_security_token_ForbiddenOnErr('group_member_change', 't');
         $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 limit 1", dbesc(base64url_decode(argv(2))), intval(local_channel()));
         if (count($r)) {
             $change = base64url_decode(argv(2));
         }
     }
     if (argc() > 1 && intval(argv(1))) {
         require_once 'include/acl_selectors.php';
         $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_channel()));
         if (!$r) {
             notice(t('Privacy group not found.') . EOL);
             goaway(z_root() . '/connections');
         }
         $group = $r[0];
         $members = group_get_members($group['id']);
         $preselected = array();
         if (count($members)) {
             foreach ($members as $member) {
                 if (!in_array($member['xchan_hash'], $preselected)) {
                     $preselected[] = $member['xchan_hash'];
                 }
             }
         }
         if ($change) {
             if (in_array($change, $preselected)) {
                 group_rmv_member(local_channel(), $group['gname'], $change);
             } else {
                 group_add_member(local_channel(), $group['gname'], $change);
             }
             $members = group_get_members($group['id']);
             $preselected = array();
             if (count($members)) {
                 foreach ($members as $member) {
                     $preselected[] = $member['xchan_hash'];
                 }
             }
         }
         $drop_tpl = get_markup_template('group_drop.tpl');
         $drop_txt = replace_macros($drop_tpl, array('$id' => $group['id'], '$delete' => t('Delete'), '$form_security_token' => get_form_security_token("group_drop")));
         $context = $context + array('$title' => t('Privacy group editor'), '$gname' => array('groupname', t('Privacy group name: '), $group['gname'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, '$public' => array('public', t('Members are visible to other channels'), $group['visible'], ''), '$form_security_token' => get_form_security_token('group_edit'));
     }
     if (!isset($group)) {
         return;
     }
     $groupeditor = array('label_members' => t('Members'), 'members' => array(), 'label_contacts' => t('All Connected Channels'), 'contacts' => array());
     $sec_token = addslashes(get_form_security_token('group_member_change'));
     $textmode = $switchtotext && count($members) > $switchtotext ? true : false;
     foreach ($members as $member) {
         if ($member['xchan_url']) {
             $member['archived'] = intval($member['abook_archived']) ? true : false;
             $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
             $groupeditor['members'][] = micropro($member, true, 'mpgroup', $textmode);
         } else {
             group_rmv_member(local_channel(), $group['gname'], $member['xchan_hash']);
         }
     }
     $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", intval(local_channel()));
     if (count($r)) {
         $textmode = $switchtotext && count($r) > $switchtotext ? true : false;
         foreach ($r as $member) {
             if (!in_array($member['xchan_hash'], $preselected)) {
                 $member['archived'] = intval($member['abook_archived']) ? true : false;
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:101,代码来源:Group.php

示例5: items_fetch

function items_fetch($arr, $channel = null, $observer_hash = null, $client_mode = CLIENT_MODE_NORMAL, $module = 'network')
{
    $result = array('success' => false);
    $a = get_app();
    $sql_extra = '';
    $sql_nets = '';
    $sql_options = '';
    $sql_extra2 = '';
    $sql_extra3 = '';
    $def_acl = '';
    $item_uids = ' true ';
    if ($arr['uid']) {
        $uid = $arr['uid'];
    }
    if ($channel) {
        $uid = $channel['channel_id'];
        $uidhash = $channel['channel_hash'];
        $item_uids = " item.uid = " . intval($uid) . " ";
    }
    if ($arr['star']) {
        $sql_options .= " and (item_flags & " . intval(ITEM_STARRED) . ")>0 ";
    }
    if ($arr['wall']) {
        $sql_options .= " and (item_flags & " . intval(ITEM_WALL) . ")>0 ";
    }
    $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 {$sql_options} ) ";
    if ($arr['since_id']) {
        $sql_extra .= " and item.id > " . $since_id . " ";
    }
    if ($arr['gid'] && $uid) {
        $r = q("SELECT * FROM `groups` WHERE id = %d AND uid = %d LIMIT 1", intval($arr['group']), intval($uid));
        if (!$r) {
            $result['message'] = t('Collection not found.');
            return $result;
        }
        $contact_str = '';
        /** @FIXME $group is undefined */
        $contacts = group_get_members($group);
        if ($contacts) {
            foreach ($contacts as $c) {
                if ($contact_str) {
                    $contact_str .= ',';
                }
                $contact_str .= "'" . $c['xchan'] . "'";
            }
        } else {
            $contact_str = ' 0 ';
            $result['message'] = t('Collection is empty.');
            return $result;
        }
        $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND (( author_xchan IN ( {$contact_str} ) OR owner_xchan in ( {$contact_str})) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
        $x = group_rec_byhash($uid, $r[0]['hash']);
        $result['headline'] = sprintf(t('Collection: %s'), $x['name']);
    } elseif ($arr['cid'] && $uid) {
        $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ")>0 limit 1", intval($arr['cid']), intval(local_channel()));
        if ($r) {
            $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
            $result['headline'] = sprintf(t('Connection: %s'), $r[0]['xchan_name']);
        } else {
            $result['message'] = t('Connection not found.');
            return $result;
        }
    }
    if ($arr['datequery']) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $arr['datequery']))));
    }
    if ($arr['datequery2']) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $arr['datequery2']))));
    }
    if (!array_key_exists('nouveau', $arr)) {
        $sql_extra2 = " AND item.parent = item.id ";
        $sql_extra3 = '';
    }
    if ($arr['search']) {
        if (strpos($arr['search'], '#') === 0) {
            $sql_extra .= term_query('item', substr($arr['search'], 1), TERM_HASHTAG);
        } else {
            $sql_extra .= sprintf(" AND item.body like '%s' ", dbesc(protect_sprintf('%' . $arr['search'] . '%')));
        }
    }
    if (strlen($arr['file'])) {
        $sql_extra .= term_query('item', $arr['files'], TERM_FILE);
    }
    if ($arr['conv'] && $channel) {
        $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or ( item_flags & %d )>0)) ", dbesc(protect_sprintf($uidhash)), intval(ITEM_MENTIONSME));
    }
    if ($client_mode & CLIENT_MODE_UPDATE && !($client_mode & CLIENT_MODE_LOAD)) {
        // only setup pagination on initial page view
        $pager_sql = '';
    } else {
        $itemspage = $channel ? get_pconfig($uid, 'system', 'itemspage') : 20;
        $a->set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
        $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(get_app()->pager['itemspage']), intval(get_app()->pager['start']));
    }
    if (isset($arr['start']) && isset($arr['records'])) {
        $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($arr['records']), intval($arr['start']));
    }
    if (array_key_exists('cmin', $arr) || array_key_exists('cmax', $arr)) {
        if ($arr['cmin'] != 0 || $arr['cmax'] != 99) {
            // Not everybody who shows up in the network stream will be in your address book.
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:101,代码来源:items.php

示例6: get


//.........这里部分代码省略.........
             // NOTREACHED
         }
         if ($_GET['pf'] === '1') {
             $deftag = '@' . t('forum') . '+' . intval($cid) . '+';
         } else {
             $def_acl = array('allow_cid' => '<' . $r[0]['abook_xchan'] . '>');
         }
     }
     if (!$update) {
         $tabs = network_tabs();
         $o .= $tabs;
         // search terms header
         if ($search) {
             $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8')));
         }
         nav_set_selected('network');
         $channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
         $private_editing = ($group || $cid) && !intval($_GET['pf']) ? true : false;
         $x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($private_editing ? $def_acl : $channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => $private_editing ? '!' : '', 'visitor' => true, 'profile_uid' => local_channel(), 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
         if ($deftag) {
             $x['pretext'] = $deftag;
         }
         $status_editor = status_editor($a, $x);
         $o .= $status_editor;
     }
     // We don't have to deal with ACL's on this page. You're looking at everything
     // that belongs to you, hence you can see all of it. We will filter by group if
     // desired.
     $sql_options = $star ? " and item_starred = 1 " : '';
     $sql_nets = '';
     $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE item_thread_top = 1 {$sql_options} ) ";
     if ($group) {
         $contact_str = '';
         $contacts = group_get_members($group);
         if ($contacts) {
             foreach ($contacts as $c) {
                 if ($contact_str) {
                     $contact_str .= ',';
                 }
                 $contact_str .= "'" . $c['xchan'] . "'";
             }
         } else {
             $contact_str = ' 0 ';
             info(t('Privacy group is empty'));
         }
         $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND (( author_xchan IN ( {$contact_str} ) OR owner_xchan in ( {$contact_str} )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent {$item_normal} ) ";
         $x = group_rec_byhash(local_channel(), $group_hash);
         if ($x) {
             $title = replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Privacy group: ') . $x['name']));
         }
         $o = $tabs;
         $o .= $title;
         $o .= $status_editor;
     } elseif ($cid) {
         $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($cid), intval(local_channel()));
         if ($r) {
             $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) {$item_normal} ) ";
             $title = replace_macros(get_markup_template("section_title.tpl"), array('$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>'));
             $o = $tabs;
             $o .= $title;
             $o .= $status_editor;
         } else {
             notice(t('Invalid connection.') . EOL);
             goaway(z_root() . '/network');
         }
     }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:67,代码来源:Network.php

示例7: recursive_activity_recipients

/**
 * @brief Returns array of channels which have recursive permission for a file
 *
 * @param $arr_allow_cid
 * @param $arr_allow_gid
 * @param $arr_deny_cid
 * @param $arr_deny_gid
 * @param $folder_hash
 */
function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash)
{
    $ret = array();
    $parent_arr = array();
    $count_values = array();
    $poster = App::get_observer();
    //turn allow_gid into allow_cid's
    foreach ($arr_allow_gid as $gid) {
        $in_group = group_get_members($gid);
        $arr_allow_cid = array_unique(array_merge($arr_allow_cid, $in_group));
    }
    $count = 0;
    while ($folder_hash) {
        $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s' LIMIT 1", dbesc($folder_hash));
        //only process private folders
        if ($x[0]['allow_cid'] || $x[0]['allow_gid'] || $x[0]['deny_cid'] || $x[0]['deny_gid']) {
            $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']);
            $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']);
            /**
             * @TODO should find a much better solution for the allow_cid <-> allow_gid problem.
             * Do not use allow_gid for now. Instead lookup the members of the group directly and add them to allow_cid.
             * */
            if ($parent_arr['allow_gid']) {
                foreach ($parent_arr['allow_gid'][$count] as $gid) {
                    $in_group = group_get_members($gid);
                    $parent_arr['allow_cid'][$count] = array_unique(array_merge($parent_arr['allow_cid'][$count], $in_group));
                }
            }
            $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']);
            $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']);
            $count++;
        }
        $folder_hash = $x[0]['folder'];
    }
    //if none of the parent folders is private just return file perms
    if (!$parent_arr['allow_cid'] && !$parent_arr['allow_gid'] && !$parent_arr['deny_cid'] && !$parent_arr['deny_gid']) {
        $ret['allow_gid'] = $arr_allow_gid;
        $ret['allow_cid'] = $arr_allow_cid;
        $ret['deny_gid'] = $arr_deny_gid;
        $ret['deny_cid'] = $arr_deny_cid;
        return $ret;
    }
    //if there are no perms on the file we get them from the first parent folder
    if (!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) {
        $arr_allow_cid = $parent_arr['allow_cid'][0];
        $arr_allow_gid = $parent_arr['allow_gid'][0];
        $arr_deny_cid = $parent_arr['deny_cid'][0];
        $arr_deny_gid = $parent_arr['deny_gid'][0];
    }
    //allow_cid
    $r_arr_allow_cid = false;
    foreach ($parent_arr['allow_cid'] as $folder_arr_allow_cid) {
        foreach ($folder_arr_allow_cid as $ac_hash) {
            $count_values[$ac_hash]++;
        }
    }
    foreach ($arr_allow_cid as $fac_hash) {
        if ($count_values[$fac_hash] == $count) {
            $r_arr_allow_cid[] = $fac_hash;
        }
    }
    //allow_gid
    $r_arr_allow_gid = false;
    foreach ($parent_arr['allow_gid'] as $folder_arr_allow_gid) {
        foreach ($folder_arr_allow_gid as $ag_hash) {
            $count_values[$ag_hash]++;
        }
    }
    foreach ($arr_allow_gid as $fag_hash) {
        if ($count_values[$fag_hash] == $count) {
            $r_arr_allow_gid[] = $fag_hash;
        }
    }
    //deny_gid
    foreach ($parent_arr['deny_gid'] as $folder_arr_deny_gid) {
        $r_arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid);
    }
    $r_arr_deny_gid = array_unique($r_arr_deny_gid);
    //deny_cid
    foreach ($parent_arr['deny_cid'] as $folder_arr_deny_cid) {
        $r_arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid);
    }
    $r_arr_deny_cid = array_unique($r_arr_deny_cid);
    //if none is allowed restrict to self
    if ($r_arr_allow_gid === false && $r_arr_allow_cid === false) {
        $ret['allow_cid'] = $poster['xchan_hash'];
    } else {
        $ret['allow_gid'] = $r_arr_allow_gid;
        $ret['allow_cid'] = $r_arr_allow_cid;
        $ret['deny_gid'] = $r_arr_deny_gid;
        $ret['deny_cid'] = $r_arr_deny_cid;
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:attach.php

示例8: group_content

function group_content(&$a)
{
    $change = false;
    if (!local_user()) {
        notice(t('Permission denied') . EOL);
        return;
    }
    // Switch to text mode interface if we have more than 'n' contacts or group members
    $switchtotext = get_pconfig(local_user(), 'system', 'groupedit_image_limit');
    if ($switchtotext === false) {
        $switchtotext = get_config('system', 'groupedit_image_limit');
    }
    if ($switchtotext === false) {
        $switchtotext = 400;
    }
    $tpl = get_markup_template('group_edit.tpl');
    $context = array('$submit' => t('Submit'));
    if ($a->argc == 2 && $a->argv[1] === 'new') {
        return replace_macros($tpl, $context + array('$title' => t('Create a group of contacts/friends.'), '$gname' => array('groupname', t('Group Name: '), '', ''), '$gid' => 'new', '$form_security_token' => get_form_security_token("group_edit")));
    }
    if ($a->argc == 3 && $a->argv[1] === 'drop') {
        check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
        if (intval($a->argv[2])) {
            $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user()));
            if (count($r)) {
                $result = group_rmv(local_user(), $r[0]['name']);
            }
            if ($result) {
                info(t('Group removed.') . EOL);
            } else {
                notice(t('Unable to remove group.') . EOL);
            }
        }
        goaway($a->get_baseurl() . '/group');
        // NOTREACHED
    }
    if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
        check_form_security_token_ForbiddenOnErr('group_member_change', 't');
        $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($a->argv[2]), intval(local_user()));
        if (count($r)) {
            $change = intval($a->argv[2]);
        }
    }
    if ($a->argc > 1 && intval($a->argv[1])) {
        require_once 'include/acl_selectors.php';
        $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            notice(t('Group not found.') . EOL);
            goaway($a->get_baseurl() . '/contacts');
        }
        $group = $r[0];
        $members = group_get_members($group['id']);
        $preselected = array();
        if (count($members)) {
            foreach ($members as $member) {
                $preselected[] = $member['id'];
            }
        }
        if ($change) {
            if (in_array($change, $preselected)) {
                group_rmv_member(local_user(), $group['name'], $change);
            } else {
                group_add_member(local_user(), $group['name'], $change);
            }
            $members = group_get_members($group['id']);
            $preselected = array();
            if (count($members)) {
                foreach ($members as $member) {
                    $preselected[] = $member['id'];
                }
            }
        }
        $drop_tpl = get_markup_template('group_drop.tpl');
        $drop_txt = replace_macros($drop_tpl, array('$id' => $group['id'], '$delete' => t('Delete'), '$form_security_token' => get_form_security_token("group_drop")));
        $celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
        $context = $context + array('$title' => t('Group Editor'), '$gname' => array('groupname', t('Group Name: '), $group['name'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, '$form_security_token' => get_form_security_token('group_edit'));
    }
    if (!isset($group)) {
        return;
    }
    $groupeditor = array('label_members' => t('Members'), 'members' => array(), 'label_contacts' => t('All Contacts'), 'contacts' => array());
    $sec_token = addslashes(get_form_security_token('group_member_change'));
    $textmode = $switchtotext && count($members) > $switchtotext ? true : false;
    foreach ($members as $member) {
        if ($member['url']) {
            $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
            $groupeditor['members'][] = micropro($member, true, 'mpgroup', $textmode);
        } else {
            group_rmv_member(local_user(), $group['name'], $member['id']);
        }
    }
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", intval(local_user()));
    if (count($r)) {
        $textmode = $switchtotext && count($r) > $switchtotext ? true : false;
        foreach ($r as $member) {
            if (!in_array($member['id'], $preselected)) {
                $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
                $groupeditor['contacts'][] = micropro($member, true, 'mpall', $textmode);
            }
        }
//.........这里部分代码省略.........
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:group.php

示例9: network_content

function network_content(&$a, $update = 0, $load = false)
{
    if (!local_user()) {
        $_SESSION['return_url'] = $a->query_string;
        return login(false);
    }
    $arr = array('query' => $a->query_string);
    call_hooks('network_content_init', $arr);
    $channel = $a->get_channel();
    $search = $_GET['search'] ? $_GET['search'] : '';
    if ($search) {
        if (strpos($search, '@') === 0) {
            $r = q("select abook_id from abook left join xchan on abook_xchan = xchan_hash where xchan_name = '%s' and abook_channel = %d limit 1", dbesc(substr($search, 1)), intval(local_user()));
            if ($r) {
                $_GET['cid'] = $r[0]['abook_id'];
                $search = $_GET['search'] = '';
            }
        } elseif (strpos($search, '#') === 0) {
            $search = $_GET['search'] = substr($search, 1);
        }
    }
    $datequery = $datequery2 = '';
    $group = 0;
    $nouveau = false;
    $datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
    $datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
    $nouveau = x($_GET, 'new') ? intval($_GET['new']) : 0;
    $gid = x($_GET, 'gid') ? intval($_GET['gid']) : 0;
    if ($datequery) {
        $_GET['order'] = 'post';
    }
    if ($gid) {
        $r = q("SELECT * FROM `groups` WHERE id = %d AND uid = %d LIMIT 1", intval($gid), intval(local_user()));
        if (!$r) {
            if ($update) {
                killme();
            }
            notice(t('No such group') . EOL);
            goaway($a->get_baseurl(true) . '/network');
            // NOTREACHED
        }
        $group = $gid;
        $group_hash = $r[0]['hash'];
        $def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
    }
    $o = '';
    // if no tabs are selected, defaults to comments
    $cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
    $star = x($_GET, 'star') ? intval($_GET['star']) : 0;
    $order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
    $liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
    $conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
    $spam = x($_GET, 'spam') ? intval($_GET['spam']) : 0;
    $cmin = x($_GET, 'cmin') ? intval($_GET['cmin']) : 0;
    $cmax = x($_GET, 'cmax') ? intval($_GET['cmax']) : 99;
    $firehose = x($_GET, 'fh') ? intval($_GET['fh']) : 0;
    $file = x($_GET, 'file') ? $_GET['file'] : '';
    if (x($_GET, 'search') || x($_GET, 'file')) {
        $nouveau = true;
    }
    if ($cid) {
        $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
    }
    if (!$update) {
        $o .= network_tabs();
        // search terms header
        if ($search) {
            $o .= '<h2>' . t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8') . '</h2>';
        }
        nav_set_selected('network');
        $channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
        $x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($group || $cid ? $def_acl : $channel_acl), 'bang' => $group || $cid ? '!' : '', 'visitor' => true, 'profile_uid' => local_user());
        $o .= status_editor($a, $x);
    }
    // We don't have to deal with ACL's on this page. You're looking at everything
    // that belongs to you, hence you can see all of it. We will filter by group if
    // desired.
    $sql_options = $star ? " and (item_flags & " . intval(ITEM_STARRED) . ")" : '';
    $sql_nets = '';
    $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ") {$sql_options} ) ";
    if ($group) {
        $contact_str = '';
        $contacts = group_get_members($group);
        if ($contacts) {
            foreach ($contacts as $c) {
                if ($contact_str) {
                    $contact_str .= ',';
                }
                $contact_str .= "'" . $c['xchan'] . "'";
            }
        } else {
            $contact_str = ' 0 ';
            info(t('Collection is empty'));
        }
        $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND (( author_xchan IN ( {$contact_str} ) OR owner_xchan in ( {$contact_str} )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
        $x = group_rec_byhash(local_user(), $group_hash);
        if ($x) {
            $o = '<h2>' . t('Collection: ') . $x['name'] . '</h2>' . $o;
        }
    } elseif ($cid) {
//.........这里部分代码省略.........
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:network.php

示例10: group_content

function group_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied') . EOL);
        return;
    }
    // Switch to text mod interface if we have more than 'n' contacts or group members
    $switchtotext = get_pconfig(local_user(), 'system', 'groupedit_image_limit');
    if ($switchtotext === false) {
        $switchtotext = get_config('system', 'groupedit_image_limit');
    }
    if ($switchtotext === false) {
        $switchtotext = 400;
    }
    if ($a->argc == 2 && $a->argv[1] === 'new') {
        $tpl = get_markup_template('group_new.tpl');
        $o .= replace_macros($tpl, array('$desc' => t('Create a group of contacts/friends.'), '$name' => t('Group Name: '), '$submit' => t('Submit')));
        return $o;
    }
    if ($a->argc == 3 && $a->argv[1] === 'drop') {
        if (intval($a->argv[2])) {
            $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user()));
            if (count($r)) {
                $result = group_rmv(local_user(), $r[0]['name']);
            }
            if ($result) {
                info(t('Group removed.') . EOL);
            } else {
                notice(t('Unable to remove group.') . EOL);
            }
        }
        goaway($a->get_baseurl() . '/group');
        // NOTREACHED
    }
    if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
        $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($a->argv[2]), intval(local_user()));
        if (count($r)) {
            $change = intval($a->argv[2]);
        }
    }
    if ($a->argc > 1 && intval($a->argv[1])) {
        require_once 'include/acl_selectors.php';
        $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            notice(t('Group not found.') . EOL);
            goaway($a->get_baseurl() . '/contacts');
        }
        $group = $r[0];
        $members = group_get_members($group['id']);
        $preselected = array();
        if (count($members)) {
            foreach ($members as $member) {
                $preselected[] = $member['id'];
            }
        }
        if ($change) {
            if (in_array($change, $preselected)) {
                group_rmv_member(local_user(), $group['name'], $change);
            } else {
                group_add_member(local_user(), $group['name'], $change);
            }
            $members = group_get_members($group['id']);
            $preselected = array();
            if (count($members)) {
                foreach ($members as $member) {
                    $preselected[] = $member['id'];
                }
            }
        }
        $drop_tpl = get_markup_template('group_drop.tpl');
        $drop_txt = replace_macros($drop_tpl, array('$id' => $group['id'], '$delete' => t('Delete')));
        $celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
        $tpl = get_markup_template('group_edit.tpl');
        $o .= replace_macros($tpl, array('$gid' => $group['id'], '$name' => $group['name'], '$drop' => $drop_txt, '$desc' => t('Click on a contact to add or remove.'), '$title' => t('Group Editor'), '$gname' => t('Group Name: '), '$submit' => t('Submit')));
    }
    if (!isset($group)) {
        return;
    }
    $o .= '<div id="group-update-wrapper">';
    if ($change) {
        $o = '';
    }
    $o .= '<h3>' . t('Members') . '</h3>';
    $o .= '<div id="group-members">';
    $textmode = $switchtotext && count($members) > $switchtotext ? true : false;
    foreach ($members as $member) {
        if ($member['url']) {
            $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;';
            $o .= micropro($member, true, 'mpgroup', $textmode);
        } else {
            group_rmv_member(local_user(), $group['name'], $member['id']);
        }
    }
    $o .= '</div><div id="group-members-end"></div>';
    $o .= '<hr id="group-separator" />';
    $o .= '<h3>' . t('All Contacts') . '</h3>';
    $o .= '<div id="group-all-contacts">';
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", intval(local_user()));
    if (count($r)) {
        $textmode = $switchtotext && count($r) > $switchtotext ? true : false;
//.........这里部分代码省略.........
开发者ID:nextgensh,项目名称:friendica,代码行数:101,代码来源:group.php

示例11: group_content

function group_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($a->argc == 2 && $a->argv[1] == 'new') {
        $tpl = file_get_contents('view/group_new.tpl');
        $o .= replace_macros($tpl, array());
    }
    if ($a->argc == 3 && $a->argv[1] == 'drop') {
        if (intval($a->argv[2])) {
            $r = q("SELECT `name` FROM `group` WHERE `id` = %d LIMIT 1", intval($a->argv[2]));
            if (count($r)) {
                $result = group_rmv($r[0]['name']);
            }
            if ($result) {
                notice(t('Group removed.') . EOL);
            } else {
                notice(t('Unable to remove group.') . EOL);
            }
        }
        goaway($a->get_baseurl() . '/group');
        return;
        // NOTREACHED
    }
    if ($a->argc == 2 && intval($a->argv[1])) {
        require_once 'view/acl_selectors.php';
        $r = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1", intval($a->argv[1]));
        if (!count($r)) {
            notice(t('Group not found.') . EOL);
            goaway($a->get_baseurl() . '/contacts');
        }
        $group = $r[0];
        $ret = group_get_members($group['id']);
        $preselected = array();
        if (count($ret)) {
            foreach ($ret as $p) {
                $preselected[] = $p['id'];
            }
        }
        $drop_tpl = file_get_contents('view/group_drop.tpl');
        $drop_txt = replace_macros($drop_tpl, array('$id' => $group['id'], '$delete' => t('Delete')));
        $tpl = file_get_contents('view/group_edit.tpl');
        $o .= replace_macros($tpl, array('$gid' => $group['id'], '$name' => $group['name'], '$drop' => $drop_txt, '$selector' => contact_select('group_members_select', 'group_members_select', $preselected, 25)));
    }
    return $o;
}
开发者ID:vishalp,项目名称:MistparkPE-Remix,代码行数:48,代码来源:group.php


注:本文中的group_get_members函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。