21 define(
"TITLE_CORE_INIT", _(
"Initialize"));
26 var $Title = TITLE_CORE_INIT;
28 var $MenuList =
"Admin::Initialize";
29 var $Dependency = array(
"auth",
"refresh",
"menus",
"Default");
32 var $PluginLevel= 100;
42 if ($this->
State != PLUGIN_STATE_VALID) {
48 $Filename = getcwd() .
"/init.ui";
49 if (! file_exists($Filename)) {
50 $this->
State = PLUGIN_STATE_INVALID;
53 $Max = count($Plugins);
54 for ($i = 0; $i < $Max; $i ++) {
56 if ($P->State == PLUGIN_STATE_INVALID) {
60 if ($P->State == PLUGIN_STATE_READY) {
66 $Key = array_search($P->Name, $this->Dependency);
67 if (($Key === FALSE) && strcmp($P->Name, $this->Name)) {
70 $P->State = PLUGIN_STATE_INVALID;
75 $this->
State = PLUGIN_STATE_READY;
77 ($this->MenuList !==
"")) {
78 menu_insert(
"Main::" . $this->MenuList, $this->MenuOrder, $this->Name,
81 return($this->
State == PLUGIN_STATE_READY);
89 if ($this->
State != PLUGIN_STATE_READY) {
94 switch ($this->OutputType) {
99 if (empty($_SESSION[
'User'])) {
100 $P = &$Plugins[
"auth"];
101 $P->OutputSet($this->OutputType, 0);
106 $Filename = getcwd() .
"/init.ui";
107 $Schema = &$Plugins[
"schema"];
108 if (empty($Schema)) {
109 $V .= _(
"Failed to find schema plugin.\n");
113 $FailFlag = $Schema->ApplySchema($Schema->Filename, 0, 0);
118 "Initialization complete. Click 'Home' in the top menu to proceed.<br />");
119 if (is_writable(getcwd())) {
120 $State = unlink($Filename);
125 $V .=
"<font color='red'>";
126 $V .= _(
"Failed to remove $Filename\n");
127 $text = _(
"Remove this file to complete the initialization.\n");
133 $V .=
"<font color='red'>";
134 $V .= _(
"Initialization complete with errors.");
144 if (! $this->OutputToStdout) {
156 $text = _(
"The system requires initialization. Please login and use the Initialize option under the Admin menu.");
157 $V .=
"<b>$text</b>";
162 $sql =
"SELECT * FROM users WHERE user_perm = $Level LIMIT 1;";
163 $result = pg_query($PG_CONN, $sql);
165 $R = pg_fetch_assoc($result);
166 pg_free_result($result);
167 if (array_key_exists(
"user_seed", $R) && array_key_exists(
"user_pass", $R)) {
168 $sql =
"SELECT user_name FROM users WHERE user_seed IS NULL AND user_pass IS NULL";
170 $sql =
"SELECT user_name FROM users";
172 $result = pg_query($PG_CONN, $sql);
174 $R = pg_fetch_assoc($result);
175 pg_free_result($result);
176 if (! empty($R[
'user_name'])) {
178 "If you need an account, use '" . $R[
'user_name'] .
179 "' with no password.\n");
187 $NewPlugin->Initialize();
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
PostInitialize()
This is where the magic for mod=init happens. This plugin only runs when the special file "...
#define PLUGIN_DB_NONE
Plugin requires no DB permission.
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Output()
This is only called when the user logs out.