From bbec7a1ed9e3b359d31d8b24de09043178d7dddb Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 24 Dec 2012 12:41:00 +0100 Subject: [PATCH 01/10] Vier: added template for vcard --- view/theme/vier/profile_vcard.tpl | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 view/theme/vier/profile_vcard.tpl diff --git a/view/theme/vier/profile_vcard.tpl b/view/theme/vier/profile_vcard.tpl new file mode 100644 index 0000000000..b982a20693 --- /dev/null +++ b/view/theme/vier/profile_vcard.tpl @@ -0,0 +1,64 @@ +
+ +
+
$profile.name
+ {{ if $profile.edit }} +
+ $profile.edit.1 + +
+ {{ endif }} +
+ + + +
$profile.name
+ {{ if $pdesc }}
$profile.pdesc
{{ endif }} + + + {{ if $location }} +
$location

+
+ {{ if $profile.address }}
$profile.address
{{ endif }} + + $profile.locality{{ if $profile.locality }}, {{ endif }} + $profile.region + $profile.postal-code + + {{ if $profile.country-name }}$profile.country-name{{ endif }} +
+
+ {{ endif }} + + {{ if $gender }}
$gender
$profile.gender
{{ endif }} + + {{ if $profile.pubkey }}{{ endif }} + + {{ if $marital }}
$marital
$profile.marital
{{ endif }} + + {{ if $homepage }}
$homepage
$profile.homepage
{{ endif }} + + {{ inc diaspora_vcard.tpl }}{{ endinc }} + + +
+ +$contact_block + + From 5bc68966715de22d1c837e91aec8a6d840d1eaa3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 25 Dec 2012 12:52:30 +0100 Subject: [PATCH 02/10] The caches are now cleared only once an hour. --- include/poller.php | 24 ++++++++++++++++++------ view/theme/vier/style.css | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/poller.php b/include/poller.php index 4eb5e8a2b9..113405dbbe 100644 --- a/include/poller.php +++ b/include/poller.php @@ -99,14 +99,26 @@ function poller_run(&$argv, &$argc){ proc_run('php','include/expire.php'); } - // clear old cache - Cache::clear(); + $last = get_config('system','cache_last_cleared'); - // clear old item cache files - clear_cache(); + if($last) { + $next = $last + (3600); // Once per hour + $clear_cache = ($next <= time()); + } else + $clear_cache = true; - // clear cache for photos - clear_cache($a->get_basepath(), $a->get_basepath()."/photo"); + if ($clear_cache) { + // clear old cache + Cache::clear(); + + // clear old item cache files + clear_cache(); + + // clear cache for photos + clear_cache($a->get_basepath(), $a->get_basepath()."/photo"); + + set_config('system','cache_last_cleared', time()); + } $manual_id = 0; $generation = 0; diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index ffd50ed146..5532c06eee 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1689,7 +1689,7 @@ div.pager, .birthday-notice, ul.tabs a, #jot-preview-link, .comment-edit-submit- border: 1px solid lightgray; color: black; background: #F2F2F2; - padding: 3px 7px 2px 7px; + padding: 2px 7px 2px 7px; margin-top: 2px; margin-bottom: 2px; From 763504f0d530f8fbe3ccedbf877eae71838644b9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 27 Dec 2012 01:05:59 +0100 Subject: [PATCH 03/10] Vier: Now the language of a post is shown --- object/Item.php | 18 ++++++++++++------ view/theme/vier/profile_vcard.tpl | 5 +++-- view/theme/vier/style.css | 20 +++++++++++++++----- view/theme/vier/wall_thread.tpl | 8 +++++--- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/object/Item.php b/object/Item.php index 0c84146f9b..5cea341f02 100644 --- a/object/Item.php +++ b/object/Item.php @@ -115,10 +115,10 @@ class Item extends BaseObject { $drop = array( 'dropping' => $dropping, 'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''), - 'select' => t('Select'), + 'select' => t('Select'), 'delete' => t('Delete'), ); - + $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false); $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); @@ -133,7 +133,7 @@ class Item extends BaseObject { if($sp) $sparkle = ' sparkle'; else - $profile_link = zrl($profile_link); + $profile_link = zrl($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) @@ -212,13 +212,18 @@ class Item extends BaseObject { localize_item($item); + if ($item["postopts"]) { + $langdata = explode(";", $item["postopts"]); + $langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; + } + $body = prepare_body($item,true); - list($categories, $folders) = get_cats_and_terms($item); + list($categories, $folders) = get_cats_and_terms($item); $tmp_item = array( 'template' => $this->get_template(), - + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'tags' => $tags, 'hashtags' => $hashtags, @@ -268,7 +273,8 @@ class Item extends BaseObject { 'comment' => $this->get_comment_box($indent), 'previewing' => ($conv->is_preview() ? ' preview ' : ''), 'wait' => t('Please wait'), - 'thread_level' => $thread_level + 'thread_level' => $thread_level, + 'postopts' => $langstr ); $arr = array('item' => $item, 'output' => $tmp_item); diff --git a/view/theme/vier/profile_vcard.tpl b/view/theme/vier/profile_vcard.tpl index b982a20693..451bf9dabd 100644 --- a/view/theme/vier/profile_vcard.tpl +++ b/view/theme/vier/profile_vcard.tpl @@ -17,10 +17,11 @@ + {{ else }} +
{{ endif }} - - +
$profile.name
{{ if $pdesc }}
$profile.pdesc
{{ endif }} diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 5532c06eee..9524c73cab 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1067,8 +1067,9 @@ border-bottom: 1px solid #D2D2D2; text-align: left; width: 80px; } -.wall-item-container .wall-item-location { - padding-right: 40px; +.wall-item-container { + /* padding-right: 30px; */ + padding-right: 0px; } .wall-item-container .wall-item-ago { word-wrap: break-word; @@ -1077,7 +1078,7 @@ border-bottom: 1px solid #D2D2D2; color: #999; } .wall-item-location { - width: 180px; + width: 350px; float: left; } @@ -1282,6 +1283,10 @@ border-bottom: 1px solid #D2D2D2; height: 100px; } +#profile-jot-perms { + float: right; +} + #jot-preview-content { padding-top: 25px; } @@ -1816,10 +1821,15 @@ div.pager, .birthday-notice, ul.tabs a, #jot-preview-link, .comment-edit-submit- } .profile-edit-side-div { - display: none; -/* float: right; */ +/* display: none; */ + float: right; } +/* aside div.clear { + clear: none; + float: left; +} */ + #register-form label, #profile-edit-form label { width: 300px; float: left; diff --git a/view/theme/vier/wall_thread.tpl b/view/theme/vier/wall_thread.tpl index d535704605..366493a686 100644 --- a/view/theme/vier/wall_thread.tpl +++ b/view/theme/vier/wall_thread.tpl @@ -111,7 +111,7 @@ {{ endif }} -
$item.location
+
$item.location $item.postopts
{{ if $item.drop.pagedrop }} @@ -128,14 +128,16 @@
- +
$item.dislike
{{ if $item.threaded }}{{ if $item.comment }}
- + From 6f6b1f95c855eb1e06aa73aaab8ddefd8eb970da Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 28 Dec 2012 11:31:30 +0100 Subject: [PATCH 04/10] vier: With IE there are no borders around images anymore bbcode: Multiple new lines are now reduced --- include/bbcode.php | 10 ++++++++++ view/theme/vier/style.css | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/bbcode.php b/include/bbcode.php index 384fd5ebd9..08edc19340 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -310,6 +310,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // remove some newlines before the general conversion $Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text); + $Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text); // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems if (!$tryoembed) @@ -324,6 +325,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = trim($Text); $Text = str_replace("\r\n","\n", $Text); + + // removing multiplicated newlines + $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]"); + $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]"); + do { + $oldtext = $Text; + $Text = str_replace($search, $replace, $Text); + } while ($oldtext != $Text); + $Text = str_replace(array("\r","\n"), array('
','
'), $Text); if($preserve_nl) diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 9524c73cab..1701e8ac4c 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -7,6 +7,10 @@ @import url("css/font-awesome.css") all; @import url("css/font2.css") all; +img { + border: 0px; +} + /* ========= */ /* = Admin = */ /* ========= */ From ad287914c796c1512c3ff2385873ad111aa72d89 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 30 Dec 2012 21:30:39 +0100 Subject: [PATCH 05/10] Support of "share" through the API. --- include/api.php | 15 +++++++++++++-- view/theme/vier/style.css | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/api.php b/include/api.php index 667629e139..555315bd86 100644 --- a/include/api.php +++ b/include/api.php @@ -944,7 +944,7 @@ //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`, - `contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item`, `contact` @@ -957,7 +957,18 @@ ); if ($r[0]['body'] != "") { - $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body']; + if (intval(get_config('system','new_share'))) { + $post = "[share author='".str_replace("'", "'", $r[0]['reply_author']). + "' profile='".$r[0]['reply_url']. + "' avatar='".$r[0]['reply_photo']. + "' link='".$r[0]['plink']."']"; + + $post .= $r[0]['body']; + $post .= "[/share]"; + $_REQUEST['body'] = $post; + } else + $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body']; + $_REQUEST['profile_uid'] = api_user(); $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 1701e8ac4c..f97fc2f590 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1258,7 +1258,8 @@ border-bottom: 1px solid #D2D2D2; #profile-jot-form #profile-jot-text { height: 2.0em; - width: 99%; + /* width: 99%; */ + width: 752px; font-size: 15px; color: #999999; border: 1px solid #DDD; @@ -1272,7 +1273,8 @@ border-bottom: 1px solid #D2D2D2; font-weight: bold; height: 20px; margin: 0 0 5px; - width: 60%; + /* width: 60%; */ + width: 762px; border: 1px solid #d2d2d2; } From 348f43157ae3733b572e420ada9883ae34826328 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 30 Dec 2012 22:58:05 +0100 Subject: [PATCH 06/10] Vier: Some templates were missing --- .gitignore | 9 ++- view/theme/vier/profile_edlink.tpl | 1 + view/theme/vier/smarty3/profile_edlink.tpl | 1 + view/theme/vier/smarty3/profile_vcard.tpl | 65 ++++++++++++++++++++++ view/theme/vier/smarty3/wall_thread.tpl | 8 ++- 5 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 view/theme/vier/profile_edlink.tpl create mode 100644 view/theme/vier/smarty3/profile_edlink.tpl create mode 100644 view/theme/vier/smarty3/profile_vcard.tpl diff --git a/.gitignore b/.gitignore index 358114a444..038ac32a55 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,11 @@ report/ #ignore OSX .DS_Store files .DS_Store -/nbproject/private/ \ No newline at end of file +/nbproject/private/ + +#ignore smarty cache +/view/smarty3/compiled/ + +#ignore cache folders +/privacy_image_cache/ +/photo/ diff --git a/view/theme/vier/profile_edlink.tpl b/view/theme/vier/profile_edlink.tpl new file mode 100644 index 0000000000..5bdbb834a5 --- /dev/null +++ b/view/theme/vier/profile_edlink.tpl @@ -0,0 +1 @@ +
diff --git a/view/theme/vier/smarty3/profile_edlink.tpl b/view/theme/vier/smarty3/profile_edlink.tpl new file mode 100644 index 0000000000..5bdbb834a5 --- /dev/null +++ b/view/theme/vier/smarty3/profile_edlink.tpl @@ -0,0 +1 @@ +
diff --git a/view/theme/vier/smarty3/profile_vcard.tpl b/view/theme/vier/smarty3/profile_vcard.tpl new file mode 100644 index 0000000000..b02a3a5c69 --- /dev/null +++ b/view/theme/vier/smarty3/profile_vcard.tpl @@ -0,0 +1,65 @@ +
+ +
+
{{$profile.name}}
+ {{if $profile.edit}} +
+ {{$profile.edit.1}} + +
+ {{else}} +
+ {{/if}} +
+ + +
{{$profile.name}}
+ {{if $pdesc}}
{{$profile.pdesc}}
{{/if}} + + + {{if $location}} +
{{$location}}

