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


PHP post_activity_item函数代码示例

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


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

示例1: api_channel_stream

function api_channel_stream(&$a, $type)
{
    if (api_user() === false) {
        logger('api_channel_stream: no user');
        return false;
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        json_return_and_die(post_activity_item($_REQUEST));
    } else {
        // fetch stream
    }
}
开发者ID:msooon,项目名称:hubzilla,代码行数:12,代码来源:api.php

示例2: send_profile_photo_activity

function send_profile_photo_activity($channel, $photo, $profile)
{
    // for now only create activities for the default profile
    if (!intval($profile['is_default'])) {
        return;
    }
    $arr = array();
    $arr['item_thread_top'] = 1;
    $arr['item_origin'] = 1;
    $arr['item_wall'] = 1;
    $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
    $arr['verb'] = ACTIVITY_UPDATE;
    $arr['object'] = json_encode(array('type' => $arr['obj_type'], 'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'], 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id'])));
    if (stripos($profile['gender'], t('female')) !== false) {
        $t = t('%1$s updated her %2$s');
    } elseif (stripos($profile['gender'], t('male')) !== false) {
        $t = t('%1$s updated his %2$s');
    } else {
        $t = t('%1$s updated their %2$s');
    }
    $ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('profile photo') . '[/zrl]';
    $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
    $arr['body'] = sprintf($t, $channel['channel_name'], $ptext) . "\n\n" . $ltext;
    $acl = new AccessList($channel);
    $x = $acl->get();
    $arr['allow_cid'] = $x['allow_cid'];
    $arr['allow_gid'] = $x['allow_gid'];
    $arr['deny_cid'] = $x['deny_cid'];
    $arr['deny_gid'] = $x['deny_gid'];
    $arr['uid'] = $channel['channel_id'];
    $arr['aid'] = $channel['channel_account_id'];
    $arr['owner_xchan'] = $channel['channel_hash'];
    $arr['author_xchan'] = $channel['channel_hash'];
    post_activity_item($arr);
}
开发者ID:kenrestivo,项目名称:hubzilla,代码行数:35,代码来源:profile_photo.php

示例3: thing_init


//.........这里部分代码省略.........
     * That needs to be specified in your thing. e.g. Mike has "a carrot", Greg wants "balls", Bob likes "the Boston Red Sox".  
     */
    /*
     * Future work on this module might produce more complex activities with targets, e.g. Phillip likes Karen's moustache
     * and to describe other non-thing objects like channels, such as Karl wants Susan - where Susan represents a channel profile.
     */
    if (!$name || !$translated_verb) {
        return;
    }
    $acl = new Zotlabs\Access\AccessList($channel);
    if (array_key_exists('contact_allow', $_REQUEST) || array_key_exists('group_allow', $_REQUEST) || array_key_exists('contact_deny', $_REQUEST) || array_key_exists('group_deny', $_REQUEST)) {
        $acl->set_from_array($_REQUEST);
    }
    $x = $acl->get();
    if ($term_hash) {
        $t = q("select * from obj where obj_obj = '%s' and obj_channel = %d limit 1", dbesc($term_hash), intval(local_channel()));
        if (!$t) {
            notice(t('Item not found.') . EOL);
            return;
        }
        $orig_record = $t[0];
        if ($photo != $orig_record['obj_imgurl']) {
            $arr = import_xchan_photo($photo, get_observer_hash(), true);
            $local_photo = $arr[0];
            $local_photo_type = $arr[3];
        } else {
            $local_photo = $orig_record['obj_imgurl'];
        }
        $r = q("update obj set obj_term = '%s', obj_url = '%s', obj_imgurl = '%s', obj_edited = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where obj_obj = '%s' and obj_channel = %d ", dbesc($name), dbesc($url ? $url : z_root() . '/thing/' . $term_hash), dbesc($local_photo), dbesc(datetime_convert()), dbesc($x['allow_cid']), dbesc($x['allow_gid']), dbesc($x['deny_cid']), dbesc($x['deny_gid']), dbesc($term_hash), intval(local_channel()));
        info(t('Thing updated') . EOL);
        $r = q("select * from obj where obj_channel = %d and obj_obj = '%s' limit 1", intval(local_channel()), dbesc($term_hash));
        if ($r) {
            build_sync_packet(0, array('obj' => $r));
        }
        return;
    }
    $sql = $profile_guid ? " and profile_guid = '" . dbesc($profile_guid) . "' " : " and is_default = 1 ";
    $p = q("select profile_guid, is_default from profile where uid = %d {$sql} limit 1", intval(local_channel()));
    if ($p) {
        $profile = $p[0];
    } else {
        return;
    }
    $local_photo = null;
    if ($photo) {
        $arr = import_xchan_photo($photo, get_observer_hash(), true);
        $local_photo = $arr[0];
        $local_photo_type = $arr[3];
    }
    $created = datetime_convert();
    $url = $url ? $url : z_root() . '/thing/' . $hash;
    $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj, obj_term, obj_url, obj_imgurl, obj_created, obj_edited, allow_cid, allow_gid, deny_cid, deny_gid ) values ('%s','%s', %d, %d, '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s') ", dbesc($profile['profile_guid']), dbesc($verb), intval(TERM_OBJ_THING), intval(local_channel()), dbesc($hash), dbesc($name), dbesc($url), dbesc($photo ? $local_photo : ''), dbesc($created), dbesc($created), dbesc($x['allow_cid']), dbesc($x['allow_gid']), dbesc($x['deny_cid']), dbesc($x['deny_gid']));
    if (!$r) {
        notice(t('Object store: failed'));
        return;
    }
    info(t('Thing added'));
    $r = q("select * from obj where obj_channel = %d and obj_obj = '%s' limit 1", intval(local_channel()), dbesc($hash));
    if ($r) {
        build_sync_packet(0, array('obj' => $r));
    }
    if ($activity) {
        $arr = array();
        $links = array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $url));
        if ($local_photo) {
            $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo);
        }
        $objtype = ACTIVITY_OBJ_THING;
        $obj = json_encode(array('type' => $objtype, 'id' => $url, 'link' => $links, 'title' => $name, 'content' => $name));
        $bodyverb = str_replace('OBJ: ', '', t('OBJ: %1$s %2$s %3$s'));
        $arr['owner_xchan'] = $channel['channel_hash'];
        $arr['author_xchan'] = $channel['channel_hash'];
        $arr['item_origin'] = 1;
        $arr['item_wall'] = 1;
        $arr['item_thread_top'] = 1;
        $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
        $plink = '[zrl=' . $url . ']' . $name . '[/zrl]';
        $arr['body'] = sprintf($bodyverb, $ulink, $translated_verb, $plink);
        if ($local_photo) {
            $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]";
        }
        $arr['verb'] = $verb;
        $arr['obj_type'] = $objtype;
        $arr['object'] = $obj;
        if (!$profile['is_default']) {
            $arr['item_private'] = true;
            $str = '';
            $r = q("select abook_xchan from abook where abook_channel = %d and abook_profile = '%s'", intval(local_channel()), dbesc($profile_guid));
            if ($r) {
                $arr['allow_cid'] = '';
                foreach ($r as $rr) {
                    $arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>';
                }
            } else {
                $arr['allow_cid'] = '<' . get_observer_hash() . '>';
            }
        }
        $ret = post_activity_item($arr);
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:101,代码来源:thing.php

示例4: poke_init

function poke_init(&$a)
{
    if (!local_channel()) {
        return;
    }
    $uid = local_channel();
    $channel = $a->get_channel();
    $verb = notags(trim($_REQUEST['verb']));
    if (!$verb) {
        return;
    }
    $verbs = get_poke_verbs();
    if (!array_key_exists($verb, $verbs)) {
        return;
    }
    $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
    $contact_id = intval($_REQUEST['cid']);
    if (!$contact_id) {
        return;
    }
    $parent = x($_REQUEST, 'parent') ? intval($_REQUEST['parent']) : 0;
    logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG);
    $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where abook_id = %d and abook_channel = %d LIMIT 1", intval($contact_id), intval($uid));
    if (!$r) {
        logger('poke: no target ' . $contact_id);
        return;
    }
    $target = $r[0];
    $parent_item = null;
    if ($parent) {
        $r = q("select mid, item_private, owner_xchan, allow_cid, allow_gid, deny_cid, deny_gid \n\t\t\tfrom item where id = %d and parent = %d and uid = %d limit 1", intval($parent), intval($parent), intval($uid));
        if ($r) {
            $parent_item = $r[0];
            $parent_mid = $r[0]['mid'];
            $item_private = $r[0]['item_private'];
            $allow_cid = $r[0]['allow_cid'];
            $allow_gid = $r[0]['allow_gid'];
            $deny_cid = $r[0]['deny_cid'];
            $deny_gid = $r[0]['deny_gid'];
        }
    } else {
        $item_private = x($_GET, 'private') ? intval($_GET['private']) : 0;
        $allow_cid = $item_private ? '<' . $target['abook_xchan'] . '>' : $channel['channel_allow_cid'];
        $allow_gid = $item_private ? '' : $channel['channel_allow_gid'];
        $deny_cid = $item_private ? '' : $channel['channel_deny_cid'];
        $deny_gid = $item_private ? '' : $channel['channel_deny_gid'];
    }
    $arr = array();
    $arr['item_wall'] = 1;
    $arr['owner_xchan'] = $parent_item ? $parent_item['owner_xchan'] : $channel['channel_hash'];
    $arr['parent_mid'] = $parent_mid ? $parent_mid : $mid;
    $arr['title'] = '';
    $arr['allow_cid'] = $allow_cid;
    $arr['allow_gid'] = $allow_gid;
    $arr['deny_cid'] = $deny_cid;
    $arr['deny_gid'] = $deny_gid;
    $arr['verb'] = $activity;
    $arr['item_private'] = $item_private;
    $arr['obj_type'] = ACTIVITY_OBJ_PERSON;
    $arr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t($verbs[$verb][0]) . ' ' . '[zrl=' . $target['xchan_url'] . ']' . $target['xchan_name'] . '[/zrl]';
    $obj = array('type' => ACTIVITY_OBJ_PERSON, 'title' => $target['xchan_name'], 'id' => $target['xchan_hash'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $target['xchan_url']), array('rel' => 'photo', 'type' => $target['xchan_photo_mimetype'], 'href' => $target['xchan_photo_l'])));
    $arr['object'] = json_encode($obj);
    $arr['item_origin'] = 1;
    $arr['item_wall'] = 1;
    $arr['item_unseen'] = 1;
    if (!$parent_item) {
        $item['item_thread_top'] = 1;
    }
    post_activity_item($arr);
    return;
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:71,代码来源:poke.php

