コード例 #1
0
 /**
  * Displays the user's points achievement history
  *
  * @since	2.0
  * @access	public
  */
 public function history($tmpl = null)
 {
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id');
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('Unable to locate the id of the user.'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss');
         $app->close();
     }
     $model = DiscussHelper::getModel('Points', true);
     $history = $model->getPointsHistory($id);
     foreach ($history as $item) {
         $date = DiscussDateHelper::dateWithOffSet($item->created);
         $item->created = $date->toFormat('%A, %b %e %Y');
         $points = DiscussHelper::getHelper('Points')->getPoints($item->command);
         if ($points) {
             if ($points[0]->rule_limit < 0) {
                 $item->class = 'badge-important';
                 $item->points = $points[0]->rule_limit;
             } else {
                 $item->class = 'badge-info';
                 $item->points = '+' . $points[0]->rule_limit;
             }
         } else {
             $item->class = 'badge-info';
             $item->points = '+';
         }
     }
     $theme = new DiscussThemes();
     $theme->set('history', $history);
     echo $theme->fetch('points.history.php');
 }
コード例 #2
0
ファイル: ranks.php プロジェクト: BetterBetterBetter/B3App
 public function save()
 {
     JRequest::checkToken('request') or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     $post = JRequest::get('post');
     $ids = isset($post['id']) ? $post['id'] : '';
     $starts = isset($post['start']) ? $post['start'] : '';
     $ends = isset($post['end']) ? $post['end'] : '';
     $titles = isset($post['title']) ? $post['title'] : '';
     $removal = isset($post['itemRemove']) ? $post['itemRemove'] : '';
     $model = DiscussHelper::getModel('Ranks', true);
     if (!empty($removal)) {
         $rids = explode(',', $removal);
         $model->removeRanks($rids);
     }
     if (!empty($ids)) {
         if (count($ids) > 0) {
             for ($i = 0; $i < count($ids); $i++) {
                 $data = array();
                 $data['id'] = $ids[$i];
                 $data['start'] = $starts[$i];
                 $data['end'] = $ends[$i];
                 $data['title'] = $titles[$i];
                 $ranks = DiscussHelper::getTable('Ranks');
                 $ranks->bind($data);
                 $ranks->store();
             }
         }
         //end if
     }
     //end if
     $message = JText::_('COM_EASYDISCUSS_RANKING_SUCCESSFULLY_UPDATED');
     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
     $mainframe->redirect('index.php?option=com_easydiscuss&view=ranks');
 }
コード例 #3
0
ファイル: spools.php プロジェクト: BetterBetterBetter/B3App
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mails = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'success';
     if (empty($mails)) {
         $message = JText::_('COM_EASYDISCUSS_NO_MAIL_ID_PROVIDED');
         $type = 'error';
     } else {
         $table = DiscussHelper::getTable('MailQueue');
         foreach ($mails as $id) {
             $table->load($id);
             if (!$table->delete()) {
                 DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SPOOLS_DELETE_ERROR'), DISCUSS_QUEUE_ERROR);
                 $this->setRedirect('index.php?option=com_easydiscuss&view=spools');
                 return;
             }
         }
         $message = JText::_('COM_EASYDISCUSS_SPOOLS_EMAILS_DELETED');
     }
     DiscussHelper::setMessageQueue($message, $type);
     $this->setRedirect('index.php?option=com_easydiscuss&view=spools');
 }
コード例 #4
0
ファイル: comments.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Converts a comment into a discussion reply
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return	
  */
 public function convert()
 {
     JRequest::checkToken('request') or jexit('Invalid Token');
     // Get the Joomla app
     $app = JFactory::getApplication();
     // Get the comment id from the request.
     $id = JRequest::getInt('id');
     // Load the comment
     $comment = DiscussHelper::getTable('Comment');
     $comment->load($id);
     if (!$id || !$comment->id) {
         // Throw error here.
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_INVALID_COMMENT_ID_PROVIDED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     // Get the post id from the request.
     $postId = JRequest::getInt('postId');
     $post = DiscussHelper::getTable('Post');
     $post->load($postId);
     if (!$postId || !$post->id) {
         // Throw error here.
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_INVALID_POST_ID_PROVIDED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     if (!$comment->canConvert()) {
         // Throw error here.
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_NOT_ALLOWED_TO_CONVERT'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false));
         $app->close();
     }
     // Create a new reply.
     $reply = DiscussHelper::getTable('Post');
     $reply->title = $post->title;
     $reply->content = $comment->comment;
     $reply->published = 1;
     $reply->created = $comment->created;
     $reply->parent_id = $post->id;
     $reply->user_id = $comment->user_id;
     $reply->user_type = 'member';
     $reply->category_id = $post->category_id;
     $state = $reply->store();
     if (!$state) {
         // Throw error here.
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_ERROR_SAVING_REPLY'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false));
         $app->close();
     }
     // Once the reply is stored, delete the comment
     $comment->delete();
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_SUCCESS_CONVERTED_COMMENT_TO_REPLY'), DISCUSS_QUEUE_SUCCESS);
     $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false));
     $app->close();
 }
コード例 #5
0
 /**
  * Allows user to mark all their notification items as read
  **/
 public function markreadall()
 {
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_LOGIN_FIRST'), 'error');
         JFactory::getApplication()->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
     }
     $db = DiscussHelper::getDBO();
     $query = 'UPDATE ' . $db->nameQuote('#__discuss_notifications') . ' ' . 'SET ' . $db->nameQuote('state') . '=' . $db->Quote(0) . ' ' . 'WHERE ' . $db->nameQuote('target') . '=' . $db->Quote($my->id);
     $db->setQuery($query);
     $db->Query();
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_ALL_NOTIFICATIONS_MARKED_AS_READ'));
     JFactory::getApplication()->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=notifications', false));
 }
コード例 #6
0
 public function display($tpl = null)
 {
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_LOGIN_FIRST'), 'error');
         JFactory::getApplication()->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
     }
     $model = $this->getModel('Notification');
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_NOTIFICATIONS'));
     // Make this configurable?
     $limit = 100;
     $notifications = $model->getNotifications($my->id, false, $limit);
     DiscussHelper::getHelper('Notifications')->format($notifications, true);
     $theme = new DiscussThemes();
     $theme->set('notifications', $notifications);
     echo $theme->fetch('notifications.php');
 }
コード例 #7
0
ファイル: twitter.php プロジェクト: BetterBetterBetter/B3App
 function removeAccess()
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $return = DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false);
     if ($user->id == 0) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_USER_NOT_FOUND'), 'error');
         $this->setRedirect($return);
     }
     $twitter = DiscussHelper::getTable('Twitter');
     if (!$twitter->load($user->id)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_OAUTH_DOESNT_EXIST'), 'error');
         $this->setRedirect($return);
     }
     $twitter->delete();
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_REQUIRE_AUTHENTICATION'));
     $this->setRedirect($return);
 }
コード例 #8
0
ファイル: discuss.php プロジェクト: BetterBetterBetter/B3App
 public function clearCache()
 {
     $paths = array(DISCUSS_ADMIN_THEMES, DISCUSS_SITE_THEMES, DISCUSS_JOOMLA_MODULES);
     $count = 0;
     foreach ($paths as $path) {
         $cachedFiles = JFolder::files($path, 'style.less.cache', true, true);
         foreach ($cachedFiles as $file) {
             $count++;
             JFile::delete($file);
         }
     }
     // Also purge the /resources and /config files
     require_once DISCUSS_CLASSES . '/compiler.php';
     $compiler = new DiscussCompiler();
     $compiler->purgeResources();
     $message = JText::sprintf('COM_EASYDISCUSS_CACHE_DELETED', $count);
     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
     $this->setRedirect('index.php?option=com_easydiscuss');
 }
