Ejemplo n.º 1
0
function suggest_content(&$a)
{
    require_once "mod/proxy.php";
    $o = '';
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
    $r = suggestion_query(local_user());
    if (!count($r)) {
        $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
        return $o;
    }
    require_once 'include/contact_selectors.php';
    foreach ($r as $rr) {
        $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']);
        $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id'];
        $photo_menu = array(array(t("View Profile"), zrl($rr["url"])));
        $photo_menu[] = array(t("Connect/Follow"), $connlnk);
        $photo_menu[] = array(t('Ignore/Hide'), $ignlnk);
        $contact_details = get_contact_details_by_url($rr["url"], local_user());
        $entry = array('url' => zrl($rr['url']), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'img_hover' => $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'ignlnk' => $ignlnk, 'ignid' => $rr['id'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'ignore' => t('Ignore/Hide'), 'network' => network_to_name($rr['network'], $rr['url']), 'id' => ++$id);
        $entries[] = $entry;
    }
    $tpl = get_markup_template('viewcontact_template.tpl');
    $o .= replace_macros($tpl, array('$title' => t('Friend Suggestions'), '$contacts' => $entries));
    return $o;
}
Ejemplo n.º 2
0
function suggest_content(&$a)
{
    $o = '';
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
    $o .= '<h2>' . t('Friend Suggestions') . '</h2>';
    $r = suggestion_query(local_user());
    if (!count($r)) {
        $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
        return $o;
    }
    $tpl = get_markup_template('suggest_friends.tpl');
    foreach ($r as $rr) {
        $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']);
        $o .= replace_macros($tpl, array('$url' => zrl($rr['url']), '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignid' => $rr['id'], '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$ignore' => t('Ignore/Hide')));
    }
    $o .= cleardiv();
    //	$o .= paginate($a);
    return $o;
}
Ejemplo n.º 3
0
function contacts_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = 0;
    if ($a->argc == 2 && intval($a->argv[1])) {
        $contact_id = intval($a->argv[1]);
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id));
        if (!count($r)) {
            $contact_id = 0;
        }
    }
    require_once 'include/group.php';
    require_once 'include/contact_widgets.php';
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($contact_id) {
        $a->data['contact'] = $r[0];
        $o .= '<div class="vcard">';
        $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
        $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
        $o .= '</div>';
        $a->page['aside'] .= $o;
    } else {
        $a->page['aside'] .= follow_widget();
    }
    $a->page['aside'] .= group_side('contacts', 'group', false, 0, $contact_id);
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= networks_widget('contacts', $_GET['nets']);
}
Ejemplo n.º 4
0
function dirfind_init(&$a)
{
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
}
Ejemplo n.º 5
0
function dirfind_init(&$a)
{
    require_once 'include/contact_widgets.php';
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
}
Ejemplo n.º 6
0
/**
 * @brief Controller for /match.
 *
 * It takes keywords from your profile and queries the directory server for
 * matching keywords from other profiles.
 *
 * @param App &$a
 * @return void|string
 */
function match_content(&$a)
{
    $o = '';
    if (!local_user()) {
        return;
    }
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if ($a->pager['page'] != 1) {
            $params['p'] = $a->pager['page'];
        }
        if (strlen(get_config('system', 'directory'))) {
            $x = post_url(get_server() . '/msearch', $params);
        } else {
            $x = post_url($a->get_baseurl() . '/msearch', $params);
        }
        $j = json_decode($x);
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $id = 0;
            foreach ($j->results as $jj) {
                $match_nurl = normalise_link($jj->url);
                $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
                if (!count($match)) {
                    $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
                    $photo_menu = array(array(t("View Profile"), zrl($jj->url)));
                    $photo_menu[] = array(t("Connect/Follow"), $connlnk);
                    $contact_details = get_contact_details_by_url($jj->url, local_user());
                    $entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id);
                    $entries[] = $entry;
                }
            }
            $tpl = get_markup_template('viewcontact_template.tpl');
            $o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a)));
        } else {
            info(t('No matches') . EOL);
        }
    }
    return $o;
}
Ejemplo n.º 7
0
function directory_init(&$a)
{
    $a->set_pager_itemspage(60);
    if (local_user()) {
        require_once 'include/contact_widgets.php';
        $a->page['aside'] .= findpeople_widget();
    } else {
        unset($_SESSION['theme']);
    }
}
Ejemplo n.º 8
0
function forumdirectory_init(&$a)
{
    $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/forumdirectory/forumdirectory.css" media="all" />';
    $a->set_pager_itemspage(60);
    if (local_user()) {
        require_once 'include/contact_widgets.php';
        $a->page['aside'] .= findpeople_widget();
    } else {
        unset($_SESSION['theme']);
    }
}
Ejemplo n.º 9
0
function match_content(&$a)
{
    $o = '';
    if (!local_user()) {
        return;
    }
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match')));
    $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if ($a->pager['page'] != 1) {
            $params['p'] = $a->pager['page'];
        }
        if (strlen(get_config('system', 'directory'))) {
            $x = post_url(get_server() . '/msearch', $params);
        } else {
            $x = post_url($a->get_baseurl() . '/msearch', $params);
        }
        $j = json_decode($x);
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $tpl = get_markup_template('match.tpl');
            foreach ($j->results as $jj) {
                $match_nurl = normalise_link($jj->url);
                $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
                if (!count($match)) {
                    $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
                    $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags));
                }
            }
        } else {
            info(t('No matches') . EOL);
        }
    }
    $o .= cleardiv();
    $o .= paginate($a);
    return $o;
}
Ejemplo n.º 10
0
function dirfind_init(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
}
Ejemplo n.º 11
0
function contacts_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = 0;
    if ($a->argc == 2 && intval($a->argv[1]) or $a->argc == 3 && intval($a->argv[1]) && $a->argv[2] == "posts") {
        $contact_id = intval($a->argv[1]);
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id));
        if (!count($r)) {
            $contact_id = 0;
        }
    }
    require_once 'include/group.php';
    require_once 'include/contact_widgets.php';
    if ($_GET['nets'] == "all") {
        $_GET['nets'] = "";
    }
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($contact_id) {
        $a->data['contact'] = $r[0];
        if ($a->data['contact']['network'] != "" and $a->data['contact']['network'] != NETWORK_DFRN) {
            $networkname = format_network_name($a->data['contact']['network'], $a->data['contact']['url']);
        } else {
            $networkname = '';
        }
        $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => htmlentities($a->data['contact']['name']), '$photo' => $a->data['contact']['photo'], '$url' => $a->data['contact']['network'] == NETWORK_DFRN ? z_root() . "/redir/" . $a->data['contact']['id'] : $a->data['contact']['url'], '$addr' => $a->data['contact']['addr'] != "" ? $a->data['contact']['addr'] : "", '$network_name' => $networkname, '$network' => t('Network:'), 'account_type' => $a->data['contact']['forum'] || $a->data['contact']['prv'] ? t('Forum') : ''));
        $finpeople_widget = '';
        $follow_widget = '';
        $networks_widget = '';
    } else {
        $vcard_widget = '';
        $networks_widget .= networks_widget('contacts', $_GET['nets']);
        if (isset($_GET['add'])) {
            $follow_widget = follow_widget($_GET['add']);
        } else {
            $follow_widget = follow_widget();
        }
        $findpeople_widget .= findpeople_widget();
    }
    $groups_widget .= group_side('contacts', 'group', 'full', 0, $contact_id);
    $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array('$vcard_widget' => $vcard_widget, '$findpeople_widget' => $findpeople_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$networks_widget' => $networks_widget));
    $base = z_root();
    $tpl = get_markup_template("contacts-head.tpl");
    $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base));
    $tpl = get_markup_template("contacts-end.tpl");
    $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base));
}
Ejemplo n.º 12
0
function contacts_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = 0;
    if ($a->argc == 2 && intval($a->argv[1])) {
        $contact_id = intval($a->argv[1]);
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id));
        if (!count($r)) {
            $contact_id = 0;
        }
    }
    require_once 'include/group.php';
    require_once 'include/contact_widgets.php';
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($contact_id) {
        $a->data['contact'] = $r[0];
        $o .= '<div class="vcard">';
        $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
        $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
        $o .= '</div>';
        $a->page['aside'] .= $o;
    } else {
        $a->page['aside'] .= follow_widget();
    }
    $a->page['aside'] .= group_side('contacts', 'group', false, 0, $contact_id);
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= networks_widget('contacts', $_GET['nets']);
    $base = $a->get_baseurl();
    $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
    $a->page['htmlhead'] .= <<<EOT

<script>\$(document).ready(function() { 
\tvar a; 
\ta = \$("#contacts-search").autocomplete({ 
\t\tserviceUrl: '{$base}/acl',
\t\tminChars: 2,
\t\twidth: 350,
\t});
\ta.setOptions({ params: { type: 'a' }});

}); 

</script>
EOT;
}
Ejemplo n.º 13
0
function contacts_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = 0;
    if ($a->argc == 2 && intval($a->argv[1])) {
        $contact_id = intval($a->argv[1]);
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id));
        if (!count($r)) {
            $contact_id = 0;
        }
    }
    require_once 'include/group.php';
    require_once 'include/contact_widgets.php';
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($contact_id) {
        $a->data['contact'] = $r[0];
        $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => $a->data['contact']['name'], '$photo' => $a->data['contact']['photo'], '$url' => $a->data['contact']['network'] == NETWORK_DFRN ? $a->get_baseurl() . "/redir/" . $a->data['contact']['id'] : $a->data['contact']['url']));
        $follow_widget = '';
    } else {
        $vcard_widget = '';
        if (isset($_GET['add'])) {
            $follow_widget = follow_widget($_GET['add']);
        } else {
            $follow_widget = follow_widget();
        }
    }
    if ($_GET['nets'] == "all") {
        $_GET['nets'] = "";
    }
    $groups_widget .= group_side('contacts', 'group', false, 0, $contact_id);
    $findpeople_widget .= findpeople_widget();
    $networks_widget .= networks_widget('contacts', $_GET['nets']);
    $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array('$vcard_widget' => $vcard_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$findpeople_widget' => $findpeople_widget, '$networks_widget' => $networks_widget));
    $base = $a->get_baseurl();
    $tpl = get_markup_template("contacts-head.tpl");
    $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base));
    $tpl = get_markup_template("contacts-end.tpl");
    $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base));
}
Ejemplo n.º 14
0
function suggest_content(&$a)
{
    $o = '';
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
    $o .= '<h2>' . t('Friend Suggestions') . '</h2>';
    $r = suggestion_query(local_user());
    if (!count($r)) {
        $o .= t('No suggestions. This works best when you have more than one contact/friend.');
        return $o;
    }
    $tpl = get_markup_template('suggest_friends.tpl');
    foreach ($r as $rr) {
        $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignore' => t('Ignore/Hide')));
    }
    $o .= cleardiv();
    //	$o .= paginate($a);
    return $o;
}
Ejemplo n.º 15
0
function widget_findpeople($arr)
{
    return findpeople_widget();
}