diff options
-rwxr-xr-x | boot.php | 2 | ||||
-rwxr-xr-x | include/importdoc.php | 22 | ||||
-rw-r--r-- | include/taxonomy.php | 10 | ||||
-rw-r--r-- | install/schema_mysql.sql | 10 | ||||
-rw-r--r-- | install/schema_postgres.sql | 10 | ||||
-rw-r--r-- | install/update.php | 30 | ||||
-rwxr-xr-x | mod/like.php | 13 | ||||
-rw-r--r-- | mod/thing.php | 55 | ||||
-rw-r--r-- | view/tpl/show_thing.tpl | 8 |
9 files changed, 110 insertions, 50 deletions
@@ -50,7 +50,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'H'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1149 ); +define ( 'DB_UPDATE_VERSION', 1150 ); /** * @brief Constant with a HTML line break. diff --git a/include/importdoc.php b/include/importdoc.php index 9cce35c50..10f868697 100755 --- a/include/importdoc.php +++ b/include/importdoc.php @@ -1,17 +1,30 @@ <?php + + require_once('include/cli_startup.php'); -cli_startup(); -require_once('mod/help.php'); +function importdoc_run($argv, $argc){ + + cli_startup(); + + require_once('mod/help.php'); + + + update_docs_dir('doc/*'); + +} +if (array_search(__file__,get_included_files())===0){ + importdoc_run($argv,$argc); + killme(); +} function update_docs_dir($s) { $f = basename($s); $d = dirname($s); if($s === 'doc/html') return; - $files = glob("$d/$f"); if($files) { foreach($files as $fi) { @@ -25,7 +38,4 @@ function update_docs_dir($s) { } } -update_docs_dir('doc/*'); - - diff --git a/include/taxonomy.php b/include/taxonomy.php index b57cfc5c4..a82cf94f7 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -341,7 +341,7 @@ function get_things($profile_hash,$uid) { $sql_extra = (($profile_hash) ? " and obj_page = '" . $profile_hash . "' " : ''); - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and uid = %d and obj_type = %d $sql_extra order by obj_verb, term", + $r = q("select * from obj where obj_channel = %d and obj_type = %d $sql_extra order by obj_verb, obj_term", intval($uid), intval(TERM_OBJ_THING) ); @@ -357,8 +357,8 @@ function get_things($profile_hash,$uid) { foreach($r as $rr) { $rr['profile_name'] = ''; - if(! in_array($rr['term_hash'],$profile_hashes)) - $profile_hashes[] = $rr['term_hash']; + if(! in_array($rr['obj_obj'],$profile_hashes)) + $profile_hashes[] = $rr['obj_obj']; } stringify_array_elms($profile_hashes); if(! $profile_hash) { @@ -390,7 +390,7 @@ function get_things($profile_hash,$uid) { $l = q("select xchan_name, xchan_url from likes left join xchan on likee = xchan_hash where target_type = '%s' and target_id = '%s' and channel_id = %d", dbesc(ACTIVITY_OBJ_THING), - dbesc($rr['term_hash']), + dbesc($rr['obj_obj']), intval($uid) ); @@ -400,7 +400,7 @@ function get_things($profile_hash,$uid) { if(! $things[$rr['obj_verb']]) $things[$rr['obj_verb']] = array(); - $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun')); + $things[$rr['obj_verb']][] = array('term' => $rr['obj_term'],'url' => $rr['obj_url'],'img' => $rr['obj_imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['obj_obj'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun')); } $sorted_things = array(); if($things) { diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 5ee1ec463..d7d44a0a6 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -823,6 +823,11 @@ CREATE TABLE IF NOT EXISTS `obj` ( `obj_type` int(10) unsigned NOT NULL DEFAULT '0', `obj_obj` char(255) NOT NULL DEFAULT '', `obj_channel` int(10) unsigned NOT NULL DEFAULT '0', + `obj_term` char(255) NOT NULL DEFAULT '', + `obj_url` char(255) NOT NULL DEFAULT '', + `obj_imgurl` char(255) NOT NULL DEFAULT '', + `obj_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `obj_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, @@ -832,6 +837,11 @@ CREATE TABLE IF NOT EXISTS `obj` ( KEY `obj_page` (`obj_page`), KEY `obj_type` (`obj_type`), KEY `obj_channel` (`obj_channel`), + KEY `obj_term` (`obj_term`), + KEY `obj_url` (`obj_url`), + KEY `obj_imgurl` (`obj_imgurl`), + KEY `obj_created` (`obj_created`), + KEY `obj_edited` (`obj_edited`), KEY `obj_obj` (`obj_obj`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index c594d0f87..4c307a7f0 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -812,6 +812,11 @@ CREATE TABLE "obj" ( "obj_type" bigint NOT NULL DEFAULT '0', "obj_obj" text NOT NULL DEFAULT '', "obj_channel" bigint NOT NULL DEFAULT '0', + "obj_term" char(255) NOT NULL DEFAULT '', + "obj_url" char(255) NOT NULL DEFAULT '', + "obj_imgurl" char(255) NOT NULL DEFAULT '', + "obj_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', + "obj_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "allow_cid" text NOT NULL, "allow_gid" text NOT NULL, "deny_cid" text NOT NULL, @@ -824,6 +829,11 @@ create index "obj_page" on obj ("obj_page"); create index "obj_type" on obj ("obj_type"); create index "obj_channel" on obj ("obj_channel"); create index "obj_obj" on obj ("obj_obj"); +create index "obj_term" on obj ("obj_term"); +create index "obj_url" on obj ("obj_url"); +create index "obj_imgurl" on obj ("obj_imgurl"); +create index "obj_created" on obj ("obj_created"); +create index "obj_edited" on obj ("obj_edited"); CREATE TABLE "outq" ( "outq_hash" text NOT NULL, diff --git a/install/update.php b/install/update.php index b398711b2..d0ea4d147 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1149 ); +define( 'UPDATE_VERSION' , 1150 ); /** * @@ -1748,3 +1748,31 @@ function update_r1148() { return UPDATE_FAILED; } + +function update_r1149() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE obj ADD obj_term CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_url CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_imgurl CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', + ADD obj_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); + } + else { + $r1 = q("ALTER TABLE obj ADD obj_term CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_url CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_imgurl CHAR( 255 ) NOT NULL DEFAULT '', + ADD obj_created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + ADD obj_edited DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); + } + + $r2 = q("create index obj_term on obj ( obj_term ) "); + $r3 = q("create index obj_url on obj ( obj_url ) "); + $r4 = q("create index obj_imgurl on obj ( obj_imgurl ) "); + $r5 = q("create index obj_created on obj ( obj_created ) "); + $r6 = q("create index obj_edited on obj ( obj_edited ) "); + $r = $r1 && $r2 && $r3 && $r4 && $r5 && $r6; + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +}
\ No newline at end of file diff --git a/mod/like.php b/mod/like.php index 0d0a1a8c2..42ff9bb8a 100755 --- a/mod/like.php +++ b/mod/like.php @@ -117,8 +117,7 @@ function like_content(&$a) { } elseif($obj_type == 'thing') { - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' - and obj_type = %d and term_hash = '%s' limit 1", + $r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1", intval(TERM_OBJ_THING), dbesc(argv(2)) ); @@ -146,18 +145,18 @@ function like_content(&$a) { $links = array(); $links[] = array('rel' => 'alternate', 'type' => 'text/html', - 'href' => z_root() . '/thing/' . $r[0]['term_hash']); + 'href' => z_root() . '/thing/' . $r[0]['obj_obj']); if($r[0]['imgurl']) - $links[] = array('rel' => 'photo', 'href' => $r[0]['imgurl']); + $links[] = array('rel' => 'photo', 'href' => $r[0]['obj_imgurl']); $target = json_encode(array( 'type' => $tgttype, - 'title' => $r[0]['term'], - 'id' => z_root() . '/thing/' . $r[0]['term_hash'], + 'title' => $r[0]['obj_term'], + 'id' => z_root() . '/thing/' . $r[0]['obj_obj'], 'link' => $links )); - $plink = '[zrl=' . z_root() . '/thing/' . $r[0]['term_hash'] . ']' . $r[0]['term'] . '[/zrl]'; + $plink = '[zrl=' . z_root() . '/thing/' . $r[0]['obj_obj'] . ']' . $r[0]['obj_term'] . '[/zrl]'; } diff --git a/mod/thing.php b/mod/thing.php index b4b8ad027..f673b8c43 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -66,16 +66,16 @@ function thing_init(&$a) { return; if($term_hash) { - $t = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", - intval(TERM_OBJ_THING), - dbesc($term_hash) + $t = q("select * from obj where obj_obj = '%s' and obj_channel = %d limit 1", + dbesc($term_hash), + intval(local_channel()) ); if(! $t) { notice( t('Item not found.') . EOL); return; } $orig_record = $t[0]; - if($photo != $orig_record['imgurl']) { + if($photo != $orig_record['obj_imgurl']) { $arr = import_profile_photo($photo,get_observer_hash(),true); $local_photo = $arr[0]; $local_photo_type = $arr[3]; @@ -83,10 +83,11 @@ function thing_init(&$a) { else $local_photo = $orig_record['imgurl']; - $r = q("update term set term = '%s', url = '%s', imgurl = '%s' where term_hash = '%s' and uid = %d", + $r = q("update obj set obj_term = '%s', obj_url = '%s', obj_imgurl = '%s', obj_edited = '%s' where obj_obj = '%s' and uid = %d", dbesc($name), dbesc(($url) ? $url : z_root() . '/thing/' . $term_hash), dbesc($local_photo), + dbesc(datetime_convert()), dbesc($term_hash), intval(local_channel()) ); @@ -113,10 +114,9 @@ function thing_init(&$a) { $local_photo_type = $arr[3]; } - $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", + $r = q("select * from obj where obj_channel = %d and obj_type = %d and obj_term = '%s' limit 1", intval(local_channel()), intval(TERM_OBJ_THING), - intval(TERM_THING), dbesc($name) ); if(! $r) { @@ -139,14 +139,21 @@ function thing_init(&$a) { dbesc($name) ); } - $term = $r[0]; - $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj) values ('%s','%s', %d, %d, '%s') ", + $created = datetime_convert(); + $url = (($url) ? $url : z_root() . '/thing/' . $hash); + + $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj, obj_term, obj_url, obj_imgurl, obj_created, obj_edited ) values ('%s','%s', %d, %d, '%s','%s','%s','%s','%s','%s') ", dbesc($profile['profile_guid']), dbesc($verb), intval(TERM_OBJ_THING), intval(local_channel()), - dbesc($term['term_hash']) + dbesc($hash), + dbesc($name), + dbesc($url), + dbesc(($photo) ? $local_photo : ''), + dbesc($created), + dbesc($created) ); if(! $r) { @@ -155,10 +162,10 @@ function thing_init(&$a) { } info( t('Thing added')); - + if($activity) { $arr = array(); - $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); + $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $url)); if($local_photo) $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); @@ -166,10 +173,10 @@ function thing_init(&$a) { $obj = json_encode(array( 'type' => $objtype, - 'id' => $term['url'], + 'id' => $url, 'link' => $links, - 'title' => $term['term'], - 'content' => $term['term'] + 'title' => $name, + 'content' => $name )); $bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s')); @@ -182,7 +189,7 @@ function thing_init(&$a) { $arr['item_thread_top'] = 1; $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; - $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; + $plink = '[zrl=' . $url . ']' . $name . '[/zrl]'; $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); @@ -218,7 +225,7 @@ function thing_content(&$a) { if(argc() == 2) { - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", + $r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1", intval(TERM_OBJ_THING), dbesc(argv(1)) ); @@ -249,7 +256,7 @@ function thing_content(&$a) { if(argc() == 3 && argv(1) === 'edit') { $thing_hash = argv(2); - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", + $r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1", intval(TERM_OBJ_THING), dbesc($thing_hash) ); @@ -269,11 +276,11 @@ function thing_content(&$a) { '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$thing_hash' => $thing_hash, '$thing_lbl' => t('Name of thing e.g. something'), - '$thething' => $r[0]['term'], + '$thething' => $r[0]['obj_term'], '$url_lbl' => t('URL of thing (optional)'), - '$theurl' => $r[0]['url'], + '$theurl' => $r[0]['obj_url'], '$img_lbl' => t('URL for photo of thing (optional)'), - '$imgurl' => $r[0]['imgurl'], + '$imgurl' => $r[0]['obj_imgurl'], '$submit' => t('Submit') )); @@ -283,7 +290,7 @@ function thing_content(&$a) { if(argc() == 3 && argv(1) === 'drop') { $thing_hash = argv(2); - $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", + $r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1", intval(TERM_OBJ_THING), dbesc($thing_hash) ); @@ -298,10 +305,6 @@ function thing_content(&$a) { intval(TERM_OBJ_THING), intval(local_channel()) ); - $x = q("delete from term where term_hash = '%s' and uid = %d", - dbesc($thing_hash), - intval(local_channel()) - ); return $o; } diff --git a/view/tpl/show_thing.tpl b/view/tpl/show_thing.tpl index 9aacc8958..4ef5473c2 100644 --- a/view/tpl/show_thing.tpl +++ b/view/tpl/show_thing.tpl @@ -1,13 +1,13 @@ <h2>{{$header}}</h2> {{if $thing}} <div class="thing-show"> -{{if $thing.imgurl}}<img src="{{$thing.imgurl}}" width="175" height="175" alt="{{$thing.term}}" />{{/if}} -<a href="{{$thing.url}}" >{{$thing.term}}</a> +{{if $thing.obj_imgurl}}<img src="{{$thing.obj_imgurl}}" width="175" height="175" alt="{{$thing.obj_term}}" />{{/if}} +<a href="{{$thing.obj_url}}" >{{$thing.obj_term}}</a> </div> {{if $canedit}} <div class="thing-edit-links"> -<a href="thing/edit/{{$thing.term_hash}}" title="{{$edit}}" class="btn btn-default" ><i class="icon-pencil thing-edit-icon"></i></a> -<a href="thing/drop/{{$thing.term_hash}}" onclick="return confirmDelete();" title="{{$delete}}" class="btn btn-default" ><i class="icon-trash drop-icons"></i></a> +<a href="thing/edit/{{$thing.obj_obj}}" title="{{$edit}}" class="btn btn-default" ><i class="icon-pencil thing-edit-icon"></i></a> +<a href="thing/drop/{{$thing.obj_obj}}" onclick="return confirmDelete();" title="{{$delete}}" class="btn btn-default" ><i class="icon-trash drop-icons"></i></a> </div> <div class="thing-edit-links-end"></div> {{/if}} |