$dbo->setQuery($query);
$rows = $dbo->loadObjectList();
if (count($rows) == 0) {
$subscription = new JCommentsSubscriptionsDB($dbo);
$subscription->object_id = $object_id;
$subscription->object_group = $object_group;
$subscription->name = $name;
$subscription->email = $email;
$subscription->userid = $userid;
$subscription->hash = JCommentsSubscriptionManager::getHash($object_id, $object_group, $userid, $email, $lang);
$subscription->lang = $lang;
$subscription->published = 1;
$subscription->store();
return true;
} else {
// if current user is registered, but already exists subscription
// on same email by guest - update subscription data
if ($userid > 0 && $rows[0]->userid == 0) {
$subscription = new JCommentsSubscriptionsDB($dbo);
$subscription->id = $rows[0]->id;
$subscription->userid = $userid;
$subscription->lang = $lang;
$subscription->hash = JCommentsSubscriptionManager::getHash($object_id, $object_group, $userid, $email, $lang);
$subscription->store();
return true;
} else {
$this->_errors[] = JText::_('Already subscribed');
}
}
return false;
}
/**
* Unsubscribe guest from new comments notifications by subscription hash
*
* @param string $hash The secret hash value of subscription
* @return boolean True on success, false otherwise.
*/
function unsubscribeByHash($hash)
{
if (!empty($hash)) {
$dbo = & JCommentsFactory::getDBO();
$dbo->setQuery("DELETE FROM #__jcomments_subscriptions WHERE `hash`='" . $hash . "'");
$dbo->query();
return true;
}
return false;
}
/**
* Unsubscribe registered user from new comments notifications for an object
*
* @param int $object_id The object identifier
* @param string $object_group The object group (component name)
* @param int $userid The registered user identifier
* @return boolean True on success, false otherwise.
*/
function unsubscribe($object_id, $object_group, $userid)
{
if ($userid != 0) {
$dbo = & JCommentsFactory::getDBO();
$query = "DELETE"
. "\n FROM #__jcomments_subscriptions"
. "\n WHERE object_id = " . (int) $object_id
. "\n AND object_group = '" . $dbo->getEscaped($object_group) . "'"
. "\n AND userid = " . (int) $userid
.(JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "")
;
$dbo->setQuery($query);
$dbo->query();
return true;
}
return false;
}
/**
* Checks if given user is subscribed to new comments notifications for an object
*
* @param int $object_id The object identifier
* @param string $object_group The object group (component name)
* @param int $userid The registered user identifier
* @param string $email The user email (for guests only)
* @return int
*/
function isSubscribed( $object_id, $object_group, $userid, $email = '', $lang = '')
{
static $cache = null;
if (isset($cache[$object_id . $object_group . $userid . $email])) {
return $cache[$object_id . $object_group . $userid . $email];
}
$dbo = & JCommentsFactory::getDBO();
if ($lang == '') {
$lang = JCommentsMultilingual::getLanguage();
}
$query = "SELECT COUNT(*) "
."\n FROM #__jcomments_subscriptions"
."\n WHERE object_id = " . (int) $object_id
."\n AND object_group = '" . $dbo->getEscaped($object_group) . "'"
."\n AND userid = " . (int) $userid
.(($userid == 0) ? "\n AND email = '" . $dbo->getEscaped($email) . "'" : '')
.(JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . $lang . "'" : "")
;
$dbo->setQuery($query);
$cnt = $dbo->loadResult();
$cache[$object_id . $object_group . $userid . $email] = (int) $cnt > 0;
return ($cnt > 0 ? 1 : 0);
}
/**
* Return an array of errors messages
*
* @return Array The array of error messages
*/
function getErrors()
{
return $this->_errors;
}
}
?>
/**
* JComments - Joomla Comment System
*
* Router (Translates an internal Joomla URL to a humanly readable URL)
*
* @version 2.1
* @package JComments
* @author Sergey M. Litvinov (
smart@joomlatune.ru)
* @copyright (C) 2006-2010 by Sergey M. Litvinov (http://www.joomlatune.ru)
* @license GNU/GPL:
http://www.gnu.org/copyleft/gpl.html
*
* If you fork this to create your own project,
* please make a reference to JComments someplace in your code
* and provide a link to
http://www.joomlatune.ru
**/
function JCommentsBuildRoute(& $query){
$segments = array();
if(isset($query['task'])){
switch($query['task']) {
case 'rss':
$segments[] = 'feed';
break;
case 'rss_full':
$segments[] = 'feed';
$segments[] = 'full';
break;
case 'unsubscribe':
$segments[] = 'unsubscribe';
if(isset($query['hash'])){
$segments[] = $query['hash'];
unset($query['hash']);
}
break;
case 'cmd':
// $segments[] = $query['task'];
if(isset($query['cmd'])){
$segments[] = $query['cmd'];
unset($query['cmd']);
}
if(isset($query['id'])){
$segments[] = $query['id'];
unset($query['id']);
}
if(isset($query['hash'])){
$segments[] = $query['hash'];
unset($query['hash']);
}
break;
}
unset($query['task']);
}
if(isset($query['object_group'])){
$segments[] = $query['object_group'];
unset($query['object_group']);
}
if(isset($query['object_id'])){
$segments[] = $query['object_id'];
unset($query['object_id']);
}
if (isset($query['limit'])) {
$segments[] = $query['limit'];
unset($query['limit']);
}
if(isset($query['tmpl'])){
unset($query['tmpl']);
}
if(isset($query['format'])){
unset($query['format']);
}
return $segments;
}
function JCommentsParseRoute($segments){
$vars = array();
$cnt = count($segments);
if (isset($segments[0])) {
switch($segments[0]) {
case 'feed':
if ($segments[1] == 'full') {
$vars['task'] = 'rss_full';
if ($cnt == 2) {
$vars['object_group'] = $segments[2];
} else if ($cnt == 2) {
$vars['object_group'] = $segments[2];
$vars['limit'] = $segments[3];
}
//$vars['tmpl'] = 'component';
$vars['format'] = 'raw';
} else {
$vars['task'] = 'rss';
$vars['object_group'] = $segments[1];
$vars['object_id'] = $segments[2];
if (isset($segments[3])) {
$vars['limit'] = $segments[3];
}
//$vars['tmpl'] = 'component';
$vars['format'] = 'raw';
}
break;
case 'unsubscribe':
$vars['task'] = $segments[0];
$vars['hash'] = $segments[1];
//$vars['tmpl'] = 'component';
$vars['format'] = 'raw';
break;
case 'delete':
case 'publish':
case 'unpublish':
$vars['task'] = 'cmd';
$vars['cmd'] = $segments[0];
$vars['id'] = $segments[1];
$vars['hash'] = $segments[2];
//$vars['tmpl'] = 'component';
$vars['format'] = 'raw';
break;
default:
if (isset($segments[1]) && $segments[1] == 'unsubscribe') {
$vars['task'] = $segments[1];
$vars['hash'] = $segments[0];
//$vars['tmpl'] = 'component';
$vars['format'] = 'raw';
}
break;
}
}
return $vars;
}
at are not necessarily
empirical in nature, but describe interesting new educational tools,
approaches or solutions.
The book series will include both edited volumes comprised of
peer-reviewed articles and authored books. Each volume is dedicated to a
specific theme in business education, and will be complemented with
articles that can be a resource to advance business education and
training.=20
=20
=20
=20
=20
Wim Gijselaers
Chair Department of Educational Development & Educational R
/**
* JComments - Joomla Comment System
*
* Service functions for JComments content plugins
*
* @version 2.1
* @package JComments
* @subpackage Helpers
* @author Sergey M. Litvinov (
smart@joomlatune.ru)
* @copyright (C) 2006-2010 by Sergey M. Litvinov (http://www.joomlatune.ru)
* @license GNU/GPL:
http://www.gnu.org/copyleft/gpl.html
*
**/
/**
* JComments Content Plugin Helper
*
* @static
* @package JComments
* @subpackage Helpers
*/
class JCommentsContentPluginHelper
{
/**
*
* @access private
* @param object $row The content item object
* @param array $patterns
* @param array $replacements
* @param boolean $fromText Process 'text' field or introtext/fulltext fields?
* @return void
*/
function _processTags( &$row, $patterns = array(), $replacements = array(), $fromText = true )
{
if (count($patterns) > 0) {
ob_start();
if (true == $fromText) {
$row->text = preg_replace($patterns, $replacements, $row->text);
} else {
if (isset($row->introtext)) {
$row->introtext = preg_replace($patterns, $replacements, $row->introtext);
}
if (isset($row->fulltext)) {
$row->fulltext = preg_replace($patterns, $replacements, $row->fulltext);
}
}
ob_end_clean();
}
}
/**
* Searches given tag in content object
*
* @access private
* @param object $row The content item object
* @param string $pattern
* @param boolean $fromText Process 'text' field or introtext/fulltext fields?
* @return boolean True if any tag found, False otherwise
*/
function _findTag( &$row, $pattern, $fromText = false )
{
if (true == $fromText) {
return (isset($row->text) && preg_match($pattern, $row->text));
} else {
return ((isset($row->introtext) && preg_match($pattern, $row->introtext)) || (isset($row->fulltext) && preg_match($pattern, $row->fulltext)));
}
}
/**
* Replaces or removes commenting systems tags like {moscomment}, {jomcomment} etc
*
* @static
* @access public
* @param object $row The content item object
* @param boolean $removeTags Remove all 3rd party tags or replace it to JComments tags?
* @param boolean $fromText Process 'text' field or introtext/fulltext fields?
* @return void
*/
function processForeignTags( &$row, $removeTags = false, $fromText = true )
{
if (false == $removeTags) {
$patterns = array('#\{(moscomment|mxc|jomcomment|easycomments)\}#is', '#\{\!jomcomment\}#is', '#\{mxc\:\:closed\}#is');
$replacements = array('{jcomments on}', '{jcomments off}', '{jcomments lock}');
} else {
$patterns = array('#\{(moscomment|mxc|msc::closed|!jomcomment|jomcomment|easycomments)\}#is');
$replacements = array('');
}
JCommentsContentPluginHelper::_processTags($row, $patterns, $replacements, $fromText);
}
/**
* Return true if one of text fields contains {jcomments on} tag
*
* @static
* @access public
* @param object $row Content object
* @param boolean $fromText Look field 'text' or 'introtext' & 'fulltext'
* @return boolean True if {jcomments on} found, False otherwise
*/
function isEnabled( &$row, $fromText = false )
{
return JCommentsContentPluginHelper::_findTag($row, '/{jcomments\s+on}/is', $fromText);
}
/**
* Return true if one of text fields contains {jcomments off} tag
*
* @static
* @access public
* @param object $row Content object
* @param boolean $fromText Look field 'text' or 'introtext' & 'fulltext'
* @return boolean True if {jcomments off} found, False otherwise
*/
function isDisabled( &$row, $fromText = false )
{
return JCommentsContentPluginHelper::_findTag($row, '/{jcomments\s+off}/is', $fromText);
}
/**
* Return true if one of text fields contains {jcomments lock} tag
*
* @static
* @access public
* @param object $row Content object
* @param boolean $fromText Look field 'text' or 'introtext' & 'fulltext'
* @return boolean True if {jcomments lock} found, False otherwise
*/
function isLocked( &$row, $fromText = false )
{
return JCommentsContentPluginHelper::_findTag($row, '/{jcomments\s+lock}/is', $fromText);
}
/**
* Clears all JComments tags from content item
*
* @static
* @access public
* @param object $row Content object
* @param boolean $fromText Look field 'text' or 'introtext' & 'fulltext'
* @return void
*/
function clear( &$row, $fromText = false )
{
$patterns = array('/{jcomments\s+(off|on|lock)}/is');
$replacements = array('');
JCommentsContentPluginHelper::_processTags($row, $patterns, $replacements, $fromText);
}
/**
* Checks if comments are enabled for specified category
*
* @static
* @access public
* @param int $id Category ID
* @return boolean
*/
function checkCategory( $id )
{
$config = & JCommentsFactory::getConfig();
$categories = $config->get('enable_categories', '');
$ids = explode(',', $categories);
return ($categories == '*' || ($categories != '' && in_array($id, $ids)));
}
}
?>ial">Publications