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


PHP App::get_observer方法代码示例

本文整理汇总了PHP中App::get_observer方法的典型用法代码示例。如果您正苦于以下问题:PHP App::get_observer方法的具体用法?PHP App::get_observer怎么用?PHP App::get_observer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


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

示例1: dirstats_content

function dirstats_content(&$a)
{
    $hubcount = get_config('dirstats', 'hubcount');
    $zotcount = get_config('dirstats', 'zotcount');
    $friendicacount = get_config('dirstats', 'friendicacount');
    $diasporacount = get_config('dirstats', 'diasporacount');
    $channelcount = get_config('dirstats', 'channelcount');
    $friendicachannelcount = get_config('dirstats', 'friendicachannelcount');
    $diasporachannelcount = get_config('dirstats', 'diasporachannelcount');
    $over35s = get_config('dirstats', 'over35s');
    $under35s = get_config('dirstats', 'under35s');
    $average = get_config('dirstats', 'averageage');
    $chatrooms = get_config('dirstats', 'chatrooms');
    $tags = get_config('dirstats', 'tags');
    $ob = App::get_observer();
    $observer = $ob['xchan_hash'];
    // Requested by Martin
    $fountainofyouth = get_xconfig($observer, 'dirstats', 'averageage');
    if (intval($fountainofyouth)) {
        $average = $fountainofyouth;
    }
    if (argv(1) == 'json') {
        $dirstats = array('hubcount' => $hubcount, 'zotcount' => $zotcount, 'friendicacount' => $friendicacount, 'diasporacount' => $diasporacount, 'channelcount' => $channelcount, 'friendicachannelcount' => $friendicachannelcount, 'diasporachannelcount' => $diasporachannelcount, 'over35s' => $over35s, 'under35s' => $under35s, 'average' => $average, 'chatrooms' => $chatrooms, 'tags' => $tags);
        echo json_return_and_die($dirstats);
    } elseif (argv(1) == 'genpost' && get_config('dirstats', 'allowfiledump')) {
        $result = '[b]Hub count[/b] : ' . $hubcount . "\n" . '[b]Hubzilla Hubs[/b] : ' . $zotcount . "\n" . '[b]Friendica Hubs[/b] : ' . $friendicacount . "\n" . '[b]Diaspora Pods[/b] : ' . $diasporacount . "\n" . '[b]Hubzilla Channels[/b] : ' . $channelcount . "\n" . '[b]Friendica Profiles[/b] : ' . $friendicachannelcount . "\n" . '[b]Diaspora Profiles[/b] : ' . $diasporachannelcount . "\n" . '[b]People aged 35 and above[/b] : ' . $over35s . "\n" . '[b]People aged 34 and below[/b] : ' . $under35s . "\n" . '[b]Average Age[/b] : ' . $average . "\n" . '[b]Known Chatrooms[/b] : ' . $chatrooms . "\n" . '[b]Unique Profile Tags[/b] : ' . $tags . "\n";
        file_put_contents('genpost', $result);
    } else {
        $tpl = get_markup_template("dirstats.tpl", "addon/dirstats/");
        return replace_macros($tpl, array('$title' => t('Hubzilla Directory Stats'), '$hubtitle' => t('Total Hubs'), '$hubcount' => $hubcount, '$zotlabel' => t('Hubzilla Hubs'), '$zotcount' => $zotcount, '$friendicalabel' => t('Friendica Hubs'), '$friendicacount' => $friendicacount, '$diasporalabel' => t('Diaspora Pods'), '$diasporacount' => $diasporacount, '$zotchanlabel' => t('Hubzilla Channels'), '$channelcount' => $channelcount, '$friendicachanlabel' => t('Friendica Channels'), '$friendicachannelcount' => $friendicachannelcount, '$diasporachanlabel' => t('Diaspora Channels'), '$diasporachannelcount' => $diasporachannelcount, '$over35label' => t('Aged 35 and above'), '$over35s' => $over35s, '$under35label' => t('Aged 34 and under'), '$under35s' => $under35s, '$averageagelabel' => t('Average Age'), '$average' => $average, '$chatlabel' => t('Known Chatrooms'), '$chatrooms' => $chatrooms, '$tagslabel' => t('Known Tags'), '$tags' => $tags, '$disclaimer' => t('Please note Diaspora and Friendica statistics are merely those **this directory** is aware of, and not all those known in the network.  This also applies to chatrooms,')));
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:32,代码来源:dirstats.php

示例2: set_mode

 /**
  * Set the mode we'll be displayed on
  */
 private function set_mode($mode)
 {
     if ($this->get_mode() == $mode) {
         return;
     }
     $a = $this->get_app();
     $this->observer = App::get_observer();
     $ob_hash = $this->observer ? $this->observer['xchan_hash'] : '';
     switch ($mode) {
         case 'network':
             $this->profile_owner = local_channel();
             $this->writable = true;
             break;
         case 'channel':
             $this->profile_owner = App::$profile['profile_uid'];
             $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
             break;
         case 'display':
             // in this mode we set profile_owner after initialisation (from conversation()) and then
             // pull some trickery which allows us to re-invoke this function afterward
             // it's an ugly hack so FIXME
             $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
             break;
         case 'page':
             $this->profile_owner = App::$profile['uid'];
             $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
             break;
         default:
             logger('[ERROR] Conversation::set_mode : Unhandled mode (' . $mode . ').', LOGGER_DEBUG);
             return false;
             break;
     }
     $this->mode = $mode;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:37,代码来源:ConversationObject.php

示例3: post

 function post()
 {
     $using_api = false;
     if (\App::$data['api_info'] && array_key_exists('media', $_FILES)) {
         $using_api = true;
         $user_info = \App::$data['api_info'];
         $nick = $user_info['screen_name'];
         $channel = get_channel_by_nick($user_info['screen_name']);
     } elseif (argc() > 1) {
         $channel = get_channel_by_nick(argv(1));
     }
     if (!$channel) {
         killme();
     }
     $observer = \App::get_observer();
     $def_album = get_pconfig($channel['channel_id'], 'system', 'photo_path');
     $def_attach = get_pconfig($channel['channel_id'], 'system', 'attach_path');
     $r = attach_store($channel, $observer ? $observer['xchan_hash'] : '', '', array('source' => 'editor', 'visible' => 0, 'album' => $def_album, 'directory' => $def_attach, 'allow_cid' => '<' . $channel['channel_hash'] . '>'));
     if (!$r['success']) {
         notice($r['message'] . EOL);
         killme();
     }
     if (intval($r['data']['is_photo'])) {
         $s = "\n\n" . $r['body'] . "\n\n";
     } else {
         $s = "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
     }
     if ($using_api) {
         return $s;
     }
     echo $s;
     killme();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:33,代码来源:Wall_attach.php

示例4: init

 function init()
 {
     $result = array('success' => false);
     $mindate = $_REQUEST['mindate'] ? datetime_convert('UTC', 'UTC', $_REQUEST['mindate']) : '';
     if (!$mindate) {
         $mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
     }
     if (observer_prohibited()) {
         $result['message'] = 'Public access denied';
         json_return_and_die($result);
     }
     $observer = \App::get_observer();
     $channel_address = argc() > 1 ? argv(1) : '';
     if ($channel_address) {
         $r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc(argv(1)));
     } else {
         $x = get_sys_channel();
         if ($x) {
             $r = array($x);
         }
         $mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
     }
     if (!$r) {
         $result['message'] = 'Channel not found.';
         json_return_and_die($result);
     }
     logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
     $result['messages'] = zot_feed($r[0]['channel_id'], $observer['xchan_hash'], array('mindate' => $mindate));
     $result['success'] = true;
     json_return_and_die($result);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:31,代码来源:Zotfeed.php

示例5: 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

示例6: get

 function get()
 {
     // 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($which, $profile);
     $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
     if ($r) {
         $owner = intval($r[0]['channel_id']);
     }
     $observer = \App::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:BlaBlaNet,项目名称:hubzilla,代码行数:59,代码来源:Achievements.php

示例7: 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 && $owner)) {
         notice(t('Item not found') . EOL);
         return;
     }
     $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner));
     if ($itm) {
         $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", intval($itm[0]['id']));
         if ($item_id) {
             $block_title = $item_id[0]['sid'];
         }
     } else {
         notice(t('Item not found') . EOL);
         return;
     }
     $mimetype = $itm[0]['mimetype'];
     $rp = 'blocks/' . $channel['channel_address'];
     $x = array('nickname' => $channel['channel_address'], 'bbco_autocomplete' => $mimetype == 'text/bbcode' ? 'bbcode' : 'comanche-block', 'return_path' => $rp, 'webpage' => ITEM_TYPE_BLOCK, 'ptlabel' => t('Block Name'), 'button' => t('Edit'), 'writefiles' => $mimetype == 'text/bbcode' ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false, 'weblink' => $mimetype == 'text/bbcode' ? t('Insert web link') : false, 'hide_voting' => true, 'hide_future' => true, 'hide_location' => true, 'hide_expire' => true, 'showacl' => false, 'ptyp' => $itm[0]['type'], 'mimeselect' => true, 'mimetype' => $itm[0]['mimetype'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, 'visitor' => true, 'title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), 'placeholdertitle' => t('Title (optional)'), 'pagetitle' => $block_title, 'profile_uid' => intval($channel['channel_id']), 'bbcode' => $mimetype == 'text/bbcode' ? true : false);
     $editor = status_editor($a, $x);
     $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Block'), '$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,代码行数:58,代码来源:Editblock.php

示例8: get

 function get()
 {
     if (!local_channel()) {
         if (remote_channel()) {
             $observer = \App::get_observer();
             if ($observer && $observer['xchan_url']) {
                 $parsed = @parse_url($observer['xchan_url']);
                 if (!$parsed) {
                     notice(t('Unable to find your hub.') . EOL);
                     return;
                 }
                 $url = $parsed['scheme'] . '://' . $parsed['host'] . ($parsed['port'] ? ':' . $parsed['port'] : '');
                 $url .= '/oexchange';
                 $result = z_post_url($url, $_REQUEST);
                 json_return_and_die($result);
             }
         }
         return login(false);
     }
     if (argc() > 1 && argv(1) === 'done') {
         info(t('Post successful.') . EOL);
         return;
     }
     $url = x($_REQUEST, 'url') && strlen($_REQUEST['url']) ? urlencode(notags(trim($_REQUEST['url']))) : '';
     $title = x($_REQUEST, 'title') && strlen($_REQUEST['title']) ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '';
     $description = x($_REQUEST, 'description') && strlen($_REQUEST['description']) ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '';
     $tags = x($_REQUEST, 'tags') && strlen($_REQUEST['tags']) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '';
     $ret = z_fetch_url(z_root() . '/urlinfo?f=&url=' . $url . $title . $description . $tags);
     if ($ret['success']) {
         $s = $ret['body'];
     }
     if (!strlen($s)) {
         return;
     }
     $post = array();
     $post['profile_uid'] = local_channel();
     $post['return'] = '/oexchange/done';
     $post['body'] = $s;
     $post['type'] = 'wall';
     $_REQUEST = $post;
     $mod = new Item();
     $mod->post();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:43,代码来源:Oexchange.php

示例9: connect_content

function connect_content(&$a)
{
    $edit = local_channel() && local_channel() == App::$data['channel']['channel_id'] ? true : false;
    $text = get_pconfig(App::$data['channel']['channel_id'], 'system', 'selltext');
    if ($edit) {
        $o = replace_macros(get_markup_template('sellpage_edit.tpl'), array('$header' => t('Premium Channel Setup'), '$address' => App::$data['channel']['channel_address'], '$premium' => array('premium', t('Enable premium channel connection restrictions'), App::$data['channel']['channel_pageflags'] & PAGE_PREMIUM ? '1' : '', ''), '$lbl_about' => t('Please enter your restrictions or conditions, such as paypal receipt, usage guidelines, etc.'), '$text' => $text, '$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'), '$lbl2' => t('Potential connections will then see the following text before proceeding:'), '$desc2' => t('By continuing, I certify that I have complied with any instructions provided on this page.'), '$submit' => t('Submit')));
        return $o;
    } else {
        if (!$text) {
            $text = t('(No specific instructions have been provided by the channel owner.)');
        }
        $submit = replace_macros(get_markup_template('sellpage_submit.tpl'), array('$continue' => t('Continue'), '$address' => App::$data['channel']['channel_address']));
        $o = replace_macros(get_markup_template('sellpage_view.tpl'), array('$header' => t('Restricted or Premium Channel'), '$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'), '$text' => prepare_text($text), '$desc2' => t('By continuing, I certify that I have complied with any instructions provided on this page.'), '$submit' => $submit));
        $arr = array('channel' => App::$data['channel'], 'observer' => App::get_observer(), 'sellpage' => $o, 'submit' => $submit);
        call_hooks('connect_premium', $arr);
        $o = $arr['sellpage'];
    }
    return $o;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:19,代码来源:connect.php

示例10: init

 function init()
 {
     if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) {
         return;
     }
     $o = '';
     if (argc() > 1) {
         $nick = argv(1);
         profile_load($a, $nick);
         $channelx = channelx_by_nick($nick);
         if (!$channelx) {
             return;
         }
         \App::$data['channel'] = $channelx;
         $observer = \App::get_observer();
         \App::$data['observer'] = $observer;
         $observer_xchan = $observer ? $observer['xchan_hash'] : '';
         head_set_icon(\App::$data['channel']['xchan_photo_s']);
         \App::$page['htmlhead'] .= "<script> var profile_uid = " . (\App::$data['channel'] ? \App::$data['channel']['channel_id'] : 0) . "; </script>";
     }
     return;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:22,代码来源:Cal.php

示例11: init

 function init()
 {
     if (observer_prohibited()) {
         return;
     }
     $o = '';
     if (argc() > 1) {
         $nick = argv(1);
         profile_load($nick);
         $channelx = channelx_by_nick($nick);
         if (!$channelx) {
             return;
         }
         \App::$data['channel'] = $channelx;
         $observer = \App::get_observer();
         \App::$data['observer'] = $observer;
         $observer_xchan = $observer ? $observer['xchan_hash'] : '';
         head_set_icon(\App::$data['channel']['xchan_photo_s']);
         \App::$page['htmlhead'] .= "<script> var profile_uid = " . (\App::$data['channel'] ? \App::$data['channel']['channel_id'] : 0) . "; </script>";
     }
     return;
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:22,代码来源:Cal.php

示例12: post

 function post()
 {
     $using_api = x($_FILES, 'media') ? true : false;
     if ($using_api) {
         require_once 'include/api.php';
         $user_info = api_get_user($a);
         $nick = $user_info['screen_name'];
     } else {
         if (argc() > 1) {
             $nick = argv(1);
         }
     }
     $channel = $nick ? get_channel_by_nick($nick) : false;
     if (!$channel) {
         if ($using_api) {
             return;
         }
         notice(t('Channel not found.') . EOL);
         killme();
     }
     $observer = \App::get_observer();
     $args = array('source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
     $ret = photo_upload($channel, $observer, $args);
     if (!$ret['success']) {
         if ($using_api) {
             return;
         }
         notice($ret['message']);
         killme();
     }
     if ($using_api) {
         return "\n\n" . $ret['body'] . "\n\n";
     } else {
         echo "\n\n" . $ret['body'] . "\n\n";
     }
     killme();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:37,代码来源:Wall_upload.php

示例13: get

 function get($update = 0, $load = false)
 {
     if ($load) {
         $_SESSION['loadtime'] = datetime_convert();
     }
     $checkjs = new \Zotlabs\Web\CheckJS(1);
     $category = $datequery = $datequery2 = '';
     $mid = x($_REQUEST, 'mid') ? $_REQUEST['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 (observer_prohibited(true)) {
         return login();
     }
     $category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
     $hashtags = x($_REQUEST, 'tag') ? $_REQUEST['tag'] : '';
     $groups = array();
     $o = '';
     if ($update) {
         // Ensure we've got a profile owner if updating.
         \App::$profile['profile_uid'] = \App::$profile_uid = $update;
     } else {
         if (\App::$profile['profile_uid'] == local_channel()) {
             nav_set_selected('home');
         }
     }
     $is_owner = local_channel() && \App::$profile['profile_uid'] == local_channel() ? true : false;
     $channel = \App::get_channel();
     $observer = \App::get_observer();
     $ob_hash = $observer ? $observer['xchan_hash'] : '';
     $perms = get_all_perms(\App::$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/" . \App::$profile['channel_address']);
         }
         notice(t('Permission denied.') . EOL);
         return;
     }
     if (!$update) {
         $o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
         $o .= common_friends_visitor_widget(\App::$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(\App::$profile['profile_uid'], 'system', 'use_browser_location')) ? true : false, 'default_location' => $is_owner ? \App::$profile['channel_location'] : '', 'nickname' => \App::$profile['channel_address'], 'lockstate' => strlen(\App::$profile['channel_allow_cid']) || strlen(\App::$profile['channel_allow_gid']) || strlen(\App::$profile['channel_deny_cid']) || strlen(\App::$profile['channel_deny_gid']) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : '', 'showacl' => $is_owner ? 'yes' : '', 'bang' => '', 'visitor' => $is_owner || $observer ? true : false, 'profile_uid' => \App::$profile['profile_uid'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
             $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
      */
     $item_normal = item_normal();
     $sql_extra = item_permissions_sql(\App::$profile['profile_uid']);
     if (get_pconfig(\App::$profile['profile_uid'], 'system', 'channel_list_mode') && !$mid) {
         $page_mode = 'list';
     } else {
         $page_mode = 'client';
     }
     $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
     $simple_update = $update ? " AND item_unseen = 1 " : '';
     \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
     if ($update && $_SESSION['loadtime']) {
         $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' )  OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
     }
     if ($load) {
         $simple_update = '';
     }
     if ($update && !$load) {
         if ($mid) {
             $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 AND item_unseen = 1 {$sql_extra} limit 1", dbesc($mid . '%'), intval(\App::$profile['profile_uid']));
         } else {
             $r = q("SELECT distinct parent AS `item_id`, created from item\n\t\t\t\t\tleft join abook on ( item.owner_xchan = abook.abook_xchan {$abook_uids} )\n\t\t\t\t\tWHERE uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 {$simple_update}\n\t\t\t\t\tAND (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\tORDER BY created DESC", intval(\App::$profile['profile_uid']));
             $_SESSION['loadtime'] = datetime_convert();
         }
     } else {
         if (x($category)) {
             $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
         }
         if (x($hashtags)) {
             $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
         }
         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_channel(), 'system', 'itemspage');
         \App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
         $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
         if ($load || $checkjs->disabled()) {
             if ($mid) {
                 $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d {$item_normal}\n\t\t\t\t\t\tAND item_wall = 1 {$sql_extra} limit 1", dbesc($mid), intval(\App::$profile['profile_uid']));
                 if (!$r) {
                     notice(t('Permission denied.') . EOL);
                 }
//.........这里部分代码省略.........
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:101,代码来源:Channel.php

示例14: map_shareUserLocation

/**
 * API: map_shareUserLocation
 * Share real-time location data by generating an access token and posting it. 
 * $data contains the ACL specified by the user. The access token is returned
 * @param type $data
 */
function map_shareUserLocation($data)
{
    $resource_type = 'locserv';
    $token = random_string();
    //Extract the ACL for permissions
    $args = array();
    $args['allow_cid'] = perms2str($data['contact_allow']);
    $args['allow_gid'] = perms2str($data['group_allow']);
    $args['deny_cid'] = perms2str($data['contact_deny']);
    $args['deny_gid'] = perms2str($data['group_deny']);
    $args['token'] = $token;
    array_key_exists('token', $args) ? $token = $args['token'] : ($token = '');
    $channel = App::get_channel();
    $observer = App::get_observer();
    $acl = new Zotlabs\Access\AccessList($channel);
    if (array_key_exists('allow_cid', $args)) {
        $acl->set($args);
    }
    $ac = $acl->get();
    $mid = item_message_id();
    // Generate a unique message ID
    $arr = array();
    // Initialize the array of parameters for the post
    // If this were an actual location, ACTIVITY_OBJ_LOCATION would make sense,
    // but since this is actually an access token to retrieve location data, we'll
    // have to use something more vague
    $objtype = ACTIVITY_OBJ_THING;
    //check if item for this object exists
    $y = q("SELECT mid FROM item WHERE obj_type = '%s' AND resource_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1", dbesc(ACTIVITY_POST), dbesc($resource_type), dbesc($token), intval($channel['channel_id']));
    if ($y) {
        notice('Error posting access token. Item already exists.');
        logger('map plugin: Error posting access token. item already exists: ' . json_encode($y));
        die;
    }
    $body = $channel['channel_name'] . ' shared their location with you. ';
    $link = z_root() . '/map/?action=getLatestLocation&token=' . $token;
    /*
     * The local map plugin link for the receiver only needs the token. The plugin
     * will look up the stored item table record and use the object->locationDataType
     * to determine what kind of location data has been shared. This will allow it
     * to make the proper request for data to the sharer's hub. For example, if the
     * object->locationDataType is a dynamicMarker, then the receiver will request
     * only the most recent location associated with that token
     */
    $body .= '[url=' . z_root() . '/map?action=getLatestLocation&token=' . $token . ']Click here to view[/url]';
    // Encode object according to Activity Streams: http://activitystrea.ms/specs/json/1.0/
    $object = json_encode(array('type' => $objtype, 'title' => 'location data access token', 'locationDataType' => 'dynamicMarker', 'id' => $token, 'url' => $link));
    if (intval($data['visible']) || $data['visible'] === 'true') {
        $visible = 1;
    } else {
        $visible = 0;
    }
    $item_hidden = $visible ? 0 : 1;
    $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'] = $resource_type;
    $arr['resource_id'] = $token;
    $arr['owner_xchan'] = $channel['channel_hash'];
    $arr['author_xchan'] = $observer['xchan_hash'];
    $arr['title'] = 'Shared Location';
    $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'] = 0;
    $arr['item_origin'] = 1;
    $arr['item_thread_top'] = 1;
    $arr['item_private'] = intval($acl->is_private());
    $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
    $arr['verb'] = ACTIVITY_POST;
    $arr['obj_type'] = $objtype;
    $arr['object'] = $object;
    $arr['body'] = $body;
    $post = item_store($arr);
    $item_id = $post['item_id'];
    if ($item_id) {
        proc_run('php', "include/notifier.php", "activity", $item_id);
        echo json_encode(array('item' => $arr, 'status' => true));
    } else {
        echo json_encode(array('item' => null, 'status' => false));
    }
    die;
}
开发者ID:anaqreon,项目名称:ownmapp,代码行数:92,代码来源:map.php

示例15: recursive_activity_recipients

/**
 * @brief Returns array of channels which have recursive permission for a file
 *
 * @param $arr_allow_cid
 * @param $arr_allow_gid
 * @param $arr_deny_cid
 * @param $arr_deny_gid
 * @param $folder_hash
 */
function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash)
{
    $ret = array();
    $parent_arr = array();
    $count_values = array();
    $poster = App::get_observer();
    //turn allow_gid into allow_cid's
    foreach ($arr_allow_gid as $gid) {
        $in_group = group_get_members($gid);
        $arr_allow_cid = array_unique(array_merge($arr_allow_cid, $in_group));
    }
    $count = 0;
    while ($folder_hash) {
        $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s' LIMIT 1", dbesc($folder_hash));
        //only process private folders
        if ($x[0]['allow_cid'] || $x[0]['allow_gid'] || $x[0]['deny_cid'] || $x[0]['deny_gid']) {
            $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']);
            $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']);
            /**
             * @TODO should find a much better solution for the allow_cid <-> allow_gid problem.
             * Do not use allow_gid for now. Instead lookup the members of the group directly and add them to allow_cid.
             * */
            if ($parent_arr['allow_gid']) {
                foreach ($parent_arr['allow_gid'][$count] as $gid) {
                    $in_group = group_get_members($gid);
                    $parent_arr['allow_cid'][$count] = array_unique(array_merge($parent_arr['allow_cid'][$count], $in_group));
                }
            }
            $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']);
            $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']);
            $count++;
        }
        $folder_hash = $x[0]['folder'];
    }
    //if none of the parent folders is private just return file perms
    if (!$parent_arr['allow_cid'] && !$parent_arr['allow_gid'] && !$parent_arr['deny_cid'] && !$parent_arr['deny_gid']) {
        $ret['allow_gid'] = $arr_allow_gid;
        $ret['allow_cid'] = $arr_allow_cid;
        $ret['deny_gid'] = $arr_deny_gid;
        $ret['deny_cid'] = $arr_deny_cid;
        return $ret;
    }
    //if there are no perms on the file we get them from the first parent folder
    if (!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) {
        $arr_allow_cid = $parent_arr['allow_cid'][0];
        $arr_allow_gid = $parent_arr['allow_gid'][0];
        $arr_deny_cid = $parent_arr['deny_cid'][0];
        $arr_deny_gid = $parent_arr['deny_gid'][0];
    }
    //allow_cid
    $r_arr_allow_cid = false;
    foreach ($parent_arr['allow_cid'] as $folder_arr_allow_cid) {
        foreach ($folder_arr_allow_cid as $ac_hash) {
            $count_values[$ac_hash]++;
        }
    }
    foreach ($arr_allow_cid as $fac_hash) {
        if ($count_values[$fac_hash] == $count) {
            $r_arr_allow_cid[] = $fac_hash;
        }
    }
    //allow_gid
    $r_arr_allow_gid = false;
    foreach ($parent_arr['allow_gid'] as $folder_arr_allow_gid) {
        foreach ($folder_arr_allow_gid as $ag_hash) {
            $count_values[$ag_hash]++;
        }
    }
    foreach ($arr_allow_gid as $fag_hash) {
        if ($count_values[$fag_hash] == $count) {
            $r_arr_allow_gid[] = $fag_hash;
        }
    }
    //deny_gid
    foreach ($parent_arr['deny_gid'] as $folder_arr_deny_gid) {
        $r_arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid);
    }
    $r_arr_deny_gid = array_unique($r_arr_deny_gid);
    //deny_cid
    foreach ($parent_arr['deny_cid'] as $folder_arr_deny_cid) {
        $r_arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid);
    }
    $r_arr_deny_cid = array_unique($r_arr_deny_cid);
    //if none is allowed restrict to self
    if ($r_arr_allow_gid === false && $r_arr_allow_cid === false) {
        $ret['allow_cid'] = $poster['xchan_hash'];
    } else {
        $ret['allow_gid'] = $r_arr_allow_gid;
        $ret['allow_cid'] = $r_arr_allow_cid;
        $ret['deny_gid'] = $r_arr_deny_gid;
        $ret['deny_cid'] = $r_arr_deny_cid;
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:attach.php


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