public static function Delete($id) { global $db_connection; global $link_to_direction_images; global $link_to_logo; $direction = Direction::FetchByID($id); $langs = $direction->FetchLanguages(); $from_table = Direction::$table; if ($direction->language !== 'rus') { $from_table .= '_' . $direction->language; } if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { return 0; } else { if (count($langs) < 2) { $projs = Project::FetchByDirectionID($id, array('all')); if ($projs != NULL) { for ($i = 0, $size = count($projs); $i < $size; ++$i) { if (!$projs[$i]->DeleteThis()) { echo 'error while deleting projects on proj id: ' . $projs[$i]->id; return 0; } } } removeDirectory($link_to_direction_images . $id); } else { if ($direction->path_to_image !== $link_to_logo) { unlink($direction->path_to_image); } } return 1; } }
$direction = $directions[$i]; $content .= $direction->ToHTMLAutoShortForTable(GetUserPrivileges()); if ($i != $to) { $content .= '<hr><div style="background-color: #eeeeee;"><br></div><hr>'; } } } else { $content .= ToPageHeader(Language::Word('no directions'), 'h3', 'black'); } $header .= Language::PublicMenu('directions'); } else { if ($_GET['content_type'] == $content_types_short['projects']) { $directions = Direction::FetchAll(); $projects = array(); for ($i = 0, $size = count($directions); $i < $size; ++$i) { $tmp = Project::FetchByDirectionID($directions[$i]->id); if ($tmp !== NULL) { $projects = array_merge($projects, $tmp); } } $size = count($projects); if ($size) { require $link_to_pagination_init_template; for ($i = $from; $i <= $to; ++$i) { $project = $projects[$i]; if ($i === $from || $i > $from && $projects[$i - 1]->direction_id != $project->direction_id) { if ($i != $from) { $content .= '<hr>'; } $content .= '<div align="left" style="padding: 15px; background-color: #eeeeee;">'; $content .= Language::Word('direction') . ': ' . Direction::FetchByID($project->direction_id)->LinkToThis();
$footer = ''; $header_type = 'h4'; if ($direction === NULL) { $title = Language::Word('error'); $header = $title; $content = Language::Word('internal server error'); } else { if ($direction === Error::no_translation) { $title = Language::Word('error'); $header = Language::Word('sorry'); $content = Language::Word('no translation for this direction'); } else { $title = $direction->name; $header = htmlspecialchars($direction->name); $content .= '<div class="row"><div class="' . ColAllTypes(12) . '">' . $direction->text_block . '</div></div>'; $projects = Project::FetchByDirectionID($direction->id); $size = count($projects); if ($size > 0) { $content .= '<hr><div class="row" align="center">' . ToPageHeader(Language::Word('linked projects'), 'h4', 'grey') . '</div><hr>'; require $link_to_pagination_init_template; for ($i = $from; $i <= $to; ++$i) { $content .= $projects[$i]->ToHTMLAutoShortForTable(GetUserPrivileges()); if ($i != $to) { $content .= '<hr>'; } } require $link_to_pagination_show_template; } $no_content_center = true; } }