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


PHP is_sys_channel函数代码示例

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


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

示例1: zot_feed

function zot_feed($uid, $observer_hash, $arr)
{
    $result = array();
    $mindate = null;
    $message_id = null;
    require_once 'include/security.php';
    if (array_key_exists('mindate', $arr)) {
        $mindate = datetime_convert('UTC', 'UTC', $arr['mindate']);
    }
    if (array_key_exists('message_id', $arr)) {
        $message_id = $arr['message_id'];
    }
    if (!$mindate) {
        $mindate = NULL_DATE;
    }
    $mindate = dbesc($mindate);
    logger('zot_feed: requested for uid ' . $uid . ' from observer ' . $observer_hash, LOGGER_DEBUG);
    if ($message_id) {
        logger('message_id: ' . $message_id, LOGGER_DEBUG);
    }
    if (!perm_is_allowed($uid, $observer_hash, 'view_stream')) {
        logger('zot_feed: permission denied.');
        return $result;
    }
    if (!is_sys_channel($uid)) {
        $sql_extra = item_permissions_sql($uid, $observer_hash);
    }
    $limit = " LIMIT 100 ";
    if ($mindate != NULL_DATE) {
        $sql_extra .= " and ( created > '{$mindate}' or changed > '{$mindate}' ) ";
    }
    if ($message_id) {
        $sql_extra .= " and mid = '" . dbesc($message_id) . "' ";
        $limit = '';
    }
    $items = array();
    /** @FIXME fix this part for PostgreSQL */
    if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
        return array();
    }
    if (is_sys_channel($uid)) {
        $r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid != %d\n\t\t\tAND item_private = 0 AND item_restrict = 0 AND uid in (" . stream_perms_api_uids(PERMS_PUBLIC, 10, 1) . ")\n\t\t\tAND (item_flags &  %d) > 0\n\t\t\t{$sql_extra} GROUP BY parent ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
    } else {
        $r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid = %d AND item_restrict = 0\n\t\t\tAND (item_flags &  %d) > 0\n\t\t\t{$sql_extra} GROUP BY parent ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
    }
    if ($r) {
        for ($x = 0; $x < count($r); $x++) {
            if (strpos($r[$x]['postopts'], 'nodeliver') !== false) {
                unset($r[$x]);
            }
        }
        $parents_str = ids_to_querystr($r, 'parent');
        $sys_query = is_sys_channel($uid) ? $sql_extra : '';
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`\n\t\t\tWHERE `item`.`item_restrict` = 0\n\t\t\tAND `item`.`parent` IN ( %s ) {$sys_query} ", dbesc($parents_str));
    }
    if ($items) {
        xchan_query($items);
        $items = fetch_post_tags($items);
        require_once 'include/conversation.php';
        $items = conv_sort($items, 'ascending');
    } else {
        $items = array();
    }
    logger('zot_feed: number items: ' . count($items), LOGGER_DEBUG);
    foreach ($items as $item) {
        $result[] = encode_item($item);
    }
    return $result;
}
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:69,代码来源:items.php

示例2: init

 function init()
 {
     // We need this to make sure the channel theme is always loaded.
     $which = argv(1);
     $profile = 0;
     profile_load($a, $which, $profile);
     if (\App::$profile['profile_uid']) {
         head_set_icon(\App::$profile['thumb']);
     }
     // load the item here in the init function because we need to extract
     // the page layout and initialise the correct theme.
     $observer = \App::get_observer();
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     // perm_is_allowed is denied unconditionally when 'site blocked to unauthenticated members'.
     // This bypasses that restriction for sys channel (public) content
     if (!perm_is_allowed(\App::$profile['profile_uid'], $ob_hash, 'view_pages') && !is_sys_channel(\App::$profile['profile_uid'])) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     if (argc() < 3) {
         notice(t('Invalid item.') . EOL);
         return;
     }
     $channel_address = argv(1);
     // The page link title was stored in a urlencoded format
     // php or the browser may/will have decoded it, so re-encode it for our search
     $page_id = urlencode(argv(2));
     $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
     if (!$u) {
         notice(t('Channel not found.') . EOL);
         return;
     }
     if ($_REQUEST['rev']) {
         $revision = " and revision = " . intval($_REQUEST['rev']) . " ";
     } else {
         $revision = " order by revision desc ";
     }
     require_once 'include/security.php';
     $sql_options = item_permissions_sql($u[0]['channel_id']);
     $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\t\twhere item.uid = %d and sid = '%s' and item.item_delayed = 0 and (( service = 'WEBPAGE' and item_type = %d ) \n\t\t\tOR ( service = 'PDL' AND item_type = %d )) {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_WEBPAGE), intval(ITEM_TYPE_PDL));
     if (!$r) {
         // Check again with no permissions clause to see if it is a permissions issue
         $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\t\twhere item.uid = %d and sid = '%s' and item.item_delayed = 0 and service = 'WEBPAGE' and \n\t\t\titem_type = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_WEBPAGE));
         if ($x) {
             // Yes, it's there. You just aren't allowed to see it.
             notice(t('Permission denied.') . EOL);
         } else {
             notice(t('Page not found.') . EOL);
         }
         return;
     }
     if ($r[0]['title']) {
         \App::$page['title'] = escape_tags($r[0]['title']);
     }
     if ($r[0]['item_type'] == ITEM_TYPE_PDL) {
         \App::$comanche = new \Zotlabs\Render\Comanche();
         \App::$comanche->parse($r[0]['body']);
         \App::$pdl = $r[0]['body'];
     } elseif ($r[0]['layout_mid']) {
         $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']));
         if ($l) {
             \App::$comanche = new \Zotlabs\Render\Comanche();
             \App::$comanche->parse($l[0]['body']);
             \App::$pdl = $l[0]['body'];
         }
     }
     \App::$data['webpage'] = $r;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:68,代码来源:Page.php

示例3: profile_sidebar

/**
 * @brief Formats a profile for display in the sidebar.
 *
 * It is very difficult to templatise the HTML completely
 * because of all the conditional logic.
 *
 * @param array $profile
 * @param int $block
 * @param boolean $show_connect
 *
 * @return HTML string suitable for sidebar inclusion
 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
 */
function profile_sidebar($profile, $block = 0, $show_connect = true)
{
    $a = get_app();
    $observer = $a->get_observer();
    $o = '';
    $location = false;
    $pdesc = true;
    $reddress = true;
    if (!is_array($profile) && !count($profile)) {
        return $o;
    }
    head_set_icon($profile['thumb']);
    $is_owner = $profile['uid'] == local_channel() ? true : false;
    if (is_sys_channel($profile['uid'])) {
        $show_connect = false;
    }
    $profile['picdate'] = urlencode($profile['picdate']);
    call_hooks('profile_sidebar_enter', $profile);
    require_once 'include/Contact.php';
    if ($show_connect) {
        // This will return an empty string if we're already connected.
        $connect_url = rconnect_url($profile['uid'], get_observer_hash());
        $connect = $connect_url ? t('Connect') : '';
        if ($connect_url) {
            $connect_url = sprintf($connect_url, urlencode($profile['channel_address'] . '@' . $a->get_hostname()));
        }
        // premium channel - over-ride
        if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
            $connect_url = z_root() . '/connect/' . $profile['channel_address'];
        }
    }
    // show edit profile to yourself
    if ($is_owner) {
        $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'entries' => array());
        $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
        if ($multi_profiles) {
            $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles'));
            $profile['menu']['cr_new'] = t('Create New Profile');
        } else {
            $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'), '', t('Edit Profile'));
        }
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
        if ($r) {
            foreach ($r as $rr) {
                if (!($multi_profiles || $rr['is_default'])) {
                    continue;
                }
                $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile_name'], 'isdefault' => $rr['is_default'], 'visible_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility'));
            }
        }
    }
    if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) {
        $location = t('Location:');
    }
    $profile['homepage'] = linkify($profile['homepage'], true);
    $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
    $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
    $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
    $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False;
    //	logger('online: ' . $profile['online']);
    if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
        $block = true;
    }
    if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) {
        $location = $reddress = $pdesc = $gender = $marital = $homepage = False;
    }
    $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name'];
    $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname)));
    $diaspora = array('podloc' => z_root(), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg');
    $contact_block = contact_block();
    $channel_menu = false;
    $menu = get_pconfig($profile['uid'], 'system', 'channel_menu');
    if ($menu && !$block) {
        require_once 'include/menu.php';
        $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']);
        if ($m) {
            $channel_menu = menu_render($m);
        }
    }
    $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock');
    if ($menublock && !$block) {
        require_once 'include/comanche.php';
        $channel_menu .= comanche_block($menublock);
    }
    $tpl = get_markup_template('profile_vcard.tpl');
    require_once 'include/widgets.php';
    $z = widget_rating(array('target' => $profile['channel_hash']));
//.........这里部分代码省略.........
开发者ID:23n,项目名称:hubzilla,代码行数:101,代码来源:identity.php

示例4: zot_feed

function zot_feed($uid, $observer_hash, $arr)
{
    $result = array();
    $mindate = null;
    $message_id = null;
    require_once 'include/security.php';
    if (array_key_exists('mindate', $arr)) {
        $mindate = datetime_convert('UTC', 'UTC', $arr['mindate']);
    }
    if (array_key_exists('message_id', $arr)) {
        $message_id = $arr['message_id'];
    }
    if (!$mindate) {
        $mindate = NULL_DATE;
    }
    $mindate = dbesc($mindate);
    logger('zot_feed: requested for uid ' . $uid . ' from observer ' . $observer_hash, LOGGER_DEBUG);
    if ($message_id) {
        logger('message_id: ' . $message_id, LOGGER_DEBUG);
    }
    if (!perm_is_allowed($uid, $observer_hash, 'view_stream')) {
        logger('zot_feed: permission denied.');
        return $result;
    }
    if (!is_sys_channel($uid)) {
        $sql_extra = item_permissions_sql($uid, $observer_hash);
    }
    $limit = " LIMIT 100 ";
    if ($mindate != NULL_DATE) {
        $sql_extra .= " and ( created > '{$mindate}' or changed > '{$mindate}' ) ";
    }
    if ($message_id) {
        $sql_extra .= " and mid = '" . dbesc($message_id) . "' ";
        $limit = '';
    }
    $items = array();
    /** @FIXME re-unite these SQL statements. There is no need for them to be separate. The mySQL is convoluted with misuse of group by. As it stands, there is a slight difference where the postgres version doesn't remove the duplicate parents up to 100. In practice this doesn't matter. It could be made to match behavior by adding "distinct on (parent) " to the front of the selection list, at a not-worth-it performance penalty (page temp results to disk). duplicates are still ignored in the in() clause, you just get less than 100 parents if there are many children. */
    if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
        $groupby = '';
    } else {
        $groupby = 'GROUP BY parent';
    }
    $item_normal = item_normal();
    if (is_sys_channel($uid)) {
        $r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid != %d\n\t\t\t{$item_normal}\n\t\t\tAND item_wall = 1\n\t\t\tand item_private = 0 {$sql_extra} {$groupby} ORDER BY created ASC {$limit}", intval($uid));
    } else {
        $r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid = %d {$item_normal}\n\t\t\tAND item_wall = 1\n\t\t\t{$sql_extra} {$groupby} ORDER BY created ASC {$limit}", intval($uid));
    }
    if ($r) {
        for ($x = 0; $x < count($r); $x++) {
            if (strpos($r[$x]['postopts'], 'nodeliver') !== false) {
                unset($r[$x]);
            }
        }
        $parents_str = ids_to_querystr($r, 'parent');
        $sys_query = is_sys_channel($uid) ? $sql_extra : '';
        $item_normal = item_normal();
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`\n\t\t\tWHERE `item`.`parent` IN ( %s ) {$item_normal} {$sys_query} ", dbesc($parents_str));
    }
    if ($items) {
        xchan_query($items);
        $items = fetch_post_tags($items);
        require_once 'include/conversation.php';
        $items = conv_sort($items, 'ascending');
    } else {
        $items = array();
    }
    logger('zot_feed: number items: ' . count($items), LOGGER_DEBUG);
    foreach ($items as $item) {
        $result[] = encode_item($item);
    }
    return $result;
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:73,代码来源:items.php

