From a8fc30016cda3f18b1672d4744a9c0bfc998e11a Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 4 May 2013 19:59:54 -0700 Subject: [PATCH] Issue #235 - Database Utility fixes. --- e107_admin/db.php | 268 +++++++++++++++++--------- e107_admin/e107_update.php | 189 ------------------ e107_admin/header.php | 2 +- e107_admin/update_routines.php | 193 +++++++++++++++++++ e107_handlers/db_verify_class.php | 4 +- e107_handlers/e107_class.php | 14 +- e107_handlers/form_handler.php | 5 +- e107_themes/bootstrap/admin_style.css | 4 + e107_web/js/core/admin.jquery.js | 9 +- 9 files changed, 394 insertions(+), 294 deletions(-) diff --git a/e107_admin/db.php b/e107_admin/db.php index 6ae2f1ba8..81eaa9344 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -52,11 +52,7 @@ if(isset($_POST['db_execute'])) } } -if(isset($_POST['db_update']) || varset($_GET['mode'])=='db_update') -{ - header("location: ".e_ADMIN."e107_update.php"); - exit(); -} + @@ -117,11 +113,11 @@ class system_tools 'plugin_scan' => array('diz'=>DBLAN_28, 'label'=> DBLAN_29), 'pref_editor' => array('diz'=>DBLAN_19, 'label'=> DBLAN_20), // 'backup_core' => array('diz'=>DBLAN_8, 'label'=> DBLAN_9), - 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36), + // 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36), 'importForm' => array('diz'=>DBLAN_59, 'label'=> DBLAN_59), 'exportForm' => array('diz'=>DBLAN_58, 'label'=> DBLAN_58), 'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56), - 'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8'), + 'convert_to_utf8' => array('diz'=>'Check Database Charset','label'=>'Check Charset'), 'correct_perms' => array('diz'=>'Correct File and Directory permissions','label'=>'Correct Perms') ); @@ -151,18 +147,25 @@ class system_tools return; } - if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) - { + // if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) + // { //$this->verify_sql_record(); // - currently performed in db_verify_class.php - } + // } if(isset($_POST['importForm']) || $_GET['mode']=='importForm') { $this->importForm(); } - - + + if(isset($_POST['db_update']) || varset($_GET['mode'])=='db_update') // Requires further testing. + { + // header("location: ".e_ADMIN."e107_update.php"); + require_once(e_ADMIN."update_routines.php"); + new e107Update($dbupdate); + return; + } + if(isset($_POST['convert_to_utf8']) || $_GET['mode']=='convert_to_utf8') { $this->convertUTF8Form(); @@ -243,117 +246,188 @@ class system_tools private function convertUTF8Form() { - $mes = e107::getMessage(); - $frm = e107::getForm(); - //TODO a function to call the e107_config information in e107_class.php. - require(e_BASE."e107_config.php"); - $dbtable = $mySQLdefaultdb; + $mes = e107::getMessage(); + $frm = e107::getForm(); + $config = e107::getMySQLConfig(); + $sql = e107::getDb(); + + $sql->gen('SHOW TABLE STATUS WHERE Name LIKE "'.$config['mySQLprefix'].'%" '); + + + $text = " + + + + + + + + + + + + + + + + "; + + + + $invalidCollations = false; + while($row = $sql->fetch()) + { + $text .= " + + + + + "; + // print_a($row); + + if($row['Collation'] != 'utf8_general_ci') + { + $invalidCollations = true; + } - //TODO LAN - $message = ' - This function will permanently modify all tables in your database. ('.$mySQLdefaultdb.')
- It is HIGHLY recommended that you backup your database first.
- If possible use a copy of your database.
- Do not forget to purge unnecessary input - e.g. old chatbox messages, pm, …
- as well as to set the maintenance flag to main admins only.
-
- Be sure to click the “Convert Database” button only once.
- The conversion process can take up to one minute or much much more depending on the size of your database.
-
- Known problems (list non-exhaustive): - - '; + } + + $text .= "
TableEngineCollationStatus
".$row['Name']."".$row['Engine']."".$row['Collation']."".(($row['Collation'] == 'utf8_general_ci') ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON)."
"; - $mes->add($message, E_MESSAGE_WARNING); - $text = " -
-
- "."Convert Database"." -
- ".$frm->admin_button('perform_utf8_convert', "Convert Database")." -
-
-
"; + if($invalidCollations == true) + { + //TODO LAN + $message = ' + This function will permanently modify all tables in your database. ('.$config['mySQLdefaultdb'].')
+ It is HIGHLY recommended that you first backup your database and switch your site into maintenance mode. +
+
+ Please note: + + '; + + $mes->add($message, E_MESSAGE_WARNING); + + $text .= " +
+
+ "."Convert Database"." +
+ ".$frm->admin_button('perform_utf8_convert', "Convert non-UTF8 Tables",false,"Convert non-UTF8 Tables",'class=btn-success&data-loading-text=Please wait...')." +
+
+
"; + + } + else + { + $mes->addSuccess("Your tables are using the correct character set."); + } - e107::getRender()->tablerender(DBLAN_10.SEP."Convert Database to UTF-8", $mes->render().$text); + + e107::getRender()->tablerender(DBLAN_10.SEP."Check Charset".SEP.$config['mySQLdefaultdb'], $mes->render().$text); } private function perform_utf8_convert() { - require(e_BASE."e107_config.php"); - - $dbtable = $mySQLdefaultdb; + $config = e107::getMySQLConfig(); + $dbtable = $config['mySQLdefaultdb']; //TODO Add a check to be sure the database is not already utf-8. // yep, needs more methods - possibly a class in e107_handler - $sql = e107::getDb(); + $sql = e107::getDb('utf8-convert'); $mes = e107::getMessage(); $ERROR = FALSE; - if(!mysql_query("USE information_schema;")) - { - $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR); - return; - } - + // if(!$sql->gen("USE information_schema;")) + // { + // $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR); + // return; + // } + + $queries = array(); - $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';"); - $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';"); + $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';"); + $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';"); $queries2 = array(); - $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';"); - $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';"); + $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA ='".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';"); + $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';"); - mysql_query("USE ".$dbtable); + // $sql->gen("USE ".$dbtable); + + + // print_a($queries2); + // echo $mes->render(); + // return; + + // Convert Text tables to Binary. foreach($queries as $qry) { + foreach($qry as $q) { if(!$sql->db_Query($q)) { - $mes->add($q, E_MESSAGE_ERROR); + $mes->addError($q); $ERROR = TRUE; } + else + { + $mes->addDebug($q); + } } } //------------ - $result = mysql_list_tables($dbtable); - while ($row = mysql_fetch_array($result, MYSQL_NUM)) + // Convert Table Fields to utf8 + $sql2 = e107::getDb('sql2'); + + $sql->gen('SHOW TABLE STATUS WHERE Collation != "utf8_general_ci" '); + while ($row = $sql->fetch()) { - $table = $row[0]; - $tab_query = "ALTER TABLE ".$table." charset=utf8; "; - if(!$sql->db_Query($tab_query)) + $table = $row['Name']; + $tab_query = "ALTER TABLE ".$table." DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; "; + + //echo "TABQRT= ".$tab_query; + + if(!$sql2->db_Query($tab_query)) { - $mes->add($tab_query, E_MESSAGE_ERROR); + $mes->addError($tab_query); $ERROR = TRUE; } + else + { + $mes->addDebug($tab_query); + } } // --------------- - + // Convert Table Fields back to Text/varchar etc. foreach($queries2 as $qry) { foreach($qry as $q) { if(!$sql->db_Query($q)) { - $mes->add($q, E_MESSAGE_ERROR); + $mes->addError($q); $ERROR = TRUE; } + else + { + $mes->addDebug($q); + } } } @@ -367,22 +441,40 @@ class system_tools } elseif($ERROR != TRUE) { - $message = "Database Converted successfully to UTF-8.
- Please now add the following line to your e107_config.php file:
- \$mySQLcharset = 'utf8'; - "; + $message = "Database Converted successfully to UTF-8. "; + //$message .= "
Please now add the following line to your e107_config.php file:
\$mySQLcharset = 'utf8';"; $mes->add($message, E_MESSAGE_SUCCESS); } - + echo $mes->render(); } function getQueries($query) { + + $mes = e107::getMessage(); + $sql = e107::getDb('utf8-convert'); + + if($sql->gen($query)) + { + while ($row = $sql->fetch(MYSQL_NUM)) + { + $qry[] = $row[0]; + } + } + else + { + $mes->addError($query); + } + + return $qry; + + + /* if(!$result = mysql_query($query)) { - $mes->add("Query Failed", E_MESSAGE_ERROR); + $mes->addError("Query Failed: ".$query); return; } while ($row = mysql_fetch_array($result, MYSQL_NUM)) @@ -391,6 +483,7 @@ class system_tools } return $qry; + * */ } @@ -485,18 +578,7 @@ class system_tools ".ADMIN_EXECUTE_ICON."

