Пример #1
0
 function get()
 {
     if (observer_prohibited()) {
         notice(t('Public access denied.') . EOL);
         return;
     }
     if (!count(\App::$profile) || \App::$profile['hide_friends']) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     if (!perm_is_allowed(\App::$profile['uid'], get_observer_hash(), 'view_contacts')) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     if (!$_REQUEST['aj']) {
         $_SESSION['return_url'] = \App::$query_string;
     }
     $is_owner = local_channel() && local_channel() == \App::$profile['uid'] ? true : false;
     $abook_flags = " and abook_pending = 0 and abook_self = 0 ";
     $sql_extra = '';
     if (!$is_owner) {
         $abook_flags = " and abook_hidden = 0 ";
         $sql_extra = " and xchan_hidden = 0 ";
     }
     $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} ", intval(\App::$profile['uid']));
     if ($r) {
         \App::set_pager_total($r[0]['total']);
     }
     $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} order by xchan_name LIMIT %d OFFSET %d ", intval(\App::$profile['uid']), intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
     if (!$r && !$_REQUEST['aj']) {
         info(t('No connections.') . EOL);
         return $o;
     }
     $contacts = array();
     foreach ($r as $rr) {
         $url = chanlink_url($rr['xchan_url']);
         if ($url) {
             $contacts[] = array('id' => $rr['abook_id'], 'archived' => intval($rr['abook_archived']) ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
         }
     }
     if ($_REQUEST['aj']) {
         if ($contacts) {
             $o = replace_macros(get_markup_template('viewcontactsajax.tpl'), array('$contacts' => $contacts));
         } else {
             $o = '<div id="content-complete"></div>';
         }
         echo $o;
         killme();
     } else {
         $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
         $tpl = get_markup_template("viewcontact_template.tpl");
         $o .= replace_macros($tpl, array('$title' => t('View Connections'), '$contacts' => $contacts));
     }
     if (!$contacts) {
         $o .= '<div id="content-complete"></div>';
     }
     return $o;
 }
Пример #2
0
function viewconnections_content(&$a)
{
    if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) {
        notice(t('Public access denied.') . EOL);
        return;
    }
    if (!count($a->profile) || $a->profile['hide_friends']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (!perm_is_allowed($a->profile['uid'], get_observer_hash(), 'view_contacts')) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (!$_REQUEST['aj']) {
        $_SESSION['return_url'] = $a->query_string;
    }
    $is_owner = local_channel() && local_channel() == $a->profile['uid'] ? true : false;
    $abook_flags = ABOOK_FLAG_PENDING | ABOOK_FLAG_SELF;
    $xchan_flags = XCHAN_FLAGS_ORPHAN | XCHAN_FLAGS_DELETED;
    if (!$is_owner) {
        $abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
        $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
    }
    $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d )>0 and not ( xchan_flags & %d )>0 ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags));
    if ($r) {
        $a->set_pager_total($r[0]['total']);
    }
    $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d )>0 and not ( xchan_flags & %d )>0 order by xchan_name LIMIT %d OFFSET %d ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags), intval($a->pager['itemspage']), intval($a->pager['start']));
    if (!$r && !$_REQUEST['aj']) {
        info(t('No connections.') . EOL);
        return $o;
    }
    $contacts = array();
    foreach ($r as $rr) {
        $url = chanlink_url($rr['xchan_url']);
        if ($url) {
            $contacts[] = array('id' => $rr['abook_id'], 'archived' => $rr['abook_flags'] & ABOOK_FLAG_ARCHIVED ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
        }
    }
    if ($_REQUEST['aj']) {
        if ($contacts) {
            $o = replace_macros(get_markup_template('viewcontactsajax.tpl'), array('$contacts' => $contacts));
        } else {
            $o = '<div id="content-complete"></div>';
        }
        echo $o;
        killme();
    } else {
        $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
        $tpl = get_markup_template("viewcontact_template.tpl");
        $o .= replace_macros($tpl, array('$title' => t('View Connections'), '$contacts' => $contacts));
    }
    if (!$contacts) {
        $o .= '<div id="content-complete"></div>';
    }
    return $o;
}
Пример #3
0
 function init()
 {
     $x = random_profile();
     if ($x) {
         goaway(chanlink_url($x));
     }
     /** FIXME this doesn't work at the moment as a fallback */
     goaway(z_root() . '/profile');
 }
Пример #4
0
 function init()
 {
     require_once 'include/Contact.php';
     $x = random_profile();
     if ($x) {
         goaway(chanlink_url($x));
     }
     /** FIXME this doesn't work at the moment as a fallback */
     goaway(z_root() . '/profile');
 }
