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 --- include/taxonomy.php | 10 +++++++++ mod/thing.php | 56 +++++++++++++++++++++++++++++++++++++----------- view/css/mod_thing.css | 27 +++++++++++++++++++++++ view/tpl/thing_input.tpl | 28 ++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 view/css/mod_thing.css create mode 100644 view/tpl/thing_input.tpl diff --git a/include/taxonomy.php b/include/taxonomy.php index 70c2ad3e0..b6803743a 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -196,3 +196,13 @@ function obj_verbs() { } +function obj_verb_selector() { + $verbs = obj_verbs(); + $o .= ''; + return $o; + +} \ No newline at end of file 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; } diff --git a/view/css/mod_thing.css b/view/css/mod_thing.css new file mode 100644 index 000000000..2a2ba7c92 --- /dev/null +++ b/view/css/mod_thing.css @@ -0,0 +1,27 @@ + + +.thing-profile #contact-profile-selector { + margin-left: 0; +} + +.thing-verb-label { + margin-top: 15px; +} + +.thing-verb { + margin-bottom: 15px; +} + +.thing-label { + float: left; + width: 250px; +} + +.thing-input { + float: left; + margin-bottom: 15px; +} + +.thing-field-end { + clear: both; +} \ No newline at end of file diff --git a/view/tpl/thing_input.tpl b/view/tpl/thing_input.tpl new file mode 100644 index 000000000..06cbfe917 --- /dev/null +++ b/view/tpl/thing_input.tpl @@ -0,0 +1,28 @@ +

{{$thing_hdr}}

+
+ +{{if $multiprof }} +
{{$profile_lbl}}
+ +
{{$profile_select}}
+{{/if}} + +
{{$verb_lbl}}
+ +
{{$verb_select}}
+ + + + +
+ + +
+ + +
+ +
+ + +
-- cgit v1.2.3