Respect coding style
This commit is contained in:
parent
a3cda32392
commit
9760b5e153
1 changed files with 50 additions and 50 deletions
100
lib/app.php
100
lib/app.php
|
@ -54,14 +54,14 @@ class OC_App{
|
|||
// prevent app.php from printing output
|
||||
ob_start();
|
||||
foreach( $apps as $app ){
|
||||
if((is_null($types) or self::isType($app,$types)) && !in_array($app, self::$loadedApps)){
|
||||
if((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
|
||||
self::loadApp($app);
|
||||
self::$loadedApps[] = $app;
|
||||
}
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
if (!defined('DEBUG') || !DEBUG){
|
||||
if (!defined('DEBUG') || !DEBUG) {
|
||||
if (is_null($types)) {
|
||||
OC_Util::$core_scripts = OC_Util::$scripts;
|
||||
OC_Util::$scripts = array();
|
||||
|
@ -82,10 +82,10 @@ class OC_App{
|
|||
* load a single app
|
||||
* @param string app
|
||||
*/
|
||||
public static function loadApp($app){
|
||||
public static function loadApp($app) {
|
||||
if(is_file(self::getAppPath($app).'/appinfo/app.php')){
|
||||
self::checkUpgrade($app);
|
||||
require_once( $app.'/appinfo/app.php' );
|
||||
require_once $app.'/appinfo/app.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,12 +95,12 @@ class OC_App{
|
|||
* @param string/array $types
|
||||
*/
|
||||
public static function isType($app,$types){
|
||||
if(is_string($types)){
|
||||
if(is_string($types)) {
|
||||
$types=array($types);
|
||||
}
|
||||
$appTypes=self::getAppTypes($app);
|
||||
foreach($types as $type){
|
||||
if(array_search($type,$appTypes)!==false){
|
||||
if(array_search($type, $appTypes)!==false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -114,12 +114,12 @@ class OC_App{
|
|||
*/
|
||||
private static function getAppTypes($app){
|
||||
//load the cache
|
||||
if(count(self::$appTypes)==0){
|
||||
self::$appTypes=OC_Appconfig::getValues(false,'types');
|
||||
if(count(self::$appTypes)==0) {
|
||||
self::$appTypes=OC_Appconfig::getValues(false, 'types');
|
||||
}
|
||||
|
||||
if(isset(self::$appTypes[$app])){
|
||||
return explode(',',self::$appTypes[$app]);
|
||||
if(isset(self::$appTypes[$app])) {
|
||||
return explode(',', self::$appTypes[$app]);
|
||||
}else{
|
||||
return array();
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ class OC_App{
|
|||
public static function setAppTypes($app){
|
||||
$appData=self::getAppInfo($app);
|
||||
|
||||
if(isset($appData['types'])){
|
||||
$appTypes=implode(',',$appData['types']);
|
||||
if(isset($appData['types'])) {
|
||||
$appTypes=implode(',', $appData['types']);
|
||||
}else{
|
||||
$appTypes='';
|
||||
}
|
||||
|
||||
OC_Appconfig::setValue($app,'types',$appTypes);
|
||||
OC_Appconfig::setValue($app, 'types', $appTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ class OC_App{
|
|||
$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){
|
||||
if(array_search($row['appid'], $apps)===false) {
|
||||
$apps[]=$row['appid'];
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ class OC_App{
|
|||
* This function checks whether or not an app is enabled.
|
||||
*/
|
||||
public static function isEnabled( $app ){
|
||||
if( 'files'==$app or 'yes' == OC_Appconfig::getValue( $app, 'enabled' )){
|
||||
if( 'files'==$app or 'yes' == OC_Appconfig::getValue( $app, 'enabled' )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -180,23 +180,23 @@ class OC_App{
|
|||
* This function set an app as enabled in appconfig.
|
||||
*/
|
||||
public static function enable( $app ){
|
||||
if(!OC_Installer::isInstalled($app)){
|
||||
if(!OC_Installer::isInstalled($app)) {
|
||||
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
|
||||
if(!is_numeric($app)){
|
||||
if(!is_numeric($app)) {
|
||||
$app = OC_Installer::installShippedApp($app);
|
||||
}else{
|
||||
$download=OC_OCSClient::getApplicationDownload($app,1);
|
||||
$download=OC_OCSClient::getApplicationDownload($app, 1);
|
||||
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
|
||||
$app=OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if($app!==false){
|
||||
if($app!==false) {
|
||||
// check if the app is compatible with this version of ownCloud
|
||||
$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);
|
||||
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);
|
||||
return false;
|
||||
}else{
|
||||
OC_Appconfig::setValue( $app, 'enabled', 'yes' );
|
||||
|
@ -239,7 +239,7 @@ class OC_App{
|
|||
*/
|
||||
public static function addNavigationEntry( $data ){
|
||||
$data['active']=false;
|
||||
if(!isset($data['icon'])){
|
||||
if(!isset($data['icon'])) {
|
||||
$data['icon']='';
|
||||
}
|
||||
OC_App::$navigation[] = $data;
|
||||
|
@ -283,7 +283,7 @@ class OC_App{
|
|||
|
||||
$settings = array();
|
||||
// by default, settings only contain the help menu
|
||||
if(OC_Config::getValue('knowledgebaseenabled', true)==true){
|
||||
if(OC_Config::getValue('knowledgebaseenabled', true)==true) {
|
||||
$settings = array(
|
||||
array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "help.php" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "settings", "help.svg" ))
|
||||
);
|
||||
|
@ -300,7 +300,7 @@ class OC_App{
|
|||
$settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "settings.php" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" ));
|
||||
|
||||
//SubAdmins are also allowed to access user management
|
||||
if(OC_SubAdmin::isSubAdmin($_SESSION["user_id"]) || OC_Group::inGroup( $_SESSION["user_id"], "admin" )){
|
||||
if(OC_SubAdmin::isSubAdmin($_SESSION["user_id"]) || OC_Group::inGroup( $_SESSION["user_id"], "admin" )) {
|
||||
// admin users menu
|
||||
$settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "settings", "users.php" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" ));
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class OC_App{
|
|||
private static function proceedNavigation( $list ){
|
||||
foreach( $list as &$naventry ){
|
||||
$naventry['subnavigation'] = array();
|
||||
if( $naventry['id'] == self::$activeapp ){
|
||||
if( $naventry['id'] == self::$activeapp ) {
|
||||
$naventry['active'] = true;
|
||||
}
|
||||
else{
|
||||
|
@ -349,7 +349,7 @@ class OC_App{
|
|||
return $dir['path'];
|
||||
}
|
||||
|
||||
OC_Log::write('core','No application directories are marked as writable.',OC_Log::ERROR);
|
||||
OC_Log::write('core', 'No application directories are marked as writable.', OC_Log::ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ class OC_App{
|
|||
public static function getAppVersion($appid){
|
||||
$file= self::getAppPath($appid).'/appinfo/version';
|
||||
$version=@file_get_contents($file);
|
||||
if($version){
|
||||
if($version) {
|
||||
return trim($version);
|
||||
}else{
|
||||
$appData=self::getAppInfo($appid);
|
||||
|
@ -406,17 +406,17 @@ class OC_App{
|
|||
* @returns array
|
||||
*/
|
||||
public static function getAppInfo($appid,$path=false){
|
||||
if($path){
|
||||
if($path) {
|
||||
$file=$appid;
|
||||
}else{
|
||||
if(isset(self::$appInfo[$appid])){
|
||||
if(isset(self::$appInfo[$appid])) {
|
||||
return self::$appInfo[$appid];
|
||||
}
|
||||
$file= self::getAppPath($appid).'/appinfo/info.xml';
|
||||
}
|
||||
$data=array();
|
||||
$content=@file_get_contents($file);
|
||||
if(!$content){
|
||||
if(!$content) {
|
||||
return;
|
||||
}
|
||||
$xml = new SimpleXMLElement($content);
|
||||
|
@ -424,22 +424,22 @@ class OC_App{
|
|||
$data['remote']=array();
|
||||
$data['public']=array();
|
||||
foreach($xml->children() as $child){
|
||||
if($child->getName()=='remote'){
|
||||
if($child->getName()=='remote') {
|
||||
foreach($child->children() as $remote){
|
||||
$data['remote'][$remote->getName()]=(string)$remote;
|
||||
}
|
||||
}elseif($child->getName()=='public'){
|
||||
}elseif($child->getName()=='public') {
|
||||
foreach($child->children() as $public){
|
||||
$data['public'][$public->getName()]=(string)$public;
|
||||
}
|
||||
}elseif($child->getName()=='types'){
|
||||
}elseif($child->getName()=='types') {
|
||||
$data['types']=array();
|
||||
foreach($child->children() as $type){
|
||||
$data['types'][]=$type->getName();
|
||||
}
|
||||
}elseif($child->getName()=='description'){
|
||||
}elseif($child->getName()=='description') {
|
||||
$xml=(string)$child->asXML();
|
||||
$data[$child->getName()]=substr($xml,13,-14);//script <description> tags
|
||||
$data[$child->getName()]=substr($xml, 13, -14);//script <description> tags
|
||||
}else{
|
||||
$data[$child->getName()]=(string)$child;
|
||||
}
|
||||
|
@ -469,11 +469,11 @@ class OC_App{
|
|||
* @return string
|
||||
*/
|
||||
public static function getCurrentApp(){
|
||||
$script=substr($_SERVER["SCRIPT_NAME"],strlen(OC::$WEBROOT)+1);
|
||||
$topFolder=substr($script,0,strpos($script,'/'));
|
||||
if($topFolder=='apps'){
|
||||
$script=substr($_SERVER["SCRIPT_NAME"], strlen(OC::$WEBROOT)+1);
|
||||
$topFolder=substr($script, 0, strpos($script, '/'));
|
||||
if($topFolder=='apps') {
|
||||
$length=strlen($topFolder);
|
||||
return substr($script,$length+1,strpos($script,'/',$length+1)-$length-1);
|
||||
return substr($script, $length+1, strpos($script, '/', $length+1)-$length-1);
|
||||
}else{
|
||||
return $topFolder;
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ class OC_App{
|
|||
foreach(OC::$APPSROOTS as $apps_dir) {
|
||||
$dh=opendir($apps_dir['path']);
|
||||
while($file=readdir($dh)){
|
||||
if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')){
|
||||
if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
|
||||
$apps[]=$file;
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ class OC_App{
|
|||
if ($currentVersion) {
|
||||
$installedVersion = $versions[$app];
|
||||
if (version_compare($currentVersion, $installedVersion, '>')) {
|
||||
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);
|
||||
OC_App::updateApp($app);
|
||||
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
|
||||
}
|
||||
|
@ -573,8 +573,8 @@ class OC_App{
|
|||
foreach($apps as $app) {
|
||||
// check if the app is compatible with this version of ownCloud
|
||||
$info = OC_App::getAppInfo($app);
|
||||
if(!isset($info['require']) or ($version[0]>$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);
|
||||
if(!isset($info['require']) or ($version[0]>$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_App::disable( $app );
|
||||
}
|
||||
}
|
||||
|
@ -602,13 +602,13 @@ class OC_App{
|
|||
* @param string appid
|
||||
*/
|
||||
public static function updateApp($appid){
|
||||
if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')){
|
||||
if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')) {
|
||||
OC_DB::updateDbFromStructure(self::getAppPath($appid).'/appinfo/database.xml');
|
||||
}
|
||||
if(!self::isEnabled($appid)){
|
||||
if(!self::isEnabled($appid)) {
|
||||
return;
|
||||
}
|
||||
if(file_exists(self::getAppPath($appid).'/appinfo/update.php')){
|
||||
if(file_exists(self::getAppPath($appid).'/appinfo/update.php')) {
|
||||
self::loadApp($appid);
|
||||
include self::getAppPath($appid).'/appinfo/update.php';
|
||||
}
|
||||
|
@ -630,19 +630,19 @@ class OC_App{
|
|||
* @return OC_FilesystemView
|
||||
*/
|
||||
public static function getStorage($appid){
|
||||
if(OC_App::isEnabled($appid)){//sanity check
|
||||
if(OC_User::isLoggedIn()){
|
||||
if(OC_App::isEnabled($appid)) {//sanity check
|
||||
if(OC_User::isLoggedIn()) {
|
||||
$view = new OC_FilesystemView('/'.OC_User::getUser());
|
||||
if(!$view->file_exists($appid)) {
|
||||
$view->mkdir($appid);
|
||||
}
|
||||
return new OC_FilesystemView('/'.OC_User::getUser().'/'.$appid);
|
||||
}else{
|
||||
OC_Log::write('core','Can\'t get app storage, app, user not logged in',OC_Log::ERROR);
|
||||
OC_Log::write('core', 'Can\'t get app storage, app, user not logged in', OC_Log::ERROR);
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
OC_Log::write('core','Can\'t get app storage, app '.$appid.' not enabled',OC_Log::ERROR);
|
||||
OC_Log::write('core', 'Can\'t get app storage, app '.$appid.' not enabled', OC_Log::ERROR);
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue