function friendheader_widget_content(&$a, $conf)
{
    $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` \n\t\t\tLEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`\n\t\t\tWHERE `user`.`uid` = %s AND `profile`.`is-default` = 1 LIMIT 1", intval($conf['uid']));
    if (!count($r)) {
        return;
    }
    $a->profile = $r[0];
    $o = "";
    $o .= "<style>\n\t\tbody {font-size: 0.8em; margin: 0px; padding: 0px;}\n\t\t#contact-block { overflow: hidden; height: auto; }\n\t\t.contact-block-h4 { float: left; margin: 0px; }\n\t\t.allcontact-link { float: right; margin: 0px; }\n\t\t.contact-block-content { clear:both; }\n\t\t.contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;}\n\t\t\n\t</style>";
    $o .= _abs_url(contact_block());
    $o .= "<a href='" . $a->get_baseurl() . '/profile/' . $a->profile['nickname'] . "' target=new>" . t('Get added to this list!') . "</a>";
    return $o;
}
Пример #2
0
/**
 * @brief Formats a profile for display in the sidebar.
 *
 * It is very difficult to templatise the HTML completely
 * because of all the conditional logic.
 *
 * @param array $profile
 * @param int $block
 * @param boolean $show_connect
 *
 * @return HTML string suitable for sidebar inclusion
 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
 */
