10 define(
"TITLE_CORE_INIT", _(
"Initialize"));
15 var $Title = TITLE_CORE_INIT;
17 var $MenuList =
"Admin::Initialize";
18 var $Dependency = array(
"auth",
"refresh",
"menus",
"Default");
21 var $PluginLevel= 100;
31 if ($this->
State != PLUGIN_STATE_VALID) {
37 $Filename = getcwd() .
"/init.ui";
38 if (! file_exists($Filename)) {
39 $this->
State = PLUGIN_STATE_INVALID;
42 $Max = count($Plugins);
43 for ($i = 0; $i < $Max; $i ++) {
45 if ($P->State == PLUGIN_STATE_INVALID) {
49 if ($P->State == PLUGIN_STATE_READY) {
55 $Key = array_search($P->Name, $this->Dependency);
56 if (($Key === FALSE) && strcmp($P->Name, $this->Name)) {
59 $P->State = PLUGIN_STATE_INVALID;
64 $this->
State = PLUGIN_STATE_READY;
66 ($this->MenuList !==
"")) {
67 menu_insert(
"Main::" . $this->MenuList, $this->MenuOrder, $this->Name,
70 return($this->
State == PLUGIN_STATE_READY);
78 if ($this->
State != PLUGIN_STATE_READY) {
83 switch ($this->OutputType) {
88 if (empty($_SESSION[
'User'])) {
89 $P = &$Plugins[
"auth"];
90 $P->OutputSet($this->OutputType, 0);
95 $Filename = getcwd() .
"/init.ui";
96 $Schema = &$Plugins[
"schema"];
98 $V .= _(
"Failed to find schema plugin.\n");
102 $FailFlag = $Schema->ApplySchema($Schema->Filename, 0, 0);
107 "Initialization complete. Click 'Home' in the top menu to proceed.<br />");
108 if (is_writable(getcwd())) {
109 $State = unlink($Filename);
114 $V .=
"<font color='red'>";
115 $V .= _(
"Failed to remove $Filename\n");
116 $text = _(
"Remove this file to complete the initialization.\n");
122 $V .=
"<font color='red'>";
123 $V .= _(
"Initialization complete with errors.");
133 if (! $this->OutputToStdout) {
145 $text = _(
"The system requires initialization. Please login and use the Initialize option under the Admin menu.");
146 $V .=
"<b>$text</b>";
151 $sql =
"SELECT * FROM users WHERE user_perm = $Level LIMIT 1;";
154 $R = pg_fetch_assoc($result);
155 pg_free_result($result);
156 if (array_key_exists(
"user_seed", $R) && array_key_exists(
"user_pass", $R)) {
157 $sql =
"SELECT user_name FROM users WHERE user_seed IS NULL AND user_pass IS NULL";
159 $sql =
"SELECT user_name FROM users";
163 $R = pg_fetch_assoc($result);
164 pg_free_result($result);
165 if (! empty($R[
'user_name'])) {
167 "If you need an account, use '" . $R[
'user_name'] .
168 "' with no password.\n");
176 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
Output()
This is only called when the user logs out.
PostInitialize()
This is where the magic for mod=init happens. This plugin only runs when the special file "....
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
#define PLUGIN_DB_NONE
Plugin requires no DB permission.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN