From: <be...@us...> - 2012-07-31 12:24:40
|
Revision: 9957 http://xoops.svn.sourceforge.net/xoops/?rev=9957&view=rev Author: beckmi Date: 2012-07-31 12:24:26 +0000 (Tue, 31 Jul 2012) Log Message: ----------- Adding MyComments (by Trabis) Added Paths: ----------- XoopsModules/mycomments/ XoopsModules/mycomments/branches/ XoopsModules/mycomments/releases/ XoopsModules/mycomments/releases/1.0/ XoopsModules/mycomments/releases/1.0/mycomments/ XoopsModules/mycomments/releases/1.0/mycomments/blocks/ XoopsModules/mycomments/releases/1.0/mycomments/blocks/index.html XoopsModules/mycomments/releases/1.0/mycomments/blocks/mycomments_blocks.php XoopsModules/mycomments/releases/1.0/mycomments/class/ XoopsModules/mycomments/releases/1.0/mycomments/class/comment.php XoopsModules/mycomments/releases/1.0/mycomments/class/commentrenderer.php XoopsModules/mycomments/releases/1.0/mycomments/class/index.html XoopsModules/mycomments/releases/1.0/mycomments/images/ XoopsModules/mycomments/releases/1.0/mycomments/images/img.gif XoopsModules/mycomments/releases/1.0/mycomments/images/slogo.png XoopsModules/mycomments/releases/1.0/mycomments/images/xuupslogo.png XoopsModules/mycomments/releases/1.0/mycomments/include/ XoopsModules/mycomments/releases/1.0/mycomments/include/comment_constants.php XoopsModules/mycomments/releases/1.0/mycomments/include/functions.php XoopsModules/mycomments/releases/1.0/mycomments/include/index.html XoopsModules/mycomments/releases/1.0/mycomments/include/search.inc.php XoopsModules/mycomments/releases/1.0/mycomments/index.php XoopsModules/mycomments/releases/1.0/mycomments/language/ XoopsModules/mycomments/releases/1.0/mycomments/language/english/ XoopsModules/mycomments/releases/1.0/mycomments/language/english/blocks.php XoopsModules/mycomments/releases/1.0/mycomments/language/english/index.html XoopsModules/mycomments/releases/1.0/mycomments/language/english/main.php XoopsModules/mycomments/releases/1.0/mycomments/language/english/modinfo.php XoopsModules/mycomments/releases/1.0/mycomments/language/index.html XoopsModules/mycomments/releases/1.0/mycomments/language/portugues/ XoopsModules/mycomments/releases/1.0/mycomments/language/portugues/blocks.php XoopsModules/mycomments/releases/1.0/mycomments/language/portugues/index.html XoopsModules/mycomments/releases/1.0/mycomments/language/portugues/main.php XoopsModules/mycomments/releases/1.0/mycomments/language/portugues/modinfo.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/ XoopsModules/mycomments/releases/1.0/mycomments/plugins/index.html XoopsModules/mycomments/releases/1.0/mycomments/plugins/mydownloads.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/mylinks.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/news.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/publisher.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/webshow.php XoopsModules/mycomments/releases/1.0/mycomments/plugins/xoopstube.php XoopsModules/mycomments/releases/1.0/mycomments/readme.txt XoopsModules/mycomments/releases/1.0/mycomments/templates/ XoopsModules/mycomments/releases/1.0/mycomments/templates/blocks/ XoopsModules/mycomments/releases/1.0/mycomments/templates/blocks/index.html XoopsModules/mycomments/releases/1.0/mycomments/templates/blocks/mycomments_block_comments.html XoopsModules/mycomments/releases/1.0/mycomments/templates/index.html XoopsModules/mycomments/releases/1.0/mycomments/templates/mycomments_comments.html XoopsModules/mycomments/releases/1.0/mycomments/templates/mycomments_navigation.html XoopsModules/mycomments/releases/1.0/mycomments/xoops_version.php XoopsModules/mycomments/trunk/ XoopsModules/mycomments/trunk/mycomments/ XoopsModules/mycomments/trunk/mycomments/blocks/ XoopsModules/mycomments/trunk/mycomments/blocks/index.html XoopsModules/mycomments/trunk/mycomments/blocks/mycomments_blocks.php XoopsModules/mycomments/trunk/mycomments/class/ XoopsModules/mycomments/trunk/mycomments/class/comment.php XoopsModules/mycomments/trunk/mycomments/class/commentrenderer.php XoopsModules/mycomments/trunk/mycomments/class/index.html XoopsModules/mycomments/trunk/mycomments/images/ XoopsModules/mycomments/trunk/mycomments/images/img.gif XoopsModules/mycomments/trunk/mycomments/images/slogo.png XoopsModules/mycomments/trunk/mycomments/images/xuupslogo.png XoopsModules/mycomments/trunk/mycomments/include/ XoopsModules/mycomments/trunk/mycomments/include/comment_constants.php XoopsModules/mycomments/trunk/mycomments/include/functions.php XoopsModules/mycomments/trunk/mycomments/include/index.html XoopsModules/mycomments/trunk/mycomments/include/search.inc.php XoopsModules/mycomments/trunk/mycomments/index.php XoopsModules/mycomments/trunk/mycomments/language/ XoopsModules/mycomments/trunk/mycomments/language/english/ XoopsModules/mycomments/trunk/mycomments/language/english/blocks.php XoopsModules/mycomments/trunk/mycomments/language/english/index.html XoopsModules/mycomments/trunk/mycomments/language/english/main.php XoopsModules/mycomments/trunk/mycomments/language/english/modinfo.php XoopsModules/mycomments/trunk/mycomments/language/index.html XoopsModules/mycomments/trunk/mycomments/language/portugues/ XoopsModules/mycomments/trunk/mycomments/language/portugues/blocks.php XoopsModules/mycomments/trunk/mycomments/language/portugues/index.html XoopsModules/mycomments/trunk/mycomments/language/portugues/main.php XoopsModules/mycomments/trunk/mycomments/language/portugues/modinfo.php XoopsModules/mycomments/trunk/mycomments/plugins/ XoopsModules/mycomments/trunk/mycomments/plugins/index.html XoopsModules/mycomments/trunk/mycomments/plugins/mydownloads.php XoopsModules/mycomments/trunk/mycomments/plugins/mylinks.php XoopsModules/mycomments/trunk/mycomments/plugins/news.php XoopsModules/mycomments/trunk/mycomments/plugins/publisher.php XoopsModules/mycomments/trunk/mycomments/plugins/webshow.php XoopsModules/mycomments/trunk/mycomments/plugins/xoopstube.php XoopsModules/mycomments/trunk/mycomments/readme.txt XoopsModules/mycomments/trunk/mycomments/templates/ XoopsModules/mycomments/trunk/mycomments/templates/blocks/ XoopsModules/mycomments/trunk/mycomments/templates/blocks/index.html XoopsModules/mycomments/trunk/mycomments/templates/blocks/mycomments_block_comments.html XoopsModules/mycomments/trunk/mycomments/templates/index.html XoopsModules/mycomments/trunk/mycomments/templates/mycomments_comments.html XoopsModules/mycomments/trunk/mycomments/templates/mycomments_navigation.html XoopsModules/mycomments/trunk/mycomments/xoops_version.php Added: XoopsModules/mycomments/releases/1.0/mycomments/blocks/index.html =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/blocks/index.html (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/blocks/index.html 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/mycomments/releases/1.0/mycomments/blocks/mycomments_blocks.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/blocks/mycomments_blocks.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/blocks/mycomments_blocks.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,155 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +function b_mycomments_show($options) +{ + $block = array(); + include_once XOOPS_ROOT_PATH.'/modules/mycomments/include/comment_constants.php'; + $comment_handler =& xoops_getmodulehandler('comment','mycomments'); + $criteria = new CriteriaCompo(new Criteria('com_status', MYCOM_ACTIVE)); + $criteria->setLimit(intval($options[0])); + $criteria->setSort('com_created'); + $criteria->setOrder('DESC'); + + // Check modules permissions + global $xoopsUser; + $moduleperm_handler =& xoops_gethandler('groupperm'); + $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); + $criteria1 = new CriteriaCompo(new Criteria('gperm_name','module_read','=')); + $criteria1->add(new Criteria('gperm_groupid', '('.implode(',', $gperm_groupid).')', 'IN')); + $perms = $moduleperm_handler->getObjects($criteria1, true); + $modIds = array(); + foreach($perms as $item) { + $modIds[] = $item->getVar('gperm_itemid'); + } + if(count($modIds) > 0 ) { + $modIds = array_unique($modIds); + $criteria->add(new Criteria('com_modid', '('.implode(',', $modIds).')', 'IN')); + } + // Check modules permissions + + $comments = $comment_handler->getObjects($criteria, true); + $member_handler =& xoops_gethandler('member'); + $module_handler =& xoops_gethandler('module'); + $modules = $module_handler->getObjects(new Criteria('hascomments', 1), true); + $comment_config = array(); + foreach (array_keys($comments) as $i) { + $mid = $comments[$i]->getVar('com_modid'); + $com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>'; + if (!isset($comment_config[$mid])) { + $comment_config[$mid] = $modules[$mid]->getInfo('comments'); + } + $com['id'] = $i; + $com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>'; + $com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES ); + $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif'; + $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m'); + if ($comments[$i]->getVar('com_uid') > 0) { + $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid')); + if (is_object($poster)) { + $com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>'; + } else { + $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; + } + } else { + $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; + } + $block['comments'][] =& $com; + unset($com); + } + return $block; +} + + +function b_mycomments_edit($options) +{ + $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />"; + $form = sprintf(_MB_MYCOM_DISPLAYC, $inputtag); + return $form; +} + +function b_mycomments2_show($options) +{ + global $xoopsUser; + include_once XOOPS_ROOT_PATH.'/modules/mycomments/include/comment_constants.php'; + $limit = 10; // If you are not getting suficient results, please increase a little more this number + $block = $comment_config = $trackedItems = array(); + + $comment_handler =& xoops_getmodulehandler('comment','mycomments'); + $moduleperm_handler =& xoops_gethandler('groupperm'); + $member_handler =& xoops_gethandler('member'); + $module_handler =& xoops_gethandler('module'); + + $criteria = new CriteriaCompo(new Criteria('com_status', MYCOM_ACTIVE)); + $criteria->setLimit(intval($options[0] * $limit)); + $criteria->setSort('com_created'); + $criteria->setOrder('DESC'); + + $comments = $comment_handler->getObjects($criteria, true); + $modules = $module_handler->getObjects(new Criteria('hascomments', 1), true); + + $count = 0; + foreach (array_keys($comments) as $i) { + if ( $count == $options[0]) continue; + $mid = $comments[$i]->getVar('com_modid'); + + if ($xoopsUser) { + if (!$moduleperm_handler->checkRight('module_read', $mid, $xoopsUser->getGroups())) { + continue; + } + } else { + if (!$moduleperm_handler->checkRight('module_read', $mid, XOOPS_GROUP_ANONYMOUS)) { + continue; + } + } + + $com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>'; + if (!isset($comment_config[$mid])) { + $comment_config[$mid] = $modules[$mid]->getInfo('comments'); + } + $com['id'] = $i; + $com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>'; + $com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES ); + $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif'; + $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m'); + if ($comments[$i]->getVar('com_uid') > 0) { + $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid')); + if (is_object($poster)) { + $com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>'; + } else { + $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; + } + } else { + $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; + } + if (count($trackedItems) > 0) { + $itemMatch = false; + foreach (array_keys($trackedItems) as $j) { + if ($comments[$i]->getVar('com_modid') == $trackedItems[$j]['modid'] && $comments[$i]->getVar('com_itemid') == $trackedItems[$j]['itemid']) { + $itemMatch = true; + } + } + if (!$itemMatch) { + $block['comments'][] =& $com; + $trackedItems[] = array('modid' => $comments[$i]->getVar('com_modid'), 'itemid' => $comments[$i]->getVar('com_itemid') ); + $count++; + } + } else { + $block['comments'][] =& $com; + $trackedItems[] = array('modid' => $comments[$i]->getVar('com_modid'), 'itemid' => $comments[$i]->getVar('com_itemid') ); + $count++; + } + unset($com); + } + return $block; +} + +function b_mycomments2_edit($options) +{ + $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />"; + $form = sprintf(_MB_MYCOM_DISPLAYC, $inputtag); + return $form; +} +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/class/comment.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/class/comment.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/class/comment.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,431 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} + +/** + * + * + * @package kernel + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + */ + +/** + * A Comment + * + * @package kernel + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + */ +class MycommentsComment extends XoopsObject +{ + + /** + * Constructor + **/ + function MycommentsComment() + { + $this->XoopsObject(); + $this->initVar('com_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('com_pid', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_modid', XOBJ_DTYPE_INT, null, false); + $this->initVar('com_icon', XOBJ_DTYPE_OTHER, null, false); + $this->initVar('com_title', XOBJ_DTYPE_TXTBOX, null, true, 255, true); + $this->initVar('com_text', XOBJ_DTYPE_TXTAREA, null, true, null, true); + $this->initVar('com_created', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_modified', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_uid', XOBJ_DTYPE_INT, 0, true); + $this->initVar('com_ip', XOBJ_DTYPE_OTHER, null, false); + $this->initVar('com_sig', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_itemid', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_rootid', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_status', XOBJ_DTYPE_INT, 0, false); + $this->initVar('com_exparams', XOBJ_DTYPE_OTHER, null, false, 255); + $this->initVar('dohtml', XOBJ_DTYPE_INT, 0, false); + $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false); + $this->initVar('doxcode', XOBJ_DTYPE_INT, 0, false); + $this->initVar('doimage', XOBJ_DTYPE_INT, 0, false); + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); + //yup, lets handle the module + $this->initVar('mid', XOBJ_DTYPE_INT, null, false); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, true, 150); + $this->initVar('version', XOBJ_DTYPE_INT, 100, false); + $this->initVar('last_update', XOBJ_DTYPE_INT, null, false); + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false); + $this->initVar('isactive', XOBJ_DTYPE_INT, 1, false); + $this->initVar('dirname', XOBJ_DTYPE_OTHER, null, true); + $this->initVar('hasmain', XOBJ_DTYPE_INT, 0, false); + $this->initVar('hasadmin', XOBJ_DTYPE_INT, 0, false); + $this->initVar('hassearch', XOBJ_DTYPE_INT, 0, false); + $this->initVar('hasconfig', XOBJ_DTYPE_INT, 0, false); + $this->initVar('hascomments', XOBJ_DTYPE_INT, 0, false); + $this->initVar('hasnotification', XOBJ_DTYPE_INT, 0, false); + } + + /** + * Is this comment on the root level? + * + * @return bool + **/ + function isRoot() + { + return ($this->getVar('com_id') == $this->getVar('com_rootid')); + } +} + +/** + * XOOPS comment handler class. + * + * This class is responsible for providing data access mechanisms to the data source + * of XOOPS comment class objects. + * + * + * @package kernel + * @subpackage comment + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + */ +class MycommentsCommentHandler extends XoopsObjectHandler +{ + + /** + * Create a {@link XoopsComment} + * + * @param bool $isNew Flag the object as "new"? + * + * @return object + */ + function &create($isNew = true) + { + $comment = new MycommentsComment(); + if ($isNew) { + $comment->setNew(); + } + return $comment; + } + + /** + * Retrieve a {@link XoopsComment} + * + * @param int $id ID + * + * @return object {@link XoopsComment}, FALSE on fail + **/ + function &get($id) + { + $comment = false; + $id = intval($id); + if ($id > 0) { + $sql = 'SELECT * FROM '.$this->db->prefix('xoopscomments').' WHERE com_id='.$id; + if (!$result = $this->db->query($sql)) { + return $comment; + } + $numrows = $this->db->getRowsNum($result); + if ($numrows == 1) { + $comment = new MycommentsComment(); + $comment->assignVars($this->db->fetchArray($result)); + } + } + return $comment; + } + + /** + * Write a comment to database + * + * @param object &$comment + * + * @return bool + **/ + function insert(&$comment) + { + if (strtolower(get_class($comment)) != 'mycommentscomment') { + return false; + } + if (!$comment->isDirty()) { + return true; + } + if (!$comment->cleanVars()) { + return false; + } + foreach ($comment->cleanVars as $k => $v) { + ${$k} = $v; + } + if ($comment->isNew()) { + $com_id = $this->db->genId('xoopscomments_com_id_seq'); + $sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, com_exparams, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, %s, %s, %s, %u, %u, %u, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u)", $this->db->prefix('xoopscomments'), $com_id, $com_pid, $com_modid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr); + } else { + $sql = sprintf("UPDATE %s SET com_pid = %u, com_icon = %s, com_title = %s, com_text = %s, com_created = %u, com_modified = %u, com_uid = %u, com_ip = %s, com_sig = %u, com_itemid = %u, com_rootid = %u, com_status = %u, com_exparams = %s, dohtml = %u, dosmiley = %u, doxcode = %u, doimage = %u, dobr = %u WHERE com_id = %u", $this->db->prefix('xoopscomments'), $com_pid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $com_id); + } + if (!$result = $this->db->query($sql)) { + return false; + } + if (empty($com_id)) { + $com_id = $this->db->getInsertId(); + } + $comment->assignVar('com_id', $com_id); + return true; + } + + /** + * Delete a {@link XoopsComment} from the database + * + * @param object &$comment + * + * @return bool + **/ + function delete(&$comment) + { + if (strtolower(get_class($comment)) != 'mycommentscomment') { + return false; + } + $sql = sprintf("DELETE FROM %s WHERE com_id = %u", $this->db->prefix('xoopscomments'), $comment->getVar('com_id')); + if (!$result = $this->db->query($sql)) { + return false; + } + return true; + } + + /** + * Get some {@link XoopsComment}s + * + * @param object $criteria + * @param bool $id_as_key Use IDs as keys into the array? + * + * @return array Array of {@link XoopsComment} objects + **/ + function getObjects($criteria = null, $id_as_key = false) + { + $ret = array(); + $limit = $start = 0; + $sql = 'SELECT c.* ,m.* FROM '.$this->db->prefix('xoopscomments').' c, '.$this->db->prefix('modules').' m'; + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { + $sql .= ' '.$criteria->renderWhere(); + $sql .= ' AND c.com_modid = m.mid'; + $sort = ($criteria->getSort() != '') ? $criteria->getSort() : 'com_id'; + $sql .= ' ORDER BY '.$sort.' '.$criteria->getOrder(); + $limit = $criteria->getLimit(); + $start = $criteria->getStart(); + } + $result = $this->db->query($sql, $limit, $start); + if (!$result) { + return $ret; + } + while ($myrow = $this->db->fetchArray($result)) { + $comment = new MycommentsComment(); + $comment->assignVars($myrow); + if (!$id_as_key) { + $ret[] =& $comment; + } else { + $ret[$myrow['com_id']] =& $comment; + } + unset($comment); + } + return $ret; + } + + /** + * Count Comments + * + * @param object $criteria {@link CriteriaElement} + * + * @return int Count + **/ + function getCount($criteria = null) + { + $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('xoopscomments'); + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { + $sql .= ' '.$criteria->renderWhere(); + } + if (!$result =& $this->db->query($sql)) { + return 0; + } + list($count) = $this->db->fetchRow($result); + return $count; + } + + /** + * Delete multiple comments + * + * @param object $criteria {@link CriteriaElement} + * + * @return bool + **/ + function deleteAll($criteria = null) + { + $sql = 'DELETE FROM '.$this->db->prefix('xoopscomments'); + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { + $sql .= ' '.$criteria->renderWhere(); + } + if (!$result = $this->db->query($sql)) { + return false; + } + return true; + } + + /** + * Get a list of comments + * + * @param object $criteria {@link CriteriaElement} + * + * @return array Array of raw database records + **/ + function getList($criteria = null) + { + $comments = $this->getObjects($criteria, true); + $ret = array(); + foreach (array_keys($comments) as $i) { + $ret[$i] = $comments[$i]->getVar('com_title'); + } + return $ret; + } + + /** + * Retrieves comments for an item + * + * @param int $module_id Module ID + * @param int $item_id Item ID + * @param string $order Sort order + * @param int $status Status of the comment + * @param int $limit Max num of comments to retrieve + * @param int $start Start offset + * + * @return array Array of {@link XoopsComment} objects + **/ + function getByItemId($module_id, $item_id, $order = null, $status = null, $limit = null, $start = 0) + { + $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); + $criteria->add(new Criteria('com_itemid', intval($item_id))); + if (isset($status)) { + $criteria->add(new Criteria('com_status', intval($status))); + } + if (isset($order)) { + $criteria->setOrder($order); + } + if (isset($limit)) { + $criteria->setLimit($limit); + $criteria->setStart($start); + } + return $this->getObjects($criteria); + } + + /** + * Gets total number of comments for an item + * + * @param int $module_id Module ID + * @param int $item_id Item ID + * @param int $status Status of the comment + * + * @return array Array of {@link XoopsComment} objects + **/ + function getCountByItemId($module_id, $item_id, $status = null) + { + $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); + $criteria->add(new Criteria('com_itemid', intval($item_id))); + if (isset($status)) { + $criteria->add(new Criteria('com_status', intval($status))); + } + return $this->getCount($criteria); + } + + + /** + * Get the top {@link XoopsComment}s + * + * @param int $module_id + * @param int $item_id + * @param strint $order + * @param int $status + * + * @return array Array of {@link XoopsComment} objects + **/ + function getTopComments($module_id, $item_id, $order, $status = null) + { + $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); + $criteria->add(new Criteria('com_itemid', intval($item_id))); + $criteria->add(new Criteria('com_pid', 0)); + if (isset($status)) { + $criteria->add(new Criteria('com_status', intval($status))); + } + $criteria->setOrder($order); + return $this->getObjects($criteria); + } + + /** + * Retrieve a whole thread + * + * @param int $comment_rootid + * @param int $comment_id + * @param int $status + * + * @return array Array of {@link XoopsComment} objects + **/ + function getThread($comment_rootid, $comment_id, $status = null) + { + $criteria = new CriteriaCompo(new Criteria('com_rootid', intval($comment_rootid))); + $criteria->add(new Criteria('com_id', intval($comment_id), '>=')); + if (isset($status)) { + $criteria->add(new Criteria('com_status', intval($status))); + } + return $this->getObjects($criteria); + } + + /** + * Update + * + * @param object &$comment {@link XoopsComment} object + * @param string $field_name Name of the field + * @param mixed $field_value Value to write + * + * @return bool + **/ + function updateByField(&$comment, $field_name, $field_value) + { + $comment->unsetNew(); + $comment->setVar($field_name, $field_value); + return $this->insert($comment); + } + + /** + * Delete all comments for one whole module + * + * @param int $module_id ID of the module + * @return bool + **/ + function deleteByModule($module_id) + { + return $this->deleteAll(new Criteria('com_modid', intval($module_id))); + } + + /** + * Change a value in multiple comments + * + * @param string $fieldname Name of the field + * @param string $fieldvalue Value to write + * @param object $criteria {@link CriteriaElement} + * + * @return bool + **/ + /* + function updateAll($fieldname, $fieldvalue, $criteria = null) + { + $set_clause = is_numeric($fieldvalue) ? $filedname.' = '.$fieldvalue : $filedname.' = '.$this->db->quoteString($fieldvalue); + $sql = 'UPDATE '.$this->db->prefix('xoopscomments').' SET '.$set_clause; + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { + $sql .= ' '.$criteria->renderWhere(); + } + if (!$result = $this->db->query($sql)) { + return false; + } + return true; + } + */ +} +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/class/commentrenderer.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/class/commentrenderer.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/class/commentrenderer.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,224 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +class MycommentsCommentRenderer { + + /**#@+ + * @access private + */ + var $_tpl; + var $_comments = null; + var $_useIcons = true; + var $_doIconCheck = false; + var $_memberHandler; + var $_statusText; + /**#@-*/ + + /** + * Constructor + * + * @param object &$tpl + * @param boolean $use_icons + * @param boolean $do_iconcheck + **/ + function MycommentsCommentRenderer(&$tpl, $use_icons = true, $do_iconcheck = false) + { + $this->_tpl =& $tpl; + $this->_useIcons = $use_icons; + $this->_doIconCheck = $do_iconcheck; + $this->_memberHandler =& xoops_gethandler('member'); + $this->_statusText = array(MYCOM_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #00ff00;">'._MA_MYCOM_PENDING.'</span>', MYCOM_ACTIVE => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">'._MA_MYCOM_ACTIVE.'</span>', MYCOM_HIDDEN => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">'._MA_MYCOM_HIDDEN.'</span>'); + } + + /** + * Access the only instance of this class + * + * @param object $tpl reference to a {@link Smarty} object + * @param boolean $use_icons + * @param boolean $do_iconcheck + * @return + **/ + function &instance(&$tpl, $use_icons = true, $do_iconcheck = false) + { + static $instance; + if (!isset($instance)) { + $instance = new MycommentsCommentRenderer($tpl, $use_icons, $do_iconcheck); + } + return $instance; + } + + /** + * Accessor + * + * @param object &$comments_arr array of {@link XoopsComment} objects + **/ + function setComments(&$comments_arr) + { + if (isset($this->_comments)) { + unset($this->_comments); + } + $this->_comments =& $comments_arr; + } + + /** + * Render the comments in flat view + * + * @param boolean $admin_view + **/ + function renderFlatView($admin_view = false, $modlink = '', $itemlink = '') + { + $count = count($this->_comments); + for ($i = 0; $i < $count; $i++) { + if (false != $this->_useIcons) { + $title = $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).' '.$this->_comments[$i]->getVar('com_title'); + } else { + $title = $this->_comments[$i]->getVar('com_title'); + } + $poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid')); + if (false != $admin_view) { + $text = $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid')).'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._MA_MYCOM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$this->_comments[$i]->getVar('com_ip').'</span></div>'; + } else { + // hide comments that are not active + if (MYCOM_ACTIVE != $this->_comments[$i]->getVar('com_status')) { + continue; + } else { + $text = $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid')); + } + } + $array[0] = $this->_comments[$i]->getVar('com_itemid'); + $item = mycomments_plugin_execute( $this->_comments[$i]->getVar('dirname') , $array/*$this->_comments[$i]->getVar('com_itemid')*/, 'iteminfo'); + $this->_tpl->append('comments', array( + 'id' => $this->_comments[$i]->getVar('com_id'), + 'title' => $title, + 'text' => $text, + 'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), + 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), + 'item_link' => $item[0]['link'], + 'item_title' => $item[0]['title'], + 'module_link' => XOOPS_URL.'/modules/'.$this->_comments[$i]->getVar('dirname'), + 'module_name' => $this->_comments[$i]->getVar('name'), + 'editcomment_link' => XOOPS_URL.'/modules/'.$this->_comments[$i]->getVar('dirname').'/comment_edit.php?com_itemid='.$this->_comments[$i]->getVar('com_itemid'), + 'deletecomment_link' => XOOPS_URL.'/modules/'.$this->_comments[$i]->getVar('dirname').'/comment_delete.php?com_itemid='.$this->_comments[$i]->getVar('com_itemid'), + 'replycomment_link' => XOOPS_URL.'/modules/'.$this->_comments[$i]->getVar('dirname').'/comment_reply.php?com_itemid='.$this->_comments[$i]->getVar('com_itemid'), + 'poster' => $poster)); + } + } + + /** + * Get the name of the poster + * + * @param int $poster_id + * @return string + * + * @access private + **/ + function _getPosterName($poster_id) + { + $poster['id'] = intval($poster_id); + if ($poster['id'] > 0) { + $com_poster =& $this->_memberHandler->getUser($poster_id); + if (is_object($com_poster)) { + $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>'; + return $poster; + } + } + $poster['id'] = 0; // to cope with deleted user accounts + $poster['uname'] = $GLOBALS['xoopsConfig']['anonymous']; + return $poster; + } + + /** + * Get an array with info about the poster + * + * @param int $poster_id + * @return array + * + * @access private + **/ + function _getPosterArray($poster_id) + { + $poster['id'] = intval($poster_id); + if ($poster['id'] > 0) { + $com_poster =& $this->_memberHandler->getUser($poster['id']); + if (is_object($com_poster)) { + $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>'; + $poster_rank = $com_poster->rank(); + $poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif'; + $poster['rank_title'] = $poster_rank['title']; + $poster['avatar'] = $com_poster->getVar('user_avatar'); + $poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's'); + $poster['from'] = $com_poster->getVar('user_from'); + $poster['postnum'] = $com_poster->getVar('posts'); + $poster['status'] = $com_poster->isOnline() ? _MA_MYCOM_ONLINE : ''; + return $poster; + } + } + $poster['id'] = 0; // to cope with deleted user accounts + $poster['uname'] = $GLOBALS['xoopsConfig']['anonymous']; + $poster['rank_title'] = ''; + $poster['avatar'] = 'blank.gif'; + $poster['regdate'] = ''; + $poster['from'] = ''; + $poster['postnum'] = 0; + $poster['status'] = ''; + return $poster; + } + + /** + * Get the IMG tag for the title icon + * + * @param string $icon_image + * @return string HTML IMG tag + * + * @access private + **/ + function _getTitleIcon($icon_image) + { + $icon_image = htmlspecialchars( trim( $icon_image ) ); + if ($icon_image != '') { + if (false != $this->_doIconCheck) { + if (!file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) { + return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; + } else { + return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />'; + } + } else { + return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />'; + } + } + return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; + } + + /** + * Get Text with Signature + * + * @param string $text + * @param int $uid + * @return string + * + * @access private + **/ + function _getText($text='', $uid=0) + { + global $xoopsConfig, $xoopsUser; + if ( $uid != 0 ) { + $poster = new XoopsUser($uid); + if ( !$poster->isActive() ) { + $poster = 0; + } + } else { + $poster = 0; + } + + if ( $poster ) { + if ( $poster->getVar("attachsig") ) { + $text .= "<p><br />_________________<br />". $poster->user_sig()."</p>"; + } + } + return $text; + } + +} +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/class/index.html =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/class/index.html (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/class/index.html 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/mycomments/releases/1.0/mycomments/images/img.gif =================================================================== (Binary files differ) Property changes on: XoopsModules/mycomments/releases/1.0/mycomments/images/img.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: XoopsModules/mycomments/releases/1.0/mycomments/images/slogo.png =================================================================== (Binary files differ) Property changes on: XoopsModules/mycomments/releases/1.0/mycomments/images/slogo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: XoopsModules/mycomments/releases/1.0/mycomments/images/xuupslogo.png =================================================================== (Binary files differ) Property changes on: XoopsModules/mycomments/releases/1.0/mycomments/images/xuupslogo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: XoopsModules/mycomments/releases/1.0/mycomments/include/comment_constants.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/include/comment_constants.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/include/comment_constants.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,15 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +define('MYCOM_APPROVENONE', 0); +define('MYCOM_APPROVEALL', 1); +define('MYCOM_APPROVEUSER', 2); +define('MYCOM_APPROVEADMIN', 3); +define('MYCOM_PENDING', 1); +define('MYCOM_ACTIVE', 2); +define('MYCOM_HIDDEN', 3); +define('MYCOM_OLD1ST', 0); +define('MYCOM_NEW1ST', 1); +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/include/functions.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/include/functions.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/include/functions.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,118 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +function mycomments_plugin_execute($dirname, $items, $func = 'useritems') +{ + global $xoopsUser, $xoopsConfig, $xoopsDB; + + $ret = array(); + $plugins_path = XOOPS_ROOT_PATH . "/modules/mycomments/plugins"; + + $plugin_info = mycomments_get_plugin_info( $dirname , $func ) ; + + if( empty( $plugin_info ) || empty( $plugin_info['plugin_path'] ) ) return false ; + include_once $plugin_info['plugin_path'] ; + + // call the plugin + if( function_exists( @$plugin_info['func'] ) ) { + // get the list of items + $ret = $plugin_info['func']($items, $limit=0, $offset=0); + } + + return $ret ; +} + +function mycomments_get_plugin_info( $dirname , $func = 'useritems' ) +{ + global $xoopsConfig; + $language = $xoopsConfig['language']; + // get $mytrustdirname for D3 modules + $mytrustdirname = '' ; + if( defined( 'XOOPS_TRUST_PATH' ) && file_exists( XOOPS_ROOT_PATH."/modules/".$dirname."/mytrustdirname.php" ) ) { + @include XOOPS_ROOT_PATH."/modules/".$dirname."/mytrustdirname.php" ; + $d3module_plugin_file = XOOPS_TRUST_PATH."/modules/".$mytrustdirname."/include/mycomments.plugin.php" ; + } + + $module_plugin_file = XOOPS_ROOT_PATH."/modules/".$dirname."/include/mycomments.plugin.php" ; + $builtin_plugin_file = XOOPS_ROOT_PATH."/modules/mycomments/plugins/".$dirname.".php" ; + + if( file_exists( $module_plugin_file ) ) { + // module side (1st priority) + $ret = array( + 'plugin_path' => $module_plugin_file , + 'func' => $dirname.'_'.$func , + 'type' => 'module' , + ) ; + } else if( ! empty( $mytrustdirname ) && file_exists( $d3module_plugin_file ) ) { + // D3 module's plugin under xoops_trust_path (2nd priority) + $ret = array( + 'plugin_path' => $d3module_plugin_file , + 'func' => $mytrustdirname.'_'.$func , + 'type' => 'module (D3)' , + ) ; + } else if( file_exists( $builtin_plugin_file ) ) { + // built-in plugin under modules/mycomments (3rd priority) + $ret = array( + 'plugin_path' => $builtin_plugin_file , + 'func' => $dirname.'_'.$func , + 'type' => 'built-in' , + ) ; + } else { + $ret = array() ; + } + + return $ret ; +} + +function mycomments_advanced_search($queryarray, $andor, $limit, $offset, $userid, $moduleid, $items){ + global $xoopsDB; + include_once( XOOPS_ROOT_PATH . "/modules/mycomments/class/comment.php" ) ; + $sql = "SELECT * FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_id>0 "; + if ( $moduleid != 0 ) { + $sql .= " AND com_modid=".$moduleid." "; + } + if ( $userid != 0 ) { + $sql .= " AND com_uid=".$userid." "; + } + // because count() returns 1 even if a supplied variable + // is not an array, we must check if $querryarray is really an array + if ( is_array($queryarray) && $count = count($queryarray) ) { + $sql .= " AND ((com_title LIKE '%$queryarray[0]%' OR com_text LIKE '%$queryarray[0]%')"; + for($i=1;$i<$count;$i++){ + $sql .= " $andor "; + $sql .= "(com_title LIKE '%$queryarray[$i]%' OR com_text LIKE '%$queryarray[$i]%')"; + } + $sql .= ") "; + } + + if(is_array($items) && count($items)>0) { + $sql .= ' AND com_itemid IN ('.implode(',', $items).')'; + } + + $sql .= "ORDER BY com_created DESC"; + $result = $xoopsDB->query($sql,$limit,$offset); + + $module_handler =& xoops_gethandler('module'); + $modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true); + + + $ret = array(); + $i = 0; + while($myrow = $xoopsDB->fetchArray($result)){ + $id_as_key = false; + $comment = new MycommentsComment(); + $comment->assignVars($myrow); + if (!$id_as_key) { + $ret[] =& $comment; + } else { + $ret[$myrow['com_id']] =& $comment; + } + unset($comment); + } + return $ret; +} + +?> + Added: XoopsModules/mycomments/releases/1.0/mycomments/include/index.html =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/include/index.html (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/include/index.html 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/mycomments/releases/1.0/mycomments/include/search.inc.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/include/search.inc.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/include/search.inc.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,57 @@ +<?php +// Author: Trabis, Kaper +// URL: http://www.xuups.com, http://kaper.zk-p.pl +// E-Mail: lus...@gm... , ka...@zk... + +function mycomments_search($queryarray, $andor, $limit, $offset, $userid){ + global $xoopsDB; + $sql = "SELECT com_id, com_pid, com_rootid, com_modid, com_itemid, com_created, com_uid, com_title, com_text, com_status FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_id>0 "; + if ( $userid != 0 ) { + $sql .= " AND com_uid=".$userid." "; + } + // because count() returns 1 even if a supplied variable + // is not an array, we must check if $querryarray is really an array + if ( is_array($queryarray) && $count = count($queryarray) ) { + $sql .= " AND ((com_title LIKE '%$queryarray[0]%' OR com_text LIKE '%$queryarray[0]%')"; + for($i=1;$i<$count;$i++){ + $sql .= " $andor "; + $sql .= "(com_title LIKE '%$queryarray[$i]%' OR com_text LIKE '%$queryarray[$i]%')"; + } + $sql .= ") "; + } + $sql .= "ORDER BY com_created DESC"; + $result = $xoopsDB->query($sql,$limit,$offset); + + $module_handler =& xoops_gethandler('module'); + $modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true); + + $ret = array(); + $i = 0; + while($myrow = $xoopsDB->fetchArray($result)){ + + $com_id = $myrow['com_id']; + $com_modid=$myrow['com_modid']; + $com_pid=$myrow['com_pid']; + $com_rootid=$myrow['com_rootid']; + $com_itemid=$myrow['com_itemid']; + + $comment_config = array(); + $comment_config = $modules[$com_modid]->getInfo('comments'); + + $link = "../".$modules[$com_modid]->getVar('dirname').'/'; + $link .= $comment_config['pageName'].'?'; + $link .= $comment_config['itemName'].'='; + $link .= $com_itemid.'&com_id='.$com_id.'&com_rootid='.$com_rootid; + $link .= '&com_mode=thread&#comment'.$com_id; + + $ret[$i]['image'] = "images/img.gif"; + $ret[$i]['link'] = $link; + $ret[$i]['title'] = $myrow['com_title']; + $ret[$i]['time'] = $myrow['com_created']; + $ret[$i]['uid'] = $myrow['com_uid']; + $i++; + } + return $ret; +} + +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/index.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/index.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/index.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,216 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... + +include_once "../../mainfile.php"; +include_once XOOPS_ROOT_PATH.'/modules/mycomments/include/functions.php'; +include_once XOOPS_ROOT_PATH.'/modules/mycomments/class/commentrenderer.php'; +include_once XOOPS_ROOT_PATH.'/modules/mycomments/include/comment_constants.php'; + +$uid = is_object($xoopsUser)? $xoopsUser->getVar('uid') : 0; +if ($uid == 0) { + redirect_header(XOOPS_URL,2,_NOPERM); + exit(); +} +$uid = isset($_GET['uid']) ? intval($_GET['uid']) : $uid; + +$start = (isset($_GET['start'])) ? intval($_GET['start']) : 0; +$mid = (isset($_GET['mid'])) ? intval($_GET['mid']) : 0; + +$d_view = 0; //set 0 for default comments recieved or 1 for default comments sent +$view_array = array('0' => _MA_MYCOM_COM_RECIEVED, '1' => _MA_MYCOM_COM_SENT); +$view = (isset($_GET['view']) && array_key_exists(intval($_GET['view']), $view_array)) ? intval($_GET['view']) : $d_view; + +$d_limit = $xoopsModuleConfig['comnum']; +$limit_array = array('5' => 5, '10' => 10, '20' => 20, '50' => 50, '100' => 100); +$limit = (isset($_GET['limit']) && array_key_exists(intval($_GET['limit']), $limit_array)) ? intval($_GET['limit']) : $d_limit; + +if ($uid == 0) { + redirect_header(XOOPS_URL,2,_NOPERM); + exit(); +} + +$myts =& MyTextSanitizer::getInstance(); +$xoopsOption['template_main'] = 'mycomments_comments.html'; +include_once XOOPS_ROOT_PATH.'/header.php'; + +$thisuser = new XoopsUser($uid); + +switch($xoopsModuleConfig['displayname']) { + case 1: // Username + $username = $thisuser->getVar('uname'); + break; + + case 2: // Display full name (if it is not empty) + if(xoops_trim($thisuser->getVar('name')) == '') { + $username = $thisuser->getVar('uname'); + } else { + $username = $thisuser->getVar('name'); + } + break; +} + +// admins can view all comments and IPs, others can only view approved(active) comments +if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { + $admin_view = true; +} else { + $admin_view = false; +} + + +$module_handler =& xoops_gethandler('module'); +$comments_handler =& xoops_getmodulehandler('comment'); + +$criteria = new CriteriaCompo(new Criteria('hascomments', 1)); +if ($mid > 0) $criteria->add(new Criteria('mid', $mid), 'AND'); +$modules =& $module_handler->getObjects($criteria, true); +unset($criteria); + +$criteria = new CriteriaCompo(); +$criteria2 = new CriteriaCompo(); +foreach( $modules as $moduleid => $module ) { + //for comments recieved + if ($view == 0){ + $items = array(); + $items = mycomments_plugin_execute( $module->getVar('dirname') , $uid, 'useritems'); + if (is_array($items) && count($items)>0){ + $items = '('.implode(',',$items).')'; + $dirname = $module->getVar('dirname'); + $$dirname = new CriteriaCompo(new Criteria('com_modid', $moduleid)); + $$dirname->add(new Criteria('com_itemid', $items, 'IN'), 'AND'); + $criteria->add($$dirname,'OR'); + } else { + //ugly fix, sorry + $criteria->add(new CriteriaCompo(new Criteria('1', 2)),'OR'); + } + unset($items); + //for comments sent + } else { + $items = array(); + $items = mycomments_get_plugin_info( $module->getVar('dirname') , 'useritems'); + if (is_array($items) && count($items)>0){ + $dirname = $module->getVar('dirname'); + $$dirname = new Criteria('com_modid', $moduleid); + $criteria2->add($$dirname,'OR'); + } else { + //ugly fix, sorry + $criteria2->add(new CriteriaCompo(new Criteria('1', 2)),'OR'); + } + unset($items); + } +} +if ($view ==1 ) { + $criteria->add($criteria2); + $criteria->add(new Criteria('com_uid', $uid)); +} +$criteria->setSort('com_id'); +$criteria->setOrder('DESC'); +$criteria->setLimit($limit); +$criteria->setStart($start); + +$comments =& $comments_handler->getObjects($criteria); +$com_count =& $comments_handler->getCount($criteria); +$renderer =& MycommentsCommentRenderer::instance($xoopsTpl); +$renderer->setComments($comments); +$renderer->renderFlatView($admin_view); +unset($criteria); + +$gperm_handler = & xoops_gethandler( 'groupperm' ); +$groups = ( $xoopsUser ) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS; +$xoopsTpl->assign( 'xoops_iscommentadmin', $gperm_handler->checkRight( 'system_admin', 14, $groups) ); + +$count_string = ($com_count != 1 )?_MA_MYCOM_NCOMMENTS:_MA_MYCOM_NCOMMENT; +$xoopsTpl->assign( 'com_count', sprintf($count_string, $com_count)); + +$com_order=$com_mode=$link_extra=''; + +// assign some lang variables +$xoopsTpl->assign(array( + 'lang_from' => _MA_MYCOM_FROM, + 'lang_joined' => _MA_MYCOM_JOINED, + 'lang_posts' => _MA_MYCOM_POSTS, + 'lang_poster' => _MA_MYCOM_POSTER, + 'lang_thread' => _MA_MYCOM_THREAD, + 'lang_edit' => _EDIT, + 'lang_delete' => _DELETE, + 'lang_reply' => _REPLY, + 'lang_subject' => _MA_MYCOM_REPLIES, + 'lang_posted' => _MA_MYCOM_POSTED, + 'lang_updated' => _MA_MYCOM_UPDATED, + 'lang_notice' => _MA_MYCOM_NOTICE) +); + + +//For the navbar, get all modules that have plugins + +$mod_array = array(); +//Lets save a query, if no $mid is set then we already have $modules correctly populated +if ($mid > 0){ + $modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true); +} + +foreach( $modules as $moduleid => $module ) { + $items = array(); + $items = mycomments_get_plugin_info( $module->getVar('dirname'), 'useritems'); + if (is_array($items) && count($items)>0){ + $mod_array[$module->getVar('mid')] = $module->getVar('name'); + } + unset($items); +} +//Now lets create the form fields +$sel = ''; +if ("0" == $mid) { + $sel = ' selected="selected"'; +} +$mod_options = '<option value="0"'.$sel.'>'._MA_MYCOM_ALL.'</option>'; +foreach($mod_array as $key=>$value) { + $sel = ''; + if ($key == $mid) { + $sel = ' selected="selected"'; + } + $mod_options .= '<option value="'.$key.'"'.$sel.'>'.$value.'</option>'; +} +$xoopsTpl->assign('mod_options', $mod_options); + + +$view_options = ''; +foreach($view_array as $key=>$value) { + $sel = ''; + if ($key == $view) { + $sel = ' selected="selected"'; + } + $view_options .= '<option value="'.$key.'"'.$sel.'>'.$value.'</option>'; +} +$xoopsTpl->assign('view_options', $view_options); + +$limit_options = ''; +foreach($limit_array as $key=>$value) { + $sel = ''; + if ($key == $limit) { + $sel = ' selected="selected"'; + } + $limit_options .= '<option value="'.$key.'"'.$sel.'>'.$value.'</option>'; +} +$xoopsTpl->assign('limit_options', $limit_options); + +if ( $com_count > $limit ) { + include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; + $pagenav_args = 'mid='.$mid; + if ($d_view != $view) $pagenav_args .='&view='.$view; + if ($d_limit != $limit) $pagenav_args .='&limit='.$limit; + $pagenav = new XoopsPageNav($com_count, $limit, $start, 'start',$pagenav_args); + $xoopsTpl->assign('pagenav', $pagenav->renderNav()); +} else { + $xoopsTpl->assign('pagenav', ''); +} +$xoopsTpl->assign('lang_go', _GO); + +//navbar +$xoopsTpl->assign('module_name',$xoopsModule->getVar('name')); +$xoopsTpl->assign('module_dirname',$xoopsModule->getVar('dirname')); +$xoopsTpl->assign('user_name','<a href="'.XOOPS_URL.'/userinfo.php?uid='.$uid.'">'.$username.'</a>'); +$xoopsTpl->assign('lang_home',_MA_MYCOM_HOME); + +include_once XOOPS_ROOT_PATH.'/footer.php'; +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/language/english/blocks.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/language/english/blocks.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/language/english/blocks.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,6 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... +define("_MB_MYCOM_DISPLAYC","Display %s comments"); +?> Added: XoopsModules/mycomments/releases/1.0/mycomments/language/english/index.html =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/language/english/index.html (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/language/english/index.html 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/mycomments/releases/1.0/mycomments/language/english/main.php =================================================================== --- XoopsModules/mycomments/releases/1.0/mycomments/language/english/main.php (rev 0) +++ XoopsModules/mycomments/releases/1.0/mycomments/language/english/main.php 2012-07-31 12:24:26 UTC (rev 9957) @@ -0,0 +1,51 @@ +<?php +// Author: Trabis +// URL: http://www.xuups.com +// E-Mail: lus...@gm... +define('_MA_MYCOM_TITLE','Title'); +define('_MA_MYCOM_MESSAGE','Message'); +define('_MA_MYCOM_DOSMILEY','Enable Smiley Icons'); +define('_MA_MYCOM_DOHTML','Enable HTML Tags'); +define('_MA_MYCOM_DOAUTOWRAP','Auto wrap lines'); +define('_MA_MYCOM_DOXCODE','Enable XOOPS Codes'); +define('_MA_MYCOM_REFRESH','Refresh'); +define('_MA_MYCOM_PENDING','Pending'); +define('_MA_MYCOM_HIDDEN','Hidden'); +define('_MA_MYCOM_ACTIVE','Active'); +define('_MA_MYCOM_STATUS','Status'); +define('_MA_MYCOM_POSTCOMMENT','Post Comment'); +define('_MA_MYCOM_REPLIES','Replies'); +define('_MA_MYCOM_PARENT','Parent'); +define('_MA_MYCOM_TOP','Top'); +define('_MA_MYCOM_BOTTOM','Bottom'); +define('_MA_MYCOM_ONLINE','Online!'); +define('_MA_MYCOM_POSTED','Posted'); // Posted date +define('_MA_MYCOM_UPDATED', 'Updated'); +define('_MA_MYCOM_THREAD','Thread'); +define('_MA_MYCOM_POSTER','Poster'); +define('_MA_MYCOM_JOINED','Joined'); +define('_MA_MYCOM_POSTS','Posts'); +define('_MA_MYCOM_FROM','From'); +define('_MA_MYCOM_COMDELETED', 'Comment(s) deleted.'); +define('_MA_MYCOM_COMDELETENG', 'Could not delete comment.'); +define('_MA_MYCOM_DELETESELECT' , 'Delete all its child comments?'); +define('_MA_MYCOM_DELETEONE' , 'No, delete only this comment'); +define('_MA_MYCOM_DELETEALL', 'Yes, delete all'); +define('_MA_MYCOM_THANKSPOST', 'Thanks for posting!'); +define(... [truncated message content] |