Example #1
0
 function profile_load(&$a, $nickname, $profile = 0, $profiledata = array())
 {
     $user = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($nickname));
     if (!$user && count($user) && !count($profiledata)) {
         logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
         notice(t('Requested account is not available.') . EOL);
         $a->error = 404;
         return;
     }
     $pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
     if ($pdata === false || !count($pdata) && !count($profiledata)) {
         logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
         notice(t('Requested profile is not available.') . EOL);
         $a->error = 404;
         return;
     }
     // fetch user tags if this isn't the default profile
     if (!$pdata['is-default']) {
         $x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($pdata['profile_uid']));
         if ($x && count($x)) {
             $pdata['pub_keywords'] = $x[0]['pub_keywords'];
         }
     }
     $a->profile = $pdata;
     $a->profile_uid = $pdata['profile_uid'];
     $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
     $a->profile['network'] = NETWORK_DFRN;
     $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
     //		if (!$profiledata)
     //			$_SESSION['theme'] = $a->profile['theme'];
     $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
     /**
      * load/reload current theme info
      */
     $a->set_template_engine();
     // reset the template engine to the default in case the user's theme doesn't specify one
     $theme_info_file = "view/theme/" . current_theme() . "/theme.php";
     if (file_exists($theme_info_file)) {
         require_once $theme_info_file;
     }
     if (!x($a->page, 'aside')) {
         $a->page['aside'] = '';
     }
     if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
         $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'), array('$editprofile' => t('Edit profile'), '$profid' => $a->profile['id']));
     }
     $block = get_config('system', 'block_public') && !local_user() && !remote_user() ? true : false;
     // To-Do:
     // By now, the contact block isn't shown, when a different profile is given
     // But: When this profile was on the same server, then we could display the contacts
     if ($profiledata) {
         $a->page['aside'] .= profile_sidebar($profiledata, true);
     } else {
         $a->page['aside'] .= profile_sidebar($a->profile, $block);
     }
     /*if(! $block)
     	 $a->page['aside'] .= contact_block();*/
     return;
 }
Example #2
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 #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;
    }
    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;
}