コード例 #9
0
 function display($tpl = null)
 {
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     if (!$config->get('main_favorite')) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_FEATURE_IS_DISABLED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_FAVOURITES_TITLE'));
     // @task: Add view
     $this->logView();
     DiscussHelper::setMeta();
     $postModel = DiscussHelper::getModel('Posts');
     $posts = $postModel->getData(true, 'latest', null, 'favourites');
     $posts = DiscussHelper::formatPost($posts);
     $theme = new DiscussThemes();
     $theme->set('posts', $posts);
     echo $theme->fetch('favourites.php');
 }
コード例 #10
0
 function remove()
 {
     $subs = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'success';
     if (count($subs) <= 0) {
         $message = JText::_('COM_EASYDISCUSS_INVALID_POST_ID');
         $type = 'error';
     } else {
         $table = JTable::getInstance('Subscribe', 'Discuss');
         foreach ($subs as $sub) {
             $table->load($sub);
             if (!$table->delete()) {
                 DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_REMOVING_SUBSCRIPTION_PLEASE_TRY_AGAIN_LATER'), DISCUSS_QUEUE_ERROR);
                 $this->setRedirect('index.php?option=com_easydiscuss&view=subscription');
                 return;
             }
         }
         $message = JText::_('COM_EASYDISCUSS_SUBSCRIPTION_DELETED');
     }
     DiscussHelper::setMessageQueue($message, $type);
     $this->setRedirect('index.php?option=com_easydiscuss&view=subscription');
 }
コード例 #11
0
ファイル: reports.php プロジェクト: BetterBetterBetter/B3App
 public function submit()
 {
     $config = DiscussHelper::getConfig();
     $my = JFactory::getUser();
     $id = JRequest::getInt('id');
     $app = JFactory::getApplication();
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     $acl = DiscussHelper::getHelper('ACL');
     if (!$post->id || !$state) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     // Get the URL to the discussion.
     $url = DiscussRouter::getPostRoute($post->id, false);
     if ($post->isReply()) {
         $url = DiscussRouter::getPostRoute($post->parent_id, false);
     }
     if (!$acl->allowed('send_report')) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_YOU_DO_NOT_HAVE_PERMISION_TO_SUBMIT_REPORT'), DISCUSS_QUEUE_ERROR);
         $app->redirect($url);
         $app->close();
     }
     if (!$config->get('main_report')) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_REPORT_HAS_BEEN_DISABLED_BY_ADMINISTRATOR'), DISCUSS_QUEUE_ERROR);
         $app->redirect($url);
         $app->close();
     }
     $message = JRequest::getString('reporttext', '');
     if (empty($message)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_REPORT_EMPTY_TEXT'), DISCUSS_QUEUE_ERROR);
         $app->redirect($url);
         $app->close();
     }
     $date = DiscussHelper::getDate();
     $report = DiscussHelper::getTable('Report');
     $report->created_by = $my->id;
     $report->post_id = $post->id;
     $report->reason = $message;
     $report->created = $date->toMySQL();
     if (!$report->store()) {
         DiscussHelper::setMessageQueue($report->getError(), DISCUSS_QUEUE_ERROR);
         $app->redirect($url);
         $app->close();
     }
     // Mark post as reported.
     $report->markPostReport();
     $threshold = $config->get('main_reportthreshold', 15);
     $totalReports = $report->getReportCount();
     $redirectMessage = JText::_('COM_EASYDISCUSS_REPORT_SUBMITTED');
     // Check if the number of reports for this post exceeded the threshold.
     if ($totalReports > $reportThreshold) {
         $owner = $post->getOwner();
         $date = DiscussHelper::getDate($post->created);
         $emailData = array();
         $emailData['postContent'] = $post->content;
         $emailData['postAuthor'] = $owner->name;
         $emailData['postAuthorAvatar'] = $owner->avatar;
         $emailData['postDate'] = $date->toFormat();
         $emailData['postLink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false, true);
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_REPORT_REQUIRED_YOUR_ATTENTION', JString::substr($postTbl->content, 0, 15)) . '...';
         $emailData['emailTemplate'] = 'email.post.attention.php';
         if ($post->isReply()) {
             $emailData['postLink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $post->parent_id, false, true);
         }
         DiscussHelper::getHelper('Mailer')->notifyAdministrators($emailData, array(), $config->get('notify_admin'), $config->get('notify_moderator'));
         $redirectMessage = JText::_('COM_EASYDISCUSS_REPORT_SUBMITTED_BUT_POST_MARKED_AS_REPORT');
     }
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_REPORT_SUBMITTED'), DISCUSS_QUEUE_SUCCESS);
     $app->redirect($url);
 }
コード例 #12
0
 /**
  * Marks a message as unread
  *
  * @since	3.0
  * @access	public
  */
 public function unread()
 {
     JRequest::checkToken('request', 'get') or jexit('Invalid Token');
     $id = JRequest::getInt('id');
     $app = JFactory::getApplication();
     // Test for valid recipients.
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_MESSAGING_INVALID_ID'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation', false));
         $app->close();
     }
     // Only registered users are allowed to use conversation.
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation', false));
         $app->close();
     }
     // Retrieve model.
     $model = DiscussHelper::getModel('Conversation');
     // Test if user has access
     if (!$model->hasAccess($id, $my->id)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation', false));
         $app->close();
     }
     // Mark the conversation as unread.
     $model->markAsUnread($id, $my->id);
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CONVERSATION_MARKED_AS_UNREAD'), DISCUSS_QUEUE_SUCCESS);
     $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation', false));
     $app->close();
 }
コード例 #13
0
ファイル: roles.php プロジェクト: BetterBetterBetter/B3App
 public function saveOrder()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $app = JFactory::getApplication();
     $row = DiscussHelper::getTable('Role');
     $row->rebuildOrdering();
     $message = JText::_('COM_EASYDISCUSS_ROLES_ORDERING_SAVED');
     $type = 'message';
     DiscussHelper::setMessageQueue($message, $type);
     $app->redirect('index.php?option=com_easydiscuss&view=roles');
     exit;
 }
コード例 #14
0
 /**
  * Responsible to display the conversation form.
  *
  * @since	3.0
  * @access	public
  */
 public function compose()
 {
     // Get recipient id from request.
     $id = JRequest::getInt('id');
     $app = JFactory::getApplication();
     $my = JFactory::getUser();
     // Do not allow non logged in users to view anything in conversation.
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
         $app->close();
     }
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CONVERSATION_INVALID'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
         $app->close();
     }
     $recipient = DiscussHelper::getTable('Profile');
     $recipient->load($id);
     // Initialize conversation table.
     $conversation = DiscussHelper::getTable('Conversation');
     // Check if this conversation already exist in the system.
     $state = $conversation->loadByRelation($my->id, $recipient->id);
     // If conversation already exists between both parties, just redirect to the reply in an existing conversation.
     if ($state) {
         $app->redirect(DiscussRouter::getMessageRoute($conversation->id, false) . '#reply');
         $app->close();
     }
     $theme = new DiscussThemes();
     $theme->set('recipient', $recipient);
     echo $theme->fetch('conversation.compose.php');
 }