Пример #5
0
function randprof_init(&$a)
{
    require_once 'include/Contact.php';
    $x = random_profile();
    if ($x) {
        goaway(chanlink_url($x));
    }
    /** FIXME this doesn't work at the moment as a fallback */
    goaway($a->get_baseurl() . '/profile');
}
Пример #6
0
function viewconnections_content(&$a)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        notice(t('Public access denied.') . EOL);
        return;
    }
    if (!count($a->profile) || $a->profile['hide_friends']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (!perm_is_allowed($a->profile['uid'], get_observer_hash(), 'view_contacts')) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $is_owner = local_user() && local_user() == $a->profile['uid'] ? true : false;
    $abook_flags = ABOOK_FLAG_PENDING | ABOOK_FLAG_SELF;
    $xchan_flags = XCHAN_FLAGS_ORPHAN | XCHAN_FLAGS_DELETED;
    if (!$is_owner) {
        $abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
        $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
    }
    $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d ) and not ( xchan_flags & %d ) ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags));
    if ($r) {
        $a->set_pager_total($r[0]['total']);
    }
    $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d ) and not ( xchan_flags & %d ) order by xchan_name LIMIT %d , %d ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags), intval($a->pager['start']), intval($a->pager['itemspage']));
    if (!$r) {
        info(t('No connections.') . EOL);
        return $o;
    }
    $contacts = array();
    foreach ($r as $rr) {
        $url = chanlink_url($rr['xchan_url']);
        if ($url) {
            $contacts[] = array('id' => $rr['abook_id'], 'archived' => $rr['abook_flags'] & ABOOK_FLAG_ARCHIVED ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
        }
    }
    $tpl = get_markup_template("viewcontact_template.tpl");
    $o .= replace_macros($tpl, array('$title' => t('View Connnections'), '$contacts' => $contacts, '$paginate' => paginate($a)));
    return $o;
}
Пример #7
0
 function get()
 {
     $o = '';
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $_SESSION['return_url'] = z_root() . '/' . \App::$cmd;
     $r = suggestion_query(local_channel(), get_observer_hash());
     if (!$r) {
         info(t('No suggestions available. If this is a new site, please try again in 24 hours.'));
         return;
     }
     $arr = array();
     foreach ($r as $rr) {
         $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
         $arr[] = array('url' => chanlink_url($rr['xchan_url']), 'common' => $rr['total'], 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide'));
     }
     $o = replace_macros(get_markup_template('suggest_page.tpl'), array('$title' => t('Channel Suggestions'), '$entries' => $arr));
     return $o;
 }
Пример #8
0
function fetch_post_tags($items, $link = false)
{
    $tag_finder = array();
    if ($items) {
        foreach ($items as $item) {
            if (is_array($item)) {
                if (array_key_exists('item_id', $item)) {
                    if (!in_array($item['item_id'], $tag_finder)) {
                        $tag_finder[] = $item['item_id'];
                    }
                } else {
                    if (!in_array($item['id'], $tag_finder)) {
                        $tag_finder[] = $item['id'];
                    }
                }
            }
        }
    }
    $tag_finder_str = implode(', ', $tag_finder);
    if (strlen($tag_finder_str)) {
        $tags = q("select * from term where oid in ( %s ) and otype = %d", dbesc($tag_finder_str), intval(TERM_OBJ_POST));
    }
    for ($x = 0; $x < count($items); $x++) {
        if ($tags) {
            foreach ($tags as $t) {
                if ($link && $t['type'] == TERM_MENTION) {
                    $t['url'] = chanlink_url($t['url']);
                }
                if (array_key_exists('item_id', $items[$x])) {
                    if ($t['oid'] == $items[$x]['item_id']) {
                        if (!is_array($items[$x]['term'])) {
                            $items[$x]['term'] = array();
                        }
                        $items[$x]['term'][] = $t;
                    }
                } else {
                    if ($t['oid'] == $items[$x]['id']) {
                        if (!is_array($items[$x]['term'])) {
                            $items[$x]['term'] = array();
                        }
                        $items[$x]['term'][] = $t;
                    }
                }
            }
        }
    }
    return $items;
}
Пример #9
0
function connections_content(&$a)
{
    $sort_type = 0;
    $o = '';
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return login();
    }
    $blocked = false;
    $hidden = false;
    $ignored = false;
    $archived = false;
    $unblocked = false;
    $pending = false;
    $unconnected = false;
    $all = false;
    if (!$_REQUEST['aj']) {
        $_SESSION['return_url'] = $a->query_string;
    }
    $search_flags = 0;
    $head = '';
    if (argc() == 2) {
        switch (argv(1)) {
            case 'blocked':
                $search_flags = ABOOK_FLAG_BLOCKED;
                $head = t('Blocked');
                $blocked = true;
                break;
            case 'ignored':
                $search_flags = ABOOK_FLAG_IGNORED;
                $head = t('Ignored');
                $ignored = true;
                break;
            case 'hidden':
                $search_flags = ABOOK_FLAG_HIDDEN;
                $head = t('Hidden');
                $hidden = true;
                break;
            case 'archived':
                $search_flags = ABOOK_FLAG_ARCHIVED;
                $head = t('Archived');
                $archived = true;
                break;
            case 'pending':
                $search_flags = ABOOK_FLAG_PENDING;
                $head = t('New');
                $pending = true;
                nav_set_selected('intros');
                break;
            case 'ifpending':
                $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)", intval(local_channel()), intval(ABOOK_FLAG_PENDING), intval(ABOOK_FLAG_SELF | ABOOK_FLAG_IGNORED), intval(XCHAN_FLAGS_DELETED | XCHAN_FLAGS_ORPHAN));
                if ($r && $r[0]['total']) {
                    $search_flags = ABOOK_FLAG_PENDING;
                    $head = t('New');
                    $pending = true;
                    nav_set_selected('intros');
                    $a->argv[1] = 'pending';
                } else {
                    $head = t('All');
                    $search_flags = 0;
                    $all = true;
                    $a->argc = 1;
                    unset($a->argv[1]);
                }
                nav_set_selected('intros');
                break;
                //			case 'unconnected':
                //				$search_flags = ABOOK_FLAG_UNCONNECTED;
                //				$head = t('Unconnected');
                //				$unconnected = true;
                //				break;
            //			case 'unconnected':
            //				$search_flags = ABOOK_FLAG_UNCONNECTED;
            //				$head = t('Unconnected');
            //				$unconnected = true;
            //				break;
            case 'all':
                $head = t('All');
            default:
                $search_flags = 0;
                $all = true;
                break;
        }
        $sql_extra = $search_flags ? " and ( abook_flags & " . $search_flags . " )>0 " : "";
        if (argv(1) === 'pending') {
            $sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " )>0 ";
        }
    } else {
        $sql_extra = " and not ( abook_flags & " . ABOOK_FLAG_BLOCKED . " )>0 ";
        $unblocked = true;
    }
    $search = x($_REQUEST, 'search') ? notags(trim($_REQUEST['search'])) : '';
    $tabs = array(array('label' => t('Suggestions'), 'url' => z_root() . '/suggest', 'sel' => '', 'title' => t('Suggest new connections')), array('label' => t('New Connections'), 'url' => z_root() . '/connections/pending', 'sel' => $pending ? 'active' : '', 'title' => t('Show pending (new) connections')), array('label' => t('All Connections'), 'url' => z_root() . '/connections/all', 'sel' => $all ? 'active' : '', 'title' => t('Show all connections')), array('label' => t('Unblocked'), 'url' => z_root() . '/connections', 'sel' => $unblocked && !$search && !$nets ? 'active' : '', 'title' => t('Only show unblocked connections')), array('label' => t('Blocked'), 'url' => z_root() . '/connections/blocked', 'sel' => $blocked ? 'active' : '', 'title' => t('Only show blocked connections')), array('label' => t('Ignored'), 'url' => z_root() . '/connections/ignored', 'sel' => $ignored ? 'active' : '', 'title' => t('Only show ignored connections')), array('label' => t('Archived'), 'url' => z_root() . '/connections/archived', 'sel' => $archived ? 'active' : '', 'title' => t('Only show archived connections')), array('label' => t('Hidden'), 'url' => z_root() . '/connections/hidden', 'sel' => $hidden ? 'active' : '', 'title' => t('Only show hidden connections')));
    $tab_tpl = get_markup_template('common_tabs.tpl');
    $t = replace_macros($tab_tpl, array('$tabs' => $tabs));
    $searching = false;
    if ($search) {
        $search_hdr = $search;
        $search_txt = dbesc(protect_sprintf(preg_quote($search)));
        $searching = true;
    }
    $sql_extra .= $searching ? protect_sprintf(" AND xchan_name like '%{$search_txt}%' ") : "";
    if ($_REQUEST['gid']) {
        $sql_extra .= " and xchan_hash in ( select xchan from group_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) ";
    }
    $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash \n\t\twhere abook_channel = %d and not (abook_flags & %d)>0 and not (xchan_flags & %d )>0 {$sql_extra} {$sql_extra2} ", intval(local_channel()), intval(ABOOK_FLAG_SELF), intval(XCHAN_FLAGS_DELETED | XCHAN_FLAGS_ORPHAN));
    if ($r) {
        $a->set_pager_total($r[0]['total']);
        $total = $r[0]['total'];
    }
    $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash\n\t\tWHERE abook_channel = %d and not (abook_flags & %d)>0 and not ( xchan_flags & %d)>0 {$sql_extra} {$sql_extra2} ORDER BY xchan_name LIMIT %d OFFSET %d ", intval(local_channel()), intval(ABOOK_FLAG_SELF), intval(XCHAN_FLAGS_DELETED | XCHAN_FLAGS_ORPHAN), intval($a->pager['itemspage']), intval($a->pager['start']));
    $contacts = array();
    if (count($r)) {
        foreach ($r as $rr) {
            if ($rr['xchan_url']) {
                $contacts[] = array('img_hover' => sprintf(t('%1$s [%2$s]'), $rr['xchan_name'], $rr['xchan_url']), 'edit_hover' => t('Edit connection'), 'id' => $rr['abook_id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => $rr['xchan_photo_m'], 'name' => $rr['xchan_name'], 'username' => $rr['xchan_name'], 'classes' => $rr['abook_flags'] & ABOOK_FLAG_ARCHIVED ? 'archived' : '', 'link' => z_root() . '/connedit/' . $rr['abook_id'], 'edit' => t('Edit'), 'url' => chanlink_url($rr['xchan_url']), 'network' => network_to_name($rr['network']));
            }
        }
    }
    if ($_REQUEST['aj']) {
        if ($contacts) {
            $o = replace_macros(get_markup_template('contactsajax.tpl'), array('$contacts' => $contacts, '$edit' => t('Edit')));
        } else {
            $o = '<div id="content-complete"></div>';
        }
        echo $o;
        killme();
    } else {
        $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
        $o .= replace_macros(get_markup_template('connections.tpl'), array('$header' => t('Connections') . ($head ? ' - ' . $head : ''), '$tabs' => $t, '$total' => $total, '$search' => $search_hdr, '$desc' => t('Search your connections'), '$finding' => $searching ? t('Finding: ') . "'" . $search . "'" : "", '$submit' => t('Find'), '$edit' => t('Edit'), '$cmd' => $a->cmd, '$contacts' => $contacts, '$paginate' => paginate($a)));
    }
    if (!$contacts) {
        $o .= '<div id="content-complete"></div>';
    }
    return $o;
}
Пример #10
0
/**
 * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
 *
 * Increments the count of each matching activity and adds a link to the author as needed.
 *
 * @param array $item
 * @param array &$conv_responses (already created with builtin activity structure)
 */
function builtin_activity_puller($item, &$conv_responses)
{
    // if this item is a post or comment there's nothing for us to do here, just return.
    if (activity_match($item['verb'], ACTIVITY_POST)) {
        return;
    }
    foreach ($conv_responses as $mode => $v) {
        $url = '';
        switch ($mode) {
            case 'like':
                $verb = ACTIVITY_LIKE;
                break;
            case 'dislike':
                $verb = ACTIVITY_DISLIKE;
                break;
            case 'agree':
                $verb = ACTIVITY_AGREE;
                break;
            case 'disagree':
                $verb = ACTIVITY_DISAGREE;
                break;
            case 'abstain':
                $verb = ACTIVITY_ABSTAIN;
                break;
            case 'attendyes':
                $verb = ACTIVITY_ATTEND;
                break;
            case 'attendno':
                $verb = ACTIVITY_ATTENDNO;
                break;
            case 'attendmaybe':
                $verb = ACTIVITY_ATTENDMAYBE;
                break;
            default:
                return;
                break;
        }
        if (activity_match($item['verb'], $verb) && $item['id'] != $item['parent']) {
            $name = $item['author']['xchan_name'] ? $item['author']['xchan_name'] : t('Unknown');
            $url = $item['author']['xchan_url'] ? '<a href="' . chanlink_url($item['author']['xchan_url']) . '">' . $name . '</a>' : '<a href="#" class="disabled">' . $name . '</a>';
            if (!$item['thr_parent']) {
                $item['thr_parent'] = $item['parent_mid'];
            }
            if (!(isset($conv_responses[$mode][$item['thr_parent'] . '-l']) && is_array($conv_responses[$mode][$item['thr_parent'] . '-l']))) {
                $conv_responses[$mode][$item['thr_parent'] . '-l'] = array();
            }
            // only list each unique author once
            if (in_array($url, $conv_responses[$mode][$item['thr_parent'] . '-l'])) {
                continue;
            }
            if (!isset($conv_responses[$mode][$item['thr_parent']])) {
                $conv_responses[$mode][$item['thr_parent']] = 1;
            } else {
                $conv_responses[$mode][$item['thr_parent']]++;
            }
            $conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
            // there can only be one activity verb per item so if we found anything, we can stop looking
            return;
        }
    }
}
Пример #11
0
 function get()
 {
     if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) {
         notice(t('Public access denied.') . EOL);
         return;
     }
     $observer = get_observer_hash();
     $globaldir = get_directory_setting($observer, 'globaldir');
     // override your personal global search pref if we're doing a navbar search of the directory
     if (intval($_REQUEST['navsearch'])) {
         $globaldir = 1;
     }
     $safe_mode = get_directory_setting($observer, 'safemode');
     $pubforums = get_directory_setting($observer, 'pubforums');
     $o = '';
     nav_set_selected('directory');
     if (x($_POST, 'search')) {
         $search = notags(trim($_POST['search']));
     } else {
         $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
     }
     if (strpos($search, '=') && local_channel() && get_pconfig(local_channel(), 'feature', 'expert')) {
         $advanced = $search;
     }
     $keywords = $_GET['keywords'] ? $_GET['keywords'] : '';
     // Suggest channels if no search terms or keywords are given
     $suggest = local_channel() && x($_REQUEST, 'suggest') ? $_REQUEST['suggest'] : '';
     if ($suggest) {
         $r = suggestion_query(local_channel(), get_observer_hash());
         // Remember in which order the suggestions were
         $addresses = array();
         $common = array();
         $index = 0;
         foreach ($r as $rr) {
             $common[$rr['xchan_addr']] = $rr['total'];
             $addresses[$rr['xchan_addr']] = $index++;
         }
         // Build query to get info about suggested people
         $advanced = '';
         foreach (array_keys($addresses) as $address) {
             $advanced .= "address=\"{$address}\" ";
         }
         // Remove last space in the advanced query
         $advanced = rtrim($advanced);
     }
     $tpl = get_markup_template('directory_header.tpl');
     $dirmode = intval(get_config('system', 'directory_mode'));
     if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
         $url = z_root() . '/dirsearch';
     }
     if (!$url) {
         $directory = find_upstream_directory($dirmode);
         if (!$directory || !array_key_exists('url', $directory) || !$directory['url']) {
             logger('CRITICAL: No directory server URL');
         }
         $url = $directory['url'] . '/dirsearch';
     }
     $token = get_config('system', 'realm_token');
     logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
     $contacts = array();
     if (local_channel()) {
         $x = q("select abook_xchan from abook where abook_channel = %d", intval(local_channel()));
         if ($x) {
             foreach ($x as $xx) {
                 $contacts[] = $xx['abook_xchan'];
             }
         }
     }
     if ($url) {
         $numtags = get_config('system', 'directorytags');
         $kw = intval($numtags) > 0 ? intval($numtags) : 50;
         if (get_config('system', 'disable_directory_keywords')) {
             $kw = 0;
         }
         $query = $url . '?f=&kw=' . $kw . ($safe_mode != 1 ? '&safe=' . $safe_mode : '');
         if ($token) {
             $query .= '&t=' . $token;
         }
         if (!$globaldir) {
             $query .= '&hub=' . \App::get_hostname();
         }
         if ($search) {
             $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
         }
         if (strpos($search, '@')) {
             $query .= '&address=' . urlencode($search);
         }
         if ($keywords) {
             $query .= '&keywords=' . urlencode($keywords);
         }
         if ($advanced) {
             $query .= '&query=' . urlencode($advanced);
         }
         if (!is_null($pubforums)) {
             $query .= '&pubforums=' . intval($pubforums);
         }
         $directory_sort_order = get_config('system', 'directory_sort_order');
         if (!$directory_sort_order) {
             $directory_sort_order = 'date';
         }
         $sort_order = x($_REQUEST, 'order') ? $_REQUEST['order'] : $directory_sort_order;
         if ($sort_order) {
             $query .= '&order=' . urlencode($sort_order);
         }
         if (\App::$pager['page'] != 1) {
             $query .= '&p=' . \App::$pager['page'];
         }
         logger('mod_directory: query: ' . $query);
         $x = z_fetch_url($query);
         logger('directory: return from upstream: ' . print_r($x, true), LOGGER_DATA);
         if ($x['success']) {
             $t = 0;
             $j = json_decode($x['body'], true);
             if ($j) {
                 if ($j['results']) {
                     $entries = array();
                     $photo = 'thumb';
                     foreach ($j['results'] as $rr) {
                         $profile_link = chanlink_url($rr['url']);
                         $pdesc = $rr['description'] ? $rr['description'] . '<br />' : '';
                         $connect_link = local_channel() ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '';
                         // Checking status is disabled ATM until someone checks the performance impact more carefully
                         //$online = remote_online_status($rr['address']);
                         $online = '';
                         if (in_array($rr['hash'], $contacts)) {
                             $connect_link = '';
                         }
                         $location = '';
                         if (strlen($rr['locale'])) {
                             $location .= $rr['locale'];
                         }
                         if (strlen($rr['region'])) {
                             if (strlen($rr['locale'])) {
                                 $location .= ', ';
                             }
                             $location .= $rr['region'];
                         }
                         if (strlen($rr['country'])) {
                             if (strlen($location)) {
                                 $location .= ', ';
                             }
                             $location .= $rr['country'];
                         }
                         $age = '';
                         if (strlen($rr['birthday'])) {
                             if (($years = age($rr['birthday'], 'UTC', '')) != 0) {
                                 $age = $years;
                             }
                         }
                         $page_type = '';
                         if ($rr['total_ratings']) {
                             $total_ratings = sprintf(tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']);
                         } else {
                             $total_ratings = '';
                         }
                         $profile = $rr;
                         if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) {
                             $gender = x($profile, 'gender') == 1 ? t('Gender: ') . $profile['gender'] : False;
                         }
                         $marital = x($profile, 'marital') == 1 ? t('Status: ') . $profile['marital'] : False;
                         $homepage = x($profile, 'homepage') == 1 ? t('Homepage: ') : False;
                         $homepageurl = x($profile, 'homepage') == 1 ? $profile['homepage'] : '';
                         $hometown = x($profile, 'hometown') == 1 ? $profile['hometown'] : False;
                         $about = x($profile, 'about') == 1 ? bbcode($profile['about']) : False;
                         $keywords = x($profile, 'keywords') ? $profile['keywords'] : '';
                         $out = '';
                         if ($keywords) {
                             $keywords = str_replace(',', ' ', $keywords);
                             $keywords = str_replace('  ', ' ', $keywords);
                             $karr = explode(' ', $keywords);
                             if ($karr) {
                                 if (local_channel()) {
                                     $r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval(local_channel()));
                                     if ($r) {
                                         $keywords = str_replace(',', ' ', $r[0]['keywords']);
                                         $keywords = str_replace('  ', ' ', $keywords);
                                         $marr = explode(' ', $keywords);
                                     }
                                 }
                                 foreach ($karr as $k) {
                                     if (strlen($out)) {
                                         $out .= ', ';
                                     }
                                     if ($marr && in_arrayi($k, $marr)) {
                                         $out .= '<strong>' . $k . '</strong>';
                                     } else {
                                         $out .= $k;
                                     }
                                 }
                             }
                         }
                         $entry = array('id' => ++$t, 'profile_link' => $profile_link, 'public_forum' => $rr['public_forum'], 'photo' => $rr['photo'], 'hash' => $rr['hash'], 'alttext' => $rr['name'] . (local_channel() || remote_channel() ? ' ' . $rr['address'] : ''), 'name' => $rr['name'], 'age' => $age, 'age_label' => t('Age:'), 'profile' => $profile, 'address' => $rr['address'], 'nickname' => substr($rr['address'], 0, strpos($rr['address'], '@')), 'location' => $location, 'location_label' => t('Location:'), 'gender' => $gender, 'total_ratings' => $total_ratings, 'viewrate' => true, 'canrate' => local_channel() ? true : false, 'pdesc' => $pdesc, 'pdesc_label' => t('Description:'), 'marital' => $marital, 'homepage' => $homepage, 'homepageurl' => linkify($homepageurl), 'hometown' => $hometown, 'hometown_label' => t('Hometown:'), 'about' => $about, 'about_label' => t('About:'), 'conn_label' => t('Connect'), 'forum_label' => t('Public Forum:'), 'connect' => $connect_link, 'online' => $online, 'kw' => $out ? t('Keywords: ') : '', 'keywords' => $out, 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => t('Don\'t suggest'), 'common_friends' => $common[$rr['address']] ? intval($common[$rr['address']]) : '', 'common_label' => t('Common connections:'), 'common_count' => intval($common[$rr['address']]), 'safe' => $safe_mode);
                         $arr = array('contact' => $rr, 'entry' => $entry);
                         call_hooks('directory_item', $arr);
                         unset($profile);
                         unset($location);
                         if (!$arr['entry']) {
                             continue;
                         }
                         if ($sort_order == '' && $suggest) {
                             $entries[$addresses[$rr['address']]] = $arr['entry'];
                             // Use the same indexes as originally to get the best suggestion first
                         } else {
                             $entries[] = $arr['entry'];
                         }
                     }
                     ksort($entries);
                     // Sort array by key so that foreach-constructs work as expected
                     if ($j['keywords']) {
                         \App::$data['directory_keywords'] = $j['keywords'];
                     }
                     logger('mod_directory: entries: ' . print_r($entries, true), LOGGER_DATA);
                     if ($_REQUEST['aj']) {
                         if ($entries) {
                             $o = replace_macros(get_markup_template('directajax.tpl'), array('$entries' => $entries));
                         } else {
                             $o = '<div id="content-complete"></div>';
                         }
                         echo $o;
                         killme();
                     } else {
                         $maxheight = 94;
                         $dirtitle = $globaldir ? t('Global Directory') : t('Local Directory');
                         $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . ";  </script>";
                         $o .= replace_macros($tpl, array('$search' => $search, '$desc' => t('Find'), '$finddsc' => t('Finding:'), '$safetxt' => htmlspecialchars($search, ENT_QUOTES, 'UTF-8'), '$entries' => $entries, '$dirlbl' => $suggest ? t('Channel Suggestions') : $dirtitle, '$submit' => t('Find'), '$next' => alt_pager($a, $j['records'], t('next page'), t('previous page')), '$sort' => t('Sort options'), '$normal' => t('Alphabetic'), '$reverse' => t('Reverse Alphabetic'), '$date' => t('Newest to Oldest'), '$reversedate' => t('Oldest to Newest'), '$suggest' => $suggest ? '&suggest=1' : ''));
                     }
                 } else {
                     if ($_REQUEST['aj']) {
                         $o = '<div id="content-complete"></div>';
                         echo $o;
                         killme();
                     }
                     if (\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search, '@')) {
                         goaway(z_root() . '/chanview/?f=&address=' . $search);
                     }
                     info(t("No entries (some entries may be hidden).") . EOL);
                 }
             }
         }
     }
     return $o;
 }
Пример #12
0
 function get()
 {
     $sort_type = 0;
     $o = '';
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return login();
     }
     $blocked = false;
     $hidden = false;
     $ignored = false;
     $archived = false;
     $unblocked = false;
     $pending = false;
     $unconnected = false;
     $all = false;
     if (!$_REQUEST['aj']) {
         $_SESSION['return_url'] = \App::$query_string;
     }
     $search_flags = '';
     $head = '';
     if (argc() == 2) {
         switch (argv(1)) {
             case 'blocked':
                 $search_flags = " and abook_blocked = 1 ";
                 $head = t('Blocked');
                 $blocked = true;
                 break;
             case 'ignored':
                 $search_flags = " and abook_ignored = 1 ";
                 $head = t('Ignored');
                 $ignored = true;
                 break;
             case 'hidden':
                 $search_flags = " and abook_hidden = 1 ";
                 $head = t('Hidden');
                 $hidden = true;
                 break;
             case 'archived':
                 $search_flags = " and abook_archived = 1 ";
                 $head = t('Archived');
                 $archived = true;
                 break;
             case 'pending':
                 $search_flags = " and abook_pending = 1 ";
                 $head = t('New');
                 $pending = true;
                 nav_set_selected('intros');
                 break;
             case 'ifpending':
                 $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", intval(local_channel()));
                 if ($r && $r[0]['total']) {
                     $search_flags = " and abook_pending = 1 ";
                     $head = t('New');
                     $pending = true;
                     nav_set_selected('intros');
                     \App::$argv[1] = 'pending';
                 } else {
                     $head = t('All');
                     $search_flags = '';
                     $all = true;
                     \App::$argc = 1;
                     unset(\App::$argv[1]);
                 }
                 nav_set_selected('intros');
                 break;
                 //			case 'unconnected':
                 //				$search_flags = " and abook_unconnected = 1 ";
                 //				$head = t('Unconnected');
                 //				$unconnected = true;
                 //				break;
             //			case 'unconnected':
             //				$search_flags = " and abook_unconnected = 1 ";
             //				$head = t('Unconnected');
             //				$unconnected = true;
             //				break;
             case 'all':
                 $head = t('All');
             default:
                 $search_flags = '';
                 $all = true;
                 break;
         }
         $sql_extra = $search_flags;
         if (argv(1) === 'pending') {
             $sql_extra .= " and abook_ignored = 0 ";
         }
     } else {
         $sql_extra = " and abook_blocked = 0 ";
         $unblocked = true;
     }
     $search = x($_REQUEST, 'search') ? notags(trim($_REQUEST['search'])) : '';
     $tabs = array('pending' => array('label' => t('New Connections'), 'url' => z_root() . '/connections/pending', 'sel' => $pending ? 'active' : '', 'title' => t('Show pending (new) connections')), 'all' => array('label' => t('All Connections'), 'url' => z_root() . '/connections/all', 'sel' => $all ? 'active' : '', 'title' => t('Show all connections')), 'blocked' => array('label' => t('Blocked'), 'url' => z_root() . '/connections/blocked', 'sel' => $blocked ? 'active' : '', 'title' => t('Only show blocked connections')), 'ignored' => array('label' => t('Ignored'), 'url' => z_root() . '/connections/ignored', 'sel' => $ignored ? 'active' : '', 'title' => t('Only show ignored connections')), 'archived' => array('label' => t('Archived'), 'url' => z_root() . '/connections/archived', 'sel' => $archived ? 'active' : '', 'title' => t('Only show archived connections')), 'hidden' => array('label' => t('Hidden'), 'url' => z_root() . '/connections/hidden', 'sel' => $hidden ? 'active' : '', 'title' => t('Only show hidden connections')));
     //$tab_tpl = get_markup_template('common_tabs.tpl');
     //$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
     $searching = false;
     if ($search) {
         $search_hdr = $search;
         $search_txt = dbesc(protect_sprintf(preg_quote($search)));
         $searching = true;
     }
     $sql_extra .= $searching ? protect_sprintf(" AND xchan_name like '%{$search_txt}%' ") : "";
     if ($_REQUEST['gid']) {
         $sql_extra .= " and xchan_hash in ( select xchan from group_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) ";
     }
     $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash \n\t\t\twhere abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 {$sql_extra} {$sql_extra2} ", intval(local_channel()));
     if ($r) {
         \App::set_pager_total($r[0]['total']);
         $total = $r[0]['total'];
     }
     $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash\n\t\t\tWHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 {$sql_extra} {$sql_extra2} ORDER BY xchan_name LIMIT %d OFFSET %d ", intval(local_channel()), intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
     $contacts = array();
     if (count($r)) {
         foreach ($r as $rr) {
             if ($rr['xchan_url']) {
                 $status_str = '';
                 $status = array(intval($rr['abook_pending']) ? t('Pending approval') : '', intval($rr['abook_archived']) ? t('Archived') : '', intval($rr['abook_hidden']) ? t('Hidden') : '', intval($rr['abook_ignored']) ? t('Ignored') : '', intval($rr['abook_blocked']) ? t('Blocked') : '');
                 foreach ($status as $str) {
                     if (!$str) {
                         continue;
                     }
                     $status_str .= $str;
                     $status_str .= ', ';
                 }
                 $status_str = rtrim($status_str, ', ');
                 $contacts[] = array('img_hover' => sprintf(t('%1$s [%2$s]'), $rr['xchan_name'], $rr['xchan_url']), 'edit_hover' => t('Edit connection'), 'delete_hover' => t('Delete connection'), 'id' => $rr['abook_id'], 'thumb' => $rr['xchan_photo_m'], 'name' => $rr['xchan_name'], 'classes' => intval($rr['abook_archived']) ? 'archived' : '', 'link' => z_root() . '/connedit/' . $rr['abook_id'], 'deletelink' => z_root() . '/connedit/' . intval($rr['abook_id']) . '/drop', 'delete' => t('Delete'), 'url' => chanlink_url($rr['xchan_url']), 'webbie_label' => t('Channel address'), 'webbie' => $rr['xchan_addr'], 'network_label' => t('Network'), 'network' => network_to_name($rr['xchan_network']), 'public_forum' => intval($rr['xchan_pubforum']) ? true : false, 'status_label' => t('Status'), 'status' => $status_str, 'connected_label' => t('Connected'), 'connected' => datetime_convert('UTC', date_default_timezone_get(), $rr['abook_created'], 'c'), 'approve_hover' => t('Approve connection'), 'approve' => $rr['abook_pending'] ? t('Approve') : false, 'ignore_hover' => t('Ignore connection'), 'ignore' => !$rr['abook_ignored'] ? t('Ignore') : false, 'recent_label' => t('Recent activity'), 'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id']));
             }
         }
     }
     if ($_REQUEST['aj']) {
         if ($contacts) {
             $o = replace_macros(get_markup_template('contactsajax.tpl'), array('$contacts' => $contacts, '$edit' => t('Edit')));
         } else {
             $o = '<div id="content-complete"></div>';
         }
         echo $o;
         killme();
     } else {
         $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
         $o .= replace_macros(get_markup_template('connections.tpl'), array('$header' => t('Connections') . ($head ? ': ' . $head : ''), '$tabs' => $tabs, '$total' => $total, '$search' => $search_hdr, '$label' => t('Search'), '$desc' => t('Search your connections'), '$finding' => $searching ? t('Connections search') . ": '" . $search . "'" : "", '$submit' => t('Find'), '$edit' => t('Edit'), '$cmd' => \App::$cmd, '$contacts' => $contacts, '$paginate' => paginate($a)));
     }
     if (!$contacts) {
         $o .= '<div id="content-complete"></div>';
     }
     return $o;
 }
