本文整理汇总了PHP中perm_is_allowed函数的典型用法代码示例。如果您正苦于以下问题:PHP perm_is_allowed函数的具体用法?PHP perm_is_allowed怎么用?PHP perm_is_allowed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了perm_is_allowed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get()
{
$o = '';
if (!\App::$profile['profile_uid']) {
return;
}
$observer_hash = get_observer_hash();
if (!perm_is_allowed(\App::$profile['profile_uid'], $observer_hash, 'view_contacts')) {
notice(t('Permission denied.') . EOL);
return;
}
$o .= '<h2>' . t('Common connections') . '</h2>';
$t = count_common_friends(\App::$profile['profile_uid'], $observer_hash);
if (!$t) {
notice(t('No connections in common.') . EOL);
return $o;
}
$r = common_friends(\App::$profile['profile_uid'], $observer_hash);
if ($r) {
$tpl = get_markup_template('common_friends.tpl');
foreach ($r as $rr) {
$o .= replace_macros($tpl, array('$url' => $rr['xchan_url'], '$name' => $rr['xchan_name'], '$photo' => $rr['xchan_photo_m'], '$tags' => ''));
}
$o .= cleardiv();
}
return $o;
}
示例2: tagadelic
function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG)
{
require_once 'include/security.php';
if (!perm_is_allowed($uid, get_observer_hash(), 'view_stream')) {
return array();
}
$item_normal = item_normal();
$sql_options = item_permissions_sql($uid);
$count = intval($count);
if ($flags) {
if ($flags === 'wall') {
$sql_options .= " and item_wall = 1 ";
}
}
if ($authors) {
if (!is_array($authors)) {
$authors = array($authors);
}
stringify_array_elms($authors, true);
$sql_options .= " and author_xchan in (" . implode(',', $authors) . ") ";
}
if ($owner) {
$sql_options .= " and owner_xchan = '" . dbesc($owner) . "' ";
}
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id\n\t\twhere term.uid = %d and term.ttype = %d \n\t\tand otype = %d and item_type = %d and item_private = 0\n\t\t{$sql_options} {$item_normal}\n\t\tgroup by term order by total desc %s", intval($uid), intval($type), intval(TERM_OBJ_POST), intval($restrict), intval($count) ? "limit {$count}" : '');
if (!$r) {
return array();
}
return Zotlabs\Text\Tagadelic::calc($r);
}
示例3: p_init
function p_init(&$a)
{
if (argc() < 2) {
http_status_exit(401);
}
$mid = str_replace('.xml', '', argv(1));
$r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1", dbesc($mid));
if (!$r || !perm_is_allowed($r[0]['uid'], '', 'view_stream')) {
http_status_exit(404);
}
$c = q("select * from channel where channel_id = %d limit 1", intval($r[0]['uid']));
if (!$c) {
http_status_exit(404);
}
$myaddr = $c[0]['channel_address'] . '@' . App::get_hostname();
$item = $r[0];
$title = $item['title'];
$body = bb2diaspora_itembody($item);
$created = datetime_convert('UTC', 'UTC', $item['created'], 'Y-m-d H:i:s \\U\\T\\C');
$tpl = get_markup_template('diaspora_post.tpl', 'addon/diaspora');
$msg = replace_macros($tpl, array('$body' => xmlify($body), '$guid' => $item['mid'], '$handle' => xmlify($myaddr), '$public' => 'true', '$created' => $created, '$provider' => $item['app'] ? $item['app'] : t('$projectname')));
header('Content-type: text/xml');
echo $msg;
killme();
}
示例4: embedphotos_widget_album
/**
* Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
* the input array as in widget_item()
* @param type $name
* @return string
*/
function embedphotos_widget_album($args)
{
$channel_id = 0;
if (array_key_exists('channel', $args)) {
$channel = $args['channel'];
}
$channel_id = intval($channel['channel_id']);
if (!$channel_id) {
$channel_id = \App::$profile_uid;
}
if (!$channel_id) {
return '';
}
$owner_uid = $channel_id;
require_once 'include/security.php';
$sql_extra = permissions_sql($channel_id);
if (!perm_is_allowed($channel_id, get_observer_hash(), 'view_storage')) {
return '';
}
if ($args['album']) {
$album = $args['album'];
}
if ($args['title']) {
$title = $args['title'];
}
/**
* This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/
if ($album) {
$x = q("select hash from attach where filename = '%s' and uid = %d limit 1", dbesc($album), intval($owner_uid));
if ($x) {
$y = attach_can_view_folder($owner_uid, get_observer_hash(), $x[0]['hash']);
if (!$y) {
return '';
}
}
}
$order = 'DESC';
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN\n\t\t\t\t(SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) {$sql_extra} GROUP BY resource_id) ph \n\t\t\t\tON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)\n\t\t\tORDER BY created {$order}", intval($owner_uid), dbesc($album), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE));
$photos = array();
if (count($r)) {
$twist = 'rotright';
foreach ($r as $rr) {
if ($twist == 'rotright') {
$twist = 'rotleft';
} else {
$twist = 'rotright';
}
$ext = $phototypes[$rr['mimetype']];
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
$imagelink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id'] . ($_GET['order'] === 'posted' ? '?f=&order=posted' : '');
$photos[] = array('id' => $rr['id'], 'twist' => ' ' . $twist . rand(2, 4), 'link' => $imagelink, 'title' => t('View Photo'), 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['imgscale'] . '.' . $ext, 'alt' => $imgalt_e, 'desc' => $desc_e, 'ext' => $ext, 'hash' => $rr['resource_id'], 'unknown' => t('Unknown'));
}
}
$tpl = get_markup_template('photo_album.tpl');
$o .= replace_macros($tpl, array('$photos' => $photos, '$album' => $title ? $title : $album, '$album_id' => rand(), '$album_edit' => array(t('Edit Album'), $album_edit), '$can_post' => false, '$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$profile['channel_address'] . '/upload/' . bin2hex($album)), '$order' => false, '$upload_form' => $upload_form, '$no_fullscreen_btn' => true));
return $o;
}
示例5: get_feed_for
/**
* @brief
*
* @param array $channel
* @param string $observer_hash
* @param array $params
* @return string
*/
function get_feed_for($channel, $observer_hash, $params)
{
if (!channel) {
http_status_exit(401);
}
if ($params['pages']) {
if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'view_pages')) {
http_status_exit(403);
}
} else {
if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'view_stream')) {
http_status_exit(403);
}
}
$items = items_fetch(array('wall' => '1', 'datequery' => $params['end'], 'datequery2' => $params['begin'], 'start' => $params['start'], 'records' => $params['records'], 'direction' => $params['direction'], 'pages' => $params['pages'], 'order' => 'post', 'top' => $params['top'], 'cat' => $params['cat']), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module);
$feed_template = get_markup_template('atom_feed.tpl');
$atom = '';
$atom .= replace_macros($feed_template, array('$version' => xmlify(Zotlabs\Lib\System::get_project_version()), '$red' => xmlify(Zotlabs\Lib\System::get_platform_name()), '$feed_id' => xmlify($channel['xchan_url']), '$feed_title' => xmlify($channel['channel_name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), '$hub' => '', '$salmon' => '', '$name' => xmlify($channel['channel_name']), '$profile_page' => xmlify($channel['xchan_url']), '$mimephoto' => xmlify($channel['xchan_photo_mimetype']), '$photo' => xmlify($channel['xchan_photo_l']), '$thumb' => xmlify($channel['xchan_photo_m']), '$picdate' => '', '$uridate' => '', '$namdate' => '', '$birthday' => '', '$community' => ''));
call_hooks('atom_feed', $atom);
if ($items) {
$type = 'html';
foreach ($items as $item) {
if ($item['item_private']) {
continue;
}
/** @BUG $owner is undefined in this call */
$atom .= atom_entry($item, $type, null, $owner, true);
}
}
call_hooks('atom_feed_end', $atom);
$atom .= '</feed>' . "\r\n";
return $atom;
}
示例6: 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;
}
示例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;
}
示例8: get
function get()
{
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
if (!count(\App::$profile) || \App::$profile['hide_friends']) {
notice(t('Permission denied.') . EOL);
return;
}
if (!perm_is_allowed(\App::$profile['uid'], get_observer_hash(), 'view_contacts')) {
notice(t('Permission denied.') . EOL);
return;
}
if (!$_REQUEST['aj']) {
$_SESSION['return_url'] = \App::$query_string;
}
$is_owner = local_channel() && local_channel() == \App::$profile['uid'] ? true : false;
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
$sql_extra = '';
if (!$is_owner) {
$abook_flags = " and abook_hidden = 0 ";
$sql_extra = " and xchan_hidden = 0 ";
}
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} ", intval(\App::$profile['uid']));
if ($r) {
\App::set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} order by xchan_name LIMIT %d OFFSET %d ", intval(\App::$profile['uid']), intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if (!$r && !$_REQUEST['aj']) {
info(t('No connections.') . EOL);
return $o;
}
$contacts = array();
foreach ($r as $rr) {
$url = chanlink_url($rr['xchan_url']);
if ($url) {
$contacts[] = array('id' => $rr['abook_id'], 'archived' => intval($rr['abook_archived']) ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
}
}
if ($_REQUEST['aj']) {
if ($contacts) {
$o = replace_macros(get_markup_template('viewcontactsajax.tpl'), array('$contacts' => $contacts));
} else {
$o = '<div id="content-complete"></div>';
}
echo $o;
killme();
} else {
$o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
$tpl = get_markup_template("viewcontact_template.tpl");
$o .= replace_macros($tpl, array('$title' => t('View Connections'), '$contacts' => $contacts));
}
if (!$contacts) {
$o .= '<div id="content-complete"></div>';
}
return $o;
}
示例9: viewconnections_content
function viewconnections_content(&$a)
{
if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) {
notice(t('Public access denied.') . EOL);
return;
}
if (!count($a->profile) || $a->profile['hide_friends']) {
notice(t('Permission denied.') . EOL);
return;
}
if (!perm_is_allowed($a->profile['uid'], get_observer_hash(), 'view_contacts')) {
notice(t('Permission denied.') . EOL);
return;
}
if (!$_REQUEST['aj']) {
$_SESSION['return_url'] = $a->query_string;
}
$is_owner = local_channel() && local_channel() == $a->profile['uid'] ? true : false;
$abook_flags = ABOOK_FLAG_PENDING | ABOOK_FLAG_SELF;
$xchan_flags = XCHAN_FLAGS_ORPHAN | XCHAN_FLAGS_DELETED;
if (!$is_owner) {
$abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
$xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
}
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d )>0 and not ( xchan_flags & %d )>0 ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags));
if ($r) {
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d )>0 and not ( xchan_flags & %d )>0 order by xchan_name LIMIT %d OFFSET %d ", intval($a->profile['uid']), intval($abook_flags), intval($xchan_flags), intval($a->pager['itemspage']), intval($a->pager['start']));
if (!$r && !$_REQUEST['aj']) {
info(t('No connections.') . EOL);
return $o;
}
$contacts = array();
foreach ($r as $rr) {
$url = chanlink_url($rr['xchan_url']);
if ($url) {
$contacts[] = array('id' => $rr['abook_id'], 'archived' => $rr['abook_flags'] & ABOOK_FLAG_ARCHIVED ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
}
}
if ($_REQUEST['aj']) {
if ($contacts) {
$o = replace_macros(get_markup_template('viewcontactsajax.tpl'), array('$contacts' => $contacts));
} else {
$o = '<div id="content-complete"></div>';
}
echo $o;
killme();
} else {
$o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
$tpl = get_markup_template("viewcontact_template.tpl");
$o .= replace_macros($tpl, array('$title' => t('View Connections'), '$contacts' => $contacts));
}
if (!$contacts) {
$o .= '<div id="content-complete"></div>';
}
return $o;
}
示例10: set_writeable
/**
* The DAV browser is instantiated after the auth module and directory classes
* but before we know the current directory and who the owner and observer
* are. So we add a pointer to the browser into the auth module and vice versa.
* Then when we've figured out what directory is actually being accessed, we
* call the following function to decide whether or not to show web elements
* which include writeable objects.
*
* @fixme It only disable/enable the visible parts. Not the POST handler
* which handels the actual requests when uploading files or creating folders.
*
* @todo Maybe this whole way of doing this can be solved with some
* $server->subscribeEvent().
*/
public function set_writeable()
{
if (!$this->auth->owner_id) {
$this->enablePost = false;
}
if (!perm_is_allowed($this->auth->owner_id, get_observer_hash(), 'write_storage')) {
$this->enablePost = false;
} else {
$this->enablePost = true;
}
}
示例11: chatsvc_init
function chatsvc_init(&$a)
{
//logger('chatsvc');
$ret = array('success' => false);
$a->data['chat']['room_id'] = intval($_REQUEST['room_id']);
$x = q("select cr_uid from chatroom where cr_id = %d and cr_id != 0 limit 1", intval($a->data['chat']['room_id']));
if (!$x) {
json_return_and_die($ret);
}
$a->data['chat']['uid'] = $x[0]['cr_uid'];
if (!perm_is_allowed($a->data['chat']['uid'], get_observer_hash(), 'chat')) {
json_return_and_die($ret);
}
}
示例12: tagadelic
function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG)
{
require_once 'include/security.php';
if (!perm_is_allowed($uid, get_observer_hash(), 'view_stream')) {
return array();
}
$item_normal = item_normal();
$sql_options = item_permissions_sql($uid);
$count = intval($count);
if ($flags) {
if ($flags === 'wall') {
$sql_options .= " and item_wall = 1 ";
}
}
if ($authors) {
if (!is_array($authors)) {
$authors = array($authors);
}
stringify_array_elms($authors, true);
$sql_options .= " and author_xchan in (" . implode(',', $authors) . ") ";
}
if ($owner) {
$sql_options .= " and owner_xchan = '" . dbesc($owner) . "' ";
}
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id\n\t\twhere term.uid = %d and term.type = %d \n\t\tand otype = %d and item_type = %d and item_private = 0\n\t\t{$sql_options} {$item_normal}\n\t\tgroup by term order by total desc %s", intval($uid), intval($type), intval(TERM_OBJ_POST), intval($restrict), intval($count) ? "limit {$count}" : '');
if (!$r) {
return array();
}
// Find minimum and maximum log-count.
$tags = array();
$min = 1000000000.0;
$max = -1000000000.0;
$x = 0;
foreach ($r as $rr) {
$tags[$x][0] = $rr['term'];
$tags[$x][1] = log($rr['total']);
$tags[$x][2] = 0;
$min = min($min, $tags[$x][1]);
$max = max($max, $tags[$x][1]);
$x++;
}
usort($tags, 'tags_sort');
$range = max(0.01, $max - $min) * 1.0001;
for ($x = 0; $x < count($tags); $x++) {
$tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
}
return $tags;
}
示例13: RedChannelList
/**
* @brief Returns an array with viewable channels.
*
* Get a list of RedDirectory objects with all the channels where the visitor
* has <b>view_storage</b> perms.
*
* @todo Is there any reason why this is not inside RedDirectory class?
* @fixme function name looks like a class name, should we rename it?
*
* @param RedBasicAuth &$auth
* @return array RedDirectory[]
*/
function RedChannelList(&$auth)
{
$ret = array();
$r = q("SELECT channel_id, channel_address FROM channel WHERE NOT (channel_pageflags & %d)>0 AND NOT (channel_pageflags & %d)>0", intval(PAGE_REMOVED), intval(PAGE_HIDDEN));
if ($r) {
foreach ($r as $rr) {
if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage')) {
logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
// @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory
$ret[] = new RedDAV\RedDirectory('/cloud/' . $rr['channel_address'], $auth);
}
}
}
return $ret;
}
示例14: common_friends_visitor_widget
function common_friends_visitor_widget($profile_uid)
{
if (local_channel() == $profile_uid) {
return;
}
$observer_hash = get_observer_hash();
if (!$observer_hash || !perm_is_allowed($profile_uid, $observer_hash, 'view_contacts')) {
return;
}
require_once 'include/socgraph.php';
$t = count_common_friends($profile_uid, $observer_hash);
if (!$t) {
return;
}
$r = common_friends($profile_uid, $observer_hash, 0, 5, true);
return replace_macros(get_markup_template('remote_friends_common.tpl'), array('$desc' => sprintf(tt("%d connection in common", "%d connections in common", $t), $t), '$base' => z_root(), '$uid' => $profile_uid, '$cid' => $observer, '$linkmore' => $t > 5 ? 'true' : '', '$more' => t('show more'), '$items' => $r));
}
示例15: block_content
function block_content(&$a)
{
if (!perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), '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 = 'BUILDBLOCK' and \n\t\titem_type = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_BLOCK));
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 = 'BUILDBLOCK' and \n\t\titem_type = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_BLOCK));
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;
}
xchan_query($r);
$r = fetch_post_tags($r, true);
$o .= prepare_page($r[0]);
return $o;
}