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


PHP item_message_id函数代码示例

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


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

示例1: get

 function get()
 {
     if (!local_channel()) {
         return;
     }
     $postid = $_REQUEST['postid'];
     if (!$postid) {
         return;
     }
     $emoji = $_REQUEST['emoji'];
     if ($_REQUEST['emoji']) {
         $i = q("select * from item where id = %d and uid = %d", intval($postid), intval(local_channel()));
         if (!$i) {
             return;
         }
         $channel = \App::get_channel();
         $n = array();
         $n['aid'] = $channel['channel_account_id'];
         $n['uid'] = $channel['channel_id'];
         $n['item_origin'] = true;
         $n['parent'] = $postid;
         $n['parent_mid'] = $i[0]['mid'];
         $n['mid'] = item_message_id();
         $n['verb'] = ACTIVITY_REACT . '#' . $emoji;
         $n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n";
         $n['author_xchan'] = $channel['channel_hash'];
         $x = item_store($n);
         if ($x['success']) {
             $nid = $x['item_id'];
             \Zotlabs\Daemon\Master::Summon(array('Notifier', 'like', $nid));
         }
     }
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:33,代码来源:React.php

示例2: post_activity_item

/**
 * @brief Post an activity.
 *
 * In its simplest form one needs only to set $arr['body'] to post a note to the logged in channel's wall.
 * Much more complex activities can be created. Permissions are checked. No filtering, tag expansion
 * or other processing is performed.
 *
 * @param array $arr
 * @returns array
 *  * \e boolean \b success true or false
 *  * \e array \b activity the resulting activity if successful
 */
function post_activity_item($arr)
{
    $ret = array('success' => false);
    $is_comment = false;
    if ($arr['parent'] && $arr['parent'] != $arr['id'] || $arr['parent_mid'] && $arr['parent_mid'] != $arr['mid']) {
        $is_comment = true;
    }
    if (!array_key_exists('item_origin', $arr)) {
        $arr['item_origin'] = 1;
    }
    if (!array_key_exists('item_wall', $arr) && !$is_comment) {
        $arr['item_wall'] = 1;
    }
    if (!array_key_exists('item_thread_top', $arr) && !$is_comment) {
        $arr['item_thread_top'] = 1;
    }
    $channel = App::get_channel();
    $observer = App::get_observer();
    $arr['aid'] = x($arr, 'aid') ? $arr['aid'] : $channel['channel_account_id'];
    $arr['uid'] = x($arr, 'uid') ? $arr['uid'] : $channel['channel_id'];
    if (!perm_is_allowed($arr['uid'], $observer['xchan_hash'], $is_comment ? 'post_comments' : 'post_wall')) {
        $ret['message'] = t('Permission denied');
        return $ret;
    }
    $arr['public_policy'] = x($_REQUEST, 'public_policy') ? escape_tags($_REQUEST['public_policy']) : map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'], 'view_stream'), true);
    if ($arr['public_policy']) {
        $arr['item_private'] = 1;
    }
    if (!array_key_exists('mimetype', $arr)) {
        $arr['mimetype'] = 'text/bbcode';
    }
    if (array_key_exists('item_private', $arr) && $arr['item_private']) {
        $arr['body'] = trim(z_input_filter($arr['uid'], $arr['body'], $arr['mimetype']));
        if ($channel) {
            if ($channel['channel_hash'] === $arr['author_xchan']) {
                $arr['sig'] = base64url_encode(rsa_sign($arr['body'], $channel['channel_prvkey']));
                $arr['item_verified'] = 1;
            }
        }
    }
    $arr['mid'] = x($arr, 'mid') ? $arr['mid'] : item_message_id();
    $arr['parent_mid'] = x($arr, 'parent_mid') ? $arr['parent_mid'] : $arr['mid'];
    $arr['thr_parent'] = x($arr, 'thr_parent') ? $arr['thr_parent'] : $arr['mid'];
    $arr['owner_xchan'] = x($arr, 'owner_xchan') ? $arr['owner_xchan'] : $channel['channel_hash'];
    $arr['author_xchan'] = x($arr, 'author_xchan') ? $arr['author_xchan'] : $observer['xchan_hash'];
    $arr['verb'] = x($arr, 'verb') ? $arr['verb'] : ACTIVITY_POST;
    $arr['obj_type'] = x($arr, 'obj_type') ? $arr['obj_type'] : ACTIVITY_OBJ_NOTE;
    if ($is_comment && $arr['obj_type'] === ACTIVITY_OBJ_NOTE) {
        $arr['obj_type'] = ACTIVITY_OBJ_COMMENT;
    }
    $arr['allow_cid'] = x($arr, 'allow_cid') ? $arr['allow_cid'] : $channel['channel_allow_cid'];
    $arr['allow_gid'] = x($arr, 'allow_gid') ? $arr['allow_gid'] : $channel['channel_allow_gid'];
    $arr['deny_cid'] = x($arr, 'deny_cid') ? $arr['deny_cid'] : $channel['channel_deny_cid'];
    $arr['deny_gid'] = x($arr, 'deny_gid') ? $arr['deny_gid'] : $channel['channel_deny_gid'];
    $arr['comment_policy'] = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'], 'post_comments'));
    if (!$arr['plink'] && intval($arr['item_thread_top'])) {
        $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    }
    // for the benefit of plugins, we will behave as if this is an API call rather than a normal online post
    $_REQUEST['api_source'] = 1;
    call_hooks('post_local', $arr);
    if (x($arr, 'cancel')) {
        logger('post_activity_item: post cancelled by plugin.');
        return $ret;
    }
    $post = item_store($arr);
    if ($post['success']) {
        $post_id = $post['item_id'];
    }
    if ($post_id) {
        $arr['id'] = $post_id;
        call_hooks('post_local_end', $arr);
        Zotlabs\Daemon\Master::Summon(array('Notifier', 'activity', $post_id));
        $ret['success'] = true;
        $ret['activity'] = $post['item'];
    }
    return $ret;
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:90,代码来源:items.php

示例3: get

 function get()
 {
     if (!local_channel() && !remote_channel()) {
         return;
     }
     $item_id = argc() > 2 ? notags(trim(argv(2))) : 0;
     if (argv(1) === 'sub') {
         $activity = ACTIVITY_FOLLOW;
     } elseif (argv(1) === 'unsub') {
         $activity = ACTIVITY_UNFOLLOW;
     }
     $r = q("SELECT parent FROM item WHERE id = '%s'", dbesc($item_id));
     if ($r) {
         $r = q("select * from item where id = parent and id = %d limit 1", dbesc($r[0]['parent']));
     }
     if (!$item_id || !$r) {
         logger('subthread: no item ' . $item_id);
         return;
     }
     $item = $r[0];
     $owner_uid = $item['uid'];
     $observer = \App::get_observer();
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     if (!perm_is_allowed($owner_uid, $ob_hash, 'post_comments')) {
         return;
     }
     $sys = get_sys_channel();
     $owner_uid = $item['uid'];
     $owner_aid = $item['aid'];
     // if this is a "discover" item, (item['uid'] is the sys channel),
     // fallback to the item comment policy, which should've been
     // respected when generating the conversation thread.
     // Even if the activity is rejected by the item owner, it should still get attached
     // to the local discover conversation on this site.
     if ($owner_uid != $sys['channel_id'] && !perm_is_allowed($owner_uid, $observer['xchan_hash'], 'post_comments')) {
         notice(t('Permission denied') . EOL);
         killme();
     }
     $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['owner_xchan']));
     if ($r) {
         $thread_owner = $r[0];
     } else {
         killme();
     }
     $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']));
     if ($r) {
         $item_author = $r[0];
     } else {
         killme();
     }
     $mid = item_message_id();
     $post_type = $item['resource_type'] === 'photo' ? t('photo') : t('status');
     $links = array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item['plink']));
     $objtype = $item['resource_type'] === 'photo' ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE;
     $body = $item['body'];
     $obj = json_encode(array('type' => $objtype, 'id' => $item['mid'], 'parent' => $item['thr_parent'] ? $item['thr_parent'] : $item['parent_mid'], 'link' => $links, 'title' => $item['title'], 'content' => $item['body'], 'created' => $item['created'], 'edited' => $item['edited'], 'author' => array('name' => $item_author['xchan_name'], 'address' => $item_author['xchan_addr'], 'guid' => $item_author['xchan_guid'], 'guid_sig' => $item_author['xchan_guid_sig'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item_author['xchan_url']), array('rel' => 'photo', 'type' => $item_author['xchan_photo_mimetype'], 'href' => $item_author['xchan_photo_m'])))));
     if (!intval($item['item_thread_top'])) {
         $post_type = 'comment';
     }
     if ($activity === ACTIVITY_FOLLOW) {
         $bodyverb = t('%1$s is following %2$s\'s %3$s');
     }
     if ($activity === ACTIVITY_UNFOLLOW) {
         $bodyverb = t('%1$s stopped following %2$s\'s %3$s');
     }
     $arr = array();
     $arr['mid'] = $mid;
     $arr['aid'] = $owner_aid;
     $arr['uid'] = $owner_uid;
     $arr['parent'] = $item['id'];
     $arr['parent_mid'] = $item['mid'];
     $arr['thr_parent'] = $item['mid'];
     $arr['owner_xchan'] = $thread_owner['xchan_hash'];
     $arr['author_xchan'] = $observer['xchan_hash'];
     $arr['item_origin'] = 1;
     $arr['item_notshown'] = 1;
     if (intval($item['item_wall'])) {
         $arr['item_wall'] = 1;
     } else {
         $arr['item_wall'] = 0;
     }
     $ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]';
     $alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]';
     $plink = '[zrl=' . z_root() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
     $arr['body'] = sprintf($bodyverb, $alink, $ulink, $plink);
     $arr['verb'] = $activity;
     $arr['obj_type'] = $objtype;
     $arr['object'] = $obj;
     $arr['allow_cid'] = $item['allow_cid'];
     $arr['allow_gid'] = $item['allow_gid'];
     $arr['deny_cid'] = $item['deny_cid'];
     $arr['deny_gid'] = $item['deny_gid'];
     $post = item_store($arr);
     $post_id = $post['item_id'];
     $arr['id'] = $post_id;
     call_hooks('post_local_end', $arr);
     killme();
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:98,代码来源:Subthread.php