Пример #13
0
function visage_content(&$a)
{
    if (!local_channel()) {
        return;
    }
    $o = '<h3>' . t('Recent Channel/Profile Viewers') . '</h3>';
    $enabled = get_pconfig(local_channel(), 'visage', 'enabled');
    if (!$enabled) {
        $o .= t('This plugin/addon has not been configured.') . EOL;
        $o .= sprintf(t('Please visit the Visage settings on %s'), '<a href="settings/featured">' . t('your feature settings page') . '</a>');
        return $o;
    }
    // let's play fair.
    require_once 'include/identity.php';
    if (!is_public_profile()) {
        return $o;
    }
    $x = get_pconfig(local_channel(), 'visage', 'visitors');
    if (!$x || !is_array($x)) {
        $o .= t('No entries.');
        return $o;
    }
    $chans = '';
    for ($n = 0; $n < count($x); $n++) {
        if ($chans) {
            $chans .= ',';
        }
        $chans .= "'" . dbesc($x[$n][0]) . "'";
    }
    if ($chans) {
        $r = q("select * from xchan where xchan_hash in ( {$chans} )");
    }
    if ($r) {
        $tpl = get_markup_template('common_friends.tpl');
        for ($g = count($x) - 1; $g >= 0; $g--) {
            foreach ($r as $rr) {
                if ($x[$g][0] == $rr['xchan_hash']) {
                    break;
                }
            }
            $o .= replace_macros($tpl, array('$url' => $rr['xchan_flags'] & XCHAN_FLAGS_HIDDEN ? z_root() : chanlink_url($rr['xchan_url']), '$name' => $rr['xchan_name'], '$photo' => $rr['xchan_photo_m'], '$tags' => $rr['xchan_flags'] & XCHAN_FLAGS_HIDDEN ? z_root() : chanlink_url($rr['xchan_url']), '$note' => relative_date($x[$g][1])));
        }
        $o .= cleardiv();
    }
    return $o;
}
Пример #14
0
function like_puller($a, $item, &$arr, $mode)
{
    $url = '';
    $sparkle = '';
    $verb = $mode === 'like' ? ACTIVITY_LIKE : ACTIVITY_DISLIKE;
    if (activity_match($item['verb'], $verb) && $item['id'] != $item['parent']) {
        $url = chanlink_url($item['author']['xchan_url']);
        if (!$item['thr_parent']) {
            $item['thr_parent'] = $item['parent_mid'];
        }
        if (!(isset($arr[$item['thr_parent'] . '-l']) && is_array($arr[$item['thr_parent'] . '-l']))) {
            $arr[$item['thr_parent'] . '-l'] = array();
        }
        if (!isset($arr[$item['thr_parent']])) {
            $arr[$item['thr_parent']] = 1;
        } else {
            $arr[$item['thr_parent']]++;
        }
        $arr[$item['thr_parent'] . '-l'][] = '<a href="' . $url . '">' . $item['author']['xchan_name'] . '</a>';
    }
    return;
}
Пример #15
0
function dirprofile_init(&$a)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        notice(t('Public access denied.') . EOL);
        return;
    }
    $hash = $_REQUEST['hash'];
    if (!$hash) {
        return '';
    }
    $o = '';
    $dirmode = intval(get_config('system', 'directory_mode'));
    if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
        $url = z_root() . '/dirsearch';
    }
    if (!$url) {
        $directory = find_upstream_directory($dirmode);
        $url = $directory['url'] . '/dirsearch';
    }
    logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
    $contacts = array();
    if (local_user()) {
        $x = q("select abook_xchan from abook where abook_channel = %d", intval(local_user()));
        if ($x) {
            foreach ($x as $xx) {
                $contacts[] = $xx['abook_xchan'];
            }
        }
    }
    if ($url) {
        $query = $url . '?f=&hash=' . $hash;
        $x = z_fetch_url($query);
        logger('dirprofile: return from upstream: ' . print_r($x, true), LOGGER_DATA);
        if ($x['success']) {
            $t = 0;
            $j = json_decode($x['body'], true);
            if ($j) {
                if ($j['results']) {
                    $entries = array();
                    $photo = 'thumb';
                    foreach ($j['results'] as $rr) {
                        $profile_link = chanlink_url($rr['url']);
                        $pdesc = $rr['description'] ? $rr['description'] . '<br />' : '';
                        $qrlink = zid($rr['url']);
                        $connect_link = local_user() ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '';
                        $online = remote_online_status($rr['address']);
                        if (in_array($rr['hash'], $contacts)) {
                            $connect_link = '';
                        }
                        $details = '';
                        if (strlen($rr['locale'])) {
                            $details .= $rr['locale'];
                        }
                        if (strlen($rr['region'])) {
                            if (strlen($rr['locale'])) {
                                $details .= ', ';
                            }
                            $details .= $rr['region'];
                        }
                        if (strlen($rr['country'])) {
                            if (strlen($details)) {
                                $details .= ', ';
                            }
                            $details .= $rr['country'];
                        }
                        if (strlen($rr['birthday'])) {
                            if (($years = age($rr['birthday'], 'UTC', '')) != 0) {
                                $details .= '<br />' . t('Age: ') . $years;
                            }
                        }
                        if (strlen($rr['gender'])) {
                            $details .= '<br />' . t('Gender: ') . $rr['gender'];
                        }
                        $page_type = '';
                        $profile = $rr;
                        if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) {
                            $location = t('Location:');
                        }
                        $marital = x($profile, 'marital') == 1 ? t('Status: ') . $profile['marital'] : False;
                        $sexual = x($profile, 'sexual') == 1 ? t('Sexual Preference: ') . $profile['sexual'] : False;
                        $homepage = x($profile, 'homepage') == 1 ? t('Homepage: ') . linkify($profile['homepage']) : False;
                        $hometown = x($profile, 'hometown') == 1 ? t('Hometown: ') . $profile['hometown'] : False;
                        $about = x($profile, 'about') == 1 ? t('About: ') . bbcode($profile['about']) : False;
                        $keywords = x($profile, 'keywords') ? $profile['keywords'] : '';
                        if ($keywords) {
                            $keywords = str_replace(',', ' ', $keywords);
                            $keywords = str_replace('  ', ' ', $keywords);
                            $karr = explode(' ', $keywords);
                            $out = '';
                            if ($karr) {
                                if (local_user()) {
                                    $r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval(local_user()));
                                    if ($r) {
                                        $keywords = str_replace(',', ' ', $r[0]['keywords']);
                                        $keywords = str_replace('  ', ' ', $keywords);
                                        $marr = explode(' ', $keywords);
                                    }
                                }
                                foreach ($karr as $k) {
                                    if (strlen($out)) {
                                        $out .= ', ';
                                    }
                                    if ($marr && in_arrayi($k, $marr)) {
                                        $out .= '<strong>' . $k . '</strong>';
                                    } else {
                                        $out .= $k;
                                    }
                                }
                            }
                        }
                        $entry = replace_macros(get_markup_template('direntry_large.tpl'), array('$id' => ++$t, '$profile_link' => $profile_link, '$qrlink' => $qrlink, '$photo' => $rr['photo_l'], '$alttext' => $rr['name'] . ' ' . $rr['address'], '$name' => $rr['name'], '$online' => $online ? t('Online Now') : '', '$details' => $pdesc . $details, '$profile' => $profile, '$address' => $rr['address'], '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$hometown' => $hometown, '$about' => $about, '$kw' => $out ? t('Keywords: ') : '', '$keywords' => $out, '$conn_label' => t('Connect'), '$connect' => $connect_link));
                        echo $entry;
                        killme();
                    }
                } else {
                    info(t("Not found.") . EOL);
                }
            }
        }
    }
}
Пример #16
0
 /**
  * Check if we are a wall to wall item and set the relevant properties
  */
 protected function check_wall_to_wall()
 {
     $conv = $this->get_conversation();
     $this->wall_to_wall = false;
     $this->owner_url = '';
     $this->owner_photo = '';
     $this->owner_name = '';
     if ($conv->get_mode() === 'channel') {
         return;
     }
     if ($this->is_toplevel() && $this->get_data_value('author_xchan') != $this->get_data_value('owner_xchan')) {
         $this->owner_url = chanlink_url($this->data['owner']['xchan_url']);
         $this->owner_photo = $this->data['owner']['xchan_photo_m'];
         $this->owner_name = $this->data['owner']['xchan_name'];
         $this->wall_to_wall = true;
     }
 }
