aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-07-04 20:35:42 -0700
committerfriendica <info@friendica.com>2013-07-04 20:35:42 -0700
commit8b9f2f8ef766c169e77a34c72118d14beb2b21de (patch)
tree4ccdac7beb859d368eb02f8436cf38e036683383
parent08258da9444a94708426cf2d445e60b21dbbe84a (diff)
downloadvolse-hubzilla-8b9f2f8ef766c169e77a34c72118d14beb2b21de.tar.gz
volse-hubzilla-8b9f2f8ef766c169e77a34c72118d14beb2b21de.tar.bz2
volse-hubzilla-8b9f2f8ef766c169e77a34c72118d14beb2b21de.zip
input form for profile stuff
-rw-r--r--include/taxonomy.php10
-rw-r--r--mod/thing.php56
-rw-r--r--view/css/mod_thing.css27
-rw-r--r--view/tpl/thing_input.tpl28
4 files changed, 108 insertions, 13 deletions
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 .= '<select class="obj-verb-selector" name="verb" >';
+ foreach($verbs as $k => $v) {
+ $o .= '<option value="' . urlencode($k) . '">' . $v[0] . '</option>';
+ }
+ $o .= '</select>';
+ 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 @@
+<h2>{{$thing_hdr}}</h2>
+<form action="thing" method="post" >
+
+{{if $multiprof }}
+<div class="thing-profile-label">{{$profile_lbl}}</div>
+
+<div class="thing-profile">{{$profile_select}}</div>
+{{/if}}
+
+<div class="thing-verb-label">{{$verb_lbl}}</div>
+
+<div class="thing-verb">{{$verb_select}}</div>
+
+
+<label class="thing-label" for="thing-term">{{$thing_lbl}}</label>
+<input type="text" class="thing-input" id="thing-term" name="term" />
+<div class="thing-field-end"></div>
+<label class="thing-label" for="thing-url">{{$url_lbl}}</label>
+<input type="text" class="thing-input" id="thing-url" name="url" />
+<div class="thing-field-end"></div>
+<label class="thing-label" for="thing-img">{{$img_lbl}}</label>
+<input type="text" class="thing-input" id="thing-img" name="img" />
+<div class="thing-field-end"></div>
+
+<div class="thing-end"></div>
+
+<input type="submit" class="thing-submit" name="submit" value="{{$submit}}" />
+</form>