public function copy($eventId, $templateName) { if (isset($eventId) && !empty($templateName)) { // Get event infos $params = array(); $params['recursive'] = 1; $params['contain']['EventsRole'] = array(); $params['conditions']['id'] = $eventId; if ($event = $this->find('first', $params)) { $toSave = array(); $toSave['EventsTemplate']['title'] = $templateName; $toSave['EventsTemplate']['event_title'] = $event['Event']['title']; $toSave['EventsTemplate']['event_description'] = $event['Event']['description']; $toSave['EventsTemplate']['game_id'] = $event['Event']['game_id']; $toSave['EventsTemplate']['dungeon_id'] = $event['Event']['dungeon_id']; $toSave['EventsTemplate']['time_invitation'] = $event['Event']['time_invitation']; $toSave['EventsTemplate']['time_start'] = $event['Event']['time_start']; $toSave['EventsTemplate']['character_level'] = $event['Event']['character_level']; $toSave['EventsTemplate']['open'] = $event['Event']['open']; if (!empty($event['EventsRole'])) { foreach ($event['EventsRole'] as $key => $eventRole) { $toSave['EventsTemplatesRole'][$key]['raids_role_id'] = $eventRole['raids_role_id']; $toSave['EventsTemplatesRole'][$key]['count'] = $eventRole['count']; } } App::uses('EventsTemplate', 'Model'); $EventsTemplate = new EventsTemplate(); if ($EventsTemplate->saveAll($toSave)) { return true; } } } return false; }
public function patchNeeded() { // bêta 2 $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='default_role_id' AND TABLE_NAME='" . Configure::read('Database.prefix') . "characters'"; if (!$this->controller->Character->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/beta-2'); } // bêta 3 $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='status' AND TABLE_NAME='" . Configure::read('Database.prefix') . "dungeons'"; if (!$this->controller->User->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/beta-3'); } // v1.1 $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='status' AND TABLE_NAME='" . Configure::read('Database.prefix') . "characters'"; if (!$this->controller->User->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.1'); } // v1.3 $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='bridge' AND TABLE_NAME='" . Configure::read('Database.prefix') . "users'"; if (!$this->controller->User->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.3'); } // v1.3.5 App::uses('EventsTemplate', 'Model'); $EventsTemplate = new EventsTemplate(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='time_invitation' AND TABLE_NAME='" . Configure::read('Database.prefix') . "events_templates'"; if (!$EventsTemplate->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.3.5'); } // v1.4 App::uses('RaidsRole', 'Model'); $RaidsRole = new RaidsRole(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='order' AND TABLE_NAME='" . Configure::read('Database.prefix') . "raids_roles'"; if (!$RaidsRole->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.4'); } // v1.4.1 App::uses('EventsCharacter', 'Model'); $EventsCharacter = new EventsCharacter(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='last_notification' AND TABLE_NAME='" . Configure::read('Database.prefix') . "events_characters'"; if (!$EventsCharacter->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.4.1'); } // v1.5 App::uses('Event', 'Model'); $Event = new Event(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='open' AND TABLE_NAME='" . Configure::read('Database.prefix') . "events'"; if (!$Event->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.5'); } // v1.5.2 App::uses('Event', 'Model'); $Event = new Event(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='time_inscription' AND TABLE_NAME='" . Configure::read('Database.prefix') . "events'"; if (!$Event->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.5.2'); } // v1.6 App::uses('User', 'Model'); $User = new User(); $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='calendar_key' AND TABLE_NAME='" . Configure::read('Database.prefix') . "users'"; if (!$User->query($sql)) { return $this->redirectToPatch('/admin/patcher/apply/v-1.6'); } // v1.6.2 App::uses('Setting', 'Model'); $SettingModel = new Setting(); $notifications = json_decode($SettingModel->getOption('notifications'), true); if (!isset($notifications['comments'])) { return $this->redirectToPatch('/admin/patcher/apply/v-1.6.2'); } }