ability to like things
This commit is contained in:
parent
d43227a730
commit
0cfcb02311
2
boot.php
2
boot.php
@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
|
||||
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
|
||||
define ( 'ZOT_REVISION', 1 );
|
||||
|
||||
define ( 'DB_UPDATE_VERSION', 1114 );
|
||||
define ( 'DB_UPDATE_VERSION', 1115 );
|
||||
|
||||
define ( 'EOL', '<br />' . "\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
@ -1044,10 +1044,12 @@ function advanced_profile(&$a) {
|
||||
|
||||
$things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']);
|
||||
|
||||
logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
|
||||
// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
|
||||
|
||||
return replace_macros($tpl, array(
|
||||
'$title' => t('Profile'),
|
||||
'$canlike' => (($profile['canlike'])? true : false),
|
||||
'$likethis' => t('Like this thing'),
|
||||
'$profile' => $profile,
|
||||
'$things' => $things
|
||||
));
|
||||
|
@ -322,9 +322,21 @@ function get_things($profile_hash,$uid) {
|
||||
foreach($v as $k => $foo)
|
||||
$things[$k] = null;
|
||||
foreach($r as $rr) {
|
||||
|
||||
$l = q("select xchan_name, xchan_url from likes left join xchan on likee = xchan_hash where
|
||||
target_type = '%s' and target_id = '%s' and channel_id = %d",
|
||||
dbesc(ACTIVITY_OBJ_THING),
|
||||
dbesc($rr['term_hash']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
for($x = 0; $x < count($l); $x ++)
|
||||
$l[$x]['xchan_url'] = zid($l[$x]['xchan_url']);
|
||||
|
||||
if(! $things[$rr['obj_verb']])
|
||||
$things[$rr['obj_verb']] = array();
|
||||
$things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name']);
|
||||
$things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
|
||||
|
||||
}
|
||||
$sorted_things = array();
|
||||
if($things) {
|
||||
@ -335,7 +347,7 @@ function get_things($profile_hash,$uid) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//logger('things: ' . print_r($sorted_things,true));
|
||||
return $sorted_things;
|
||||
|
||||
}
|
@ -581,6 +581,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
|
||||
`iid` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`verb` char(255) NOT NULL DEFAULT '',
|
||||
`target_type` char(255) NOT NULL DEFAULT '',
|
||||
`target_id` char(128) NOT NULL DEFAULT '',
|
||||
`target` mediumtext NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `channel_id` (`channel_id`),
|
||||
@ -588,7 +589,8 @@ CREATE TABLE IF NOT EXISTS `likes` (
|
||||
KEY `likee` (`likee`),
|
||||
KEY `iid` (`iid`),
|
||||
KEY `verb` (`verb`),
|
||||
KEY `target_type` (`target_type`)
|
||||
KEY `target_type` (`target_type`),
|
||||
KEY `target_id` (`target_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mail` (
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1114 );
|
||||
define( 'UPDATE_VERSION' , 1115 );
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1283,3 +1283,11 @@ ADD INDEX ( `channel_id` )");
|
||||
return UPDATE_FAILED;
|
||||
}
|
||||
|
||||
function update_r1114() {
|
||||
$r = q("ALTER TABLE `likes` ADD `target_id` CHAR( 128 ) NOT NULL DEFAULT '' AFTER `target_type` ,
|
||||
ADD INDEX ( `target_id` )");
|
||||
if($r)
|
||||
return UPDATE_SUCCESS;
|
||||
return UPDATE_FAILED;
|
||||
}
|
||||
|
||||
|
11
mod/like.php
11
mod/like.php
@ -151,12 +151,12 @@ function like_content(&$a) {
|
||||
|
||||
// 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 = '%s' limit 1",
|
||||
$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(json_encode(($target)?$target:$object))
|
||||
dbesc($obj_id)
|
||||
);
|
||||
|
||||
if($z) {
|
||||
@ -328,6 +328,10 @@ function like_content(&$a) {
|
||||
|
||||
|
||||
$arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
|
||||
if($obj_type === 'thing' && $r[0]['imgurl']) {
|
||||
$arr['body'] .= "\n\n[zmg=80x80]" . $r[0]['imgurl'] . '[/zmg]';
|
||||
}
|
||||
|
||||
|
||||
$arr['verb'] = $activity;
|
||||
$arr['obj_type'] = $objtype;
|
||||
@ -354,13 +358,14 @@ function like_content(&$a) {
|
||||
|
||||
|
||||
if($extended_like) {
|
||||
$r = q("insert into likes (channel_id,liker,likee,iid,verb,target_type,target) values (%d,'%s','%s',%d,'%s','%s','%s')",
|
||||
$r = q("insert into likes (channel_id,liker,likee,iid,verb,target_type,target_id,target) values (%d,'%s','%s',%d,'%s','%s','%s','%s')",
|
||||
intval($ch[0]['channel_id']),
|
||||
dbesc($observer['xchan_hash']),
|
||||
dbesc($ch[0]['channel_hash']),
|
||||
intval($post_id),
|
||||
dbesc($activity),
|
||||
dbesc(($tgttype)?$tgttype:$objtype),
|
||||
dbesc($obj_id),
|
||||
dbesc(json_encode(($target)?$target:$object))
|
||||
);
|
||||
};
|
||||
|
@ -1743,6 +1743,14 @@ header {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.profile-thing-list img {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.profile-thing-list li {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
div.page-list-item {
|
||||
margin: 20px;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{{if $profile.canlike || $profile.like_count}}
|
||||
<div id="profile-like-wrapper">
|
||||
{{if $profile.canlike}}
|
||||
<button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('profile/' + '{{$profile.profile_guid}}','like'); return false;">
|
||||
<button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('profile/' + '{{$profile.profile_guid}}','like'); return false;" title="{{$profile.likethis}}" >
|
||||
<i class="icon-thumbs-up-alt" title="{{$profile.likethis}}"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
@ -200,6 +200,19 @@
|
||||
{{foreach $items as $item}}
|
||||
<li>{{if $item.img}}<img src="{{$item.img}}" width="100" height="100" alt="{{$item.term}}" />{{/if}}
|
||||
<a href="{{$item.url}}" >{{$item.term}}</a>
|
||||
{{if $profile.canlike}}<br />
|
||||
<button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('thing/' + '{{$item.term_hash}}','like'); return false;" title="{{$likethis}}" >
|
||||
<i class="icon-thumbs-up-alt" title="{{$likethis}}"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
{{if $item.like_count}}
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="thing-like-{{$item.term_hash}}">{{$item.like_count}} {{$item.like_label}}</button>
|
||||
{{if $item.likes}}
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="thing-like-{{$item.term_hash}}">{{foreach $item.likes as $liker}}<li role="presentation"><a href="{{$liker.xchan_url}}">{{$liker.xchan_name}}</a></li>{{/foreach}}</ul>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
@ -6,8 +6,8 @@
|
||||
</div>
|
||||
{{if $canedit}}
|
||||
<div class="thing-edit-links">
|
||||
<a href="thing/edit/{{$thing.term_hash}}" title="{{$edit}}"><i class="icon-pencil thing-edit-icon"></i></a>
|
||||
<a href="thing/drop/{{$thing.term_hash}}" onclick="return confirmDelete();" title="{{$delete}}" ><i class="icon-remove drop-icons"></i></a>
|
||||
<a href="thing/edit/{{$thing.term_hash}}" title="{{$edit}}" class="btn btn-default" ><i class="icon-pencil thing-edit-icon"></i></a>
|
||||
<a href="thing/drop/{{$thing.term_hash}}" onclick="return confirmDelete();" title="{{$delete}}" class="btn btn-default" ><i class="icon-remove drop-icons"></i></a>
|
||||
</div>
|
||||
<div class="thing-edit-links-end"></div>
|
||||
{{/if}}
|
||||
|
Reference in New Issue
Block a user