MyBB Community Forums

Full Version: MyBB Integrator / MyBB SDK (Version 1.3)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
i solved the problem it was related to sessions and a lot of other stuff i use codeigniter on site i have a chat integrated and a lot of things that didn't play well togheder.

can u please make a function change password ?

or what is the password algorithm i can change the pass myself using a query
I will put it on my todo list.

This is how MyBB uses salts on their Passwords:
function salt_password($password, $salt)
{
	return md5(md5($salt).$password);
}
thanks. this has been a lifesaver for me. Big Grin Might think of adding a function for getEvents() though.
getEvents() would be referring to the calendar?
Hi I've got everything setup as in the examples but I am getting a strange permissions error. Perhaps someone can help me figure this out?

The following warnings occurred:
Warning [2] Illegal offset type - Line: 1173 - File: forums\inc\functions.php
forums\inc\functions.php line 1173 - errorHandler->error
forums\inc\functions.php line 1141 - fetch_forum_permissions
forums\inc\class.MyBBIntegrator.php line 211 - forum_permissions
forums\index.php line 29 - MyBBIntegrator->getLatestThreads

Warning [2] Illegal offset type - Line: 1141 - File: forums\inc\functions.php
forums\inc\functions.php line 1141 - errorHandler->error
forums\inc\class.MyBBIntegrator.php line 211 - forum_permissions
forums\index.php line 29 - MyBBIntegrator->getLatestThreads

Warning [2] Illegal offset type - Line: 1143 - File: forums\inc\functions.php
forums\inc\functions.php line 1143 - errorHandler->error
forums\inc\class.MyBBIntegrator.php line 211 - forum_permissions
forums\index.php line 29 - MyBBIntegrator->getLatestThreads

Warning [2] Invalid argument supplied for foreach() - Line: 30 - File: forums\index.php
forums\index.php line 30 - errorHandler->error

in the INDEX.PHP File this is what I have:

<?PHP
define('IN_MYBB', NULL);
define('THIS_SCRIPT', 'index.php');

// set the path to your forums directory here (without trailing slash)
$forumdir = "./";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}
require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/class.MyBBIntegrator.php";;
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang);

$forums = array('2', '3');
$fields = 't.`tid`, t.`fid`, t.`subject`, t.`uid`, t.`username`, t.`dateline`, t.`views`, t.`replies`, t.`numratings`, t.`totalratings`';
$latest_threads = $MyBBI->getLatestThreads($forums, $fields, 5, true, true, false);
foreach ($latest_threads as $latest_thread)
{
    echo $latest_thread['subject'].'<br />';
} 
?>


** UPDATE ***

I was playing with the code trying to figure out the problem and finally found that it is an issue with the arrays, which are being treated as single integers.

This Works
$fields = 't.`tid`, t.`fid`, t.`subject`, t.`uid`, t.`username`, t.`dateline`, t.`views`, t.`replies`, t.`numratings`, t.`totalratings`';
$latest_threads = $MyBBI->getLatestThreads(2, $fields, 5, true, true, false);
foreach ($latest_threads as $latest_thread)
{
    echo $latest_thread['subject'].'<br />';
} 


This Does NOT Work
$forum_arr = array('2','4');
$fields = 't.`tid`, t.`fid`, t.`subject`, t.`uid`, t.`username`, t.`dateline`, t.`views`, t.`replies`, t.`numratings`, t.`totalratings`';
$latest_threads = $MyBBI->getLatestThreads($forum_arr, $fields, 5, true, true, false);
foreach ($latest_threads as $latest_thread)
{
    echo $latest_thread['subject'].'<br />';
} 

Ok, so what this tells us is that Arrays are not working.

If we open class.MyBBIntegrator.php and goto "function getLatestThreads"
we see that it is treating the value of $forum_id as a single value and not as an array.

Perhaps the Author can fix this up?

Smile
I managed to recreate the bug and I have fixed it.
It will be online with the next version. If you cannot wait, here is the fix.

Replace your getLatestThreads function with this one:

	function getLatestThreads($forum_id = 0, $fields = '*', $limit = 7, $exclude_invisible = true, $join_forums = true, $join_first_post = true)
	{
		if ($forum_id != 0)
		{
			// If we have multiple values, we have to check permission for each forum!
			if (is_array($forum_id))
			{
				foreach ($forum_id as $single_forum_id)
				{
					$forum_permissions = forum_permissions($single_forum_id);
					if ($forum_permissions['canview'] != 1 || $forum_permissions['canviewthreads'] != 1)
					{
						// error_no_permission();
						return false;
					}
				}
			}
			else
			{
				// Do we have permission?
				$forumpermissions = forum_permissions($forum_id);
				if ($forumpermissions['canview'] != 1 || $forumpermissions['canviewthreads'] != 1)
				{
					// error_no_permission();
					return false;
				}
			}
		}
		
		// This is what we will be returning
		$threads = array();
		
		// Do we want to get invisible threads as well?
		$fetch_invisible_threads = ($exclude_invisible == true) ? '1' : '0';
		$condition = 't.`visible` = '.$fetch_invisible_threads;
		
		// Are we fetching threads from multiple forums?
		if (is_array($forum_id) || is_object($forum_id))
		{
			$condition .= ' AND t.`fid` IN ('.implode(', ', $forum_id).')';
			
		}
		// Or are we just fetching threads from one forum?
		else
		{
			$condition .= ($forum_id == 0) ? '' : ' AND t.`fid` = '.$forum_id;
		}
		
		// Do we want to get information of the forum where the thread is located in?
		$forum_join = ($join_forums == true) ? 'INNER JOIN '.TABLE_PREFIX.'forums f ON f.`fid` = t.`fid`' : '';
		
		// Do we want to get the first post from the thread?
		$first_post_join = ($join_first_post == true) ? 'INNER JOIN '.TABLE_PREFIX.'posts p ON p.`pid` = t.`firstpost`' : '';
		
		// Run the Query
		$query = $this->db->query('
			SELECT '.$fields.'
			FROM '.TABLE_PREFIX.'threads t
			'.$forum_join.'
			'.$first_post_join.'
			WHERE '.$condition.'
			ORDER BY t.`dateline` DESC
			LIMIT '.intval($limit).'
		');
		
		// Iterate through the results and assign it to our returning array
		while ($thread = $this->db->fetch_array($query))
		{
			$threads[] = $thread;
		}
		
		return $threads;
	}


And by the way: it was treating it as an array, it just failed to check the permissions for the forums Smile - that's where the bug was
Super fast fixing!

thanks No0oB!

This class roxx!

Smile
quick question

I want to have a list of today's hot topics (threads with most posts in 24hrs) is this possible using one of the existing functions or would I have to create this in the class?
You would have to create it for yourself.
I will put it onto my to-do list though
the integrator still works with the last sec fix ?
i updated the forum and now the integrator functions stoped working
Can you tell me which functions you are using?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15