+
+ {{if $profile.address}}
{{$profile.address}}
{{/if}} + + {{$profile.locality}}{{if $profile.locality}}, {{/if}} + {{$profile.region}} + {{$profile.postal-code}} + + {{if $profile.country-name}}{{$profile.country-name}}{{/if}} +
+
+ {{/if}} + + {{if $gender}}
{{$gender}}
{{$profile.gender}}
{{/if}} + + {{if $profile.pubkey}}{{/if}} + + {{if $marital}}
{{$marital}}
{{$profile.marital}}
{{/if}} + + {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} + + {{include file="diaspora_vcard.tpl"}} + + +
+ +{{$contact_block}} + + diff --git a/view/theme/vier/smarty3/wall_thread.tpl b/view/theme/vier/smarty3/wall_thread.tpl index 07a7a50f85..386164f18c 100644 --- a/view/theme/vier/smarty3/wall_thread.tpl +++ b/view/theme/vier/smarty3/wall_thread.tpl @@ -111,7 +111,7 @@ {{/if}}
-
{{$item.location}}
+
{{$item.location}} {{$item.postopts}}
{{if $item.drop.pagedrop}} @@ -128,14 +128,16 @@
- +
{{$item.dislike}}
{{if $item.threaded}}{{if $item.comment}}
- + From fdd142c42ef097912e8fad1dc200ea091d769c1e Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Thu, 3 Jan 2013 10:47:45 -0700 Subject: [PATCH 07/10] never use profile_load outside of a module's _init() function --- boot.php | 6 + mod/display.php | 12 +- mod/profile.php | 1 - mod/profiles.php | 263 +++++++++++++++++-------------- view/theme/cleanzero/theme.php | 3 +- view/theme/comix-plain/theme.php | 3 + view/theme/comix/theme.php | 3 + view/theme/darkbubble/theme.php | 2 + view/theme/darkzero-NS/theme.php | 4 +- view/theme/darkzero/theme.php | 2 +- view/theme/diabook/theme.php | 5 +- view/theme/dispy/dark/theme.php | 13 +- view/theme/dispy/light/theme.php | 13 +- view/theme/dispy/theme.php | 13 +- view/theme/easterbunny/theme.php | 3 + view/theme/facepark/theme.php | 4 + view/theme/greenzero/theme.php | 3 +- view/theme/purplezero/theme.php | 3 +- view/theme/quattro/theme.php | 2 +- view/theme/slack-NS/theme.php | 5 +- view/theme/slackr/theme.php | 3 +- view/theme/smoothly/theme.php | 7 +- view/theme/testbubble/theme.php | 3 + view/theme/vier/theme.php | 2 +- 24 files changed, 214 insertions(+), 164 deletions(-) diff --git a/boot.php b/boot.php index 864cdedd32..b19f0aa963 100644 --- a/boot.php +++ b/boot.php @@ -1107,6 +1107,10 @@ if(! function_exists('get_max_import_size')) { * Profile information is placed in the App structure for later retrieval. * Honours the owner's chosen theme for display. * + * IMPORTANT: Should only be run in the _init() functions of a module. That ensures that + * the theme is chosen before the _init() function of a theme is run, which will usually + * load a lot of theme-specific content + * */ if(! function_exists('profile_load')) { @@ -1185,6 +1189,8 @@ if(! function_exists('profile_load')) { * load/reload current theme info */ + set_template_engine($a); // reset the template engine to the default in case the user's theme doesn't specify one + $theme_info_file = "view/theme/".current_theme()."/theme.php"; if (file_exists($theme_info_file)){ require_once($theme_info_file); diff --git a/mod/display.php b/mod/display.php index 32c4bcae9f..2e0b8216a4 100644 --- a/mod/display.php +++ b/mod/display.php @@ -1,13 +1,22 @@ argc > 1) ? $a->argv[1] : ''); + profile_load($a,$nick); + +} + + +function display_content(&$a, $update = 0) { + require_once("include/bbcode.php"); require_once('include/security.php'); require_once('include/conversation.php'); @@ -25,7 +34,6 @@ function display_content(&$a, $update = 0) { else { $nick = (($a->argc > 1) ? $a->argv[1] : ''); } - profile_load($a,$nick); if($update) { $item_id = $_REQUEST['item_id']; diff --git a/mod/profile.php b/mod/profile.php index 9e9af19834..25871c2405 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -33,7 +33,6 @@ function profile_init(&$a) { auto_redir($a, $which); } - set_template_engine($a); // reset the template engine to the default in case the user's theme doesn't specify one profile_load($a,$which,$profile); $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); diff --git a/mod/profiles.php b/mod/profiles.php index eaa603a282..1fc1f484a3 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -1,6 +1,147 @@ argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) { + $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1", + intval($a->argv[2]), + intval(local_user()) + ); + if(! count($r)) { + notice( t('Profile not found.') . EOL); + goaway($a->get_baseurl(true) . '/profiles'); + return; // NOTREACHED + } + + check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't'); + + // move every contact using this profile as their default to the user default + + $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", + intval(local_user()), + intval($a->argv[2]), + intval(local_user()) + ); + $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($a->argv[2]), + intval(local_user()) + ); + if($r) + info( t('Profile deleted.') . EOL); + + goaway($a->get_baseurl(true) . '/profiles'); + return; // NOTREACHED + } + + + + + + if(($a->argc > 1) && ($a->argv[1] === 'new')) { + + check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); + + $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", + intval(local_user())); + $num_profiles = count($r0); + + $name = t('Profile-') . ($num_profiles + 1); + + $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + intval(local_user())); + + $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`) + VALUES ( %d, '%s', '%s', '%s', '%s' )", + intval(local_user()), + dbesc($name), + dbesc($r1[0]['name']), + dbesc($r1[0]['photo']), + dbesc($r1[0]['thumb']) + ); + + $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", + intval(local_user()), + dbesc($name) + ); + + info( t('New profile created.') . EOL); + if(count($r3) == 1) + goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); + + goaway($a->get_baseurl(true) . '/profiles'); + } + + if(($a->argc > 2) && ($a->argv[1] === 'clone')) { + + check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); + + $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", + intval(local_user())); + $num_profiles = count($r0); + + $name = t('Profile-') . ($num_profiles + 1); + $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1", + intval(local_user()), + intval($a->argv[2]) + ); + if(! count($r1)) { + notice( t('Profile unavailable to clone.') . EOL); + killme(); + return; + } + unset($r1[0]['id']); + $r1[0]['is-default'] = 0; + $r1[0]['publish'] = 0; + $r1[0]['net-publish'] = 0; + $r1[0]['profile-name'] = dbesc($name); + + dbesc_array($r1[0]); + + $r2 = dbq("INSERT INTO `profile` (`" + . implode("`, `", array_keys($r1[0])) + . "`) VALUES ('" + . implode("', '", array_values($r1[0])) + . "')" ); + + $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", + intval(local_user()), + dbesc($name) + ); + info( t('New profile created.') . EOL); + if(count($r3) == 1) + goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); + + goaway($a->get_baseurl(true) . '/profiles'); + + return; // NOTREACHED + } + + + if(($a->argc > 1) && (intval($a->argv[1]))) { + $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($a->argv[1]), + intval(local_user()) + ); + if(! count($r)) { + notice( t('Profile not found.') . EOL); + killme(); + return; + } + + profile_load($a,$a->user['nickname'],$r[0]['id']); + } + +} + function profiles_post(&$a) { if(! local_user()) { @@ -425,126 +566,6 @@ function profile_activity($changed, $value) { function profiles_content(&$a) { $o = ''; - nav_set_selected('profiles'); - - if(! local_user()) { - notice( t('Permission denied.') . EOL); - return; - } - - if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) { - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1", - intval($a->argv[2]), - intval(local_user()) - ); - if(! count($r)) { - notice( t('Profile not found.') . EOL); - goaway($a->get_baseurl(true) . '/profiles'); - return; // NOTREACHED - } - - check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't'); - - // move every contact using this profile as their default to the user default - - $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", - intval(local_user()), - intval($a->argv[2]), - intval(local_user()) - ); - $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[2]), - intval(local_user()) - ); - if($r) - info( t('Profile deleted.') . EOL); - - goaway($a->get_baseurl(true) . '/profiles'); - return; // NOTREACHED - } - - - - - - if(($a->argc > 1) && ($a->argv[1] === 'new')) { - - check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); - - $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", - intval(local_user())); - $num_profiles = count($r0); - - $name = t('Profile-') . ($num_profiles + 1); - - $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", - intval(local_user())); - - $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`) - VALUES ( %d, '%s', '%s', '%s', '%s' )", - intval(local_user()), - dbesc($name), - dbesc($r1[0]['name']), - dbesc($r1[0]['photo']), - dbesc($r1[0]['thumb']) - ); - - $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", - intval(local_user()), - dbesc($name) - ); - - info( t('New profile created.') . EOL); - if(count($r3) == 1) - goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); - - goaway($a->get_baseurl(true) . '/profiles'); - } - - if(($a->argc > 2) && ($a->argv[1] === 'clone')) { - - check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); - - $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", - intval(local_user())); - $num_profiles = count($r0); - - $name = t('Profile-') . ($num_profiles + 1); - $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1", - intval(local_user()), - intval($a->argv[2]) - ); - if(! count($r1)) { - notice( t('Profile unavailable to clone.') . EOL); - return; - } - unset($r1[0]['id']); - $r1[0]['is-default'] = 0; - $r1[0]['publish'] = 0; - $r1[0]['net-publish'] = 0; - $r1[0]['profile-name'] = dbesc($name); - - dbesc_array($r1[0]); - - $r2 = dbq("INSERT INTO `profile` (`" - . implode("`, `", array_keys($r1[0])) - . "`) VALUES ('" - . implode("', '", array_values($r1[0])) - . "')" ); - - $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", - intval(local_user()), - dbesc($name) - ); - info( t('New profile created.') . EOL); - if(count($r3) == 1) - goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); - - goaway($a->get_baseurl(true) . '/profiles'); - - return; // NOTREACHED - } - if(($a->argc > 1) && (intval($a->argv[1]))) { $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -556,8 +577,6 @@ function profiles_content(&$a) { return; } - profile_load($a,$a->user['nickname'],$r[0]['id']); - require_once('include/profile_selectors.php'); diff --git a/view/theme/cleanzero/theme.php b/view/theme/cleanzero/theme.php index 356a1b71cb..37ba15ce0a 100644 --- a/view/theme/cleanzero/theme.php +++ b/view/theme/cleanzero/theme.php @@ -5,12 +5,13 @@ * Version: * Author: Christian Vogeley (https://christian-vogeley.de/profile/christian) */ + +function cleanzero_init(&$a) { $a->theme_info = array( 'extends' => 'duepuntozero', ); set_template_engine($a, 'smarty3'); -function cleanzero_init(&$a) { $a->page['htmlhead'] .= <<< EOT EOT; +} + diff --git a/view/theme/comix/theme.php b/view/theme/comix/theme.php index ce28ebf189..da195f267a 100644 --- a/view/theme/comix/theme.php +++ b/view/theme/comix/theme.php @@ -8,6 +8,7 @@ */ +function comix_init(&$a) { $a->theme_info = array( 'extends' => 'duepuntozero', ); @@ -59,3 +60,5 @@ $('.savedsearchterm').hover( EOT; +} + diff --git a/view/theme/darkbubble/theme.php b/view/theme/darkbubble/theme.php index ecd14da772..475d4e63ce 100644 --- a/view/theme/darkbubble/theme.php +++ b/view/theme/darkbubble/theme.php @@ -7,6 +7,7 @@ */ +function darkbubble_init(&$a) { $a->theme_info = array( 'extends' => 'testbubble', ); @@ -21,3 +22,4 @@ $('html').click(function() { $("#nav-notifications-menu" ).hide(); }); }); EOT; +} diff --git a/view/theme/darkzero-NS/theme.php b/view/theme/darkzero-NS/theme.php index 211c552c51..ee227109b1 100644 --- a/view/theme/darkzero-NS/theme.php +++ b/view/theme/darkzero-NS/theme.php @@ -7,11 +7,11 @@ * Author: Mike Macgirvin */ +function darkzero_NS_init(&$a) { $a->theme_info = array( 'extends' => 'duepuntozero', ); -function darkzero_NS_init(&$a) { $a->page['htmlhead'] .= <<< EOT EOT; -} \ No newline at end of file +} diff --git a/view/theme/darkzero/theme.php b/view/theme/darkzero/theme.php index ceafdf5956..1fe4bf859c 100644 --- a/view/theme/darkzero/theme.php +++ b/view/theme/darkzero/theme.php @@ -8,12 +8,12 @@ * Maintainer: Mike Macgirvin */ +function darkzero_init(&$a) { $a->theme_info = array( 'extends' => 'duepuntozero', ); set_template_engine($a, 'smarty3'); -function darkzero_init(&$a) { $a->page['htmlhead'] .= <<< EOT EOT; +} + diff --git a/view/theme/greenzero/theme.php b/view/theme/greenzero/theme.php index 09a63c040d..9a3dd1d3e1 100644 --- a/view/theme/greenzero/theme.php +++ b/view/theme/greenzero/theme.php @@ -1,10 +1,11 @@ theme_info = array( 'extends' => 'duepuntozero', ); set_template_engine($a, 'smarty3'); -function greenzero_init(&$a) { $a->page['htmlhead'] .= <<< EOT EOT; -} \ No newline at end of file +} diff --git a/view/theme/slackr/theme.php b/view/theme/slackr/theme.php index bc09299794..43deb4b8cc 100644 --- a/view/theme/slackr/theme.php +++ b/view/theme/slackr/theme.php @@ -1,10 +1,11 @@ theme_info = array( 'extends' => 'duepuntozero', ); set_template_engine($a, 'smarty3'); -function slackr_init(&$a) { $a->page['htmlhead'] .= <<< EOT EOT; +} diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7c0f3d3f8d..7da0731f78 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -8,11 +8,11 @@ * Description: "Vier" uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/ */ +function vier_init(&$a) { set_template_engine($a, 'smarty3'); $a->theme_info = array(); -function vier_init(&$a) { $a->page['htmlhead'] .= <<< EOT