]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'rewrites/dbm_is_result' of github.com:Quix0r/friendica into rewrites...
authorRoland Häder <roland@mxchange.org>
Tue, 13 Dec 2016 10:00:44 +0000 (11:00 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 13 Dec 2016 10:00:44 +0000 (11:00 +0100)
Signed-off-by: Roland Häder <roland@mxchange.org>
Conflicts:
include/Photo.php
include/api.php
include/cache.php
include/dbstructure.php
include/enotify.php
include/items.php
include/onepoll.php
include/queue_fn.php
include/session.php
include/text.php
mod/contacts.php
mod/dfrn_request.php
mod/display.php
mod/events.php
mod/item.php
mod/message.php
mod/msearch.php
mod/photos.php
mod/poco.php
mod/profile.php
mod/proxy.php
mod/videos.php
update.php
view/theme/diabook/theme.php
view/theme/vier/theme.php

29 files changed:
1  2 
include/api.php
include/cron.php
include/dbstructure.php
include/diaspora.php
include/enotify.php
include/feed.php
include/items.php
include/network.php
include/notifier.php
include/queue_fn.php
include/session.php
include/text.php
include/threads.php
mod/contactgroup.php
mod/contacts.php
mod/dfrn_request.php
mod/display.php
mod/events.php
mod/item.php
mod/msearch.php
mod/network.php
mod/p.php
mod/photo.php
mod/photos.php
mod/poco.php
mod/profile.php
mod/search.php
view/templates/head.tpl
view/theme/vier/style.css

diff --cc include/api.php
index 24120018bd6334e96b2f6721ba2a72e095c900c0,521354edc12077dea6005353c311a84d458e9e10..f627955cf458caedceba65254b98c4faafb1de71
        }
        api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
  
 +      /**
 +       * @brief return data of all the profiles a user has to the client
 +       *
 +       * @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
 +       * @return string
 +       */
 +      function api_friendica_profile_show($type){
 +              $a = get_app();
 +
 +              if (api_user()===false) throw new ForbiddenException();
 +
 +              // input params
 +              $profileid = (x($_REQUEST,'profile_id') ? $_REQUEST['profile_id'] : 0);
 +
 +              // retrieve general information about profiles for user
 +              $multi_profiles = feature_enabled(api_user(),'multi_profiles');
 +              $directory = get_config('system', 'directory');
 +
 +// get data of the specified profile id or all profiles of the user if not specified
 +              if ($profileid != 0) {
 +                      $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d",
 +                              intval(api_user()),
 +                              intval($profileid));
 +                      // error message if specified gid is not in database
 +                      if (!dbm::is_result($r))
 +                              throw new BadRequestException("profile_id not available");
 +              }
 +              else
 +                      $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
 +                              intval(api_user()));
 +
 +              // loop through all returned profiles and retrieve data and users
 +              $k = 0;
 +              foreach ($r as $rr) {
 +                      $profile = api_format_items_profiles($rr, $type);
 +
 +                      // select all users from contact table, loop and prepare standard return for user data
 +                      $users = array();
 +                      $r = q("SELECT `id`, `nurl` FROM `contact` WHERE `uid`= %d AND `profile-id` = %d",
 +                              intval(api_user()),
 +                              intval($rr['profile_id']));
 +
 +                      foreach ($r as $rr) {
 +                              $user = api_get_user($a, $rr['nurl']);
 +                              ($type == "xml") ? $users[$k++.":user"] = $user : $users[] = $user;
 +                      }
 +                      $profile['users'] = $users;
 +
 +                      // add prepared profile data to array for final return
 +                      if ($type == "xml") {
 +                              $profiles[$k++.":profile"] = $profile;
 +                      } else {
 +                              $profiles[] = $profile;
 +                      }
 +              }
 +
 +              // return settings, authenticated user and profiles data
 +              $result = array('multi_profiles' => $multi_profiles ? true : false,
 +                                              'global_dir' => $directory,
 +                                              'friendica_owner' => api_get_user($a, intval(api_user())),
 +                                              'profiles' => $profiles);
 +              return api_format_data("friendica_profiles", $type, array('$result' => $result));
 +      }
 +      api_register_func('api/friendica/profile/show', 'api_friendica_profile_show', true, API_METHOD_GET);
 +
  /*
  To.Do:
      [pagename] => api/1.1/statuses/lookup.json
Simple merge
index 94e8da4a44fbda632652204ecc4afe53f1acf1bf,0da209a36651c5af7d3a57ba3ca55bd6f003e06a..cd80a0865d31d0b822ce71dab07afe520f206459
@@@ -178,8 -157,8 +187,8 @@@ function update_structure($verbose, $ac
                $is_new_table = False;
                $sql3="";
                if (!isset($database[$name])) {
 -                      $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
 +                      $r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
-                       if(false === $r) {
+                       if(!dbm::is_result($r)) {
                                $errors .=  t('Errors encountered creating database tables.').$name.EOL;
                        }
                        $is_new_table = True;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 241b0bb3641872e400c78ca2db4e7b5a7652bb57,a253aa2fb2282c4a0360f8e7fc58c9e128c84fde..df9ab6b4cbc950f048040486f68f926a27017d5f
@@@ -15,20 -15,16 +15,25 @@@ function remove_queue_item($id) 
        );
  }
  
 +/**
 + * @brief Checks if the communication with a given contact had problems recently
 + *
 + * @param int $cid Contact id
 + *
 + * @return bool The communication with this contact has currently problems
 + */
  function was_recently_delayed($cid) {
  
-       $was_delayed = false;
+       $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d 
+               and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
+               intval($cid)
+       );
+       if(dbm::is_result($r))
+               return true;
  
 -      $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
 +      // Are there queue entries that were recently added?
 +      $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
 +              AND `last` > UTC_TIMESTAMP() - interval 15 minute LIMIT 1",
                intval($cid)
        );
  
