Check if the tab is already inserted - refs #7173

1.9.x
Francis Gonzales 11 years ago
parent be7459d7bd
commit 5b88eabe83
  1. 26
      main/inc/lib/plugin.class.php

@ -481,11 +481,10 @@ class Plugin
public function addTab($tabName, $url)
{
$sql = "SELECT * FROM settings_current
WHERE
variable = 'show_tabs' AND
subkey like 'custom_tab_%'";
WHERE
variable = 'show_tabs' AND
subkey like 'custom_tab_%'";
$result = Database::query($sql);
$customTabsNum = Database::num_rows($result);
$tabNum = $customTabsNum + 1;
@ -493,6 +492,22 @@ class Plugin
//Avoid Tab Name Spaces
$tabNameNoSpaces = preg_replace('/\s+/', '', $tabName);
$subkeytext = "Tabs" . $tabNameNoSpaces;
//Check if it is already added
$checkCondition = array(
'where' =>
array(
"variable = 'show_tabs' AND subkeytext = ?" => array(
$subkeytext
)
)
);
$checkDuplicate = Database::select('*', 'settings_current', $checkCondition);
if (!empty($checkDuplicate)) {
return false;
}
//End Check
$subkey = 'custom_tab_' . $tabNum;
$attributes = array(
'variable' => 'show_tabs',
@ -517,7 +532,6 @@ class Plugin
$whereCondition = array(
'id = ?' => key($settings)
);
Database::update('settings_current', $setData, $whereCondition);
return $resp;
@ -526,6 +540,8 @@ class Plugin
/**
* Delete a tab to chamilo's platform
* @param string $key
*
* @return boolean $resp
*/
public function deleteTab($key)
{

Loading…
Cancel
Save