sort out some permissions, comments, fetch
This commit is contained in:
parent
8e22178b8a
commit
4e40156607
|
@ -84,6 +84,7 @@ function item_display(&$a, $item,$template,$comment) {
|
||||||
'$thumb' => $thumb,
|
'$thumb' => $thumb,
|
||||||
'$body' => bbcode($item['body']),
|
'$body' => bbcode($item['body']),
|
||||||
'$ago' => relative_date($item['created']),
|
'$ago' => relative_date($item['created']),
|
||||||
|
'$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''),
|
||||||
'$comment' => $comment
|
'$comment' => $comment
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -92,12 +93,13 @@ function item_display(&$a, $item,$template,$comment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function profile_content(&$a) {
|
function profile_content(&$a) {
|
||||||
|
|
||||||
require_once("include/bbcode.php");
|
require_once("include/bbcode.php");
|
||||||
require_once('include/security.php');
|
require_once('include/security.php');
|
||||||
|
|
||||||
|
$groups = array();
|
||||||
|
|
||||||
$tab = 'posts';
|
$tab = 'posts';
|
||||||
|
|
||||||
if(x($_GET,'tab'))
|
if(x($_GET,'tab'))
|
||||||
|
@ -110,8 +112,10 @@ function profile_content(&$a) {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(remote_user())
|
if(remote_user()) {
|
||||||
$contact_id = $_SESSION['visitor_id'];
|
$contact_id = $_SESSION['visitor_id'];
|
||||||
|
$groups = init_groups_visitor($contact_id);
|
||||||
|
}
|
||||||
if(local_user()) {
|
if(local_user()) {
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
|
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
|
||||||
$_SESSION['uid']
|
$_SESSION['uid']
|
||||||
|
@ -139,49 +143,95 @@ function profile_content(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($a->profile['is-default']) {
|
dbg(2);
|
||||||
|
|
||||||
// TODO left join with contact which will carry names and photos. (done)Store local users in contact as well as user.(done)
|
// TODO
|
||||||
// Alter registration and settings
|
// Alter registration and settings
|
||||||
// and profile to update contact table when names and photos change.
|
// and profile to update contact table when names and photos change.
|
||||||
// work on item_display and can_write_wall
|
// work on item_display and can_write_wall
|
||||||
|
|
||||||
// Add comments.
|
// Add comments.
|
||||||
|
|
||||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`,
|
// default - anonymous user
|
||||||
`contact`.`uid` AS `contact-uid`
|
|
||||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
|
||||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1
|
|
||||||
AND `contact`.`blocked` = 0
|
// Profile owner - everything is visible
|
||||||
AND `allow_uid` = '' AND `allow_gid` = '' AND `deny_uid` = '' AND `deny_gid` = ''
|
|
||||||
GROUP BY `item`.`parent`, `item`.`id`
|
if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid']))
|
||||||
ORDER BY `created` DESC LIMIT 0,30 ",
|
$sql_extra = '';
|
||||||
intval($a->profile['uid'])
|
|
||||||
|
// authenticated visitor - here lie dragons
|
||||||
|
|
||||||
|
elseif(remote_user()) {
|
||||||
|
$gs = '<<>>'; // should be impossible to match
|
||||||
|
if(count($groups)) {
|
||||||
|
foreach($groups as $g)
|
||||||
|
$gs .= '|<' . dbesc($g) . '>';
|
||||||
|
}
|
||||||
|
$sql_extra = sprintf(
|
||||||
|
" AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
|
||||||
|
AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
|
||||||
|
AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
|
||||||
|
AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
|
||||||
|
|
||||||
|
intval($visitor_id),
|
||||||
|
intval($visitor_id),
|
||||||
|
$gs,
|
||||||
|
$gs
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = q("SELECT COUNT(*) AS `total`
|
||||||
|
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||||
|
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||||
|
AND `contact`.`blocked` = 0
|
||||||
|
$sql_extra ",
|
||||||
|
intval($a->profile['uid'])
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
if(count($r))
|
||||||
|
$a->set_pager_total($r[0]['total']);
|
||||||
|
|
||||||
|
|
||||||
|
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||||
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`,
|
||||||
|
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||||
|
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||||
|
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||||
|
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||||
|
AND `contact`.`blocked` = 0
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
|
||||||
|
intval($a->profile['uid']),
|
||||||
|
intval($a->pager['start']),
|
||||||
|
intval($a->pager['itemspage'])
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$template = file_get_contents('view/comment_item.tpl');
|
$template = file_get_contents('view/comment_item.tpl');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tpl = file_get_contents('view/wall_item.tpl');
|
$tpl = file_get_contents('view/wall_item.tpl');
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
if(can_write_wall($a,$a->profile['profile_uid'])) {
|
if(can_write_wall($a,$a->profile['profile_uid'])) {
|
||||||
$comment = replace_macros($template,array(
|
$comment = replace_macros($template,array(
|
||||||
'$id' => $rr['item_id'],
|
'$id' => $rr['item_id'],
|
||||||
|
'$parent' => $rr['parent'],
|
||||||
'$profile_uid' => $a->profile['profile_uid']
|
'$profile_uid' => $a->profile['profile_uid']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$comment = '';
|
$comment = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= item_display($a,$rr,$tpl,$comment);
|
$o .= item_display($a,$rr,$tpl,$comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
$o .= paginate($a);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
|
|
2
update.sql
Normal file
2
update.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `item` CHANGE `allow_uid` `allow_cid` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
|
||||||
|
CHANGE `deny_uid` `deny_cid` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
|
|
@ -4,7 +4,7 @@
|
||||||
<form class="comment-edit-form" id="comment-edit-form-$id" action="item" method="post" >
|
<form class="comment-edit-form" id="comment-edit-form-$id" action="item" method="post" >
|
||||||
<input type="hidden" name="type" value="jot" />
|
<input type="hidden" name="type" value="jot" />
|
||||||
<input type="hidden" name="profile_uid" value="$profile_uid" />
|
<input type="hidden" name="profile_uid" value="$profile_uid" />
|
||||||
<input type="hidden" name="parent" value="$id" />
|
<input type="hidden" name="parent" value="$parent" />
|
||||||
<textarea rows="3" cols="40" id="comment-edit-text-$id" name="body" ></textarea>
|
<textarea rows="3" cols="40" id="comment-edit-text-$id" name="body" ></textarea>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,10 @@ input#dfrn-url {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wall-item-comment-outside-wrapper {
|
||||||
|
margin-left: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
.wall-item-photo-wrapper {
|
.wall-item-photo-wrapper {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="wall-item-outside-wrapper" id="wall-item-outside-wrapper-$id" >
|
<div class="wall-item-$indentoutside-wrapper" id="wall-item-outside-wrapper-$id" >
|
||||||
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" >
|
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" >
|
||||||
<a href="$profile_url" title="View $name's profile" class="wall-item-photo-link" id="wall-item-photo-link-$id">
|
<a href="$profile_url" title="View $name's profile" class="wall-item-photo-link" id="wall-item-photo-link-$id">
|
||||||
<img src="$thumb" class="wall-item-photo" id="wall-item-photo-$id" height="80" width="80" alt="$name" /></a>
|
<img src="$thumb" class="wall-item-photo" id="wall-item-photo-$id" height="80" width="80" alt="$name" /></a>
|
||||||
|
@ -13,5 +13,5 @@ $comment
|
||||||
</div>
|
</div>
|
||||||
<div class="wall-item-wrapper-end"></div>
|
<div class="wall-item-wrapper-end"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wall-item-outside-wrapper-end" ></div>
|
<div class="wall-item-$indentoutside-wrapper-end" ></div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue