]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
typo
[friendica.git] / boot.php
index 9a7f038a1536d9d861901bb4e2c0d1a04a93195a..50cfbf66168755f96742ee5a2e2e29aea4a665fe 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -6,11 +6,12 @@ require_once('include/plugin.php');
 require_once('include/text.php');
 require_once("include/pgettext.php");
 require_once('include/nav.php');
+require_once('include/cache.php');
 
-define ( 'FRIENDIKA_PLATFORM',     'Free Friendika');
-define ( 'FRIENDIKA_VERSION',      '2.3.1141' );
-define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1097      );
+define ( 'FRIENDICA_PLATFORM',     'Friendica');
+define ( 'FRIENDICA_VERSION',      '2.3.1181' );
+define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    );
+define ( 'DB_UPDATE_VERSION',      1107      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -93,12 +94,14 @@ define ( 'PAGE_FREELOVE',          3 );
  */
 
 define ( 'NETWORK_ZOT',              'zot!');    // Zot!
-define ( 'NETWORK_DFRN',             'dfrn');    // Friendika, Mistpark, other DFRN implementations
+define ( 'NETWORK_DFRN',             'dfrn');    // Friendica, Mistpark, other DFRN implementations
 define ( 'NETWORK_OSTATUS',          'stat');    // status.net, identi.ca, GNU-social, other OStatus implementations
 define ( 'NETWORK_FEED',             'feed');    // RSS/Atom feeds with no known "post/notify" protocol
 define ( 'NETWORK_DIASPORA',         'dspr');    // Diaspora
 define ( 'NETWORK_MAIL',             'mail');    // IMAP/POP
 define ( 'NETWORK_FACEBOOK',         'face');    // Facebook API     
+define ( 'NETWORK_LINKEDIN',         'lnkd');    // LinkedIn
+define ( 'NETWORK_XMPP',             'xmpp');    // XMPP     
 
 
 /**
@@ -190,7 +193,7 @@ function startup() {
        set_time_limit(0);
 
        // This has to be quite large to deal with embedded private photos
-       ini_set('pcre.backtrack_limit', 350000);
+       ini_set('pcre.backtrack_limit', 500000);
 
 
        if (get_magic_quotes_gpc()) {
@@ -253,6 +256,8 @@ class App {
        public  $plugins;
        public  $apps = array();
        public  $identities;
+       
+       public $nav_sel;
 
        private $scheme;
        private $hostname;
@@ -412,9 +417,11 @@ class App {
                $tpl = file_get_contents('view/head.tpl');
                $this->page['htmlhead'] = replace_macros($tpl,array(
                        '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
-                       '$generator' => 'Friendika' . ' ' . FRIENDIKA_VERSION,
+                       '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
                        '$delitem' => t('Delete this item?'),
-                       '$comment' => t('Comment')
+                       '$comment' => t('Comment'),
+                       '$showmore' => t('show more'),
+                       '$showfewer' => t('show fewer')
                ));
        }
 
@@ -651,7 +658,7 @@ function get_guid($size=16) {
 // returns the complete html for inserting into the page
 
 if(! function_exists('login')) {
-function login($register = false) {
+function login($register = false, $hiddens=false) {
        $o = "";
        $reg = false;
        if ($register) {
@@ -682,6 +689,7 @@ function login($register = false) {
                '$openid'               => !$noid,
                '$lopenid'      => array('openid_url', t('OpenID: '),'',''),
                
+               '$hiddens'      => $hiddens,
                
                '$register'             => $reg,
                
@@ -792,17 +800,17 @@ function profile_load(&$a, $nickname, $profile = 0) {
 
        if($profile) {
                $profile_int = intval($profile);
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
+               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` 
+                       left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+                       WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
                        dbesc($nickname),
                        intval($profile_int)
                );
        }
        if(! count($r)) {       
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
+               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` 
+                       left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+                       WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
                        dbesc($nickname)
                );
        }
@@ -819,9 +827,24 @@ function profile_load(&$a, $nickname, $profile = 0) {
        $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
        $_SESSION['theme'] = $a->profile['theme'];
 
+       /**
+        * load/reload current theme info
+        */
+       $theme_info_file = "view/theme/".current_theme()."/theme.php";
+       if (file_exists($theme_info_file)){
+               require_once($theme_info_file);
+       }
+
        if(! (x($a->page,'aside')))
                $a->page['aside'] = '';
 
+       if(local_user() && local_user() == $a->profile['uid']) {
+               $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
+                       '$editprofile' => t('Edit profile'),
+                       '$profid' => $a->profile['id']
+               ));
+       }
+
        $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
 
        $a->page['aside'] .= profile_sidebar($a->profile, $block);
