]> git.mxchange.org Git - friendica.git/commitdiff
birthday notifications working
authorFriendika <info@friendika.com>
Fri, 14 Jan 2011 04:28:33 +0000 (20:28 -0800)
committerFriendika <info@friendika.com>
Fri, 14 Jan 2011 04:28:33 +0000 (20:28 -0800)
boot.php
include/auth.php
index.php
mod/openid.php
mod/profile.php
view/theme/default/style.css
view/theme/duepuntozero/style.css

index 46c5144815b8e54283f31680e3b8b26c63cc7ab0..7e71a38d9e07de55d423af40e7deced7efb32a76 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -182,6 +182,7 @@ class App {
        public  $strings;   
        public  $path;
        public  $hooks;
+       public  $timezone;
        public  $interactive = true;
 
 
@@ -2118,3 +2119,60 @@ function call_hooks($name, &$data = null) {
        }
 }}
 
+
+if(! function_exists('day_translate')) {
+function day_translate($s) {
+       $ret = str_replace(array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'),
+               array( t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'), t('Sunday')),
+               $s);
+
+       $ret = str_replace(array('January','February','March','April','May','June','July','August','September','October','November','December'),
+               array( t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December')),
+               $ret);
+
+       return $ret;
+}}
+
+if(! function_exists('get_birthdays')) {
+function get_birthdays() {
+
+       $a = get_app();
+       $o = '';
+
+       if(! local_user())
+               return $o;
+
+       $bd_format = get_config('system','birthday_format');
+       if(! $bd_format)
+               $bd_format = 'g A l F d' ; // 8 AM Friday January 18
+
+       $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` 
+               LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` 
+               WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' 
+               ORDER BY `start` DESC ",
+               intval(local_user()),
+               dbesc(datetime_convert('UTC','UTC','now + 6 days')),
+               dbesc(datetime_convert('UTC','UTC','now'))
+       );
+
+       if($r && count($r)) {
+               $o .= '<div id="birthday-wrapper"><div id="birthday-title">' . t('Birthdays this week:') . '</div>'; 
+               $o .= '<div id="birthday-adjust">' . t("\x28Adjusted for local time\x29") . '</div>';
+               $o .= '<div id="birthday-title-end"></div>';
+
+               foreach($r as $rr) {
+                       $now = strtotime('now');
+                       $today = (((strtotime($rr['start']) < $now) && (strtotime($rr['finish']) > $now)) ? true : false); 
+
+                       $o .= '<div class="birthday-list" id="birthday-' . $rr['eid'] . '"><a class="sparkle" href="' 
+                       . $a->get_baseurl() . '/redir/'  . $rr['cid'] . '">' . $rr['name'] . '</a> ' 
+                       . day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $bd_format)) . (($today) ?  ' ' . t('[today]') : '') ;
+               }
+
+               $o .= '</div>';
+       }
+
+  return $o;
+
+}}
+
index d2bcb68dc8caf6557c68e968d26484a6d1fa921a..a0244571b3fec5703c99a7d5832cc2c51f1f374e 100644 (file)
@@ -53,8 +53,11 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
                $a->user = $r[0];
                $_SESSION['theme'] = $a->user['theme'];
                $_SESSION['page_flags'] = $a->user['page-flags'];
-               if(strlen($a->user['timezone']))
+
+               if(strlen($a->user['timezone'])) {
                        date_default_timezone_set($a->user['timezone']);
+                       $a->timezone = $a->user['timezone'];
+               }
 
                $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
 
@@ -183,8 +186,11 @@ else {
 
                notice( t("Welcome back ") . $record['username'] . EOL);
                $a->user = $record;
-               if(strlen($a->user['timezone']))
+
+               if(strlen($a->user['timezone'])) {
                        date_default_timezone_set($a->user['timezone']);
+                       $a->timezone = $a->user['timezone'];
+               }
 
                $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
                        intval($_SESSION['uid']));
index 1c069678135f1dd82d420da5fd81b65f7b1950bd..ae6a578cb4a68bb9b1b6c02b6e6a675643ed4fb7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -71,7 +71,9 @@ if(! $install) {
 
 require_once("datetime.php");
 
-date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
+$a->timezone = (($default_timezone) ? $default_timezone : 'UTC');
+
+date_default_timezone_set($a->timezone);
 
 $a->init_pagehead();
 
index 91efbbbc421313e405e6eb2f3acdecf665f2e111..2e1025692d3a8285eff137a2fc0a7d8589700904 100644 (file)
@@ -72,8 +72,11 @@ function openid_content(&$a) {
 
                        notice( t("Welcome back ") . $r[0]['username'] . EOL);
                        $a->user = $r[0];
-                       if(strlen($a->user['timezone']))
+
+                       if(strlen($a->user['timezone'])) {
                                date_default_timezone_set($a->user['timezone']);
+                               $a->timezone = $a->user['timezone'];
+                       }
 
                        $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
                                intval($_SESSION['uid']));
index e8eee810bfb6a9ba686931abdb27548523d92067..9b8388177d5bdde811994aba5eb3e68d5295d19f 100644 (file)
@@ -228,6 +228,10 @@ function profile_content(&$a, $update = 0) {
 
        );
 
+
+       if($is_owner && ! $update)
+                       $o .= get_birthdays();
+
        $cmnt_tpl = load_view_file('view/comment_item.tpl');
 
        $like_tpl = load_view_file('view/like.tpl');
index 240ace89605a04daa8292b4754a4de71a2424869..fd14c6bddddfb70d9305fc4944f38a287ef3324b 100644 (file)
@@ -1957,3 +1957,27 @@ a.mail-list-link {
 #plugin-settings-link, #account-settings-link {
        margin-bottom: 25px;
 }
+
+
+#birthday-title {
+       float: left;
+       font-weight: bold;      
+}
+
+#birthday-adjust {
+       float: left;
+       font-size: 75%;
+       margin-left: 10px;
+}
+
+#birthday-title-end {
+       clear: both;
+}
+
+.birthday-list {
+       margin-left: 15px;
+}
+
+#birthday-wrapper {
+       margin-bottom: 15px;
+}
index f64ad3fb891bce81f47c679176e4499e500c3611..37670df01e4b5fc9b011d914ff5bd9ba0273a65b 100644 (file)
@@ -1854,3 +1854,27 @@ a.mail-list-link {
        font-size: 120%;
        font-weight: bold;
 }
+
+
+#birthday-title {
+       float: left;
+       font-weight: bold;      
+}
+
+#birthday-adjust {
+       float: left;
+       font-size: 75%;
+       margin-left: 10px;
+}
+
+#birthday-title-end {
+       clear: both;
+}
+
+.birthday-list {
+       margin-left: 15px;
+}
+
+#birthday-wrapper {
+       margin-bottom: 15px;
+}