From 42d5d515b25e1bf0068da6bbf4ffef2374f02617 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 3 Jul 2013 16:55:57 -0700 Subject: birthday error checking - if year is present but no month or day, set to 1 January. Otherwise the date will be set to 30 November the prior year due to how the PHP strtotime() function works. --- mod/profiles.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 28d8dd973..173d97138 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -200,6 +200,11 @@ function profiles_post(&$a) { $day = intval($_POST['day']); if(($day > $mtab[$month]) || ($day < 0)) $day = 0; + + if($year && (! ($month && $day))) { + $month = 1; $day = 1; + } + $dob = '0000-00-00'; $dob = sprintf('%04d-%02d-%02d',$year,$month,$day); -- cgit v1.2.3 From 1af5ecf1af7111020d99a7f274e7fed2bbc663f1 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 3 Jul 2013 17:22:40 -0700 Subject: tag cloud tweaking - allow your own comments, disallow all private posts --- mod/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 5d4c7ce1b..c7b631c96 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -48,7 +48,7 @@ function channel_aside(&$a) { $a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/channel/' . $a->profile['channel_address'],$cat)); } if(feature_enabled($a->profile['profile_uid'],'tagadelic')) - $a->set_widget('tagcloud',tagblock('search',$a->profile['profile_uid'],50,ITEM_WALL|ITEM_THREAD_TOP)); + $a->set_widget('tagcloud',tagblock('search',$a->profile['profile_uid'],50,$a->profile['channel_hash'],ITEM_WALL)); } -- 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') 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') 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') 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') 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 6e880cfd4954c4a044358a823fac4dc9d5467a6b Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 7 Jul 2013 17:22:40 -0700 Subject: use current channel photo for favicon where applicable - might be browser dependent but seems to work on FF --- mod/connections.php | 5 +++++ mod/message.php | 1 + mod/network.php | 3 +++ mod/settings.php | 5 +++++ 4 files changed, 14 insertions(+) (limited to 'mod') diff --git a/mod/connections.php b/mod/connections.php index 89c0bcbc0..1b97412d4 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -23,6 +23,11 @@ function connections_init(&$a) { $a->data['abook'] = $r[0]; } } + + $channel = $a->get_channel(); + if($channel) + head_set_icon($channel['xchan_photo_s']); + } function connections_aside(&$a) { diff --git a/mod/message.php b/mod/message.php index 54615f081..f5a2101ab 100644 --- a/mod/message.php +++ b/mod/message.php @@ -206,6 +206,7 @@ function message_content(&$a) { } $channel = $a->get_channel(); + head_set_icon($channel['xchan_photo_s']); $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array( diff --git a/mod/network.php b/mod/network.php index aa134eece..0f4b4f7e8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -7,6 +7,9 @@ function network_init(&$a) { notice( t('Permission denied.') . EOL); return; } + + $channel = $a->get_channel(); + head_set_icon($channel['xchan_photo_s']); $is_a_date_query = false; diff --git a/mod/settings.php b/mod/settings.php index e830d7070..164a2a8a0 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -580,6 +580,11 @@ function settings_content(&$a) { return; } + + $channel = $a->get_channel(); + if($channel) + head_set_icon($channel['xchan_photo_s']); + // if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) { // notice( t('Permission denied.') . EOL ); // return; -- cgit v1.2.3