示例5: zot_feed

function zot_feed($uid, $observer_xchan, $mindate)
{
    $result = array();
    $mindate = datetime_convert('UTC', 'UTC', $mindate);
    if (!$mindate) {
        $mindate = NULL_DATE;
    }
    $mindate = dbesc($mindate);
    logger('zot_feed: ' . $uid);
    if (!perm_is_allowed($uid, $observer_xchan, 'view_stream')) {
        logger('zot_feed: permission denied.');
        return $result;
    }
    if (!is_sys_channel($uid)) {
        require_once 'include/security.php';
        $sql_extra = item_permissions_sql($uid);
    }
    if ($mindate != NULL_DATE) {
        $sql_extra .= " and ( created > '{$mindate}' or edited > '{$mindate}' ) ";
        $limit = "";
    } else {
        $limit = " limit 0, 50 ";
    }
    $items = array();
    if (is_sys_channel($uid)) {
        require_once 'include/security.php';
        $r = q("SELECT distinct parent from item\n\t\t\tWHERE uid != %d\n\t\t\tand uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 \n\t\t\tAND (item_flags &  %d) \n\t\t\tand item_private = 0 {$sql_extra} ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
    } else {
        $r = q("SELECT distinct parent from item\n\t\t\tWHERE uid = %d AND item_restrict = 0\n\t\t\tAND (item_flags &  %d) \n\t\t\t{$sql_extra} ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
    }
    if ($r) {
        $parents_str = ids_to_querystr($r, 'parent');
        $sys_query = is_sys_channel($uid) ? $sql_extra : '';
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` \n\t\t\tWHERE `item`.`item_restrict` = 0\n\t\t\tAND `item`.`parent` IN ( %s ) {$sys_query} ", dbesc($parents_str));
    }
    if ($items) {
        xchan_query($items);
        $items = fetch_post_tags($items);
        require_once 'include/conversation.php';
        $items = conv_sort($items, 'ascending');
    } else {
        $items = array();
    }
    logger('zot_feed: number items: ' . count($items), LOGGER_DEBUG);
    foreach ($items as $item) {
        $result[] = encode_item($item);
    }
    return $result;
}
开发者ID:Mauru,项目名称:red,代码行数:49,代码来源:items.php

示例6: profile_sidebar

/**
 * @brief Formats a profile for display in the sidebar.
 *
 * It is very difficult to templatise the HTML completely
 * because of all the conditional logic.
 *
 * @param array $profile
 * @param int $block
 * @param boolean $show_connect
 *
 * @return HTML string suitable for sidebar inclusion
 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
 */
function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false)
{
    $observer = App::get_observer();
    $o = '';
    $location = false;
    $pdesc = true;
    $reddress = true;
    if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
        $block = true;
    }
    if (!is_array($profile) && !count($profile)) {
        return $o;
    }
    head_set_icon($profile['thumb']);
    if (is_sys_channel($profile['uid'])) {
        $show_connect = false;
    }
    $profile['picdate'] = urlencode($profile['picdate']);
    call_hooks('profile_sidebar_enter', $profile);
    if ($show_connect) {
        // This will return an empty string if we're already connected.
        $connect_url = rconnect_url($profile['uid'], get_observer_hash());
        $connect = $connect_url ? t('Connect') : '';
        if ($connect_url) {
            $connect_url = sprintf($connect_url, urlencode(channel_reddress($profile)));
        }
        // premium channel - over-ride
        if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
            $connect_url = z_root() . '/connect/' . $profile['channel_address'];
        }
    }
    if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) {
        $location = t('Location:');
    }
    $profile['homepage'] = linkify($profile['homepage'], true);
    $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
    $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
    $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
    $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False;
    //	logger('online: ' . $profile['online']);
    if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) {
        $location = $reddress = $pdesc = $gender = $marital = $homepage = False;
    }
    $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name'];
    $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname)));
    $diaspora = array('podloc' => z_root(), 'guid' => $profile['channel_guid'] . str_replace('.', '', App::get_hostname()), 'pubkey' => pemtorsa($profile['channel_pubkey']), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg');
    $contact_block = contact_block();
    $channel_menu = false;
    $menu = get_pconfig($profile['uid'], 'system', 'channel_menu');
    if ($menu && !$block) {
        require_once 'include/menu.php';
        $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']);
        if ($m) {
            $channel_menu = menu_render($m);
        }
    }
    $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock');
    if ($menublock && !$block) {
        $comanche = new Zotlabs\Render\Comanche();
        $channel_menu .= $comanche->block($menublock);
    }
    if ($zcard) {
        $tpl = get_markup_template('profile_vcard_short.tpl');
    } else {
        $tpl = get_markup_template('profile_vcard.tpl');
    }
    require_once 'include/widgets.php';
    //	if(! feature_enabled($profile['uid'],'hide_rating'))
    $z = widget_rating(array('target' => $profile['channel_hash']));
    $o .= replace_macros($tpl, array('$zcard' => $zcard, '$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block, '$editmenu' => profile_edit_menu($profile['uid'])));
    $arr = array('profile' => &$profile, 'entry' => &$o);
    call_hooks('profile_sidebar', $arr);
    return $o;
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:87,代码来源:channel.php

示例7: event_store_item

function event_store_item($arr, $event)
{
    require_once 'include/datetime.php';
    require_once 'include/items.php';
    require_once 'include/bbcode.php';
    $item = null;
    if ($arr['mid'] && $arr['uid']) {
        $i = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval($arr['uid']));
        if ($i) {
            xchan_query($i);
            $item = fetch_post_tags($i, true);
        }
    }
    $item_arr = array();
    $prefix = '';
    //	$birthday = false;
    if ($event && array_key_exists('event_hash', $event) && !array_key_exists('event_hash', $arr)) {
        $arr['event_hash'] = $event['event_hash'];
    }
    if ($event['etype'] === 'birthday') {
        if (!is_sys_channel($arr['uid'])) {
            $prefix = t('This event has been added to your calendar.');
        }
        //		$birthday = true;
        // The event is created on your own site by the system, but appears to belong
        // to the birthday person. It also isn't propagated - so we need to prevent
        // folks from trying to comment on it. If you're looking at this and trying to
        // fix it, you'll need to completely change the way birthday events are created
        // and send them out from the source. This has its own issues.
        $item_arr['comment_policy'] = 'none';
    }
    $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", dbesc($event['event_hash']), intval($arr['uid']));
    if ($r) {
        $object = json_encode(array('type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], 'title' => $arr['summary'], 'dtstart' => $arr['dtstart'], 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], 'description' => $arr['description'], 'location' => $arr['location'], 'adjust' => $arr['adjust'], 'content' => format_event_bbcode($arr), 'author' => array('name' => $r[0]['xchan_name'], 'address' => $r[0]['xchan_addr'], 'guid' => $r[0]['xchan_guid'], 'guid_sig' => $r[0]['xchan_guid_sig'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']), array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])))));
        $private = $arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid'] ? 1 : 0;
        // @FIXME can only update sig if we have the author's channel on this site
        // Until fixed, set it to nothing so it won't give us signature errors
        $sig = '';
        q("UPDATE item SET title = '%s', body = '%s', obj = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s'  WHERE id = %d AND uid = %d", dbesc($arr['summary']), dbesc($prefix . format_event_bbcode($arr)), dbesc($object), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), dbesc($arr['edited']), dbesc($sig), intval($r[0]['item_flags']), intval($private), dbesc(ACTIVITY_OBJ_EVENT), intval($r[0]['id']), intval($arr['uid']));
        q("delete from term where oid = %d and otype = %d", intval($r[0]['id']), intval(TERM_OBJ_POST));
        if ($arr['term'] && is_array($arr['term'])) {
            foreach ($arr['term'] as $t) {
                q("insert into term (uid,oid,otype,ttype,term,url)\n\t\t\t\t\tvalues(%d,%d,%d,%d,'%s','%s') ", intval($arr['uid']), intval($r[0]['id']), intval(TERM_OBJ_POST), intval($t['ttype']), dbesc($t['term']), dbesc($t['url']));
            }
        }
        $item_id = $r[0]['id'];
        call_hooks('event_updated', $event['id']);
        return $item_id;
    } else {
        $z = q("select * from channel where channel_id = %d limit 1", intval($arr['uid']));
        $private = $arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid'] ? 1 : 0;
        $item_wall = 0;
        $item_origin = 0;
        $item_thread_top = 0;
        if ($item) {
            $item_arr['id'] = $item['id'];
        } else {
            $wall = $z[0]['channel_hash'] == $event['event_xchan'] ? true : false;
            $item_thread_top = 1;
            if ($wall) {
                $item_wall = 1;
                $item_origin = 1;
            }
        }
        if (!$arr['mid']) {
            $arr['mid'] = item_message_id();
        }
        $item_arr['aid'] = $z[0]['channel_account_id'];
        $item_arr['uid'] = $arr['uid'];
        $item_arr['author_xchan'] = $arr['event_xchan'];
        $item_arr['mid'] = $arr['mid'];
        $item_arr['parent_mid'] = $arr['mid'];
        $item_arr['owner_xchan'] = $wall ? $z[0]['channel_hash'] : $arr['event_xchan'];
        $item_arr['author_xchan'] = $arr['event_xchan'];
        $item_arr['title'] = $arr['summary'];
        $item_arr['allow_cid'] = $arr['allow_cid'];
        $item_arr['allow_gid'] = $arr['allow_gid'];
        $item_arr['deny_cid'] = $arr['deny_cid'];
        $item_arr['deny_gid'] = $arr['deny_gid'];
        $item_arr['item_private'] = $private;
        $item_arr['verb'] = ACTIVITY_POST;
        $item_arr['item_wall'] = $item_wall;
        $item_arr['item_origin'] = $item_origin;
        $item_arr['item_thread_top'] = $item_thread_top;
        $attach = array(array('href' => z_root() . '/events/ical/' . urlencode($event['event_hash']), 'length' => 0, 'type' => 'text/calendar', 'title' => t('event') . '-' . $event['event_hash'], 'revision' => ''));
        $item_arr['attach'] = $attach;
        if (array_key_exists('term', $arr)) {
            $item_arr['term'] = $arr['term'];
        }
        $item_arr['resource_type'] = 'event';
        $item_arr['resource_id'] = $event['event_hash'];
        $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
        $item_arr['body'] = $prefix . format_event_bbcode($arr);
        // if it's local send the permalink to the channel page.
        // otherwise we'll fallback to /display/$message_id
        if ($wall) {
            $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . $item_arr['mid'];
        } else {
            $item_arr['plink'] = z_root() . '/display/' . $item_arr['mid'];
        }
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:event.php


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