@@ -862,6 +885,8 @@ function profile_sidebar($profile, $block = 0) {
        if((! is_array($profile)) && (! count($profile)))
                return $o;
 
+       $profile['picdate'] = urlencode($profile['picdate']);
+
        call_hooks('profile_sidebar_enter', $profile);
 
        
@@ -936,7 +961,7 @@ function profile_sidebar($profile, $block = 0) {
        $diaspora = array(
                'podloc' => $a->get_baseurl(),
                'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
-               'nickname ' => $profile['nickname'],
+               'nickname' => $profile['nickname'],
                'fullname' => $profile['name'],
                'firstname' => $firstname,
                'lastname' => $lastname,
@@ -988,7 +1013,7 @@ function get_birthdays() {
        $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 ",
+               ORDER BY `start` ASC ",
                intval(local_user()),
                dbesc(datetime_convert('UTC','UTC','now + 6 days')),
                dbesc(datetime_convert('UTC','UTC','now'))
@@ -996,20 +1021,23 @@ function get_birthdays() {
 
        if($r && count($r)) {
                $total = 0;
-               foreach($r as $rr)
+               $now = strtotime('now');
+               $istoday = false;
+               foreach($r as $rr) {
                        if(strlen($rr['name']))
                                $total ++;
-
+                               if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
+                                       $istoday = true;
+               }
+               $classtoday = $istoday ? ' birthday-today ' : '';
                if($total) {
-                       $o .= '<div id="birthday-notice" class="birthday-notice fakelink" onclick=openClose(\'birthday-wrapper\'); >' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '</div>'; 
+                       $o .= '<div id="birthday-notice" class="birthday-notice fakelink' . $classtoday . '" onclick=openClose(\'birthday-wrapper\'); >' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '</div>'; 
                        $o .= '<div id="birthday-wrapper" style="display: none;" ><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) {
                                if(! strlen($rr['name']))
                                        continue;
-                               $now = strtotime('now');
                                $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); 
                                $sparkle = '';
                                $url = $rr['url'];
@@ -1030,6 +1058,70 @@ function get_birthdays() {
 }}
 
 
+if(! function_exists('get_events')) {
+function get_events() {
+
+       require_once('include/bbcode.php');
+
+       $a = get_app();
+       $o = '';
+
+       if(! local_user())
+               return $o;
+
+       $bd_format = t('g A l F d') ; // 8 AM Friday January 18
+       $bd_short = t('F d');
+
+       $r = q("SELECT `event`.* FROM `event` 
+               WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s'
+               ORDER BY `start` ASC ",
+               intval(local_user()),
+               dbesc(datetime_convert('UTC','UTC','now + 6 days')),
+               dbesc(datetime_convert('UTC','UTC','now - 1 days'))
+       );
+
+       if($r && count($r)) {
+               $now = strtotime('now');
+               $istoday = false;
+               foreach($r as $rr) {
+                       if(strlen($rr['name']))
+                               $total ++;
+
+                       $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
+                       if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
+                               $istoday = true;
+               }
+               $classtoday = (($istoday) ? ' event-today ' : '');
+
+               $o .= '<div id="event-notice" class="birthday-notice fakelink' . $classtoday . '" onclick=openClose(\'event-wrapper\'); >' . t('Event Reminders') . ' ' . '(' . count($r) . ')' . '</div>'; 
+               $o .= '<div id="event-wrapper" style="display: none;" ><div id="event-title">' . t('Events this week:') . '</div>'; 
+               $o .= '<div id="event-title-end"></div>';
+
+               foreach($r as $rr) {
+
+                       if($rr['adjust'])
+                               $md = datetime_convert('UTC',$a->timezone,$rr['start'],'Y/m\#\l\i\n\k\-j');
+                       else
+                               $md = datetime_convert('UTC','UTC',$rr['start'],'Y/m\#\l\i\n\k\-j');
+
+                       $title = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
+                       if(! $title)
+                               $title = t('[No description]');
+
+                       $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
+                       $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);  
+
+                       $o .= '<div class="event-list" id="event-' . $rr['eid'] . '"></a> <a href="events/' . $md . '">' . $title . '</a>' 
+                       . day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ?  ' ' . t('[today]') : '')
+                       . '</div>' ;
+               }
+               $o .= '</div></div>';
+       }
+
+       return $o;
+}}
+
+
 /**
  * 
  * Wrap calls to proc_close(proc_open()) and call hook