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 ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
|
||||||
define ( 'ZOT_REVISION', 1 );
|
define ( 'ZOT_REVISION', 1 );
|
||||||
|
|
||||||
define ( 'DB_UPDATE_VERSION', 1114 );
|
define ( 'DB_UPDATE_VERSION', 1115 );
|
||||||
|
|
||||||
define ( 'EOL', '<br />' . "\r\n" );
|
define ( 'EOL', '<br />' . "\r\n" );
|
||||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
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']);
|
$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(
|
return replace_macros($tpl, array(
|
||||||
'$title' => t('Profile'),
|
'$title' => t('Profile'),
|
||||||
|
'$canlike' => (($profile['canlike'])? true : false),
|
||||||
|
'$likethis' => t('Like this thing'),
|
||||||
'$profile' => $profile,
|
'$profile' => $profile,
|
||||||
'$things' => $things
|
'$things' => $things
|
||||||
));
|
));
|
||||||
|
@ -322,9 +322,21 @@ function get_things($profile_hash,$uid) {
|
|||||||
foreach($v as $k => $foo)
|
foreach($v as $k => $foo)
|
||||||
$things[$k] = null;
|
$things[$k] = null;
|
||||||
foreach($r as $rr) {
|
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']])
|
if(! $things[$rr['obj_verb']])
|
||||||
$things[$rr['obj_verb']] = array();
|
$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();
|
$sorted_things = array();
|
||||||
if($things) {
|
if($things) {
|
||||||
@ -335,7 +347,7 @@ function get_things($profile_hash,$uid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//logger('things: ' . print_r($sorted_things,true));
|
||||||
return $sorted_things;
|
return $sorted_things;
|
||||||
|
|
||||||
}
|
}
|
@ -581,6 +581,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
|
|||||||
`iid` int(10) unsigned NOT NULL DEFAULT '0',
|
`iid` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
`verb` char(255) NOT NULL DEFAULT '',
|
`verb` char(255) NOT NULL DEFAULT '',
|
||||||
`target_type` char(255) NOT NULL DEFAULT '',
|
`target_type` char(255) NOT NULL DEFAULT '',
|
||||||
|
`target_id` char(128) NOT NULL DEFAULT '',
|
||||||
`target` mediumtext NOT NULL,
|
`target` mediumtext NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `channel_id` (`channel_id`),
|
KEY `channel_id` (`channel_id`),
|
||||||
@ -588,7 +589,8 @@ CREATE TABLE IF NOT EXISTS `likes` (
|
|||||||
KEY `likee` (`likee`),
|
KEY `likee` (`likee`),
|
||||||
KEY `iid` (`iid`),
|
KEY `iid` (`iid`),
|
||||||
KEY `verb` (`verb`),
|
KEY `verb` (`verb`),
|
||||||
KEY `target_type` (`target_type`)
|
KEY `target_type` (`target_type`),
|
||||||
|
KEY `target_id` (`target_id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `mail` (
|
CREATE TABLE IF NOT EXISTS `mail` (
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1114 );
|
define( 'UPDATE_VERSION' , 1115 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1283,3 +1283,11 @@ ADD INDEX ( `channel_id` )");
|
|||||||
return UPDATE_FAILED;
|
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
|
// 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']),
|
intval($ch[0]['channel_id']),
|
||||||
dbesc($observer['xchan_hash']),
|
dbesc($observer['xchan_hash']),
|
||||||
dbesc($activity),
|
dbesc($activity),
|
||||||
dbesc(($tgttype)?$tgttype:$objtype),
|
dbesc(($tgttype)?$tgttype:$objtype),
|
||||||
dbesc(json_encode(($target)?$target:$object))
|
dbesc($obj_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($z) {
|
if($z) {
|
||||||
@ -328,6 +328,10 @@ function like_content(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
$arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
|
$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['verb'] = $activity;
|
||||||
$arr['obj_type'] = $objtype;
|
$arr['obj_type'] = $objtype;
|
||||||
@ -354,13 +358,14 @@ function like_content(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
if($extended_like) {
|
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']),
|
intval($ch[0]['channel_id']),
|
||||||
dbesc($observer['xchan_hash']),
|
dbesc($observer['xchan_hash']),
|
||||||
dbesc($ch[0]['channel_hash']),
|
dbesc($ch[0]['channel_hash']),
|
||||||
intval($post_id),
|
intval($post_id),
|
||||||
dbesc($activity),
|
dbesc($activity),
|
||||||
dbesc(($tgttype)?$tgttype:$objtype),
|
dbesc(($tgttype)?$tgttype:$objtype),
|
||||||
|
dbesc($obj_id),
|
||||||
dbesc(json_encode(($target)?$target:$object))
|
dbesc(json_encode(($target)?$target:$object))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1743,6 +1743,14 @@ header {
|
|||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile-thing-list img {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-thing-list li {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
div.page-list-item {
|
div.page-list-item {
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{if $profile.canlike || $profile.like_count}}
|
{{if $profile.canlike || $profile.like_count}}
|
||||||
<div id="profile-like-wrapper">
|
<div id="profile-like-wrapper">
|
||||||
{{if $profile.canlike}}
|
{{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>
|
<i class="icon-thumbs-up-alt" title="{{$profile.likethis}}"></i>
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -200,6 +200,19 @@
|
|||||||
{{foreach $items as $item}}
|
{{foreach $items as $item}}
|
||||||
<li>{{if $item.img}}<img src="{{$item.img}}" width="100" height="100" alt="{{$item.term}}" />{{/if}}
|
<li>{{if $item.img}}<img src="{{$item.img}}" width="100" height="100" alt="{{$item.term}}" />{{/if}}
|
||||||
<a href="{{$item.url}}" >{{$item.term}}</a>
|
<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>
|
</li>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{{if $canedit}}
|
{{if $canedit}}
|
||||||
<div class="thing-edit-links">
|
<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/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}}" ><i class="icon-remove drop-icons"></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>
|
||||||
<div class="thing-edit-links-end"></div>
|
<div class="thing-edit-links-end"></div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Reference in New Issue
Block a user