示例4: post


//.........这里部分代码省略.........
             $post_tags[] = array('uid' => $profile_uid, 'ttype' => TERM_CATEGORY, 'otype' => TERM_OBJ_POST, 'term' => trim($cat), 'url' => $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)));
         }
     }
     if ($orig_post) {
         // preserve original tags
         $t = q("select * from term where oid = %d and otype = %d and uid = %d and ttype in ( %d, %d, %d )", intval($orig_post['id']), intval(TERM_OBJ_POST), intval($profile_uid), intval(TERM_UNKNOWN), intval(TERM_FILE), intval(TERM_COMMUNITYTAG));
         if ($t) {
             foreach ($t as $t1) {
                 $post_tags[] = array('uid' => $profile_uid, 'ttype' => $t1['type'], 'otype' => TERM_OBJ_POST, 'term' => $t1['term'], 'url' => $t1['url']);
             }
         }
     }
     $item_unseen = local_channel() != $profile_uid ? 1 : 0;
     $item_wall = $post_type === 'wall' || $post_type === 'wall-comment' ? 1 : 0;
     $item_origin = $origin ? 1 : 0;
     $item_consensus = $consensus ? 1 : 0;
     $item_nocomment = $nocomment ? 1 : 0;
     // determine if this is a wall post
     if ($parent) {
         $item_wall = $parent_item['item_wall'];
     } else {
         if (!$webpage) {
             $item_wall = 1;
         }
     }
     if ($moderated) {
         $item_blocked = ITEM_MODERATED;
     }
     if (!strlen($verb)) {
         $verb = ACTIVITY_POST;
     }
     $notify_type = $parent ? 'comment-new' : 'wall-new';
     if (!$mid) {
         $mid = $message_id ? $message_id : item_message_id();
     }
     if (!$parent_mid) {
         $parent_mid = $mid;
     }
     if ($parent_item) {
         $parent_mid = $parent_item['mid'];
     }
     // Fallback so that we alway have a thr_parent
     if (!$thr_parent) {
         $thr_parent = $mid;
     }
     $datarray = array();
     $item_thread_top = !$parent ? 1 : 0;
     if (!$plink && $item_thread_top) {
         $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
     }
     $datarray['aid'] = $channel['channel_account_id'];
     $datarray['uid'] = $profile_uid;
     $datarray['owner_xchan'] = $owner_hash ? $owner_hash : $owner_xchan['xchan_hash'];
     $datarray['author_xchan'] = $observer['xchan_hash'];
     $datarray['created'] = $created;
     $datarray['edited'] = $orig_post ? datetime_convert() : $created;
     $datarray['expires'] = $expires;
     $datarray['commented'] = $orig_post ? datetime_convert() : $created;
     $datarray['received'] = $orig_post ? datetime_convert() : $created;
     $datarray['changed'] = $orig_post ? datetime_convert() : $created;
     $datarray['mid'] = $mid;
     $datarray['parent_mid'] = $parent_mid;
     $datarray['mimetype'] = $mimetype;
     $datarray['title'] = $title;
     $datarray['body'] = $body;
     $datarray['app'] = $app;
