public static function install() { session_destroy(); // // Create necessary dirs // if (!file_exists(CINTIENT_WORK_DIR) && !mkdir(CINTIENT_WORK_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create working dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_PROJECTS_DIR) && !mkdir(CINTIENT_PROJECTS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create projects dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_ASSETS_DIR) && !mkdir(CINTIENT_ASSETS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create assets dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_AVATARS_DIR) && !mkdir(CINTIENT_AVATARS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create avatars dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Setup all objects // if (!User::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup User object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!Project::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup Project object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!SystemSettings::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup SystemSettings object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Test user setup // $user = new User(); $user->setEmail('*****@*****.**'); $user->setNotificationEmails('pedro.matamouros@gmail.com,'); $user->setName('Pedro Mata-Mouros'); $user->setUsername('matamouros'); $user->setCos(UserCos::ROOT); $user->init(); $user->setPassword('pedro'); header('Location: ' . UrlManager::getForDashboard()); exit; }
// // Setup all objects // if (!User::install()) { $ok = false; $msg = "Could not setup User object."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); } if (!Project::install()) { $ok = false; $msg = "Could not setup Project object."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); } if (!SystemSettings::install()) { $ok = false; $msg = "Could not setup SystemSettings object."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); } // // Everything ok!!! // if (!Database::endTransaction()) { Database::rollbackTransaction(); $ok = false; $msg = "Problems commiting all changes to the database."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); }