当前位置: 首页>>代码示例>>PHP>>正文


PHP can_write_wall函数代码示例

本文整理汇总了PHP中can_write_wall函数的典型用法代码示例。如果您正苦于以下问题:PHP can_write_wall函数的具体用法?PHP can_write_wall怎么用?PHP can_write_wall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了can_write_wall函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_mode

 /**
  * Set the mode we'll be displayed on
  */
 private function set_mode($mode)
 {
     if ($this->get_mode() == $mode) {
         return;
     }
     $a = $this->get_app();
     switch ($mode) {
         case 'network':
         case 'notes':
             $this->profile_owner = local_user();
             $this->writable = true;
             break;
         case 'profile':
             $this->profile_owner = $a->profile['profile_uid'];
             $this->writable = can_write_wall($a, $this->profile_owner);
             break;
         case 'display':
             $this->profile_owner = $a->profile['uid'];
             $this->writable = can_write_wall($a, $this->profile_owner);
             break;
         default:
             logger('[ERROR] Conversation::set_mode : Unhandled mode (' . $mode . ').', LOGGER_DEBUG);
             return false;
             break;
     }
     $this->mode = $mode;
 }
开发者ID:ZerGabriel,项目名称:friendica,代码行数:30,代码来源:Conversation.php

示例2: common_friends_visitor_widget

function common_friends_visitor_widget($profile_uid)
{
    $a = get_app();
    if (local_user() == $profile_uid) {
        return;
    }
    $cid = $zcid = 0;
    if (can_write_wall($a, $profile_uid)) {
        $cid = remote_user();
    } else {
        if (get_my_url()) {
            $r = q("select id from contact where nurl = '%s' and uid = %d limit 1", dbesc(normalise_link(get_my_url())), intval($profile_uid));
            if (count($r)) {
                $cid = $r[0]['id'];
            } else {
                $r = q("select id from gcontact where nurl = '%s' limit 1", dbesc(normalise_link(get_my_url())));
                if (count($r)) {
                    $zcid = $r[0]['id'];
                }
            }
        }
    }
    if ($cid == 0 && $zcid == 0) {
        return;
    }
    require_once 'include/socgraph.php';
    if ($cid) {
        $t = count_common_friends($profile_uid, $cid);
    } else {
        $t = count_common_friends_zcid($profile_uid, $zcid);
    }
    if (!$t) {
        return;
    }
    if ($cid) {
        $r = common_friends($profile_uid, $cid, 0, 5, true);
    } else {
        $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
    }
    return replace_macros(get_markup_template('remote_friends_common.tpl'), array('$desc' => sprintf(tt("%d contact in common", "%d contacts in common", $t), $t), '$base' => $a->get_baseurl(), '$uid' => $profile_uid, '$cid' => $cid ? $cid : '0', '$linkmore' => $t > 5 ? 'true' : '', '$more' => t('show more'), '$items' => $r));
}
开发者ID:robhell,项目名称:friendica,代码行数:41,代码来源:contact_widgets.php

示例3: conversation

 function conversation(&$a, $items, $mode, $update, $preview = false)
 {
     require_once 'bbcode.php';
     $ssl_state = local_user() ? true : false;
     $profile_owner = 0;
     $page_writeable = false;
     $previewing = $preview ? ' preview ' : '';
     if ($mode === 'network') {
         $profile_owner = local_user();
         $page_writeable = true;
     }
     if ($mode === 'profile') {
         $profile_owner = $a->profile['profile_uid'];
         $page_writeable = can_write_wall($a, $profile_owner);
     }
     if ($mode === 'notes') {
         $profile_owner = local_user();
         $page_writeable = true;
     }
     if ($mode === 'display') {
         $profile_owner = $a->profile['uid'];
         $page_writeable = can_write_wall($a, $profile_owner);
     }
     if ($mode === 'community') {
         $profile_owner = 0;
         $page_writeable = false;
     }
     if ($update) {
         $return_url = $_SESSION['return_url'];
     } else {
         $return_url = $_SESSION['return_url'] = $a->query_string;
     }
     load_contact_links(local_user());
     $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
     call_hooks('conversation_start', $cb);
     $items = $cb['items'];
     $cmnt_tpl = get_markup_template('comment_item.tpl');
     $tpl = 'wall_item.tpl';
     $wallwall = 'wallwall_item.tpl';
     $hide_comments_tpl = get_markup_template('hide_comments.tpl');
     $alike = array();
     $dlike = array();
     // array with html for each thread (parent+comments)
     $threads = array();
     $threadsid = -1;
     if ($items && count($items)) {
         if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
             // "New Item View" on network page or search page results
             // - just loop through the items and format them minimally for display
             //$tpl = get_markup_template('search_item.tpl');
             $tpl = 'search_item.tpl';
             foreach ($items as $item) {
                 $threadsid++;
                 $comment = '';
                 $owner_url = '';
                 $owner_photo = '';
                 $owner_name = '';
                 $sparkle = '';
                 if ($mode === 'search' || $mode === 'community') {
                     if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                         continue;
                     }
                     $nickname = $item['nickname'];
                 } else {
                     $nickname = $a->user['nickname'];
                 }
                 // prevent private email from leaking.
                 if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
                     continue;
                 }
                 $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
                 if ($item['author-link'] && !$item['author-name']) {
                     $profile_name = $item['author-link'];
                 }
                 $sp = false;
                 $profile_link = best_link_url($item, $sp);
                 if ($profile_link === 'mailbox') {
                     $profile_link = '';
                 }
                 if ($sp) {
                     $sparkle = ' sparkle';
                 } else {
                     $profile_link = zrl($profile_link);
                 }
                 $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
                 if ($normalised != 'mailbox' && x($a->contacts[$normalised])) {
                     $profile_avatar = $a->contacts[$normalised]['thumb'];
                 } else {
                     $profile_avatar = strlen($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'];
                 }
                 $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
                 call_hooks('render_location', $locate);
                 $location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate);
                 localize_item($item);
                 if ($mode === 'network-new') {
                     $dropping = true;
                 } else {
                     $dropping = false;
                 }
                 $drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete'));
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica,代码行数:101,代码来源:conversation.php

示例4: like_content

function like_content(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    $verb = notags(trim($_GET['verb']));
    if (!$verb) {
        $verb = 'like';
    }
    switch ($verb) {
        case 'like':
        case 'unlike':
            $activity = ACTIVITY_LIKE;
            break;
        case 'dislike':
        case 'undislike':
            $activity = ACTIVITY_DISLIKE;
            break;
        case 'attendyes':
        case 'unattendyes':
            $activity = ACTIVITY_ATTEND;
            break;
        case 'attendno':
        case 'unattendno':
            $activity = ACTIVITY_ATTENDNO;
            break;
        case 'attendmaybe':
        case 'unattendmaybe':
            $activity = ACTIVITY_ATTENDMAYBE;
            break;
        default:
            return;
            break;
    }
    $item_id = $a->argc > 1 ? notags(trim($a->argv[1])) : 0;
    logger('like: verb ' . $verb . ' item ' . $item_id);
    $r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", dbesc($item_id), dbesc($item_id));
    if (!$item_id || !count($r)) {
        logger('like: no item ' . $item_id);
        return;
    }
    $item = $r[0];
    $owner_uid = $item['uid'];
    if (!can_write_wall($a, $owner_uid)) {
        return;
    }
    $remote_owner = null;
    if (!$item['wall']) {
        // The top level post may have been written by somebody on another system
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item['contact-id']), intval($item['uid']));
        if (!count($r)) {
            return;
        }
        if (!$r[0]['self']) {
            $remote_owner = $r[0];
        }
    }
    // this represents the post owner on this system.
    $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\tWHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", intval($owner_uid));
    if (count($r)) {
        $owner = $r[0];
    }
    if (!$owner) {
        logger('like: no owner');
        return;
    }
    if (!$remote_owner) {
        $remote_owner = $owner;
    }
    // This represents the person posting
    if (local_user() && local_user() == $owner_uid) {
        $contact = $owner;
    } else {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid));
        if (count($r)) {
            $contact = $r[0];
        }
    }
    if (!$contact) {
        return;
    }
    // See if we've been passed a return path to redirect to
    $return_path = x($_REQUEST, 'return') ? $_REQUEST['return'] : '';
    $verbs = " '" . dbesc($activity) . "' ";
    // event participation 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) . "' ";
    }
    $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( {$verbs} ) AND `deleted` = 0\n\t\tAND `contact-id` = %d AND `uid` = %d\n\t\tAND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1", intval($contact['id']), intval($owner_uid), dbesc($item_id), dbesc($item_id), dbesc($item['uri']));
    if (count($r)) {
        $like_item = $r[0];
        // Already voted, undo it
        $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), intval($like_item['id']));
        // Clean up the Diaspora signatures for this like
        // Go ahead and do it even if Diaspora support is disabled. We still want to clean up
        // if it had been enabled in the past
        $r = q("DELETE FROM `sign` WHERE `iid` = %d", intval($like_item['id']));
        // Save the author information for the unlike in case we need to relay to Diaspora
        store_diaspora_like_retract_sig($activity, $item, $like_item, $contact);