".$val['label']."

".$val['diz']." "; - /* - $text .= " - ".$val['diz']." - - ".ADMIN_EXECUTE_ICON." - ". - // $frm->submit_image('db_execute['.$key.']', '1', 'execute', $val['label']). - // $frm->radio('db_execute', $key).$frm->label($val['label'], 'db_execute', $key). - " - - \n"; - */ + } /* $text .= " @@ -702,7 +784,7 @@ class system_tools * Optimize SQL * @return none */ - private function optimizesql($mySQLdefaultdb) + private function optimizesql($mySQLdefaultdb) //FIXME Use mysql class. { // global $mes; $result = mysql_list_tables($mySQLdefaultdb); @@ -1118,7 +1200,7 @@ function backup_core() */ - +/* function verify_sql_record() // deprecated by db_verify.php ( i think). { global $e107; @@ -1531,6 +1613,6 @@ function verify_sql_record() // deprecated by db_verify.php ( i think). $ns->tablerender(DBLAN_10.SEP.DBLAN_50, $mes->render().$text); } } - +*/ ?> \ No newline at end of file diff --git a/e107_admin/e107_update.php b/e107_admin/e107_update.php index c230055d0..b7202832e 100644 --- a/e107_admin/e107_update.php +++ b/e107_admin/e107_update.php @@ -158,195 +158,6 @@ function show_updates($dbupdate, $what) */ -// New in v2.x ------------------------------------------------ - -class e107Update -{ - var $core = array(); - var $updates = 0; - var $disabled = 0; - - - function __construct($core=null) - { - $mes = e107::getMessage(); - - $this->core = $core; - - if(varset($_POST['update_core']) && is_array($_POST['update_core'])) - { - $func = key($_POST['update_core']); - $message = $this->updateCore(); - } - - if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates - { - $func = key($_POST['update']); - $this->updatePlugin($func); - } - - if(vartrue($message)) - { - $mes->addSuccess($message); - } - - $this->renderForm(); - } - - - - - function updateCore($func='') - { - $mes = e107::getMessage(); - - // foreach($this->core as $func => $data) - // { - if(function_exists('update_'.$func)) // Legacy Method. - { - $installed = call_user_func("update_".$func); - //?! (LAN_UPDATE == $_POST[$func]) - if(varsettrue($_POST['update_core'][$func]) && !$installed) - { - if(function_exists("update_".$func)) - { - $message = LAN_UPDATE_7." ".$data['title']; - $error = call_user_func("update_".$func, "do"); - - if($error != '') - { - $mes->add($message, E_MESSAGE_ERROR); - $mes->add($error, E_MESSAGE_ERROR); - } - else - { - $mes->add($message, E_MESSAGE_SUCCESS); - } - } - } - } - - //} - - } - - - - function updatePlugin($path) - { - e107::getPlugin()->install_plugin_xml($path, 'upgrade'); - } - - - - function plugins() - { - if(!$list = e107::getPlugin()->updateRequired()) - { - return; - } - - $frm = e107::getForm(); - - $text = ""; - foreach($list as $path=>$val) - { - $text .= " - ".$val['@attributes']['name']." - ".$frm->admin_button('update['.$path.']', LAN_UPDATE, 'warning', '', 'disabled='.$this->disabled)." - "; - } - - return $text; - } - - - - - function core() - { - $frm = e107::getForm(); - $mes = e107::getMessage(); - - $text = ""; - - foreach($this->core as $func => $data) - { - if(function_exists("update_".$func)) - { - $text .= "".$data['title'].""; - - - - if(call_user_func("update_".$func)) - { - $text .= "".ADMIN_TRUE_ICON.""; - } - else - { - if(vartrue($data['message'])) - { - $mes->addInfo($data['message']); - } - - $this->updates ++; - - $text .= "".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}&disabled=".$this->disabled).""; - if($data['master'] == true) - { - $this->disabled = 1; - } - } - $text .= "\n"; - } - } - - return $text; - } - - - - function renderForm() - { - $ns = e107::getRender(); - $mes = e107::getMessage(); - - $caption = LAN_UPDATE; - $text = " -
-
- {$caption} - - - - - - - - - - - - - "; - - $text .= $this->core(); - $text .= $this->plugins(); - - $text .= " - -
".LAN_UPDATE_55."".LAN_UPDATE_2."
-
-
- "; - - - $ns->tablerender("Updates",$mes->render() . $text); - - } - - -} new e107Update($dbupdate); diff --git a/e107_admin/header.php b/e107_admin/header.php index b0e0ce303..3ae3c8e98 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -468,7 +468,7 @@ echo getAlert(); } -function getAlert($caption) +function getAlert($caption='') { return '
diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 1d2c5b335..b3be3d73e 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -135,6 +135,199 @@ if (!$dont_check_update) +// New in v2.x ------------------------------------------------ + +class e107Update +{ + var $core = array(); + var $updates = 0; + var $disabled = 0; + + + function __construct($core=null) + { + $mes = e107::getMessage(); + + $this->core = $core; + + if(varset($_POST['update_core']) && is_array($_POST['update_core'])) + { + $func = key($_POST['update_core']); + $message = $this->updateCore($func); + } + + if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates + { + $func = key($_POST['update']); + $this->updatePlugin($func); + } + + if(vartrue($message)) + { + $mes->addSuccess($message); + } + + $this->renderForm(); + } + + + + + function updateCore($func='') + { + $mes = e107::getMessage(); + + // foreach($this->core as $func => $data) + // { + if(function_exists('update_'.$func)) // Legacy Method. + { + $installed = call_user_func("update_".$func); + //?! (LAN_UPDATE == $_POST[$func]) + if(varsettrue($_POST['update_core'][$func]) && !$installed) + { + if(function_exists("update_".$func)) + { + $message = LAN_UPDATE_7." ".$data['title']; + $error = call_user_func("update_".$func, "do"); + + if($error != '') + { + $mes->add($message, E_MESSAGE_ERROR); + $mes->add($error, E_MESSAGE_ERROR); + } + else + { + $mes->add($message, E_MESSAGE_SUCCESS); + } + } + } + } + else + { + $mes->addDebug("could run 'update_".$func); + } + + //} + + } + + + + function updatePlugin($path) + { + e107::getPlugin()->install_plugin_xml($path, 'upgrade'); + } + + + + function plugins() + { + if(!$list = e107::getPlugin()->updateRequired()) + { + return; + } + + $frm = e107::getForm(); + + $text = ""; + foreach($list as $path=>$val) + { + $text .= " + ".$val['@attributes']['name']." + ".$frm->admin_button('update['.$path.']', LAN_UPDATE, 'warning', '', 'disabled='.$this->disabled)." + "; + } + + return $text; + } + + + + + function core() + { + $frm = e107::getForm(); + $mes = e107::getMessage(); + + $text = ""; + + foreach($this->core as $func => $data) + { + if(function_exists("update_".$func)) + { + $text .= "".$data['title'].""; + + + + if(call_user_func("update_".$func)) + { + $text .= "".ADMIN_TRUE_ICON.""; + } + else + { + if(vartrue($data['message'])) + { + $mes->addInfo($data['message']); + } + + $this->updates ++; + + $text .= "".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}&disabled=".$this->disabled).""; + if($data['master'] == true) + { + $this->disabled = 1; + } + } + $text .= "\n"; + } + } + + return $text; + } + + + + function renderForm() + { + $ns = e107::getRender(); + $mes = e107::getMessage(); + + $caption = LAN_UPDATE; + $text = " +
+
+ {$caption} + + + + + + + + + + + + + "; + + $text .= $this->core(); + $text .= $this->plugins(); + + $text .= " + +
".LAN_UPDATE_55."".LAN_UPDATE_2."
+
+
+ "; + + + $ns->tablerender("Updates",$mes->render() . $text); + + } + + +} /** * Master routine to call to check for updates diff --git a/e107_handlers/db_verify_class.php b/e107_handlers/db_verify_class.php index ae90cede9..3a4ebdffd 100644 --- a/e107_handlers/db_verify_class.php +++ b/e107_handlers/db_verify_class.php @@ -924,7 +924,7 @@ class db_verify - ".$frm->checkbox_toggle('check-all-verify', 'verify_table').LAN_CHECKALL.' | '.LAN_UNCHECKALL." + ".$frm->checkbox_toggle('check-all-verify', 'verify_table',false,LAN_CHECKALL.' | '.LAN_UNCHECKALL)." @@ -934,7 +934,7 @@ class db_verify { $text .= " - ".$frm->checkbox('verify_table[]', $x).$frm->label($x, "verify_table".$x, $x)." + ".$frm->checkbox('verify_table[]', $x,false,'label='.$x)." "; } diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index b58e52711..ea28a9131 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -596,16 +596,20 @@ class e107 * Replaces all $mySQL(*) globals * Example: $e107->getMySQLConfig('prefix'); * - * @param string $for prefix|server|user|password|defaultdb - * @return string + * @param string $for prefix|server|user|password|defaultdb - leave blank for full array. + * @return string or array */ - function getMySQLConfig($for) + function getMySQLConfig($for='') { $key = 'mySQL'.$for; $self = self::getInstance(); - return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : ''); - // return (isset($this->e107_config_mysql_info[$key]) ? $this->e107_config_mysql_info[$key] : ''); + if($for == '') + { + return $self->e107_config_mysql_info; + } + + return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : ''); } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index d8e31931d..d25e813a2 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -967,11 +967,12 @@ class e_form return $this->checkbox($name, $value, $checked).$this->label($label ? $label : LAN_ENABLED, $name, $value); } - function checkbox_toggle($name, $selector = 'multitoggle', $id = false) + function checkbox_toggle($name, $selector = 'multitoggle', $id = false, $label='') { $selector = 'jstarget:'.$selector; if($id) $id = $this->name2id($id); - return $this->checkbox($name, $selector, false, array('id' => $id,'class' => 'checkbox toggle-all')); + + return $this->checkbox($name, $selector, false, array('id' => $id,'class' => 'checkbox toggle-all','label'=>$label)); } function uc_checkbox($name, $current_value, $uc_options, $field_options = array()) diff --git a/e107_themes/bootstrap/admin_style.css b/e107_themes/bootstrap/admin_style.css index d9e5dd9db..c515fcebf 100644 --- a/e107_themes/bootstrap/admin_style.css +++ b/e107_themes/bootstrap/admin_style.css @@ -397,9 +397,13 @@ i.s-message-debug { background-position: -1480px 0; width: 32px; height: 32px; } tr.e-sort { box-shadow: 0 5px 8px #cccccc; -webkit-box-shadow: 0 5px 8px #cccccc; -moz-box-shadow: 0 5px 8px #cccccc;} +th label.checkbox { min-height:inherit; } /* Bootstrap Fix but doesn't work */ /* ****************************** ICONS ************************************* */ + + + i.S16 { background: url(images/adminicons_16.png) no-repeat top left; display:inline-block; diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index d135dede3..ac3393f5c 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -123,8 +123,13 @@ $(document).ready(function() $('button[data-loading-text],a[data-loading-text]').on('click', function() { - var caption = $(this).attr('data-loading-text'); - $(this).attr('disabled', 'disabled').html(caption); + var caption = $(this).attr('data-loading-text'); + $(this).removeClass('btn-success'); + $(this).html(caption); + if($(this).attr('data-disable') == 'true') + { + $(this).attr('disabled', 'disabled'); + } return true; } );