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; }
function app_render($papp, $mode = 'view') { /** * modes: * view: normal mode for viewing an app via bbcode from a conversation or page * provides install/update button if you're logged in locally * list: normal mode for viewing an app on the app page * no buttons are shown * edit: viewing the app page in editing mode provides a delete button */ $installed = false; if (!$papp['photo']) { $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); } if (!$papp) { return; } $papp['papp'] = papp_encode($papp); foreach ($papp as $k => $v) { if (strpos($v, 'http') === 0 && $k != 'papp') { $papp[$k] = zid($v); } if ($k === 'desc') { $papp['desc'] = str_replace(array('\'', '"'), array(''', '&dquot;'), $papp['desc']); } if ($k === 'requires') { $require = trim(strtolower($v)); switch ($require) { case 'nologin': if (local_user()) { return ''; } break; case 'admin': if (!is_site_admin()) { return ''; } break; case 'local_user': if (!local_user()) { return ''; } break; case 'public_profile': if (!is_public_profile()) { return ''; } break; case 'observer': $observer = get_app()->get_observer(); if (!$observer) { return ''; } break; default: if (!local_user() && feature_enabled(local_user(), $require)) { return ''; } break; } } } $hosturl = ''; if (local_user()) { $installed = app_installed(local_user(), $papp); $hosturl = z_root() . '/'; } elseif (remote_user()) { $observer = get_app()->get_observer(); if ($observer && $observer['xchan_network'] === 'zot') { // some folks might have xchan_url redirected offsite, use the connurl $x = parse_url($observer['xchan_connurl']); if ($x) { $hosturl = $x['scheme'] . '://' . $x['host'] . '/'; } } } $install_action = $installed ? t('Update') : t('Install'); return replace_macros(get_markup_template('app.tpl'), array('$app' => $papp, '$hosturl' => $hosturl, '$purchase' => $papp['page'] && !$installed ? t('Purchase') : '', '$install' => $hosturl && $mode == 'view' ? $install_action : '', '$edit' => local_user() && $installed && $mode == 'edit' ? t('Edit') : '', '$delete' => local_user() && $installed && $mode == 'edit' ? t('Delete') : '')); }