//.........这里部分代码省略.........
开发者ID:vinzv,项目名称:friendica,代码行数:101,代码来源:like.php

示例5: conversation

/**
 * "Render" a conversation or list of items for HTML display.
 * There are two major forms of display:
 *      - Sequential or unthreaded ("New Item View" or search results)
 *      - conversation view
 * The $mode parameter decides between the various renderings and also
 * figures out how to determine page owner and other contextual items 
 * that are based on unique features of the calling module.
 *
 */
function conversation(&$a, $items, $mode, $update, $preview = false)
{
    require_once 'bbcode.php';
    $profile_owner = 0;
    $page_writeable = false;
    if ($mode === 'network') {
        $profile_owner = local_user();
        $page_writeable = true;
    }
    if ($mode === 'profile') {
        $profile_owner = $a->profile['profile_uid'];
        $page_writeable = can_write_wall($a, $profile_owner);
    }
    if ($mode === 'notes') {
        $profile_owner = local_user();
        $page_writeable = true;
    }
    if ($mode === 'display') {
        $profile_owner = $a->profile['uid'];
        $page_writeable = can_write_wall($a, $profile_owner);
    }
    if ($mode === 'community') {
        $profile_owner = 0;
        $page_writeable = false;
    }
    if ($update) {
        $return_url = $_SESSION['return_url'];
    } else {
        $return_url = $_SESSION['return_url'] = $a->cmd;
    }
    load_contact_links(local_user());
    $cmnt_tpl = get_markup_template('comment_item.tpl');
    $tpl = get_markup_template('wall_item.tpl');
    $wallwall = get_markup_template('wallwall_item.tpl');
    $hide_comments_tpl = get_markup_template('hide_comments.tpl');
    $alike = array();
    $dlike = array();
    // array with html for each thread (parent+comments)
    $threads = array();
    $threadsid = -1;
    if (count($items)) {
        if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
            // "New Item View" on network page or search page results
            // - just loop through the items and format them minimally for display
            $tpl = get_markup_template('search_item.tpl');
            foreach ($items as $item) {
                $threadsid++;
                $comment = '';
                $owner_url = '';
                $owner_photo = '';
                $owner_name = '';
                $sparkle = '';
                if ($mode === 'search' || $mode === 'community') {
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                        continue;
                    }
                    $nickname = $item['nickname'];
                } else {
                    $nickname = $a->user['nickname'];
                }
                $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
                if ($item['author-link'] && !$item['author-name']) {
                    $profile_name = $item['author-link'];
                }
                $sp = false;
                $profile_link = best_link_url($item, $sp);
                if ($sp) {
                    $sparkle = ' sparkle';
                }
                if ($profile_link === 'mailbox') {
                    $profile_link = '';
                }
                $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
                if ($normalised != 'mailbox' && x($a->contacts[$normalised])) {
                    $profile_avatar = $a->contacts[$normalised]['thumb'];
                } else {
                    $profile_avatar = strlen($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'];
                }
                $location = $item['location'] ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '';
                $coord = $item['coord'] ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '';
                if ($coord) {
                    if ($location) {
                        $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
                    } else {
                        $location = '<span class="smalltext">' . $coord . '</span>';
                    }
                }
                localize_item($item);
                if ($mode === 'network-new') {
                    $dropping = true;
//.........这里部分代码省略.........
开发者ID:nphyx,项目名称:friendica,代码行数:101,代码来源:conversation.php

示例6: photos_content


//.........这里部分代码省略.........
            $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, \n\t\t\t\t`contact`.`rel`, `contact`.`thumb`, `contact`.`self`, \n\t\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tWHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tAND `item`.`uid` = %d\n\t\t\t\t{$sql_extra}\n\t\t\t\tORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", dbesc($link_item['uri']), dbesc($link_item['uri']), intval($link_item['uid']), intval($a->pager['start']), intval($a->pager['itemspage']));
            if (local_user() && local_user() == $link_item['uid']) {
                q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d", intval($link_item['parent']), intval(local_user()));
            }
        }
        $tags = Null;
        if (count($linked_items) && strlen($link_item['tag'])) {
            $arr = explode(',', $link_item['tag']);
            // parse tags and add links
            $tag_str = '';
            foreach ($arr as $t) {
                if (strlen($tag_str)) {
                    $tag_str .= ', ';
                }
                $tag_str .= bbcode($t);
            }
            $tags = array(t('Tags: '), $tag_str);
            if ($cmd === 'edit') {
                $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
                $tags[] = t('[Remove any tag]');
            }
        }
        $edit = Null;
        if ($cmd === 'edit' && $can_post) {
            $edit_tpl = get_markup_template('photo_edit.tpl');
            $edit = replace_macros($edit_tpl, array('$id' => $ph[0]['id'], '$rotate' => t('Rotate CW'), '$album' => template_escape($ph[0]['album']), '$newalbum' => t('New album name'), '$nickname' => $a->data['user']['nickname'], '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => template_escape($ph[0]['desc']), '$tag_label' => t('Add a Tag'), '$tags' => $link_item['tag'], '$permissions' => t('Permissions'), '$aclselect' => template_escape(populate_acl($ph[0])), '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), '$item_id' => count($linked_items) ? $link_item['id'] : 0, '$submit' => t('Submit'), '$delete' => t('Delete Photo')));
        }
        if (count($linked_items)) {
            $cmnt_tpl = get_markup_template('comment_item.tpl');
            $tpl = get_markup_template('photo_item.tpl');
            $return_url = $a->cmd;
            $like_tpl = get_markup_template('like_noshare.tpl');
            $likebuttons = '';
            if ($can_post || can_write_wall($a, $owner_uid)) {
                $likebuttons = replace_macros($like_tpl, array('$id' => $link_item['id'], '$likethis' => t("I like this (toggle)"), '$nolike' => t("I don't like this (toggle)"), '$share' => t('Share'), '$wait' => t('Please wait')));
            }
            $comments = '';
            if (!count($r)) {
                if ($can_post || can_write_wall($a, $owner_uid)) {
                    if ($link_item['last-child']) {
                        $comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => ''));
                    }
                }
            }
            $alike = array();
            $dlike = array();
            $like = '';
            $dislike = '';
            // display comments
            if (count($r)) {
                foreach ($r as $item) {
                    like_puller($a, $item, $alike, 'like');
                    like_puller($a, $item, $dlike, 'dislike');
                }
                $like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
                $dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
                if ($can_post || can_write_wall($a, $owner_uid)) {
                    if ($link_item['last-child']) {
                        $comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
                    }
                }
                foreach ($r as $item) {
                    $comment = '';
                    $template = $tpl;
                    $sparkle = '';
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
开发者ID:robhell,项目名称:friendica,代码行数:67,代码来源:photos.php

示例7: item_post


//.........这里部分代码省略.........
                    if ($probed_contact["network"] != NETWORK_FEED) {
                        $parent_contact = $probed_contact;
                        $parent_contact["nurl"] = normalise_link($probed_contact["url"]);
                        $parent_contact["thumb"] = $probed_contact["photo"];
                        $parent_contact["micro"] = $probed_contact["photo"];
                    }
                    logger('parent contact: ' . print_r($parent_contact, true), LOGGER_DEBUG);
                } else {
                    logger('no contact found: ' . print_r($thrparent, true), LOGGER_DEBUG);
                }
            }
        }
    }
    if ($parent) {
        logger('mod_item: item_post parent=' . $parent);
    }
    $profile_uid = x($_REQUEST, 'profile_uid') ? intval($_REQUEST['profile_uid']) : 0;
    $post_id = x($_REQUEST, 'post_id') ? intval($_REQUEST['post_id']) : 0;
    $app = x($_REQUEST, 'source') ? strip_tags($_REQUEST['source']) : '';
    $extid = x($_REQUEST, 'extid') ? strip_tags($_REQUEST['extid']) : '';
    $allow_moderated = false;
    // here is where we are going to check for permission to post a moderated comment.
    // First check that the parent exists and it is a wall item.
    if (x($_REQUEST, 'commenter') && (!$parent || !$parent_item['wall'])) {
        notice(t('Permission denied.') . EOL);
        if (x($_REQUEST, 'return')) {
            goaway($a->get_baseurl() . "/" . $return_path);
        }
        killme();
    }
    // Now check that it is a page_type of PAGE_BLOG, and that valid personal details
    // have been provided, and run any anti-spam plugins
    // TODO
    if (!can_write_wall($a, $profile_uid) && !$allow_moderated) {
        notice(t('Permission denied.') . EOL);
        if (x($_REQUEST, 'return')) {
            goaway($a->get_baseurl() . "/" . $return_path);
        }
        killme();
    }
    // is this an edited post?
    $orig_post = null;
    if ($post_id) {
        $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($profile_uid), intval($post_id));
        if (!count($i)) {
            killme();
        }
        $orig_post = $i[0];
    }
    $user = null;
    $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($profile_uid));
    if (count($r)) {
        $user = $r[0];
    }
    if ($orig_post) {
        $str_group_allow = $orig_post['allow_gid'];
        $str_contact_allow = $orig_post['allow_cid'];
        $str_group_deny = $orig_post['deny_gid'];
        $str_contact_deny = $orig_post['deny_cid'];
        $location = $orig_post['location'];
        $coord = $orig_post['coord'];
        $verb = $orig_post['verb'];
        $objecttype = $orig_post['object-type'];
        $emailcc = $orig_post['emailcc'];
        $app = $orig_post['app'];
        $categories = $orig_post['file'];
开发者ID:strk,项目名称:friendica,代码行数:67,代码来源:item.php

示例8: item_post

function item_post(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    require_once 'include/security.php';
    $uid = $_SESSION['uid'];
    $parent = x($_POST, 'parent') ? intval($_POST['parent']) : 0;
    $parent_item = null;
    if ($parent) {
        $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($parent));
        if (!count($r)) {
            notice(t('Unable to locate original post.') . EOL);
            goaway($a->get_baseurl() . "/" . $_POST['return']);
        }
        $parent_item = $r[0];
    }
    $profile_uid = x($_POST, 'profile_uid') ? intval($_POST['profile_uid']) : 0;
    if (!can_write_wall($a, $profile_uid)) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $user = null;
    $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($profile_uid));
    if (count($r)) {
        $user = $r[0];
    }
    $str_group_allow = perms2str($_POST['group_allow']);
    $str_contact_allow = perms2str($_POST['contact_allow']);
    $str_group_deny = perms2str($_POST['group_deny']);
    $str_contact_deny = perms2str($_POST['contact_deny']);
    $title = notags(trim($_POST['title']));
    $body = escape_tags(trim($_POST['body']));
    $location = notags(trim($_POST['location']));
    $verb = notags(trim($_POST['verb']));
    if (!strlen($body)) {
        notice(t('Empty post discarded.') . EOL);
        goaway($a->get_baseurl() . "/" . $_POST['return']);
    }
    // get contact info for poster
    $author = null;
    if ($_SESSION['uid'] && $_SESSION['uid'] == $profile_uid) {
        $r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1", intval($_SESSION['uid']));
    } else {
        if (x($_SESSION, 'visitor_id') && intval($_SESSION['visitor_id'])) {
            $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($_SESSION['visitor_id']));
        }
    }
    if (count($r)) {
        $author = $r[0];
        $contact_id = $author['id'];
    }
    // get contact info for owner
    if ($profile_uid == $_SESSION['uid']) {
        $contact_record = $author;
    } else {
        $r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1", intval($profile_uid));
        if (count($r)) {
            $contact_record = $r[0];
        }
    }
    $post_type = notags(trim($_POST['type']));
    if ($post_type == 'net-comment') {
        if ($parent_item !== null) {
            if ($parent_item['type'] == 'remote') {
                $post_type = 'remote-comment';
            } else {
                $post_type = 'wall-comment';
            }
        }
    }
    $wall = 0;
    if ($post_type == 'wall' || $post_type == 'wall-comment') {
        $wall = 1;
    }
    if (!strlen($verb)) {
        $verb = ACTIVITY_POST;
    }
    $gravity = $parent ? 6 : 0;
    $notify_type = $parent ? 'comment-new' : 'wall-new';
    $uri = item_new_uri($a->get_hostname(), $profile_uid);
    $r = q("INSERT INTO `item` (`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, \n\t\t`author-name`, `author-link`, `author-avatar`, `created`,\n\t\t`edited`, `changed`, `uri`, `title`, `body`, `location`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)\n\t\tVALUES( '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", dbesc($post_type), intval($wall), intval($gravity), intval($contact_id), dbesc($contact_record['name']), dbesc($contact_record['url']), dbesc($contact_record['thumb']), dbesc($author['name']), dbesc($author['url']), dbesc($author['thumb']), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($uri), dbesc($title), dbesc($body), dbesc($location), dbesc($verb), dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), dbesc($str_group_deny));
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($uri));
    if (count($r)) {
        $post_id = $r[0]['id'];
        if ($parent) {
            // This item is the last leaf and gets the comment box, clear any ancestors
            $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s'  WHERE `parent` = %d ", dbesc(datetime_convert()), intval($parent));
            // Inherit ACL's from the parent item.
            // TODO merge with subsequent UPDATE operation and save a db write
            $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'\n\t\t\t\tWHERE `id` = %d LIMIT 1", dbesc($parent_item['allow_cid']), dbesc($parent_item['allow_gid']), dbesc($parent_item['deny_cid']), dbesc($parent_item['deny_gid']), intval($post_id));
            if ($user['notify-flags'] & NOTIFY_COMMENT && $contact_record != $author) {
                require_once 'bbcode.php';
                $from = $author['name'];
                $tpl = file_get_contents('view/cmnt_received_eml.tpl');
                $email_tpl = replace_macros($tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user['username'], '$email' => $user['email'], '$from' => $from, '$body' => strip_tags(bbcode($body))));
                $res = mail($user['email'], $from . t(" commented on your item at ") . $a->config['sitename'], $email_tpl, t("From: Administrator@") . $a->get_hostname());
            }
        } else {
            $parent = $post_id;
//.........这里部分代码省略.........
开发者ID:vishalp,项目名称:MistparkPE-Remix,代码行数:101,代码来源:item.php

示例9: photos_content


//.........这里部分代码省略.........
            $private_post = 1;
            if ($_REQUEST['public']) {
                $private_post = 0;
            }
            $query_str = $a->query_string;
            if (strpos($query_str, 'public=1') !== false) {
                $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
            }
            // I think $a->query_string may never have ? in it, but I could be wrong
            // It looks like it's from the index.php?q=[etc] rewrite that the web
            // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
            if (strpos($query_str, '?') === false) {
                $public_post_link = '?public=1';
            } else {
                $public_post_link = '&public=1';
            }
            if ($a->theme['template_engine'] === 'internal') {
                $album_e = template_escape($ph[0]['album']);
                $caption_e = template_escape($ph[0]['desc']);
                $aclselect_e = template_escape(populate_acl($ph[0]));
            } else {
                $album_e = $ph[0]['album'];
                $caption_e = $ph[0]['desc'];
                $aclselect_e = populate_acl($ph[0]);
            }
            $edit = replace_macros($edit_tpl, array('$id' => $ph[0]['id'], '$rotatecw' => t('Rotate CW (right)'), '$rotateccw' => t('Rotate CCW (left)'), '$album' => $album_e, '$newalbum' => t('New album name'), '$nickname' => $a->data['user']['nickname'], '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => $caption_e, '$tag_label' => t('Add a Tag'), '$tags' => $link_item['tag'], '$permissions' => t('Permissions'), '$aclselect' => $aclselect_e, '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), '$item_id' => count($linked_items) ? $link_item['id'] : 0, '$submit' => t('Submit'), '$delete' => t('Delete Photo'), '$acl_data' => construct_acl_data($a, $ph[0]), '$group_perms' => t('Show to Groups'), '$contact_perms' => t('Show to Contacts'), '$private' => t('Private photo'), '$public' => t('Public photo'), '$is_private' => $private_post, '$return_path' => $query_str, '$public_link' => $public_post_link));
        }
        if (count($linked_items)) {
            $cmnt_tpl = get_markup_template('comment_item.tpl');
            $tpl = get_markup_template('photo_item.tpl');
            $return_url = $a->cmd;
            $like_tpl = get_markup_template('like_noshare.tpl');
            $likebuttons = '';
            if ($can_post || can_write_wall($a, $owner_uid)) {
                $likebuttons = replace_macros($like_tpl, array('$id' => $link_item['id'], '$likethis' => t("I like this (toggle)"), '$nolike' => feature_enabled(local_user(), 'dislike') ? t("I don't like this (toggle)") : '', '$share' => t('Share'), '$wait' => t('Please wait'), '$return_path' => $a->query_string));
            }
            $comments = '';
            if (!count($r)) {
                if ($can_post || can_write_wall($a, $owner_uid)) {
                    if ($link_item['last-child']) {
                        $comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => '', '$rand_num' => random_digits(12)));
                    }
                }
            }
            $alike = array();
            $dlike = array();
            $like = '';
            $dislike = '';
            // display comments
            if (count($r)) {
                foreach ($r as $item) {
                    like_puller($a, $item, $alike, 'like');
                    like_puller($a, $item, $dlike, 'dislike');
                }
                $like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
                $dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
                if ($can_post || can_write_wall($a, $owner_uid)) {
                    if ($link_item['last-child']) {
                        $comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => '', '$rand_num' => random_digits(12)));
                    }
                }
                foreach ($r as $item) {
                    $comment = '';
                    $template = $tpl;
                    $sparkle = '';
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
开发者ID:jzacman,项目名称:friendica,代码行数:67,代码来源:photos.php

示例10: profile_content

function profile_content(&$a, $update = 0)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return login();
    }
    require_once "include/bbcode.php";
    require_once 'include/security.php';
    require_once 'include/conversation.php';
    require_once 'include/acl_selectors.php';
    $groups = array();
    $tab = 'posts';
    $o = '';
    if ($update) {
        // Ensure we've got a profile owner if updating.
        $a->profile['profile_uid'] = $update;
    } else {
        if ($a->profile['profile_uid'] == local_user()) {
            nav_set_selected('home');
        }
    }
    $contact = null;
    $remote_contact = false;
    if (remote_user()) {
        $contact_id = $_SESSION['visitor_id'];
        $groups = init_groups_visitor($contact_id);
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($a->profile['profile_uid']));
        if (count($r)) {
            $contact = $r[0];
            $remote_contact = true;
        }
    }
    if (!$remote_contact) {
        if (local_user()) {
            $contact_id = $_SESSION['cid'];
            $contact = $a->contact;
        }
    }
    $is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
    if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
        notice(t('Access to this profile has been restricted.') . EOL);
        return;
    }
    if (!$update) {
        if (x($_GET, 'tab')) {
            $tab = notags(trim($_GET['tab']));
        }
        $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
        if ($tab === 'profile') {
            require_once 'include/profile_advanced.php';
            $o .= advanced_profile($a);
            call_hooks('profile_advanced', $o);
            return $o;
        }
        if (x($_SESSION, 'new_member') && $_SESSION['new_member'] && $is_owner) {
            $o .= '<a href="newmember">' . t('Tips for New Members') . '</a>' . EOL;
        }
        $commpage = $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        $commvisitor = $commpage && $remote_contact == true ? true : false;
        $celeb = $a->profile['page-flags'] == PAGE_SOAPBOX || $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        if (can_write_wall($a, $a->profile['profile_uid'])) {
            $x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'] ? true : false, 'default_location' => $is_owner ? $a->user['default-location'] : '', 'nickname' => $a->profile['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($a->user, $celeb) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid']);
            $o .= status_editor($a, $x);
        }
    }
    if ($is_owner) {
        $r = q("UPDATE `item` SET `unseen` = 0 \n\t\t\tWHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", intval(local_user()));
    }
    /**
     * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     */
    $sql_extra = permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
    $r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 \n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1\n\t\t{$sql_extra} ", intval($a->profile['profile_uid']));
    if (count($r)) {
        $a->set_pager_total($r[0]['total']);
        $a->set_pager_itemspage(40);
    }
    $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1\n\t\t{$sql_extra}\n\t\tORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval($a->profile['profile_uid']), intval($a->pager['start']), intval($a->pager['itemspage']));
    $parents_arr = array();
    $parents_str = '';
    if (count($r)) {
        foreach ($r as $rr) {
            $parents_arr[] = $rr['item_id'];
        }
        $parents_str = implode(', ', $parents_arr);
        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, \n\t\t\t`contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent` = `p`.`id`) AS `parentitem`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `parentitem`.`created` DESC, `gravity` ASC, `item`.`created` ASC ", intval($a->profile['profile_uid']), dbesc($parents_str));
    }
    if ($is_owner && !$update) {
        $o .= get_birthdays();
        $o .= get_events();
    }
    if (!$update && $tab === 'posts') {
        // 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-profile"></div>' . "\r\n";
        $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
    }
    $o .= conversation($a, $r, 'profile', $update);
    if (!$update) {
        $o .= paginate($a);
    }
