]> git.mxchange.org Git - friendica.git/blobdiff - include/plugin.php
Removed stuff that was never used or isn't used anymore
[friendica.git] / include / plugin.php
index 60ef6138b9c4712145fb3c69ecf9d2e7c574936f..d5bceafdea82406e6b9ff770e647d325bfcbd50e 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 use Friendica\App;
+use Friendica\Core\System;
 
 /**
  * @brief uninstalls an addon.
@@ -46,22 +47,17 @@ function install_plugin($plugin) {
                $func = $plugin . '_install';
                $func();
 
-               $plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
+               $plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
 
-               $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
-                       dbesc($plugin),
-                       intval($t),
-                       $plugin_admin
-               );
+               dba::insert('addon', array('name' => $plugin, 'installed' => true,
+                                       'timestamp' => $t, 'plugin_admin' => $plugin_admin));
 
                // we can add the following with the previous SQL
                // once most site tables have been updated.
                // This way the system won't fall over dead during the update.
 
                if (file_exists('addon/' . $plugin . '/.hidden')) {
-                       q("UPDATE `addon` SET `hidden` = 1 WHERE `name` = '%s'",
-                               dbesc($plugin)
-                       );
+                       dba::update('addon', array('hidden' => true), array('name' => $plugin));
                }
                return true;
        }
@@ -109,10 +105,7 @@ function reload_plugins() {
                                                                $func = $pl . '_install';
                                                                $func();
                                                        }
-                                                       q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d",
-                                                               intval($t),
-                                                               intval($i['id'])
-                                                       );
+                                                       dba::update('addon', array('timestamp' => $t), array('id' => $i['id']));
                                                }
                                        }
                                }
@@ -129,8 +122,7 @@ function reload_plugins() {
  * @return boolean
  */
 function plugin_enabled($plugin) {
-       $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin);
-       return ((dbm::is_result($r)) && (count($r) > 0));
+       return dba::exists('addon', array('installed' => true, 'name' => $plugin));
 }
 
 
@@ -154,12 +146,8 @@ function register_hook($hook,$file,$function,$priority=0) {
        if (dbm::is_result($r))
                return true;
 
-       $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ",
-               dbesc($hook),
-               dbesc($file),
-               dbesc($function),
-               dbesc($priority)
-       );
+       $r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
+
        return $r;
 }}
 
@@ -194,6 +182,7 @@ function load_hooks() {
                }
                $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
        }
+       dba::close($r);
 }
 
 /**
@@ -413,10 +402,10 @@ function get_theme_screenshot($theme) {
        $exts = array('.png','.jpg');
        foreach ($exts as $ext) {
                if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
-                       return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+                       return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext);
                }
        }
-       return(App::get_baseurl() . '/images/blank.png');
+       return(System::baseUrl() . '/images/blank.png');
 }
 
 // install and uninstall theme
@@ -556,6 +545,8 @@ function upgrade_bool_message($bbcode = false) {
  * @return string Path to the file or empty string if the file isn't found
  */
 function theme_include($file, $root = '') {
+       $file = basename($file);
+
        // Make sure $root ends with a slash / if it's not blank
        if ($root !== '' && $root[strlen($root)-1] !== '/') {
                $root = $root . '/';