コード例 #1
0
ファイル: allfriends.php プロジェクト: vinzv/friendica
function allfriends_content(&$a)
{
    $o = '';
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($a->argc > 1) {
        $cid = intval($a->argv[1]);
    }
    if (!$cid) {
        return;
    }
    $uid = $a->user[uid];
    $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
    if (!count($c)) {
        return;
    }
    $a->page['aside'] = "";
    profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
    $total = count_all_friends(local_user(), $cid);
    if (count($total)) {
        $a->set_pager_total($total);
    }
    $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
    if (!count($r)) {
        $o .= t('No friends to display.');
        return $o;
    }
    $id = 0;
    foreach ($r as $rr) {
        //get further details of the contact
        $contact_details = get_contact_details_by_url($rr['url'], $uid);
        $photo_menu = '';
        // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
        // If the contact is not common to the user, Connect/Follow' will be added to the photo menu
        if ($rr[cid]) {
            $rr[id] = $rr[cid];
            $photo_menu = contact_photo_menu($rr);
        } else {
            $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
            $photo_menu = array(array(t("View Profile"), zrl($rr['url'])));
            $photo_menu[] = array(t("Connect/Follow"), $connlnk);
        }
        $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'id' => ++$id);
        $entries[] = $entry;
    }
    $tab_str = contacts_tab($a, $cid, 3);
    $tpl = get_markup_template('viewcontact_template.tpl');
    $o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a)));
    return $o;
}
コード例 #2
0
ファイル: common.php プロジェクト: vinzv/friendica
function common_content(&$a)
{
    $o = '';
    $cmd = $a->argv[1];
    $uid = intval($a->argv[2]);
    $cid = intval($a->argv[3]);
    $zcid = 0;
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($cmd !== 'loc' && $cmd != 'rem') {
        return;
    }
    if (!$uid) {
        return;
    }
    if ($cmd === 'loc' && $cid) {
        $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid));
        $a->page['aside'] = "";
        profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
    } else {
        $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid));
        $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => htmlentities($c[0]['name']), '$photo' => $c[0]['photo'], 'url' => z_root() . '/contacts/' . $cid));
        if (!x($a->page, 'aside')) {
            $a->page['aside'] = '';
        }
        $a->page['aside'] .= $vcard_widget;
    }
    if (!count($c)) {
        return;
    }
    if (!$cid) {
        if (get_my_url()) {
            $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link(get_my_url())), intval($profile_uid));
            if (count($r)) {
                $cid = $r[0]['id'];
            } else {
                $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link(get_my_url())));
                if (count($r)) {
                    $zcid = $r[0]['id'];
                }
            }
        }
    }
    if ($cid == 0 && $zcid == 0) {
        return;
    }
    if ($cid) {
        $t = count_common_friends($uid, $cid);
    } else {
        $t = count_common_friends_zcid($uid, $zcid);
    }
    if (count($t)) {
        $a->set_pager_total($t);
    } else {
        notice(t('No contacts in common.') . EOL);
        return $o;
    }
    if ($cid) {
        $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
    } else {
        $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
    }
    if (!count($r)) {
        return $o;
    }
    $id = 0;
    foreach ($r as $rr) {
        //get further details of the contact
        $contact_details = get_contact_details_by_url($rr['url'], $uid);
        // $rr[id] is needed to use contact_photo_menu()
        $rr[id] = $rr[cid];
        $photo_menu = '';
        $photo_menu = contact_photo_menu($rr);
        $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'id' => ++$id);
        $entries[] = $entry;
    }
    if ($cmd === 'loc' && $cid && $uid == local_user()) {
        $tab_str = contacts_tab($a, $cid, 4);
    } else {
        $title = t('Common Friends');
    }
    $tpl = get_markup_template('viewcontact_template.tpl');
    $o .= replace_macros($tpl, array('$title' => $title, '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a)));
    return $o;
}
コード例 #3
0
ファイル: crepair.php プロジェクト: vinzv/friendica
function crepair_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $cid = $a->argc > 1 ? intval($a->argv[1]) : 0;
    if ($cid) {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
    }
    if (!count($r)) {
        notice(t('Contact not found.') . EOL);
        return;
    }
    $contact = $r[0];
    $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
    $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
    $returnaddr = "contacts/{$cid}";
    $allow_remote_self = get_config('system', 'allow_users_remote_self');
    // Disable remote self for everything except feeds.
    // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
    // Problem is, you couldn't reply to both networks.
    if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA))) {
        $allow_remote_self = false;
    }
    if ($contact['network'] == NETWORK_FEED) {
        $remote_self_options = array('0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting'));
    } else {
        $remote_self_options = array('0' => t('No mirroring'), '2' => t('Mirror as my own posting'));
    }
    $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
    $tab_str = contacts_tab($a, $contact['id'], 5);
    $tpl = get_markup_template('crepair.tpl');
    $o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$warning' => $warning, '$info' => $info, '$returnaddr' => $returnaddr, '$return' => t('Return to contact editor'), '$update_profile' => update_profile, '$udprofilenow' => t('Refetch contact data'), '$label_name' => t('Name'), '$label_nick' => t('Account Nickname'), '$label_attag' => t('@Tagname - overrides Name/Nickname'), '$label_url' => t('Account URL'), '$label_request' => t('Friend Request URL'), '$label_confirm' => t('Friend Confirm URL'), '$label_notify' => t('Notification Endpoint URL'), '$label_poll' => t('Poll/Feed URL'), '$label_photo' => t('New photo from this URL'), '$label_remote_self' => t('Remote Self'), '$allow_remote_self' => $allow_remote_self, '$remote_self' => array('remote_self', t('Mirror postings from this contact'), $contact['remote_self'], t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'), $remote_self_options), '$contact_name' => htmlentities($contact['name']), '$contact_nick' => htmlentities($contact['nick']), '$contact_id' => $contact['id'], '$contact_url' => $contact['url'], '$request' => $contact['request'], '$confirm' => $contact['confirm'], '$notify' => $contact['notify'], '$poll' => $contact['poll'], '$contact_attag' => $contact['attag'], '$lbl_submit' => t('Submit')));
    return $o;
}
コード例 #4
0
ファイル: contacts.php プロジェクト: vinzv/friendica
function contact_posts($a, $contact_id)
{
    require_once 'include/conversation.php';
    $r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($contact_id));
    if ($r) {
        $contact = $r[0];
        $a->page['aside'] = "";
        profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
    }
    if (get_config('system', 'old_pager')) {
        $r = q("SELECT COUNT(*) AS `total` FROM `item`\n\t\t\tWHERE `item`.`uid` = %d AND `author-link` IN ('%s', '%s')", intval(local_user()), dbesc(str_replace("https://", "http://", $contact["url"])), dbesc(str_replace("http://", "https://", $contact["url"])));
        $a->set_pager_total($r[0]['total']);
    }
    $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,\n\t\t\t`author-name` AS `name`, `owner-avatar` AS `photo`,\n\t\t\t`owner-link` AS `url`, `owner-avatar` AS `thumb`\n\t\tFROM `item` FORCE INDEX (uid_contactid_created)\n\t\tWHERE `item`.`uid` = %d AND `contact-id` = %d\n\t\t\tAND `author-link` IN ('%s', '%s')\n\t\tORDER BY `item`.`created` DESC LIMIT %d, %d", intval(local_user()), intval($contact_id), dbesc(str_replace("https://", "http://", $contact["url"])), dbesc(str_replace("http://", "https://", $contact["url"])), intval($a->pager['start']), intval($a->pager['itemspage']));
    $tab_str = contacts_tab($a, $contact_id, 1);
    $o .= $tab_str;
    $o .= conversation($a, $r, 'community', false);
    if (!get_config('system', 'old_pager')) {
        $o .= alt_pager($a, count($r));
    } else {
        $o .= paginate($a);
    }
    return $o;
}