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


PHP get_all_perms函数代码示例

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


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

示例1: change_channel

function change_channel($change_channel)
{
    $ret = false;
    if ($change_channel) {
        $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and not ( channel_pageflags & %d) limit 1", intval($change_channel), intval(get_account_id()), intval(PAGE_REMOVED));
        if ($r) {
            $hash = $r[0]['channel_hash'];
            $_SESSION['uid'] = intval($r[0]['channel_id']);
            get_app()->set_channel($r[0]);
            $_SESSION['theme'] = $r[0]['channel_theme'];
            $_SESSION['mobile_theme'] = get_pconfig(local_user(), 'system', 'mobile_theme');
            date_default_timezone_set($r[0]['channel_timezone']);
            $ret = $r[0];
        }
        $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($hash));
        if ($x) {
            $_SESSION['my_url'] = $x[0]['xchan_url'];
            $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(get_app()->get_baseurl(), strpos(get_app()->get_baseurl(), '://') + 3);
            get_app()->set_observer($x[0]);
            get_app()->set_perms(get_all_perms(local_user(), $hash));
        }
        if (!is_dir('store/' . $r[0]['channel_address'])) {
            @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS, true);
        }
    }
    return $ret;
}
开发者ID:Mauru,项目名称:red,代码行数:27,代码来源:security.php

示例2: achievements_content