//.........这里部分代码省略.........
开发者ID:ryivhnn,项目名称:friendica,代码行数:101,代码来源:profile.php

示例11: like_content

function like_content(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    $verb = notags(trim($_GET['verb']));
    if (!$verb) {
        $verb = 'like';
    }
    switch ($verb) {
        case 'like':
        case 'unlike':
            $activity = ACTIVITY_LIKE;
            break;
        case 'dislike':
        case 'undislike':
            $activity = ACTIVITY_DISLIKE;
            break;
        default:
            return;
            break;
    }
    $item_id = $a->argc > 1 ? notags(trim($a->argv[1])) : 0;
    logger('like: verb ' . $verb . ' item ' . $item_id);
    $r = q("SELECT * FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s') AND `id` = `parent` LIMIT 1", dbesc($item_id), dbesc($item_id));
    if (!$item_id || !count($r)) {
        logger('like: no item ' . $item_id);
        return;
    }
    $item = $r[0];
    $owner_uid = $item['uid'];
    if (!can_write_wall($a, $owner_uid)) {
        return;
    }
    $remote_owner = null;
    if (!$item['wall']) {
        // The top level post may have been written by somebody on another system
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item['contact-id']), intval($item['uid']));
        if (!count($r)) {
            return;
        }
        if (!$r[0]['self']) {
            $remote_owner = $r[0];
        }
    }
    // this represents the post owner on this system.
    $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\tWHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", intval($owner_uid));
    if (count($r)) {
        $owner = $r[0];
    }
    if (!$owner) {
        logger('like: no owner');
        return;
    }
    if (!$remote_owner) {
        $remote_owner = $owner;
    }
    // This represents the person posting
    if (local_user() && local_user() == $owner_uid) {
        $contact = $owner;
    } else {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid));
        if (count($r)) {
            $contact = $r[0];
        }
    }
    if (!$contact) {
        return;
    }
    $r = q("SELECT `id` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0 \n\t\tAND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s') LIMIT 1", dbesc($activity), intval($contact['id']), dbesc($item_id), dbesc($item_id));
    if (count($r)) {
        // Already voted, undo it
        $r = q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($r[0]['id']));
        proc_run('php', "include/notifier.php", "like", "{$post_id}");
        return;
    }
    $uri = item_new_uri($a->get_hostname(), $owner_uid);
    $post_type = $item['resource-id'] ? t('photo') : t('status');
    $objtype = $item['resource-id'] ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE;
    $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
    $body = $item['body'];
    $obj = <<<EOT

\t<object>
\t\t<type>{$objtype}</type>
\t\t<local>1</local>
\t\t<id>{$item['uri']}</id>
\t\t<link>{$link}</link>
\t\t<title></title>
\t\t<content>{$body}</content>
\t</object>
EOT;
    if ($verb === 'like') {
        $bodyverb = t('%1$s likes %2$s\'s %3$s');
    }
    if ($verb === 'dislike') {
        $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
    }
    if (!isset($bodyverb)) {
        return;
//.........这里部分代码省略.........
开发者ID:nextgensh,项目名称:friendica,代码行数:101,代码来源:like.php

示例12: profile_content

function profile_content(&$a, $update = false)
{
    require_once "include/bbcode.php";
    require_once 'include/security.php';
    $groups = array();
    $tab = 'posts';
    if (remote_user()) {
        $contact_id = $_SESSION['visitor_id'];
        $groups = init_groups_visitor($contact_id);
        $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($contact_id));
        if (count($r)) {
            $contact = $r[0];
        }
    } else {
        if (local_user()) {
            $contact_id = $_SESSION['cid'];
            $contact = $a->contact;
        }
    }
    $a->profile['profile_uid'] = 1;
    if (!$update) {
        if (x($_GET, 'tab')) {
            $tab = notags(trim($_GET['tab']));
        }
        $tpl = file_get_contents('view/profile_tabs.tpl');
        $o .= replace_macros($tpl, array('$url' => $a->get_baseurl() . '/' . $a->cmd, '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname']));
        if ($tab == 'profile') {
            require_once 'view/profile_advanced.php';
            return $o;
        }
        if (can_write_wall($a, 1)) {
            $tpl = file_get_contents('view/jot-header.tpl');
            $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
            require_once 'view/acl_selectors.php';
            $tpl = file_get_contents("view/jot.tpl");
            if (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid']))) {
                $lockstate = 'lock';
            } else {
                $lockstate = 'unlock';
            }
            $o .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$defloc' => $_SESSION['uid'] == 1 ? $a->user['default-location'] : '', '$return_path' => $a->cmd, '$visitor' => $_SESSION['uid'] == 1 ? 'block' : 'none', '$lockstate' => $lockstate, '$acl' => $_SESSION['uid'] == 1 ? populate_acl($a->user) : '', '$profile_uid' => 1));
        }
        if ($tab == 'posts' && !$a->pager['start']) {
            $o .= '<div id="live-profile"></div>' . "\r\n";
        }
    }
    // default permissions - anonymous user
    $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
    // Profile owner - everything is visible
    if (local_user()) {
        $sql_extra = '';
        // Oh - while we're here... reset the Unseen messages
        $r = q("UPDATE `item` SET `unseen` = 0 WHERE `type` != 'remote' AND `unseen` = 1 ");
    } elseif (remote_user()) {
        $gs = '<<>>';
        // should be impossible to match
        if (count($groups)) {
            foreach ($groups as $g) {
                $gs .= '|<' . intval($g) . '>';
            }
        }
        $sql_extra = sprintf(" AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) \n\t\t\t  AND ( `deny_cid`  = '' OR  NOT `deny_cid` REGEXP '<%d>' ) \n\t\t\t  AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )\n\t\t\t  AND ( `deny_gid`  = '' OR NOT `deny_gid` REGEXP '%s') ", intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']), dbesc($gs), dbesc($gs));
    }
    $r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tAND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote') \n\t\t{$sql_extra} ");
    if (count($r)) {
        $a->set_pager_total($r[0]['total']);
    }
    $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, \n\t\t`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, \n\t\t`contact`.`id` AS `cid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tAND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote') \n\t\t{$sql_extra}\n\t\tORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", intval($a->pager['start']), intval($a->pager['itemspage']));
    $cmnt_tpl = file_get_contents('view/comment_item.tpl');
    $tpl = file_get_contents('view/wall_item.tpl');
    if ($update) {
        $return_url = $_SESSION['return_url'];
    } else {
        $return_url = $_SESSION['return_url'] = $a->cmd;
    }
    if (count($r)) {
        foreach ($r as $item) {
            $comment = '';
            $template = $tpl;
            $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
            if (can_write_wall($a, 1)) {
                if ($item['last-child']) {
                    $comment = replace_macros($cmnt_tpl, array('$return_path' => $_SESSION['return_url'], '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => 1, '$mylink' => $contact['url'], '$mytitle' => t('Me'), '$myphoto' => $contact['thumb'], '$ww' => ''));
                }
            }
            $profile_url = $item['url'];
            // This is my profile but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend,
            // I can go directly to their profile as an authenticated guest.
            if (local_user() && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && !$item['self']) {
                $profile_url = $redirect_url;
            }
            // We received this post via a remote feed. It's either a wall-to-wall or a remote comment. The author is
            // known to us and is reflected in the contact-id for this item. We can use the contact url or redirect rather than
            // use the link in the feed. This is different than on the network page where we may not know the author.
            $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
            $profile_avatar = strlen($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'];
            $profile_link = $profile_url;
            $drop = '';
            if ($item['contact-id'] == $_SESSION['visitor_id'] || $_SESSION['uid']) {
                $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
//.........这里部分代码省略.........
开发者ID:vishalp,项目名称:MistparkPE-Remix,代码行数:101,代码来源:profile.php

示例13: item_post

function item_post(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    require_once 'include/security.php';
    $uid = local_user();
    if (x($_POST, 'dropitems')) {
        require_once 'include/items.php';
        $arr_drop = explode(',', $_POST['dropitems']);
        drop_items($arr_drop);
        $json = array('success' => 1);
        echo json_encode($json);
        killme();
    }
    call_hooks('post_local_start', $_POST);
    $api_source = x($_POST, 'api_source') && $_POST['api_source'] ? true : false;
    $return_path = x($_POST, 'return') ? $_POST['return'] : '';
    /**
     * Is this a reply to something?
     */
    $parent = x($_POST, 'parent') ? intval($_POST['parent']) : 0;
    $parent_uri = x($_POST, 'parent_uri') ? trim($_POST['parent_uri']) : '';
    $parent_item = null;
    $parent_contact = null;
    $thr_parent = '';
    $parid = 0;
    $r = false;
    $preview = x($_POST, 'preview') ? intval($_POST['preview']) : 0;
    if ($parent || $parent_uri) {
        if (!x($_POST, 'type')) {
            $_POST['type'] = 'net-comment';
        }
        if ($parent) {
            $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($parent));
        } elseif ($parent_uri && local_user()) {
            // This is coming from an API source, and we are logged in
            $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($parent_uri), intval(local_user()));
        }
        // if this isn't the real parent of the conversation, find it
        if ($r !== false && count($r)) {
            $parid = $r[0]['parent'];
            if ($r[0]['id'] != $r[0]['parent']) {
                $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", intval($parid));
            }
        }
        if ($r === false || !count($r)) {
            notice(t('Unable to locate original post.') . EOL);
            if (x($_POST, 'return')) {
                goaway($a->get_baseurl() . "/" . $return_path);
            }
            killme();
        }
        $parent_item = $r[0];
        $parent = $r[0]['id'];
        // multi-level threading - preserve the info but re-parent to our single level threading
        if ($parid && $parid != $parent) {
            $thr_parent = $parent_uri;
        }
        if ($parent_item['contact-id'] && $uid) {
            $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($parent_item['contact-id']), intval($uid));
            if (count($r)) {
                $parent_contact = $r[0];
            }
        }
    }
    if ($parent) {
        logger('mod_post: parent=' . $parent);
    }
    $profile_uid = x($_POST, 'profile_uid') ? intval($_POST['profile_uid']) : 0;
    $post_id = x($_POST['post_id']) ? intval($_POST['post_id']) : 0;
    $app = x($_POST['source']) ? strip_tags($_POST['source']) : '';
    if (!can_write_wall($a, $profile_uid)) {
        notice(t('Permission denied.') . EOL);
        if (x($_POST, 'return')) {
            goaway($a->get_baseurl() . "/" . $return_path);
        }
        killme();
    }
    // is this an edited post?
    $orig_post = null;
    if ($post_id) {
        $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($profile_uid), intval($post_id));
        if (!count($i)) {
            killme();
        }
        $orig_post = $i[0];
    }
    $user = null;
    $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($profile_uid));
    if (count($r)) {
        $user = $r[0];
    }
    if ($orig_post) {
        $str_group_allow = $orig_post['allow_gid'];
        $str_contact_allow = $orig_post['allow_cid'];
        $str_group_deny = $orig_post['deny_gid'];
        $str_contact_deny = $orig_post['deny_cid'];
        $title = $orig_post['title'];
        $location = $orig_post['location'];
//.........这里部分代码省略.........
开发者ID:nphyx,项目名称:friendica,代码行数:101,代码来源:item.php

示例14: photos_content


//.........这里部分代码省略.........
        // fetch image, item containing image, then comments
        $ph = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' \n\t\t\t{$sql_extra} ORDER BY `scale` ASC ", dbesc($datum));
        if (!count($ph)) {
            notice(t('Photo not available') . EOL);
            return;
        }
        if (count($ph) == 1) {
            $hires = $lores = $ph[0];
        }
        if (count($ph) > 1) {
            if ($ph[1]['scale'] == 2) {
                // original is 640 or less, we can display it directly
                $hires = $lores = $ph[0];
            } else {
                $hires = $ph[0];
                $lores = $ph[1];
            }
        }
        $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']) . '">' . $ph[0]['album'] . '</a></h3>';
        if (local_user()) {
            $o .= '<div id="photo-edit-link-wrap" ><a id="photo-edit-link" href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit' . '">' . t('Edit photo') . '</a></div>';
        }
        $o .= '<a href="' . $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg" title="' . t('View Full Size') . '" ><img src="' . $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" /></a>';
        // Do we have an item for this photo?
        $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' {$sql_extra} LIMIT 1", dbesc($datum));
        if (count($i1)) {
            $r = q("SELECT COUNT(*) AS `total`\n\t\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tWHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0\n\t\t\t\tAND NOT `item`.`type` IN ( 'remote', 'net-comment') \n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 \n\t\t\t\t{$sql_extra} ", dbesc($i1[0]['uri']), dbesc($i1[0]['uri']));
            if (count($r)) {
                $a->set_pager_total($r[0]['total']);
            }
            $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, \n\t\t\t\t`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, \n\t\t\t\t`contact`.`id` AS `cid`\n\t\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tWHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0\n\t\t\t\tAND NOT `item`.`type` IN ( 'remote', 'net-comment') \n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t{$sql_extra}\n\t\t\t\tORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", dbesc($i1[0]['uri']), dbesc($i1[0]['uri']), intval($a->pager['start']), intval($a->pager['itemspage']));
        }
        $o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
        if (count($i1) && strlen($i1[0]['tag'])) {
            // parse tags and add links
            $o .= '<div id="in-this-photo-text">' . t('In this photo: ') . '</div>';
            $o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
        }
        if ($cmd == 'edit') {
            $edit_tpl = file_get_contents('view/photo_edit.tpl');
            $o .= replace_macros($edit_tpl, array('$id' => $ph[0]['id'], '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => $ph[0]['desc'], '$tag_label' => t('Tags'), '$tags' => $i1[0]['tag'], '$item_id' => count($i1) ? $i1[0]['id'] : 0, '$submit' => t('Submit'), '$delete' => t('Delete Photo')));
        }
        if (count($i1)) {
            // pull out how many people like the photo
            $cmnt_tpl = file_get_contents('view/comment_item.tpl');
            $tpl = file_get_contents('view/photo_item.tpl');
            $return_url = $a->cmd;
            if (can_write_wall($a, $a->data['user']['uid'])) {
                if ($i1[0]['last-child']) {
                    $o .= replace_macros($cmnt_tpl, array('$return_path' => $return_url, '$type' => 'wall-comment', '$id' => $i1[0]['id'], '$parent' => $i1[0]['id'], '$profile_uid' => $a->data['user']['uid'], '$ww' => ''));
                }
            }
            // display comments
            if (count($r)) {
                foreach ($r as $item) {
                    $comment = '';
                    $template = $tpl;
                    $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
                    if (can_write_wall($a, $a->data['user']['uid'])) {
                        if ($item['last-child']) {
                            $comment = replace_macros($cmnt_tpl, array('$return_path' => $return_url, '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $a->data['user']['uid'], '$ww' => ''));
                        }
                    }
                    $profile_url = $item['url'];
                    if (local_user() && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && !$item['self']) {
                        $profile_url = $redirect_url;
                    }
                    $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
                    $profile_avatar = strlen($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'];
                    $profile_link = $profile_url;
                    $drop = '';
                    if ($item['contact-id'] == $_SESSION['visitor_id'] || local_user()) {
                        $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
                    }
                    $o .= replace_macros($template, array('$id' => $item['item_id'], '$profile_url' => $profile_link, '$name' => $profile_name, '$thumb' => $profile_avatar, '$title' => $item['title'], '$body' => bbcode($item['body']), '$ago' => relative_date($item['created']), '$indent' => $item['parent'] != $item['item_id'] ? ' comment' : '', '$drop' => $drop, '$comment' => $comment));
                }
            }
            $o .= paginate($a);
        }
        return $o;
    }
    // Default - show recent photos with upload link (if applicable)
    $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `album` != '%s' \n\t\t{$sql_extra} GROUP BY `resource-id`", dbesc(t('Contact Photos')));
    if (count($r)) {
        $a->set_pager_total(count($r));
    }
    $r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `album` != '%s' \n\t\t{$sql_extra} GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", dbesc(t('Contact Photos')), intval($a->pager['start']), intval($a->pager['itemspage']));
    $o .= '<h3>' . t('Recent Photos') . '</h3>';
    if (local_user()) {
        $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
    }
    $tpl = file_get_contents('view/photo_top.tpl');
    if (count($r)) {
        foreach ($r as $rr) {
            $o .= replace_macros($tpl, array('$id' => $rr['id'], '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], '$phototitle' => t('View Photo'), '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg', '$albumlink' => $a->get_baseurl . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), '$albumname' => $rr['album'], '$albumalt' => t('View Album'), '$imgalt' => $rr['filename']));
        }
        $o .= '<div id="photo-top-end"></div>';
    }
    return $o;
}
开发者ID:vishalp,项目名称:MistparkPE-Remix,代码行数:101,代码来源:photos.php

示例15: profile_content

function profile_content(&$a, $update = 0)
{
    $category = $datequery = $datequery2 = '';
    if ($a->argc > 2) {
        for ($x = 2; $x < $a->argc; $x++) {
            if (is_a_date_arg($a->argv[$x])) {
                if ($datequery) {
                    $datequery2 = escape_tags($a->argv[$x]);
                } else {
                    $datequery = escape_tags($a->argv[$x]);
                }
            } else {
                $category = $a->argv[$x];
            }
        }
    }
    if (!x($category)) {
        $category = x($_GET, 'category') ? $_GET['category'] : '';
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return login();
    }
    require_once "include/bbcode.php";
    require_once 'include/security.php';
    require_once 'include/conversation.php';
    require_once 'include/acl_selectors.php';
    require_once 'include/items.php';
    $groups = array();
    $tab = 'posts';
    $o = '';
    if ($update) {
        // Ensure we've got a profile owner if updating.
        $a->profile['profile_uid'] = $update;
    } else {
        if ($a->profile['profile_uid'] == local_user()) {
            nav_set_selected('home');
        }
    }
    $contact = null;
    $remote_contact = false;
    $contact_id = 0;
    if (is_array($_SESSION['remote'])) {
        foreach ($_SESSION['remote'] as $v) {
            if ($v['uid'] == $a->profile['profile_uid']) {
                $contact_id = $v['cid'];
                break;
            }
        }
    }
    if ($contact_id) {
        $groups = init_groups_visitor($contact_id);
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($a->profile['profile_uid']));
        if (count($r)) {
            $contact = $r[0];
            $remote_contact = true;
        }
    }
    if (!$remote_contact) {
        if (local_user()) {
            $contact_id = $_SESSION['cid'];
            $contact = $a->contact;
        }
    }
    $is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
    if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
        notice(t('Access to this profile has been restricted.') . EOL);
        return;
    }
    if (!$update) {
        if (x($_GET, 'tab')) {
            $tab = notags(trim($_GET['tab']));
        }
        $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
        if ($tab === 'profile') {
            $o .= advanced_profile($a);
            call_hooks('profile_advanced', $o);
            return $o;
        }
        $o .= common_friends_visitor_widget($a->profile['profile_uid']);
        if (x($_SESSION, 'new_member') && $_SESSION['new_member'] && $is_owner) {
            $o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
        }
        $commpage = $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        $commvisitor = $commpage && $remote_contact == true ? true : false;
        $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
        $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], x($category) ? xmlify($category) : '');
        if (can_write_wall($a, $a->profile['profile_uid'])) {
            $x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'] ? true : false, 'default_location' => $is_owner ? $a->user['default-location'] : '', 'nickname' => $a->profile['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($a->user, true) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid'], 'acl_data' => $is_owner ? construct_acl_data($a, $a->user) : '');
            $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
     */
    $sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
    if ($update) {
        $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND\n\t\t\t(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE . "' OR item.verb = '" . ACTIVITY_DISLIKE . "')\n\t\t\tand `item`.`moderated` = 0 and `item`.`unseen` = 1\n\t\t\tAND `item`.`wall` = 1\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `item`.`created` DESC", intval($a->profile['profile_uid']));
    } else {
        $sql_post_table = "";
        if (x($category)) {
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:profile.php


注:本文中的can_write_wall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。