Пример #17
0
function widget_suggestions($arr)
{
    if (!local_user() || !feature_enabled(local_user(), 'suggest')) {
        return '';
    }
    require_once 'include/socgraph.php';
    $r = suggestion_query(local_user(), get_observer_hash(), 0, 20);
    if (!$r) {
        return;
    }
    $arr = array();
    // Get two random entries from the top 20 returned.
    // We'll grab the first one and the one immediately following.
    // This will throw some entropy intot he situation so you won't
    // be looking at the same two mug shots every time the widget runs
    $index = count($r) > 2 ? mt_rand(0, count($r) - 2) : 0;
    for ($x = $index; $x <= $index + 1; $x++) {
        $rr = $r[$x];
        if (!$rr['xchan_url']) {
            break;
        }
        $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
        $arr[] = array('url' => chanlink_url($rr['xchan_url']), 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide'));
    }
    $o = replace_macros(get_markup_template('suggest_widget.tpl'), array('$title' => t('Suggestions'), '$more' => t('See more...'), '$entries' => $arr));
    return $o;
}
Пример #18
0
function directory_content(&$a)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        notice(t('Public access denied.') . EOL);
        return;
    }
    $safe_mode = 1;
    $observer = get_observer_hash();
    if ($observer) {
        $safe_mode = get_xconfig($observer, 'directory', 'safe_mode');
    }
    if ($safe_mode === false) {
        $safe_mode = 1;
    } else {
        $safe_mode = intval($safe_mode);
    }
    if (x($_REQUEST, 'safe')) {
        $safe_mode = intval($_REQUEST['safe']);
    }
    $o = '';
    nav_set_selected('directory');
    if (x($_POST, 'search')) {
        $search = notags(trim($_POST['search']));
    } else {
        $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
    }
    $advanced = x($_REQUEST, 'query') ? notags(trim($_REQUEST['query'])) : '';
    $keywords = $_GET['keywords'] ? $_GET['keywords'] : '';
    $tpl = get_markup_template('directory_header.tpl');
    $dirmode = intval(get_config('system', 'directory_mode'));
    if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
        $url = z_root() . '/dirsearch';
    }
    if (!$url) {
        $directory = find_upstream_directory($dirmode);
        $url = $directory['url'] . '/dirsearch';
    }
    logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
    $contacts = array();
    if (local_user()) {
        $x = q("select abook_xchan from abook where abook_channel = %d", intval(local_user()));
        if ($x) {
            foreach ($x as $xx) {
                $contacts[] = $xx['abook_xchan'];
            }
        }
    }
    if ($url) {
        // We might want to make the tagadelic count (&kw=) configurable or turn it off completely.
        $numtags = get_config('system', 'directorytags');
        $kw = intval($numtags) ? $numtags : 24;
        $query = $url . '?f=&kw=' . $kw . ($safe_mode != 1 ? '&safe=' . $safe_mode : '');
        if ($search) {
            $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
        }
        if (strpos($search, '@')) {
            $query .= '&address=' . urlencode($search);
        }
        if ($keywords) {
            $query .= '&keywords=' . urlencode($keywords);
        }
        if ($advanced) {
            $query .= '&query=' . urlencode($advanced);
        }
        $sort_order = x($_REQUEST, 'order') ? $_REQUEST['order'] : '';
        if ($sort_order) {
            $query .= '&order=' . urlencode($sort_order);
        }
        if ($a->pager['page'] != 1) {
            $query .= '&p=' . $a->pager['page'];
        }
        logger('mod_directory: query: ' . $query);
        $x = z_fetch_url($query);
        logger('directory: return from upstream: ' . print_r($x, true), LOGGER_DATA);
        if ($x['success']) {
            $t = 0;
            $j = json_decode($x['body'], true);
            if ($j) {
                if ($j['results']) {
                    $entries = array();
                    $photo = 'thumb';
                    foreach ($j['results'] as $rr) {
                        $profile_link = chanlink_url($rr['url']);
                        $pdesc = $rr['description'] ? $rr['description'] . '<br />' : '';
                        $connect_link = local_user() ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '';
                        if (in_array($rr['hash'], $contacts)) {
                            $connect_link = '';
                        }
                        $details = '';
                        if (strlen($rr['locale'])) {
                            $details .= $rr['locale'];
                        }
                        if (strlen($rr['region'])) {
                            if (strlen($rr['locale'])) {
                                $details .= ', ';
                            }
                            $details .= $rr['region'];
                        }
                        if (strlen($rr['country'])) {
                            if (strlen($details)) {
                                $details .= ', ';
                            }
                            $details .= $rr['country'];
                        }
                        if (strlen($rr['birthday'])) {
                            if (($years = age($rr['birthday'], 'UTC', '')) != 0) {
                                $details .= '<br />' . t('Age: ') . $years;
                            }
                        }
                        if (strlen($rr['gender'])) {
                            $details .= '<br />' . t('Gender: ') . $rr['gender'];
                        }
                        $page_type = '';
                        $profile = $rr;
                        if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) {
                            $location = t('Location:');
                        }
                        $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
                        $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
                        $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
                        $about = x($profile, 'about') == 1 ? t('About:') : False;
                        $entry = array('id' => ++$t, 'profile_link' => $profile_link, 'photo' => $rr['photo'], 'hash' => $rr['hash'], 'alttext' => $rr['name'] . ' ' . $rr['address'], 'name' => $rr['name'], 'details' => $pdesc . $details, 'profile' => $profile, 'address' => $rr['address'], 'location' => $location, 'gender' => $gender, 'pdesc' => $pdesc, 'marital' => $marital, 'homepage' => $homepage, 'about' => $about, 'conn_label' => t('Connect'), 'connect' => $connect_link);
                        $arr = array('contact' => $rr, 'entry' => $entry);
                        call_hooks('directory_item', $arr);
                        $entries[] = $arr['entry'];
                        unset($profile);
                        unset($location);
                    }
                    if ($j['keywords']) {
                        $a->data['directory_keywords'] = $j['keywords'];
                    }
                    logger('mod_directory: entries: ' . print_r($entries, true), LOGGER_DATA);
                    if ($_REQUEST['aj']) {
                        if ($entries) {
                            $o = replace_macros(get_markup_template('directajax.tpl'), array('$entries' => $entries));
                        } else {
                            $o = '<div id="content-complete"></div>';
                        }
                        echo $o;
                        killme();
                    } else {
                        $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
                        $o .= replace_macros($tpl, array('$search' => $search, '$desc' => t('Find'), '$finddsc' => t('Finding:'), '$safetxt' => htmlspecialchars($search, ENT_QUOTES, 'UTF-8'), '$entries' => $entries, '$dirlbl' => t('Directory'), '$submit' => t('Find'), '$next' => alt_pager($a, $j['records'], t('next page'), t('previous page'))));
                    }
                } else {
                    if ($_REQUEST['aj']) {
                        $o = '<div id="content-complete"></div>';
                        echo $o;
                        killme();
                    }
                    if ($a->pager['page'] == 1 && $j['records'] == 0 && strpos($search, '@')) {
                        goaway(z_root() . '/chanview/?f=&address=' . $search);
                    }
                    info(t("No entries (some entries may be hidden).") . EOL);
                }
            }
        }
    }
    return $o;
}