示例#1
0
 /** 
  * Gets categories data 
  * 
  * @return array 
  */
 function getCategories()
 {
     global $mainframe, $option;
     static $items;
     if (isset($items)) {
         return $items;
     }
     $params = JComponentHelper::getParams('com_discussions');
     $_dateformat = $params->get('dateformat', '%d.%m.%Y');
     $_timeformat = $params->get('timeformat', '%H:%i');
     $db =& $this->getDBO();
     $user =& JFactory::getUser();
     $logUser = new CofiUser($user->id);
     if ($logUser->isModerator()) {
         // show me all categories
         $query = "SELECT c.id, c.parent_id, c.name, c.alias, c.description, c.image, c.show_image, c.published, \n\t\t\t\t\t\tc.counter_posts, c.counter_threads, \n\t\t\t\t\t\tDATE_FORMAT( c.last_entry_date, '" . $_dateformat . " " . $_timeformat . "') AS last_entry_date, c.last_entry_user_id, u.username,\n\t\t\t\t\t\tCASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as slug\n\t\t\t\t\t\tFROM " . $db->nameQuote('#__discussions_categories') . "c LEFT JOIN  (" . $db->nameQuote('#__users') . " u) ON u.id=c.last_entry_user_id \n\t\t\t\t\t\tWHERE c.published='1' ORDER by c.ordering ASC";
     } else {
         // only show the public forums (privates are hidden)
         $query = "SELECT c.id, c.parent_id, c.name, c.alias, c.description, c.image, c.show_image, c.published, \n\t\t\t\t\t\tc.counter_posts, c.counter_threads, \n\t\t\t\t\t\tDATE_FORMAT( c.last_entry_date, '" . $_dateformat . " " . $_timeformat . "') AS last_entry_date, c.last_entry_user_id, u.username,\n\t\t\t\t\t\tCASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as slug\n\t\t\t\t\t\tFROM " . $db->nameQuote('#__discussions_categories') . "c LEFT JOIN  (" . $db->nameQuote('#__users') . " u) ON u.id=c.last_entry_user_id \n\t\t\t\t\t\tWHERE c.private='0' AND c.published='1' ORDER by c.ordering ASC";
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $children = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $pt = $row->parent_id;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $row);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children);
     $items = $list;
     return $items;
 }
示例#2
0
 /**
  * Constructor
  *
  * @since 1.5
  */
 function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $this->_task = JRequest::getString('task', '');
     $this->_thread = JRequest::getInt('thread', 0);
     $this->_categoryFrom = JRequest::getInt('catid', 0);
     $this->_categoryTo = JRequest::getInt('catidto', 0);
     $this->_post = JRequest::getInt('post', 0);
     if ($this->_post == 0) {
         $this->_post = JRequest::getInt('id', 0);
     }
     $user =& JFactory::getUser();
     $logUser = new CofiUser($user->id);
     if ($logUser->isModerator()) {
         switch ($this->_task) {
             case "move":
                 $this->_headline = JText::_('COFI_MOVE_THREAD');
                 if ($this->_categoryTo > 0) {
                     // move it now
                     $this->moveThread();
                 }
                 break;
             case "sticky":
                 $this->stickyThread();
                 break;
             case "unsticky":
                 $this->unstickyThread();
                 break;
             case "lock":
                 $this->lockThread();
                 break;
             case "unlock":
                 $this->unlockThread();
                 break;
             case "accept":
                 $this->acceptPost($this->_post);
                 break;
             case "deny":
                 $this->denyPost($this->_post);
                 break;
             case "createmsgaliases":
                 $this->createMsgAliases();
                 break;
             case "delete":
                 $this->deletePost($this->_post);
                 break;
             default:
                 break;
         }
     } else {
         // not allowed
         // redirect	link
         $redirectLink = JRoute::_("index.php?option=com_discussions&view=category&catid=" . $this->_categoryFrom);
         $app->redirect($redirectLink, JText::_('COFI_NO_ACCESS_TO_MODERATOR_FUNCTIONS'), "notice");
     }
 }
示例#3
0
 /** 
  * Gets Threads data 
  * 
  * @return array 
  */
 function getThreads()
 {
     global $mainframe;
     //     	$_catid = JRequest::getVar('catid', 0);
     $_catid = JRequest::getInt('catid', 0);
     if ($this->getExistStatus() != null) {
         // check if this category exists
         // 1. check if this is a private (moderator only) forum
         if ($this->getPrivateStatus() == 1) {
             // 2. if it is private -> check if this user is a moderator
             $user =& JFactory::getUser();
             $logUser = new CofiUser($user->id);
             if ($logUser->isModerator() == 0) {
                 // user is not moderator -> kick him out of here
                 $redirectLink = JRoute::_("index.php?option=com_discussions");
                 $mainframe->redirect($redirectLink, JText::_('COFI_NO_ACCESS_TO_FORUM'), "notice");
             }
         }
         $db =& $this->getDBO();
         // Load threads if they doesn't exist
         if (empty($this->_data)) {
             $selectQuery = $this->_buildSelectQuery();
             $limitstart = $this->getState('limitstart');
             $limit = $this->getState('limit');
             $this->_data = $this->_getList($selectQuery, $limitstart, $limit);
         }
         // return the category list data
         return $this->_data;
     } else {
         // category does not exist
         $redirectLink = JRoute::_("index.php?option=com_discussions");
         $mainframe->redirect($redirectLink, JText::_('COFI_FORUM_NOT_EXISTS'), "notice");
     }
 }
示例#4
0
 function getMoveToSelectBox()
 {
     $user =& JFactory::getUser();
     $logUser = new CofiUser($user->id);
     if ($logUser->isModerator() == 1) {
         $db =& JFactory::getDBO();
         $html = "<select class='quickselectbox' name='catidto'>";
         // get all published category groups
         $sql_groups = "SELECT id, name FROM " . $db->nameQuote('#__discussions_categories') . " WHERE parent_id='0' AND published='1'" . " ORDER BY ordering ASC";
         $db->setQuery($sql_groups);
         $_group_list = $db->loadAssocList();
         reset($_group_list);
         while (list($key, $val) = each($_group_list)) {
             $group_id = $_group_list[$key]['id'];
             $group_name = $_group_list[$key]['name'];
             $html .= "<optgroup label='" . $group_name . "'>";
             /* get categories from this group */
             $sql_categories = "SELECT id, name FROM " . $db->nameQuote('#__discussions_categories') . " WHERE parent_id='" . $group_id . "' AND published='1'" . " ORDER BY ordering ASC";
             $db->setQuery($sql_categories);
             $_category_list = $db->loadAssocList();
             reset($_category_list);
             while (list($key, $val) = each($_category_list)) {
                 $category_id = $_category_list[$key]['id'];
                 $category_name = $_category_list[$key]['name'];
                 $html .= "<option value='" . $category_id . "'>" . $category_name;
             }
             /* get categories from this group */
             $html .= "</optgroup>";
         }
         $html .= "</select>";
         return $html;
     } else {
         // return an empty string when not moderator
         return "";
     }
 }
示例#5
0
    echo "<td width='16' align='center' valign='middle' class='noborder' style='padding-left: 0px;'>";
    echo "<img src='" . $_root . "components/com_discussions/assets/system/lastentry.png' style='margin-left: 5px; margin-right: 5px; border:0px;' />";
    echo "</td>";
    echo "<td align='left' valign='middle' class='noborder'>";
    $menuLinkLastTMP = "index.php?option=com_discussions&view=thread&catid=" . $this->categorySlug . "&thread=" . $this->threadSlug;
    $menuLinkLastTMP .= $this->lastEntryJumpPoint;
    $menuLinkLast = JRoute::_($menuLinkLastTMP);
    echo "<a href='" . $menuLinkLast . "'>" . JText::_('COFI_GOTO_LAST_ENTRY') . "</a>";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
} else {
    // user is logged in
    echo "<table class='noborder' style='margin:20px 0px 20px 0px;'>";
    echo "<tr>";
    if ($this->lockedStatus == 0 || $logUser->isModerator()) {
        // thread is not locked or user is moderator
        echo "<td width='16' align='center' valign='middle' class='noborder' style='padding-left: 0px;' >";
        echo "<img src='" . $_root . "components/com_discussions/assets/threads/reply.png' style='margin-left: 15px; margin-right: 5px; border:0px;' />";
        echo "</td>";
        echo "<td align='left' valign='middle' class='noborder'>";
        $menuLinkReplyTMP = "index.php?option=com_discussions&view=posting&task=reply&catid=" . $this->categorySlug . "&thread=" . $this->thread . "&parent=" . $this->threadId;
        $menuLinkReply = JRoute::_($menuLinkReplyTMP);
        echo "<a href='" . $menuLinkReply . "'>" . JText::_('COFI_REPLY1') . "</a>";
        echo "</td>";
    }
    echo "<td width='16' align='center' valign='middle' class='noborder' style='padding-left: 20px;'>";
    echo "<img src='" . $_root . "components/com_discussions/assets/threads/new.png' style='margin-left: 5px; margin-right: 5px; border:0px;' />";
    echo "</td>";
    echo "<td align='left' valign='middle' class='noborder'>";
    $menuLinkNewTMP = "index.php?option=com_discussions&view=posting&task=new&catid=" . $this->categorySlug;
示例#6
0
 /**
  * save posting
  *
  * @return int
  */
 function savePosting()
 {
     //global $mainframe;
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_discussions');
     $_dateformat = $params->get('dateformat', 'd.m.Y');
     $_timeformat = $params->get('timeformat', 'H:i');
     $user =& JFactory::getUser();
     $logUser = new CofiUser($user->id);
     $CofiHelper = new CofiHelper();
     $this->_headline = "";
     $this->_dbmode = JRequest::getString('dbmode', '');
     $_postSubject = JRequest::getString('postSubject', '', 'POST', JREQUEST_ALLOWRAW);
     $_postSubject = strip_tags($_postSubject);
     $_postText = JRequest::getString('postText', '', 'POST', JREQUEST_ALLOWRAW);
     $_postText = strip_tags($_postText);
     $_image1_description = JRequest::getString('image1_description', '');
     $_image1_description = strip_tags($_image1_description);
     $_image2_description = JRequest::getString('image2_description', '');
     $_image2_description = strip_tags($_image2_description);
     $_image3_description = JRequest::getString('image3_description', '');
     $_image3_description = strip_tags($_image3_description);
     $_image4_description = JRequest::getString('image4_description', '');
     $_image4_description = strip_tags($_image4_description);
     $_image5_description = JRequest::getString('image5_description', '');
     $_image5_description = strip_tags($_image5_description);
     $_postCatId = JRequest::getInt('catid', '0');
     $_postThread = JRequest::getInt('thread', '0');
     $_postParent = JRequest::getInt('parent', '0');
     $_postId = JRequest::getInt('id', '0');
     // get user IP address
     $_postIpAddress = $_SERVER['REMOTE_ADDR'];
     // redirect	link
     $redirectLink = JRoute::_("index.php?option=com_discussions&view=category&catid=" . $this->getCategorySlug());
     // check if user is logged in - maybe session has timed out
     if ($user->guest) {
         // if user is not logged in, kick him back into category
         $app->redirect($redirectLink, JText::_('COFI_POST_NOT_SAVED'), "message");
     }
     // 1. check if subject >= 5 chars
     // todo make minimum subject length configurable
     if (strlen($_postSubject) < 5) {
         $isSubjectTooShort = true;
     } else {
         $isSubjectTooShort = false;
     }
     // 2. check if text >= 5 chars
     // todo make minimum text length configurable
     if (strlen($_postText) < 5) {
         $isTextTooShort = true;
     } else {
         $isTextTooShort = false;
     }
     // check if insert or update
     // update
     if ($this->_dbmode == "update") {
         if (!$isSubjectTooShort && !$isTextTooShort) {
             // check if subject and text have minimum length
             $db =& $this->getDBO();
             // insert last edit time stamp
             $_unixtime = time();
             // todo change date, time calculation
             // get rid of the percentage symbol %
             $_dateformat = str_replace("%", "", $_dateformat);
             $_timeformat = str_replace("%", "", $_timeformat);
             //$_timeformat = "g:i A";
             $_date = date($_dateformat, $_unixtime);
             $_time = date($_timeformat, $_unixtime);
             $_timestamp = "\n\n" . JText::_('COFI_EDITED_BY') . " " . $user->username . " - " . $_date . " " . $_time;
             $_postText .= $_timestamp;
             if ($logUser->isModerator()) {
                 // moderators are allowed to edit all posts
                 $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET" . " message = " . $db->Quote($_postText) . ", " . " image1_description = " . $db->Quote($_image1_description) . ", " . " image2_description = " . $db->Quote($_image2_description) . ", " . " image3_description = " . $db->Quote($_image3_description) . ", " . " image4_description = " . $db->Quote($_image4_description) . ", " . " image5_description = " . $db->Quote($_image5_description) . " WHERE id = '" . $_postId . "'";
             } else {
                 // no mod? then user must be owner
                 $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET" . " message = " . $db->Quote($_postText) . ", " . " image1_description = " . $db->Quote($_image1_description) . ", " . " image2_description = " . $db->Quote($_image2_description) . ", " . " image3_description = " . $db->Quote($_image3_description) . ", " . " image4_description = " . $db->Quote($_image4_description) . ", " . " image5_description = " . $db->Quote($_image5_description) . " WHERE id = '" . $_postId . "' AND user_id = '" . $user->id . "'";
             }
             $db->setQuery($sql);
             $result = $db->query();
             // check if there are images to delete
             // get folder name
             $rootDir = JPATH_ROOT;
             $cb_image1 = JRequest::getString('cb_image1', '', 'POST');
             $cb_image2 = JRequest::getString('cb_image2', '', 'POST');
             $cb_image3 = JRequest::getString('cb_image3', '', 'POST');
             $cb_image4 = JRequest::getString('cb_image4', '', 'POST');
             $cb_image5 = JRequest::getString('cb_image5', '', 'POST');
             if ($cb_image1 == "delete") {
                 $this->del_image($_postThread, $_postId, "image1", $rootDir, $db, 1);
             }
             if ($cb_image2 == "delete") {
                 $this->del_image($_postThread, $_postId, "image2", $rootDir, $db, 2);
             }
             if ($cb_image3 == "delete") {
                 $this->del_image($_postThread, $_postId, "image3", $rootDir, $db, 3);
             }
             if ($cb_image4 == "delete") {
                 $this->del_image($_postThread, $_postId, "image4", $rootDir, $db, 4);
             }
             if ($cb_image5 == "delete") {
                 $this->del_image($_postThread, $_postId, "image5", $rootDir, $db, 5);
             }
             if ($result) {
                 // update went fine
                 // upload images to id folder
                 if (isset($_FILES['image1']) and !$_FILES['image1']['error']) {
                     $this->add_image($_postThread, $_postId, "image1", $rootDir, $db, 1);
                 }
                 if (isset($_FILES['image2']) and !$_FILES['image2']['error']) {
                     $this->add_image($_postThread, $_postId, "image2", $rootDir, $db, 2);
                 }
                 if (isset($_FILES['image3']) and !$_FILES['image3']['error']) {
                     $this->add_image($_postThread, $_postId, "image3", $rootDir, $db, 3);
                 }
                 if (isset($_FILES['image4']) and !$_FILES['image4']['error']) {
                     $this->add_image($_postThread, $_postId, "image4", $rootDir, $db, 4);
                 }
                 if (isset($_FILES['image5']) and !$_FILES['image5']['error']) {
                     $this->add_image($_postThread, $_postId, "image5", $rootDir, $db, 5);
                 }
             }
         }
     } else {
         if (!$isSubjectTooShort && !$isTextTooShort) {
             // check if subject and text have minimum length
             $db =& $this->getDBO();
             // preset is published and not moderated (normal state)
             $published = 1;
             $wfm = 0;
             // wfm = waiting for moderation
             if ($logUser->isModerator() == 0) {
                 // bypass these checks if user is moderator
                 // 1. check for rookie mode
                 // get Rookie Mode setting from com_discussions parameters
                 $rookie = $params->get('rookie', '0');
                 if ($rookie > 0) {
                     // we are in rookie mode
                     if ($logUser->isRookie() == 1) {
                         // user is a rookie
                         $wfm = 1;
                         // wfm = waiting for moderation
                         $published = 0;
                     }
                 }
                 // 2. check if this is a moderated user
                 if ($logUser->isModerated() == 1) {
                     // user is moderated
                     $wfm = 1;
                     // wfm = waiting for moderation
                     $published = 0;
                 }
                 // 3. check if this is a moderated category
                 if ($CofiHelper->isCategoryModerated($_postCatId)) {
                     // category is moderated
                     $wfm = 1;
                     // wfm = waiting for moderation
                     $published = 0;
                 }
             }
             // create alias for SEF URL
             jimport('joomla.filter.output');
             $alias = $_postSubject;
             $alias = JFilterOutput::stringURLSafe($alias);
             $insert_sql = "INSERT INTO " . $db->nameQuote('#__discussions_messages') . " ( parent_id, cat_id, thread, user_id, account, name, email, ip, subject, alias, message, image1_description,  image2_description, image3_description, image4_description, image5_description, published, wfm) " . " VALUES ( " . $_postParent . ", " . $_postCatId . ", " . $_postThread . ", '" . $user->id . "', '" . $user->username . "', '" . $user->name . "', '" . $user->email . "', '" . $_postIpAddress . "', " . $db->Quote($_postSubject) . ", " . $db->Quote($alias) . ", " . $db->Quote($_postText) . ", " . $db->Quote($_image1_description) . ", " . $db->Quote($_image2_description) . ", " . $db->Quote($_image3_description) . ", " . $db->Quote($_image4_description) . ", " . $db->Quote($_image5_description) . ", " . $published . ", " . $wfm . " )";
             $db->setQuery($insert_sql);
             $insert_result = $db->query();
             // $_postId = last_insert_id();
             $db->setQuery("SELECT LAST_INSERT_ID() FROM " . $db->nameQuote('#__discussions_messages'));
             $_postId = $db->loadResult();
             // get parent and set thread to id if 0
             if ($_postThread == 0) {
                 // no thread id, so it is like id
                 $_postThread = $_postId;
                 $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET thread = '" . $_postThread . "' WHERE id = '" . $_postId . "'";
                 $db->setQuery($sql);
                 $result = $db->query();
             } else {
                 // thread is set
                 if ($_postParent == 0) {
                     // no parent id, so it is like thread id
                     $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET parent_id = '" . $_postThread . "' WHERE id = '" . $_postId . "'";
                     $db->setQuery($sql);
                     $result = $db->query();
                 }
             }
             if ($insert_result) {
                 // if insert was successful update statistics
                 if ($published == 1) {
                     // thread goes live, so we can update stats
                     // set user post counter ++
                     $result = $CofiHelper->increaseUserPostCounter($user->id);
                     // update thread stats
                     $result = $CofiHelper->updateThreadStats($_postThread);
                     // update category stats
                     $result = $CofiHelper->updateCategoryStats($_postCatId);
                 }
                 // if published
             }
             if ($insert_result) {
                 // insert went fine
                 // upload image attachments todo
                 // get folder name
                 $rootDir = JPATH_ROOT;
                 if (isset($_FILES['image1']) and !$_FILES['image1']['error']) {
                     $this->add_image($_postThread, $_postId, "image1", $rootDir, $db, 1);
                 }
                 if (isset($_FILES['image2']) and !$_FILES['image2']['error']) {
                     $this->add_image($_postThread, $_postId, "image2", $rootDir, $db, 2);
                 }
                 if (isset($_FILES['image3']) and !$_FILES['image3']['error']) {
                     $this->add_image($_postThread, $_postId, "image3", $rootDir, $db, 3);
                 }
                 if (isset($_FILES['image4']) and !$_FILES['image4']['error']) {
                     $this->add_image($_postThread, $_postId, "image4", $rootDir, $db, 4);
                 }
                 if (isset($_FILES['image5']) and !$_FILES['image5']['error']) {
                     $this->add_image($_postThread, $_postId, "image5", $rootDir, $db, 5);
                 }
                 if ($wfm == 1) {
                     // this post needs moderator approval
                     $CofiHelper->sendEmailToModeratorsPostWFM();
                     $app->redirect($redirectLink, JText::_('COFI_POST_SAVED_NEEDS_APPROVAL'), "notice");
                 } else {
                     // redirect	link to last post
                     $redirectLinkToLastPost = $this->getLinkToLastPostByThreadId($_postThread);
                     $app->redirect($redirectLinkToLastPost, JText::_('COFI_POST_SAVED'), "notice");
                 }
             } else {
                 $app->redirect($redirectLink, JText::_('COFI_POST_NOT_SAVED_INSERT_ERROR'), "message");
             }
         }
     }
     // end insert
     if ($isSubjectTooShort) {
         $app->redirect($redirectLink, JText::_('COFI_POST_NOT_SAVED_SUBJECT_TOO_SHORT'), "message");
     }
     if ($isTextTooShort) {
         $app->redirect($redirectLink, JText::_('COFI_POST_NOT_SAVED_TEXT_TOO_SHORT'), "message");
     }
     // redirect	link to last post
     $redirectLinkToLastPost = $this->getLinkToLastPostByThreadId($_postThread);
     $app->redirect($redirectLinkToLastPost, JText::_('COFI_POST_SAVED'), "notice");
     return 0;
     // save OK
 }
示例#7
0
    echo "</div>";
}
?>
<!-- HTML Box Top -->



<?php 
include 'components/com_discussions/includes/topmenu.php';
?>



<!-- show moderator how many posts wait for approval -->
<?php 
if ($logUser->isModerator() == 1) {
    if ($logUser->isApprovalNotification() == 1) {
        $countposts = CofiHelper::getPostsWFM();
        if ($countposts > 0) {
            // here is something to do for the moderator
            ?>
			<center>
				<div class="cofiPostsWaitingForApproval">
		
					<?php 
            $approveLink = JRoute::_('index.php?option=com_discussions&view=moderation&task=approve');
            echo "<a href='{$approveLink}' title='" . JText::_('COFI_APPROVE_NEW_POSTS') . "'>";
            echo "<b>";
            echo $countposts;
            echo "</b>";
            if ($countposts == 1) {
示例#8
0
 echo "<br />";
 echo "<br />";
 $signature = nl2br($CofiUser->getSignature());
 if ($signature != "") {
     // display signature hr if one is present
     echo "<div class='cofiHorizontalRuler'></div>";
     echo $signature;
 }
 echo "<br />";
 echo "<br />";
 // moderation menu
 echo "<div class='cofiPostMenu'>";
 echo "<table width='100%' border='0' cellspacing='0' cellpadding='5' class='noborder'>";
 echo "<tr>";
 // check if user has moderator rights
 if ($logUser->isModerator()) {
     // accept post
     echo "<td width='16' align='center' valign='middle' class='noborder'>";
     echo "<img src='" . $_root . "components/com_discussions/assets/threads/accept.png' style='margin-left: 5px; border:0px;' />";
     echo "</td>";
     echo "<td width='20' align='left' valign='middle' class='noborder'>";
     echo "<span class='cofiPostMenuLinks'>";
     $menuLinkAcceptTMP = "index.php?option=com_discussions&view=moderation&task=accept&post=" . $posting->id;
     $menuLinkAccept = JRoute::_($menuLinkAcceptTMP);
     echo "<a href='" . $menuLinkAccept . "'>" . JText::_('COFI_MODERATION_ACCEPT') . "</a>";
     echo "</span>";
     echo "</td>";
     echo "<td class='noborder'>";
     echo "&nbsp;&nbsp;&nbsp;";
     echo "</td>";
     // deny post