More whitespace fixes

This commit is contained in:
Bart Visscher 2012-12-14 23:16:32 +01:00
parent 2ef2dc4dda
commit 68562dafb4
5 changed files with 117 additions and 116 deletions

View File

@ -347,20 +347,20 @@ abstract class Access {
} }
private function findMappedGroup($dn) { private function findMappedGroup($dn) {
static $query = null; static $query = null;
if(is_null($query)) { if(is_null($query)) {
$query = \OCP\DB::prepare(' $query = \OCP\DB::prepare('
SELECT `owncloud_name` SELECT `owncloud_name`
FROM `'.$this->getMapTable(false).'` FROM `'.$this->getMapTable(false).'`
WHERE `ldap_dn` = ?' WHERE `ldap_dn` = ?'
); );
} }
$res = $query->execute(array($dn))->fetchOne(); $res = $query->execute(array($dn))->fetchOne();
if($res) { if($res) {
return $res; return $res;
} }
return false; return false;
} }
private function ldap2ownCloudNames($ldapObjects, $isUsers) { private function ldap2ownCloudNames($ldapObjects, $isUsers) {

View File

@ -597,16 +597,16 @@ class OC_App{
$app1[$i]['internal'] = $app1[$i]['active'] = 0; $app1[$i]['internal'] = $app1[$i]['active'] = 0;
// rating img // rating img
if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" ); if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" );
elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" ); elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" );
elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" ); elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" );
elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" ); elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" );
elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" ); elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" );
elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" ); elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" );
elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" ); elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" );
elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" ); elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" );
elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" ); elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" );
elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" ); elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" );
elseif($app['score']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" ); elseif($app['score']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" );
$app1[$i]['score'] = '<img src="'.$img.'"> Score: '.$app['score'].'%'; $app1[$i]['score'] = '<img src="'.$img.'"> Score: '.$app['score'].'%';

View File

