- Patch #19965 by Robin Monks: fixed problem with duplicate block titles.
parent
bbb746b814
commit
f33f9a5fcd
|
@ -154,7 +154,6 @@ CREATE TABLE boxes (
|
|||
info varchar(128) NOT NULL default '',
|
||||
format int(4) NOT NULL default '0',
|
||||
PRIMARY KEY (bid),
|
||||
UNIQUE KEY title (title),
|
||||
UNIQUE KEY info (info)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ CREATE TABLE boxes (
|
|||
info varchar(128) NOT NULL default '',
|
||||
format smallint NOT NULL default '0',
|
||||
PRIMARY KEY (bid),
|
||||
UNIQUE (info),
|
||||
UNIQUE (title)
|
||||
UNIQUE (info)
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -106,7 +106,8 @@ $sql_updates = array(
|
|||
"2005-03-18" => "update_127",
|
||||
"2005-03-21" => "update_128",
|
||||
"2005-04-08: first update since Drupal 4.6.0 release" => "update_129",
|
||||
"2005-04-10" => "update_130"
|
||||
"2005-04-10" => "update_130",
|
||||
"2005-04-11" => "update_131"
|
||||
);
|
||||
|
||||
function update_32() {
|
||||
|
@ -2376,4 +2377,18 @@ function update_130() {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function update_131() {
|
||||
$ret = array();
|
||||
|
||||
if ($GLOBALS['db_type'] == 'mysql') {
|
||||
$ret[] = update_sql("ALTER TABLE {boxes} DROP INDEX title");
|
||||
$ret[] = update_sql("ALTER TABLE {boxes} ADD INDEX title (title)");
|
||||
}
|
||||
elseif ($GLOBALS['db_type'] == 'pgsql') {
|
||||
$ret[] = update_sql("DROP INDEX boxes_title_idx");;
|
||||
$ret[] = update_sql("CREATE INDEX title ON {boxes} (title)");
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -312,12 +312,13 @@ function block_box_add() {
|
|||
|
||||
switch ($op) {
|
||||
case t('Save block'):
|
||||
block_box_save($edit);
|
||||
drupal_set_message(t('The new block has been added.'));
|
||||
drupal_goto('admin/block');
|
||||
|
||||
if (block_box_save($edit)) {
|
||||
drupal_set_message(t('The new block has been added.'));
|
||||
drupal_goto('admin/block');
|
||||
}
|
||||
// deliberate no break
|
||||
default:
|
||||
$form = block_box_form();
|
||||
$form = block_box_form($edit);
|
||||
$form .= form_submit(t('Save block'));
|
||||
$output .= form($form);
|
||||
}
|
||||
|
@ -368,8 +369,13 @@ function block_box_save($edit, $delta = NULL) {
|
|||
db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['title'], $edit['body'], $edit['info'], $edit['format'], $delta);
|
||||
}
|
||||
else {
|
||||
if (empty($edit['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $edit['info']))) {
|
||||
form_set_error('title', t('Please ensure each block description is unique.'));
|
||||
return false;
|
||||
}
|
||||
db_query("INSERT INTO {boxes} (title, body, info, format) VALUES ('%s', '%s', '%s', %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -312,12 +312,13 @@ function block_box_add() {
|
|||
|
||||
switch ($op) {
|
||||
case t('Save block'):
|
||||
block_box_save($edit);
|
||||
drupal_set_message(t('The new block has been added.'));
|
||||
drupal_goto('admin/block');
|
||||
|
||||
if (block_box_save($edit)) {
|
||||
drupal_set_message(t('The new block has been added.'));
|
||||
drupal_goto('admin/block');
|
||||
}
|
||||
// deliberate no break
|
||||
default:
|
||||
$form = block_box_form();
|
||||
$form = block_box_form($edit);
|
||||
$form .= form_submit(t('Save block'));
|
||||
$output .= form($form);
|
||||
}
|
||||
|
@ -368,8 +369,13 @@ function block_box_save($edit, $delta = NULL) {
|
|||
db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['title'], $edit['body'], $edit['info'], $edit['format'], $delta);
|
||||
}
|
||||
else {
|
||||
if (empty($edit['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $edit['info']))) {
|
||||
form_set_error('title', t('Please ensure each block description is unique.'));
|
||||
return false;
|
||||
}
|
||||
db_query("INSERT INTO {boxes} (title, body, info, format) VALUES ('%s', '%s', '%s', %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue