function clm_api_db_season_enable($id = -1) { $id = clm_core::$load->make_valid($id, 0, -1); // Nur Saisons mit einer gültigen ID und die geändert oder neu ist, kann aktiviert werden. if ($id != -1 && (clm_core::$db->saison->get($id)->isChange() || !clm_core::$db->saison->get($id)->isNew())) { // Aktiviere die gewählte Saison clm_core::$db->saison->get($id)->published = 1; clm_core::$db->saison->get($id)->archiv = 0; clm_core::$db->saison->write(); // Schreibe die Änderungen // Archive alle anderen die bisher aktiv waren $sql = "UPDATE #__clm_saison SET archiv=1 WHERE published=1 AND archiv=0 AND id!=" . $id; clm_core::$db->query($sql); if (clm_core::$db->saison->get($id)->isNew() && clm_core::$access->getId() != -1) { // Kopiere den aktuellen Benutzer in die neue Saison $user = clm_core::$db->user->get(clm_core::$access->getId()); $sql = "REPLACE INTO #__clm_user " . " (`sid`, `jid`, `name`, `username` ,`aktive` ,`email` ,`tel_fest` " . " ,`tel_mobil`, `usertype`, `zps`, `mglnr` " . " ,`mannschaft`, `published`, `bemerkungen`, `bem_int` ) " . ' VALUES ( ' . $id . ', ' . clm_core::$db->escape($user->jid) . ',"' . clm_core::$db->escape($user->name) . '", "' . clm_core::$db->escape($user->username) . '", 1, "' . clm_core::$db->escape($user->email) . '", "' . clm_core::$db->escape($user->tel_fest) . '" ' . ' ,"' . clm_core::$db->escape($user->tel_mobil) . '", "admin", "' . clm_core::$db->escape($user->zps) . '", "' . clm_core::$db->escape($user->mglnr) . '" ' . ' , 0, 1, "' . clm_core::$db->escape($user->bemerkungen) . '", "' . clm_core::$db->escape($user->bem_int) . '" )'; } else { $data = clm_core::$cms->getUserData(); // Aktualisiere einen alten Benutzer oder Erstelle einen neuen in der aktuellen Saison $sql = "REPLACE INTO #__clm_user " . " (`sid`, `jid`, `username`, `name`, `usertype`,`aktive`,`published`, `email`) " . ' VALUES ( ' . $id . ', ' . clm_core::$db->escape(clm_core::$access->getJid()) . ', "' . clm_core::$db->escape(clm_core::$access->getUsername()) . '", "' . clm_core::$db->escape(clm_core::$access->getName()) . '", "admin",1,1, "' . clm_core::$db->escape($data[3]) . '")'; } clm_core::$db->query($sql); clm_core::$access = new clm_class_access(); return array(true, "m_enableSeasonSuccess"); } else { return array(false, "e_noSeasonToEnable"); } }
function __construct($url, $path) { self::$url = $url; self::$path = $path; self::$load = $this; // CLM Klassen automatisch einbinden spl_autoload_register("clm_core::autoload"); self::$cms = clm_class_cms::init(); self::$id = new clm_class_id(); // Grundlegende Konfiguration require self::$path . "/includes/database.php"; require self::$path . "/includes/table.php"; require self::$path . "/includes/config.php"; self::$db = new clm_class_db($database, $table, $config); self::$lang = new clm_class_lang(); // Weitere Initialisierung nur bei abgeschlossener Installation if (!defined("clm_install")) { self::$access = new clm_class_access(); self::$api = new clm_class_api(); // Erzeugung von Beispieldaten nach Installation / Korrektur bei inkonsistenter Datenbank if (self::$access->getId() == -1 && self::$access->getType() == "admin") { if (self::$access->getSeason() == -1) { $lang = self::$lang->designation; self::$api->direct("db_season_save", array(-1, 1, 0, $lang->ExampleSeason, "", "", "0000-00-00 00:00:00")); } else { self::$api->direct("db_season_enable", array(self::$access->getSeason())); } } self::$cms->afterBoot(); // Log prinzipiell aktiv? if (clm_core::$db->config()->log) { self::$log = new clm_class_log(); set_error_handler('clm_core::errorHandler'); set_exception_handler('clm_core::exceptionHandler'); register_shutdown_function('clm_core::shutdown'); } } else { self::$api = new clm_class_api(); self::$api->check(false); // Rechtekontrolle deaktivieren } }
public function logout() { clm_core::$access = new clm_class_access(); return true; }
function clm_api_db_season_save($id = -1, $published = null, $archiv = null, $name = null, $bemerkungen = null, $bem_int = null, $datum = null) { $id = clm_core::$load->make_valid($id, 0, -1); // Eine bereits bestehende Saison wird bearbeitet if ($id != -1 && !clm_core::$db->saison->get($id)->isNew()) { if (is_null($published)) { $published = clm_core::$db->saison->get($id)->published; } if (is_null($archiv)) { $archiv = clm_core::$db->saison->get($id)->archiv; } if (is_null($name)) { $name = clm_core::$db->saison->get($id)->name; } if (is_null($bemerkungen)) { $bemerkungen = clm_core::$db->saison->get($id)->bemerkungen; } if (is_null($bem_int)) { $bem_int = clm_core::$db->saison->get($id)->bem_int; } if (is_null($datum)) { $datum = clm_core::$db->saison->get($id)->datum; } } $published = clm_core::$load->make_valid($published, 9, 0, array(0, 1)); $archiv = clm_core::$load->make_valid($archiv, 9, 0, array(0, 1)); $name = clm_core::$load->make_valid($name, 8, ""); $bemerkungen = clm_core::$load->make_valid($bemerkungen, 8, ""); $bem_int = clm_core::$load->make_valid($bem_int, 8, ""); $datum = clm_core::$load->make_valid($datum, 8, "0000-00-00 00:00:00"); $notice = "m_changeSeasonSuccess"; $enableSeason = false; if ($name == "") { return array(false, "e_needSeasonName", -1); } // Neue Saison erstellen falls übergebene ID ungültig oder nicht vorhanden if ($id == -1 || clm_core::$db->saison->get($id)->isNew()) { $id = clm_core::$db->saison->getMax() + 1; if ($published == 1 && $archiv == 0) { $enableSeason = true; } } else { $publishedOld = clm_core::$db->saison->get($id)->published; $archivOld = clm_core::$db->saison->get($id)->archiv; // Es gibt nur eine aktive Saison, diese kann nicht deaktiviert werden. if ($publishedOld == 1 && $archivOld == 0 && ($published == 0 || $archiv == 1)) { $published = 1; $archiv = 0; $notice = "e_lastSeason"; } // Die Season war vorher nicht aktiv und wird es nun if (($publishedOld == 0 || $archivOld == 1) && $published == 1 && $archiv == 0) { $enableSeason = true; } } clm_core::$db->saison->get($id)->name = $name; clm_core::$db->saison->get($id)->bemerkungen = $bemerkungen; clm_core::$db->saison->get($id)->bem_int = $bem_int; clm_core::$db->saison->get($id)->datum = $datum; if ($enableSeason) { $out = clm_core::$api->db_season_enable($id); $out[2] = $id; return $out; } else { clm_core::$db->saison->get($id)->published = $published; clm_core::$db->saison->get($id)->archiv = $archiv; clm_core::$db->saison->write(); // Erneuere die Rechteverwaltung clm_core::$access = new clm_class_access(); return array(true, $notice, $id); } }