Example #1
0
function profile_init(&$a)
{
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($a->argc > 1) {
        $which = $a->argv[1];
    } else {
        $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
        if (count($r)) {
            goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
        } else {
            logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
            notice(t('Requested profile is not available.') . EOL);
            $a->error = 404;
            return;
        }
    }
    $profile = 0;
    if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
        $which = $a->user['nickname'];
        $profile = $a->argv[1];
    } else {
        auto_redir($a, $which);
    }
    profile_load($a, $which, $profile);
    $blocked = get_config('system', 'block_public') && !local_user() && !remote_user() ? true : false;
    $userblock = $a->profile['hidewall'] && !local_user() && !remote_user() ? true : false;
    if (x($a->profile, 'page-flags') && $a->profile['page-flags'] == PAGE_COMMUNITY) {
        $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
    }
    if (x($a->profile, 'openidserver')) {
        $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
    }
    if (x($a->profile, 'openid')) {
        $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
        $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
    }
    // site block
    if (!$blocked && !$userblock) {
        $keywords = x($a->profile, 'pub_keywords') ? $a->profile['pub_keywords'] : '';
        $keywords = str_replace(array('#', ',', ' ', ',,'), array('', ' ', ',', ','), $keywords);
        if (strlen($keywords)) {
            $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
        }
    }
    $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
    $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which . '" />' . "\r\n";
    $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : ''));
    $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
    header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
    $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
    foreach ($dfrn_pages as $dfrn) {
        $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $a->get_baseurl() . "/dfrn_{$dfrn}/{$which}\" />\r\n";
    }
    $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"" . $a->get_baseurl() . "/poco/{$which}\" />\r\n";
}
Example #2
0
function photos_init(&$a)
{
    if ($a->argc > 1) {
        auto_redir($a, $a->argv[1]);
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return;
    }
    $o = '';
    if ($a->argc > 1) {
        $nick = $a->argv[1];
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick));
        if (!count($r)) {
            return;
        }
        $a->data['user'] = $r[0];
        $o .= '<div class="vcard">';
        $o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
        $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg') . '" alt="' . $a->data['user']['username'] . '" /></div>';
        $o .= '</div>';
        $sql_extra = permissions_sql($a->data['user']['uid']);
        $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d {$sql_extra} order by created desc", intval($a->data['user']['uid']));
        if (count($albums)) {
            $a->data['albums'] = $albums;
            $albums_visible = intval($a->data['user']['hidewall']) && !local_user() && !remote_user() ? false : true;
            if ($albums_visible) {
                $o .= '<div id="side-bar-photos-albums" class="widget">';
                $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
                $o .= '<ul>';
                foreach ($albums as $album) {
                    // don't show contact photos. We once translated this name, but then you could still access it under
                    // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
                    if (!strlen($album['album']) || $album['album'] === 'Contact Photos' || $album['album'] === t('Contact Photos')) {
                        continue;
                    }
                    $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
                }
                $o .= '</ul>';
            }
            if (local_user() && $a->data['user']['uid'] == local_user()) {
                $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' . t('Upload New Photos') . '</a></div>';
            }
            $o .= '</div>';
        }
        if (!x($a->page, 'aside')) {
            $a->page['aside'] = '';
        }
        $a->page['aside'] .= $o;
        $tpl = get_markup_template("photos_head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl, array('$ispublic' => t('everybody')));
    }
    return;
}
Example #3
0
function photos_init(&$a)
{
    if ($a->argc > 1) {
        auto_redir($a, $a->argv[1]);
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return;
    }
    $o = '';
    if ($a->argc > 1) {
        $nick = $a->argv[1];
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick));
        if (!count($r)) {
            return;
        }
        $a->data['user'] = $r[0];
        $a->profile_uid = $r[0]['uid'];
        $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
        $tpl = get_markup_template("vcard-widget.tpl");
        $vcard_widget .= replace_macros($tpl, array('$name' => $a->data['user']['username'], '$photo' => $profilephoto));
        $sql_extra = permissions_sql($a->data['user']['uid']);
        $albums = q("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s'\n\t\t\t{$sql_extra} group by album order by created desc", intval($a->data['user']['uid']), dbesc('Contact Photos'), dbesc(t('Contact Photos')));
        $albums_visible = intval($a->data['user']['hidewall']) && !local_user() && !remote_user() ? false : true;
        // add various encodings to the array so we can just loop through and pick them out in a template
        $ret = array('success' => false);
        if ($albums) {
            $a->data['albums'] = $albums;
            if ($albums_visible) {
                $ret['success'] = true;
            }
            $ret['albums'] = array();
            foreach ($albums as $k => $album) {
                $entry = array('text' => $album['album'], 'total' => $album['total'], 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), 'bin2hex' => bin2hex($album['album']));
                $ret['albums'][] = $entry;
            }
        }
        $albums = $ret;
        if (local_user() && $a->data['user']['uid'] == local_user()) {
            $can_post = true;
        }
        if ($albums['success']) {
            $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'), array('$nick' => $a->data['user']['nickname'], '$title' => t('Photo Albums'), 'recent' => t('Recent Photos'), '$albums' => $albums['albums'], '$baseurl' => z_root(), '$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'), '$can_post' => $can_post));
        }
        if (!x($a->page, 'aside')) {
            $a->page['aside'] = '';
        }
        $a->page['aside'] .= $vcard_widget;
        $a->page['aside'] .= $photo_albums_widget;
        $tpl = get_markup_template("photos_head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl, array('$ispublic' => t('everybody')));
    }
    return;
}
Example #4
0
function videos_init(&$a)
{
    if ($a->argc > 1) {
        auto_redir($a, $a->argv[1]);
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return;
    }
    nav_set_selected('home');
    $o = '';
    if ($a->argc > 1) {
        $nick = $a->argv[1];
        $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick));
        if (!count($user)) {
            return;
        }
        $a->data['user'] = $user[0];
        $a->profile_uid = $user[0]['uid'];
        $profile = get_profiledata_by_nick($nick, $a->profile_uid);
        if (intval($profile['page-flags']) == PAGE_COMMUNITY || intval($profile['page-flags']) == PAGE_PRVGROUP) {
            $account_type = t('Forum');
        } else {
            $account_type = "";
        }
        $tpl = get_markup_template("vcard-widget.tpl");
        $vcard_widget .= replace_macros($tpl, array('$name' => $profile['name'], '$photo' => $profile['photo'], '$addr' => $profile['addr'] != "" ? $profile['addr'] : "", '$account_type' => $account_type, '$pdesc' => $profile['pdesc'] != "" ? $profile['pdesc'] : ""));
        /*$sql_extra = permissions_sql($a->data['user']['uid']);
        
        		$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
        			intval($a->data['user']['uid'])
        		);
        
        		if(count($albums)) {
        			$a->data['albums'] = $albums;
        
        			$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
        
        			if($albums_visible) {
        				$o .= '<div id="sidebar-photos-albums" class="widget">';
        				$o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
        
        				$o .= '<ul>';
        				foreach($albums as $album) {
        
        					// don't show contact photos. We once translated this name, but then you could still access it under
        					// a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
        
        					if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
        						continue;
        					$o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
        				}
        				$o .= '</ul>';
        			}
        			if(local_user() && $a->data['user']['uid'] == local_user()) {
        				$o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
        			}
        
        			$o .= '</div>';
        		}*/
        if (!x($a->page, 'aside')) {
            $a->page['aside'] = '';
        }
        $a->page['aside'] .= $vcard_widget;
        $tpl = get_markup_template("videos_head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
        $tpl = get_markup_template("videos_end.tpl");
        $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
    }
    return;
}
Example #5
0
function photos_init(&$a)
{
    if ($a->argc > 1) {
        auto_redir($a, $a->argv[1]);
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return;
    }
    nav_set_selected('home');
    $o = '';
    if ($a->argc > 1) {
        $nick = $a->argv[1];
        $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick));
        if (!count($user)) {
            return;
        }
        $a->data['user'] = $user[0];
        $a->profile_uid = $user[0]['uid'];
        $is_owner = local_user() && local_user() == $a->profile_uid;
        $profile = get_profiledata_by_nick($nick, $a->profile_uid);
        if (intval($profile['page-flags']) == PAGE_COMMUNITY || intval($profile['page-flags']) == PAGE_PRVGROUP) {
            $account_type = t('Forum');
        } else {
            $account_type = "";
        }
        $tpl = get_markup_template("vcard-widget.tpl");
        $vcard_widget .= replace_macros($tpl, array('$name' => $profile['name'], '$photo' => $profile['photo'], '$addr' => $profile['addr'] != "" ? $profile['addr'] : "", '$account_type' => $account_type, '$pdesc' => $profile['pdesc'] != "" ? $profile['pdesc'] : ""));
        $sql_extra = permissions_sql($a->data['user']['uid']);
        $albums = q("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` WHERE `uid` = %d  AND `album` != '%s' AND `album` != '%s'\n\t\t\t{$sql_extra} group by album order by created desc", intval($a->data['user']['uid']), dbesc('Contact Photos'), dbesc(t('Contact Photos')));
        $albums_visible = intval($a->data['user']['hidewall']) && !local_user() && !remote_user() ? false : true;
        // add various encodings to the array so we can just loop through and pick them out in a template
        $ret = array('success' => false);
        if ($albums) {
            $a->data['albums'] = $albums;
            if ($albums_visible) {
                $ret['success'] = true;
            }
            $ret['albums'] = array();
            foreach ($albums as $k => $album) {
                //hide profile photos to others
                if (!$is_owner && !remote_user() && $album['album'] == t('Profile Photos')) {
                    continue;
                }
                $entry = array('text' => $album['album'], 'total' => $album['total'], 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), 'bin2hex' => bin2hex($album['album']));
                $ret['albums'][] = $entry;
            }
        }
        $albums = $ret;
        if (local_user() && $a->data['user']['uid'] == local_user()) {
            $can_post = true;
        }
        if ($albums['success']) {
            $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'), array('$nick' => $a->data['user']['nickname'], '$title' => t('Photo Albums'), '$recent' => t('Recent Photos'), '$albums' => $albums['albums'], '$baseurl' => z_root(), '$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'), '$can_post' => $can_post));
        }
        if (!x($a->page, 'aside')) {
            $a->page['aside'] = '';
        }
        $a->page['aside'] .= $vcard_widget;
        $a->page['aside'] .= $photo_albums_widget;
        $tpl = get_markup_template("photos_head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl, array('$ispublic' => t('everybody')));
    }
    return;
}