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 +++++++++++++++++++++++++----------------------- view/css/mod_thing.css | 14 +++----- view/tpl/thing_edit.tpl | 4 +++ view/tpl/thing_input.tpl | 5 +++ 4 files changed, 62 insertions(+), 54 deletions(-) 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)'), diff --git a/view/css/mod_thing.css b/view/css/mod_thing.css index 2a2ba7c92..125230b38 100644 --- a/view/css/mod_thing.css +++ b/view/css/mod_thing.css @@ -4,22 +4,16 @@ margin-left: 0; } -.thing-verb-label { - margin-top: 15px; -} - -.thing-verb { - margin-bottom: 15px; -} -.thing-label { +.thing-label, .field label, .thing-verb-label, .thing-profile-label{ float: left; - width: 250px; + width: 350px; } -.thing-input { +.thing-input, .thing-verb, .thing-profile{ float: left; margin-bottom: 15px; + width: 400px; } .thing-field-end { diff --git a/view/tpl/thing_edit.tpl b/view/tpl/thing_edit.tpl index 8379c15ae..b170f152c 100644 --- a/view/tpl/thing_edit.tpl +++ b/view/tpl/thing_edit.tpl @@ -6,11 +6,13 @@
{{$profile_lbl}}
{{$profile_select}}
+
{{/if}}
{{$verb_lbl}}
{{$verb_select}}
+
@@ -23,6 +25,8 @@
+{{include file="field_checkbox.tpl" field=$activity}} +
diff --git a/view/tpl/thing_input.tpl b/view/tpl/thing_input.tpl index 06cbfe917..e93a1aa65 100644 --- a/view/tpl/thing_input.tpl +++ b/view/tpl/thing_input.tpl @@ -5,11 +5,14 @@
{{$profile_lbl}}
{{$profile_select}}
+
{{/if}} +
{{$verb_lbl}}
{{$verb_select}}
+
@@ -22,6 +25,8 @@
+{{include file="field_checkbox.tpl" field=$activity}} +
-- cgit v1.2.3