示例5: tagger_content

function tagger_content(&$a)
{
    if (!local_channel() && !remote_channel()) {
        return;
    }
    $observer_hash = get_observer_hash();
    //strip html-tags
    $term = notags(trim($_GET['term']));
    //check if empty
    if (!$term) {
        return;
    }
    $item_id = argc() > 1 ? notags(trim(argv(1))) : 0;
    logger('tagger: tag ' . $term . ' item ' . $item_id);
    $r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = '%s' and uid = %d LIMIT 1", dbesc($item_id), intval(local_channel()));
    if (!$item_id || !$r) {
        logger('tagger: no item ' . $item_id);
        return;
    }
    $item = $r[0];
    $owner_uid = $item['uid'];
    switch ($item['resource_type']) {
        case 'photo':
            $targettype = ACTIVITY_OBJ_PHOTO;
            $post_type = t('photo');
            break;
        case 'event':
            $targgettype = ACTIVITY_OBJ_EVENT;
            $post_type = t('event');
            break;
        default:
            $targettype = ACTIVITY_OBJ_NOTE;
            $post_type = t('post');
            if ($item['mid'] != $item['parent_mid']) {
                $post_type = t('comment');
            }
            break;
    }
    $links = array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/display/' . $item['mid']));
    $target = json_encode(array('type' => $targettype, 'id' => $item['mid'], 'link' => $links, 'title' => $item['title'], 'content' => $item['body'], 'created' => $item['created'], 'edited' => $item['edited'], 'author' => array('name' => $item['xchan_name'], 'address' => $item['xchan_addr'], 'guid' => $item['xchan_guid'], 'guid_sig' => $item['xchan_guid_sig'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item['xchan_url']), array('rel' => 'photo', 'type' => $item['xchan_photo_mimetype'], 'href' => $item['xchan_photo_m'])))));
    $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
    $tagid = $a->get_baseurl() . '/search?tag=' . $term;
    $objtype = ACTIVITY_OBJ_TAGTERM;
    $obj = json_encode(array('type' => $objtype, 'id' => $tagid, 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $tagid)), 'title' => $term, 'content' => $term));
    $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
    // saving here for reference
    // also check out x22d5 and x2317 and x0d6b and x0db8 and x24d0 and xff20 !!!
    $termlink = html_entity_decode('&#x22d5;') . '[zrl=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']' . $term . '[/zrl]';
    $channel = $a->get_channel();
    $arr = array();
    $arr['owner_xchan'] = $item['owner_xchan'];
    $arr['author_xchan'] = $channel['channel_hash'];
    $arr['item_flags'] = ITEM_ORIGIN;
    if ($item['item_flags'] & ITEM_WALL) {
        $arr['item_flags'] |= ITEM_WALL;
    }
    $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
    $alink = '[zrl=' . $item['xchan_url'] . ']' . $item['xchan_name'] . '[/zrl]';
    $plink = '[zrl=' . $item['plink'] . ']' . $post_type . '[/zrl]';
    $arr['body'] = sprintf($bodyverb, $ulink, $alink, $plink, $termlink);
    $arr['verb'] = ACTIVITY_TAG;
    $arr['tgt_type'] = $targettype;
    $arr['target'] = $target;
    $arr['obj_type'] = $objtype;
    $arr['object'] = $obj;
    $arr['parent_mid'] = $item['mid'];
    store_item_tag($item['uid'], $item['id'], TERM_OBJ_POST, TERM_HASHTAG, $term, $tagid);
    $ret = post_activity_item($arr);
    if ($ret['success']) {
        proc_run('php', 'include/notifier.php', 'tag', $ret['activity']['id']);
    }
    killme();
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:73,代码来源:tagger.php

