本文整理汇总了PHP中item_normal函数的典型用法代码示例。如果您正苦于以下问题:PHP item_normal函数的具体用法?PHP item_normal怎么用?PHP item_normal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了item_normal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bookmarks_init
function bookmarks_init(&$a)
{
if (!local_channel()) {
return;
}
$item_id = intval($_REQUEST['item']);
if (!$item_id) {
return;
}
$u = $a->get_channel();
$item_normal = item_normal();
$i = q("select * from item where id = %d and uid = %d {$item_normal} limit 1", intval($item_id), intval(local_channel()));
if (!$i) {
return;
}
$i = fetch_post_tags($i);
$item = $i[0];
$terms = get_terms_oftype($item['term'], TERM_BOOKMARK);
if ($terms) {
require_once 'include/bookmarks.php';
$s = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']));
if (!$s) {
logger('mod_bookmarks: author lookup failed.');
killme();
}
foreach ($terms as $t) {
bookmark_add($u, $s[0], $t, $item['item_private']);
info(t('Bookmark added') . EOL);
}
}
killme();
}
示例2: viewsrc_content
function viewsrc_content(&$a)
{
$o = '';
$sys = get_sys_channel();
$item_id = argc() > 1 ? intval(argv(1)) : 0;
$json = argc() > 2 && argv(2) === 'json' ? true : false;
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
}
if (!$item_id) {
App::$error = 404;
notice(t('Item not found.') . EOL);
}
$item_normal = item_normal();
if (local_channel() && $item_id) {
$r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d {$item_normal} limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id));
if ($r) {
if (intval($r[0]['item_obscured'])) {
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey'));
}
$o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']);
}
}
if (is_ajax()) {
print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>';
echo $o;
killme();
}
return $o;
}
示例3: categories_widget
function categories_widget($baseurl, $selected = '')
{
if (!feature_enabled(App::$profile['profile_uid'], 'categories')) {
return '';
}
$item_normal = item_normal();
$terms = array();
$r = q("select distinct(term.term)\n from term join item on term.oid = item.id\n where item.uid = %d\n and term.uid = item.uid\n and term.ttype = %d\n\t\t\t\tand term.otype = %d\n and item.owner_xchan = '%s'\n\t\t\t\tand item.item_wall = 1\n\t\t\t\t{$item_normal}\n order by term.term asc", intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), intval(TERM_OBJ_POST), dbesc(App::$profile['channel_hash']));
if ($r && count($r)) {
foreach ($r as $rr) {
$terms[] = array('name' => $rr['term'], 'selected' => $selected == $rr['term'] ? 'selected' : '');
}
return replace_macros(get_markup_template('categories_widget.tpl'), array('$title' => t('Categories'), '$desc' => '', '$sel_all' => $selected == '' ? 'selected' : '', '$all' => t('Everything'), '$terms' => $terms, '$base' => $baseurl));
}
return '';
}
示例4: get
function get($update = 0, $load = false)
{
if (!local_channel()) {
$_SESSION['return_url'] = \App::$query_string;
return login(false);
}
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
$arr = array('query' => \App::$query_string);
call_hooks('network_content_init', $arr);
$channel = \App::get_channel();
$item_normal = item_normal();
$datequery = $datequery2 = '';
$group = 0;
$nouveau = false;
$datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
$datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
$nouveau = x($_GET, 'new') ? intval($_GET['new']) : 0;
$gid = x($_GET, 'gid') ? intval($_GET['gid']) : 0;
$category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
$hashtags = x($_REQUEST, 'tag') ? $_REQUEST['tag'] : '';
$verb = x($_REQUEST, 'verb') ? $_REQUEST['verb'] : '';
$search = $_GET['search'] ? $_GET['search'] : '';
if ($search) {
if (strpos($search, '@') === 0) {
$r = q("select abook_id from abook left join xchan on abook_xchan = xchan_hash where xchan_name = '%s' and abook_channel = %d limit 1", dbesc(substr($search, 1)), intval(local_channel()));
if ($r) {
$_GET['cid'] = $r[0]['abook_id'];
$search = $_GET['search'] = '';
}
} elseif (strpos($search, '#') === 0) {
$hashtags = substr($search, 1);
$search = $_GET['search'] = '';
}
}
if ($datequery) {
$_GET['order'] = 'post';
}
// filter by collection (e.g. group)
if ($gid) {
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d LIMIT 1", intval($gid), intval(local_channel()));
if (!$r) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway(z_root() . '/network');
// NOTREACHED
}
$group = $gid;
$group_hash = $r[0]['hash'];
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
$o = '';
// if no tabs are selected, defaults to comments
$cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
$star = x($_GET, 'star') ? intval($_GET['star']) : 0;
$order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
$liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
$conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
$spam = x($_GET, 'spam') ? intval($_GET['spam']) : 0;
$cmin = x($_GET, 'cmin') ? intval($_GET['cmin']) : 0;
$cmax = x($_GET, 'cmax') ? intval($_GET['cmax']) : 99;
$firehose = x($_GET, 'fh') ? intval($_GET['fh']) : 0;
$file = x($_GET, 'file') ? $_GET['file'] : '';
$deftag = '';
if (x($_GET, 'search') || x($_GET, 'file')) {
$nouveau = true;
}
if ($cid) {
$r = q("SELECT abook_xchan FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($cid), intval(local_channel()));
if (!$r) {
if ($update) {
killme();
}
notice(t('No such channel') . EOL);
goaway(z_root() . '/network');
// NOTREACHED
}
if ($_GET['pf'] === '1') {
$deftag = '@' . t('forum') . '+' . intval($cid) . '+';
} else {
$def_acl = array('allow_cid' => '<' . $r[0]['abook_xchan'] . '>');
}
}
if (!$update) {
$tabs = network_tabs();
$o .= $tabs;
// search terms header
if ($search) {
$o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8')));
}
nav_set_selected('network');
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
$private_editing = ($group || $cid) && !intval($_GET['pf']) ? true : false;
$x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($private_editing ? $def_acl : $channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => $private_editing ? '!' : '', 'visitor' => true, 'profile_uid' => local_channel(), 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
if ($deftag) {
$x['pretext'] = $deftag;
}
//.........这里部分代码省略.........
示例5: get
function get($update = 0, $load = false)
{
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
$checkjs = new \Zotlabs\Web\CheckJS(1);
$category = $datequery = $datequery2 = '';
$mid = x($_REQUEST, 'mid') ? $_REQUEST['mid'] : '';
$datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
$datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
if (observer_prohibited(true)) {
return login();
}
$category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
$hashtags = x($_REQUEST, 'tag') ? $_REQUEST['tag'] : '';
$groups = array();
$o = '';
if ($update) {
// Ensure we've got a profile owner if updating.
\App::$profile['profile_uid'] = \App::$profile_uid = $update;
} else {
if (\App::$profile['profile_uid'] == local_channel()) {
nav_set_selected('home');
}
}
$is_owner = local_channel() && \App::$profile['profile_uid'] == local_channel() ? true : false;
$channel = \App::get_channel();
$observer = \App::get_observer();
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms(\App::$profile['profile_uid'], $ob_hash);
if (!$perms['view_stream']) {
// We may want to make the target of this redirect configurable
if ($perms['view_profile']) {
notice(t('Insufficient permissions. Request redirected to profile page.') . EOL);
goaway(z_root() . "/profile/" . \App::$profile['channel_address']);
}
notice(t('Permission denied.') . EOL);
return;
}
if (!$update) {
$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
$o .= common_friends_visitor_widget(\App::$profile['profile_uid']);
if ($channel && $is_owner) {
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
} else {
$channel_acl = array();
}
if ($perms['post_wall']) {
$x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $observer) && intval(get_pconfig(\App::$profile['profile_uid'], 'system', 'use_browser_location')) ? true : false, 'default_location' => $is_owner ? \App::$profile['channel_location'] : '', 'nickname' => \App::$profile['channel_address'], 'lockstate' => strlen(\App::$profile['channel_allow_cid']) || strlen(\App::$profile['channel_allow_gid']) || strlen(\App::$profile['channel_deny_cid']) || strlen(\App::$profile['channel_deny_gid']) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : '', 'showacl' => $is_owner ? 'yes' : '', 'bang' => '', 'visitor' => $is_owner || $observer ? true : false, 'profile_uid' => \App::$profile['profile_uid'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
$o .= status_editor($a, $x);
}
}
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
$item_normal = item_normal();
$sql_extra = item_permissions_sql(\App::$profile['profile_uid']);
if (get_pconfig(\App::$profile['profile_uid'], 'system', 'channel_list_mode') && !$mid) {
$page_mode = 'list';
} else {
$page_mode = 'client';
}
$abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
$simple_update = $update ? " AND item_unseen = 1 " : '';
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
if ($update && $_SESSION['loadtime']) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
}
if ($load) {
$simple_update = '';
}
if ($update && !$load) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 AND item_unseen = 1 {$sql_extra} limit 1", dbesc($mid . '%'), intval(\App::$profile['profile_uid']));
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item\n\t\t\t\t\tleft join abook on ( item.owner_xchan = abook.abook_xchan {$abook_uids} )\n\t\t\t\t\tWHERE uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 {$simple_update}\n\t\t\t\t\tAND (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\tORDER BY created DESC", intval(\App::$profile['profile_uid']));
$_SESSION['loadtime'] = datetime_convert();
}
} else {
if (x($category)) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if (x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
\App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if ($load || $checkjs->disabled()) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d {$item_normal}\n\t\t\t\t\t\tAND item_wall = 1 {$sql_extra} limit 1", dbesc($mid), intval(\App::$profile['profile_uid']));
if (!$r) {
notice(t('Permission denied.') . EOL);
}
//.........这里部分代码省略.........
示例6: items_fetch
function items_fetch($arr, $channel = null, $observer_hash = null, $client_mode = CLIENT_MODE_NORMAL, $module = 'network')
{
$result = array('success' => false);
$a = get_app();
$sql_extra = '';
$sql_nets = '';
$sql_options = '';
$sql_extra2 = '';
$sql_extra3 = '';
$def_acl = '';
$item_uids = ' true ';
$item_normal = item_normal();
if ($arr['uid']) {
$uid = $arr['uid'];
}
if ($channel) {
$uid = $channel['channel_id'];
$uidhash = $channel['channel_hash'];
$item_uids = " item.uid = " . intval($uid) . " ";
}
if ($arr['star']) {
$sql_options .= " and item_starred = 1 ";
}
if ($arr['wall']) {
$sql_options .= " and item_wall = 1 ";
}
if ($arr['item_id']) {
$sql_options .= " and parent = " . intval($arr['item_id']) . " ";
}
if ($arr['mid']) {
$sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' ";
}
$sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 {$sql_options} {$item_normal} ) ";
if ($arr['since_id']) {
$sql_extra .= " and item.id > " . $since_id . " ";
}
if ($arr['cat']) {
$sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY));
}
if ($arr['gid'] && $uid) {
$r = q("SELECT * FROM `groups` WHERE id = %d AND uid = %d LIMIT 1", intval($arr['group']), intval($uid));
if (!$r) {
$result['message'] = t('Collection not found.');
return $result;
}
$contact_str = '';
/** @FIXME $group is undefined */
$contacts = group_get_members($group);
if ($contacts) {
foreach ($contacts as $c) {
if ($contact_str) {
$contact_str .= ',';
}
$contact_str .= "'" . $c['xchan'] . "'";
}
} else {
$contact_str = ' 0 ';
$result['message'] = t('Collection is empty.');
return $result;
}
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND (( author_xchan IN ( {$contact_str} ) OR owner_xchan in ( {$contact_str})) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent {$item_normal} ) ";
$x = group_rec_byhash($uid, $r[0]['hash']);
$result['headline'] = sprintf(t('Collection: %s'), $x['name']);
} elseif ($arr['cid'] && $uid) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($arr['cid']), intval(local_channel()));
if ($r) {
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) {$item_normal} ) ";
$result['headline'] = sprintf(t('Connection: %s'), $r[0]['xchan_name']);
} else {
$result['message'] = t('Connection not found.');
return $result;
}
}
if ($arr['datequery']) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $arr['datequery']))));
}
if ($arr['datequery2']) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $arr['datequery2']))));
}
if (!array_key_exists('nouveau', $arr)) {
$sql_extra2 = " AND item.parent = item.id ";
$sql_extra3 = '';
}
if ($arr['search']) {
if (strpos($arr['search'], '#') === 0) {
$sql_extra .= term_query('item', substr($arr['search'], 1), TERM_HASHTAG, TERM_COMMUNITYTAG);
} else {
$sql_extra .= sprintf(" AND item.body like '%s' ", dbesc(protect_sprintf('%' . $arr['search'] . '%')));
}
}
if (strlen($arr['file'])) {
$sql_extra .= term_query('item', $arr['files'], TERM_FILE);
}
if ($arr['conv'] && $channel) {
$sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", dbesc(protect_sprintf($uidhash)));
}
if ($client_mode & CLIENT_MODE_UPDATE && !($client_mode & CLIENT_MODE_LOAD)) {
// only setup pagination on initial page view
$pager_sql = '';
} else {
//.........这里部分代码省略.........
示例7: init
function init()
{
$result = array();
$notifs = array();
$result['notify'] = 0;
$result['home'] = 0;
$result['network'] = 0;
$result['intros'] = 0;
$result['mail'] = 0;
$result['register'] = 0;
$result['events'] = 0;
$result['events_today'] = 0;
$result['birthdays'] = 0;
$result['birthdays_today'] = 0;
$result['all_events'] = 0;
$result['all_events_today'] = 0;
$result['notice'] = array();
$result['info'] = array();
$t0 = dba_timer();
header("content-type: application/json");
$vnotify = false;
$item_normal = item_normal();
if (local_channel()) {
$vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
$evdays = intval(get_pconfig(local_channel(), 'system', 'evdays'));
$ob_hash = get_observer_hash();
}
// if unset show all visual notification types
if ($vnotify === false) {
$vnotify = -1;
}
if ($evdays < 1) {
$evdays = 3;
}
/**
* If you have several windows open to this site and switch to a different channel
* in one of them, the others may get into a confused state showing you a page or options
* on that page which were only valid under the old identity. You session has changed.
* Therefore we send a notification of this fact back to the browser where it is picked up
* in javascript and which reloads the page it is on so that it is valid under the context
* of the now current channel.
*/
$result['invalid'] = intval($_GET['uid']) && intval($_GET['uid']) != local_channel() ? 1 : 0;
/**
* Send all system messages (alerts) to the browser.
* Some are marked as informational and some represent
* errors or serious notifications. These typically
* will popup on the current page (no matter what page it is)
*/
if (x($_SESSION, 'sysmsg')) {
foreach ($_SESSION['sysmsg'] as $m) {
$result['notice'][] = array('message' => $m);
}
unset($_SESSION['sysmsg']);
}
if (x($_SESSION, 'sysmsg_info')) {
foreach ($_SESSION['sysmsg_info'] as $m) {
$result['info'][] = array('message' => $m);
}
unset($_SESSION['sysmsg_info']);
}
if (!($vnotify & VNOTIFY_INFO)) {
$result['info'] = array();
}
if (!($vnotify & VNOTIFY_ALERT)) {
$result['notice'] = array();
}
if (\App::$install) {
echo json_encode($result);
killme();
}
/**
* Update chat presence indication (if applicable)
*/
if (get_observer_hash() && !$result['invalid']) {
$r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1", dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']));
$basic_presence = false;
if ($r) {
$basic_presence = true;
q("update chatpresence set cp_last = '%s' where cp_id = %d", dbesc(datetime_convert()), intval($r[0]['cp_id']));
}
if (!$basic_presence) {
q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)\n\t\t\t\t\tvalues( '%s', '%s', '%s', '%s' ) ", dbesc(get_observer_hash()), dbesc(datetime_convert()), dbesc('online'), dbesc($_SERVER['REMOTE_ADDR']));
}
}
/**
* Chatpresence continued... if somebody hasn't pinged recently, they've most likely left the page
* and shouldn't count as online anymore. We allow an expection for bots.
*/
q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ", db_utcnow(), db_quoteinterval('3 MINUTE'));
if (!local_channel() || $result['invalid']) {
echo json_encode($result);
killme();
}
/**
* Everything following is only permitted under the context of a locally authenticated site member.
*/
/**
* Handle "mark all xyz notifications read" requests.
*/
//.........这里部分代码省略.........
示例8: public_content
function public_content(&$a, $update = 0, $load = false)
{
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
if (get_config('system', 'block_public') && !get_account_id() && !remote_channel()) {
return login();
}
if (get_config('system', 'disable_discover_tab')) {
return;
}
$item_normal = item_normal();
if (!$update) {
$maxheight = get_config('system', 'home_divmore_height');
if (!$maxheight) {
$maxheight = 400;
}
$o .= '<div id="live-public"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var profile_page = " . App::$pager['page'] . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'public', '$uid' => local_channel() ? local_channel() : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '99', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '1', '$nouveau' => '0', '$wall' => '0', '$list' => '0', '$page' => App::$pager['page'] != 1 ? App::$pager['page'] : 1, '$search' => '', '$order' => 'comment', '$file' => '', '$cats' => '', '$tags' => '', '$dend' => '', '$mid' => '', '$verb' => '', '$dbegin' => ''));
}
if ($update && !$load) {
// only setup pagination on initial page view
$pager_sql = '';
} else {
App::set_pager_itemspage(20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
}
require_once 'include/identity.php';
require_once 'include/security.php';
if (get_config('system', 'site_firehose')) {
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
} else {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$sql_extra = item_permissions_sql($sys['channel_id']);
App::$data['firehose'] = intval($sys['channel_id']);
}
if (get_config('system', 'public_list_mode')) {
$page_mode = 'list';
} else {
$page_mode = 'client';
}
$simple_update = $update ? " and item.item_unseen = 1 " : '';
if ($update && $_SESSION['loadtime']) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
}
if ($load) {
$simple_update = '';
}
//logger('update: ' . $update . ' load: ' . $load);
if ($update) {
$ordering = "commented";
if ($load) {
// Fetch a page full of parent items for this page
$r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\tWHERE true {$uids} {$item_normal}\n\t\t\t\tAND item.parent = item.id\n\t\t\t\tand (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}\n\t\t\t\tORDER BY {$ordering} DESC {$pager_sql} ");
} elseif ($update) {
$r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\tWHERE true {$uids} {$item_normal}\n\t\t\t\tAND item.parent = item.id {$simple_update}\n\t\t\t\tand (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}");
$_SESSION['loadtime'] = datetime_convert();
}
// Then fetch all the children of the parents that are on this page
$parents_str = '';
$update_unseen = '';
if ($r) {
$parents_str = ids_to_querystr($r, 'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item\n\t\t\t\tWHERE true {$uids} {$item_normal}\n\t\t\t\tAND item.parent IN ( %s )\n\t\t\t\t{$sql_extra} ", dbesc($parents_str));
xchan_query($items, true, -1);
$items = fetch_post_tags($items, true);
$items = conv_sort($items, $ordering);
} else {
$items = array();
}
}
// fake it
$mode = 'network';
$o .= conversation($a, $items, $mode, $update, $page_mode);
if ($items && !$update) {
$o .= alt_pager($a, count($items));
}
return $o;
}
示例9: get
function get()
{
if (!get_account_id() || $_SESSION['delegate']) {
notice(t('Permission denied.') . EOL);
return;
}
require_once 'include/security.php';
$change_channel = argc() > 1 ? intval(argv(1)) : 0;
if (argc() > 2 && argv(2) === 'default') {
$r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1", intval($change_channel), intval(get_account_id()));
if ($r) {
q("update account set account_default_channel = %d where account_id = %d", intval($change_channel), intval(get_account_id()));
}
goaway(z_root() . '/manage');
}
if ($change_channel) {
$r = change_channel($change_channel);
if (argc() > 2 && !(argv(2) === 'default')) {
goaway(z_root() . '/' . implode('/', array_slice(\App::$argv, 2)));
// Go to whatever is after /manage/, but with the new channel
} else {
if ($r && $r['channel_startpage']) {
goaway(z_root() . '/' . $r['channel_startpage']);
}
// If nothing extra is specified, go to the default page
}
goaway(z_root());
}
$channels = null;
if (local_channel()) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", intval(get_account_id()));
$account = \App::get_account();
if ($r && count($r)) {
$channels = $r;
for ($x = 0; $x < count($channels); $x++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
$channels[$x]['default'] = $channels[$x]['channel_id'] == $account['account_default_channel'] ? "1" : '';
$channels[$x]['default_links'] = '1';
$c = q("SELECT id, item_wall FROM item\n\t\t\t\t\t\tWHERE item_unseen = 1 and uid = %d " . item_normal(), intval($channels[$x]['channel_id']));
if ($c) {
foreach ($c as $it) {
if (intval($it['item_wall'])) {
$channels[$x]['home']++;
} else {
$channels[$x]['network']++;
}
}
}
$intr = 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($channels[$x]['channel_id']));
if ($intr) {
$channels[$x]['intros'] = intval($intr[0]['total']);
}
$mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", intval($channels[$x]['channel_id']), dbesc($channels[$x]['channel_hash']));
if ($mails) {
$channels[$x]['mail'] = intval($mails[0]['total']);
}
$events = q("SELECT type, start, adjust FROM `event`\n\t\t\t\t\t\tWHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0\n\t\t\t\t\t\tORDER BY `start` ASC ", intval($channels[$x]['channel_id']), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')));
if ($events) {
$channels[$x]['all_events'] = count($events);
if ($channels[$x]['all_events']) {
$str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d');
foreach ($events as $e) {
$bd = false;
if ($e['type'] === 'birthday') {
$channels[$x]['birthdays']++;
$bd = true;
} else {
$channels[$x]['events']++;
}
if (datetime_convert('UTC', intval($e['adjust']) ? date_default_timezone_get() : 'UTC', $e['start'], 'Y-m-d') === $str_now) {
$channels[$x]['all_events_today']++;
if ($bd) {
$channels[$x]['birthdays_today']++;
} else {
$channels[$x]['events_today']++;
}
}
}
}
}
}
}
$r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", intval(get_account_id()));
$limit = account_service_class_fetch(get_account_id(), 'total_identities');
if ($limit !== false) {
$channel_usage_message = sprintf(t("You have created %1\$.0f of %2\$.0f allowed channels."), $r[0]['total'], $limit);
} else {
$channel_usage_message = '';
}
}
$create = array('new_channel', t('Create a new channel'), t('Create New'));
$delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where \n\t\t\tabook_channel = %d and (abook_their_perms & %d) > 0", intval(local_channel()), intval(PERMS_A_DELEGATE));
if ($delegates) {
for ($x = 0; $x < count($delegates); $x++) {
$delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url']) . '&delegate=' . urlencode($delegates[$x]['xchan_addr']);
$delegates[$x]['channel_name'] = $delegates[$x]['xchan_name'];
$delegates[$x]['delegate'] = 1;
}
} else {
$delegates = null;
//.........这里部分代码省略.........
示例10: item_check_service_class
function item_check_service_class($channel_id, $iswebpage)
{
$ret = array('success' => false, 'message' => '');
if ($iswebpage) {
$r = q("select count(i.id) as total from item i \n\t\t\tright join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) \n\t\t\tand i.parent=i.id and i.item_type = %d and i.item_deleted = 0 and i.uid= %d ", intval(ITEM_TYPE_WEBPAGE), intval($channel_id));
} else {
$r = q("select count(id) as total from item where parent = id and item_wall = 1 and uid = %d " . item_normal(), intval($channel_id));
}
if (!$r) {
$ret['message'] = t('Unable to obtain post information from database.');
return $ret;
}
if (!$iswebpage) {
$max = service_class_fetch($channel_id, 'total_items');
if (!service_class_allows($channel_id, 'total_items', $r[0]['total'])) {
$result['message'] .= upgrade_message() . sprintf(t('You have reached your limit of %1$.0f top level posts.'), $max);
return $result;
}
} else {
$max = service_class_fetch($channel_id, 'total_pages');
if (!service_class_allows($channel_id, 'total_pages', $r[0]['total'])) {
$result['message'] .= upgrade_message() . sprintf(t('You have reached your limit of %1$.0f webpages.'), $max);
return $result;
}
}
$ret['success'] = true;
return $ret;
}
示例11: widget_forums
function widget_forums($arr)
{
$a = get_app();
if (!local_channel()) {
return '';
}
$o = '';
if (is_array($arr) && array_key_exists('limit', $arr)) {
$limit = " limit " . intval($limit) . " ";
} else {
$limit = '';
}
$unseen = 0;
if (is_array($arr) && array_key_exists('unseen', $arr) && intval($arr['unseen'])) {
$unseen = 1;
}
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
$r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and abook_channel = %d order by xchan_name {$limit} ", intval(PERMS_W_TAGWALL), intval(PERMS_W_STREAM), intval(local_channel()));
if (!$r1) {
return $o;
}
$str = '';
// Trying to cram all this into a single query with joins and the proper group by's is tough.
// There also should be a way to update this via ajax.
for ($x = 0; $x < count($r1); $x++) {
$r = q("select sum(item_unseen) as unseen from item where owner_xchan = '%s' and uid = %d {$perms_sql} ", dbesc($r1[$x]['xchan_hash']), intval(local_channel()));
if ($r) {
$r1[$x]['unseen'] = $r[0]['unseen'];
}
}
if ($r1) {
$o .= '<div class="widget">';
$o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills nav-stacked">';
foreach ($r1 as $rr) {
if ($unseen && !intval($rr['unseen'])) {
continue;
}
$o .= '<li><a href="network?f=&pf=1&cid=' . $rr['abook_id'] . '" ><span class="badge pull-right">' . (intval($rr['unseen']) ? intval($rr['unseen']) : '') . '</span><img src="' . $rr['xchan_photo_s'] . '" style="width: 16px; height: 16px;" /> ' . $rr['xchan_name'] . '</a></li>';
}
$o .= '</ul></div>';
}
return $o;
}
示例12: search_content
function search_content(&$a, $update = 0, $load = false)
{
if (get_config('system', 'block_public') || get_config('system', 'block_public_search')) {
if (!local_channel() && !remote_channel()) {
notice(t('Public access denied.') . EOL);
return;
}
}
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
nav_set_selected('search');
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/items.php';
$format = $_REQUEST['format'] ? $_REQUEST['format'] : '';
if ($format !== '') {
$update = $load = 1;
}
$observer = $a->get_observer();
$observer_hash = $observer ? $observer['xchan_hash'] : '';
$o = '<div id="live-search"></div>' . "\r\n";
$o = '<div class="generic-content-wrapper-styled">' . "\r\n";
$o .= '<h3>' . t('Search') . '</h3>';
if (x($a->data, 'search')) {
$search = trim($a->data['search']);
} else {
$search = x($_GET, 'search') ? trim(rawurldecode($_GET['search'])) : '';
}
$tag = false;
if (x($_GET, 'tag')) {
$tag = true;
$search = x($_GET, 'tag') ? trim(rawurldecode($_GET['tag'])) : '';
}
if (!local_channel() || !feature_enabled(local_channel(), 'savedsearch')) {
$o .= search($search, 'search-box', '/search', local_channel() ? true : false);
}
if (strpos($search, '#') === 0) {
$tag = true;
$search = substr($search, 1);
}
if (strpos($search, '@') === 0) {
$search = substr($search, 1);
goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
if (strpos($search, '?') === 0) {
$search = substr($search, 1);
goaway(z_root() . '/help' . '?f=1&navsearch=1&search=' . $search);
}
// look for a naked webbie
if (strpos($search, '@') !== false) {
goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
if (!$search) {
return $o;
}
if ($tag) {
$sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type in ( %d , %d) and term = '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG), dbesc(protect_sprintf($search)));
} else {
$regstr = db_getfunc('REGEXP');
$sql_extra = sprintf(" AND `item`.`body` {$regstr} '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
// Here is the way permissions work in the search module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
if (!$update && !$load) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
$o .= '<div id="live-search"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'search', '$uid' => $a->profile['profile_uid'] ? $a->profile['profile_uid'] : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '0', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$page' => $a->pager['page'] != 1 ? $a->pager['page'] : 1, '$search' => ($tag ? urlencode('#') : '') . $search, '$order' => '', '$file' => '', '$cats' => '', '$tags' => '', '$mid' => '', '$verb' => '', '$dend' => '', '$dbegin' => ''));
}
$item_normal = item_normal();
$pub_sql = public_permissions_sql($observer_hash);
require_once 'include/identity.php';
$sys = get_sys_channel();
if ($update && $load) {
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
$a->set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
// in case somebody turned off public access to sys channel content with permissions
if (!perm_is_allowed($sys['channel_id'], $observer_hash, 'view_stream')) {
$sys['xchan_hash'] .= 'disabled';
}
if ($load) {
$r = null;
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'distinct on (created, mid)';
$suffix = 'ORDER BY created DESC, mid';
} else {
$prefix = 'distinct';
$suffix = 'group by mid ORDER BY created DESC';
}
if (local_channel()) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) \n\t\t\t\t\tOR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )\n\t\t\t\t\t{$item_normal}\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t{$suffix} {$pager_sql} ", intval(local_channel()), dbesc($sys['xchan_hash']));
}
if ($r === null) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''\n\t\t\t\t\tAND `item`.`deny_gid` = '' AND item_private = 0 )\n\t\t\t\t\tand owner_xchan in ( " . stream_perms_xchans($observer ? PERMS_NETWORK | PERMS_PUBLIC : PERMS_PUBLIC) . " ))\n\t\t\t\t\t\t{$pub_sql} ) OR owner_xchan = '%s')\n\t\t\t\t\t{$item_normal}\n\t\t\t\t\t{$sql_extra} \n\t\t\t\t\t{$suffix} {$pager_sql}", dbesc($sys['xchan_hash']));
//.........这里部分代码省略.........
示例13: get
//.........这里部分代码省略.........
// if this is a "discover" item, (item['uid'] is the sys channel),
// fallback to the item comment policy, which should've been
// respected when generating the conversation thread.
// Even if the activity is rejected by the item owner, it should still get attached
// to the local discover conversation on this site.
if ($owner_uid != $sys['channel_id'] && !perm_is_allowed($owner_uid, $observer['xchan_hash'], 'post_comments')) {
notice(t('Permission denied') . EOL);
killme();
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['owner_xchan']));
if ($r) {
$thread_owner = $r[0];
} else {
killme();
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']));
if ($r) {
$item_author = $r[0];
} else {
killme();
}
$verbs = " '" . dbesc($activity) . "' ";
$multi_undo = false;
// event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
$multi_undo = 1;
}
if ($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
$verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
$multi_undo = true;
}
$item_normal = item_normal();
$r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( {$verbs} ) {$item_normal}\n\t\t\t\tAND author_xchan = '%s' AND thr_parent = '%s' and uid = %d ", dbesc($observer['xchan_hash']), dbesc($item['mid']), intval($owner_uid));
if ($r) {
// already liked it. Drop that item.
require_once 'include/items.php';
foreach ($r as $rr) {
drop_item($rr['id'], false, DROPITEM_PHASE1);
// set the changed timestamp on the parent so we'll see the update without a page reload
$z = q("update item set changed = '%s' where id = %d and uid = %d", dbesc(datetime_convert()), intval($rr['parent']), intval($rr['uid']));
// Prior activity was a duplicate of the one we're submitting, just undo it;
// don't fall through and create another
if (activity_match($rr['verb'], $activity)) {
$multi_undo = false;
}
// drop_item was not done interactively, so we need to invoke the notifier
// in order to push the changes to connections
proc_run('php', 'include/notifier.php', 'drop', $rr['id']);
}
if ($interactive) {
return;
}
if (!$multi_undo) {
killme();
}
}
}
$mid = item_message_id();
$arr = array();
if ($extended_like) {
$arr['item_thread_top'] = 1;
$arr['item_origin'] = 1;
$arr['item_wall'] = 1;
} else {
示例14: tagadelic
function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG)
{
require_once 'include/security.php';
if (!perm_is_allowed($uid, get_observer_hash(), 'view_stream')) {
return array();
}
$item_normal = item_normal();
$sql_options = item_permissions_sql($uid);
$count = intval($count);
if ($flags) {
if ($flags === 'wall') {
$sql_options .= " and item_wall = 1 ";
}
}
if ($authors) {
if (!is_array($authors)) {
$authors = array($authors);
}
stringify_array_elms($authors, true);
$sql_options .= " and author_xchan in (" . implode(',', $authors) . ") ";
}
if ($owner) {
$sql_options .= " and owner_xchan = '" . dbesc($owner) . "' ";
}
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id\n\t\twhere term.uid = %d and term.ttype = %d \n\t\tand otype = %d and item_type = %d and item_private = 0\n\t\t{$sql_options} {$item_normal}\n\t\tgroup by term order by total desc %s", intval($uid), intval($type), intval(TERM_OBJ_POST), intval($restrict), intval($count) ? "limit {$count}" : '');
if (!$r) {
return array();
}
return Zotlabs\Text\Tagadelic::calc($r);
}
示例15: photos_content
//.........这里部分代码省略.........
$lores = $ph[1];
}
}
$album_link = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null;
$lock = Null;
if ($can_post && $ph[0]['uid'] == $owner_uid) {
$tools = array('profile' => array($a->get_baseurl() . '/profile_photo/use/' . $ph[0]['resource_id'], t('Use as profile photo')));
}
// lockstate
$lockstate = strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']) ? array('lock', t('Private Photo')) : array('unlock', Null);
$a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
if ($prevlink) {
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
}
if ($nextlink) {
$a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
}
$a->page['htmlhead'] .= '});</script>';
if ($prevlink) {
$prevlink = array($prevlink, t('Previous'));
}
$photo = array('href' => $a->get_baseurl() . '/photo/' . $hires['resource_id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'title' => t('View Full Size'), 'src' => $a->get_baseurl() . '/photo/' . $lores['resource_id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('', '', '', 'ymdhis'));
if ($nextlink) {
$nextlink = array($nextlink, t('Next'));
}
// Do we have an item for this photo?
$linked_items = q("SELECT * FROM item WHERE resource_id = '%s' and resource_type = 'photo' \n\t\t\t{$sql_extra} LIMIT 1", dbesc($datum));
$map = null;
if ($linked_items) {
xchan_query($linked_items);
$linked_items = fetch_post_tags($linked_items, true);
$link_item = $linked_items[0];
$item_normal = item_normal();
$r = q("select * from item where parent_mid = '%s' \n\t\t\t\t{$item_normal} and uid = %d {$sql_extra} ", dbesc($link_item['mid']), intval($link_item['uid']));
if ($r) {
xchan_query($r);
$r = fetch_post_tags($r, true);
$r = conv_sort($r, 'commented');
}
$tags = array();
if ($link_item['term']) {
$cnt = 0;
foreach ($link_item['term'] as $t) {
$tags[$cnt] = array(0 => format_term_for_display($t));
if ($can_post && $ph[0]['uid'] == $owner_uid) {
$tags[$cnt][1] = 'tagrm/drop/' . $link_item['id'] . '/' . bin2hex($t['term']);
//?f=&item=' . $link_item['id'];
$tags[$cnt][2] = t('Remove');
}
$cnt++;
}
}
if (local_channel() && local_channel() == $link_item['uid']) {
q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1", intval($link_item['parent']), intval(local_channel()));
}
if ($link_item['coord']) {
$map = generate_map($link_item['coord']);
}
}
// logger('mod_photo: link_item' . print_r($link_item,true));
// FIXME - remove this when we move to conversation module
$r = $r[0]['children'];
$edit = null;
if ($can_post) {
$album_e = $ph[0]['album'];