public function __construct($data)
 {
     $guid = $data['guid'];
     if (!LikesPlugin::loggedInUserHasLiked($guid)) {
         die;
     }
     $like = getEntity(array("type" => "Like", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "container_guid", "value" => $guid))));
     $like->delete();
     die;
 }
 public function __construct($data)
 {
     $guid = $data['guid'];
     if (LikesPlugin::loggedInUserHasLiked($guid)) {
         die;
     }
     $entity = getEntity($guid);
     $owner_guid = $entity->owner_guid;
     $owner = getEntity($owner_guid);
     $like = new Like();
     $like->container_guid = $guid;
     $like->owner_guid = getLoggedInUserGuid();
     $like->save();
     new Activity(getLoggedInUserGuid(), "activity:like", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $owner->getURL(), $owner->full_name, $entity->getURL(), translate($entity->type)));
     notifyUser("like", $guid, getLoggedInUserGuid(), $owner_guid);
     die;
 }
Пример #3
0
 * Patents, patents in process, and are protected by trade secret or copyright law. 
 * 
 * Dissemination of this information or reproduction of this material is strictly forbidden 
 * unless prior written permission is obtained from SocialApparatus.
 * 
 * Contact Shane Barron admin@socia.us for more information.
 */
namespace SocialApparatus;

denyDirect();
$guid = Vars::get("guid");
if (!$guid) {
    $guid = getInput("guid");
}
$count = LikesPlugin::countLikes($guid);
$likers = LikesPlugin::likers($guid);
echo "<div class='likes like_" . $guid . " pull-right'>";
$s = $count != 1 ? "s" : "";
$likers_link = "<a title='{$likers}' data-toggle='tooltip'>{$count} Like{$s}</a>";
if (LikesPlugin::loggedInUserHasLiked($guid)) {
    echo <<<HTML
    <a href = 'javascript:likes.remove({$guid})' class = 'btn btn-xs btn-success disabled'><i class = 'fa fa fa-thumbs-up'></i></a>
    <small>{$likers_link}</small>
HTML;
} else {
    echo <<<HTML
    <a href = 'javascript:likes.add({$guid})' class = 'btn btn-xs btn-success'><i class = 'fa fa-thumbs-up'></i></a>
    <small>{$likers_link}</small>
HTML;
}
echo "</div>";