Skip to content

Commit

Permalink
#6
Browse files Browse the repository at this point in the history
Prepare for DB update
  • Loading branch information
pihel committed Aug 13, 2014
1 parent 02de3dd commit 03b0cdd
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 14 deletions.
6 changes: 5 additions & 1 deletion lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ class LangEn extends iLang {
215 => "Install",
216 => "Installs and configures. Please wait ...",
217 => "Installation was successful",
218 => "Installation failed, contact support https://github.com/pihel/cash/issues"
218 => "Installation failed, contact support https://github.com/pihel/cash/issues",
//update
219 => "Updating ...",
220 => "Manually change the version is forbidden",
221 => "The version of the database"
);

}
6 changes: 5 additions & 1 deletion lang/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ class LangRu extends iLang {
215 => "Установить",
216 => "Выполняется установка и настройка. Пожалуйста подождите...",
217 => "Установка прошла успешно",
218 => "Установка завершилась с ошибкой, обратитесь в поддержку https://github.com/pihel/cash/issues"
218 => "Установка завершилась с ошибкой, обратитесь в поддержку https://github.com/pihel/cash/issues",
//update
219 => "Обновление...",
220 => "Ручное изменение версии запрещено",
221 => "Версия БД"
);

}
22 changes: 14 additions & 8 deletions lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$extjs = 'extjs';

/* App version */
$version = "1.030";
$version = "1.031";
//$version = rand(); //for reset cache

/* Path to imgs and js */
Expand Down Expand Up @@ -59,15 +59,21 @@
$ch = new Cash($db, $usr, $lng);

$settings = array();
$settings['version'] = $version;
$settings['demo'] = $demo;
$settings['debug'] = $debug;
$settings['static'] = $static;
$settings['extjs'] = $extjs;

//setup or update
$settings['setup'] = 0;
$settings['update'] = 0;
if( $upd->needSetup() ) {
$settings['setup'] = 1;
$settings['site_name'] = $lng->get(213);
} elseif( $upd->needUpdate() ) {
$settings['update'] = 1;
$settings['site_name'] = $lng->get(219);
} else {
$settings = $ch->getSettings();
$settings['setup'] = 0;
$settings = array_merge($settings, $ch->getSettings() );
}
$settings['version'] = $version;
$settings['demo'] = $demo;
$settings['debug'] = $debug;
$settings['static'] = $static;
$settings['extjs'] = $extjs;
6 changes: 5 additions & 1 deletion lib/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ public function setSetting($refb, $indx, $data) {
$col = "id";
if($refb == "cashes_setting") {
$col = "name";
}

if( in_array('version', $data) ) {
return $this->lng->get(220);
} //in_array
} //refb

$set = "";
unset($data[$col]);//unset ID col
Expand Down
15 changes: 12 additions & 3 deletions lib/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public function createData($pasw) {
$this->db->exec("INSERT INTO cashes_type(name) VALUES(?)", $this->lng->get(205));
$this->db->exec("INSERT INTO cashes_type(name) VALUES(?)", $this->lng->get(206));

global $settings;
$this->db->exec("INSERT INTO cashes_setting(name, descr, value) VALUES(?, ?, ?)", "site_name", $this->lng->get(207), $this->lng->get(208));
$this->db->exec("INSERT INTO cashes_setting(name, descr, value) VALUES(?, ?, ?)", "mail", $this->lng->get(209), "");
$this->db->exec("INSERT INTO cashes_setting(name, descr, value) VALUES(?, ?, ?)", "mail", $this->lng->get(209), "");
$this->db->exec("INSERT INTO cashes_setting(name, descr, value) VALUES(?, ?, ?)", "version", $this->lng->get(221), $settings['version'] );

$this->db->exec("INSERT INTO cashes_group(name) VALUES(?)", $this->lng->get(210));
$this->db->exec("INSERT INTO cashes_group(name) VALUES(?)", $this->lng->get(211));
Expand Down Expand Up @@ -76,6 +78,10 @@ public function clean() {
$this->db->commit();
} //clean

public function difChange() {
//
} //difChange

} //DbUpdate


Expand All @@ -102,8 +108,11 @@ public function needSetup() {
} //needSetup

public function needUpdate() {
global $version;//хранить гдето версию бд??
return false;
global $settings;
$file_ver = doubleval( $settings['version'] );
$db_ver = doubleval( $this->db->element("SELECT value FROM cashes_setting WHERE name = 'version'") );

return ( $file_ver > $db_ver && false ); //TODO
} //needUpdate


Expand Down
8 changes: 8 additions & 0 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ function setup() {
});
}

function update() {
loadScript(settings.static + "/js/update.js", function() {
updateWindow.show();
});
}

function logout() {
Ext.Ajax.request({
url: "ajax/logout.php",
Expand All @@ -329,6 +335,8 @@ Ext.onReady(function(){

if(settings.setup == 1) {
setup();
} else if(settings.update == 1) {
update();
} else {
checkAuth();
}
Expand Down
14 changes: 14 additions & 0 deletions static/js/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var updateWindow = new Ext.Window({
frame:true,
border: false,
title: lang(219),
width: 400,
closable: false,
resizable: false,
items: [],
listeners: {
show: function(){
//
}
}
});

0 comments on commit 03b0cdd

Please sign in to comment.