aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/apps.php13
-rw-r--r--install/schema_mysql.sql6
-rw-r--r--install/schema_postgres.sql4
-rw-r--r--install/update.php18
4 files changed, 35 insertions, 6 deletions
diff --git a/include/apps.php b/include/apps.php
index 7943bc927..3d480d901 100644
--- a/include/apps.php
+++ b/include/apps.php
@@ -342,7 +342,9 @@ function app_store($arr) {
$darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : '');
$darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : '');
- $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
+ $created = datetime_convert();
+
+ $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires, app_created, app_edited ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
dbesc($darray['app_id']),
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
@@ -355,7 +357,9 @@ function app_store($arr) {
dbesc($darray['app_addr']),
dbesc($darray['app_price']),
dbesc($darray['app_page']),
- dbesc($darray['app_requires'])
+ dbesc($darray['app_requires']),
+ dbesc($created),
+ dbesc($created)
);
if($r) {
$ret['success'] = true;
@@ -393,7 +397,9 @@ function app_update($arr) {
$darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : '');
$darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : '');
- $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s' where app_id = '%s' and app_channel = %d",
+ $edited = datetime_convert();
+
+ $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s', app_edited = '%s' where app_id = '%s' and app_channel = %d",
dbesc($darray['app_sig']),
dbesc($darray['app_author']),
dbesc($darray['app_name']),
@@ -405,6 +411,7 @@ function app_update($arr) {
dbesc($darray['app_price']),
dbesc($darray['app_page']),
dbesc($darray['app_requires']),
+ dbesc($edited),
dbesc($darray['app_id']),
intval($darray['app_channel'])
);
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index d7d44a0a6..1793f89c2 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -108,6 +108,8 @@ CREATE TABLE IF NOT EXISTS `app` (
`app_price` char(255) NOT NULL DEFAULT '',
`app_page` char(255) NOT NULL DEFAULT '',
`app_requires` char(255) NOT NULL DEFAULT '',
+ `app_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `app_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `app_id` (`app_id`),
KEY `app_name` (`app_name`),
@@ -115,7 +117,9 @@ CREATE TABLE IF NOT EXISTS `app` (
KEY `app_photo` (`app_photo`),
KEY `app_version` (`app_version`),
KEY `app_channel` (`app_channel`),
- KEY `app_price` (`app_price`)
+ KEY `app_price` (`app_price`),
+ KEY `app_created` (`app_created`),
+ KEY `app_edited` (`app_edited`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `attach` (
diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql
index 4c307a7f0..d31c304eb 100644
--- a/install/schema_postgres.sql
+++ b/install/schema_postgres.sql
@@ -107,6 +107,8 @@ CREATE TABLE "app" (
"app_price" text NOT NULL DEFAULT '',
"app_page" text NOT NULL DEFAULT '',
"app_requires" text NOT NULL DEFAULT '',
+ "app_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
+ "app_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id")
);
create index "app_id" on app ("app_id");
@@ -116,6 +118,8 @@ create index "app_photo" on app ("app_photo");
create index "app_version" on app ("app_version");
create index "app_channel" on app ("app_channel");
create index "app_price" on app ("app_price");
+create index "app_created" on app ("app_created");
+create index "app_edited" on app ("app_edited");
CREATE TABLE "attach" (
"id" serial NOT NULL,
"aid" bigint NOT NULL DEFAULT '0',
diff --git a/install/update.php b/install/update.php
index d0a0454fb..8e531b595 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1779,8 +1779,22 @@ function update_r1149() {
function update_r1150() {
- // hubzilla update does not apply here, but we're keeping the numbers in sync
- return UPDATE_SUCCESS;
+ if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
+ $r1 = q("ALTER TABLE app ADD app_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
+ ADD app_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' ");
+ }
+ else {
+ $r1 = q("ALTER TABLE app ADD app_created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ ADD app_edited DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ");
+ }
+
+ $r2 = q("create index app_created on app ( app_created ) ");
+ $r3 = q("create index app_edited on app ( app_edited ) ");
+
+ $r = $r1 && $r2 && $r3;
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
}