diff options
Diffstat (limited to 'lib/app.php')
-rw-r--r-- | lib/app.php | 132 |
1 files changed, 92 insertions, 40 deletions
diff --git a/lib/app.php b/lib/app.php index bf7eeef0181..e653c30b2d9 100644 --- a/lib/app.php +++ b/lib/app.php @@ -76,14 +76,14 @@ class OC_App{ && empty(OC_Util::$core_scripts) && empty(OC_Util::$core_styles)) { OC_Util::$core_scripts = OC_Util::$scripts; - OC_Util::$scripts = array(); - OC_Util::$core_styles = OC_Util::$styles; - OC_Util::$styles = array(); + OC_Util::$scripts = array(); + OC_Util::$core_styles = OC_Util::$styles; + OC_Util::$styles = array(); + } } - } // return - return true; -} + return true; + } /** * load a single app @@ -157,7 +157,7 @@ class OC_App{ */ public static function isShipped($appid){ $info = self::getAppInfo($appid); - if(isset($info['shipped']) && $info['shipped']=='true'){ + if(isset($info['shipped']) && $info['shipped']=='true') { return true; } else { return false; @@ -168,10 +168,12 @@ class OC_App{ * get all enabled apps */ public static function getEnabledApps() { - if(!OC_Config::getValue('installed', false)) + if(!OC_Config::getValue('installed', false)) { return array(); + } $apps=array('files'); - $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig` WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' ); + $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig`' + .' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' ); $result=$query->execute(); while($row=$result->fetchRow()) { if(array_search($row['appid'], $apps)===false) { @@ -212,7 +214,8 @@ class OC_App{ $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'],'appdata'=>$appdata)); + $info = array('source'=>'http', 'href'=>$download['downloadlink'], 'appdata'=>$appdata); + $app=OC_Installer::installApp($info); } } } @@ -221,7 +224,10 @@ class OC_App{ $info=OC_App::getAppInfo($app); $version=OC_Util::getVersion(); if(!isset($info['require']) or ($version[0]>$info['require'])) { - OC_Log::write('core', 'App "'.$info['name'].'" can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR); + OC_Log::write('core', + 'App "'.$info['name'].'" can\'t be installed because it is' + .' not compatible with this version of ownCloud', + OC_Log::ERROR); return false; }else{ OC_Appconfig::setValue( $app, 'enabled', 'yes' ); @@ -247,7 +253,7 @@ class OC_App{ OC_Appconfig::setValue( $app, 'enabled', 'no' ); // check if app is a shipped app or not. if not delete - if(!OC_App::isShipped( $app )){ + if(!OC_App::isShipped( $app )) { OC_Installer::removeApp( $app ); } } @@ -336,33 +342,70 @@ class OC_App{ // by default, settings only contain the help menu if(OC_Config::getValue('knowledgebaseenabled', true)==true) { $settings = array( - array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_help" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "settings", "help.svg" )) - ); + array( + "id" => "help", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_help" ), + "name" => $l->t("Help"), + "icon" => OC_Helper::imagePath( "settings", "help.svg" ) + ) + ); } // if the user is logged-in if (OC_User::isLoggedIn()) { // personal menu - $settings[] = array( "id" => "personal", "order" => 1, "href" => OC_Helper::linkToRoute( "settings_personal" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.svg" )); + $settings[] = array( + "id" => "personal", + "order" => 1, + "href" => OC_Helper::linkToRoute( "settings_personal" ), + "name" => $l->t("Personal"), + "icon" => OC_Helper::imagePath( "settings", "personal.svg" ) + ); // if there are some settings forms - if(!empty(self::$settingsForms)) + if(!empty(self::$settingsForms)) { // settings menu - $settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_settings" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" )); + $settings[]=array( + "id" => "settings", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_settings" ), + "name" => $l->t("Settings"), + "icon" => OC_Helper::imagePath( "settings", "settings.svg" ) + ); + } //SubAdmins are also allowed to access user management if(OC_SubAdmin::isSubAdmin(OC_User::getUser())) { // admin users menu - $settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkToRoute( "settings_users" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" )); + $settings[] = array( + "id" => "core_users", + "order" => 2, + "href" => OC_Helper::linkToRoute( "settings_users" ), + "name" => $l->t("Users"), + "icon" => OC_Helper::imagePath( "settings", "users.svg" ) + ); } // if the user is an admin if(OC_User::isAdminUser(OC_User::getUser())) { // admin apps menu - $settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkToRoute( "settings_apps" ).'?installed', "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" )); + $settings[] = array( + "id" => "core_apps", + "order" => 3, + "href" => OC_Helper::linkToRoute( "settings_apps" ).'?installed', + "name" => $l->t("Apps"), + "icon" => OC_Helper::imagePath( "settings", "apps.svg" ) + ); - $settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_admin" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" )); + $settings[]=array( + "id" => "admin", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_admin" ), + "name" => $l->t("Admin"), + "icon" => OC_Helper::imagePath( "settings", "admin.svg" ) + ); } } @@ -395,8 +438,9 @@ class OC_App{ } foreach(OC::$APPSROOTS as $dir) { - if(isset($dir['writable']) && $dir['writable']===true) + if(isset($dir['writable']) && $dir['writable']===true) { return $dir['path']; + } } OC_Log::write('core', 'No application directories are marked as writable.', OC_Log::ERROR); @@ -557,16 +601,16 @@ class OC_App{ $forms=array(); switch($type) { case 'settings': - $source=self::$settingsForms; - break; + $source=self::$settingsForms; + break; case 'admin': - $source=self::$adminForms; - break; + $source=self::$adminForms; + break; case 'personal': - $source=self::$personalForms; - break; + $source=self::$personalForms; + break; default: - return array(); + return array(); } foreach($source as $form) { $forms[]=include $form; @@ -641,7 +685,8 @@ class OC_App{ public static function listAllApps() { $installedApps = OC_App::getAllApps(); - //TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature? + //TODO which apps do we want to blacklist and how do we integrate + // blacklisting with the multi apps folder feature? $blacklist = array('files');//we dont want to show configuration for these $appList = array(); @@ -694,19 +739,20 @@ class OC_App{ // OR $app['ocs_id'] == $remote['ocs_id'] ) { unset( $remoteApps[$key]); + } } } + $combinedApps = array_merge( $appList, $remoteApps ); + } else { + $combinedApps = $appList; } - $combinedApps = array_merge( $appList, $remoteApps ); - } else { - $combinedApps = $appList; - } - return $combinedApps; -} + return $combinedApps; + } /** * @brief: get a list of all apps on apps.owncloud.com - * @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description + * @return array, multi-dimensional array of apps. + * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ public static function getAppstoreApps( $filter = 'approved' ) { $categoryNames = OC_OCSClient::getCategories(); @@ -726,7 +772,7 @@ class OC_App{ $app1[$i]['ocs_id'] = $app['id']; $app1[$i]['internal'] = $app1[$i]['active'] = 0; $app1[$i]['update'] = false; - if($app['label']=='recommended'){ + if($app['label']=='recommended') { $app1[$i]['internallabel'] = 'Recommended'; $app1[$i]['internalclass'] = 'recommendedapp'; }else{ @@ -774,7 +820,9 @@ class OC_App{ $installedVersion = $versions[$app]; if (version_compare($currentVersion, $installedVersion, '>')) { $info = self::getAppInfo($app); - OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG); + OC_Log::write($app, + 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, + OC_Log::DEBUG); try { OC_App::updateApp($app); OC_Hook::emit('update', 'success', 'Updated '.$info['name'].' app'); @@ -804,7 +852,10 @@ class OC_App{ // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); if(!isset($info['require']) or (($version[0].'.'.$version[1])>$info['require'])) { - OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR); + OC_Log::write('core', + 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is' + .' not compatible with this version of ownCloud', + OC_Log::ERROR); OC_App::disable( $app ); OC_Hook::emit('update', 'success', 'Disabled '.$info['name'].' app because it is not compatible'); } @@ -820,7 +871,8 @@ class OC_App{ return $versions; // when function is used besides in checkUpgrade } $versions=array(); - $query = OC_DB::prepare( 'SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig` WHERE `configkey` = \'installed_version\'' ); + $query = OC_DB::prepare( 'SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig`' + .' WHERE `configkey` = \'installed_version\'' ); $result = $query->execute(); while($row = $result->fetchRow()) { $versions[$row['appid']]=$row['configvalue']; |