summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2013-01-21 20:40:23 +0100
committerFrank Karlitschek <frank@owncloud.org>2013-01-21 20:40:23 +0100
commita27f92a17ae12d2d1ff48b26aadfecd7c221c589 (patch)
treeafe980f2b1eeaacefb38ebd8a431de62c2a3a009 /lib
parent51a4240051cf5c4225813b3f948dcc069b725c81 (diff)
downloadnextcloud-server-a27f92a17ae12d2d1ff48b26aadfecd7c221c589.tar.gz
nextcloud-server-a27f92a17ae12d2d1ff48b26aadfecd7c221c589.zip
we are getting closer. updating is not working yet.
Diffstat (limited to 'lib')
-rw-r--r--lib/app.php16
-rw-r--r--lib/installer.php99
-rw-r--r--lib/ocsclient.php2
3 files changed, 110 insertions, 7 deletions
diff --git a/lib/app.php b/lib/app.php
index e60bce2a201..13f54d6cf75 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -142,6 +142,8 @@ class OC_App{
* check if app is shipped
* @param string $appid the id of the app to check
* @return bool
+ *
+ * Check if an app that is installed is a shipped app or installed from the appstore.
*/
public static function isShipped($appid){
$info = self::getAppInfo($appid);
@@ -197,9 +199,10 @@ class OC_App{
if(!is_numeric($app)) {
$app = OC_Installer::installShippedApp($app);
}else{
+ $appdata=OC_OCSClient::getApplication($app);
$download=OC_OCSClient::getApplicationDownload($app, 1);
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
- $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink']));
+ $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink'],'appdata'=>$appdata));
}
}
}
@@ -212,6 +215,7 @@ class OC_App{
return false;
}else{
OC_Appconfig::setValue( $app, 'enabled', 'yes' );
+ if(isset($appdata['id'])) OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] );
return true;
}
}else{
@@ -229,6 +233,14 @@ class OC_App{
public static function disable( $app ) {
// check if app is a shiped app or not. if not delete
OC_Appconfig::setValue( $app, 'enabled', 'no' );
+
+ // check if app is a shiped app or not. if not delete
+ if(!OC_App::isShipped( $app )){
+// error_log($app.' not shipped');
+ OC_Installer::removeApp( $app );
+ }else{
+// error_log($app.' shipped');
+ }
}
/**
@@ -609,6 +621,8 @@ class OC_App{
$app1[$i]['author'] = $app['personid'];
$app1[$i]['ocs_id'] = $app['id'];
$app1[$i]['internal'] = $app1[$i]['active'] = 0;
+ $app1[$i]['update'] = false;
+
// rating img
if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" );
diff --git a/lib/installer.php b/lib/installer.php
index 7dc8b0cef8d..f4094a5d4c9 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -141,6 +141,20 @@ class OC_Installer{
return false;
}
+ // check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
+ if(isset($info['shipped']) and ($info['shipped']=='true')) {
+ OC_Log::write('core', 'App can\'t be installed because it contains the <shipped>true</shippe> tag which is not allowed for non shipped apps', OC_Log::ERROR);
+ OC_Helper::rmdirr($extractDir);
+ return false;
+ }
+
+ // check if the ocs version is the same as the version in info.xml/version
+ if(!isset($info['version']) or ($info['version']<>$data['appdata']['version'])) {
+ OC_Log::write('core', 'App can\'t be installed because the version in info.xml/version is not the same as the version reported from the app store', OC_Log::ERROR);
+ OC_Helper::rmdirr($extractDir);
+ return false;
+ }
+
//check if an app with the same id is already installed
if(self::isInstalled( $info['id'] )) {
OC_Log::write('core', 'App already installed', OC_Log::WARN);
@@ -226,7 +240,6 @@ class OC_Installer{
/**
* @brief Update an application
* @param $data array with all information
- * @returns integer
*
* This function installs an app. All information needed are passed in the
* associative array $data.
@@ -250,11 +263,57 @@ class OC_Installer{
*
* upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid, 'installed_version')"
*/
- public static function upgradeApp( $data = array()) {
- // TODO: write function
- return true;
+ public static function updateApp( $app ) {
+ error_log('updater!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+ return(true);
+ if(OC_Installer::isDownloaded( $name )) {
+ }
}
+ /**
+ * @brief Check if an update for the app is available
+ * @param $name name of the application
+ * @returns emptry string is no update available or the version number of the update
+ *
+ * The function will check if an update for a version is available
+ */
+ public static function isUpdateAvailable( $app ) {
+ //debug
+ return('1.1');
+
+ $ocsid=OC_Appconfig::getValue( $app, 'ocsid', '');
+
+ if($ocsid<>''){
+
+ $ocsdata=OC_OCSClient::getApplication($ocsid);
+ $ocsversion=$ocsdata['version'];
+ $currentversion=OC_App::getAppVersion($app);
+
+//error_log('bb'.$app.' '.$ocsversion);
+ return($ocsversion);
+
+ }else{
+ return('');
+ }
+
+ }
+
+ /**
+ * @brief Check if app is already downloaded
+ * @param $name name of the application to remove
+ * @returns true/false
+ *
+ * The function will check if the app is already downloaded in the apps repository
+ */
+ public static function isDownloaded( $name ) {
+
+ $downloaded=false;
+ foreach(OC::$APPSROOTS as $dir) {
+ if(is_dir($dir['path'].'/'.$name)) $downloaded=true;
+ }
+ return($downloaded);
+ }
+
/**
* @brief Removes an app
* @param $name name of the application to remove
@@ -276,8 +335,36 @@ class OC_Installer{
* this has to be done by the function oc_app_uninstall().
*/
public static function removeApp( $name, $options = array()) {
- // TODO: write function
- return true;
+
+ if(isset($options['keeppreferences']) and $options['keeppreferences']==false ){
+ // todo
+ // remove preferences
+ }
+
+ if(isset($options['keepappconfig']) and $options['keepappconfig']==false ){
+ // todo
+ // remove app config
+ }
+
+ if(isset($options['keeptables']) and $options['keeptables']==false ){
+ // todo
+ // remove app database tables
+ }
+
+ if(isset($options['keepfiles']) and $options['keepfiles']==false ){
+ // todo
+ // remove user files
+ }
+
+ if(OC_Installer::isDownloaded( $name )) {
+ $appdir=OC_App::getInstallPath().'/'.$name;
+ OC_Helper::rmdirr($appdir);
+
+ }else{
+ OC_Log::write('core', 'can\'t remove app '.$name.'. It is not installed.', OC_Log::ERROR);
+
+ }
+
}
/**
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 24081425f1e..36930788774 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -123,6 +123,7 @@ class OC_OCSClient{
$app=array();
$app['id']=(string)$tmp[$i]->id;
$app['name']=(string)$tmp[$i]->name;
+ $app['version']=(string)$tmp[$i]->version;
$app['type']=(string)$tmp[$i]->typeid;
$app['typename']=(string)$tmp[$i]->typename;
$app['personid']=(string)$tmp[$i]->personid;
@@ -162,6 +163,7 @@ class OC_OCSClient{
$app=array();
$app['id']=$tmp->id;
$app['name']=$tmp->name;
+ $app['version']=$tmp->version;
$app['type']=$tmp->typeid;
$app['typename']=$tmp->typename;
$app['personid']=$tmp->personid;