make activities optional for profile things, clean up the forms

This commit is contained in:
friendica 2014-02-12 14:44:27 -08:00
parent 1ca85abf83
commit 2c1b366fdf
4 changed files with 58 additions and 50 deletions

View File

@ -19,6 +19,7 @@ function thing_init(&$a) {
$name = escape_tags($_REQUEST['term']); $name = escape_tags($_REQUEST['term']);
$verb = escape_tags($_REQUEST['verb']); $verb = escape_tags($_REQUEST['verb']);
$activity = intval($_REQUEST['activity']);
$profile_guid = escape_tags($_REQUEST['profile_assign']); $profile_guid = escape_tags($_REQUEST['profile_assign']);
$url = $_REQUEST['link']; $url = $_REQUEST['link'];
$photo = $_REQUEST['img']; $photo = $_REQUEST['img'];
@ -160,60 +161,62 @@ function thing_init(&$a) {
info( t('Thing added')); info( t('Thing added'));
$arr = array();
$links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url'])); if($activity) {
if($local_photo) $arr = array();
$links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo); $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; $objtype = ACTIVITY_OBJ_THING;
$obj = json_encode(array( $obj = json_encode(array(
'type' => $objtype, 'type' => $objtype,
'id' => $term['url'], 'id' => $term['url'],
'link' => $links, 'link' => $links,
'title' => $term['term'], 'title' => $term['term'],
'content' => $term['term'] 'content' => $term['term']
)); ));
$bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s')); $bodyverb = str_replace('OBJ: ', '',t('OBJ: %1$s %2$s %3$s'));
$arr['owner_xchan'] = $channel['channel_hash']; $arr['owner_xchan'] = $channel['channel_hash'];
$arr['author_xchan'] = $channel['channel_hash']; $arr['author_xchan'] = $channel['channel_hash'];
$arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP;
$ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
$plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]'; $plink = '[zrl=' . $term['url'] . ']' . $term['term'] . '[/zrl]';
$arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink ); $arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink );
if($local_photo) if($local_photo)
$arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]"; $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]";
$arr['verb'] = $verb; $arr['verb'] = $verb;
$arr['obj_type'] = $objtype; $arr['obj_type'] = $objtype;
$arr['object'] = $obj; $arr['object'] = $obj;
if(! $profile['is_default']) { if(! $profile['is_default']) {
$arr['item_private'] = true; $arr['item_private'] = true;
$str = ''; $str = '';
$r = q("select abook_xchan 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()), intval(local_user()),
dbesc($profile_guid) dbesc($profile_guid)
); );
if($r) { if($r) {
$arr['allow_cid'] = ''; $arr['allow_cid'] = '';
foreach($r as $rr) foreach($r as $rr)
$arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>'; $arr['allow_cid'] .= '<' . $rr['abook_xchan'] . '>';
}
else
$arr['allow_cid'] = '<' . get_observer_hash() . '>';
} }
else
$arr['allow_cid'] = '<' . get_observer_hash() . '>'; $ret = post_activity_item($arr);
} }
$ret = post_activity_item($arr);
} }
@ -269,6 +272,7 @@ function thing_content(&$a) {
'$profile_select' => contact_profile_assign($r[0]['obj_page']), '$profile_select' => contact_profile_assign($r[0]['obj_page']),
'$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'),
'$verb_select' => obj_verb_selector($r[0]['obj_verb']), '$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_hash' => $thing_hash,
'$thing_lbl' => t('Name of thing e.g. something'), '$thing_lbl' => t('Name of thing e.g. something'),
'$thething' => $r[0]['term'], '$thething' => $r[0]['term'],
@ -314,6 +318,7 @@ function thing_content(&$a) {
'$profile_lbl' => t('Select a profile'), '$profile_lbl' => t('Select a profile'),
'$profile_select' => contact_profile_assign(''), '$profile_select' => contact_profile_assign(''),
'$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), '$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(), '$verb_select' => obj_verb_selector(),
'$thing_lbl' => t('Name of thing e.g. something'), '$thing_lbl' => t('Name of thing e.g. something'),
'$url_lbl' => t('URL of thing (optional)'), '$url_lbl' => t('URL of thing (optional)'),

View File

@ -4,22 +4,16 @@
margin-left: 0; margin-left: 0;
} }
.thing-verb-label {
margin-top: 15px;
}
.thing-verb { .thing-label, .field label, .thing-verb-label, .thing-profile-label{
margin-bottom: 15px;
}
.thing-label {
float: left; float: left;
width: 250px; width: 350px;
} }
.thing-input { .thing-input, .thing-verb, .thing-profile{
float: left; float: left;
margin-bottom: 15px; margin-bottom: 15px;
width: 400px;
} }
.thing-field-end { .thing-field-end {

View File

@ -6,11 +6,13 @@
<div class="thing-profile-label">{{$profile_lbl}}</div> <div class="thing-profile-label">{{$profile_lbl}}</div>
<div class="thing-profile">{{$profile_select}}</div> <div class="thing-profile">{{$profile_select}}</div>
<div class="thing-field-end"></div>
{{/if}} {{/if}}
<div class="thing-verb-label">{{$verb_lbl}}</div> <div class="thing-verb-label">{{$verb_lbl}}</div>
<div class="thing-verb">{{$verb_select}}</div> <div class="thing-verb">{{$verb_select}}</div>
<div class="thing-field-end"></div>
<label class="thing-label" for="thing-term">{{$thing_lbl}}</label> <label class="thing-label" for="thing-term">{{$thing_lbl}}</label>
@ -23,6 +25,8 @@
<input type="text" class="thing-input" id="thing-img" name="img" value="{{$imgurl}}" /> <input type="text" class="thing-input" id="thing-img" name="img" value="{{$imgurl}}" />
<div class="thing-field-end"></div> <div class="thing-field-end"></div>
{{include file="field_checkbox.tpl" field=$activity}}
<div class="thing-end"></div> <div class="thing-end"></div>
<input type="submit" class="thing-submit" name="submit" value="{{$submit}}" /> <input type="submit" class="thing-submit" name="submit" value="{{$submit}}" />

View File

@ -5,11 +5,14 @@
<div class="thing-profile-label">{{$profile_lbl}}</div> <div class="thing-profile-label">{{$profile_lbl}}</div>
<div class="thing-profile">{{$profile_select}}</div> <div class="thing-profile">{{$profile_select}}</div>
<div class="thing-field-end"></div>
{{/if}} {{/if}}
<div class="thing-verb-label">{{$verb_lbl}}</div> <div class="thing-verb-label">{{$verb_lbl}}</div>
<div class="thing-verb">{{$verb_select}}</div> <div class="thing-verb">{{$verb_select}}</div>
<div class="thing-field-end"></div>
<label class="thing-label" for="thing-term">{{$thing_lbl}}</label> <label class="thing-label" for="thing-term">{{$thing_lbl}}</label>
@ -22,6 +25,8 @@
<input type="text" class="thing-input" id="thing-img" name="img" /> <input type="text" class="thing-input" id="thing-img" name="img" />
<div class="thing-field-end"></div> <div class="thing-field-end"></div>
{{include file="field_checkbox.tpl" field=$activity}}
<div class="thing-end"></div> <div class="thing-end"></div>
<input type="submit" class="thing-submit" name="submit" value="{{$submit}}" /> <input type="submit" class="thing-submit" name="submit" value="{{$submit}}" />