Skip to content

Commit

Permalink
Merge pull request #242 from WildcardSearch/maintenance
Browse files Browse the repository at this point in the history
3.2.9 Release
  • Loading branch information
Mark Vincent authored Feb 27, 2019
2 parents 7aa79aa + c08cacf commit ce0dd9a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## MentionMe 3.2.8
## MentionMe 3.2.9

A plugin for MyBB 1.8.x that allows Twitter-style tagging and integration with [MyAlerts](https://github.com/euantorano/MyAlerts)

Expand Down
1 change: 1 addition & 0 deletions Upload/inc/languages/english/admin/mention.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
// MyAlerts
$l['mention_myalerts_acpsetting_description'] = 'Alerts for mentions?';
$l['mention_myalerts_integration_message'] = 'MyAlerts is detected as installed but has not yet been integrated with MentionMe! Click the link below to integrate.';
$l['mention_myalerts_integration_message_mylaerts_deactivated'] = 'MyAlerts is detected as installed but is currently deactivated.';
$l['mention_myalerts_integrate_link'] = 'Integrate With MyAlerts';
$l['mention_myalerts_successfully_integrated'] = 'MentionMe has been successfully integrated with MyAlerts';

Expand Down
79 changes: 64 additions & 15 deletions Upload/inc/plugins/MentionMe/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ function mention_info()
{$lang->mention_myalerts_successfully_integrated}
</li>
EOF;
} else {
} elseif (function_exists('myalerts_info')) {
$myAlertsReport = <<<EOF
<li style="list-style-image: url(styles/{$cp_style}/images/icons/warning.png)">{$lang->mention_myalerts_integration_message}
</li>
<li style="list-style-image: url(styles/{$cp_style}/images/icons/group.png)">
<a href="index.php?module=config-plugins&amp;action=mentionme&amp;mode=myalerts_integrate">{$lang->mention_myalerts_integrate_link}</a>
</li>
EOF;
} else {
$myAlertsReport = <<<EOF
<li style="list-style-image: url(styles/{$cp_style}/images/icons/warning.png)">
{$lang->mention_myalerts_integration_message_mylaerts_deactivated}
</li>
EOF;
}
}
Expand Down Expand Up @@ -360,7 +366,7 @@ function mentionMeBuildSettingsLink()
*/

/**
* integrate with MyAlerts
* router for ACP pages
*
* @return void
*/
Expand All @@ -384,23 +390,26 @@ function mentionMeAdminLoad()
admin_redirect('index.php?module=config-plugins');
} elseif ($mybb->input['mode'] == 'rebuild_namecache') {
require_once MYBB_ROOT.'/inc/functions_task.php';
$query = $db->simple_select('tasks', 'tid', "file='mentiome_namecache'", array('limit' => '1'));
if ($db->num_rows($query) == 0) {
flash_message($lang->mention_rebuild_name_cache_error, 'error');
admin_redirect('index.php?module=config-plugins');
}

$tid = $db->fetch_field($query, 'tid');
if (run_task($tid)) {
flash_message($lang->mention_rebuild_name_cache_success, 'success');
} else {
flash_message($lang->mention_rebuild_name_cache_error, 'error');
}
admin_redirect('index.php?module=config-plugins');
mentionMeRebuildNameCache();
}
exit;
}

/**
* rebuild the name cache when our settings are updated
*
* @return void
*/
$plugins->add_hook('admin_config_settings_change', 'mentionMeAdminConfigSettingsChange');
function mentionMeAdminConfigSettingsChange()
{
global $mybb;

if (isset($mybb->input['upsetting']['mention_auto_complete'])) {
mentionMeRebuildNameCache(true);
}
}

/*
* build the single ACP setting and add it to the MyAlerts group
*
Expand Down Expand Up @@ -432,4 +441,44 @@ function mentionMeMyAlertsIntegrate()
$alertTypeManager->add($alertType);
}

/**
* rebuild the name cache data by running the task directly
*
* @param bool true to avoid messages/redirects
* @return void
*/
function mentionMeRebuildNameCache($silent=false)
{
global $mybb, $db, $lang;
if (!$lang->mention) {
$lang->load('mention');
}

require_once MYBB_ROOT.'/inc/functions_task.php';
$query = $db->simple_select('tasks', 'tid', "file='mentiome_namecache'", array('limit' => '1'));
if ($db->num_rows($query) == 0) {
if ($silent) {
return false;
}

flash_message($lang->mention_rebuild_name_cache_error, 'error');
admin_redirect('index.php?module=config-plugins');
}

$tid = $db->fetch_field($query, 'tid');
$result = run_task($tid);

if ($silent) {
return $result;
}

if ($result) {
flash_message($lang->mention_rebuild_name_cache_success, 'success');
} else {
flash_message($lang->mention_rebuild_name_cache_error, 'error');
}

admin_redirect('index.php?module=config-plugins');
}

?>
15 changes: 10 additions & 5 deletions Upload/inc/plugins/mention.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// checked by other plugin files
define('IN_MENTIONME', true);
define('MENTIONME_VERSION', '3.2.8');
define('MENTIONME_VERSION', '3.2.9');

// register custom class autoloader
spl_autoload_register('mentionMeClassAutoLoad');
Expand All @@ -37,17 +37,22 @@
*/
function mentionGetMyAlertsStatus()
{
static $status = false, $checked = false;
static $status = null;

if ($checked === true) {
if ($status !== null) {
return $status;
}

global $cache;
$checked = true;

$myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types');

return $status = ($myalerts_plugins['mention']['code'] == 'mention' && $myalerts_plugins['mention']['enabled'] == 1);
if (function_exists('myalerts_info') &&
($myalerts_plugins['mention']['code'] == 'mention' && $myalerts_plugins['mention']['enabled'] == 1)) {
$status = true;
}

return $status;
}

/**
Expand Down
17 changes: 12 additions & 5 deletions Upload/jscripts/MentionMe/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,11 +1473,11 @@ var MentionMe = (function($, m) {
return;
}

this.finalized = false;
this.id = textareaId;
this.editor = CKEDITOR.instances[this.id];

if (textareaId === "message" ||
textareaId === "signature") {
if (this.editor.status != "ready") {
this.editor.on("instanceReady", $.proxy(this.finalize, this));
} else {
this.finalize();
Expand All @@ -1492,7 +1492,10 @@ var MentionMe = (function($, m) {
* @return void
*/
function finalize() {
this.doFinalize();
if (this.editor.mode == "wysiwyg") {
this.doFinalize();
}

this.lastState = this.editor.mode;
this.editor.on('mode', $.proxy(this.onModeChange, this));
}
Expand All @@ -1513,6 +1516,8 @@ var MentionMe = (function($, m) {

// go ahead and build the popup
this.popup = new Popup(this);

this.finalized = true;
}

/**
Expand All @@ -1528,9 +1533,11 @@ var MentionMe = (function($, m) {

this.lastState = e.sender.mode;

if (e.sender.mode == "source") {
if (this.finalized) {
this.unbindKeyup();
} else {
}

if (e.sender.mode != "source") {
this.doFinalize();
}
}
Expand Down
Loading

0 comments on commit ce0dd9a

Please sign in to comment.