コード例 #15
0
ファイル: tags.php プロジェクト: BetterBetterBetter/B3App
 function unpublish()
 {
     $tags = JRequest::getVar('cid', array(0), 'POST');
     $message = '';
     $type = 'success';
     if (count($tags) <= 0) {
         $message = JText::_('COM_EASYDISCUSS_INVALID_TAG_ID');
         $type = 'error';
     } else {
         $model = $this->getModel('Tags');
         if ($model->publish($tags, 0)) {
             $message = JText::_('COM_EASYDISCUSS_TAG_UNPUBLISHED');
         } else {
             $message = JText::_('COM_EASYDISCUSS_TAG_UNPUBLISH_ERROR');
             $type = 'error';
         }
     }
     DiscussHelper::setMessageQueue($message, $type);
     $this->setRedirect('index.php?option=com_easydiscuss&view=tags');
 }
コード例 #16
0
ファイル: user.php プロジェクト: BetterBetterBetter/B3App
 public function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $cid = JRequest::getVar('cid', array(), '', 'array');
     JArrayHelper::toInteger($cid);
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('COM_EASYDISCUSS_SELECT_USER_TO_DELETE', true));
     }
     $result = null;
     foreach ($cid as $id) {
         $result = null;
         if (DiscussHelper::getJoomlaVersion() >= '1.6') {
             $result = $this->_removeUser16($id);
         } else {
             $result = $this->_removeUser($id);
         }
         if (!$result['success']) {
             DiscussHelper::setMessageQueue($result['msg'], DISCUSS_QUEUE_ERROR);
             $this->setRedirect('index.php?option=com_easydiscuss&view=users', $result['msg']);
         }
     }
     DiscussHelper::setMessageQueue($result['msg'], DISCUSS_QUEUE_SUCCESS);
     $this->setRedirect('index.php?option=com_easydiscuss&view=users', $result['msg']);
 }
コード例 #17
0
ファイル: category.php プロジェクト: BetterBetterBetter/B3App
 public function makeDefault()
 {
     $cid = JRequest::getVar('cid');
     if (is_array($cid)) {
         $cid = (int) $cid[0];
     }
     $model = $this->getModel('Categories');
     $model->updateDefault($cid);
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CATEGORY_SET_DEFAULT'), DISCUSS_QUEUE_SUCCESS);
     $this->setRedirect('index.php?option=com_easydiscuss&view=categories');
 }
コード例 #18
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $db = DiscussHelper::getDBO();
     // $driver    = JRequest::getVar( 'migrator_vBulletin_driver' );
     // $host      = JRequest::getVar( 'migrator_vBulletin_host' );
     // $user      = JRequest::getVar( 'migrator_vBulletin_user' );
     // $password  = JRequest::getVar( 'migrator_vBulletin_password' );
     // $database  = JRequest::getVar( 'migrator_vBulletin_name' );
     $prefix = JRequest::getVar('migrator_vBulletin_prefix', '');
     // // Data validation
     // $data = array(
     // 		'driver' => $driver,
     // 		'host' => $host,
     // 		'user' => $user,
     // 		'password' => $password,
     // 		'database' => $database,
     // 		'prefix' => $prefix
     // 		);
     // $invalid = array();
     // foreach( $data as $key => $item )
     // {
     // 	if( empty( $item ) )
     // 	{
     // 		$invalid[] = $key;
     // 	}
     // }
     // if( !empty( $invalid ) )
     // {
     // 	$msg = implode( ', ', $invalid );
     // 	DiscussHelper::setMessageQueue( JText::sprintf( 'COM_EASYDISCUSS_VBULLETN_DB_MISSING_DATA' , $msg ) , DISCUSS_QUEUE_ERROR );
     // 	$mainframe->redirect( 'index.php?option=com_easydiscuss&view=migrators&layout=default_vbulletin' );
     // 	$mainframe->close();
     // }
     // //Test connection
     // jimport('joomla.database.database');
     // jimport( 'joomla.database.table' );
     // // Prepare the data to be connect
     // $options	= array( 'driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix );
     // // Store it as static so that can be used else where
     // $connect = DiscussHelper::getHelper( 'DB' )->setVBConnection( $options );
     // if ( JError::isError($connect) ) {
     // 	header('HTTP/1.1 500 Internal Server Error');
     // 	jexit('Database Error: ' . $connect->toString() );
     // }
     // if ($connect->getErrorNum() > 0) {
     // 	// JError::raiseError(500 , 'JDatabase::getInstance: Could not connect to database <br />' . 'joomla.library:'.$connect->getErrorNum().' - '.$connect->getErrorMsg() );
     // 	DiscussHelper::setMessageQueue( JText::_( 'COM_EASYDISCUSS_VBULLETN_COULD_NOT_CONNECT_DB' ) , DISCUSS_QUEUE_ERROR );
     // 	$mainframe->redirect( 'index.php?option=com_easydiscuss&view=migrators&layout=default_vbulletin' );
     // 	$mainframe->close();
     // }
     if (empty($prefix)) {
         DiscussHelper::setMessageQueue(JText::sprintf('COM_EASYDISCUSS_VBULLETN_DB_PREFIX_NOT_FOUND', $prefix), DISCUSS_QUEUE_ERROR);
         $mainframe->redirect('index.php?option=com_easydiscuss&view=migrators&layout=default_vbulletin');
         $mainframe->close();
     }
     // // Check if the vBulletin table exist
     // $query = 'SELECT * FROM ' . $db->nameQuote( $prefix . 'thread' );
     // $db->setQuery( $query );
     // $results = $db->loadobject();
     // if( empty( $results ) )
     // {
     // 	DiscussHelper::setMessageQueue( JText::_( 'COM_EASYDISCUSS_VBULLETN_DB_TABLE_NOT_FOUND' ) , DISCUSS_QUEUE_ERROR );
     // 	$mainframe->redirect( 'index.php?option=com_easydiscuss&view=migrators&layout=default_vbulletin' );
     // 	$mainframe->close();
     // }
     // Check if the vBulletin table exist
     $tables = $db->getTableList();
     $exist = in_array($prefix . 'thread', $tables);
     if (empty($exist)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_VBULLETN_DB_TABLE_NOT_FOUND'), DISCUSS_QUEUE_ERROR);
         $mainframe->redirect('index.php?option=com_easydiscuss&view=migrators&layout=default_vbulletin');
         $mainframe->close();
     }
     // Save into the configuration file so that it can be use globally
     $model = DiscussHelper::getModel('Settings', true);
     // $data['migrator_vBulletin_driver'] = $driver;
     // $data['migrator_vBulletin_host'] = $host;
     // $data['migrator_vBulletin_user'] = $user;
     // $data['migrator_vBulletin_password'] = $password;
     // $data['migrator_vBulletin_name'] = $database;
     $data['migrator_vBulletin_prefix'] = $prefix;
     $model->save($data);
     $mainframe->redirect('index.php?option=com_easydiscuss&view=migrators&layout=default_vBulletin_1');
 }
コード例 #19
0
 /**
  * Marks a message as unread
  *
  * @since	3.0
  * @access	public
  */
 public function unread()
 {
     JRequest::checkToken('request', 'get') or jexit('Invalid Token');
     $id = JRequest::getInt('id');
     $app = JFactory::getApplication();
     // Test for valid recipients.
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_MESSAGING_INVALID_ID'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=messaging', false));
         $app->close();
     }
     $message = DiscussHelper::getTable('Message');
     $message->load($id);
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=messaging', false));
         $app->close();
     }
     $model = DiscussHelper::getModel('Messaging');
     $model->markUnread($message->id, $my->id);
     DiscussHelper::setMessageQueue(JText::_('The message is now marked as unread.'), DISCUSS_QUEUE_SUCCESS);
     $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=messaging', false));
     $app->close();
 }
コード例 #20
0
ファイル: posts.php プロジェクト: BetterBetterBetter/B3App
 /**
  * update posts
  */
 public function submit()
 {
     if (JRequest::getMethod() == 'POST') {
         JRequest::checkToken('request') or jexit('Invalid Token');
         $user = JFactory::getUser();
         // get all forms value
         $post = JRequest::get('post');
         // get id if available
         $id = JRequest::getInt('id', 0);
         // get post parent id
         $parent = JRequest::getInt('parent_id', 0);
         // the source where page come from
         $source = JRequest::getVar('source', 'posts');
         // Get raw content from request as we may need to respect the html codes.
         $content = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
         // Ensure that the posted content is respecting the correct values.
         $post['dc_reply_content'] = $content;
         // get config
         $config = DiscussHelper::getConfig();
         $post['alias'] = empty($post['alias']) ? DiscussHelper::getAlias($post['title'], 'post', $id) : DiscussHelper::getAlias($post['alias'], 'post', $id);
         //clear tags if editing a post.
         $previousTags = array();
         if (!empty($id)) {
             $postsTagsModel = $this->getModel('PostsTags');
             $tmppreviousTags = $postsTagsModel->getPostTags($id);
             if (!empty($tmppreviousTags)) {
                 foreach ($tmppreviousTags as $previoustag) {
                     $previousTags[] = $previoustag->id;
                 }
             }
             $postsTagsModel->deletePostTag($id);
         }
         // bind the table
         $postTable = JTable::getInstance('posts', 'Discuss');
         $postTable->load($id);
         //get previous post status before binding.
         $prevPostStatus = $postTable->published;
         $postTable->bind($post, true);
         // hold last inserted ID in DB
         $lastId = null;
         // @rule: Bind parameters
         $postTable->bindParams($post);
         if ($config->get('main_private_post') && isset($post['private'])) {
             $postTable->private = $post['private'];
         }
         // @trigger: onBeforeSave
         $isNew = (bool) $postTable->id;
         DiscussEventsHelper::importPlugin('content');
         DiscussEventsHelper::onContentBeforeSave('post', $post, $isNew);
         if (!$postTable->store()) {
             JError::raiseError(500, $postTable->getError());
         }
         //Clear off previous records before storing
         $ruleModel = DiscussHelper::getModel('CustomFields');
         $ruleModel->deleteCustomFieldsValue($postTable->id, 'update');
         // Process custom fields.
         $fieldIds = JRequest::getVar('customFields');
         if (!empty($fieldIds)) {
             foreach ($fieldIds as $fieldId) {
                 $fields = JRequest::getVar('customFieldValue_' . $fieldId);
                 if (!empty($fields)) {
                     // Cater for custom fields select list
                     // To detect if there is no value selected for the select list custom fields
                     if (in_array('defaultList', $fields)) {
                         $tempKey = array_search('defaultList', $fields);
                         $fields[$tempKey] = '';
                     }
                 }
                 $postTable->bindCustomFields($fields, $fieldId);
             }
         }
         // @trigger: onAfterSave
         DiscussEventsHelper::onContentAfterSave('post', $post, $isNew);
         // The category_id for the replies should change too
         $postTable->moveChilds($postTable->id, $postTable->category_id);
         $lastId = $postTable->id;
         // Bind file attachments
         $postTable->bindAttachments();
         $message = JText::_('COM_EASYDISCUSS_POST_SAVED');
         $date = DiscussHelper::getDate();
         //@task: Save tags
         $tags = JRequest::getVar('tags', '', 'POST');
         if (!empty($tags)) {
             $tagModel = $this->getModel('Tags');
             foreach ($tags as $tag) {
                 if (!empty($tag)) {
                     $tagTable = JTable::getInstance('Tags', 'Discuss');
                     //@task: Only add tags if it doesn't exist.
                     if (!$tagTable->exists($tag)) {
                         $tagInfo['title'] = JString::trim($tag);
                         $tagInfo['alias'] = DiscussHelper::getAlias($tag, 'tag');
                         $tagInfo['created'] = $date->toMySQL();
                         $tagInfo['published'] = 1;
                         $tagInfo['user_id'] = $user->id;
                         $tagTable->bind($tagInfo);
                         $tagTable->store();
                     } else {
                         $tagTable->load($tag, true);
                     }
                     $postTagInfo = array();
                     //@task: Store in the post tag
                     $postTagTable = JTable::getInstance('PostsTags', 'Discuss');
                     $postTagInfo['post_id'] = $postTable->id;
                     $postTagInfo['tag_id'] = $tagTable->id;
                     $postTagTable->bind($postTagInfo);
                     $postTagTable->store();
                 }
             }
         }
         $isNew = empty($id) ? true : false;
         if (($isNew || $prevPostStatus == DISCUSS_ID_PENDING) && $postTable->published == DISCUSS_ID_PUBLISHED) {
             $owner = $isNew ? $user->id : $postTable->user_id;
             DiscussHelper::sendNotification($postTable, $parent, $isNew, $owner, $prevPostStatus);
             // auto subscription
             if ($config->get('main_autopostsubscription') && $config->get('main_postsubscription') && $postTable->user_type != 'twitter' && !empty($postTable->parent_id)) {
                 // process only if this is a reply
                 //automatically subscribe this user into this reply
                 $replier = JFactory::getUser($postTable->user_id);
                 $subscription_info = array();
                 $subscription_info['type'] = 'post';
                 $subscription_info['userid'] = !empty($postTable->user_id) ? $postTable->user_id : '0';
                 $subscription_info['email'] = !empty($postTable->user_id) ? $replier->email : $postTable->poster_email;
                 $subscription_info['cid'] = $postTable->parent_id;
                 $subscription_info['member'] = !empty($postTable->user_id) ? '1' : '0';
                 $subscription_info['name'] = !empty($postTable->user_id) ? $replier->name : $postTable->poster_name;
                 $subscription_info['interval'] = 'instant';
                 //get frontend subscribe table
                 $susbcribeModel = DiscussHelper::getModel('Subscribe');
                 $sid = '';
                 if ($subscription_info['userid'] == 0) {
                     $sid = $susbcribeModel->isPostSubscribedEmail($subscription_info);
                     if (empty($sid)) {
                         $susbcribeModel->addSubscription($subscription_info);
                     }
                 } else {
                     $sid = $susbcribeModel->isPostSubscribedUser($subscription_info);
                     if (empty($sid['id'])) {
                         //add new subscription.
                         $susbcribeModel->addSubscription($subscription_info);
                     }
                 }
             }
             // only if the post is a discussion
             if ($config->get('integration_pingomatic') && empty($postTable->parent_id)) {
                 $pingo = DiscussHelper::getHelper('Pingomatic');
                 $urls = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $postTable->id, true, true);
                 $pingo->ping($postTable->title, $urls);
             }
         }
         $pid = '';
         if (!empty($parent)) {
             $pid = '&pid=' . $parent;
         }
         $task = $this->getTask();
         switch ($task) {
             case 'apply':
                 $redirect = 'index.php?option=com_easydiscuss&view=post&id=' . $postTable->id;
                 break;
             case 'save':
                 $redirect = 'index.php?option=com_easydiscuss&view=posts';
                 break;
             case 'savePublishNew':
             default:
                 $redirect = 'index.php?option=com_easydiscuss&view=post';
                 break;
         }
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_DISCUSSION_SAVED'), DISCUSS_QUEUE_SUCCESS);
         $this->setRedirect($redirect);
     }
 }
コード例 #21
0
ファイル: view.html.php プロジェクト: pguilford/vcomcc
 public function edit($tpl = null)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $acl = DiscussHelper::getHelper('ACL');
     $config = DiscussHelper::getConfig();
     // Load post item
     $id = JRequest::getInt('id', 0);
     if (empty($id)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'));
         return;
     }
     $post = DiscussHelper::getTable('Post');
     $post->load($id);
     $post->content_raw = $post->content;
     $editing = (bool) $post->id;
     if (!$editing) {
         // try to get from session if there are any.
         $this->getSessionData($post);
     }
     $categoryId = JRequest::getInt('category', $post->category_id);
     // Load category item.
     $category = DiscussHelper::getTable('Category');
     $category->load($categoryId);
     // Check if user is allowed to post a discussion, we also need to check against the category acl
     if (empty($my->id) && !$acl->allowed('add_question', 0)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_KINDLY_LOGIN_TO_CREATE_A_POST'));
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
         $app->close();
         return;
     }
     if ($my->id != 0 && !$acl->allowed('add_question', '0') && !$category->canPost()) {
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
         $app->close();
         return;
     }
     // Set the breadcrumbs.
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_ASK'));
     // Set the page title.
     $title = JText::_('COM_EASYDISCUSS_TITLE_ASK');
     if ($id && $post->id) {
         $title = JText::sprintf('COM_EASYDISCUSS_TITLE_EDIT_QUESTION', $post->getTitle());
     }
     // Set the page title
     DiscussHelper::setPageTitle($title);
     if ($editing) {
         $isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
         if (!DiscussHelper::isMine($post->user_id) && !DiscussHelper::isSiteAdmin() && !$acl->allowed('edit_question') && !$isModerator) {
             $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $postid, false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
             $app->close();
         }
         $tagsModel = DiscussHelper::getModel('PostsTags');
         $post->tags = $tagsModel->getPostTags($post->id);
     } else {
         if ($categoryId) {
             // set the default category
             $post->category_id = $categoryId;
         }
     }
     $attachments = $post->getAttachments();
     if (isset($post->sessiondata)) {
         $attachments = '';
     }
     $model = DiscussHelper::getModel('Posts');
     $postCount = count($model->getPostsBy('user', $my->id));
     $onlyPublished = empty($post->id) ? true : false;
     // @rule: If there is a category id passed through the query, respect it first.
     $showPrivateCat = empty($post->id) && $my->id == 0 ? false : true;
     // [model:category]
     $categoryModel = $this->getModel('Category');
     $defaultCategory = $categoryModel->getDefaultCategory();
     if ($categoryId == 0 && $defaultCategory !== false) {
         $categoryId = $defaultCategory->id;
     }
     $nestedCategories = '';
     $categories = '';
     if ($config->get('layout_category_selection') == 'multitier') {
         $categoriesModel = $this->getModel('Categories');
         $categories = $categoriesModel->getCategories(array('acl_type' => DISCUSS_CATEGORY_ACL_ACTION_SELECT));
     } else {
         $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $categoryId, true, $onlyPublished, $showPrivateCat, true);
     }
     if ($config->get('layout_reply_editor') == 'bbcode') {
         // Legacy fix when switching from WYSIWYG editor to bbcode.
         $post->content = EasyDiscussParser::html2bbcode($post->content);
     }
     $editor = '';
     if ($config->get('layout_editor') != 'bbcode') {
         $editor = JFactory::getEditor($config->get('layout_editor'));
     }
     // Get list of moderators from the site.
     $moderatorList = array();
     if ($config->get('main_assign_user')) {
         $moderatorList = DiscussHelper::getHelper('Moderator')->getSelectOptions($post->category_id);
     }
     $composer = new DiscussComposer("editing", $post);
     // Set the discussion object.
     $access = $post->getAccess($category);
     $theme = new DiscussThemes();
     // Test if reference is passed in query string.
     $reference = JRequest::getWord('reference');
     $referenceId = JRequest::getInt('reference_id', 0);
     $redirect = JRequest::getVar('redirect', '');
     $theme->set('redirect', $redirect);
     $theme->set('reference', $reference);
     $theme->set('referenceId', $referenceId);
     $theme->set('isEditMode', $editing);
     $theme->set('post', $post);
     $theme->set('composer', $composer);
     $theme->set('parent', $composer->parent);
     $theme->set('nestedCategories', $nestedCategories);
     $theme->set('attachments', $attachments);
     $theme->set('editor', $editor);
     $theme->set('moderatorList', $moderatorList);
     $theme->set('categories', $categories);
     $theme->set('access', $access);
     // Deprecated since 3.0. Will be removed in 4.0
     $theme->set('config', $config);
     echo $theme->fetch('form.reply.wysiwyg.php');
 }
コード例 #22
0
ファイル: points.php プロジェクト: BetterBetterBetter/B3App
 public function save()
 {
     JRequest::checkToken('request') or jexit('Invalid Token');
     $app = JFactory::getApplication();
     $point = DiscussHelper::getTable('Points');
     $id = JRequest::getInt('id');
     $point->load($id);
     $post = JRequest::get('POST');
     $point->bind($post);
     if (empty($point->created)) {
         $point->created = DiscussHelper::getDate()->toMySQL();
     }
     // Store the badge
     $point->store();
     $message = !empty($id) ? JText::_('COM_EASYDISCUSS_POINTS_UPDATED') : JText::_('COM_EASYDISCUSS_POINTS_CREATED');
     $url = 'index.php?option=com_easydiscuss&view=points';
     if (JRequest::getVar('task') == 'saveNew') {
         //$url	= 'index.php?option=com_easydiscuss&controller=points&layout=form';
         $url = 'index.php?option=com_easydiscuss&view=points&layout=form';
     }
     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
     $app->redirect($url);
 }
コード例 #23
0
ファイル: acl.php プロジェクト: BetterBetterBetter/B3App
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     $bloggers = JRequest::getVar('cid', '', 'POST');
     $message = '';
     $type = 'success';
     if (empty($bloggers)) {
         $message = JText::_('Invalid blogger id');
         $type = 'error';
     } else {
         $model = $this->getModel('Acl');
         foreach ($bloggers as $id) {
             $ruleset = $model->getRuleSet('assigned', $id);
             if (!empty($ruleset->id)) {
                 if (!$model->deleteRuleset($id, 'assigned')) {
                     $message = JText::_('Error removing blogger, ' . $ruleset->name);
                     $type = 'error';
                     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_ERROR);
                     $mainframe->redirect('index.php?option=com_easydiscuss&view=acls');
                     return;
                 }
             }
         }
         $message = JText::_('Blogger(s) deleted');
     }
     DiscussHelper::setMessageQueue($message, $type);
     $mainframe->redirect('index.php?option=com_easydiscuss&view=acls');
 }
コード例 #24
0
ファイル: settings.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Save the Email Template.
  */
 function saveEmailTemplate()
 {
     $mainframe = JFactory::getApplication();
     $file = JRequest::getVar('file', '', 'POST');
     $filepath = DISCUSS_SITE_THEMES . '/simplistic/emails/' . $file;
     $content = JRequest::getVar('content', '', 'POST', '', JREQUEST_ALLOWRAW);
     $msg = '';
     $msgType = '';
     $status = JFile::write($filepath, $content);
     if (!empty($status)) {
         $msg = JText::_('COM_EASYDISCUSS_SETTINGS_NOTIFICATIONS_EMAIL_TEMPLATES_SAVE_SUCCESS');
         $msgType = 'success';
     } else {
         $msg = JText::_('COM_EASYDISCUSS_SETTINGS_NOTIFICATIONS_EMAIL_TEMPLATES_SAVE_FAIL');
         $msgType = 'error';
     }
     DiscussHelper::setMessageQueue($msg, $msgType);
     $mainframe->redirect('index.php?option=com_easydiscuss&view=settings&layout=editEmailTemplate&file=' . $file . '&msg=' . $msg . '&msgtype=' . $msgType . '&tmpl=component&browse=1');
 }
コード例 #25
0
ファイル: rules.php プロジェクト: BetterBetterBetter/B3App
 private function installXML($path)
 {
     // @task: Try to read the temporary file.
     $contents = JFile::read($path);
     $parser = DiscussHelper::getHelper('XML', $contents);
     $app = JFactory::getApplication();
     // @task: Test for appropriate manifest type
     if ($parser->getName() != 'easydiscuss') {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
         $app->close();
     }
     // @task: Bind appropriate values from the xml file into the database table.
     $rule = DiscussHelper::getTable('Rules');
     $rule->command = (string) $parser->command;
     $rule->title = (string) $parser->title;
     $rule->description = (string) $parser->description;
     $rule->set('published', 1);
     $rule->set('created', DiscussHelper::getDate()->toMySQL());
     if ($rule->exists($rule->command)) {
         return;
     }
     return $rule->store();
 }
コード例 #26
0
ファイル: posts.php プロジェクト: pguilford/vcomcc
 /**
  * Saves an edited reply if the site is configured to use a WYSIWYG editor
  *
  * @since	3.2
  * @access	public
  * @param	string
  * @return	
  */
 public function saveReply()
 {
     //JRequest::checkToken('request') or jexit( 'Invalid Token' );
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $post = JRequest::get('POST');
     $output = array();
     $output['id'] = $post['post_id'];
     $postTable = DiscussHelper::getTable('Post');
     $postTable->load($post['post_id']);
     $categoryTable = DiscussHelper::getTable('category');
     $categoryTable->load($postTable->category_id);
     $postAccess = DiscussHelper::getPostAccess($postTable, $categoryTable);
     if (!$postAccess->canEdit()) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask&id=' . $post['post_id'], false));
         return $app->close();
     }
     // do checking here!
     if (empty($post['dc_reply_content'])) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_ERROR_REPLY_EMPTY'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask&id=' . $post['post_id'], false));
         return $app->close();
     }
     // Rebind the post data
     $post['dc_reply_content'] = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
     $post['content'] = $post['dc_reply_content'];
     $data['content_type'] = DiscussHelper::getEditorType('reply');
     $postTable->bind($post);
     $recaptcha = $config->get('antispam_recaptcha');
     $public = $config->get('antispam_recaptcha_public');
     $private = $config->get('antispam_recaptcha_private');
     if (!$config->get('antispam_recaptcha_registered_members') && $my->id > 0) {
         $recaptcha = false;
     }
     if ($recaptcha && $public && $private) {
         require_once DISCUSS_CLASSES . '/recaptcha.php';
         $obj = DiscussRecaptcha::recaptcha_check_answer($private, $_SERVER['REMOTE_ADDR'], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
         if (!$obj->is_valid) {
             $ajax->reloadCaptcha();
             $ajax->reject('error', JText::_('COM_EASYDISCUSS_POST_INVALID_RECAPTCHA_RESPONSE'));
             $ajax->send();
         }
     } else {
         if ($config->get('antispam_easydiscuss_captcha')) {
             $runCaptcha = DiscussHelper::getHelper('Captcha')->showCaptcha();
             if ($runCaptcha) {
                 $response = JRequest::getVar('captcha-response');
                 $captchaId = JRequest::getInt('captcha-id');
                 $discussCaptcha = new stdClass();
                 $discussCaptcha->captchaResponse = $response;
                 $discussCaptcha->captchaId = $captchaId;
                 $state = DiscussHelper::getHelper('Captcha')->verify($discussCaptcha);
                 if (!$state) {
                     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_CAPTCHA'), DISCUSS_QUEUE_ERROR);
                     $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&layout=edit&id=' . $postTable->id, false));
                     return $app->close();
                 }
             }
         }
     }
     // @rule: Bind parameters
     if ($config->get('reply_field_references')) {
         $postTable->bindParams($post);
     }
     // Bind file attachments
     if ($acl->allowed('add_attachment', '0')) {
         $postTable->bindAttachments();
     }
     $isNew = false;
     // @trigger: onBeforeSave
     DiscussEventsHelper::importPlugin('content');
     DiscussEventsHelper::onContentBeforeSave('post', $postTable, $isNew);
     if (!$postTable->store()) {
         $ajax->reject('error', JText::_('COM_EASYDISCUSS_ERROR'));
         $ajax->send();
     }
     // Process poll items
     $includePolls = JRequest::getBool('pollitems', false);
     // Process poll items here.
     if ($includePolls && $config->get('main_polls')) {
         $pollItems = JRequest::getVar('pollitems');
         $pollItemsOri = JRequest::getVar('pollitemsOri');
         // Delete polls if necessary since this post doesn't contain any polls.
         //if( !$isNew && !$includePolls )
         if (count($pollItems) == 1 && empty($pollItems[0]) && !$isNew) {
             $postTable->removePoll();
         }
         // Check if the multiple polls checkbox is it checked?
         $multiplePolls = JRequest::getVar('multiplePolls', '0');
         if ($pollItems) {
             // As long as we need to create the poll answers, we need to create the main question.
             $pollTitle = JRequest::getVar('poll_question', '');
             // Since poll question are entirely optional.
             $pollQuestion = DiscussHelper::getTable('PollQuestion');
             $pollQuestion->loadByPost($postTable->id);
             $pollQuestion->post_id = $postTable->id;
             $pollQuestion->title = $pollTitle;
             $pollQuestion->multiple = $config->get('main_polls_multiple') ? $multiplePolls : false;
             $pollQuestion->store();
             if (!$isNew) {
                 // Try to detect which poll items needs to be removed.
                 $remove = JRequest::getVar('pollsremove');
                 if (!empty($remove)) {
                     $remove = explode(',', $remove);
                     foreach ($remove as $id) {
                         $id = (int) $id;
                         $poll = DiscussHelper::getTable('Poll');
                         $poll->load($id);
                         $poll->delete();
                     }
                 }
             }
             for ($i = 0; $i < count($pollItems); $i++) {
                 $item = $pollItems[$i];
                 $itemOri = isset($pollItemsOri[$i]) ? $pollItemsOri[$i] : '';
                 $value = (string) $item;
                 $valueOri = (string) $itemOri;
                 if (trim($value) == '') {
                     continue;
                 }
                 $poll = DiscussHelper::getTable('Poll');
                 if (empty($valueOri) && !empty($value)) {
                     // this is a new item.
                     $poll->set('value', $value);
                     $poll->set('post_id', $postTable->get('id'));
                     $poll->store();
                 } else {
                     if (!empty($valueOri) && !empty($value)) {
                         // update existing value.
                         if (!$poll->loadByValue($valueOri, $postTable->get('id'))) {
                             $poll->set('value', $value);
                             $poll->store();
                         }
                     }
                 }
             }
         }
     }
     if (!empty($postTable->id)) {
         //Clear off previous records before storing
         $ruleModel = DiscussHelper::getModel('CustomFields');
         $ruleModel->deleteCustomFieldsValue($postTable->id, 'update');
         // Process custom fields.
         $fieldIds = JRequest::getVar('customFields');
         if (!empty($fieldIds)) {
             foreach ($fieldIds as $fieldId) {
                 $fields = JRequest::getVar('customFieldValue_' . $fieldId);
                 if (!empty($fields)) {
                     // Cater for custom fields select list
                     // To detect if there is no value selected for the select list custom fields
                     if (in_array('defaultList', $fields)) {
                         $tempKey = array_search('defaultList', $fields);
                         $fields[$tempKey] = '';
                     }
                 }
                 $postTable->bindCustomFields($fields, $fieldId);
             }
         }
     }
     // @trigger: onAfterSave
     DiscussEventsHelper::onContentAfterSave('post', $postTable, $isNew);
     //get parent post
     $parentId = $postTable->parent_id;
     $parentTable = DiscussHelper::getTable('Post');
     $parentTable->load($parentId);
     // filtering badwords
     $postTable->title = DiscussHelper::wordFilter($postTable->title);
     $postTable->content = DiscussHelper::wordFilter($postTable->content);
     //all access control goes here.
     $canDelete = false;
     if (DiscussHelper::isSiteAdmin() || $acl->allowed('delete_reply', '0') || $postTable->user_id == $user->id) {
         $canDelete = true;
     }
     // @rule: URL References
     $postTable->references = $postTable->getReferences();
     // set for vote status
     $voteModel = DiscussHelper::getModel('Votes');
     $postTable->voted = $voteModel->hasVoted($postTable->id);
     // get total vote for this reply
     $postTable->totalVote = $postTable->sum_totalvote;
     //load porfile info and auto save into table if user is not already exist in discuss's user table.
     $creator = DiscussHelper::getTable('Profile');
     $creator->load($postTable->user_id);
     $postTable->user = $creator;
     //default value
     $postTable->isVoted = 0;
     $postTable->total_vote_cnt = 0;
     $postTable->likesAuthor = '';
     $postTable->minimize = 0;
     if ($config->get('main_content_trigger_replies')) {
         // process content plugins
         DiscussEventsHelper::importPlugin('content');
         DiscussEventsHelper::onContentPrepare('reply', $postTable);
         $postTable->event = new stdClass();
         $results = DiscussEventsHelper::onContentBeforeDisplay('reply', $postTable);
         $postTable->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = DiscussEventsHelper::onContentAfterDisplay('reply', $postTable);
         $postTable->event->afterDisplayContent = trim(implode("\n", $results));
     }
     $theme = new DiscussThemes();
     $question = DiscussHelper::getTable('Post');
     $question->load($postTable->parent_id);
     $recaptcha = '';
     $enableRecaptcha = $config->get('antispam_recaptcha');
     $publicKey = $config->get('antispam_recaptcha_public');
     $skipRecaptcha = $config->get('antispam_skip_recaptcha');
     $model = DiscussHelper::getModel('Posts');
     $postCount = count($model->getPostsBy('user', $my->id));
     if ($enableRecaptcha && !empty($publicKey) && $postCount < $skipRecaptcha) {
         require_once DISCUSS_CLASSES . '/recaptcha.php';
         $recaptcha = getRecaptchaData($publicKey, $config->get('antispam_recaptcha_theme'), $config->get('antispam_recaptcha_lang'), null, $config->get('antispam_recaptcha_ssl'), 'edit-reply-recaptcha' . $postTable->id);
     }
     // Get the post access object here.
     $category = DiscussHelper::getTable('Category');
     $category->load($postTable->category_id);
     $access = $postTable->getAccess($category);
     $postTable->access = $access;
     // Get comments for the post
     $commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
     $comments = $postTable->getComments($commentLimit);
     $postTable->comments = DiscussHelper::formatComments($comments);
     $theme->set('question', $question);
     $theme->set('post', $postTable);
     $theme->set('category', $category);
     $html = $theme->fetch('post.reply.item.php');
     if ($recaptcha && $public && $private) {
         $output['type'] = 'success.captcha';
     }
     if (!$parentTable->islock) {
         $output['type'] = 'locked';
     }
     $message = $isNew ? JText::_('COM_EASYDISCUSS_POST_STORED') : JText::_('COM_EASYDISCUSS_EDIT_SUCCESS');
     $state = 'success';
     // Let's set our custom message here.
     DiscussHelper::setMessageQueue($message, $state);
     $redirect = JRequest::getVar('redirect', '');
     if (!empty($redirect)) {
         $redirect = base64_decode($redirect);
         return $this->setRedirect($redirect);
     }
     $this->setRedirect(DiscussRouter::getPostRoute($post['parent_id'], false));
 }
