Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
afbc4f1f
Commit
afbc4f1f
authored
14 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
automatically install databased of plugins
parent
1b5a0bb3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/lib_plugin.php
+119
-10
119 additions, 10 deletions
inc/lib_plugin.php
with
119 additions
and
10 deletions
inc/lib_plugin.php
+
119
−
10
View file @
afbc4f1f
...
...
@@ -49,6 +49,16 @@ class OC_PLUGIN{
}
}
}
//check for uninstalled db's
if
(
isset
(
$data
[
'install'
])
and
isset
(
$data
[
'install'
][
'database'
])){
foreach
(
$data
[
'install'
][
'database'
]
as
$db
){
if
(
!
$data
[
'install'
][
'database_installed'
][
$db
]){
self
::
installDB
(
$id
);
break
;
}
}
}
foreach
(
$data
[
'runtime'
]
as
$include
){
include
(
$SERVERROOT
.
'/plugins/'
.
$id
.
'/'
.
$include
);
}
...
...
@@ -60,16 +70,19 @@ class OC_PLUGIN{
* Load all plugins that aren't blacklisted
*/
public
static
function
loadPlugins
()
{
global
$SERVERROOT
;
$plugins
=
array
();
$blacklist
=
self
::
loadBlacklist
();
$fd
=
opendir
(
$SERVERROOT
.
'/plugins'
);
while
(
false
!==
(
$filename
=
readdir
(
$fd
))
)
{
if
(
$filename
<>
'.'
AND
$filename
<>
'..'
AND
(
'.'
!=
substr
(
$filename
,
0
,
1
))
AND
array_search
(
$filename
,
$blacklist
)
===
false
)
{
self
::
load
(
$filename
);
global
$CONFIG_INSTALLED
;
if
(
$CONFIG_INSTALLED
){
global
$SERVERROOT
;
$plugins
=
array
();
$blacklist
=
self
::
loadBlacklist
();
$fd
=
opendir
(
$SERVERROOT
.
'/plugins'
);
while
(
false
!==
(
$filename
=
readdir
(
$fd
))
)
{
if
(
$filename
<>
'.'
AND
$filename
<>
'..'
AND
(
'.'
!=
substr
(
$filename
,
0
,
1
))
AND
array_search
(
$filename
,
$blacklist
)
===
false
)
{
self
::
load
(
$filename
);
}
}
closedir
(
$fd
);
}
closedir
(
$fd
);
}
/**
...
...
@@ -138,9 +151,9 @@ class OC_PLUGIN{
}
/**
(
Load data from the plugin.xml of a plugin, either identified by the plugin or the path of the plugin.xml file
*
Load data from the plugin.xml of a plugin, either identified by the plugin or the path of the plugin.xml file
* @param string id
*
(
@return array
* @return array
*/
public
static
function
getPluginData
(
$id
){
global
$SERVERROOT
;
...
...
@@ -194,6 +207,7 @@ class OC_PLUGIN{
break
;
case
'database'
:
$data
[
'install'
][
'database'
][]
=
$child
->
textContent
;
$data
[
'install'
][
'database_installed'
][
$child
->
textContent
]
=
(
$child
->
hasAttribute
(
'installed'
)
and
$child
->
getAttribute
(
'installed'
)
==
'true'
)
?
true
:
false
;
break
;
}
}
...
...
@@ -220,6 +234,101 @@ class OC_PLUGIN{
}
return
$data
;
}
/**
* Save data to the plugin.xml of a plugin, either identified by the plugin or the path of the plugin.xml file
* @param string id
* @param array data the plugin data in the same structure as returned by getPluginData
* @return bool
*/
public
static
function
savePluginData
(
$id
,
$data
){
global
$SERVERROOT
;
if
(
is_file
(
$id
)){
$file
=
$id
;
}
if
(
!
is_dir
(
$SERVERROOT
.
'/plugins/'
.
$id
)
or
!
is_file
(
$SERVERROOT
.
'/plugins/'
.
$id
.
'/plugin.xml'
)){
return
false
;
}
else
{
$file
=
$SERVERROOT
.
'/plugins/'
.
$id
.
'/plugin.xml'
;
}
$plugin
=
new
DOMDocument
();
$pluginNode
=
$plugin
->
createElement
(
'plugin'
);
$pluginNode
->
setAttribute
(
'version'
,
$data
[
'version'
]);
$plugin
->
appendChild
(
$pluginNode
);
$info
=
$plugin
->
createElement
(
'info'
);
foreach
(
$data
[
'info'
]
as
$name
=>
$value
){
$node
=
$plugin
->
createElement
(
$name
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$value
));
$info
->
appendChild
(
$node
);
}
$pluginNode
->
appendChild
(
$info
);
if
(
isset
(
$data
[
'runtime'
])){
$runtime
=
$plugin
->
createElement
(
'runtime'
);
foreach
(
$data
[
'runtime'
]
as
$include
){
$node
=
$plugin
->
createElement
(
'include'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$include
));
$runtime
->
appendChild
(
$node
);
}
$pluginNode
->
appendChild
(
$runtime
);
}
if
(
isset
(
$data
[
'install'
])){
$install
=
$plugin
->
createElement
(
'install'
);
foreach
(
$data
[
'install'
][
'include'
]
as
$include
){
$node
=
$plugin
->
createElement
(
'include'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$include
));
$install
->
appendChild
(
$node
);
}
foreach
(
$data
[
'install'
][
'dialog'
]
as
$dialog
){
$node
=
$plugin
->
createElement
(
'dialog'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$dialog
));
$install
->
appendChild
(
$node
);
}
foreach
(
$data
[
'install'
][
'database'
]
as
$database
){
$node
=
$plugin
->
createElement
(
'database'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$database
));
if
(
$data
[
'install'
][
'database_installed'
][
$database
]){
$node
->
setAttribute
(
'installed'
,
'true'
);
}
$install
->
appendChild
(
$node
);
}
$pluginNode
->
appendChild
(
$install
);
}
if
(
isset
(
$data
[
'uninstall'
])){
$uninstall
=
$plugin
->
createElement
(
'uninstall'
);
foreach
(
$data
[
'uninstall'
][
'include'
]
as
$include
){
$node
=
$plugin
->
createElement
(
'include'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$include
));
$uninstall
->
appendChild
(
$node
);
}
foreach
(
$data
[
'uninstall'
][
'dialog'
]
as
$dialog
){
$node
=
$plugin
->
createElement
(
'dialog'
);
$node
->
appendChild
(
$plugin
->
createTextNode
(
$dialog
));
$uninstall
->
appendChild
(
$node
);
}
$pluginNode
->
appendChild
(
$uninstall
);
}
$plugin
->
save
(
$file
);
}
/**
* install the databases of a plugin
* @param string id
* @return bool
*/
public
static
function
installDB
(
$id
){
global
$SERVERROOT
;
$data
=
OC_PLUGIN
::
getPluginData
(
$id
);
foreach
(
$data
[
'install'
][
'database'
]
as
$db
){
if
(
!
$data
[
'install'
][
'database_installed'
][
$db
]){
$file
=
$SERVERROOT
.
'/plugins/'
.
$id
.
'/'
.
$db
;
OC_DB
::
createDbFromStructure
(
$file
);
$data
[
'install'
][
'database_installed'
][
$db
]
=
true
;
}
}
self
::
savePluginData
(
$id
,
$data
);
return
true
;
}
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment