Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to select by default source mode editor in usercp #646

Merged
merged 1 commit into from Jul 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion admin/inc/class_page.php
Expand Up @@ -824,7 +824,7 @@ function build_codebuttons_editor($bind, $editor_language, $smilies)
}
}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = "";
$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

if($mybb->settings['allowbasicmycode'] == 1)
{
Expand Down Expand Up @@ -877,6 +877,11 @@ function build_codebuttons_editor($bind, $editor_language, $smilies)
$code = "code,";
}

if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}

return <<<EOF

<script type="text/javascript">
Expand All @@ -902,6 +907,7 @@ function build_codebuttons_editor($bind, $editor_language, $smilies)
});

MyBBEditor = $("#{$bind}").sceditor("instance");
{$sourcemode}
});
</script>
EOF;
Expand Down
4 changes: 3 additions & 1 deletion admin/modules/user/users.php
Expand Up @@ -562,7 +562,8 @@
"receivefrombuddy" => $mybb->input['receivefrombuddy'],
"pmnotice" => $mybb->input['pmnotice'],
"daysprune" => $mybb->input['daysprune'],
"showcodebuttons" => intval($mybb->input['showcodebuttons']),
"showcodebuttons" => $mybb->input['showcodebuttons'],
"sourceeditor" => $mybb->input['sourceeditor'],
"pmnotify" => $mybb->input['pmnotify'],
"showredirect" => $mybb->input['showredirect']
);
Expand Down Expand Up @@ -1307,6 +1308,7 @@
$other_options = array(
$form->generate_check_box("showredirect", 1, $lang->show_redirect, array("checked" => $mybb->input['showredirect'])),
$form->generate_check_box("showcodebuttons", "1", $lang->show_code_buttons, array("checked" => $mybb->input['showcodebuttons'])),
$form->generate_check_box("sourceeditor", "1", $lang->source_editor, array("checked" => $mybb->input['sourceeditor'])),
"<label for=\"style\">{$lang->theme}:</label><br />".build_theme_select("style", $mybb->input['style'], 0, "", true, false, true),
"<label for=\"language\">{$lang->board_language}:</label><br />".$form->generate_select_box("language", $languages, $mybb->input['language'], array('id' => 'language'))
);
Expand Down
16 changes: 3 additions & 13 deletions inc/datahandlers/user.php
Expand Up @@ -640,6 +640,8 @@ function verify_options()
$this->verify_yesno_option($options, 'showavatars', 1);
$this->verify_yesno_option($options, 'showquickreply', 1);
$this->verify_yesno_option($options, 'showredirect', 1);
$this->verify_yesno_option($options, 'showcodebuttons', 1);
$this->verify_yesno_option($options, 'sourceeditor', 1);

if($mybb->settings['postlayout'] == 'classic')
{
Expand Down Expand Up @@ -679,19 +681,6 @@ function verify_options()
$options['dst'] = 0;
}

if(isset($options['showcodebuttons']))
{
$options['showcodebuttons'] = intval($options['showcodebuttons']);
if($options['showcodebuttons'] != 0)
{
$options['showcodebuttons'] = 1;
}
}
else if($this->method == "insert")
{
$options['showcodebuttons'] = 1;
}

if($this->method == "insert" || (isset($options['threadmode']) && $options['threadmode'] != "linear" && $options['threadmode'] != "threaded"))
{
if($mybb->settings['threadusenetstyle'])
Expand Down Expand Up @@ -1089,6 +1078,7 @@ function insert_user()
"regip" => $db->escape_binary($user['regip']),
"language" => $db->escape_string($user['language']),
"showcodebuttons" => $user['options']['showcodebuttons'],
"sourceeditor" => $user['options']['sourceeditor'],
"away" => $user['away']['away'],
"awaydate" => $user['away']['date'],
"returndate" => $user['away']['returndate'],
Expand Down
7 changes: 6 additions & 1 deletion inc/functions.php
Expand Up @@ -2878,7 +2878,7 @@ function build_mycode_inserter($bind="message", $smilies = true)
}
}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = "";
$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

if($mybb->settings['allowbasicmycode'] == 1)
{
Expand Down Expand Up @@ -2931,6 +2931,11 @@ function build_mycode_inserter($bind="message", $smilies = true)
$code = "code,";
}

if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}

eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
}
Expand Down
1 change: 1 addition & 0 deletions inc/languages/english/admin/user_users.lang.php
Expand Up @@ -222,6 +222,7 @@
$l['thread_view_options'] = "Thread View Options";
$l['show_redirect'] = "Show friendly redirection pages";
$l['show_code_buttons'] = "Show MyCode formatting options on posting pages";
$l['source_editor'] = "Put the editor in source mode by default";
$l['theme'] = "Theme";
$l['board_language'] = "Board Language";
$l['other_options'] = "Other Options";
Expand Down
1 change: 1 addition & 0 deletions inc/languages/english/usercp.lang.php
Expand Up @@ -143,6 +143,7 @@
$l['pm_notice'] = "Alert me with a notice when I receive a Private Message.";
$l['pm_notify'] = "Notify me by email when I receive a new Private Message.";
$l['show_codebuttons'] = "Show the MyCode formatting options on the posting pages.";
$l['source_editor'] = "Put the editor in source mode by default";
$l['show_redirect'] = "Show friendly redirect pages.";
$l['thread_view_options'] = "Thread View Options";
$l['thread_mode'] = "Thread View Mode:";
Expand Down
5 changes: 5 additions & 0 deletions install/resources/mybb_theme.xml
Expand Up @@ -12213,6 +12213,10 @@ if(use_xmlhttprequest == "1")
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="showcodebuttons" id="showcodebuttons" value="1" {$showcodebuttonscheck} /></td>
<td><span class="smalltext"><label for="showcodebuttons">{$lang->show_codebuttons}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="sourceeditor" id="sourceeditor" value="1" {$sourcemodecheck} /></td>
<td><span class="smalltext"><label for="sourceeditor">{$lang->source_editor}</label></span></td>
</tr>
{$board_style}
{$board_language}
</table>
Expand Down Expand Up @@ -13229,6 +13233,7 @@ $(function() {
});

MyBBEditor = $("#{$bind}").sceditor("instance");
{$sourcemode}
});
</script>]]></template>
<template name="contact" version="1800"><![CDATA[<html>
Expand Down
3 changes: 2 additions & 1 deletion install/resources/mysql_db_tables.php
Expand Up @@ -1063,6 +1063,7 @@
classicpostbit tinyint(1) NOT NULL default '0',
loginattempts tinyint(2) NOT NULL default '1',
usernotes text NOT NULL,
sourceeditor tinyint(1) NOT NULL default '0',
UNIQUE KEY username (username),
KEY usergroup (usergroup),
KEY regip (regip),
Expand Down Expand Up @@ -1113,4 +1114,4 @@ classicpostbit tinyint(1) NOT NULL default '0',
PRIMARY KEY (wid)
) ENGINE=MyISAM;";

?>
?>
3 changes: 2 additions & 1 deletion install/resources/pgsql_db_tables.php
Expand Up @@ -1026,6 +1026,7 @@
classicpostbit smallint NOT NULL default '0',
loginattempts smallint NOT NULL default '1',
usernotes text NOT NULL default '',
sourceeditor smallint NOT NULL default '0',
PRIMARY KEY (uid)
);";

Expand Down Expand Up @@ -1071,4 +1072,4 @@ classicpostbit smallint NOT NULL default '0',
PRIMARY KEY(wid)
);";

?>
?>
3 changes: 2 additions & 1 deletion install/resources/sqlite_db_tables.php
Expand Up @@ -950,7 +950,8 @@
coppauser tinyint(1) NOT NULL default '0',
classicpostbit tinyint(1) NOT NULL default '0',
loginattempts tinyint(2) NOT NULL default '1',
usernotes TEXT NOT NULL
usernotes TEXT NOT NULL,
sourceeditor tinyint(1) NOT NULL default '0'
);";

$tables[] = "CREATE TABLE mybb_usertitles (
Expand Down
7 changes: 7 additions & 0 deletions install/resources/upgrade30.php
Expand Up @@ -578,6 +578,11 @@ function upgrade30_dbchanges5()
$db->drop_column("awaitingactivation", "validated");
}

if($db->field_exists('sourceeditor', 'users'))
{
$db->drop_column("users", "sourceeditor");
}

switch($db->type)
{
case "pgsql":
Expand All @@ -593,6 +598,7 @@ function upgrade30_dbchanges5()
$db->add_column("joinrequests", "invite", "smallint NOT NULL default '0'");
$db->add_column("profilefields", "registration", "smallint NOT NULL default '0' AFTER required");
$db->add_column("awaitingactivation", "validated", "smallint NOT NULL default '0' AFTER type");
$db->add_column("users", "sourceeditor", "smallint NOT NULL default '0'");
break;
default:
$db->add_column("profilefields", "postbit", "tinyint(1) NOT NULL default '0' AFTER hidden");
Expand All @@ -607,6 +613,7 @@ function upgrade30_dbchanges5()
$db->add_column("joinrequests", "invite", "tinyint(1) NOT NULL default '0'");
$db->add_column("profilefields", "registration", "tinyint(1) NOT NULL default '0' AFTER required");
$db->add_column("awaitingactivation", "validated", "tinyint(1) NOT NULL default '0' AFTER type");
$db->add_column("users", "sourceeditor", "tinyint(1) NOT NULL default '0'");
break;
}

Expand Down
12 changes: 11 additions & 1 deletion usercp.php
Expand Up @@ -718,6 +718,7 @@
"receivefrombuddy" => $mybb->get_input('receivefrombuddy', 1),
"daysprune" => $mybb->get_input('daysprune', 1),
"showcodebuttons" => $mybb->get_input('showcodebuttons', 1),
"sourceeditor" => $mybb->get_input('sourceeditor', 1),
"pmnotify" => $mybb->get_input('pmnotify', 1),
"buddyrequestspm" => $mybb->get_input('buddyrequestspm', 1),
"buddyrequestsauto" => $mybb->get_input('buddyrequestsauto', 1),
Expand Down Expand Up @@ -928,6 +929,15 @@
$showcodebuttonscheck = "";
}

if(isset($user['sourceeditor']) && $user['sourceeditor'] == 1)
{
$sourcemodecheck = "checked=\"checked\"";
}
else
{
$sourcemodecheck = "";
}

if(isset($user['showredirect']) && $user['showredirect'] != 0)
{
$showredirectcheck = "checked=\"checked\"";
Expand Down Expand Up @@ -4050,4 +4060,4 @@
eval("\$usercp = \"".$templates->get("usercp")."\";");
output_page($usercp);
}
?>
?>