@ -80,65 +80,65 @@ class OC_Migrate{
*/ */
public static function export( $uid=null, $type='user', $path=null ) { public static function export( $uid=null, $type='user', $path=null ) {
$datadir = OC_Config::getValue( 'datadirectory' ); $datadir = OC_Config::getValue( 'datadirectory' );
// Validate export type // Validate export type
$types = array( 'user', 'instance', 'system', 'userfiles' ); $types = array( 'user', 'instance', 'system', 'userfiles' );
if( !in_array( $type, $types ) ) { if( !in_array( $type, $types ) ) {
OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR );
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
self::$exporttype = $type; self::$exporttype = $type;
// Userid? // Userid?
if( self::$exporttype == 'user' ) { if( self::$exporttype == 'user' ) {
// Check user exists // Check user exists
self::$uid = is_null($uid) ? OC_User::getUser() : $uid; self::$uid = is_null($uid) ? OC_User::getUser() : $uid;
if(!OC_User::userExists(self::$uid)) { if(!OC_User::userExists(self::$uid)) {
return json_encode( array( 'success' => false) ); return json_encode( array( 'success' => false) );
} }
} }
// Calculate zipname // Calculate zipname
if( self::$exporttype == 'user' ) { if( self::$exporttype == 'user' ) {
$zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip';
} else { } else {
$zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip';
} }
// Calculate path // Calculate path
if( self::$exporttype == 'user' ) { if( self::$exporttype == 'user' ) {
self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname;
} else { } else {
if( !is_null( $path ) ) { if( !is_null( $path ) ) {
// Validate custom path // Validate custom path
if( !file_exists( $path ) || !is_writeable( $path ) ) { if( !file_exists( $path ) || !is_writeable( $path ) ) {
OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR );
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
self::$zippath = $path . $zipname; self::$zippath = $path . $zipname;
} else { } else {
// Default path // Default path
self::$zippath = get_temp_dir() . '/' . $zipname; self::$zippath = get_temp_dir() . '/' . $zipname;
} }
} }
// Create the zip object // Create the zip object
if( !self::createZip() ) { if( !self::createZip() ) {
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
// Do the export // Do the export
self::findProviders(); self::findProviders();
$exportdata = array(); $exportdata = array();
switch( self::$exporttype ) { switch( self::$exporttype ) {
case 'user': case 'user':
// Connect to the db // Connect to the db
self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; self::$dbpath = $datadir . '/' . self::$uid . '/migration.db';
if( !self::connectDB() ) { if( !self::connectDB() ) {
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 );
// Export the app info // Export the app info
$exportdata = self::exportAppData(); $exportdata = self::exportAppData();
// Add the data dir to the zip // Add the data dir to the zip
self::$content->addDir(OC_User::getHome(self::$uid), true, '/' ); self::$content->addDir(OC_User::getHome(self::$uid), true, '/' );
break; break;
case 'instance': case 'instance':
self::$content = new OC_Migration_Content( self::$zip ); self::$content = new OC_Migration_Content( self::$zip );
// Creates a zip that is compatable with the import function // Creates a zip that is compatable with the import function
$dbfile = tempnam( get_temp_dir(), "owncloud_export_data_" ); $dbfile = tempnam( get_temp_dir(), "owncloud_export_data_" );
OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL'); OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL');
@ -155,32 +155,32 @@ class OC_Migrate{
foreach(OC_User::getUsers() as $user) { foreach(OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/userdata/" ); self::$content->addDir(OC_User::getHome($user), true, "/userdata/" );
} }
break; break;
case 'userfiles': case 'userfiles':
self::$content = new OC_Migration_Content( self::$zip ); self::$content = new OC_Migration_Content( self::$zip );
// Creates a zip with all of the users files // Creates a zip with all of the users files
foreach(OC_User::getUsers() as $user) { foreach(OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/" ); self::$content->addDir(OC_User::getHome($user), true, "/" );
} }
break; break;
case 'system': case 'system':
self::$content = new OC_Migration_Content( self::$zip ); self::$content = new OC_Migration_Content( self::$zip );
// Creates a zip with the owncloud system files // Creates a zip with the owncloud system files
self::$content->addDir( OC::$SERVERROOT . '/', false, '/'); self::$content->addDir( OC::$SERVERROOT . '/', false, '/');
foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) { foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) {
self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/");
} }
break; break;
} }
if( !$info = self::getExportInfo( $exportdata ) ) { if( !$info = self::getExportInfo( $exportdata ) ) {
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
// Add the export info json to the export zip // Add the export info json to the export zip
self::$content->addFromString( $info, 'export_info.json' ); self::$content->addFromString( $info, 'export_info.json' );
if( !self::$content->finish() ) { if( !self::$content->finish() ) {
return json_encode( array( 'success' => false ) ); return json_encode( array( 'success' => false ) );
} }
return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); return json_encode( array( 'success' => true, 'data' => self::$zippath ) );
} }
/** /**
@ -254,7 +254,7 @@ class OC_Migrate{
OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR );
} }
return json_encode( array( 'success' => true, 'data' => $appsimported ) ); return json_encode( array( 'success' => true, 'data' => $appsimported ) );
break; break;
case 'instance': case 'instance':
/* /*
* EXPERIMENTAL * EXPERIMENTAL
@ -281,7 +281,7 @@ class OC_Migrate{
// Done // Done
return json_encode( array( 'success' => true ) ); return json_encode( array( 'success' => true ) );
*/ */
break; break;
} }
} }
@ -319,10 +319,10 @@ class OC_Migrate{
static private function extractZip( $path ) { static private function extractZip( $path ) {
self::$zip = new ZipArchive; self::$zip = new ZipArchive;
// Validate path // Validate path
if( !file_exists( $path ) ) { if( !file_exists( $path ) ) {
OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR );
return false; return false;
} }
if ( self::$zip->open( $path ) != true ) { if ( self::$zip->open( $path ) != true ) {
OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR ); OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR );
return false; return false;
@ -555,9 +555,9 @@ class OC_Migrate{
if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) { if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) {
OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR);
return false; return false;
} else { } else {
return true; return true;
} }
} }
/** /**

View File

@ -54,29 +54,30 @@ namespace OCP {
* Example: * Example:
* Following function shows how to search for contacts for the name and the email address. * Following function shows how to search for contacts for the name and the email address.
* *
* public static function getMatchingRecipient($term) { * public static function getMatchingRecipient($term) {
* // The API is not active -> nothing to do * // The API is not active -> nothing to do
* if (!\OCP\Contacts::isEnabled()) { * if (!\OCP\Contacts::isEnabled()) {
* return array(); * return array();
* } * }
* *
* $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL'));
* $receivers = array(); * $receivers = array();
* foreach ($result as $r) { * foreach ($result as $r) {
* $id = $r['id']; * $id = $r['id'];
* $fn = $r['FN']; * $fn = $r['FN'];
* $email = $r['EMAIL']; * $email = $r['EMAIL'];
* if (!is_array($email)) { * if (!is_array($email)) {
* $email = array($email); * $email = array($email);
* } * }
* *
* // loop through all email addresses of this contact * // loop through all email addresses of this contact
* foreach ($email as $e) { * foreach ($email as $e) {
* $displayName = $fn . " <$e>"; * $displayName = $fn . " <$e>";
* $receivers[] = array('id' => $id, * $receivers[] = array(
* 'label' => $displayName, * 'id' => $id,
* 'value' => $displayName); * 'label' => $displayName,
* } * 'value' => $displayName);
* }
* } * }
* *
* return $receivers; * return $receivers;

View File

@ -64,7 +64,7 @@ var UserList={
} }
} }
}); });
} }
}, },
add:function(username, groups, subadmin, quota, sort) { add:function(username, groups, subadmin, quota, sort) {