X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fplugin.php;h=336b213aa3491324db2582196159a628822dbdb3;hb=cb3077b7a9023a65b6dc13df065bfbbe7f7633fb;hp=89c783f900ae3532b17adfef171818cacb3efee8;hpb=a5e4882e25f1ed1fbc1cb2a60cc5f15295273c48;p=friendica.git diff --git a/include/plugin.php b/include/plugin.php index 89c783f900..336b213aa3 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,10 +1,11 @@ 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']); @@ -324,7 +326,7 @@ function get_plugin_info($plugin){ /** * @brief Parse theme comment in search of theme infos. - * + * * like * \code * ..* Name: My Theme @@ -412,7 +414,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 +426,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 +437,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 +468,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 +478,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 +502,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) ); @@ -541,11 +546,11 @@ function upgrade_bool_message($bbcode = false) { /** * @brief Get the full path to relevant theme files by filename - * + * * This function search in the theme directory (and if not present in global theme directory) * if there is a directory with the file extension and for a file with the given - * filename. - * + * filename. + * * @param string $file Filename * @param string $root Full root path * @return string Path to the file or empty string if the file isn't found