function achievements_content(&$a)
{
    // This doesn't work, so
    if (!is_developer()) {
        return;
    }
    if (argc() > 1) {
        $which = argv(1);
    } else {
        notice(t('Requested profile is not available.') . EOL);
        return;
    }
    $profile = 0;
    $profile = argv(1);
    profile_load($a, $which, $profile);
    $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
    if ($r) {
        $owner = intval($r[0]['channel_id']);
    }
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['view_profile']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $newmembertext = t('Some blurb about what to do when you\'re new here');
    //	By default, all badges are false
    $contactbadge = false;
    $profilebadge = false;
    $keywordsbadge = false;
    // Check number of contacts.  Award a badge if over 10
    // We'll figure these out on each page load instead of
    // writing them to the DB because that will mean one needs
    // to retain their achievements - eg, you can't add
    // a bunch of channels just to get your badge, and then
    // delete them all again.  If these become popular or
    // used in profiles or something, we may need to reconsider
    // and add a table for this - because this won't scale.
    $r = q("select * from abook where abook_channel = %d", intval($owner));
    if (count($r)) {
        $contacts = count($r);
    }
    // We're checking for 11 to adjust for the abook record for self
    if ($contacts >= 11) {
        $contactbadge = true;
    }
    //	Check if an about field in the profile has been created.
    $r = q("select * from profile where uid = %d and about <> ''", intval($owner));
    if ($r) {
        $profilebadge = 1;
    }
    // Check if keywords have been set
    $r = q("select * from profile where uid = %d and keywords <> ''", intval($owner));
    if ($r) {
        $keywordsbadge = 1;
    }
    return replace_macros(get_markup_template("achievements.tpl"), array('$newmembertext' => $newmembertext, '$profilebadge' => $profilebadge, '$contactbadge' => $contactbadge, '$keywordsbadge' => $keywordsbadge, '$channelsbadge' => $channelsbadge));
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:59,代码来源:achievements.php

示例3: get

 function get()
 {
     if (!\App::$profile) {
         notice(t('Requested profile is not available.') . EOL);
         \App::$error = 404;
         return;
     }
     $which = argv(1);
     $uid = local_channel();
     $owner = 0;
     $channel = null;
     $observer = \App::get_observer();
     $channel = \App::get_channel();
     if (\App::$is_sys && is_site_admin()) {
         $sys = get_sys_channel();
         if ($sys && intval($sys['channel_id'])) {
             $uid = $owner = intval($sys['channel_id']);
             $channel = $sys;
             $observer = $sys;
         }
     }
     if (!$owner) {
         // Figure out who the page owner is.
         $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
         if ($r) {
             $owner = intval($r[0]['channel_id']);
         }
     }
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $is_owner = $uid && $uid == $owner ? true : false;
     $o = '';
     // Figure out which post we're editing
     $post_id = argc() > 2 ? intval(argv(2)) : 0;
     if (!$post_id) {
         notice(t('Item not found') . EOL);
         return;
     }
     // Now we've got a post and an owner, let's find out if we're allowed to edit it
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     $perms = get_all_perms($owner, $ob_hash);
     if (!$perms['write_pages']) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner));
     $item_id = q("select * from item_id where service = 'PDL' and iid = %d limit 1", intval($itm[0]['id']));
     if ($item_id) {
         $layout_title = $item_id[0]['sid'];
     }
     $rp = 'layouts/' . $which;
     $x = array('webpage' => ITEM_TYPE_PDL, 'nickname' => $channel['channel_address'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'comanche', 'return_path' => $rp, 'button' => t('Edit'), 'hide_voting' => true, 'hide_future' => true, 'hide_expire' => true, 'hide_location' => true, 'hide_weblink' => true, 'hide_attach' => true, 'hide_preview' => true, 'ptyp' => $itm[0]['obj_type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, 'title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), 'pagetitle' => $layout_title, 'ptlabel' => t('Layout Name'), 'placeholdertitle' => t('Layout Description (Optional)'), 'showacl' => false, 'profile_uid' => intval($owner));
     $editor = status_editor($a, $x);
     $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Layout'), '$delete' => $itm[0]['author_xchan'] === $ob_hash || $itm[0]['owner_xchan'] === $ob_hash ? t('Delete') : false, '$id' => $itm[0]['id'], '$editor' => $editor));
     return $o;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:59,代码来源:Editlayout.php

示例4: page_content

function page_content(&$a)
{
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = 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\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
    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\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_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]['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) {
            require_once 'include/comanche.php';
            comanche_parser(get_app(), $l[0]['body']);
        }
    }
    // logger('layout: ' . print_r($a->layout,true));
    // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
    if ($perms['write_pages']) {
        $chan = $a->channel['channel_id'];
        $who = $channel_address;
        $which = $r[0]['id'];
        $o .= writepages_widget($who, $which);
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
开发者ID:Mauru,项目名称:red,代码行数:59,代码来源:page.php

示例5: blocks_content

function blocks_content(&$a)
{
    if (argc() > 1) {
        $which = argv(1);
    } else {
        notice(t('Requested profile is not available.') . EOL);
        $a->error = 404;
        return;
    }
    profile_load($a, $which, 0);
    // Figure out who the page owner is.
    $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
    if ($r) {
        $owner = intval($r[0]['channel_id']);
    }
    // Block design features from visitors
    if (!local_user() || local_user() != $owner) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // Get the observer, check their permissions
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['write_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
    // Nickname is set to the observers xchan, and profile_uid to the owners.
    // This lets you post pages at other people's channels.
    require_once 'include/conversation.php';
    $x = array('webpage' => ITEM_BUILDBLOCK, 'is_owner' => true, 'nickname' => $a->profile['channel_address'], 'lockstate' => $group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'bang' => $group || $cid ? '!' : '', 'showacl' => false, 'visitor' => true, 'mimetype' => 'choose', 'ptlabel' => t('Block Name'), 'profile_uid' => intval($owner));
    if ($_REQUEST['title']) {
        $x['title'] = $_REQUEST['title'];
    }
    if ($_REQUEST['body']) {
        $x['body'] = $_REQUEST['body'];
    }
    if ($_REQUEST['pagetitle']) {
        $x['pagetitle'] = $_REQUEST['pagetitle'];
    }
    $o .= status_editor($a, $x);
    //Get a list of blocks.  We can't display all them because endless scroll makes that unusable, so just list titles and an edit link.
    //TODO - this should be replaced with pagelist_widget
    $r = q("select * from item_id where uid = %d and service = 'BUILDBLOCK' order by sid asc", intval($owner));
    $pages = null;
    if ($r) {
        $pages = array();
        foreach ($r as $rr) {
            $pages[$rr['iid']][] = array('url' => $rr['iid'], 'title' => $rr['sid']);
        }
    }
    //Build the base URL for edit links
    $url = z_root() . "/editblock/" . $which;
    // This isn't pretty, but it works.  Until I figure out what to do with the UI, it's Good Enough(TM).
    return $o . replace_macros(get_markup_template("blocklist.tpl"), array('$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, '$channel' => $which, '$view' => t('View'), '$preview' => '1'));
}
开发者ID:Mauru,项目名称:red,代码行数:58,代码来源:blocks.php

示例6: page_init

function page_init(&$a)
{
    // We need this to make sure the channel theme is always loaded.
    $which = argv(1);
    $profile = 0;
    profile_load($a, $which, $profile);
    if ($a->profile['profile_uid']) {
        head_set_icon($a->profile['thumb']);
    }
    // load the item here in the init function because we need to extract
    // the page layout and initialise the correct theme.
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = 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\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
    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\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_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]['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) {
            require_once 'include/comanche.php';
            comanche_parser(get_app(), $l[0]['body']);
            get_app()->pdl = $l[0]['body'];
        }
    }
    $a->data['webpage'] = $r;
}
开发者ID:redmatrix,项目名称:red,代码行数:58,代码来源:page.php

示例7: editlayout_content

function editlayout_content(&$a)
{
    // We first need to figure out who owns the webpage, grab it from an argument
    $which = argv(1);
    // $a->get_channel() and stuff don't work here, so we've got to find the owner for ourselves.
    $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
    if ($r) {
        $owner = intval($r[0]['channel_id']);
        //logger('owner: ' . print_r($owner,true));
    }
    if (local_user() && argc() > 2 && argv(2) === 'view') {
        $which = $channel['channel_address'];
    }
    $o = '';
    // Figure out which post we're editing
    $post_id = argc() > 2 ? intval(argv(2)) : 0;
    if (!$post_id) {
        notice(t('Item not found') . EOL);
        return;
    }
    // Now we've got a post and an owner, let's find out if we're allowed to edit it
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['write_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // We've already figured out which item we want and whose copy we need, so we don't need anything fancy here
    $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner));
    $item_id = q("select * from item_id where service = 'PDL' and iid = %d limit 1", $itm[0]['id']);
    if ($item_id) {
        $layout_title = $item_id[0]['sid'];
    }
    $plaintext = true;
    // You may or may not be a local user.  This won't work,
    //	if(feature_enabled(local_user(),'richtext'))
    //		$plaintext = false;
    $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Layout')));
    $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => '&nbsp;', '$geotag' => $geotag, '$nickname' => $a->user['nickname'], '$confirmdelete' => t('Delete layout?')));
    $tpl = get_markup_template("jot.tpl");
    $jotplugins = '';
    $jotnets = '';
    call_hooks('jot_tool', $jotplugins);
    call_hooks('jot_networks', $jotnets);
    $channel = $a->get_channel();
    //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
    //FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page.  So, send folk to the webpage list.
    $rp = '/layouts/' . $which;
    $o .= replace_macros($tpl, array('$return_path' => $rp, '$action' => 'item', '$webpage' => ITEM_PDL, '$share' => t('Edit'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), '$youtube' => t('Insert YouTube video'), '$video' => t('Insert Vorbis [.ogg] video'), '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $channel['channel_location'], '$visitor' => false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Set title'), '$pagetitle' => $layout_title, '$category' => '', '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', '$profile_uid' => intval($owner), '$preview' => feature_enabled(local_user(), 'preview') ? t('Preview') : '', '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date')));
    $ob = get_observer_hash();
    if ($itm[0]['author_xchan'] === $ob || $itm[0]['owner_xchan'] === $ob) {
        $o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
    }
    return $o;
}
开发者ID:Mauru,项目名称:red,代码行数:56,代码来源:editlayout.php

