/** * Undislike an item * @param string $element Can either be core object (photos/videos) or a plugins (plugins,plugin_name) * @param mixed $itemId Unique id to identify object item * */ public function ajaxUndislike($element, $itemId) { if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } // @rule: Only display likes html codes when likes is allowed. $config =& CFactory::getConfig(); if (!$config->get('likes_' . $element)) { return; } $my = CFactory::getUser(); $objResponse = new JAXResponse(); // Load libraries CFactory::load('libraries', 'like'); $unlike = new CLike(); $result = $unlike->unlike($element, $itemId); if (!$result) { $msg = JText::_('CC UNLIKE ERROR'); $objResponse->addScriptCall('cWindowShow', '', JText::_('CC UNLIKE'), 430, 100); $objResponse->addAssign('cWindowContent', 'innerHTML', $msg); } else { $like = new CLike(); $html = $like->getHTML($element, $itemId, $my->id); $objResponse->addScriptCall('__callback', $html); } return $objResponse->sendResponse(); }
/** * */ public function ajaxStreamUnlike($actid, $type = null) { $filter = JFilterInput::getInstance(); $actid = $filter->clean($actid, 'int'); $objResponse = new JAXResponse(); $like = new CLike(); $act = JTable::getInstance('Activity', 'CTable'); $act->load($actid); if ($type == 'comment') { $act = JTable::getInstance('Wall', 'CTable'); $act->load($actid); $act->like_type = 'comment'; $act->like_id = $act->id; } $params = new CParameter($act->params); if (isset($act->app) && $act->app == 'photos') { $act->like_type = 'album.self.share'; $act->like_id = $act->id; } else { if (isset($act->app) && $act->app == 'videos') { $act->like_type = 'videos.self.share'; $act->like_id = $act->id; } } $like->unlike($act->like_type, $act->like_id); $json = array(); $json['success'] = true; if ($type == 'comment') { $json['html'] = $this->_commentShowLikes($objResponse, $act->id); } else { $json['html'] = $this->_streamShowLikes($objResponse, $act->id, $act->like_type, $act->like_id); } die(json_encode($json)); }
/** * */ public function ajaxStreamUnlike($actid) { $filter = JFilterInput::getInstance(); $actid = $filter->clean($actid, 'int'); $objResponse = new JAXResponse(); $wallModel = CFactory::getModel('wall'); CFactory::load('libraries', 'like'); CFactory::load('libraries', 'wall'); $like = new CLike(); $act =& JTable::getInstance('Activity', 'CTable'); $act->load($actid); $like->unlike($act->like_type, $act->like_id); $this->_streamShowLikes($objResponse, $actid, $act->like_type, $act->like_id); $script = "joms.jQuery('#like_id" . $actid . "').replaceWith('<a id=like_id" . $actid . " href=#like onclick=\"jax.call(\\'community\\',\\'system,ajaxStreamAddLike\\'," . $actid . ");return false;\">" . JText::_('COM_COMMUNITY_LIKE') . "</a>');"; $objResponse->addScriptCall($script); return $objResponse->sendResponse(); }