mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:55:15 +00:00
some code cleanup and simplification in mod_like
This commit is contained in:
parent
5d4110375a
commit
304085606f
2 changed files with 42 additions and 40 deletions
|
@ -9,9 +9,41 @@ require_once('include/items.php');
|
|||
|
||||
class Like extends \Zotlabs\Web\Controller {
|
||||
|
||||
function get() {
|
||||
|
||||
|
||||
private function reaction_to_activity($reaction) {
|
||||
|
||||
$acts = [
|
||||
'like' => ACTIVITY_LIKE ,
|
||||
'dislike' => ACTIVITY_DISLIKE ,
|
||||
'agree' => ACTIVITY_AGREE ,
|
||||
'disagree' => ACTIVITY_DISAGREE ,
|
||||
'abstain' => ACTIVITY_ABSTAIN ,
|
||||
'attendyes' => ACTIVITY_ATTEND ,
|
||||
'attendno' => ACTIVITY_ATTENDNO ,
|
||||
'attendmaybe' => ACTIVITY_ATTENDMAYBE
|
||||
];
|
||||
|
||||
// unlike (etc.) reactions are an undo of positive reactions, rather than a negative action.
|
||||
// The activity is the same in undo actions and will have the same activity mapping
|
||||
|
||||
if(substr($reaction,0,2) === 'un') {
|
||||
$reaction = substr($reaction,2);
|
||||
}
|
||||
|
||||
if(array_key_exists($reaction,$acts)) {
|
||||
return $acts[$reaction];
|
||||
}
|
||||
|
||||
return EMPTY_STR;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get() {
|
||||
|
||||
$o = '';
|
||||
$o = EMPTY_STR;
|
||||
|
||||
$sys_channel = get_sys_channel();
|
||||
$sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0);
|
||||
|
@ -35,48 +67,17 @@ class Like extends \Zotlabs\Web\Controller {
|
|||
if(! $verb)
|
||||
$verb = 'like';
|
||||
|
||||
switch($verb) {
|
||||
case 'like':
|
||||
case 'unlike':
|
||||
$activity = ACTIVITY_LIKE;
|
||||
break;
|
||||
case 'dislike':
|
||||
case 'undislike':
|
||||
$activity = ACTIVITY_DISLIKE;
|
||||
break;
|
||||
case 'agree':
|
||||
case 'unagree':
|
||||
$activity = ACTIVITY_AGREE;
|
||||
break;
|
||||
case 'disagree':
|
||||
case 'undisagree':
|
||||
$activity = ACTIVITY_DISAGREE;
|
||||
break;
|
||||
case 'abstain':
|
||||
case 'unabstain':
|
||||
$activity = ACTIVITY_ABSTAIN;
|
||||
break;
|
||||
case 'attendyes':
|
||||
case 'unattendyes':
|
||||
$activity = ACTIVITY_ATTEND;
|
||||
break;
|
||||
case 'attendno':
|
||||
case 'unattendno':
|
||||
$activity = ACTIVITY_ATTENDNO;
|
||||
break;
|
||||
case 'attendmaybe':
|
||||
case 'unattendmaybe':
|
||||
$activity = ACTIVITY_ATTENDMAYBE;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
$activity = $this->reaction_to_activity($verb);
|
||||
|
||||
if(! $activity) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
|
||||
$extended_like = false;
|
||||
$object = $target = null;
|
||||
$post_type = '';
|
||||
$objtype = '';
|
||||
$post_type = EMPTY_STR;
|
||||
$objtype = EMPTY_STR;
|
||||
|
||||
if(argc() == 3) {
|
||||
|
||||
|
|
1
boot.php
1
boot.php
|
@ -66,6 +66,7 @@ define ( 'PROJECT_BASE', __DIR__ );
|
|||
* This can be used in HTML and JavaScript where needed a line break.
|
||||
*/
|
||||
define ( 'EOL', '<br>' . "\r\n" );
|
||||
define ( 'EMPTY_STR', '' );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\\TH:i:s\\Z' ); // aka ISO 8601 "Zulu"
|
||||
define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' );
|
||||
|
||||
|
|
Loading…
Reference in a new issue