示例8: get

 function get()
 {
     $channel = \App::get_channel();
     $atoken = null;
     $atoken_xchan = '';
     if (argc() > 2) {
         $id = argv(2);
         $atoken = q("select * from atoken where atoken_id = %d and atoken_uid = %d", intval($id), intval(local_channel()));
         if ($atoken) {
             $atoken = $atoken[0];
             $atoken_xchan = substr($channel['channel_hash'], 0, 16) . '.' . $atoken['atoken_name'];
         }
         if ($atoken && argc() > 3 && argv(3) === 'drop') {
             atoken_delete($id);
             $atoken = null;
             $atoken_xchan = '';
         }
     }
     $t = q("select * from atoken where atoken_uid = %d", intval(local_channel()));
     $desc = t('Use this form to create temporary access identifiers to share things with non-members. These identities may be used in Access Control Lists and visitors may login using these credentials to access private content.');
     $desc2 = t('You may also provide <em>dropbox</em> style access links to friends and associates by adding the Login Password to any specific site URL as shown. Examples:');
     $global_perms = \Zotlabs\Access\Permissions::Perms();
     $existing = get_all_perms(local_channel(), $atoken_xchan ? $atoken_xchan : '');
     if ($atoken_xchan) {
         $theirs = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'their_perms'", intval(local_channel()), dbesc($atoken_xchan));
         $their_perms = array();
         if ($theirs) {
             foreach ($theirs as $t) {
                 $their_perms[$t['k']] = $t['v'];
             }
         }
     }
     foreach ($global_perms as $k => $v) {
         $thisperm = get_abconfig(local_channel(), $contact['abook_xchan'], 'my_perms', $k);
         //fixme
         $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(), $k);
         if ($existing[$k]) {
             $thisperm = "1";
         }
         $perms[] = array('perms_' . $k, $v, array_key_exists($k, $their_perms) ? intval($their_perms[$k]) : '', $thisperm, 1, $checkinherited & PERMS_SPECIFIC ? '' : '1', '', $checkinherited);
     }
     $tpl = get_markup_template("settings_tokens.tpl");
     $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_tokens"), '$title' => t('Guest Access Tokens'), '$desc' => $desc, '$desc2' => $desc2, '$tokens' => $t, '$atoken' => $atoken, '$url1' => z_root() . '/channel/' . $channel['channel_address'], '$url2' => z_root() . '/photos/' . $channel['channel_address'], '$name' => array('name', t('Login Name') . ' <span class="required">*</span>', $atoken ? $atoken['atoken_name'] : '', ''), '$token' => array('token', t('Login Password') . ' <span class="required">*</span>', $atoken ? $atoken['atoken_token'] : autoname(8), ''), '$expires' => array('expires', t('Expires (yyyy-mm-dd)'), $atoken['atoken_expires'] && $atoken['atoken_expires'] > NULL_DATE ? datetime_convert('UTC', date_default_timezone_get(), $atoken['atoken_expires']) : '', ''), '$them' => t('Their Settings'), '$me' => t('My Settings'), '$perms' => $perms, '$inherited' => t('inherited'), '$notself' => '1', '$permlbl' => t('Individual Permissions'), '$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'), '$submit' => t('Submit')));
     return $o;
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:45,代码来源:Tokens.php

示例9: channel_content