コード例 #27
0
 function unsubscribe()
 {
     $my = JFactory::getUser();
     $redirectLInk = 'index.php?option=com_easydiscuss&view=profile#Subscriptions';
     if ($my->id == 0) {
         $redirectLInk = 'index.php?option=com_easydiscuss&view=index';
     }
     //type=site - subscription type
     //sid=1 - subscription id
     //uid=42 - user id
     //token=0fd690b25dd9e4d2dc47a252d025dff4 - md5 subid.subdate
     $data = base64_decode(JRequest::getVar('data', ''));
     $param = DiscussHelper::getRegistry($data);
     $param->type = $param->get('type', '');
     $param->sid = $param->get('sid', '');
     $param->uid = $param->get('uid', '');
     $param->token = $param->get('token', '');
     $subtable = DiscussHelper::getTable('Subscribe');
     $subtable->load($param->sid);
     $token = md5($subtable->id . $subtable->created);
     $paramToken = md5($param->sid . $subtable->created);
     if (empty($subtable->id)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SUBSCRIPTION_NOT_FOUND'), 'error');
         $this->setRedirect(DiscussRouter::_($redirectLInk, false));
         return false;
     }
     if ($token != $paramToken) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SUBSCRIPTION_UNSUBSCRIBE_FAILED'), 'error');
         $this->setRedirect(DiscussRouter::_($redirectLInk, false));
         return false;
     }
     if (!$subtable->delete($param->sid)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SUBSCRIPTION_UNSUBSCRIBE_FAILED_ERROR_DELETING_RECORDS'), 'error');
         $this->setRedirect(DiscussRouter::_($redirectLInk, false));
         return false;
     }
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SUBSCRIPTION_UNSUBSCRIBE_SUCCESS'));
     $this->setRedirect(DiscussRouter::_($redirectLInk, false));
     return true;
 }
コード例 #28
0
ファイル: less.php プロジェクト: BetterBetterBetter/B3App
 public function compileStylesheet($in, $out, $settings = array())
 {
     $config = DiscussHelper::getConfig();
     $assets = DiscussHelper::getHelper('assets');
     // Prepare result object
     $result = new stdClass();
     $result->in = $in;
     $result->in_uri = $assets->toUri($in);
     $result->out = $out;
     $result->out_uri = $assets->toUri($out);
     $result->cache = null;
     $result->failed = false;
     if ($this->compileMode == "off") {
         $result->cache = $this->getExistingCacheStructure($in);
         return $result;
     }
     // If incoming file does not exist, stop.
     if (!JFile::exists($result->in)) {
         $result->failed = true;
         $result->message = "Could not open main stylesheet file \"style.less\".";
         return $result;
     }
     // Force compile when target file does not exist.
     // This prevents less from failing to compile when
     // the css file was deleted but the cache file still retains.
     if (!JFile::exists($result->out)) {
         $this->force = true;
     }
     if ($this->compileMode == "force") {
         $this->force = true;
     }
     // Used to build relative uris
     $out_folder = dirname($result->out_uri);
     // Used to ensure uris are absolute
     $out_ext = $config->get('layout_compile_external_asset_path_type') == "absolute" ? $out_folder . '/' : "";
     // Default settings
     $defaultSettings = array("importDir" => array("media" => $assets->path('media', 'styles'), "foundry" => $assets->path('foundry', 'styles')), "variables" => array("root" => "'" . $assets->fileUri("root") . "'", "root_uri" => "'" . $out_ext . $assets->relativeUri($assets->uri('root'), $out_folder) . "'"));
     // Common locations
     $locations = array("admin", "admin_base", "site", "site_base", "media", "foundry");
     // Also include template overrides
     if ($this->allowTemplateOverride) {
         $locations[] = "admin_override";
         $locations[] = "site_override";
     }
     // This creates a pair of variables for each location,
     // one of itself, one of the uri counterpart.
     foreach ($locations as $location) {
         $defaultSettings["variables"][$location] = "'" . $assets->fileUri($location, 'styles') . "'";
         $defaultSettings["variables"][$location . '_uri'] = "'" . $out_ext . $assets->relativeUri($assets->uri($location, 'styles'), $out_folder) . "'";
     }
     // Mixin settings
     $settings = array_merge_recursive($settings, $defaultSettings);
     $this->setImportDir($settings["importDir"]);
     $this->setVariables($settings["variables"]);
     // Compile stylesheet
     try {
         $result->cache = $this->cachedCompileFile($in, $out, $this->force);
     } catch (Exception $ex) {
         $result->failed = true;
         $result->message = 'LESS Error: ' . $ex->getMessage() . 'error';
         DiscussHelper::setMessageQueue($result->message);
     }
     return $result;
 }
