From cdc66da52fb985c33e27b955324dd977830a1d8c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 27 Jun 2013 19:35:59 -0700 Subject: Basic ability to create "things" --- mod/thing.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 mod/thing.php (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php new file mode 100644 index 000000000..723b069bc --- /dev/null +++ b/mod/thing.php @@ -0,0 +1,43 @@ +get_account(); + + $name = escape_tags($_REQUEST['term']); + $url = $_REQUEST['link']; + $photo = $_REQUEST['photo']; + + $hash = random_string(); + + + if(! $name) + return; + + $r = q("insert into term ( aid, uid, oid, otype, type, term, url, imgurl, term_hash ) + values( %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s' ) ", + intval($account_id), + intval(local_user()), + 0, + TERM_OBJ_THING, + TERM_THING, + dbesc($name), + dbesc(($url) ? $url : z_root() . '/thing/' . $hash), + dbesc(($photo) ? $photo : ''), + dbesc($hash) + ); + +} + + +function thing_content(&$a) { + + + + +} -- cgit v1.2.3 From 8ec5f8b07a0f1d5ad266bfdfdfb48d4f5647eed6 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 3 Jul 2013 19:30:52 -0700 Subject: $yoursite/thing?f=&verb=has&term=big+balls These will eventually be listed by category in your profile and you will be able to have different lists in different profiles (which is why the multi-profile feature needed to get finished before I could get any further along on this...) have fun --- mod/thing.php | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 11 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 723b069bc..9cd0f519f 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -1,5 +1,6 @@ get_account(); + $channel = $a->get_channel(); + $name = escape_tags($_REQUEST['term']); + $verb = escape_tags($_REQUEST['verb']); + $profile = escape_tags($_REQUEST['profile']); $url = $_REQUEST['link']; $photo = $_REQUEST['photo']; $hash = random_string(); - if(! $name) + $verbs = obj_verbs(); + + /** + * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" + * We use the first person form when creating an activity, but the third person for use in activities + * FIXME: There is no accounting for verb gender for languages where this is significant. We may eventually + * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module. + */ + + $translated_verb = $verbs[$verb][1]; + + /** + * Things, objects: We do not provide definite (a, an) or indefinite (the) articles or singular/plural designators + * That needs to be specified in your thing. e.g. Mike has "a carrot", Greg wants "balls", Bob likes "the Boston Red Sox". + */ + + /** + * Future work on this module might produce more complex activities with targets, e.g. Phillip likes Karen's moustache + * and to describe other non-thing objects like channels, such as Karl wants Susan - where Susan represents a channel profile. + */ + + if((! $name) || (! $translated_verb)) + return; + + if(! $profile) { + $r = q("select profile_guid from profile where is_default = 1 and uid = %d limit 1", + intval(local_user()) + ); + if($r) + $profile = $r[0]['profile_guid']; + } + + if(! $profile) return; - $r = q("insert into term ( aid, uid, oid, otype, type, term, url, imgurl, term_hash ) - values( %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s' ) ", - intval($account_id), + + $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_user()), - 0, - TERM_OBJ_THING, - TERM_THING, - dbesc($name), - dbesc(($url) ? $url : z_root() . '/thing/' . $hash), - dbesc(($photo) ? $photo : ''), - dbesc($hash) + intval(TERM_OBJ_THING), + intval(TERM_THING), + dbesc($name) + ); + if(! $r) { + $r = q("insert into term ( aid, uid, oid, otype, type, term, url, imgurl, term_hash ) + values( %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s' ) ", + intval($account_id), + intval(local_user()), + 0, + intval(TERM_OBJ_THING), + intval(TERM_THING), + dbesc($name), + dbesc(($url) ? $url : z_root() . '/thing/' . $hash), + dbesc(($photo) ? $photo : ''), + dbesc($hash) + ); + $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", + intval(local_user()), + intval(TERM_OBJ_THING), + intval(TERM_THING), + dbesc($name) + ); + } + $term = $r[0]; + + $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel) values ('%s','%s', %d,%d) ", + dbesc($profile), + dbesc($verb), + intval(TERM_OBJ_THING), + intval(local_user()) ); + + if(! $r) { + notice('Object store: failed'); + return; + } + + + $arr = array(); + $links = array(array('rel' => 'alternate','type' => 'text/html', + 'href' => $term['url'])); + + $objtype = ACTIVITY_OBJ_THING; + + $obj = json_encode(array( + 'type' => $objtype, + 'id' => $term['url'], + 'link' => $links, + 'title' => $term['term'], + 'content' => $term['term'] + )); + + $bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s')); + + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $channel['channel_hash']; + + + $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; + + $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; + $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; + + $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); + + $arr['verb'] = $verb; + $arr['obj_type'] = $objtype; + $arr['object'] = $obj; + + $ret = post_activity_item($arr); + + if($ret['success']) + proc_run('php','include/notifier.php','tag',$ret['activity']['id']); } function thing_content(&$a) { + + /* placeholders */ + if(argc() > 1) { + return t('not yet implemented.'); + } + goaway(z_root() . '/network'); } -- cgit v1.2.3 From fbdee83dca4aa9e5d66488f32121d8c62e378316 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 3 Jul 2013 20:37:39 -0700 Subject: some object/thing tweaks --- mod/thing.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 9cd0f519f..8ecf00d01 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -31,6 +31,20 @@ function thing_init(&$a) { */ $translated_verb = $verbs[$verb][1]; + + /** + * The site administrator can do things that normals cannot. + * This is restricted because it will likely cause + * an activitystreams protocol violation and the activity might + * choke in some other network and result in unnecessary + * support requests. It isn't because we're trying to be heavy-handed + * about what you can and can't do. + */ + + if(! $translated_verb) { + if(is_site_admin()) + $translated_verb = $verb; + } /** * Things, objects: We do not provide definite (a, an) or indefinite (the) articles or singular/plural designators -- cgit v1.2.3 From 6f390330ff45c2b636a20c2c4e32e70c74523d6a Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 3 Jul 2013 22:51:49 -0700 Subject: nearly ready for the output template --- mod/thing.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 8ecf00d01..6df4aa3b6 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -99,11 +99,12 @@ function thing_init(&$a) { } $term = $r[0]; - $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel) values ('%s','%s', %d,%d) ", + $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj) values ('%s','%s', %d, %d, '%s') ", dbesc($profile), dbesc($verb), intval(TERM_OBJ_THING), - intval(local_user()) + intval(local_user()), + dbesc($term['term_hash']) ); if(! $r) { -- cgit v1.2.3 From 8b9f2f8ef766c169e77a34c72118d14beb2b21de Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 4 Jul 2013 20:35:42 -0700 Subject: input form for profile stuff --- mod/thing.php | 56 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 6df4aa3b6..91bdca78a 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -14,7 +14,7 @@ function thing_init(&$a) { $name = escape_tags($_REQUEST['term']); $verb = escape_tags($_REQUEST['verb']); - $profile = escape_tags($_REQUEST['profile']); + $profile_guid = escape_tags($_REQUEST['profile']); $url = $_REQUEST['link']; $photo = $_REQUEST['photo']; @@ -59,15 +59,13 @@ function thing_init(&$a) { if((! $name) || (! $translated_verb)) return; - if(! $profile) { - $r = q("select profile_guid from profile where is_default = 1 and uid = %d limit 1", - intval(local_user()) - ); - if($r) - $profile = $r[0]['profile_guid']; - } - - if(! $profile) + $sql = (($profile_guid) ? " and profile_guid = '" . dbesc($profile_guid) . "' " : " and is_default = 1 "); + $p = q("select profile_guid, is_default from profile where uid = %d $sql limit 1", + intval(local_user()) + ); + if($p) + $profile = $p[0]; + else return; @@ -100,7 +98,7 @@ function thing_init(&$a) { $term = $r[0]; $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj) values ('%s','%s', %d, %d, '%s') ", - dbesc($profile), + dbesc($profile['profile_guid']), dbesc($verb), intval(TERM_OBJ_THING), intval(local_user()), @@ -108,10 +106,11 @@ function thing_init(&$a) { ); if(! $r) { - notice('Object store: failed'); + notice( t('Object store: failed')); return; } + info( t('thing/stuff added')); $arr = array(); $links = array(array('rel' => 'alternate','type' => 'text/html', @@ -143,6 +142,22 @@ function thing_init(&$a) { $arr['verb'] = $verb; $arr['obj_type'] = $objtype; $arr['object'] = $obj; + + if(! $profile['is_default']) { + $arr['item_private'] = true; + $str = ''; + $r = q("select abook_hash from abook where abook_channel = %d and abook_profile = '%s'", + intval(local_user()), + dbesc($profile_guid) + ); + if($r) { + $arr['allow_cid'] = ''; + foreach($r as $rr) + $arr['allow_cid'] .= '<' . $rr['abook_hash'] . '>'; + } + else + $arr['allow_cid'] = '<' . get_observer_hash() . '>'; + } $ret = post_activity_item($arr); @@ -160,7 +175,22 @@ function thing_content(&$a) { return t('not yet implemented.'); } - goaway(z_root() . '/network'); + require_once('include/contact_selectors.php'); + + $o .= replace_macros(get_markup_template('thing_input.tpl'),array( + '$thing_hdr' => t('Add Stuff to your Profile'), + '$multiprof' => feature_enabled(local_user(),'multi_profiles'), + '$profile_lbl' => t('Select a profile'), + '$profile_select' => contact_profile_assign(''), + '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_select' => obj_verb_selector(), + '$thing_lbl' => t('Name of thing or stuff e.g. something'), + '$url_lbl' => t('URL of thing or stuff (optional)'), + '$img_lbl' => t('URL for photo of thing or stuff (optional)'), + '$submit' => t('Submit') + )); + + return $o; } -- cgit v1.2.3 From 1d0fddd39c50205f697b040aab1655b282afa53d Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Dec 2013 13:28:49 -0800 Subject: things can now have (consistent sized) photos - plus I found a couple of issues with duplicate notifications and contact photos not getting an album name (it was crossed with filename). The last one doesn't matter as neither is used, but it was wrong so it has been corrected. Oh and thing photos weren't working at all because the form element name was different than what the module was looking for. But that had never been tested as I was waiting to get the import/resize finished. Next up for that module is display and deletion of things; but the priority is pretty low. --- mod/thing.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 91bdca78a..955a6c173 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -16,7 +16,7 @@ function thing_init(&$a) { $verb = escape_tags($_REQUEST['verb']); $profile_guid = escape_tags($_REQUEST['profile']); $url = $_REQUEST['link']; - $photo = $_REQUEST['photo']; + $photo = $_REQUEST['img']; $hash = random_string(); @@ -68,6 +68,14 @@ function thing_init(&$a) { else return; + $local_photo = null; + + if($photo) { + $arr = import_profile_photo($photo,get_observer_hash(),true); + $local_photo = $arr[0]; + $local_photo_type = $arr[3]; + } + $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_user()), @@ -85,7 +93,7 @@ function thing_init(&$a) { intval(TERM_THING), dbesc($name), dbesc(($url) ? $url : z_root() . '/thing/' . $hash), - dbesc(($photo) ? $photo : ''), + dbesc(($photo) ? $local_photo : ''), dbesc($hash) ); $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", @@ -113,8 +121,10 @@ function thing_init(&$a) { info( t('thing/stuff added')); $arr = array(); - $links = array(array('rel' => 'alternate','type' => 'text/html', - 'href' => $term['url'])); + $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); + if($local_photo) + $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); + $objtype = ACTIVITY_OBJ_THING; @@ -139,6 +149,9 @@ function thing_init(&$a) { $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); + if($local_photo) + $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]"; + $arr['verb'] = $verb; $arr['obj_type'] = $objtype; $arr['object'] = $obj; @@ -161,8 +174,6 @@ function thing_init(&$a) { $ret = post_activity_item($arr); - if($ret['success']) - proc_run('php','include/notifier.php','tag',$ret['activity']['id']); } -- cgit v1.2.3 From f36be066af66e4e21913de3e8b4da0c7a05349b1 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Dec 2013 00:51:27 -0800 Subject: display_thing: it ain't much, but it's implemented. --- mod/thing.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 955a6c173..3e2612c68 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -180,10 +180,20 @@ function thing_init(&$a) { function thing_content(&$a) { - /* placeholders */ - if(argc() > 1) { - return t('not yet implemented.'); + + $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", + intval(TERM_OBJ_THING), + dbesc(argv(1)) + ); + + if($r) { + return replace_macros(get_markup_template('show_thing.tpl'), array( '$header' => t('Show Thing'), '$thing' => $r[0] )); + } + else { + notice( t('item not found.') . EOL); + return; + } } require_once('include/contact_selectors.php'); -- cgit v1.2.3 From 0dd7d936744cccfac4228cabecddc59ce05eb26c Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Dec 2013 04:25:55 -0800 Subject: basic edit and delete for things --- mod/thing.php | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 8 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 3e2612c68..b4fdfa039 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -1,6 +1,7 @@ get_account(); $channel = $a->get_channel(); + $term_hash = (($_REQUEST['term_hash']) ? $_REQUEST['term_hash'] : ''); $name = escape_tags($_REQUEST['term']); $verb = escape_tags($_REQUEST['verb']); @@ -59,6 +61,40 @@ function thing_init(&$a) { if((! $name) || (! $translated_verb)) 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) + ); + if(! $t) { + notice( t('Item not found.') . EOL); + return; + } + $orig_record = $t[0]; + if($photo != $orig_record['imgurl']) { + $arr = import_profile_photo($photo,get_observer_hash(),true); + $local_photo = $arr[0]; + $local_photo_type = $arr[3]; + } + else + $local_photo = $orig_record['imgurl']; + + $r = q("update term set term = '%s', url = '%s', imgurl = '%s' where term_hash = '%s' and uid = %d limit 1", + dbesc($name), + dbesc(($url) ? $url : z_root() . '/thing/' . $term_hash), + dbesc($local_photo), + dbesc($term_hash), + intval(local_user()) + ); + + info( t('Thing updated') . EOL); + return; + } + $sql = (($profile_guid) ? " and profile_guid = '" . dbesc($profile_guid) . "' " : " and is_default = 1 "); $p = q("select profile_guid, is_default from profile where uid = %d $sql limit 1", intval(local_user()) @@ -118,7 +154,7 @@ function thing_init(&$a) { return; } - info( t('thing/stuff added')); + info( t('Thing added')); $arr = array(); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); @@ -180,7 +216,7 @@ function thing_init(&$a) { function thing_content(&$a) { - if(argc() > 1) { + 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", intval(TERM_OBJ_THING), @@ -188,7 +224,12 @@ function thing_content(&$a) { ); if($r) { - return replace_macros(get_markup_template('show_thing.tpl'), array( '$header' => t('Show Thing'), '$thing' => $r[0] )); + return replace_macros(get_markup_template('show_thing.tpl'), array( + '$header' => t('Show Thing'), + '$edit' => t('Edit'), + '$delete' => t('Delete'), + '$canedit' => ((local_user() && local_user() == $r[0]['obj_channel']) ? true : false), + '$thing' => $r[0] )); } else { notice( t('item not found.') . EOL); @@ -196,18 +237,82 @@ function thing_content(&$a) { } } - require_once('include/contact_selectors.php'); + if(! local_user()) + return; + + $thing_hash = ''; + + 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", + intval(TERM_OBJ_THING), + dbesc($thing_hash) + ); + + if((! $r) || ($r[0]['obj_channel'] != local_user())) { + notice( t('Permission denied.') . EOL); + return ''; + } + + + $o .= replace_macros(get_markup_template('thing_edit.tpl'),array( + '$thing_hdr' => t('Edit Thing'), + '$multiprof' => feature_enabled(local_user(),'multi_profiles'), + '$profile_lbl' => t('Select a profile'), + '$profile_select' => contact_profile_assign($r[0]['obj_page']), + '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_select' => obj_verb_selector($r[0]['obj_verb']), + '$thing_hash' => $thing_hash, + '$thing_lbl' => t('Name of thing e.g. something'), + '$thething' => $r[0]['term'], + '$url_lbl' => t('URL of thing (optional)'), + '$theurl' => $r[0]['url'], + '$img_lbl' => t('URL for photo of thing (optional)'), + '$imgurl' => $r[0]['imgurl'], + '$submit' => t('Submit') + )); + + return $o; + } + + 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", + intval(TERM_OBJ_THING), + dbesc($thing_hash) + ); + + if((! $r) || ($r[0]['obj_channel'] != local_user())) { + notice( t('Permission denied.') . EOL); + return ''; + } + + + $x = q("delete from obj where obj_obj = '%s' and obj_type = %d and obj_channel = %d limit 1", + dbesc($thing_hash), + intval(TERM_OBJ_THING), + intval(local_user()) + ); + $x = q("delete from term where term_hash = '%s' and uid = %d limit 1", + dbesc($thing_hash), + intval(local_user()) + ); + return $o; + } $o .= replace_macros(get_markup_template('thing_input.tpl'),array( - '$thing_hdr' => t('Add Stuff to your Profile'), + '$thing_hdr' => t('Add Thing to your Profile'), '$multiprof' => feature_enabled(local_user(),'multi_profiles'), '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign(''), '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), '$verb_select' => obj_verb_selector(), - '$thing_lbl' => t('Name of thing or stuff e.g. something'), - '$url_lbl' => t('URL of thing or stuff (optional)'), - '$img_lbl' => t('URL for photo of thing or stuff (optional)'), + '$thing_lbl' => t('Name of thing e.g. something'), + '$url_lbl' => t('URL of thing (optional)'), + '$img_lbl' => t('URL for photo of thing (optional)'), '$submit' => t('Submit') )); -- cgit v1.2.3 From 4c541bb680823b7488a2614b5ef0231ad38b42c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Dec 2013 15:41:42 -0800 Subject: expose profile things in the UI --- mod/thing.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index b4fdfa039..d3b47ebb9 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -237,8 +237,10 @@ function thing_content(&$a) { } } - if(! local_user()) + if(! local_user()) { + notice( t('Permission denied.') . EOL); return; + } $thing_hash = ''; -- cgit v1.2.3 From b5728fa42efa0d12da8814711e0875da7fb88672 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 11 Feb 2014 16:56:39 -0800 Subject: fixes to thing profile assignments --- mod/thing.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index d3b47ebb9..9b362cecd 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -9,6 +9,9 @@ function thing_init(&$a) { if(! local_user()) return; + + + $account_id = $a->get_account(); $channel = $a->get_channel(); @@ -16,7 +19,7 @@ function thing_init(&$a) { $name = escape_tags($_REQUEST['term']); $verb = escape_tags($_REQUEST['verb']); - $profile_guid = escape_tags($_REQUEST['profile']); + $profile_guid = escape_tags($_REQUEST['profile_assign']); $url = $_REQUEST['link']; $photo = $_REQUEST['img']; @@ -99,6 +102,7 @@ function thing_init(&$a) { $p = q("select profile_guid, is_default from profile where uid = %d $sql limit 1", intval(local_user()) ); + if($p) $profile = $p[0]; else @@ -209,7 +213,6 @@ function thing_init(&$a) { } $ret = post_activity_item($arr); - } -- cgit v1.2.3 From 7f3f981d96338093ed8a01597e80916c6d8ea212 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 11 Feb 2014 20:45:17 -0800 Subject: fix a mysql error which popped up in the dbfail log --- mod/thing.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 9b362cecd..2620d660e 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -199,14 +199,14 @@ function thing_init(&$a) { if(! $profile['is_default']) { $arr['item_private'] = true; $str = ''; - $r = q("select abook_hash from abook where abook_channel = %d and abook_profile = '%s'", + $r = q("select abook_xchan from abook where abook_channel = %d and abook_profile = '%s'", intval(local_user()), dbesc($profile_guid) ); if($r) { $arr['allow_cid'] = ''; foreach($r as $rr) - $arr['allow_cid'] .= '<' . $rr['abook_hash'] . '>'; + $arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>'; } else $arr['allow_cid'] = '<' . get_observer_hash() . '>'; -- cgit v1.2.3 From 2c1b366fdf18929e255a223bc88474b446eaafa8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 12 Feb 2014 14:44:27 -0800 Subject: make activities optional for profile things, clean up the forms --- mod/thing.php | 93 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 44 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index 2620d660e..cbf83fdf8 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -19,6 +19,7 @@ function thing_init(&$a) { $name = escape_tags($_REQUEST['term']); $verb = escape_tags($_REQUEST['verb']); + $activity = intval($_REQUEST['activity']); $profile_guid = escape_tags($_REQUEST['profile_assign']); $url = $_REQUEST['link']; $photo = $_REQUEST['img']; @@ -160,60 +161,62 @@ function thing_init(&$a) { info( t('Thing added')); - $arr = array(); - $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); - if($local_photo) - $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); + if($activity) { + $arr = array(); + $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); + if($local_photo) + $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); - $objtype = ACTIVITY_OBJ_THING; - - $obj = json_encode(array( - 'type' => $objtype, - 'id' => $term['url'], - 'link' => $links, - 'title' => $term['term'], - 'content' => $term['term'] - )); - - $bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s')); - - $arr['owner_xchan'] = $channel['channel_hash']; - $arr['author_xchan'] = $channel['channel_hash']; + $objtype = ACTIVITY_OBJ_THING; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; - - $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; - $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; + $obj = json_encode(array( + 'type' => $objtype, + 'id' => $term['url'], + 'link' => $links, + 'title' => $term['term'], + 'content' => $term['term'] + )); - $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); + $bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s')); - if($local_photo) - $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]"; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $channel['channel_hash']; - $arr['verb'] = $verb; - $arr['obj_type'] = $objtype; - $arr['object'] = $obj; - if(! $profile['is_default']) { - $arr['item_private'] = true; - $str = ''; - $r = q("select abook_xchan from abook where abook_channel = %d and abook_profile = '%s'", - intval(local_user()), - dbesc($profile_guid) - ); - if($r) { - $arr['allow_cid'] = ''; - foreach($r as $rr) - $arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>'; - } - else - $arr['allow_cid'] = '<' . get_observer_hash() . '>'; - } + $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; - $ret = post_activity_item($arr); + $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; + $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; + + $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); + + if($local_photo) + $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]"; + + $arr['verb'] = $verb; + $arr['obj_type'] = $objtype; + $arr['object'] = $obj; + + if(! $profile['is_default']) { + $arr['item_private'] = true; + $str = ''; + $r = q("select abook_xchan from abook where abook_channel = %d and abook_profile = '%s'", + intval(local_user()), + dbesc($profile_guid) + ); + if($r) { + $arr['allow_cid'] = ''; + foreach($r as $rr) + $arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>'; + } + else + $arr['allow_cid'] = '<' . get_observer_hash() . '>'; + } + $ret = post_activity_item($arr); + } } @@ -269,6 +272,7 @@ function thing_content(&$a) { '$profile_select' => contact_profile_assign($r[0]['obj_page']), '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), '$verb_select' => obj_verb_selector($r[0]['obj_verb']), + '$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'], @@ -314,6 +318,7 @@ function thing_content(&$a) { '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign(''), '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$verb_select' => obj_verb_selector(), '$thing_lbl' => t('Name of thing e.g. something'), '$url_lbl' => t('URL of thing (optional)'), -- cgit v1.2.3 From b2feb264928908677e4c2b8de4722a2dc93d5ffa Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Jun 2014 17:05:03 -0700 Subject: clean up the awful descriptive text on thing input --- mod/thing.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mod/thing.php') diff --git a/mod/thing.php b/mod/thing.php index cbf83fdf8..b6d59a3ee 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -243,12 +243,15 @@ function thing_content(&$a) { } } - if(! local_user()) { + $channel = $a->get_channel(); + + if(! (local_user() && $channel)) { notice( t('Permission denied.') . EOL); return; } $thing_hash = ''; + if(argc() == 3 && argv(1) === 'edit') { $thing_hash = argv(2); @@ -270,7 +273,7 @@ function thing_content(&$a) { '$multiprof' => feature_enabled(local_user(),'multi_profiles'), '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign($r[0]['obj_page']), - '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_lbl' => $channel['channel_name'], '$verb_select' => obj_verb_selector($r[0]['obj_verb']), '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$thing_hash' => $thing_hash, @@ -317,7 +320,7 @@ function thing_content(&$a) { '$multiprof' => feature_enabled(local_user(),'multi_profiles'), '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign(''), - '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_lbl' => $channel['channel_name'], '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$verb_select' => obj_verb_selector(), '$thing_lbl' => t('Name of thing e.g. something'), -- cgit v1.2.3