示例6: post


//.........这里部分代码省略.........
         $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", dbesc($channel['channel_hash']), dbesc($orig_record[0]['abook_xchan']));
         if ($z) {
             $record = $z[0]['xlink_id'];
             $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'\n\t\t\t\t\twhere xlink_id = %d", intval($rating), dbesc($rating_text), dbesc($sig), dbesc(datetime_convert()), intval($record));
         } else {
             $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ", dbesc($channel['channel_hash']), dbesc($orig_record[0]['abook_xchan']), intval($rating), dbesc($rating_text), dbesc($sig), dbesc(datetime_convert()));
             $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", dbesc($channel['channel_hash']), dbesc($orig_record[0]['abook_xchan']));
             if ($z) {
                 $record = $z[0]['xlink_id'];
             }
         }
         if ($record) {
             proc_run('php', 'include/ratenotif.php', 'rating', $record);
         }
     }
     if ($_REQUEST['pending'] && intval($orig_record[0]['abook_pending'])) {
         $new_friend = true;
         // @fixme it won't be common, but when you accept a new connection request
         // the permissions will now be that of your permissions role and ignore
         // any you may have set manually on the form. We'll probably see a bug if somebody
         // tries to set the permissions *and* approve the connection in the same
         // request. The workaround is to approve the connection, then go back and
         // adjust permissions as desired.
         $abook_my_perms = get_channel_default_perms(local_channel());
         $role = get_pconfig(local_channel(), 'system', 'permissions_role');
         if ($role) {
             $x = get_role_perms($role);
             if ($x['perms_accept']) {
                 $abook_my_perms = $x['perms_accept'];
             }
         }
     }
     $abook_pending = $new_friend ? 0 : $orig_record[0]['abook_pending'];
     $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d,\n\t\t\tabook_incl = '%s', abook_excl = '%s'\n\t\t\twhere abook_id = %d AND abook_channel = %d", dbesc($profile_id), intval($abook_my_perms), intval($closeness), intval($abook_pending), dbesc($abook_incl), dbesc($abook_excl), intval($contact_id), intval(local_channel()));
     if ($orig_record[0]['abook_profile'] != $profile_id) {
         //Update profile photo permissions
         logger('A new profile was assigned - updating profile photos');
         profile_photo_set_profile_perms($profile_id);
     }
     if ($r) {
         info(t('Connection updated.') . EOL);
     } else {
         notice(t('Failed to update connection record.') . EOL);
     }
     if (\App::$poi && \App::$poi['abook_my_perms'] != $abook_my_perms && !intval(\App::$poi['abook_self'])) {
         proc_run('php', 'include/notifier.php', $new_friend ? 'permission_create' : 'permission_update', $contact_id);
     }
     if ($new_friend) {
         $default_group = $channel['channel_default_group'];
         if ($default_group) {
             require_once 'include/group.php';
             $g = group_rec_byhash(local_channel(), $default_group);
             if ($g) {
                 group_add_member(local_channel(), '', \App::$poi['abook_xchan'], $g['id']);
             }
         }
         // Check if settings permit ("post new friend activity" is allowed, and
         // friends in general or this friend in particular aren't hidden)
         // and send out a new friend activity
         $pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0", intval($channel['channel_id']));
         if ($pr && !intval($orig_record[0]['abook_hidden']) && intval(get_pconfig($channel['channel_id'], 'system', 'post_newfriend'))) {
             $xarr = array();
             $xarr['verb'] = ACTIVITY_FRIEND;
             $xarr['item_wall'] = 1;
             $xarr['item_origin'] = 1;
             $xarr['item_thread_top'] = 1;
             $xarr['owner_xchan'] = $xarr['author_xchan'] = $channel['channel_hash'];
             $xarr['allow_cid'] = $channel['channel_allow_cid'];
             $xarr['allow_gid'] = $channel['channel_allow_gid'];
             $xarr['deny_cid'] = $channel['channel_deny_cid'];
             $xarr['deny_gid'] = $channel['channel_deny_gid'];
             $xarr['item_private'] = $xarr['allow_cid'] || $xarr['allow_gid'] || $xarr['deny_cid'] || $xarr['deny_gid'] ? 1 : 0;
             $obj = array('type' => ACTIVITY_OBJ_PERSON, 'title' => \App::$poi['xchan_name'], 'id' => \App::$poi['xchan_hash'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => \App::$poi['xchan_url']), array('rel' => 'photo', 'type' => \App::$poi['xchan_photo_mimetype'], 'href' => \App::$poi['xchan_photo_l'])));
             $xarr['object'] = json_encode($obj);
             $xarr['obj_type'] = ACTIVITY_OBJ_PERSON;
             $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . \App::$poi['xchan_url'] . ']' . \App::$poi['xchan_name'] . '[/zrl]';
             $xarr['body'] .= "\n\n\n" . '[zrl=' . \App::$poi['xchan_url'] . '][zmg=80x80]' . \App::$poi['xchan_photo_m'] . '[/zmg][/zrl]';
             post_activity_item($xarr);
         }
         // pull in a bit of content if there is any to pull in
         proc_run('php', 'include/onepoll.php', $contact_id);
     }
     // Refresh the structure in memory with the new data
     $r = q("SELECT abook.*, xchan.*\n\t\t\tFROM abook left join xchan on abook_xchan = xchan_hash\n\t\t\tWHERE abook_channel = %d and abook_id = %d LIMIT 1", intval(local_channel()), intval($contact_id));
     if ($r) {
         \App::$poi = $r[0];
     }
     if ($new_friend) {
         $arr = array('channel_id' => local_channel(), 'abook' => \App::$poi);
         call_hooks('accept_follow', $arr);
     }
     if (!is_null($autoperms)) {
         set_pconfig(local_channel(), 'system', 'autoperms', $autoperms ? $abook_my_perms : 0);
     }
     $this->connedit_clone($a);
     if ($_REQUEST['pending'] && !$_REQUEST['done']) {
         goaway(z_root() . '/connections/ifpending');
     }
     return;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:101,代码来源:Connedit.php

示例7: send_cover_photo_activity

 function send_cover_photo_activity($channel, $photo, $profile)
 {
     $arr = array();
     $arr['item_thread_top'] = 1;
     $arr['item_origin'] = 1;
     $arr['item_wall'] = 1;
     $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
     $arr['verb'] = ACTIVITY_UPDATE;
     $arr['obj'] = json_encode(array('type' => $arr['obj_type'], 'id' => z_root() . '/photo/' . $photo['resource_id'] . '-7', 'link' => array('rel' => 'photo', 'type' => $photo['mimetype'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7')));
     if ($profile && stripos($profile['gender'], t('female')) !== false) {
         $t = t('%1$s updated her %2$s');
     } elseif ($profile && stripos($profile['gender'], t('male')) !== false) {
         $t = t('%1$s updated his %2$s');
     } else {
         $t = t('%1$s updated their %2$s');
     }
     $ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('cover photo') . '[/zrl]';
     $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-8[/zmg][/zrl]';
     $arr['body'] = sprintf($t, $channel['channel_name'], $ptext) . "\n\n" . $ltext;
     $acl = new \Zotlabs\Access\AccessList($channel);
     $x = $acl->get();
     $arr['allow_cid'] = $x['allow_cid'];
     $arr['allow_gid'] = $x['allow_gid'];
     $arr['deny_cid'] = $x['deny_cid'];
     $arr['deny_gid'] = $x['deny_gid'];
     $arr['uid'] = $channel['channel_id'];
     $arr['aid'] = $channel['channel_account_id'];
     $arr['owner_xchan'] = $channel['channel_hash'];
     $arr['author_xchan'] = $channel['channel_hash'];
     post_activity_item($arr);
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:31,代码来源:Cover_photo.php

示例8: connedit_post

function connedit_post(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = intval(argv(1));
    if (!$contact_id) {
        return;
    }
    $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($contact_id), intval(local_user()));
    if (!$orig_record) {
        notice(t('Could not access contact record.') . EOL);
        goaway($a->get_baseurl(true) . '/connections');
        return;
        // NOTREACHED
    }
    call_hooks('contact_edit_post', $_POST);
    $profile_id = $_POST['profile_assign'];
    if ($profile_id) {
        $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1", dbesc($profile_id), intval(local_user()));
        if (!count($r)) {
            notice(t('Could not locate selected profile.') . EOL);
            return;
        }
    }
    $hidden = intval($_POST['hidden']);
    $priority = intval($_POST['poll']);
    if ($priority > 5 || $priority < 0) {
        $priority = 0;
    }
    $closeness = intval($_POST['closeness']);
    if ($closeness < 0) {
        $closeness = 99;
    }
    $abook_my_perms = 0;
    foreach ($_POST as $k => $v) {
        if (strpos($k, 'perms_') === 0) {
            $abook_my_perms += $v;
        }
    }
    $abook_flags = $orig_record[0]['abook_flags'];
    $new_friend = false;
    if ($_REQUEST['pending'] && $abook_flags & ABOOK_FLAG_PENDING) {
        $abook_flags = $abook_flags ^ ABOOK_FLAG_PENDING;
        $new_friend = true;
    }
    $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d\n\t\twhere abook_id = %d AND abook_channel = %d LIMIT 1", dbesc($profile_id), intval($abook_my_perms), intval($closeness), intval($abook_flags), intval($contact_id), intval(local_user()));
    if ($orig_record[0]['abook_profile'] != $profile_id) {
        //Update profile photo permissions
        logger('As a new profile was assigned updating profile photos');
        require_once 'mod/profile_photo.php';
        profile_photo_set_profile_perms($profile_id);
    }
    if ($r) {
        info(t('Connection updated.') . EOL);
    } else {
        notice(t('Failed to update connection record.') . EOL);
    }
    if ($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms && !($a->poi['abook_flags'] & ABOOK_FLAG_SELF)) {
        proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
    }
    if ($new_friend) {
        $channel = $a->get_channel();
        $default_group = $channel['channel_default_group'];
        if ($default_group) {
            require_once 'include/group.php';
            $g = group_rec_byhash(local_user(), $default_group);
            if ($g) {
                group_add_member(local_user(), '', $a->poi['abook_xchan'], $g['id']);
            }
        }
        // Check if settings permit ("post new friend activity" is allowed, and
        // friends in general or this friend in particular aren't hidden)
        // and send out a new friend activity
        $pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0", intval($channel['channel_id']));
        if ($pr && !($abook_flags & ABOOK_FLAG_HIDDEN) && intval(get_pconfig($channel['channel_id'], 'system', 'post_newfriend'))) {
            $xarr = array();
            $xarr['verb'] = ACTIVITY_FRIEND;
            $xarr['item_flags'] = ITEM_WALL | ITEM_ORIGIN | ITEM_THREAD_TOP;
            $xarr['owner_xchan'] = $xarr['author_xchan'] = $channel['channel_hash'];
            $xarr['allow_cid'] = $channel['channel_allow_cid'];
            $xarr['allow_gid'] = $channel['channel_allow_gid'];
            $xarr['deny_cid'] = $channel['channel_deny_cid'];
            $xarr['deny_gid'] = $channel['channel_deny_gid'];
            $xarr['item_private'] = $xarr['allow_cid'] || $xarr['allow_gid'] || $xarr['deny_cid'] || $xarr['deny_gid'] ? 1 : 0;
            $obj = array('type' => ACTIVITY_OBJ_PERSON, 'title' => $a->poi['xchan_name'], 'id' => $a->poi['xchan_hash'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $a->poi['xchan_url']), array('rel' => 'photo', 'type' => $a->poi['xchan_photo_mimetype'], 'href' => $a->poi['xchan_photo_l'])));
            $xarr['object'] = json_encode($obj);
            $xarr['obj_type'] = ACTIVITY_OBJ_PERSON;
            $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . $a->poi['xchan_url'] . ']' . $a->poi['xchan_name'] . '[/zrl]';
            $xarr['body'] .= "\n\n\n" . '[zrl=' . $a->poi['xchan_url'] . '][zmg=80x80]' . $a->poi['xchan_photo_m'] . '[/zmg][/zrl]';
            post_activity_item($xarr);
        }
        // pull in a bit of content if there is any to pull in
        proc_run('php', 'include/onepoll.php', $contact_id);
    }
    // Refresh the structure in memory with the new data
    $r = q("SELECT abook.*, xchan.* \n\t\tFROM abook left join xchan on abook_xchan = xchan_hash\n\t\tWHERE abook_channel = %d and abook_id = %d LIMIT 1", intval(local_user()), intval($contact_id));
    if ($r) {
        $a->poi = $r[0];
    }
//.........这里部分代码省略.........
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:connedit.php


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