コード例 #29
0
ファイル: helper.php プロジェクト: pguilford/vcomcc
 public static function uploadMediaAvatar($mediaType, $mediaTable, $isFromBackend = false)
 {
     jimport('joomla.utilities.error');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $my = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     //$acl		= DiscussACLHelper::getRuleSet();
     // required params
     $layout_type = $mediaType == 'category' ? 'categories' : 'teamblogs';
     $view_type = $mediaType == 'category' ? 'categories' : 'teamblogs';
     $default_avatar_type = $mediaType == 'category' ? 'default_category.png' : 'default_team.png';
     if (!$isFromBackend && $mediaType == 'category') {
         $url = 'index.php?option=com_easydiscuss&view=categories';
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NO_PERMISSION_TO_UPLOAD_AVATAR'), 'warning');
         $mainframe->redirect(DiscussRouter::_($url, false));
     }
     $avatar_config_path = $mediaType == 'category' ? $config->get('main_categoryavatarpath') : $config->get('main_teamavatarpath');
     $avatar_config_path = rtrim($avatar_config_path, '/');
     $avatar_config_path = str_replace('/', DIRECTORY_SEPARATOR, $avatar_config_path);
     $upload_path = JPATH_ROOT . '/' . $avatar_config_path;
     $rel_upload_path = $avatar_config_path;
     $err = null;
     $file = JRequest::getVar('Filedata', '', 'files', 'array');
     //check whether the upload folder exist or not. if not create it.
     if (!JFolder::exists($upload_path)) {
         if (!JFolder::create($upload_path)) {
             // Redirect
             if (!$isFromBackend) {
                 DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_IMAGE_UPLOADER_FAILED_TO_CREATE_UPLOAD_FOLDER'), 'error');
                 $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false));
             } else {
                 //from backend
                 $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false), JText::_('COM_EASYDISCUSS_IMAGE_UPLOADER_FAILED_TO_CREATE_UPLOAD_FOLDER'), 'error');
             }
             return;
         } else {
             // folder created. now copy index.html into this folder.
             if (!JFile::exists($upload_path . '/index.html')) {
                 $targetFile = DISCUSS_ROOT . '/index.html';
                 $destFile = $upload_path . '/index.html';
                 if (JFile::exists($targetFile)) {
                     JFile::copy($targetFile, $destFile);
                 }
             }
         }
     }
     //makesafe on the file
     $file['name'] = $mediaTable->id . '_' . JFile::makeSafe($file['name']);
     if (isset($file['name'])) {
         $target_file_path = $upload_path;
         $relative_target_file = $rel_upload_path . '/' . $file['name'];
         $target_file = JPath::clean($target_file_path . '/' . JFile::makeSafe($file['name']));
         $isNew = false;
         require_once DISCUSS_HELPERS . '/image.php';
         require_once DISCUSS_CLASSES . '/simpleimage.php';
         if (!DiscussImageHelper::canUpload($file, $err)) {
             if (!$isFromBackend) {
                 DiscussHelper::setMessageQueue(JText::_($err), 'error');
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false));
             } else {
                 // From backend
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories'), JText::_($err), 'error');
             }
             return;
         }
         if (0 != (int) $file['error']) {
             if (!$isFromBackend) {
                 DiscussHelper::setMessageQueue($file['error'], 'error');
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false));
             } else {
                 // From backend
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false), $file['error'], 'error');
             }
             return;
         }
         // Rename the file 1st.
         $oldAvatar = empty($mediaTable->avatar) ? $default_avatar_type : $mediaTable->avatar;
         $tempAvatar = '';
         if ($oldAvatar != $default_avatar_type) {
             $session = JFactory::getSession();
             $sessionId = $session->getToken();
             $fileExt = JFile::getExt(JPath::clean($target_file_path . '/' . $oldAvatar));
             $tempAvatar = JPath::clean($target_file_path . '/' . $sessionId . '.' . $fileExt);
             JFile::move($target_file_path . '/' . $oldAvatar, $tempAvatar);
         } else {
             $isNew = true;
         }
         if (JFile::exists($target_file)) {
             if ($oldAvatar != $default_avatar_type) {
                 //rename back to the previous one.
                 JFile::move($tempAvatar, $target_file_path . '/' . $oldAvatar);
             }
             if (!$isFromBackend) {
                 DiscussHelper::setMessageQueue(JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false));
             } else {
                 //from backend
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false), JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
             }
             return;
         }
         if (JFolder::exists($target_file)) {
             if ($oldAvatar != $default_avatar_type) {
                 //rename back to the previous one.
                 JFile::move($tempAvatar, $target_file_path . '/' . $oldAvatar);
             }
             if (!$isFromBackend) {
                 //JError::raiseNotice(100, JText::sprintf('ERROR.FOLDER_ALREADY_EXISTS',$relative_target_file));
                 DiscussHelper::setMessageQueue(JText::sprintf('ERROR.FOLDER_ALREADY_EXISTS', $relative_target_file), 'error');
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false));
             } else {
                 //from backend
                 $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories', false), JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
             }
             return;
         }
         $configImageWidth = DISCUSS_AVATAR_LARGE_WIDTH;
         $configImageHeight = DISCUSS_AVATAR_LARGE_HEIGHT;
         $image = new SimpleImage();
         $image->load($file['tmp_name']);
         $image->resize($configImageWidth, $configImageHeight);
         $image->save($target_file, $image->image_type);
         //now we update the user avatar. If needed, we remove the old avatar.
         if ($oldAvatar != $default_avatar_type) {
             if (JFile::exists($tempAvatar)) {
                 JFile::delete($tempAvatar);
             }
         }
         return JFile::makeSafe($file['name']);
     } else {
         return $default_avatar_type;
     }
 }
コード例 #30
0
ファイル: profile.php プロジェクト: BetterBetterBetter/B3App
 public function disableUser()
 {
     // Only allow site admin to disable this.
     if (!DiscussHelper::isSiteAdmin()) {
         return $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
     }
     $userId = JRequest::getInt('id');
     $db = DiscussHelper::getDBO();
     $query = 'UPDATE ' . $db->nameQuote('#__users') . ' SET ' . $db->nameQuote('block') . '=' . $db->quote(1) . ' WHERE ' . $db->nameQuote('id') . '=' . $db->quote($userId);
     $db->setQuery($query);
     $result = $db->query();
     if (!$result) {
         return $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $userId, false));
     }
     $message = JText::_('COM_EASYDISCUSS_USER_DISABLED');
     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
     $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
 }