function channel_content(&$a, $update = 0, $load = false)
{
    $category = $datequery = $datequery2 = '';
    $mid = $_GET['mid'];
    $datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
    $datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
    if (get_config('system', 'block_public') && !get_account_id() && !remote_user()) {
        return login();
    }
    $category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
    $groups = array();
    $o = '';
    if ($update) {
        // Ensure we've got a profile owner if updating.
        $a->profile['profile_uid'] = $update;
    } else {
        if ($a->profile['profile_uid'] == local_user()) {
            nav_set_selected('home');
        }
    }
    $is_owner = local_user() && $a->profile['profile_uid'] == local_user() ? true : false;
    $channel = $a->get_channel();
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_stream']) {
        // We may want to make the target of this redirect configurable
        if ($perms['view_profile']) {
            notice(t('Insufficient permissions.  Request redirected to profile page.') . EOL);
            goaway(z_root() . "/profile/" . $a->profile['channel_address']);
        }
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (!$update) {
        $o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
        $o .= common_friends_visitor_widget($a->profile['profile_uid']);
        if ($channel && $is_owner) {
            $channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
        } else {
            $channel_acl = array();
        }
        if ($perms['post_wall']) {
            $x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $observer) && intval(get_pconfig($a->profile['profile_uid'], 'system', 'use_browser_location')) ? true : false, 'default_location' => $is_owner ? $a->profile['channel_location'] : '', 'nickname' => $a->profile['channel_address'], 'lockstate' => strlen($a->profile['channel_allow_cid']) || strlen($a->profile['channel_allow_gid']) || strlen($a->profile['channel_deny_cid']) || strlen($a->profile['channel_deny_gid']) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($channel_acl) : '', 'showacl' => $is_owner ? 'yes' : '', 'bang' => '', 'visitor' => $is_owner || $observer ? true : false, 'profile_uid' => $a->profile['profile_uid']);
            $o .= status_editor($a, $x);
        }
    }
    /**
     * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     */
    $sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
    if ($update && !$load) {
        if ($mid) {
            $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0\n\t\t\t\tAND (item_flags &  %d) AND (item_flags & %d) {$sql_extra} limit 1", dbesc($mid), intval($a->profile['profile_uid']), intval(ITEM_WALL), intval(ITEM_UNSEEN));
        } else {
            $r = q("SELECT distinct parent AS `item_id` from item\n\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\tWHERE uid = %d AND item_restrict = 0\n\t\t\t\tAND (item_flags &  %d) AND ( item_flags & %d ) \n\t\t\t\tAND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t{$sql_extra}\n\t\t\t\tORDER BY created DESC", intval($a->profile['profile_uid']), intval(ITEM_WALL), intval(ITEM_UNSEEN), intval(ABOOK_FLAG_BLOCKED));
        }
    } else {
        if (x($category)) {
            $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
        }
        if ($datequery) {
            $sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
        }
        if ($datequery2) {
            $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
        }
        $itemspage = get_pconfig(local_user(), 'system', 'itemspage');
        $a->set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
        $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
        if ($load || $_COOKIE['jsAvailable'] != 1) {
            if ($mid) {
                $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0\n\t\t\t\t\tAND (item_flags &  %d) {$sql_extra} limit 1", dbesc($mid), intval($a->profile['profile_uid']), intval(ITEM_WALL));
                if (!$r) {
                    notice(t('Permission denied.') . EOL);
                }
            } else {
                $r = q("SELECT distinct id AS item_id FROM item \n\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\tWHERE uid = %d AND item_restrict = 0\n\t\t\t\t\tAND (item_flags &  %d) and (item_flags & %d)\n\t\t\t\t\tAND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t\t{$sql_extra} {$sql_extra2}\n\t\t\t\t\tORDER BY created DESC {$pager_sql} ", intval($a->profile['profile_uid']), intval(ITEM_WALL), intval(ITEM_THREAD_TOP), intval(ABOOK_FLAG_BLOCKED));
            }
        } else {
            $r = array();
        }
    }
    if ($r) {
        $parents_str = ids_to_querystr($r, 'item_id');
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id` \n\t\t\tFROM `item`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0\n\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra} ", intval($a->profile['profile_uid']), dbesc($parents_str));
        xchan_query($items);
        $items = fetch_post_tags($items, true);
        $items = conv_sort($items, 'created');
        if ($load && $mid && !count($items)) {
            // This will happen if we don't have sufficient permissions
            // to view the parent item (or the item itself if it is toplevel)
            notice(t('Permission denied.') . EOL);
        }
    } else {
        $items = array();
    }
    if (!$update && !$load) {
        // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
        // because browser prefetching might change it on us. We have to deliver it with the page.
//.........这里部分代码省略.........
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:channel.php

示例10: like_content


//.........这里部分代码省略.........
                if ($interactive) {
                    notice(t('Invalid request.') . EOL);
                    return $o;
                }
                killme();
            }
            $owner_uid = $r[0]['obj_channel'];
            $allow_cid = $r[0]['allow_cid'];
            $allow_gid = $r[0]['allow_gid'];
            $deny_cid = $r[0]['deny_cid'];
            $deny_gid = $r[0]['deny_gid'];
            if ($allow_cid || $allow_gid || $deny_cid || $deny_gid) {
                $public = false;
            }
            $post_type = t('thing');
            $objtype = ACTIVITY_OBJ_PROFILE;
            $tgttype = ACTIVITY_OBJ_THING;
            $links = array();
            $links[] = array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/thing/' . $r[0]['term_hash']);
            if ($r[0]['imgurl']) {
                $links[] = array('rel' => 'photo', 'href' => $r[0]['imgurl']);
            }
            $target = json_encode(array('type' => $tgttype, 'title' => $r[0]['term'], 'id' => z_root() . '/thing/' . $r[0]['term_hash'], 'link' => $links));
            $plink = '[zrl=' . z_root() . '/thing/' . $r[0]['term_hash'] . ']' . $r[0]['term'] . '[/zrl]';
        }
        if (!($owner_uid && $r)) {
            if ($interactive) {
                notice(t('Invalid request.') . EOL);
                return $o;
            }
            killme();
        }
        // The resultant activity is going to be a wall-to-wall post, so make sure this is allowed
        $perms = get_all_perms($owner_uid, $observer['xchan_hash']);
        if (!($perms['post_like'] && $perms['view_profile'])) {
            if ($interactive) {
                notice(t('Permission denied.') . EOL);
                return $o;
            }
            killme();
        }
        $ch = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($owner_uid));
        if (!$ch) {
            if ($interactive) {
                notice(t('Channel unavailable.') . EOL);
                return $o;
            }
            killme();
        }
        if (!$plink) {
            $plink = '[zrl=' . z_root() . '/profile/' . $ch[0]['channel_address'] . ']' . $post_type . '[/zrl]';
        }
        $links = array();
        $links[] = array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/profile/' . $ch[0]['channel_address']);
        $links[] = array('rel' => 'photo', 'type' => $ch[0]['xchan_photo_mimetype'], 'href' => $ch[0]['xchan_photo_l']);
        $object = json_encode(array('type' => ACTIVITY_OBJ_PROFILE, 'title' => $ch[0]['channel_name'], 'id' => $ch[0]['xchan_url'] . '/' . $ch[0]['xchan_hash'], 'link' => $links));
        // second like of the same thing is "undo" for the first like
        $z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1", intval($ch[0]['channel_id']), dbesc($observer['xchan_hash']), dbesc($activity), dbesc($tgttype ? $tgttype : $objtype), dbesc($obj_id));
        if ($z) {
            q("delete from likes where id = %d limit 1", intval($z[0]['id']));
            drop_item($z[0]['iid'], false);
            if ($interactive) {
                notice(t('Previous action reversed.') . EOL);
                return $o;
            }
            killme();
开发者ID:redmatrix,项目名称:red,代码行数:67,代码来源:like.php

示例11: filestorage_content

function filestorage_content(&$a)
{
    if (argc() > 1) {
        $which = argv(1);
    } else {
        notice(t('Requested profile is not available.') . EOL);
        $a->error = 404;
        return;
    }
    $r = q("select * from channel where channel_address = '%s'", dbesc($which));
    if ($r) {
        $channel = $r[0];
        $owner = intval($r[0]['channel_id']);
    }
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['view_storage']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // Since we have ACL'd files in the wild, but don't have ACL here yet, we
    // need to return for anyone other than the owner, despite the perms check for now.
    $is_owner = local_channel() && $owner == local_channel() ? true : false;
    if (!$is_owner) {
        info(t('Permission Denied.') . EOL);
        return;
    }
    if (argc() > 3 && argv(3) === 'delete') {
        if (!$perms['write_storage']) {
            notice(t('Permission denied.') . EOL);
            return;
        }
        $file = intval(argv(2));
        $r = q("SELECT hash FROM attach WHERE id = %d AND uid = %d LIMIT 1", dbesc($file), intval($owner));
        if (!$r) {
            notice(t('File not found.') . EOL);
            goaway(z_root() . '/cloud/' . $which);
        }
        $f = $r[0];
        $channel = $a->get_channel();
        $parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
        attach_delete($owner, $f['hash']);
        goaway($parentpath);
    }
    if (argc() > 3 && argv(3) === 'edit') {
        require_once 'include/acl_selectors.php';
        if (!$perms['write_storage']) {
            notice(t('Permission denied.') . EOL);
            return;
        }
        $file = intval(argv(2));
        $r = q("select id, uid, folder, filename, revision, flags, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1", intval($file), intval($owner));
        $f = $r[0];
        $channel = $a->get_channel();
        $cloudpath = get_cloudpath($f) . ($f['flags'] & ATTACH_FLAG_DIR ? '?f=&davguest=1' : '');
        $parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
        $aclselect_e = populate_acl($f, false);
        $is_a_dir = $f['flags'] & ATTACH_FLAG_DIR ? true : false;
        $lockstate = $f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid'] ? 'lock' : 'unlock';
        // Encode path that is used for link so it's a valid URL
        // Keep slashes as slashes, otherwise mod_rewrite doesn't work correctly
        $encoded_path = str_replace('%2F', '/', rawurlencode($cloudpath));
        $o = replace_macros(get_markup_template('attach_edit.tpl'), array('$header' => t('Edit file permissions'), '$file' => $f, '$cloudpath' => z_root() . '/' . $encoded_path, '$parentpath' => $parentpath, '$uid' => $channel['channel_id'], '$channelnick' => $channel['channel_address'], '$permissions' => t('Permissions'), '$aclselect' => $aclselect_e, '$lockstate' => $lockstate, '$permset' => t('Set/edit permissions'), '$recurse' => array('recurse', t('Include all files and sub folders'), 0, '', array(t('No'), t('Yes'))), '$backlink' => t('Return to file list'), '$isadir' => $is_a_dir, '$cpdesc' => t('Copy/paste this code to attach file to a post'), '$cpldesc' => t('Copy/paste this URL to link file from a web page'), '$submit' => t('Submit'), '$attach_btn_title' => t('Share this file'), '$link_btn_title' => t('Show URL to this file'), '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes')))));
        echo $o;
        killme();
    }
    goaway(z_root() . '/cloud/' . $which);
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:69,代码来源:filestorage.php

示例12: layouts_content

function layouts_content(&$a)
{
    if (!$a->profile) {
        notice(t('Requested profile is not available.') . EOL);
        $a->error = 404;
        return;
    }
    $which = argv(1);
    $_SESSION['return_url'] = $a->query_string;
    $uid = local_channel();
    $owner = 0;
    $channel = null;
    $observer = $a->get_observer();
    $channel = $a->get_channel();
    if ($a->is_sys && is_site_admin()) {
        $sys = get_sys_channel();
        if ($sys && intval($sys['channel_id'])) {
            $uid = $owner = intval($sys['channel_id']);
            $channel = $sys;
            $observer = $sys;
        }
    }
    if (!$owner) {
        // Figure out who the page owner is.
        $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
        if ($r) {
            $owner = intval($r[0]['channel_id']);
        }
    }
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['write_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // Block design features from visitors
    if (!$uid || $uid != $owner) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // Get the observer, check their permissions
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['write_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    //This feature is not exposed in redbasic ui since it is not clear why one would want to
    //download a json encoded pdl file - we dont have a possibility to import it.
    //Use the buildin share/install feature instead.
    if (argc() > 3 && argv(2) === 'share' && argv(3)) {
        $r = q("select sid, service, mimetype, title, body  from item_id \n\t\t\tleft join item on item.id = item_id.iid \n\t\t\twhere item_id.uid = %d and item.mid = '%s' and service = 'PDL' order by sid asc", intval($owner), dbesc(argv(3)));
        if ($r) {
            header('Content-type: application/x-redmatrix-layout');
            header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"');
            echo json_encode($r);
            killme();
        }
    }
    // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
    // Nickname is set to the observers xchan, and profile_uid to the owners.
    // This lets you post pages at other people's channels.
    $x = array('webpage' => ITEM_PDL, 'is_owner' => true, 'nickname' => $a->profile['channel_address'], 'bang' => '', 'showacl' => false, 'visitor' => false, 'nopreview' => 1, 'ptlabel' => t('Layout Name'), 'profile_uid' => intval($owner), 'expanded' => true, 'placeholdertitle' => t('Layout Description (Optional)'), 'novoting' => true);
    if ($_REQUEST['title']) {
        $x['title'] = $_REQUEST['title'];
    }
    if ($_REQUEST['body']) {
        $x['body'] = $_REQUEST['body'];
    }
    if ($_REQUEST['pagetitle']) {
        $x['pagetitle'] = $_REQUEST['pagetitle'];
    }
    $editor = status_editor($a, $x);
    $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id\n\t\twhere item_id.uid = %d and service = 'PDL' and item_restrict = %d order by item.created desc", intval($owner), intval(ITEM_PDL));
    $pages = null;
    if ($r) {
        $pages = array();
        foreach ($r as $rr) {
            $element_arr = array('type' => 'layout', 'title' => $rr['title'], 'body' => $rr['body'], 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], 'pagetitle' => $rr['sid'], 'mid' => $rr['mid']);
            $pages[$rr['iid']][] = array('url' => $rr['iid'], 'title' => $rr['sid'], 'descr' => $rr['title'], 'mid' => $rr['mid'], 'created' => $rr['created'], 'edited' => $rr['edited'], 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]');
        }
    }
    //Build the base URL for edit links
    $url = z_root() . '/editlayout/' . $which;
    $o .= replace_macros(get_markup_template('layoutlist.tpl'), array('$title' => t('Layouts'), '$create' => t('Create'), '$help' => array('text' => t('Help'), 'url' => 'help/comanche', 'title' => t('Comanche page description language help')), '$editor' => $editor, '$baseurl' => $url, '$name' => t('Layout Name'), '$descr' => t('Layout Description'), '$created' => t('Created'), '$edited' => t('Edited'), '$edit' => t('Edit'), '$share' => t('Share'), '$download' => t('Download PDL file'), '$pages' => $pages, '$channel' => $which, '$view' => t('View')));
    return $o;
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:87,代码来源:layouts.php

示例13: get

 function get()
 {
     if (!\App::$profile) {
         notice(t('Requested profile is not available.') . EOL);
         \App::$error = 404;
         return;
     }
     $which = argv(1);
     $_SESSION['return_url'] = \App::$query_string;
     $uid = local_channel();
     $owner = 0;
     $channel = null;
     $observer = \App::get_observer();
     $channel = \App::get_channel();
     if (\App::$is_sys && is_site_admin()) {
         $sys = get_sys_channel();
         if ($sys && intval($sys['channel_id'])) {
             $uid = $owner = intval($sys['channel_id']);
             $channel = $sys;
             $observer = $sys;
         }
     }
     if (!$owner) {
         // Figure out who the page owner is.
         $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
         if ($r) {
             $owner = intval($r[0]['channel_id']);
         }
     }
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     $perms = get_all_perms($owner, $ob_hash);
     if (!$perms['write_pages']) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     // Block design features from visitors
     if (!$uid || $uid != $owner) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $mimetype = $_REQUEST['mimetype'] ? $_REQUEST['mimetype'] : get_pconfig($owner, 'system', 'page_mimetype');
     $x = array('webpage' => ITEM_TYPE_BLOCK, 'is_owner' => true, 'nickname' => \App::$profile['channel_address'], 'lockstate' => $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'bang' => '', 'showacl' => false, 'visitor' => true, 'mimetype' => $mimetype, 'mimeselect' => true, 'hide_location' => true, 'ptlabel' => t('Block Name'), 'profile_uid' => intval($owner), 'expanded' => true, 'novoting' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
     if ($_REQUEST['title']) {
         $x['title'] = $_REQUEST['title'];
     }
     if ($_REQUEST['body']) {
         $x['body'] = $_REQUEST['body'];
     }
     if ($_REQUEST['pagetitle']) {
         $x['pagetitle'] = $_REQUEST['pagetitle'];
     }
     $editor = status_editor($a, $x);
     $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id\n\t\t\twhere item_id.uid = %d and service = 'BUILDBLOCK' and item_type = %d order by item.created desc", intval($owner), intval(ITEM_TYPE_BLOCK));
     $pages = null;
     if ($r) {
         $pages = array();
         foreach ($r as $rr) {
             $element_arr = array('type' => 'block', 'title' => $rr['title'], 'body' => $rr['body'], 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], 'pagetitle' => $rr['sid'], 'mid' => $rr['mid']);
             $pages[$rr['iid']][] = array('url' => $rr['iid'], 'name' => $rr['sid'], 'title' => $rr['title'], 'created' => $rr['created'], 'edited' => $rr['edited'], 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]');
         }
     }
     //Build the base URL for edit links
     $url = z_root() . '/editblock/' . $which;
     $o .= replace_macros(get_markup_template('blocklist.tpl'), array('$baseurl' => $url, '$title' => t('Blocks'), '$name' => t('Block Name'), '$blocktitle' => t('Block Title'), '$created' => t('Created'), '$edited' => t('Edited'), '$create' => t('Create'), '$edit' => t('Edit'), '$share' => t('Share'), '$delete' => t('Delete'), '$editor' => $editor, '$pages' => $pages, '$channel' => $which, '$view' => t('View'), '$preview' => '1'));
     return $o;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:66,代码来源:Blocks.php

示例14: editwebpage_content

function editwebpage_content(&$a)
{
    if (!App::$profile) {
        notice(t('Requested profile is not available.') . EOL);
        App::$error = 404;
        return;
    }
    $which = argv(1);
    $uid = local_channel();
    $owner = 0;
    $channel = null;
    $observer = App::get_observer();
    $channel = App::get_channel();
    if (App::$is_sys && is_site_admin()) {
        $sys = get_sys_channel();
        if ($sys && intval($sys['channel_id'])) {
            $uid = $owner = intval($sys['channel_id']);
            $channel = $sys;
            $observer = $sys;
        }
    }
    if (!$owner) {
        // Figure out who the page owner is.
        $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
        if ($r) {
            $owner = intval($r[0]['channel_id']);
        }
    }
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $is_owner = $uid && $uid == $owner ? true : false;
    $o = '';
    // Figure out which post we're editing
    $post_id = argc() > 2 ? intval(argv(2)) : 0;
    if (!$post_id) {
        notice(t('Item not found') . EOL);
        return;
    }
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($owner, $ob_hash);
    if (!$perms['write_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    // We've already figured out which item we want and whose copy we need,
    // so we don't need anything fancy here
    $sql_extra = item_permissions_sql($owner);
    $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s {$sql_extra} LIMIT 1", intval($post_id), intval($owner));
    if (!$itm) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (intval($itm[0]['item_obscured'])) {
        $key = get_config('system', 'prvkey');
        if ($itm[0]['title']) {
            $itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
        }
        if ($itm[0]['body']) {
            $itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
        }
    }
    $item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']));
    if ($item_id) {
        $page_title = $item_id[0]['sid'];
    }
    $plaintext = true;
    $mimetype = $itm[0]['mimetype'];
    if ($mimetype === 'application/x-php') {
        if (!$uid || $uid != $itm[0]['uid']) {
            notice(t('Permission denied.') . EOL);
            return;
        }
    }
    $mimeselect = '';
    if ($mimetype != 'text/bbcode') {
        $plaintext = true;
    }
    if (get_config('system', 'page_mimetype')) {
        $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
    } else {
        $mimeselect = mimetype_select($itm[0]['uid'], $mimetype);
    }
    $layout = get_config('system', 'page_layout');
    if ($layout) {
        $layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />';
    } else {
        $layoutselect = layout_select($itm[0]['uid'], $itm[0]['layout_mid']);
    }
    App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => z_root(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$pretext' => '', '$ispublic' => '&nbsp;', '$geotag' => $geotag, '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete webpage?'), '$bbco_autocomplete' => $mimetype == 'text/bbcode' ? 'bbcode' : ''));
    $tpl = get_markup_template("jot.tpl");
    $jotplugins = '';
    $jotnets = '';
    call_hooks('jot_tool', $jotplugins);
    call_hooks('jot_networks', $jotnets);
    // FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD
    // instead of loading a sensible page.  So, send folk to the webpage list.
    $rp = 'webpages/' . $which;
//.........这里部分代码省略.........
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:101,代码来源:editwebpage.php

示例15: profile_tabs

/**
 * @brief
 *
 * @param App $a
 * @param boolean $is_owner default false
 * @param string $nickname default null
 * @return void|string
 */
function profile_tabs($a, $is_owner = false, $nickname = null)
{
    // Don't provide any profile tabs if we're running as the sys channel
    if (App::$is_sys) {
        return;
    }
    $channel = App::get_channel();
    if (is_null($nickname)) {
        $nickname = $channel['channel_address'];
    }
    $uid = App::$profile['profile_uid'] ? App::$profile['profile_uid'] : local_channel();
    if ($uid == local_channel()) {
        $cal_link = '';
    } else {
        $cal_link = '/cal/' . $nickname;
    }
    if (get_pconfig($uid, 'system', 'noprofiletabs')) {
        return;
    }
    if (x($_GET, 'tab')) {
        $tab = notags(trim($_GET['tab']));
    }
    $url = z_root() . '/channel/' . $nickname;
    $pr = z_root() . '/profile/' . $nickname;
    $tabs = array(array('label' => t('Channel'), 'url' => $url, 'sel' => argv(0) == 'channel' ? 'active' : '', 'title' => t('Status Messages and Posts'), 'id' => 'status-tab'));
    $p = get_all_perms($uid, get_observer_hash());
    if ($p['view_profile']) {
        $tabs[] = array('label' => t('About'), 'url' => $pr, 'sel' => argv(0) == 'profile' ? 'active' : '', 'title' => t('Profile Details'), 'id' => 'profile-tab');
    }
    if ($p['view_storage']) {
        $tabs[] = array('label' => t('Photos'), 'url' => z_root() . '/photos/' . $nickname, 'sel' => argv(0) == 'photos' ? 'active' : '', 'title' => t('Photo Albums'), 'id' => 'photo-tab');
        $tabs[] = array('label' => t('Files'), 'url' => z_root() . '/cloud/' . $nickname, 'sel' => argv(0) == 'cloud' || argv(0) == 'sharedwithme' ? 'active' : '', 'title' => t('Files and Storage'), 'id' => 'files-tab');
    }
    if ($p['view_stream'] && $cal_link) {
        $tabs[] = array('label' => t('Events'), 'url' => z_root() . $cal_link, 'sel' => argv(0) == 'cal' || argv(0) == 'events' ? 'active' : '', 'title' => t('Events'), 'id' => 'event-tab');
    }
    if ($p['chat'] && feature_enabled($uid, 'ajaxchat')) {
        $has_chats = Zotlabs\Lib\Chatroom::list_count($uid);
        if ($has_chats) {
            $tabs[] = array('label' => t('Chatrooms'), 'url' => z_root() . '/chat/' . $nickname, 'sel' => argv(0) == 'chat' ? 'active' : '', 'title' => t('Chatrooms'), 'id' => 'chat-tab');
        }
    }
    require_once 'include/menu.php';
    $has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK);
    if ($is_owner && $has_bookmarks) {
        $tabs[] = array('label' => t('Bookmarks'), 'url' => z_root() . '/bookmarks', 'sel' => argv(0) == 'bookmarks' ? 'active' : '', 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab');
    }
    if ($p['write_pages'] && feature_enabled($uid, 'webpages')) {
        $tabs[] = array('label' => t('Webpages'), 'url' => z_root() . '/webpages/' . $nickname, 'sel' => argv(0) == 'webpages' ? 'active' : '', 'title' => t('Manage Webpages'), 'id' => 'webpages-tab');
    }
    if (feature_enabled($uid, 'wiki') && !UNO) {
        $tabs[] = array('label' => t('Wiki'), 'url' => z_root() . '/wiki/' . $nickname, 'sel' => argv(0) == 'wiki' ? 'active' : '', 'title' => t('Wiki'), 'id' => 'wiki-tab');
    }
    $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab ? $tab : false, 'tabs' => $tabs);
    call_hooks('profile_tabs', $arr);
    $tpl = get_markup_template('common_tabs.tpl');
    return replace_macros($tpl, array('$tabs' => $arr['tabs']));
}
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:66,代码来源:conversation.php


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