{
global $DIR_PLUGINS;
- $candidates = array();
+ $query = "SELECT * FROM %s;";
+ $query = sprintf($query, sql_table('plugin'));
+ $res = DB::getResult($query);
+
+ $installed = array();
+ foreach( $res as $row )
+ {
+ $installed[] = $row['pfile'];
+ }
+
$files = scandir($DIR_PLUGINS);
+ $candidates = array();
foreach ( $files as $file )
{
- if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
+ if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
{
- $name = $matches[1];
- $query = "SELECT * FROM %s WHERE pfile=%s;";
- $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
- $res = DB::getResult($query);
-
- if ( $res->rowCount() == 0 )
+ if ( !in_array($matches[1], $installed) )
{
- $candidates[] = $name;
+ $candidates[] = $matches[1];
}
}
- continue;
}
$this->newPlugCandidates = $candidates;
return (count($candidates) > 0);