| @@ 1120-1138 (lines=19) @@ | ||
| 1117 | // add template assignments |
|
| 1118 | $assignments = explode(',', $assignments); |
|
| 1119 | ||
| 1120 | if (count($assignments) > 0) { |
|
| 1121 | ||
| 1122 | // remove existing tv -> template assignments |
|
| 1123 | $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 1124 | $row = mysqli_fetch_assoc($ds); |
|
| 1125 | $id = $row["id"]; |
|
| 1126 | mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
| 1127 | ||
| 1128 | // add tv -> template assignments |
|
| 1129 | foreach ($assignments as $assignment) { |
|
| 1130 | $template = mysqli_real_escape_string($conn, $assignment); |
|
| 1131 | $ts = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$template';"); |
|
| 1132 | if ($ds && $ts) { |
|
| 1133 | $tRow = mysqli_fetch_assoc($ts); |
|
| 1134 | $templateId = $tRow['id']; |
|
| 1135 | mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 1136 | } |
|
| 1137 | } |
|
| 1138 | } |
|
| 1139 | } |
|
| 1140 | } |
|
| 1141 | } |
|
| @@ 411-429 (lines=19) @@ | ||
| 408 | // add template assignments |
|
| 409 | $assignments = explode(',', $assignments); |
|
| 410 | ||
| 411 | if (count($assignments) > 0) { |
|
| 412 | ||
| 413 | // remove existing tv -> template assignments |
|
| 414 | $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 415 | $row = mysqli_fetch_assoc($ds); |
|
| 416 | $id = $row["id"]; |
|
| 417 | mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
| 418 | ||
| 419 | // add tv -> template assignments |
|
| 420 | foreach ($assignments as $assignment) { |
|
| 421 | $template = mysqli_real_escape_string($conn, $assignment); |
|
| 422 | $ts = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$template';"); |
|
| 423 | if ($ds && $ts) { |
|
| 424 | $tRow = mysqli_fetch_assoc($ts); |
|
| 425 | $templateId = $tRow['id']; |
|
| 426 | mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 427 | } |
|
| 428 | } |
|
| 429 | } |
|
| 430 | } |
|
| 431 | } |
|
| 432 | } |
|