summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-10 11:30:44 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-10 11:30:44 +0200
commit13e7e82d19bd36ae59128e94a12b05e95cea1b48 (patch)
tree5cff57fb4e8dc1b079d3a12e596a1976172737ea /lib
parent13515effc99bfad7e776d00476e897fa396a8c6c (diff)
parentaa13a585132fb1fd57d3af005f1d637a941d26cc (diff)
downloadnextcloud-server-13e7e82d19bd36ae59128e94a12b05e95cea1b48.tar.gz
nextcloud-server-13e7e82d19bd36ae59128e94a12b05e95cea1b48.zip
merge master into filesystem
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php37
-rw-r--r--lib/db.php16
-rw-r--r--lib/filecache.php2
-rw-r--r--lib/files.php17
-rw-r--r--lib/ocsclient.php74
-rw-r--r--lib/public/share.php5
-rwxr-xr-xlib/util.php6
7 files changed, 66 insertions, 91 deletions
diff --git a/lib/app.php b/lib/app.php
index 90b5c58a448..395230156f6 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -578,50 +578,45 @@ class OC_App{
* @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
*/
public static function getAppstoreApps( $filter = 'approved' ) {
-
$catagoryNames = OC_OCSClient::getCategories();
-
if ( is_array( $catagoryNames ) ) {
-
// Check that categories of apps were retrieved correctly
if ( ! $categories = array_keys( $catagoryNames ) ) {
-
return false;
-
}
$page = 0;
-
$remoteApps = OC_OCSClient::getApplications( $categories, $page, $filter );
-
$app1 = array();
-
$i = 0;
-
foreach ( $remoteApps as $app ) {
-
$app1[$i] = $app;
-
$app1[$i]['author'] = $app['personid'];
-
$app1[$i]['ocs_id'] = $app['id'];
-
$app1[$i]['internal'] = $app1[$i]['active'] = 0;
-
+
+ // rating img
+ 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']>=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']>=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']>=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']>=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']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" );
+
+ $app1[$i]['score'] = '<img src="'.$img.'"> Score: '.$app['score'].'%';
$i++;
-
}
-
}
-
+
if ( empty( $app1 ) ) {
-
return false;
-
} else {
-
return $app1;
-
}
}
diff --git a/lib/db.php b/lib/db.php
index 256ae5b6bf3..f1597fb49fe 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -427,14 +427,14 @@ class OC_DB {
$file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
- /* FIXME: REMOVE this commented code
- * actually mysql, postgresql, sqlite and oracle support CURRENT_TIMESTAMP
+ /* FIXME: use CURRENT_TIMESTAMP for all databases. mysql supports it as a default for DATETIME since 5.6.5 [1]
+ * as a fallback we could use <default>0000-01-01 00:00:00</default> everywhere
+ * [1] http://bugs.mysql.com/bug.php?id=27645
* http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html
* http://www.postgresql.org/docs/8.1/static/functions-datetime.html
* http://www.sqlite.org/lang_createtable.html
* http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
*/
-
if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't
$content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content );
}
@@ -475,7 +475,8 @@ class OC_DB {
*/
public static function updateDbFromStructure($file) {
$CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
-
+ $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
+
self::connectScheme();
// read file
@@ -493,16 +494,17 @@ class OC_DB {
$file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $previousSchema['name'], $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
- /* FIXME: REMOVE this commented code
- * actually mysql, postgresql, sqlite and oracle support CUURENT_TIMESTAMP
+ /* FIXME: use CURRENT_TIMESTAMP for all databases. mysql supports it as a default for DATETIME since 5.6.5 [1]
+ * as a fallback we could use <default>0000-01-01 00:00:00</default> everywhere
+ * [1] http://bugs.mysql.com/bug.php?id=27645
* http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html
* http://www.postgresql.org/docs/8.1/static/functions-datetime.html
* http://www.sqlite.org/lang_createtable.html
* http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
+ */
if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't
$content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content );
}
- */
file_put_contents( $file2, $content );
$op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
diff --git a/lib/filecache.php b/lib/filecache.php
index d68525d9a54..8fcb6fd9404 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -79,7 +79,7 @@ class OC_FileCache{
// add parent directory to the file cache if it does not exist yet.
if ($parent == -1 && $fullpath != $root) {
- $parentDir = substr(dirname($path), 0, strrpos(dirname($path), DIRECTORY_SEPARATOR));
+ $parentDir = dirname($path);
self::scanFile($parentDir);
$parent = self::getParentId($fullpath);
}
diff --git a/lib/files.php b/lib/files.php
index ac999a9bd15..2b2b8b42dc4 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -44,15 +44,16 @@ class OC_Files {
public static function getFileInfo($path) {
if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
if ($path == '/Shared') {
- $info = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
- }
- else {
- $path = substr($path, 7);
- $info = OCP\Share::getItemSharedWith('file', $path, OC_Share_Backend_File::FORMAT_FILE_APP);
+ list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
+ }else{
+ $info['size'] = OC_Filesystem::filesize($path);
+ $info['mtime'] = OC_Filesystem::filemtime($path);
+ $info['ctime'] = OC_Filesystem::filectime($path);
+ $info['mimetype'] = OC_Filesystem::getMimeType($path);
+ $info['encrypted'] = false;
+ $info['versioned'] = false;
}
- $info = $info[0];
- }
- else {
+ } else {
$info = OC_FileCache::get($path);
}
return $info;
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index fc2095f5c15..794bc972f57 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -49,6 +49,24 @@ class OC_OCSClient{
return($url);
}
+ /**
+ * @brief Get the content of an OCS url call.
+ * @returns string of the response
+ * This function calls an OCS server and returns the response. It also sets a sane timeout
+ */
+ private static function getOCSresponse($url) {
+ // set a sensible timeout of 10 sec to stay responsive even if the server is down.
+ $ctx = stream_context_create(
+ array(
+ 'http' => array(
+ 'timeout' => 10
+ )
+ )
+ );
+ $data=@file_get_contents($url, 0, $ctx);
+ return($data);
+ }
+
/**
* @brief Get all the categories from the OCS server
@@ -61,16 +79,7 @@ class OC_OCSClient{
return NULL;
}
$url=OC_OCSClient::getAppStoreURL().'/content/categories';
-
- // set a sensible timeout of 10 sec to stay responsive even if the server is down.
- $ctx = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => 10
- )
- )
- );
- $xml=@file_get_contents($url, 0, $ctx);
+ $xml=OC_OCSClient::getOCSresponse($url);
if($xml==FALSE) {
return NULL;
}
@@ -111,16 +120,7 @@ class OC_OCSClient{
$filterurl='&filter='.urlencode($filter);
$url=OC_OCSClient::getAppStoreURL().'/content/data?categories='.urlencode($categoriesstring).'&sortmode=new&page='.urlencode($page).'&pagesize=100'.$filterurl.$version;
$apps=array();
-
- // set a sensible timeout of 10 sec to stay responsive even if the server is down.
- $ctx = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => 10
- )
- )
- );
- $xml=@file_get_contents($url, 0, $ctx);
+ $xml=OC_OCSClient::getOCSresponse($url);
if($xml==FALSE) {
return NULL;
@@ -140,6 +140,7 @@ class OC_OCSClient{
$app['preview']=(string)$tmp[$i]->smallpreviewpic1;
$app['changed']=strtotime($tmp[$i]->changed);
$app['description']=(string)$tmp[$i]->description;
+ $app['score']=(string)$tmp[$i]->score;
$apps[]=$app;
}
@@ -158,16 +159,8 @@ class OC_OCSClient{
return NULL;
}
$url=OC_OCSClient::getAppStoreURL().'/content/data/'.urlencode($id);
+ $xml=OC_OCSClient::getOCSresponse($url);
- // set a sensible timeout of 10 sec to stay responsive even if the server is down.
- $ctx = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => 10
- )
- )
- );
- $xml=@file_get_contents($url, 0, $ctx);
if($xml==FALSE) {
OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
return NULL;
@@ -188,6 +181,7 @@ class OC_OCSClient{
$app['changed']=strtotime($tmp->changed);
$app['description']=$tmp->description;
$app['detailpage']=$tmp->detailpage;
+ $app['score']=$tmp->score;
return $app;
}
@@ -203,16 +197,7 @@ class OC_OCSClient{
return NULL;
}
$url=OC_OCSClient::getAppStoreURL().'/content/download/'.urlencode($id).'/'.urlencode($item);
-
- // set a sensible timeout of 10 sec to stay responsive even if the server is down.
- $ctx = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => 10
- )
- )
- );
- $xml=@file_get_contents($url, 0, $ctx);
+ $xml=OC_OCSClient::getOCSresponse($url);
if($xml==FALSE) {
OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
@@ -250,16 +235,7 @@ class OC_OCSClient{
$url=OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s.$searchcmd;
$kbe=array();
-
- // set a sensible timeout of 10 sec to stay responsive even if the server is down.
- $ctx = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => 10
- )
- )
- );
- $xml=@file_get_contents($url, 0, $ctx);
+ $xml=OC_OCSClient::getOCSresponse($url);
if($xml==FALSE) {
OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL);
diff --git a/lib/public/share.php b/lib/public/share.php
index 75363d081c0..1db3a0b2c1d 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -173,6 +173,7 @@ class Share {
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
$uidOwner = \OC_User::getUser();
+ $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
// Verify share type and sharing conditions are met
if ($shareType === self::SHARE_TYPE_USER) {
if ($shareWith == $uidOwner) {
@@ -185,7 +186,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') {
+ if ($sharingPolicy == 'groups_only') {
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
if (empty($inGroup)) {
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';
@@ -208,7 +209,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (!\OC_Group::inGroup($uidOwner, $shareWith)) {
+ if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {
$message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith;
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
diff --git a/lib/util.php b/lib/util.php
index 754360c1932..b21580cb017 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -80,8 +80,8 @@ class OC_Util {
* @return array
*/
public static function getVersion() {
- // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.9.0. This is not visible to the user
- return array(4,87,13);
+ // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user
+ return array(4,91,00);
}
/**
@@ -89,7 +89,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '4.5 RC 2';
+ return '4.5';
}
/**