]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
added more curyl braces + spaces between "if" and brace
[friendica.git] / include / api.php
index 1f3c762989f3f2c5850fdfd4327768307b545060..df62abd8e6dab1398506b8f7f13d5903251ff451 100644 (file)
                                dbesc(trim($user)),
                                dbesc($encrypted)
                        );
-                       if(count($r))
+                       if (dbm::is_result($r))
                                $record = $r[0];
                }
 
                if (is_null($user_info)) $user_info = api_get_user($a);
                $arr['$user'] = $user_info;
                $arr['$rss'] = array(
-                       'alternate' => $user_info['url'],
-                       'self' => App::get_baseurl(). "/". $a->query_string,
-                       'base' => App::get_baseurl(),
-                       'updated' => api_date(null),
+                       'alternate'    => $user_info['url'],
+                       'self'         => App::get_baseurl(). "/". $a->query_string,
+                       'base'         => App::get_baseurl(),
+                       'updated'      => api_date(null),
                        'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
-                       'language' => $user_info['language'],
-                       'logo'  => App::get_baseurl()."/images/friendica-32.png",
+                       'language'     => $user_info['language'],
+                       'logo'         => App::get_baseurl()."/images/friendica-32.png",
                );
 
                return $arr;
 
                if (isset($_GET["q"])) {
                        $r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
-                       if (!count($r))
+                       if (!dbm::is_result($r))
                                $r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
 
-                       if (count($r)) {
+                       if (dbm::is_result($r)) {
                                $k = 0;
                                foreach ($r AS $user) {
                                        $user_info = api_get_user($a, $user["id"], "json");
                        intval(api_user())
                );
 
-               if(!dbm::is_result($r))
+               if (!dbm::is_result($r))
                        return;
 
                $ids = array();
                        intval(api_user())
                );
 
-               if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+               if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
                        throw new BadRequestException("Unknown contact");
 
                $cid = $r[0]['id'];
                                intval($uid),
                                intval($gid));
                        // error message if specified gid is not in database
-                       if (count($r) == 0)
+                       if (!dbm::is_result($r))
                                throw new BadRequestException("gid not available");
                }
                else
                        intval($uid),
                        intval($gid));
                // error message if specified gid is not in database
-               if (count($r) == 0)
+               if (!dbm::is_result($r))
                        throw new BadRequestException('gid not available');
 
                // get data of the specified group id and group name
                        intval($gid),
                        dbesc($name));
                // error message if specified gid is not in database
-               if (count($rname) == 0)
+               if (!dbm::is_result($rname))
                        throw new BadRequestException('wrong group name');
 
                // delete group
                        intval($uid),
                        dbesc($name));
                // error message if specified group name already exists
-               if (count($rname) != 0)
+               if (dbm::is_result($rname))
                        throw new BadRequestException('group name already exists');
 
                // check if specified group name is a deleted group
                        intval($uid),
                        dbesc($name));
                // error message if specified group name already exists
-               if (count($rname) != 0)
+               if (dbm::is_result($rname))
                        $reactivate_group = true;
 
                // create group
 
                $profile_url = $user_info["url"];
                // message if nothing was found
-               if (count($r) == 0) 
+               if (!dbm::is_result($r))
+                       $success = array('success' => false, 'search_results' => 'problem with query');
+               else if (count($r) == 0) 
                        $success = array('success' => false, 'search_results' => 'nothing found');
                else {
                        $ret = Array();
        }
        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
         *
                                intval(api_user()),
                                intval($profileid));
                        // error message if specified gid is not in database
-                       if (count($r) == 0)
+                       if (!dbm::is_result($r))
                                throw new BadRequestException("profile_id not available");
                }
                else