<?php
/**
* page callback: tag/%tag/%
*
* @param $tag
* The tag object.
*
* @param $action
* The action to be perform.
*/
function tag_action($tag, $action) {
switch ($action) {
case 'follow':
tag_follow_save(NULL, array(
'tid' => $tag->tid,
));
set_message(t('You are now following %followee', array('%followee' => $tag->name)), 'success');
break;
case 'unfollow':
global $user;
if ($tag_follow = tag_follow_load(array('tid' => $tag->tid, 'uid' => $user->uid))) {
tag_follow_delete($tag_follow);
}
}
redirect('network/' . $tag->nid . '/tag/' . $tag->tid);
}
/**
* page callback: tag/%tag/js/%
*
* @param $tag
* The tag object.
*
* @param $action
* The action to be perform.
*
* @return
* The JSON object.
*/
function tag_js($tag, $action) {
switch ($action) {
case 'follow':
tag_follow_save(NULL, array(
'tid' => $tag->tid,
));
return json('SUCCESS');
break;
case 'unfollow':
global $user;
if ($tag_follow = tag_follow_load(array('tid' => $tag->tid, 'uid' => $user->uid))) {
tag_follow_delete($tag_follow);
return json('SUCCESS');
}
return json('FAIL');
}
}
?>