开发者ID:phellmes,项目名称:hubzilla,代码行数:67,代码来源:Item.php

示例5: randpost_fetch

function randpost_fetch(&$a, &$b)
{
    $fort_server = get_config('fortunate', 'server');
    if (!$fort_server) {
        return;
    }
    $r = q("select * from pconfig where cat = 'randpost' and k = 'enable'");
    if ($r) {
        foreach ($r as $rr) {
            if (!$rr['v']) {
                continue;
            }
            //			logger('randpost');
            // cronhooks run every 10-15 minutes typically
            // try to keep from posting frequently.
            $test = mt_rand(0, 100);
            if ($test == 25) {
                $c = q("select * from channel where channel_id = %d limit 1", intval($rr['uid']));
                if (!$c) {
                    continue;
                }
                $mention = '';
                require_once 'include/html2bbcode.php';
                $s = z_fetch_url('http://' . $fort_server . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
                if (!$s['success']) {
                    continue;
                }
                $x = array();
                $x['uid'] = $c[0]['channel_id'];
                $x['aid'] = $c[0]['channel_account_id'];
                $x['mid'] = $x['parent_mid'] = item_message_id();
                $x['author_xchan'] = $x['owner_xchan'] = $c[0]['channel_hash'];
                $x['item_thread_top'] = 1;
                $x['item_origin'] = 1;
                $x['item_verified'] = 1;
                $x['item_wall'] = 1;
                // if it might be a quote make it a quote
                if (strpos($s['body'], '--')) {
                    $x['body'] = $mention . '[quote]' . html2bbcode($s['body']) . '[/quote]';
                } else {
                    $x['body'] = $mention . html2bbcode($s['body']);
                }
                $x['sig'] = base64url_encode(rsa_sign($x['body'], $c[0]['channel_prvkey']));
                $post = item_store($x);
                $post_id = $post['item_id'];
                $x['id'] = $post_id;
                call_hooks('post_local_end', $x);
                Zotlabs\Daemon\Master::Summon(array('Notifier', 'wall-new', $post_id));
            }
        }
    }
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:52,代码来源:randpost.php

示例6: post_activity_item

/**
 * @brief Post an activity.
 *
 * In its simplest form one needs only to set $arr['body'] to post a note to the logged in channel's wall.
 * Much more complex activities can be created. Permissions are checked. No filtering, tag expansion
 * or other processing is performed.
 *
 * @param array $arr
 * @returns array
 *  * \e boolean \b success true or false
 *  * \e array \b activity the resulting activity if successful
 */
function post_activity_item($arr)
{
    $ret = array('success' => false);
    $is_comment = false;
    if ($arr['parent'] && $arr['parent'] != $arr['id'] || $arr['parent_mid'] && $arr['parent_mid'] != $arr['mid']) {
        $is_comment = true;
    }
    if (!x($arr, 'item_flags')) {
        if ($is_comment) {
            $arr['item_flags'] = ITEM_ORIGIN;
        } else {
            $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP;
        }
    }
    $channel = get_app()->get_channel();
    $observer = get_app()->get_observer();
    $arr['aid'] = x($arr, 'aid') ? $arr['aid'] : $channel['channel_account_id'];
    $arr['uid'] = x($arr, 'uid') ? $arr['uid'] : $channel['channel_id'];
    if (!perm_is_allowed($arr['uid'], $observer['xchan_hash'], $is_comment ? 'post_comments' : 'post_wall')) {
        $ret['message'] = t('Permission denied');
        return $ret;
    }
    $arr['public_policy'] = x($_REQUEST, 'public_policy') ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'], true);
    if ($arr['public_policy']) {
        $arr['item_private'] = 1;
    }
    if (!array_key_exists('mimetype', $arr)) {
        $arr['mimetype'] = 'text/bbcode';
    }
    if (array_key_exists('item_private', $arr) && $arr['item_private']) {
        $arr['body'] = trim(z_input_filter($arr['uid'], $arr['body'], $arr['mimetype']));
        if ($channel) {
            if ($channel['channel_hash'] === $arr['author_xchan']) {
                $arr['sig'] = base64url_encode(rsa_sign($arr['body'], $channel['channel_prvkey']));
                $arr['item_flags'] = $arr['item_flags'] | ITEM_VERIFIED;
            }
        }
        logger('Encrypting local storage');
        $key = get_config('system', 'pubkey');
        $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
        if ($arr['title']) {
            $arr['title'] = json_encode(crypto_encapsulate($arr['title'], $key));
        }
        if ($arr['body']) {
            $arr['body'] = json_encode(crypto_encapsulate($arr['body'], $key));
        }
    }
    $arr['mid'] = x($arr, 'mid') ? $arr['mid'] : item_message_id();
    $arr['parent_mid'] = x($arr, 'parent_mid') ? $arr['parent_mid'] : $arr['mid'];
    $arr['thr_parent'] = x($arr, 'thr_parent') ? $arr['thr_parent'] : $arr['mid'];
    $arr['owner_xchan'] = x($arr, 'owner_xchan') ? $arr['owner_xchan'] : $channel['channel_hash'];
    $arr['author_xchan'] = x($arr, 'author_xchan') ? $arr['author_xchan'] : $observer['xchan_hash'];
    $arr['verb'] = x($arr, 'verb') ? $arr['verb'] : ACTIVITY_POST;
    $arr['obj_type'] = x($arr, 'obj_type') ? $arr['obj_type'] : ACTIVITY_OBJ_NOTE;
    if ($is_comment && $arr['obj_type'] === ACTIVITY_OBJ_NOTE) {
        $arr['obj_type'] = ACTIVITY_OBJ_COMMENT;
    }
    $arr['allow_cid'] = x($arr, 'allow_cid') ? $arr['allow_cid'] : $channel['channel_allow_cid'];
    $arr['allow_gid'] = x($arr, 'allow_gid') ? $arr['allow_gid'] : $channel['channel_allow_gid'];
    $arr['deny_cid'] = x($arr, 'deny_cid') ? $arr['deny_cid'] : $channel['channel_deny_cid'];
    $arr['deny_gid'] = x($arr, 'deny_gid') ? $arr['deny_gid'] : $channel['channel_deny_gid'];
    $arr['comment_policy'] = map_scope($channel['channel_w_comment']);
    if (!$arr['plink'] && $arr['item_flags'] & ITEM_THREAD_TOP) {
        $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    }
    // for the benefit of plugins, we will behave as if this is an API call rather than a normal online post
    $_REQUEST['api_source'] = 1;
    call_hooks('post_local', $arr);
    if (x($arr, 'cancel')) {
        logger('post_activity_item: post cancelled by plugin.');
        return $ret;
    }
    $post = item_store($arr);
    if ($post['success']) {
        $post_id = $post['item_id'];
    }
    if ($post_id) {
        $arr['id'] = $post_id;
        call_hooks('post_local_end', $arr);
        proc_run('php', 'include/notifier.php', 'activity', $post_id);
        $ret['success'] = true;
        $r = q("select * from item where id = %d limit 1", intval($post_id));
        if ($r) {
            $ret['activity'] = $r[0];
        }
    }
    return $ret;
}
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:100,代码来源:items.php

示例7: file_activity

/**
 * @brief Activity for files.
 *
 * @param int $channel_id
 * @param array $object
 * @param string $allow_cid
 * @param string $allow_gid
 * @param string $deny_cid
 * @param string $deny_gid
 * @param string $verb
 * @param boolean $no_activity
 */
function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify)
{
    require_once 'include/items.php';
    $poster = get_app()->get_observer();
    //if we got no object something went wrong
    if (!$object) {
        return;
    }
    //turn strings into arrays
    $arr_allow_cid = expand_acl($allow_cid);
    $arr_allow_gid = expand_acl($allow_gid);
    $arr_deny_cid = expand_acl($deny_cid);
    $arr_deny_gid = expand_acl($deny_gid);
    //filter out receivers which do not have permission to view filestorage
    $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage');
    $is_dir = intval($object['is_dir']) ? true : false;
    //do not send activity for folders for now
    if ($is_dir) {
        return;
    }
    //check for recursive perms if we are in a folder
    if ($object['folder']) {
        $folder_hash = $object['folder'];
        $r_perms = recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash);
        //split up returned perms
        $arr_allow_cid = $r_perms['allow_cid'];
        $arr_allow_gid = $r_perms['allow_gid'];
        $arr_deny_cid = $r_perms['deny_cid'];
        $arr_deny_gid = $r_perms['deny_gid'];
        //filter out receivers which do not have permission to view filestorage
        $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage');
    }
    $mid = item_message_id();
    $arr = array();
    $arr['item_wall'] = 1;
    $arr['item_origin'] = 1;
    $arr['item_unseen'] = 1;
    $objtype = ACTIVITY_OBJ_FILE;
    $private = $arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0] ? 1 : 0;
    $jsonobject = json_encode($object);
    //check if item for this object exists
    $y = q("SELECT mid FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1", dbesc(ACTIVITY_POST), dbesc($objtype), dbesc($object['hash']), intval(local_channel()));
    if ($y) {
        $update = true;
        $object['d_mid'] = $y[0]['mid'];
        //attach mid of the old object
        $u_jsonobject = json_encode($object);
        //we have got the relevant info - delete the old item before we create the new one
        $z = q("DELETE FROM item WHERE obj_type = '%s' AND verb = '%s' AND mid = '%s'", dbesc(ACTIVITY_OBJ_FILE), dbesc(ACTIVITY_POST), dbesc($y[0]['mid']));
    }
    if ($update && $verb == 'post') {
        //send update activity and create a new one
        //updates should be sent to everybody with recursive perms and all eventual former allowed members ($object['allow_cid'] etc.).
        $u_arr_allow_cid = array_unique(array_merge($arr_allow_cid, expand_acl($object['allow_cid'])));
        $u_arr_allow_gid = array_unique(array_merge($arr_allow_gid, expand_acl($object['allow_gid'])));
        $u_arr_deny_cid = array_unique(array_merge($arr_deny_cid, expand_acl($object['deny_cid'])));
        $u_arr_deny_gid = array_unique(array_merge($arr_deny_gid, expand_acl($object['deny_gid'])));
        $u_mid = item_message_id();
        $arr['aid'] = get_account_id();
        $arr['uid'] = $channel_id;
        $arr['mid'] = $u_mid;
        $arr['parent_mid'] = $u_mid;
        $arr['author_xchan'] = $poster['xchan_hash'];
        $arr['owner_xchan'] = $poster['xchan_hash'];
        $arr['title'] = '';
        //updates should be visible to everybody -> perms may have changed
        $arr['allow_cid'] = '';
        $arr['allow_gid'] = '';
        $arr['deny_cid'] = '';
        $arr['deny_gid'] = '';
        $arr['item_hidden'] = 1;
        $arr['item_private'] = 0;
        $arr['verb'] = ACTIVITY_UPDATE;
        $arr['obj_type'] = $objtype;
        $arr['object'] = $u_jsonobject;
        $arr['resource_id'] = $object['hash'];
        $arr['resource_type'] = 'attach';
        $arr['body'] = '';
        $post = item_store($arr);
        $item_id = $post['item_id'];
        if ($item_id) {
            proc_run('php', "include/notifier.php", "activity", $item_id);
        }
        call_hooks('post_local_end', $arr);
        $update = false;
        //notice( t('File activity updated') . EOL);
    }
    if (!$notify) {
//.........这里部分代码省略.........
开发者ID:spthaolt,项目名称:hubzilla,代码行数:101,代码来源:attach.php

示例8: store_doc_file

function store_doc_file($s)
{
    if (is_dir($s)) {
        return;
    }
    $item = array();
    $sys = get_sys_channel();
    $item['aid'] = 0;
    $item['uid'] = $sys['channel_id'];
    if (strpos($s, '.md')) {
        $mimetype = 'text/markdown';
    } elseif (strpos($s, '.html')) {
        $mimetype = 'text/html';
    } else {
        $mimetype = 'text/bbcode';
    }
    require_once 'include/html2plain.php';
    $item['body'] = html2plain(prepare_text(file_get_contents($s), $mimetype, true));
    $item['mimetype'] = 'text/plain';
    $item['plink'] = z_root() . '/' . str_replace('doc', 'help', $s);
    $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
    $item['item_type'] = ITEM_TYPE_DOC;
    $r = q("select item.* from item left join iconfig on item.id = iconfig.iid \n\t\twhere iconfig.cat = 'system' and iconfig.k = 'docfile' and\n\t\ticonfig.v = '%s' and item_type = %d limit 1", dbesc($s), intval(ITEM_TYPE_DOC));
    \Zotlabs\Lib\IConfig::Set($item, 'system', 'docfile', $s);
    if ($r) {
        $item['id'] = $r[0]['id'];
        $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
        $x = item_store_update($item);
    } else {
        $item['mid'] = $item['parent_mid'] = item_message_id();
        $x = item_store($item);
    }
    return $x;
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:34,代码来源:help.php

示例9: impel_init


//.........这里部分代码省略.........
        if ($j['edited']) {
            $m['menu_edited'] = datetime_convert($j['edited']);
        }
        $m['menu_flags'] = 0;
        if ($j['flags']) {
            if (in_array('bookmark', $j['flags'])) {
                $m['menu_flags'] |= MENU_BOOKMARK;
            }
            if (in_array('system', $j['flags'])) {
                $m['menu_flags'] |= MENU_SYSTEM;
            }
        }
        $menu_id = menu_create($m);
        if ($menu_id) {
            if (is_array($j['items'])) {
                foreach ($j['items'] as $it) {
                    $mitem = array();
                    $mitem['mitem_link'] = str_replace('[baseurl]', z_root(), $it['link']);
                    $mitem['mitem_desc'] = escape_tags($it['desc']);
                    $mitem['mitem_order'] = intval($it['order']);
                    if (is_array($it['flags'])) {
                        $mitem['mitem_flags'] = 0;
                        if (in_array('zid', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_ZID;
                        }
                        if (in_array('new-window', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN;
                        }
                        if (in_array('chatroom', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM;
                        }
                    }
                    menu_add_item($menu_id, local_channel(), $mitem);
                }
                if ($j['edited']) {
                    $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d", dbesc(datetime_convert('UTC', 'UTC', $j['edited'])), intval($menu_id), intval(local_channel()));
                }
            }
            $ret['success'] = true;
        }
        $x = $ret;
    } else {
        $arr['uid'] = local_channel();
        $arr['aid'] = $channel['channel_account_id'];
        $arr['title'] = $j['title'];
        $arr['body'] = $j['body'];
        $arr['term'] = $j['term'];
        $arr['layout_mid'] = $j['layout_mid'];
        $arr['created'] = datetime_convert('UTC', 'UTC', $j['created']);
        $arr['edited'] = datetime_convert('UTC', 'UTC', $j['edited']);
        $arr['owner_xchan'] = get_observer_hash();
        $arr['author_xchan'] = $j['author_xchan'] ? $j['author_xchan'] : get_observer_hash();
        $arr['mimetype'] = $j['mimetype'] ? $j['mimetype'] : 'text/bbcode';
        if (!$j['mid']) {
            $j['mid'] = item_message_id();
        }
        $arr['mid'] = $arr['parent_mid'] = $j['mid'];
        if ($j['pagetitle']) {
            require_once 'library/urlify/URLify.php';
            $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
        }
        // Verify ability to use html or php!!!
        $execflag = false;
        if ($arr['mimetype'] === 'application/x-php') {
            $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_channel()));
            if ($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $z[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
                $execflag = true;
            }
        }
        $remote_id = 0;
        $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1", dbesc($pagetitle), dbesc($namespace), intval(local_channel()));
        $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()));
        if ($z && $i) {
            $remote_id = $z[0]['id'];
            $arr['id'] = $i[0]['id'];
            // don't update if it has the same timestamp as the original
            if ($arr['edited'] > $i[0]['edited']) {
                $x = item_store_update($arr, $execflag);
            }
        } else {
            if ($i && intval($i[0]['item_deleted'])) {
                // was partially deleted already, finish it off
                q("delete from item where mid = '%s' and uid = %d", dbesc($arr['mid']), intval(local_channel()));
            }
            $x = item_store($arr, $execflag);
        }
        if ($x['success']) {
            $item_id = $x['item_id'];
            update_remote_id($channel, $item_id, $arr['item_type'], $pagetitle, $namespace, $remote_id, $arr['mid']);
        }
    }
    if ($x['success']) {
        $ret['success'] = true;
        info(sprintf(t('%s element installed'), $installed_type));
    } else {
        notice(sprintf(t('%s element installation failed'), $installed_type));
    }
    //??? should perhaps return ret?
    json_return_and_die(true);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:101,代码来源:impel.php

示例10: profile_activity

/** @file */
function profile_activity($changed, $value)
{
    $a = get_app();
    if (!local_user() || !is_array($changed) || !count($changed)) {
        return;
    }
    if (!get_pconfig(local_user(), 'system', 'post_profilechange')) {
        return;
    }
    require_once 'include/items.php';
    $self = $a->get_channel();
    if (!count($self)) {
        return;
    }
    $arr = array();
    $arr['mid'] = $arr['parent_mid'] = item_message_id();
    $arr['uid'] = local_user();
    $arr['aid'] = $self['channel_account_id'];
    $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash'];
    $arr['item_flags'] = ITEM_WALL | ITEM_ORIGIN | ITEM_THREAD_TOP;
    $arr['verb'] = ACTIVITY_UPDATE;
    $arr['obj_type'] = ACTIVITY_OBJ_PROFILE;
    $arr['plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . $arr['mid'];
    $A = '[url=' . z_root() . '/channel/' . $self['channel_address'] . ']' . $self['channel_name'] . '[/url]';
    $changes = '';
    $t = count($changed);
    $z = 0;
    foreach ($changed as $ch) {
        if (strlen($changes)) {
            if ($z == $t - 1) {
                $changes .= t(' and ');
            } else {
                $changes .= ', ';
            }
        }
        $z++;
        $changes .= $ch;
    }
    $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]';
    if ($t == 1 && strlen($value)) {
        // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to.
        $value = linkify($value);
        $message = sprintf(t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
        $message .= "\n\n" . sprintf(t('Visit %1$s\'s %2$s'), $A, $prof);
    } else {
        $message = sprintf(t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
    }
    $arr['body'] = $message;
    $links = array();
    $links[] = array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/profile/' . $self['channel_address']);
    $links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'], 'href' => $self['xchan_photo_l']);
    $arr['object'] = json_encode(array('type' => ACTIVITY_OBJ_PROFILE, 'title' => $self['channel_name'], 'id' => $self['xchan_url'] . '/' . $self['xchan_hash'], 'link' => $links));
    $arr['allow_cid'] = $self['channel_allow_cid'];
    $arr['allow_gid'] = $self['channel_allow_gid'];
    $arr['deny_cid'] = $self['channel_deny_cid'];
    $arr['deny_gid'] = $self['channel_deny_gid'];
    $res = item_store($arr);
    $i = $res['item_id'];
    if ($i) {
        // FIXME - limit delivery in notifier.php to those specificed in the perms argument
        proc_run('php', "include/notifier.php", "activity", "{$i}", 'PERMS_R_PROFILE');
    }
}
开发者ID:Mauru,项目名称:red,代码行数:64,代码来源:activities.php

示例11: photos_create_item

/**
 * @brief Creates a new photo item.
 *
 * @param array $channel
 * @param string $creator_hash
 * @param array $photo
 * @param boolean $visible default false
 * @return int item_id
 */
function photos_create_item($channel, $creator_hash, $photo, $visible = false)
{
    // Create item container
    $item_hidden = $visible ? 0 : 1;
    $mid = item_message_id();
    $arr = array();
    $arr['aid'] = $channel['channel_account_id'];
    $arr['uid'] = $channel['channel_id'];
    $arr['mid'] = $mid;
    $arr['parent_mid'] = $mid;
    $arr['item_wall'] = 1;
    $arr['item_origin'] = 1;
    $arr['item_thread_top'] = 1;
    $arr['item_hidden'] = $item_hidden;
    $arr['resource_type'] = 'photo';
    $arr['resource_id'] = $photo['resource_id'];
    $arr['owner_xchan'] = $channel['channel_hash'];
    $arr['author_xchan'] = $creator_hash;
    $arr['allow_cid'] = $photo['allow_cid'];
    $arr['allow_gid'] = $photo['allow_gid'];
    $arr['deny_cid'] = $photo['deny_cid'];
    $arr['deny_gid'] = $photo['deny_gid'];
    $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]' . '[/zrl]';
    $result = item_store($arr);
    $item_id = $result['item_id'];
    return $item_id;
}
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:37,代码来源:photos.php

示例12: import_webpage_element

function import_webpage_element($element, $channel, $type)
{
    $arr = array();
    // construct information for the webpage element item table record
    switch ($type) {
        //
        //	PAGES
        //
        case 'page':
            $arr['item_type'] = ITEM_TYPE_WEBPAGE;
            $namespace = 'WEBPAGE';
            $name = $element['pagelink'];
            if ($name) {
                require_once 'library/urlify/URLify.php';
                $name = strtolower(\URLify::transliterate($name));
            }
            $arr['title'] = $element['title'];
            $arr['term'] = $element['term'];
            $arr['layout_mid'] = '';
            // by default there is no layout associated with the page
            // If a layout was specified, find it in the database and get its info. If
            // it does not exist, leave layout_mid empty
            if ($element['layout'] !== '') {
                $liid = q("select iid from iconfig where k = 'PDL' and v = '%s' and cat = 'system'", dbesc($element['layout']));
                if ($liid) {
                    $linfo = q("select mid from item where id = %d", intval($liid[0]['iid']));
                    $arr['layout_mid'] = $linfo[0]['mid'];
                }
            }
            break;
            //
            //	LAYOUTS
            //
        //
        //	LAYOUTS
        //
        case 'layout':
            $arr['item_type'] = ITEM_TYPE_PDL;
            $namespace = 'PDL';
            $name = $element['name'];
            $arr['title'] = $element['description'];
            $arr['term'] = $element['term'];
            break;
            //
            //	BLOCKS
            //
        //
        //	BLOCKS
        //
        case 'block':
            $arr['item_type'] = ITEM_TYPE_BLOCK;
            $namespace = 'BUILDBLOCK';
            $name = $element['name'];
            $arr['title'] = $element['title'];
            break;
        default:
            return null;
            // return null if invalid element type
    }
    $arr['uid'] = $channel['channel_id'];
    $arr['aid'] = $channel['channel_account_id'];
    // Check if an item already exists based on the name
    $iid = q("select iid from iconfig where k = '" . $namespace . "' and v = '%s' and cat = 'system'", dbesc($name));
    if ($iid) {
        // If the item does exist, get the item metadata
        $iteminfo = q("select mid,created,edited from item where id = %d", intval($iid[0]['iid']));
        $arr['mid'] = $arr['parent_mid'] = $iteminfo[0]['mid'];
        $arr['created'] = $iteminfo[0]['created'];
        $arr['edited'] = $element['edited'] ? datetime_convert('UTC', 'UTC', $element['edited']) : datetime_convert();
    } else {
        // otherwise, generate the creation times and unique id
        $arr['created'] = $element['created'] ? datetime_convert('UTC', 'UTC', $element['created']) : datetime_convert();
        $arr['edited'] = datetime_convert('UTC', 'UTC', '0000-00-00 00:00:00');
        $arr['mid'] = $arr['parent_mid'] = item_message_id();
    }
    // Import the actual element content
    $arr['body'] = file_get_contents($element['path']);
    // The element owner is the channel importing the elements
    $arr['owner_xchan'] = get_observer_hash();
    // The author is either the owner or whomever was specified
    $arr['author_xchan'] = $element['author_xchan'] ? $element['author_xchan'] : get_observer_hash();
    // Import mimetype if it is a valid mimetype for the element
    $mimetypes = ['text/bbcode', 'text/html', 'text/markdown', 'text/plain', 'application/x-pdl', 'application/x-php'];
    // Blocks and pages can have any mimetype, but layouts must be text/bbcode
    if (in_array($element['mimetype'], $mimetypes) && ($type === 'page' || $type === 'block')) {
        $arr['mimetype'] = $element['mimetype'];
    } else {
        $arr['mimetype'] = 'text/bbcode';
    }
    // Verify ability to use html or php!!!
    $execflag = false;
    if ($arr['mimetype'] === 'application/x-php') {
        $z = q("select account_id, account_roles, channel_pageflags from account " . "left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_channel()));
        if ($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $z[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
            $execflag = true;
        }
    }
    $z = q("select * from iconfig where v = '%s' and k = '%s' and cat = 'service' limit 1", dbesc($name), dbesc($namespace));
    $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()));
    $remote_id = 0;
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:import.php

示例13: photos_create_item

/**
 * @brief Creates a new photo item.
 *
 * @param array $channel
 * @param string $creator_hash
 * @param array $photo
 * @param boolean $visible default false
 * @return int item_id
 */
function photos_create_item($channel, $creator_hash, $photo, $visible = false)
{
    // Create item container
    $item_flags = ITEM_WALL | ITEM_ORIGIN | ITEM_THREAD_TOP;
    $item_restrict = $visible ? ITEM_VISIBLE : ITEM_HIDDEN;
    $mid = item_message_id();
    $arr = array();
    $arr['aid'] = $channel['channel_account_id'];
    $arr['uid'] = $channel['channel_id'];
    $arr['mid'] = $mid;
    $arr['parent_mid'] = $mid;
    $arr['item_flags'] = $item_flags;
    $arr['item_restrict'] = $item_restrict;
    $arr['resource_type'] = 'photo';
    $arr['resource_id'] = $photo['resource_id'];
    $arr['owner_xchan'] = $channel['channel_hash'];
    $arr['author_xchan'] = $creator_hash;
    $arr['allow_cid'] = $photo['allow_cid'];
    $arr['allow_gid'] = $photo['allow_gid'];
    $arr['deny_cid'] = $photo['deny_cid'];
    $arr['deny_gid'] = $photo['deny_gid'];
    $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]';
    $result = item_store($arr);
    $item_id = $result['item_id'];
    return $item_id;
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:36,代码来源:photos.php

示例14: mood_init

function mood_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $uid = local_user();
    $channel = $a->get_channel();
    $verb = notags(trim($_GET['verb']));
    if (!$verb) {
        return;
    }
    $verbs = get_mood_verbs();
    if (!array_key_exists($verb, $verbs)) {
        return;
    }
    $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
    $parent = x($_GET, 'parent') ? intval($_GET['parent']) : 0;
    logger('mood: verb ' . $verb, LOGGER_DEBUG);
    if ($parent) {
        $r = q("select mid, owner_xchan, private, 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 (count($r)) {
            $parent_mid = $r[0]['mid'];
            $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 {
        $private = 0;
        $allow_cid = $channel['channel_allow_cid'];
        $allow_gid = $channel['channel_allow_gid'];
        $deny_cid = $channel['channel_deny_cid'];
        $deny_gid = $channel['channel_deny_gid'];
    }
    $poster = $a->get_observer();
    $mid = item_message_id();
    $action = sprintf(t('%1$s is %2$s', 'mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]', $verbs[$verb]);
    $item_flags = ITEM_WALL | ITEM_ORIGIN | ITEM_UNSEEN;
    if (!$parent_mid) {
        $item_flags |= ITEM_THREAD_TOP;
    }
    $arr = array();
    $arr['aid'] = get_account_id();
    $arr['uid'] = $uid;
    $arr['mid'] = $mid;
    $arr['parent_mid'] = $parent_mid ? $parent_mid : $mid;
    $arr['item_flags'] = $item_flags;
    $arr['author_xchan'] = $poster['xchan_hash'];
    $arr['owner_xchan'] = $parent_mid ? $r[0]['owner_xchan'] : $poster['xchan_hash'];
    $arr['title'] = '';
    $arr['allow_cid'] = $allow_cid;
    $arr['allow_gid'] = $allow_gid;
    $arr['deny_cid'] = $deny_cid;
    $arr['deny_gid'] = $deny_gid;
    $arr['item_private'] = $private;
    $arr['verb'] = $activity;
    $arr['body'] = $action;
    if (!$arr['plink'] && $arr['item_flags'] & ITEM_THREAD_TOP) {
        $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    }
    $post = item_store($arr);
    $item_id = $post['item_id'];
    if ($item_id) {
        proc_run('php', "include/notifier.php", "activity", $item_id);
    }
    call_hooks('post_local_end', $arr);
    if ($_SESSION['return_url']) {
        goaway(z_root() . '/' . $_SESSION['return_url']);
    }
    return;
}
开发者ID:Mauru,项目名称:red,代码行数:72,代码来源:mood.php

示例15: wiki_create_wiki

function wiki_create_wiki($channel, $observer_hash, $wiki, $acl)
{
    $wikiinit = wiki_init_wiki($channel, $wiki);
    if (!$wikiinit['path']) {
        notice('Error creating wiki');
        return array('item' => null, 'success' => false);
    }
    $path = $wikiinit['path'];
    // Generate unique resource_id using the same method as item_message_id()
    do {
        $dups = false;
        $resource_id = random_string();
        $r = q("SELECT mid FROM item WHERE resource_id = '%s' AND resource_type = '%s' AND uid = %d LIMIT 1", dbesc($resource_id), dbesc(WIKI_ITEM_RESOURCE_TYPE), intval($channel['channel_id']));
        if (count($r)) {
            $dups = true;
        }
    } while ($dups == true);
    $ac = $acl->get();
    $mid = item_message_id();
    $arr = array();
    // Initialize the array of parameters for the post
    $item_hidden = 0;
    // TODO: Allow form creator to send post to ACL about new game automatically
    $wiki_url = z_root() . '/wiki/' . $channel['channel_address'] . '/' . $wiki['urlName'];
    $arr['aid'] = $channel['channel_account_id'];
    $arr['uid'] = $channel['channel_id'];
    $arr['mid'] = $mid;
    $arr['parent_mid'] = $mid;
    $arr['item_hidden'] = $item_hidden;
    $arr['resource_type'] = WIKI_ITEM_RESOURCE_TYPE;
    $arr['resource_id'] = $resource_id;
    $arr['owner_xchan'] = $channel['channel_hash'];
    $arr['author_xchan'] = $observer_hash;
    $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    $arr['llink'] = $arr['plink'];
    $arr['title'] = $wiki['htmlName'];
    // name of new wiki;
    $arr['allow_cid'] = $ac['allow_cid'];
    $arr['allow_gid'] = $ac['allow_gid'];
    $arr['deny_cid'] = $ac['deny_cid'];
    $arr['deny_gid'] = $ac['deny_gid'];
    $arr['item_wall'] = 1;
    $arr['item_origin'] = 1;
    $arr['item_thread_top'] = 1;
    $arr['item_private'] = intval($acl->is_private());
    $arr['verb'] = ACTIVITY_CREATE;
    $arr['obj_type'] = ACTIVITY_OBJ_WIKI;
    $arr['body'] = '[table][tr][td][h1]New Wiki[/h1][/td][/tr][tr][td][zrl=' . $wiki_url . ']' . $wiki['htmlName'] . '[/zrl][/td][/tr][/table]';
    // Save the path using iconfig. The file path should not be shared with other hubs
    if (!set_iconfig($arr, 'wiki', 'path', $path, false)) {
        return array('item' => null, 'success' => false);
    }
    // Save the wiki name information using iconfig. This is shareable.
    if (!set_iconfig($arr, 'wiki', 'rawName', $wiki['rawName'], true)) {
        return array('item' => null, 'success' => false);
    }
    if (!set_iconfig($arr, 'wiki', 'htmlName', $wiki['htmlName'], true)) {
        return array('item' => null, 'success' => false);
    }
    if (!set_iconfig($arr, 'wiki', 'urlName', $wiki['urlName'], true)) {
        return array('item' => null, 'success' => false);
    }
    $post = item_store($arr);
    $item_id = $post['item_id'];
    if ($item_id) {
        proc_run('php', "include/notifier.php", "activity", $item_id);
        return array('item' => $arr, 'success' => true);
    } else {
        return array('item' => null, 'success' => false);
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:71,代码来源:wiki.php


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