]> git.mxchange.org Git - friendica.git/blobdiff - include/plugin.php
Merge branch 'develop' of https://github.com/friendica/friendica into issue/#3039...
[friendica.git] / include / plugin.php
index 89c783f900ae3532b17adfef171818cacb3efee8..83f6f1ab9502a1f5b34e8c0039169b0d007d959a 100644 (file)
@@ -187,8 +187,9 @@ function load_hooks() {
        $a = get_app();
        $a->hooks = array();
        $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
+
        if (dbm::is_result($r)) {
-               foreach($r as $rr) {
+               foreach ($r as $rr) {
                        if(! array_key_exists($rr['hook'],$a->hooks))
                                $a->hooks[$rr['hook']] = array();
                        $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
@@ -412,7 +413,7 @@ function get_theme_info($theme){
 function get_theme_screenshot($theme) {
        $exts = array('.png','.jpg');
        foreach($exts as $ext) {
-               if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
+               if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
                        return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
                }
        }
@@ -424,8 +425,8 @@ if (! function_exists('uninstall_theme')){
 function uninstall_theme($theme){
        logger("Addons: uninstalling theme " . $theme);
 
-       @include_once("view/theme/$theme/theme.php");
-       if(function_exists("{$theme}_uninstall")) {
+       include_once("view/theme/$theme/theme.php");
+       if (function_exists("{$theme}_uninstall")) {
                $func = "{$theme}_uninstall";
                $func();
        }
@@ -435,19 +436,19 @@ if (! function_exists('install_theme')){
 function install_theme($theme) {
        // silently fail if theme was removed
 
-       if(! file_exists("view/theme/$theme/theme.php"))
+       if (! file_exists("view/theme/$theme/theme.php")) {
                return false;
+       }
 
        logger("Addons: installing theme $theme");
 
-       @include_once("view/theme/$theme/theme.php");
+       include_once("view/theme/$theme/theme.php");
 
-       if(function_exists("{$theme}_install")) {
+       if (function_exists("{$theme}_install")) {
                $func = "{$theme}_install";
                $func();
                return true;
-       }
-       else {
+       } else {
                logger("Addons: FAILED installing theme $theme");
                return false;
        }
@@ -466,10 +467,9 @@ function install_theme($theme) {
 
 function service_class_allows($uid,$property,$usage = false) {
 
-       if($uid == local_user()) {
+       if ($uid == local_user()) {
                $service_class = $a->user['service_class'];
-       }
-       else {
+       } else {
                $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($uid)
                );
@@ -477,18 +477,23 @@ function service_class_allows($uid,$property,$usage = false) {
                        $service_class = $r[0]['service_class'];
                }
        }
-       if(! x($service_class))
-               return true; // everything is allowed
+
+       if (! x($service_class)) {
+               // everything is allowed
+               return true;
+       }
 
        $arr = get_config('service_class',$service_class);
-       if(! is_array($arr) || (! count($arr)))
+       if (! is_array($arr) || (! count($arr))) {
                return true;
+       }
 
-       if($usage === false)
+       if ($usage === false) {
                return ((x($arr[$property])) ? (bool) $arr['property'] : true);
-       else {
-               if(! array_key_exists($property,$arr))
+       else {
+               if (! array_key_exists($property,$arr)) {
                        return true;
+               }
                return (((intval($usage)) < intval($arr[$property])) ? true : false);
        }
 }
@@ -496,10 +501,9 @@ function service_class_allows($uid,$property,$usage = false) {
 
 function service_class_fetch($uid,$property) {
 
-       if($uid == local_user()) {
+       if ($uid == local_user()) {
                $service_class = $a->user['service_class'];
-       }
-       else {
+       } else {
                $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($uid)
                );