function profile_sidebar($profile, $block = 0, $show_connect = true)
{
    $a = get_app();
    $observer = $a->get_observer();
    $o = '';
    $location = false;
    $pdesc = true;
    $reddress = true;
    if (!is_array($profile) && !count($profile)) {
        return $o;
    }
    head_set_icon($profile['thumb']);
    $is_owner = $profile['uid'] == local_channel() ? true : false;
    if (is_sys_channel($profile['uid'])) {
        $show_connect = false;
    }
    $profile['picdate'] = urlencode($profile['picdate']);
    call_hooks('profile_sidebar_enter', $profile);
    require_once 'include/Contact.php';
    if ($show_connect) {
        // This will return an empty string if we're already connected.
        $connect_url = rconnect_url($profile['uid'], get_observer_hash());
        $connect = $connect_url ? t('Connect') : '';
        if ($connect_url) {
            $connect_url = sprintf($connect_url, urlencode($profile['channel_address'] . '@' . $a->get_hostname()));
        }
        // premium channel - over-ride
        if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
            $connect_url = z_root() . '/connect/' . $profile['channel_address'];
        }
    }
    // show edit profile to yourself
    if ($is_owner) {
        $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'entries' => array());
        $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
        if ($multi_profiles) {
            $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles'));
            $profile['menu']['cr_new'] = t('Create New Profile');
        } else {
            $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'), '', t('Edit Profile'));
        }
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
        if ($r) {
            foreach ($r as $rr) {
                if (!($multi_profiles || $rr['is_default'])) {
                    continue;
                }
                $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile_name'], 'isdefault' => $rr['is_default'], 'visible_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility'));
            }
        }
    }
    if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) {
        $location = t('Location:');
    }
    $profile['homepage'] = linkify($profile['homepage'], true);
    $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
    $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
    $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
    $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False;
    //	logger('online: ' . $profile['online']);
    if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
        $block = true;
    }
    if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) {
        $location = $reddress = $pdesc = $gender = $marital = $homepage = False;
    }
    $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name'];
    $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname)));
    $diaspora = array('podloc' => z_root(), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg');
    $contact_block = contact_block();
    $channel_menu = false;
    $menu = get_pconfig($profile['uid'], 'system', 'channel_menu');
    if ($menu && !$block) {
        require_once 'include/menu.php';
        $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']);
        if ($m) {
            $channel_menu = menu_render($m);
        }
    }
    $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock');
    if ($menublock && !$block) {
        require_once 'include/comanche.php';
        $channel_menu .= comanche_block($menublock);
    }
    $tpl = get_markup_template('profile_vcard.tpl');
    require_once 'include/widgets.php';
    $z = widget_rating(array('target' => $profile['channel_hash']));
    $o .= replace_macros($tpl, array('$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block));
    $arr = array('profile' => &$profile, 'entry' => &$o);
    call_hooks('profile_sidebar', $arr);
    return $o;
}
Пример #3
0
/**
 * @brief Formats a profile for display in the sidebar.
 *
 * It is very difficult to templatise the HTML completely
 * because of all the conditional logic.
 *
 * @param array $profile
 * @param int $block
 * @param boolean $show_connect
 *
 * @return HTML string suitable for sidebar inclusion
 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
 */
function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false)
{
    $observer = App::get_observer();
    $o = '';
    $location = false;
    $pdesc = true;
    $reddress = true;
    if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
        $block = true;
    }
    if (!is_array($profile) && !count($profile)) {
        return $o;
    }
    head_set_icon($profile['thumb']);
    if (is_sys_channel($profile['uid'])) {
        $show_connect = false;
    }
    $profile['picdate'] = urlencode($profile['picdate']);
    call_hooks('profile_sidebar_enter', $profile);
    if ($show_connect) {
        // This will return an empty string if we're already connected.
        $connect_url = rconnect_url($profile['uid'], get_observer_hash());
        $connect = $connect_url ? t('Connect') : '';
        if ($connect_url) {
            $connect_url = sprintf($connect_url, urlencode(channel_reddress($profile)));
        }
        // premium channel - over-ride
        if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
            $connect_url = z_root() . '/connect/' . $profile['channel_address'];
        }
    }
    if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) {
        $location = t('Location:');
    }
    $profile['homepage'] = linkify($profile['homepage'], true);
    $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
    $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
    $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
    $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False;
    //	logger('online: ' . $profile['online']);
    if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) {
        $location = $reddress = $pdesc = $gender = $marital = $homepage = False;
    }
    $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name'];
    $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname)));
    $diaspora = array('podloc' => z_root(), 'guid' => $profile['channel_guid'] . str_replace('.', '', App::get_hostname()), 'pubkey' => pemtorsa($profile['channel_pubkey']), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg');
    $contact_block = contact_block();
    $channel_menu = false;
    $menu = get_pconfig($profile['uid'], 'system', 'channel_menu');
    if ($menu && !$block) {
        require_once 'include/menu.php';
        $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']);
        if ($m) {
            $channel_menu = menu_render($m);
        }
    }
    $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock');
    if ($menublock && !$block) {
        $comanche = new Zotlabs\Render\Comanche();
        $channel_menu .= $comanche->block($menublock);
    }
    if ($zcard) {
        $tpl = get_markup_template('profile_vcard_short.tpl');
    } else {
        $tpl = get_markup_template('profile_vcard.tpl');
    }
    require_once 'include/widgets.php';
    //	if(! feature_enabled($profile['uid'],'hide_rating'))
    $z = widget_rating(array('target' => $profile['channel_hash']));
    $o .= replace_macros($tpl, array('$zcard' => $zcard, '$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block, '$editmenu' => profile_edit_menu($profile['uid'])));
    $arr = array('profile' => &$profile, 'entry' => &$o);
    call_hooks('profile_sidebar', $arr);
    return $o;
}
Пример #4
0
 function profile_sidebar($profile, $block = 0)
 {
     $a = get_app();
     $o = '';
     $location = false;
     $address = false;
     $pdesc = true;
     if (!is_array($profile) && !count($profile)) {
         return $o;
     }
     $profile['picdate'] = urlencode($profile['picdate']);
     call_hooks('profile_sidebar_enter', $profile);
     // don't show connect link to yourself
     $connect = $profile['uid'] != local_user() ? t('Connect') : False;
     // don't show connect link to authenticated visitors either
     if (remote_user() && count($_SESSION['remote'])) {
         foreach ($_SESSION['remote'] as $visitor) {
             if ($visitor['uid'] == $profile['uid']) {
                 $connect = false;
                 break;
             }
         }
     }
     if (get_my_url() && $profile['unkmail'] && $profile['uid'] != local_user()) {
         $wallmessage = t('Message');
     } else {
         $wallmessage = false;
     }
     // show edit profile to yourself
     if ($profile['uid'] == local_user() && feature_enabled(local_user(), 'multi_profiles')) {
         $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles'));
         $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user());
         $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => t('Create New Profile'), 'entries' => array());
         if (count($r)) {
             foreach ($r as $rr) {
                 $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile-name'], 'isdefault' => $rr['is-default'], 'visibile_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility'));
             }
         }
     }
     if ($profile['uid'] == local_user() && !feature_enabled(local_user(), 'multi_profiles')) {
         $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit profile'), "", t('Edit profile'));
         $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => null, 'entries' => array());
     }
     if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 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;
     if (($profile['hidewall'] || $block) && !local_user() && !remote_user()) {
         $location = $pdesc = $gender = $marital = $homepage = False;
     }
     $firstname = strpos($profile['name'], ' ') ? trim(substr($profile['name'], 0, strpos($profile['name'], ' '))) : $profile['name'];
     $lastname = $firstname === $profile['name'] ? '' : trim(substr($profile['name'], strlen($firstname)));
     $diaspora = array('podloc' => $a->get_baseurl(), 'searchable' => $profile['publish'] && $profile['net-publish'] ? 'true' : 'false', 'nickname' => $profile['nickname'], 'fullname' => $profile['name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'), 'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'), 'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg'));
     if (!$block) {
         $contact_block = contact_block();
     }
     $p = array();
     foreach ($profile as $k => $v) {
         $k = str_replace('-', '_', $k);
         $p[$k] = $v;
     }
     if ($a->theme['template_engine'] === 'internal') {
         $location = template_escape($location);
     }
     $tpl = get_markup_template('profile_vcard.tpl');
     $o .= replace_macros($tpl, array('$profile' => $p, '$connect' => $connect, '$wallmessage' => $wallmessage, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$diaspora' => $diaspora, '$contact_block' => $contact_block));
     $arr = array('profile' => &$profile, 'entry' => &$o);
     call_hooks('profile_sidebar', $arr);
     return $o;
 }
Пример #5
0
 function profile_sidebar($profile, $block = 0)
 {
     $a = get_app();
     $o = '';
     $location = false;
     $address = false;
     //		$pdesc = true;
     if (!is_array($profile) && !count($profile)) {
         return $o;
     }
     $profile['picdate'] = urlencode($profile['picdate']);
     if ($profile['network'] != "" and $profile['network'] != NETWORK_DFRN) {
         $profile['network_name'] = format_network_name($profile['network'], $profile['url']);
     } else {
         $profile['network_name'] = "";
     }
     call_hooks('profile_sidebar_enter', $profile);
     // don't show connect link to yourself
     $connect = $profile['uid'] != local_user() ? t('Connect') : False;
     // don't show connect link to authenticated visitors either
     if (remote_user() && count($_SESSION['remote'])) {
         foreach ($_SESSION['remote'] as $visitor) {
             if ($visitor['uid'] == $profile['uid']) {
                 $connect = false;
                 break;
             }
         }
     }
     // Is the local user already connected to that user?
     if ($connect and local_user()) {
         if (isset($profile["url"])) {
             $profile_url = normalise_link($profile["url"]);
         } else {
             $profile_url = normalise_link($a->get_baseurl() . "/profile/" . $profile["nickname"]);
         }
         $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", local_user(), $profile_url);
         if (count($r)) {
             $connect = false;
         }
     }
     if ($connect and $profile['network'] != NETWORK_DFRN and !isset($profile['remoteconnect'])) {
         $connect = false;
     }
     if (isset($profile['remoteconnect'])) {
         $remoteconnect = $profile['remoteconnect'];
     }
     if ($connect and $profile['network'] == NETWORK_DFRN and !isset($remoteconnect)) {
         $subscribe_feed = t("Atom feed");
     } else {
         $subscribe_feed = false;
     }
     if (get_my_url() && $profile['unkmail'] && $profile['uid'] != local_user()) {
         $wallmessage = t('Message');
     } else {
         $wallmessage = false;
     }
     // show edit profile to yourself
     if ($profile['uid'] == local_user() && feature_enabled(local_user(), 'multi_profiles')) {
         $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles'));
         $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user());
         $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => t('Create New Profile'), 'entries' => array());
         if (count($r)) {
             foreach ($r as $rr) {
                 $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile-name'], 'isdefault' => $rr['is-default'], 'visibile_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility'));
             }
         }
     }
     if ($profile['uid'] == local_user() && !feature_enabled(local_user(), 'multi_profiles')) {
         $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit profile'), "", t('Edit profile'));
         $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => null, 'entries' => array());
     }
     // check if profile is a forum
     if (intval($profile['page-flags']) == PAGE_COMMUNITY || intval($profile['page-flags']) == PAGE_PRVGROUP || intval($profile['forum']) || intval($profile['prv']) || intval($profile['community'])) {
         $account_type = t('Forum');
     } else {
         $account_type = "";
     }
     if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 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;
     if (($profile['hidewall'] || $block) && !local_user() && !remote_user()) {
         $location = $pdesc = $gender = $marital = $homepage = $about = False;
     }
     $firstname = strpos($profile['name'], ' ') ? trim(substr($profile['name'], 0, strpos($profile['name'], ' '))) : $profile['name'];
     $lastname = $firstname === $profile['name'] ? '' : trim(substr($profile['name'], strlen($firstname)));
     $diaspora = array('guid' => $profile['guid'], 'podloc' => $a->get_baseurl(), 'searchable' => $profile['publish'] && $profile['net-publish'] ? 'true' : 'false', 'nickname' => $profile['nickname'], 'fullname' => $profile['name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'), 'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'), 'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg'));
     if (!$block) {
         $contact_block = contact_block();
         if (is_array($a->profile) and !$a->profile['hide-friends']) {
             $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1", intval($a->profile['uid']));
             if (count($r)) {
                 $updated = date("c", strtotime($r[0]['updated']));
             }
             $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\t\t\t\tAND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
             if (count($r)) {
                 $contacts = intval($r[0]['total']);
             }
         }
     }
     $p = array();
     foreach ($profile as $k => $v) {
         $k = str_replace('-', '_', $k);
         $p[$k] = $v;
     }
     if (isset($p["about"])) {
         $p["about"] = bbcode($p["about"]);
     }
     if (isset($p["location"])) {
         $p["location"] = bbcode($p["location"]);
     }
     if (isset($p["photo"])) {
         $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL);
     }
     if ($a->theme['template_engine'] === 'internal') {
         $location = template_escape($location);
     }
     $tpl = get_markup_template('profile_vcard.tpl');
     $o .= replace_macros($tpl, array('$profile' => $p, '$connect' => $connect, '$remoteconnect' => $remoteconnect, '$subscribe_feed' => $subscribe_feed, '$wallmessage' => $wallmessage, '$account_type' => $account_type, '$location' => $location, '$gender' => $gender, '$marital' => $marital, '$homepage' => $homepage, '$about' => $about, '$network' => t('Network:'), '$contacts' => $contacts, '$updated' => $updated, '$diaspora' => $diaspora, '$contact_block' => $contact_block));
     $arr = array('profile' => &$profile, 'entry' => &$o);
     call_hooks('profile_sidebar', $arr);
     return $o;
 }