Skip to content
Permalink
Browse files

prevent setting conflicting attributes; updates #1147

  • Loading branch information...
following5 committed Oct 8, 2017
1 parent 12d858d commit 2587a39a37addedfe0c92a954991c57028bf9642
@@ -1413,6 +1413,15 @@ function dbv_167()
sql("DELETE FROM `sys_cron` WHERE `name` = 'okapi_cleanup'");
}
function dbv_168()
{
sql(
"CREATE TABLE IF NOT EXISTS `cache_attrib_conflicts` (
`attrib1_id` int(10) NOT NULL,
`attrib2_id` int(10) NOT NULL
) ENGINE=MyISAM"
);
}
// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.
@@ -18,7 +18,7 @@
echo "applying sql deltas\n";
require __DIR__ . '/dbsv-update.php';
echo "importing static-data/data.sql\n";
echo "importing static data\n";
system(
'cat ' . $rootpath . '../sql/static-data/*.sql |' .
' mysql -h' . $opt['db']['servername'] . ' -u' . $opt['db']['username'] . ' --password=' . $opt['db']['password'] . ' ' . $opt['db']['placeholder']['db']
@@ -796,6 +796,11 @@ function getWaypoints($cacheId)
}
$line = mb_ereg_replace('{img_undef}', $record['icon_undef'], $line);
$line = mb_ereg_replace('{img_large}', $record['icon_large'], $line);
$line = mb_ereg_replace(
'{conflicting_attribs}',
implode(',', attribute::getConflictingAttribIds($record['id'])),
$line
);
if ($cache_attrib_array != '') {
$cache_attrib_array .= ',';
}
@@ -49,7 +49,7 @@
$waypointline = '<tr bgcolor="#ffffff"><td><table class="narrowtable" cellspacing="0" cellpadding="0"><tr><td><img src="{wp_image}" /></td><td>{wp_type}</td></tr></table></td><td><table class="narrowtable"><tr><td style="white-space:nowrap">{wp_coordinate}</td></tr></table></tp><td>{wp_show_description}</td><td>[<a href="childwp.php?cacheid={cacheid}&childid={childid}" onclick="testListingModified(this)">' . t('Edit') . '</a>] [<a href="childwp.php?cacheid={cacheid}&deleteid={childid}" onclick="testListingModified(this)">' . t('Delete') . '</a>]</td></tr>';
$waypointlines = '<tr><td colspan="2"><table class="edit_wptable">{lines}</table></td></tr><tr><td colspan="2">&nbsp;</td></tr>';
$cache_attrib_js = "new Array({id}, {selected}, '{img_undef}', '{img_large}')";
$cache_attrib_js = "[{id}, {selected}, '{img_undef}', '{img_large}', [{conflicting_attribs}]]";
$cache_attrib_pic = '<img id="attr{attrib_id}" src="{attrib_pic}" border="0" onmousedown="toggleAttr({attrib_id})" onmouseover="Tip(\'{html_desc}\', TITLE, \'{name}\', TITLEBGCOLOR, \'{color}\', TITLEFONTCOLOR, \'#000000\', BGCOLOR, \'#FFFFFF\', BORDERCOLOR, \'{color}\', CLICKCLOSE, true, DELAY, 0, FADEIN, false, FADEOUT, false, FONTCOLOR, \'#000080\', WIDTH, 500)" onmouseout="UnTip()" />&nbsp;';
$cache_attrib_group =
@@ -104,8 +104,15 @@ function toggleAttr(id)
{
if (maAttributes[i][0] == id)
{
if (maAttributes[i][1] == 0)
if (maAttributes[i][1] == 0) {
maAttributes[i][1] = 1;
for (a = 0; a < maAttributes[i][4].length; a++)
for (n = 0; n < maAttributes.length; n++)
if (maAttributes[n][0] == maAttributes[i][4][a]) {
maAttributes[n][1] = 0;
break;
}
}
else
maAttributes[i][1] = 0;
@@ -45,7 +45,7 @@
$sel_message = t('Select');
$cache_attrib_js = "new Array({id}, {selected}, '{img_undef}', '{img_large}')";
$cache_attrib_js = "[{id}, {selected}, '{img_undef}', '{img_large}', [{conflicting_attribs}]]";
$cache_attrib_pic = '<img id="attr{attrib_id}" src="{attrib_pic}" border="0" onmousedown="toggleAttr({attrib_id})" onmouseover="Tip(\'{html_desc}\', TITLE, \'{name}\', TITLEBGCOLOR, \'{color}\', TITLEFONTCOLOR, \'#000000\', BGCOLOR, \'#FFFFFF\', BORDERCOLOR, \'{color}\', CLICKCLOSE, true, DELAY, 0, FADEIN, false, FADEOUT, false, FONTCOLOR, \'#000080\', WIDTH, 500)" onmouseout="UnTip()" />&nbsp;';
$cache_attrib_group =
@@ -99,8 +99,15 @@ function toggleAttr(id)
{
if (maAttributes[i][0] == id)
{
if (maAttributes[i][1] == 0)
if (maAttributes[i][1] == 0) {
maAttributes[i][1] = 1;
for (a = 0; a < maAttributes[i][4].length; a++)
for (n = 0; n < maAttributes.length; n++)
if (maAttributes[n][0] == maAttributes[i][4][a]) {
maAttributes[n][1] = 0;
break;
}
}
else
maAttributes[i][1] = 0;
@@ -143,4 +143,24 @@ public static function getAttributesListArrayInternal($cacheId, $bOnlySelectable
return $attributes;
}
/**
* @param $attribId
* @return array
*/
public static function getConflictingAttribIds($attribId)
{
static $conflicts = [];
if (!$conflicts) {
$rs = sql('SELECT `attrib1_id`, `attrib2_id` FROM `cache_attrib_conflicts`');
while ($r = sql_fetch_array($rs)) {
$conflicts[$r[0]][] = $r[1];
$conflicts[$r[1]][] = $r[0];
}
sql_free_result($rs);
}
return isset($conflicts[$attribId]) ? $conflicts[$attribId] : [];
}
}
@@ -589,6 +589,11 @@
}
$line = mb_ereg_replace('{img_undef}', $record['icon_undef'], $line);
$line = mb_ereg_replace('{img_large}', $record['icon_large'], $line);
$line = mb_ereg_replace(
'{conflicting_attribs}',
implode(',', attribute::getConflictingAttribIds($record['id'])),
$line
);
if ($cache_attrib_array != '') {
$cache_attrib_array .= ',';
}
@@ -0,0 +1,16 @@
-- Table cache_attrib_conflicts
SET NAMES 'utf8';
TRUNCATE TABLE `cache_attrib_conflicts`;
INSERT INTO `cache_attrib_conflicts` VALUES
(1, 38),
(1, 40),
(24, 25),
(24, 27),
(24, 29),
(24, 50),
(24, 51),
(24, 52),
(38, 39),
(38, 40),
(42, 43),
(42, 60);

0 comments on commit 2587a39

Please sign in to comment.
You can’t perform that action at this time.