2011-05-06, 02:55 PM
I get an error when I activate the plug in I've been working on.
I have a language file written for it that is titled socialgroups.lang.php and has the language defined.
The plug-in code:
I'm sure its something simple I'm forgetting since this is the first time I've done a plug-in.
error Wrote:Fatal error: Cannot use object of type MyLanguage as array in /home/teamrogu/public_html/forums/inc/plugins/socialgroups.php on line 78
I have a language file written for it that is titled socialgroups.lang.php and has the language defined.
The plug-in code:
<?php
if (!defined("IN_MYBB"))
{
die ("Direct access to this file is not allowed. Please make use IN_MYBB is defined.");
}
function socialgroups_info()
{
return array(
"name" => "Social Groups",
"description" => "A plug-in that lets users create their own groups and control various settings.",
"website" => "http://www.teamdimensional.net",
"author" => "Mark Janssen",
"authorsite" => "http://www.teamdimensional.net",
"version" => "1.0",
"guid" => "",
"compatibility" => "16*"
);
}
function socialgroups_install ()
{
global $db;
/* Create the necessary tables */
$db->query("CREATE TABLE ".TABLE_PREFIX."socialgroups (
sgid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name TEXT,
uid INT,
description TEXT,
leader TEXT,
privacy INT NOT NULL DEFAULT 0,
numdisc INT,
memberids TEXT,
joinoptions TEXT
) ENGINE = MYISAM");
$db->query("CREATE TABLE ".TABLE_PREFIX."sgconversations (
conid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
topic TEXT,
message TEXT,
replies INT NOT NULL DEFAULT 0,
lastposter TEXT,
author TEXT,
locked INT NOT NULL DEFAULT 0,
approved INT NOT NULL DEFAULT 1,
puid INT,
sgid INT) ENGINE = MYISAM");
$db->query("CREATE TABLE ".TABLE_PREFIX."sgposts (
pid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
conid INT,
uid INT,
username TEXT,
message TEXT) ENGINE = MYISAM");
/* Alter the users table to be able to track amount of posts in this area and the groups a member is in. */
$db->query("ALTER TABLE "
.TABLE_PREFIX."users
ADD groupposts INT NOT NULL DEFAULT '0',
ADD groupsin TEXT");
}
function socialgroups_activate()
{
/* Time to create the new templates */
global $db, $mybb, $lang;
$new_template['groups'] = "<html>
<head>
<title>
Groups
</title>
{$headerinclude}
</head>
<body>
{$header}
{$groupadd}
<table width='100%' border='1'>
<tr>
<th class='thead'>{$lang['group_name']}</th>
<th class='thead'>{$lang['group_leader']}</th>
<th class='thead'>{$lang['group_discussions']}</th>
<th class='thead'>{$lang['group_description']}</th>
</tr>
{$grouplist}
</table>
{$groupcreate}
<form action='{$settings['bburl']}/groups.php' method='post'>
<input type='hidden' name='action' value='create' />
<input type='submit' value='{$lang['create_group']}' /></form>
{$footer}
</body>
</html>";
$new_template['grouplist'] = "<tr><td class='trow2'><a href='{$settings['bburl']}/showgroup.php?gid={$group['sgid']}' style='text-decoration:none'>{$group['name']}</td>
<td class='trow2'><a href='{$settings['bburl']}/member.php?action=profile&uid={$group['uid']}' style='{$group['namestyle']}'>{$group['leader']}</a></td>
<td class='trow2'>{$group['numdisc']}</td>
<td class='trow2'>{$group['description']}</td>
</tr>";
$new_template['groupthread'] = "<html>
<head>
<title>{$conversation['topic']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width='100%'>
<tr>
<td class='trow1' style='text-align:center'>{$conversation['topic']}</td>
</tr>
</table>
<table border='1' width='100%'>
<tr>
<th class='thead'>{$lang['group_username']}</th>
<th class='thead'>{$lang['group_message']}</th>
</tr>
{$groupposts}
</table>
{$groupthreadreply}
{$footer}
</body>
</html>";
$new_template['groupthread_mod'] = "<tr>
<td class='trow2'>{$lang['group_edit']} — {$lang['group_delete']}</td><td>{$lang['group_approve']} — {$lang['group_unapprove']}</td>
</tr>";
$new_template['groupthread_post'] = "<tr>
<td class='trow1'><a href='{$settings['bburl']}/member.php?action=profile&uid={$posts['uid']}' style='{$posts['namestyle']}'>{$posts['username']}<br />
<img src='{$posts['avatar']}' alt='' /></td>
<td class='trow1'>{$posts['message']}</td></tr>
<tr>
<td class='trow1'></td>
<td class='trow1'>{$posts['signature']}</td>
</tr>
{$groupthreadmod}";
$new_template['groupthread_reply'] = "<form action='{$settings['bburl']}/groupthread.php?conid={$conid}' method='post'>
<input type='hidden' name='action' value='reply' />
{$lang['group_message']}<textarea name='message' rows='10' cols='70'></textarea><br />
<input type='submit' value='{$lang['group_post_reply']}' /></form>";
$new_template['groupthread_reply_error'] = "{$lang['error_no_message']}";
$new_template['$group_add'] = "<form action='{$settings['bburl']}/groups.php' method='post'>
<input type='hidden' name='action' value='newgroup' />
{$lang['group_name']}:<input type='text' name='groupname' /><br />
{$lang['description']}:<textarea rows='3' cols='70' name='description'></textarea><br />
{$lang['group_privacy']}:<select name='privacy'>
<option value='0'>{$lang['anyone_read']}</option>
<option value='1'>{$lang['only_members_read']}</option></select><br />
{$lang['group_join_options']}:<select name='joinoptions'>
<option value='all'>{$lang['group_all_join']}</option>
<option value='mod'>{$lang['group_staff_only']}</option></select><br />
<input type='submit' value='{$lang['group_add_group']}' /></form>";
$new_template['group_add_error'] = "{$lang['group_add_error']}";
$new_template['group_add_success'] = "{$lang['group_add_success']}";
$new_template['group_add_thread_error'] = "{$lang['group_add_thread_error']}";
$new_template['group_discussions'] = "<tr>
<td class='trow2'><a href='{$settings['bburl']}/groupthread.php?conid={$groupdisc['conid']}' style='text-decoration:none'>{$groupdisc['topic']}</a></td>
<td class='trow2'><a href='{$settings['bburl']}/member.php?action=profile&uid={$groupdisc['uid']}' style='{$groupdisc['namestyle']}'>{$groupdisc['author']}</a></td>
<td class='trow2'>{$groupdisc['replies']}</td>
<td class='trow2'><a href='{$settings['bburl']}/member.php?action=profile&uid={$groupdisc['uid']}' style='{$groupdisc['namestyle']}'>{$groupdisc['lastposter']}</a></td>
</tr>";
$new_template['group_display'] = "<html>
<head>
{$headerinclude}
</head>
<body>
{$header}
{$joingroup}
{$lang['group_members']}:
<table border='1' width='100%'>
<tr>
<th class='thead'>{$lang['group_username']}</th>
<th class='thead'>{$lang['group_usertitle']}</th>
</tr>
{$group_members}
</table>
{$groupjoin}
<table border='1' width='100%'>
<tr>
<th class='thead'>{$lang['group_topic']}</th>
<th class='thead'>{$lang['group_author']}</th>
<th class='thead'>{$lang['group_replies']}</th>
<th class='thead'>{$lang['group_last_post']}</th>
</tr>
{$groupthreads}
</table>
{$newdiscussion}
{$grouptopic}
<form action='{$settings['bburl']}/showgroup.php?gid={$gid}' method='post'>
<input type='hidden' name='action' value='addthread' />
<input type='submit' value='{$lang['group_new_thread']}' /></form>
{$footer}
</body>
</html>";
$new_template['group_join_group'] = "<a href='{$settings['bburl']}/showgroup.php?action=join&gid={$gid}'>{$lang['join_group']}</a><br />";
$new_template['group_join_success'] = "{$lang['group_succesful_join']} {$groupinfo['name']} {$lang['group_group']}.<br />";
$new_template['group_members'] = "<tr>
<td class='trow2'><a href='{$settings['bburl']}/member.php?action=profile&uid={$groupmember['uid']}' style='{$groupmember['namestyle']}'>{$groupmember['username']}</a><br/>
<img src='{$groupmember['avatar']}' alt='' /></td>
<td class='trow2'>{$groupmember['usertitle']}</td>
</tr>";
$new_template['group_new_discussion'] = "<form action='{$settings['bburl']}/showgroup.php?gid={$gid}' method='post'>
<input type='hidden' name='action' value='newtopic' />
{$lang['group_topic']}:<input type='text' name='topic' /><br />
{$lang['group_message']}:<textarea name='message' rows='8' cols='70'></textarea><br />
<input type='submit' value='{$lang['submit_thread']}' /></form>";
$new_template['group_no_join'] = "{$lang['group_unable_to_join_group']}";
$new_template['group_no_threads'] = "<tr><td>{$lang['group_unable_to_view']}.</td></tr>";
foreach($new_template as $title => $template)
{
$new_template = array('title' => $db->escape_string($title), 'template' => $db->escape_string($template), 'sid' => '-1', 'version' => '1600', 'dateline' => TIME_NOW);
$db->insert_query('templates', $new_template);
}
}
function socialgroups_deactivate()
{
/* Get rid of the templates */
global $db, $mybb;
$delete_templates = array ('grouplist', 'groups', 'groupthread', 'groupthread_mod', 'groupthread_post', 'groupthread_reply', 'groupthread_reply_error', 'group_add', 'group_add_error', 'group_add_success', 'group_add_thread_error', 'group_discussions', 'group_display', 'group_join_group', 'group_join_success', 'group_members', 'group_new_discussion', 'group_no_join', 'group_no_threads');
foreach($delete_templates as $template)
{
$db->delete_query('templates', "title = '{$template}'");
}
}
function socialgroups_uninstall()
{
/* We are uninstalling the groups application so we must alter the tables again.*/
global $db;
$db->query("DROP TABLE ".TABLE_PREFIX."socialgroups");
$db->query("DROP TABLE ".TABLE_PREFIX."sgconversations");
$db->query("DROP TABLE ".TABLE_PREFIX."sgposts");
$db->query("ALTER TABLE ".TABLE_PREFIX."users
DROP groupposts, DROP groupsin");
}
function socialgroups_is_installed()
{
global $db;
/* Is the plug in already installed? */
if ($db->table_exists("socialgroups"))
{
return true;
}
return false;
}
?>
I'm sure its something simple I'm forgetting since this is the first time I've done a plug-in.