index 31024060f3c0c7c1f465a6cee6fde44af8a4c0bf,fe8e0848efb360e2f43068433c0420bcd77d864a..8aca6cb53d356c37d294e14d8d0e968f93c7021c
@@@ -7,30 -6,18 +7,30 @@@ require_once('include/cache.php')
  $session_exists = 0;
  $session_expire = 180000;
  
 -if(! function_exists('ref_session_open')) {
 -function ref_session_open ($s,$n) {
 +function ref_session_open($s, $n) {
        return true;
 -}}
 +}
  
 -if(! function_exists('ref_session_read')) {
 -function ref_session_read ($id) {
 +function ref_session_read($id) {
        global $session_exists;
 -      if(x($id))
 -              $r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
 +
 +      if (!x($id)) {
 +              return '';
 +      }
 +
 +      $memcache = cache::memcache();
 +      if (is_object($memcache)) {
 +              $data = $memcache->get(get_app()->get_hostname().":session:".$id);
 +              if (!is_bool($data)) {
 +                      return $data;
 +              }
 +              logger("no data for session $id", LOGGER_TRACE);
 +              return '';
 +      }
 +
 +      $r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
  
-       if (dbm::is_result($r)) {
+       if(dbm::is_result($r)) {
                $session_exists = true;
                return $r[0]['data'];
        } else {
Simple merge
Simple merge
Simple merge
Simple merge
index 66c891ef089cdf711e92eae1f4ca89225d8a7598,9b7dede2e2244d326d512c7d840ffa6a8cd90db3..8bca431dd234f9110839abb5b76efe072f3d24e5
@@@ -370,8 -368,7 +370,8 @@@ function dfrn_request_post(&$a) 
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval($uid)
                                );
-                               if(! dbm::is_result($r)) {
 +
+                               if(! dbm::is_result($r)) {
                                        notice( t('This account has not been configured for email. Request failed.') . EOL);
                                        return;
                                }
diff --cc mod/display.php
index 293156cf19f5dbd8a4fb87e3b30043f956340796,cf7700a145a4e3cb209fbf3a9163dca0fb403e38..8d1a44e4be18718a081fc6de6351ccd0cb75aa82
@@@ -316,16 -316,16 +316,16 @@@ function display_content(&$a, $update 
                }
        }
  
 -      $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
 +      $r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                intval($a->profile['uid'])
        );
-       if (dbm::is_result($r)) {
 -      if(dbm::is_result($r))
++      if(dbm::is_result($r)) {
                $a->page_contact = $r[0];
 -
 +      }
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
  
 -      if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
 -              notice( t('Access to this profile has been restricted.') . EOL);
 +      if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
 +              notice(t('Access to this profile has been restricted.') . EOL);
                return;
        }
  
diff --cc mod/events.php
index 4a201f43e49faa94da4a96932f50f8bececbfacf,e579d3530dcf1fca230b4a16d9af61b29fc7f2d8..a5380c8369fc4d4b4410c983b255b3720af5a415
@@@ -344,9 -344,9 +344,10 @@@ function events_content(&$a) 
                $events=array();
  
                // transform the event in a usable array
-               if(dbm::is_result($r))
+               if(dbm::is_result($r)) {
                        $r = sort_by_date($r);
                        $events = process_events($r);
++              }
  
                if ($a->argv[1] === 'json'){
                        echo json_encode($events); killme();
diff --cc mod/item.php
Simple merge
diff --cc mod/msearch.php
index 1370b63bf2ca3e476e4f9c8389b5abd9ae6990a5,fd46cc1e1bd5aaaa7ca24df3bdde357f1096cb59..8fae1177feaada91f87abeeb5392ce6afe17cd9b
@@@ -22,7 -25,6 +25,8 @@@ function msearch_post(&$a) 
                intval($perpage)
        );
  
 +      $results = array();
++
        if(dbm::is_result($r)) {
                foreach($r as $rr)
                        $results[] = array(
diff --cc mod/network.php
Simple merge
diff --cc mod/p.php
Simple merge
diff --cc mod/photo.php
Simple merge
diff --cc mod/photos.php
index a4d5544ef2109d96c63c2ff89fea9986ae63530c,328be50b27a00043f8c05c5b65e1c125f31654f6..e93fb261b88c370c0d987dfa866ee97848907035
@@@ -254,11 -268,12 +254,11 @@@ function photos_post(&$a) 
                                        dbesc($album)
                                );
                        }
-                       if (dbm::is_result($r)) {
-                               foreach ($r as $rr) {
+                       if(dbm::is_result($r)) {
+                               foreach($r as $rr) {
                                        $res[] = "'" . dbesc($rr['rid']) . "'" ;
                                }
 -                      }
 -                      else {
 +                      } else {
                                goaway($_SESSION['photo_return']);
                                return; // NOTREACHED
                        }
                                dbesc($resource_id),
                                intval($page_owner_uid)
                        );
-                       if (dbm::is_result($r)) {
+                       if(dbm::is_result($r)) {
                                $ph = new Photo($r[0]['data'], $r[0]['type']);
 -                              if($ph->is_valid()) {
 +                              if ($ph->is_valid()) {
                                        $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
                                        $ph->rotate($rotate_deg);
  
@@@ -1188,8 -1210,8 +1188,8 @@@ function photos_content(&$a) 
                        intval($owner_uid),
                        dbesc($album)
                );
-               if (dbm::is_result($r)) {
+               if(dbm::is_result($r)) {
 -                      $a->set_pager_total(dbm::is_result($r));
 +                      $a->set_pager_total(count($r));
                        $a->set_pager_itemspage(20);
                }
  
  
                $photos = array();
  
-               if (dbm::is_result($r))
+               if(dbm::is_result($r))
                        $twist = 'rotright';
 -                      foreach($r as $rr) {
 -                              if($twist == 'rotright')
 +                      foreach ($r as $rr) {
 +                              if ($twist == 'rotright')
                                        $twist = 'rotleft';
                                else
                                        $twist = 'rotright';
  
  
                        // display comments
-                       if (dbm::is_result($r)) {
+                       if(dbm::is_result($r)) {
  
 -                              foreach($r as $item) {
 +                              foreach ($r as $item) {
                                        builtin_activity_puller($item, $conv_responses);
                                }
  
                dbesc('Contact Photos'),
                dbesc( t('Contact Photos'))
        );
-       if (dbm::is_result($r)) {
+       if(dbm::is_result($r)) {
 -              $a->set_pager_total(dbm::is_result($r));
 +              $a->set_pager_total(count($r));
                $a->set_pager_itemspage(20);
        }
  
  
  
        $photos = array();
-       if (dbm::is_result($r)) {
+       if(dbm::is_result($r)) {
                $twist = 'rotright';
 -              foreach($r as $rr) {
 +              foreach ($r as $rr) {
                        //hide profile photos to others
 -                      if((! $is_owner) && (! remote_user()) && ($rr['album'] == t('Profile Photos')))
 +                      if ((! $is_owner) && (! remote_user()) && ($rr['album'] == t('Profile Photos')))
                                        continue;
 -                      
 -                      if($twist == 'rotright')
 +
 +                      if ($twist == 'rotright')
                                $twist = 'rotleft';
                        else
                                $twist = 'rotright';
diff --cc mod/poco.php
Simple merge
diff --cc mod/profile.php
Simple merge
diff --cc mod/search.php
Simple merge
Simple merge
Simple merge