summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <karlitschek@kde.org>2011-04-16 18:50:49 +0200
committerFrank Karlitschek <karlitschek@kde.org>2011-04-16 18:50:49 +0200
commit150631849f5829eaf1f68517b1c81d4339a5f23b (patch)
tree6367ab3b09da151e3a83b0942b9bc93a333bcf94 /lib
parent1419b80d4eba7c57c79e46278a343db3d0a67b40 (diff)
parentf0e59b9043292a5abfb0b0d21763a0cd7306dad7 (diff)
downloadnextcloud-server-150631849f5829eaf1f68517b1c81d4339a5f23b.tar.gz
nextcloud-server-150631849f5829eaf1f68517b1c81d4339a5f23b.zip
Merge branch 'refactoring' of git.kde.org:owncloud into refactoring
Conflicts: admin/apps.php
Diffstat (limited to 'lib')
-rw-r--r--lib/app.php40
-rw-r--r--lib/base.php32
-rw-r--r--lib/template.php17
3 files changed, 43 insertions, 46 deletions
diff --git a/lib/app.php b/lib/app.php
index 9f1ce6f1047..5db3e047fd7 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -34,7 +34,6 @@ class OC_APP{
static private $settingspages = array();
static private $navigation = array();
static private $subnavigation = array();
- static private $personalmenu = array();
/**
* @brief loads all apps
@@ -53,7 +52,7 @@ class OC_APP{
}
// Our very own core apps are hardcoded
- foreach( array( "admin", "files", "log", "settings" ) as $app ){
+ foreach( array( "admin", "files", "log", "help", "settings" ) as $app ){
require( "$app/appinfo/app.php" );
}
@@ -165,31 +164,20 @@ class OC_APP{
* property from all other entries. The templates can use this for
* highlighting the current position of the user.
*/
- public static function activateNavigationEntry( $id ){
+ public static function setActiveNavigationEntry( $id ){
self::$activeapp = $id;
return true;
}
/**
- * @brief adds an entry to the personal menu
- * @param $data array containing the data
- * @returns true/false
- *
- * This function adds a new entry to the personal menu visible to users
- * only. $data is an associative array.
- * The following keys are required:
- * - id: unique id for this entry ("logout")
- * - href: link to the page
- * - name: Human readable name ("Logout")
+ * @brief gets the active Menu entry
+ * @returns id or empty string
*
- * The following keys are optional:
- * - order: integer, that influences the position of your application in
- * the personal menu. Lower values come first.
+ * This function returns the id of the active navigation entry (set by
+ * setActiveNavigationEntry
*/
- public static function addPersonalMenuEntry( $data ){
- // TODO: write function
- OC_APP::$personalmenu[] = $data;
- return true;
+ public static function getActiveNavigationEntry(){
+ return self::$activeapp;
}
/**
@@ -256,18 +244,6 @@ class OC_APP{
}
/**
- * @brief Returns the personal menu
- * @returns associative array
- *
- * This function returns an array containing all personal menu entries
- * added. The entries are sorted by the key "order" ascending.
- */
- public static function getPersonalMenu(){
- // TODO: write function
- return OC_APP::$personalmenu;
- }
-
- /**
* @brief Returns the admin pages
* @returns associative array
*
diff --git a/lib/base.php b/lib/base.php
index 31d4142900f..9ecf7db0778 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -85,6 +85,7 @@ require_once('log.php');
require_once('user.php');
require_once('group.php');
require_once('ocs.php');
+require_once('ocsclient.php');
require_once('connect.php');
require_once('remotestorage.php');
require_once('plugin.php');
@@ -104,7 +105,6 @@ if(!$error and !$RUNTIME_NOSETUPFS ){
}
// Add the stuff we need always
-OC_APP::addPersonalMenuEntry( array( "order" => 1000, "href" => OC_HELPER::linkTo( "", "index.php?logout=1" ), "name" => "Logout" ));
OC_UTIL::addScript( "jquery-1.5.min" );
OC_UTIL::addScript( "jquery-ui-1.8.10.custom.min" );
OC_UTIL::addScript( "js" );
@@ -223,7 +223,7 @@ class OC_UTIL {
/**
* check if the current server configuration is suitable for ownCloud
- * @return array with error messages
+ * @return array arrays with error messages and hints
*/
public static function checkServer(){
global $SERVERROOT;
@@ -233,14 +233,26 @@ class OC_UTIL {
$CONFIG_BACKUPDIRECTORY = OC_CONFIG::getValue( "backupdirectory", "$SERVERROOT/backup" );
$CONFIG_INSTALLED = OC_CONFIG::getValue( "installed", false );
$errors=array();
-
+
//check for database drivers
if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){
- $errors[]='No database drivers (sqlite or mysql) installed.<br/>';
+ $errors[]=array('error'=>'No database drivers (sqlite or mysql) installed.<br/>','hint'=>'');//TODO: sane hint
}
$CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_CONFIG::getValue( "dbname", "owncloud" );
+ //try to get the username the httpd server runs on, used in hints
+ $stat=stat($_SERVER['DOCUMENT_ROOT']);
+ if(is_callable('posix_getpwuid')){
+ $serverUser=posix_getpwuid($stat['uid']);
+ $serverUser='\''.$serverUser['name'].'\'';
+ }else{
+ $serverUser='\'www-data\' for ubuntu/debian';//TODO: try to detect the distro and give a guess based on that
+ }
+
+ //common hint for all file permissons error messages
+ $permissionsHint="Permissions can usually be fixed by setting the owner of the directory to the user the web server runs as ($serverUser)";
+
//check for correct file permissions
if(!stristr(PHP_OS, 'WIN')){
if($CONFIG_DBTYPE=='sqlite'){
@@ -252,7 +264,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($file)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='SQLite database file ('.$file.') is readable from the web<br/>';
+ $errors[]=array('error'=>'SQLite database file ('.$file.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
}
@@ -263,7 +275,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_DATADIRECTORY_ROOT)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
if( OC_CONFIG::getValue( "enablebackup", false )){
@@ -273,7 +285,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_BACKUPDIRECTORY)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
}
@@ -281,11 +293,11 @@ class OC_UTIL {
//TODO: premisions checks for windows hosts
}
if(!is_writable($CONFIG_DATADIRECTORY_ROOT)){
- $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') not writable by ownCloud<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') not writable by ownCloud<br/>','hint'=>$permissionsHint);
}
-
+
//TODO: check for php modules
-
+
return $errors;
}
}
diff --git a/lib/template.php b/lib/template.php
index c36b1e7a367..0e1c268efaa 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -190,11 +190,24 @@ class OC_TEMPLATE{
{
$page = new OC_TEMPLATE( "core", "layout.user" );
// Add menu data
+
+ // Add navigation entry
+ $page->assign( "navigation", OC_APP::getNavigation());
}
elseif( $this->renderas == "admin" )
{
$page = new OC_TEMPLATE( "core", "layout.admin" );
// Add menu data
+ $navigation = array();
+ if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){
+ foreach( OC_APP::getAdminPages() as $i ){
+ $navigation[] = $i;
+ }
+ }
+ foreach( OC_APP::getSettingsPages() as $i ){
+ $navigation[] = $i;
+ }
+ $page->assign( "navigation", $navigation );
}
else
{
@@ -210,10 +223,6 @@ class OC_TEMPLATE{
$page->append( "cssfiles", "$WEBROOT/$style.css" );
}
- // Add navigation entry and personal menu
- $page->assign( "navigation", OC_APP::getNavigation());
- $page->assign( "personalmenu", OC_APP::getPersonalMenu());
-
// Add css files and js files
$page->assign( "content", $data );
return $page->fetchPage();