Merge branch 'refactoring' of git.kde.org:owncloud into refactoring

Conflicts:
	admin/apps.php
This commit is contained in:
Frank Karlitschek 2011-04-16 18:50:49 +02:00
commit 150631849f
26 changed files with 242 additions and 117 deletions

View File

@ -1,14 +1,10 @@
<?php
OC_APP::register( array( "order" => 1, "id" => "admin", "name" => "Administration" ));
if( OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' ))
{
OC_APP::addNavigationEntry( array( "id" => "admin_index", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "index.php" ), "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ), "name" => "Administration" ));
}
OC_APP::addAdminPage( array( "id" => "core_basic", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "basic.php" ), "name" => "Basic Settings" ));
OC_APP::addAdminPage( array( "id" => "core_system", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System settings" ));
OC_APP::addAdminPage( array( "id" => "core_users", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users" ));
OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps" ));
OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 5, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins" ));
OC_APP::addAdminPage( array( "id" => "core_system", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System settings", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
OC_APP::addAdminPage( array( "id" => "core_users", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 5, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
?>

View File

@ -24,14 +24,14 @@
require_once('../lib/base.php');
require( 'template.php' );
if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
header( "Location: ".OC_HELPER::linkTo( "", "index.php" ));
exit();
}
// Load the files we need
OC_UTIL::addStyle( "files", "files" );
OC_UTIL::addScript( "files", "files" );
//OC_UTIL::addStyle( "", "files" );
//OC_UTIL::addScript( "", "files" );
$categories=OC_OCSCLIENT::getCategories();
@ -39,7 +39,8 @@ $apps=OC_OCSCLIENT::getApplications($categories);
// return template
$tmpl = new OC_TEMPLATE( "files", "index", "user" );
$tmpl = new OC_TEMPLATE( "admin", "apps", "admin" );
$tmpl->assign( "categories", $categories );
$tmpl->assign( "apps", $apps );
$tmpl->printPage();
@ -47,3 +48,4 @@ $tmpl->printPage();
?>

View File

@ -24,7 +24,7 @@
require_once('../lib/base.php');
require( 'template.php' );
if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
header( "Location: ".OC_HELPER::linkTo( "","index.php" ));
exit();
}

101
admin/js/users.js Normal file
View File

@ -0,0 +1,101 @@
$(document).ready(function(){
// Dialog for adding users
$( "#adduser-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Create an account": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#adduser-button" )
.click(function() {
$( "#adduser-form" ).dialog( "open" );
return false;
});
// Dialog for adding users
$( "#edituser-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Edit password": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( ".edituser-button" )
.click(function() {
$( "#edituser-form" ).dialog( "open" );
return false;
});
// Dialog for adding users
$( "#removeuser-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Remove user": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( ".removeuser-button" )
.click(function() {
$( "#removeuser-form" ).dialog( "open" );
return false;
});
// Dialog for adding users
$( "#removegroup-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Remove group": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( ".removegroup-button" )
.click(function() {
$( "#removegroup-form" ).dialog( "open" );
return false;
});
} );

View File

@ -633,3 +633,18 @@ p.actions a.delete
border: 1px solid #CCC;
text-align: right;
}
li.error{
list-style:none;
width: 640px;
margin: 4em auto;
padding: 1em 1em 1em 4em;
background-color: #FEE;
background-image: url(../img/task-attention.png);
background-position: 0.8em 0.8em;
background-repeat: no-repeat;
border: 1px solid #CCC;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}

View File

@ -3,6 +3,6 @@
OC_APP::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
OC_APP::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "navicon.png" ), "name" => "Files" ));
OC_APP::addAdminPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files" ));
OC_APP::addSettingsPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files" ));
?>

5
help/appinfo/app.php Normal file
View File

@ -0,0 +1,5 @@
<?php
OC_APP::register( array( "id" => "help", "name" => "Help" ));
?>

34
help/index.php Normal file
View File

@ -0,0 +1,34 @@
<?php
require_once('../lib/base.php');
require( 'template.php' );
if( !OC_USER::isLoggedIn()){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
exit();
}
OC_APP::setActiveNavigationEntry( "help" );
$settings = array();
// Do the work ...
if( $_POST["submit"] )
{
if( $_POST["newpassword"] != $_POST["newpasswordconfirm"] ){
// Say "Passwords not equal"
}
else{
if( OC_USER::checkPassword( $_SESSION["username"], $_POST["password"] )){
// Set password
OC_USER::setPassord( $_SESSION["username"], $_POST["newpassword"] );
}
else{
// Say "old password bad"
}
}
}
$tmpl = new OC_TEMPLATE( "help", "index", "user" );
$tmpl->assign( "settings", $settings );
$tmpl->printPage();
?>

8
help/templates/index.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/*
* Template for settings page
*/
?>
<h1>Help</h1>
Help.

BIN
img/layout/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
img/layout/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
img/layout/logout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
img/layout/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

View File

@ -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
* @brief gets the active Menu entry
* @returns id or empty string
*
* 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")
*
* 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;
}
/**
@ -255,18 +243,6 @@ class OC_APP{
return OC_APP::$navigation;
}
/**
* @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

View File

@ -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;
@ -236,11 +236,23 @@ class OC_UTIL {
//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,7 +293,7 @@ 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

View File

@ -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();

View File

@ -1,6 +1,6 @@
<?php
OC_APP::register( array( "order" => 1, "id" => "log", "name" => "Log" ));
OC_APP::addPersonalMenuEntry( array( "order" => 2, "href" => OC_HELPER::linkTo( "log", "index.php" ), "name" => "Log" ));
OC_APP::addSettingsPage( array( "order" => 2, "href" => OC_HELPER::linkTo( "log", "index.php" ), "name" => "Log", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
?>

View File

@ -37,7 +37,7 @@ foreach( $logs as &$i ){
$i["action"] = OC_LOG::$TYPE[$i['type']];
}
$tmpl = new OC_TEMPLATE( "log", "index", "user" );
$tmpl = new OC_TEMPLATE( "log", "index", "admin" );
$tmpl->assign( "logs", $logs );
$tmpl->printPage();

View File

@ -2,3 +2,4 @@ audioplayer
ldap
test
textviewer
publiclink

View File

@ -1,6 +1,5 @@
<?php
OC_APP::register( array( "id" => "settings", "name" => "Settings" ));
OC_APP::addPersonalMenuEntry( array( "order" => 1, "href" => OC_HELPER::linkTo( "settings", "index.php" ), "name" => "Settings" ));
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

View File

@ -7,27 +7,8 @@ if( !OC_USER::isLoggedIn()){
exit();
}
$settings = array();
// Do the work ...
if( $_POST["submit"] )
{
if( $_POST["newpassword"] != $_POST["newpasswordconfirm"] ){
// Say "Passwords not equal"
}
else{
if( OC_USER::checkPassword( $_SESSION["username"], $_POST["password"] )){
// Set password
OC_USER::setPassord( $_SESSION["username"], $_POST["newpassword"] );
}
else{
// Say "old password bad"
}
}
}
$tmpl = new OC_TEMPLATE( "settings", "index", "user" );
$tmpl->assign( "settings", $settings );
$tmpl = new OC_TEMPLATE( "settings", "index", "admin" );
$tmpl->printPage();
?>

View File

@ -5,20 +5,4 @@
?>
<h1>Settings</h1>
<form action="" type="">
<p>
<span>New password:</span>
<input type="password" name="newpassword" value="">
</p>
<p>
<span>Confirm new password:</span>
<input type="password" name="newpasswordconfirm" value="">
</p>
<p>
<span>Old password:</span>
<input type="password" name="password" value="">
</p>
<p>
<input type="submit" name="submit" value="Send">
</p>
</form>
Welcome to the settings! Bla bla bla

View File

@ -5,10 +5,12 @@
?>
<div id="login">
<img src="<?php echo image_path("", "owncloud-logo-medium-white.png"); ?>" alt="ownCloud" />
<br/><br/><br/><br/>
<ul>
<?php foreach($_["errors"] as $error):?>
<li><?php echo $error ?></li>
<li class='error'>
<?php echo $error['error'] ?><br/>
<p class='hint'><?php echo $error['hint'] ?></p>
</li>
<?php endforeach ?>
</ul>
</div>

View File

@ -22,20 +22,20 @@
<a href="<?php echo link_to("", "index.php"); ?>" title="" id="owncloud"><img src="<?php echo image_path("", "owncloud-logo-small-white.png"); ?>" alt="ownCloud" /></a>
<div id="user">
<a id="user_menu_link" href="" title=""><? echo $_SESSION["user_id"] ?></a>
<ul id="user_menu">
<?php foreach($_["personalmenu"] as $entry): ?>
<li><a href="<?php echo $entry["href"]; ?>" title=""><?php echo $entry["name"]; ?></a></li>
<?php endforeach; ?>
</ul>
<a href="<?php echo link_to("","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/back.png"); ?>"></a>
<a href="<?php echo link_to("settings","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/settings.png"); ?>"></a>
<a href="<?php echo link_to("help","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/help.png"); ?>"></a>
<a href="<?php echo link_to("","index.php?logout=true"); ?>" title=""><img src="<?php echo image_path("", "layout/logout.png"); ?>"></a>
</div>
</div>
<div id="main">
<div id="plugins">
<ul>
<li><a style="background-image:url(<?php echo image_path("admin", "navicon.png"); ?>)" href="<?php echo link_to("admin", "index.php"); ?>" title="">Administration</a></li>
<li><a style="background-image:url(<?php echo image_path("", "actions/arrow-left.png"); ?>)" href="<?php echo link_to("", "index.php"); ?>" title="">Back</a></li>
<li><a style="background-image:url(<?php echo image_path("settings", "information.png"); ?>)" href="<?php echo link_to("settings", "index.php"); ?>" title="">Information</a></li>
<?php foreach($_["navigation"] as $entry):?>
<li><a style="background-image:url(<?php echo $entry["icon"]; ?>)" href="<?php echo $entry["href"]; ?>" title=""><?php echo $entry["name"] ?></a></li>
<?php endforeach; ?>
</ul>
</div>

View File

@ -22,12 +22,12 @@
<a href="<?php echo link_to("", "index.php"); ?>" title="" id="owncloud"><img src="<?php echo image_path("", "owncloud-logo-small-white.png"); ?>" alt="ownCloud" /></a>
<div id="user">
<a id="user_menu_link" href="" title=""><? echo $_SESSION["user_id"] ?></a>
<ul id="user_menu">
<?php foreach($_["personalmenu"] as $entry): ?>
<li><a href="<?php echo $entry["href"]; ?>" title=""><?php echo $entry["name"]; ?></a></li>
<?php endforeach; ?>
</ul>
<?php if( OC_APP::getActiveNavigationEntry() == "help" ): ?>
<a href="<?php echo link_to("","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/back.png"); ?>"></a>
<?php endif; ?>
<a href="<?php echo link_to("settings","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/settings.png"); ?>"></a>
<a href="<?php echo link_to("help","index.php"); ?>" title=""><img src="<?php echo image_path("", "layout/help.png"); ?>"></a>
<a href="<?php echo link_to("","index.php"); ?>?logout=true" title=""><img src="<?php echo image_path("", "layout/logout.png"); ?>"></a>
</div>
</div>