Merge branch 'master' into calendar_sharing

This commit is contained in:
Georg Ehrke 2012-02-12 10:46:34 +01:00
commit c9db88aa3b
7 changed files with 195 additions and 90 deletions

View File

@ -19,7 +19,7 @@ $caldavBackend = new OC_Connector_Sabre_CalDAV();
// Root nodes
$nodes = array(
new Sabre_DAVACL_PrincipalCollection($principalBackend),
new Sabre_CalDAV_Principal_Collection($principalBackend),
new Sabre_CalDAV_CalendarRootNode($principalBackend, $caldavBackend),
);

View File

@ -33,7 +33,7 @@ $carddavBackend = new OC_Connector_Sabre_CardDAV();
// Root nodes
$nodes = array(
new Sabre_DAVACL_PrincipalCollection($principalBackend),
new Sabre_CalDAV_Principal_Collection($principalBackend),
new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend),
);

1
config/config.sample.php Normal file → Executable file
View File

@ -12,6 +12,7 @@ $CONFIG = array(
"dbtableprefix" => "",
"forcessl" => false,
"enablebackup" => false,
"theme" => "",
// "datadirectory" => ""
);
?>

View File

@ -142,6 +142,13 @@ class OC{
// set the right include path
set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$SERVERROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
$url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
header("Location: $url");
exit();
}
// redirect to https site if configured
if( OC_Config::getValue( "forcessl", false )){
ini_set("session.cookie_secure", "on");

View File

@ -44,6 +44,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
}
return true;
}
/**
* Returns a list of principals based on a prefix.
*
@ -57,22 +58,17 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* @param string $prefixPath
* @return array
*/
public function getPrincipalsByPrefix( $prefixPath ){
$query = OC_DB::prepare('SELECT * FROM *PREFIX*principals');
$result = $query->execute();
public function getPrincipalsByPrefix( $prefixPath ) {
$principals = array();
while($row = $result->fetchRow()){
// Checking if the principal is in the prefix
list($rowPrefix) = Sabre_DAV_URLUtil::splitPath($row['uri']);
if ($rowPrefix !== $prefixPath) continue;
$principals[] = array(
'uri' => $row['uri'],
'{DAV:}displayname' => $row['displayname']?$row['displayname']:basename($row['uri'])
);
if ($prefixPath == 'principals') {
foreach(OC_User::getUsers() as $user) {
$user_uri = 'principals/'.$user;
$principals[] = array(
'uri' => $user_uri,
'{DAV:}displayname' => $user,
);
}
}
return $principals;
@ -87,20 +83,16 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* @return array
*/
public function getPrincipalByPath($path) {
$query = OC_DB::prepare('SELECT * FROM *PREFIX*principals WHERE uri=?');
$result = $query->execute(array($path));
list($prefix,$name) = Sabre_DAV_URLUtil::splitPath($path);
$users = array();
$row = $result->fetchRow();
if (!$row) return;
return array(
'id' => $row['id'],
'uri' => $row['uri'],
'{DAV:}displayname' => $row['displayname']?$row['displayname']:basename($row['uri'])
);
if ($prefix == 'principals' && OC_User::userExists($name)) {
return array(
'uri' => 'principals/'.$name,
'{DAV:}displayname' => $name,
);
}
return null;
}
/**
@ -110,17 +102,15 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* @return array
*/
public function getGroupMemberSet($principal) {
$principal = $this->getPrincipalByPath($principal);
// TODO: for now the group principal has only one member, the user itself
list($prefix,$name) = Sabre_DAV_URLUtil::splitPath($principal);
$principal = $this->getPrincipalByPath($prefix);
if (!$principal) throw new Sabre_DAV_Exception('Principal not found');
$query = OC_DB::prepare('SELECT principals.uri as uri FROM *PREFIX*principalgroups AS groupmembers LEFT JOIN *PREFIX*principals AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?');
$result = $query->execute(array($principal['id']));
$return = array();
while ($row = $result->fetchRow()){
$return[] = $row['uri'];
}
return $return;
return array(
$prefix
);
}
/**
@ -130,17 +120,24 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* @return array
*/
public function getGroupMembership($principal) {
$principal = $this->getPrincipalByPath($principal);
if (!$principal) throw new Sabre_DAV_Exception('Principal not found');
list($prefix,$name) = Sabre_DAV_URLUtil::splitPath($principal);
$query = OC_DB::prepare('SELECT principals.uri as uri FROM *PREFIX*principalgroups AS groupmembers LEFT JOIN *PREFIX*principals AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.member_id = ?');
$result = $query->execute(array($principal['id']));
$group_membership = array();
if ($prefix == 'principals') {
$principal = $this->getPrincipalByPath($principal);
if (!$principal) throw new Sabre_DAV_Exception('Principal not found');
$return = array();
while ($row = $result->fetchRow()){
$return[] = $row['uri'];
// TODO: for now the user principal has only its own groups
return array(
'principals/'.$name.'/calendar-proxy-read',
'principals/'.$name.'/calendar-proxy-write',
// The addressbook groups are not supported in Sabre,
// see http://groups.google.com/group/sabredav-discuss/browse_thread/thread/ef2fa9759d55f8c#msg_5720afc11602e753
//'principals/'.$name.'/addressbook-proxy-read',
//'principals/'.$name.'/addressbook-proxy-write',
);
}
return $return;
return $group_membership;
}
/**
@ -153,29 +150,6 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* @return void
*/
public function setGroupMemberSet($principal, array $members) {
$query = OC_DB::prepare('SELECT id, uri FROM *PREFIX*principals WHERE uri IN (? '.str_repeat(', ?', count($members)).')');
$result = $query->execute(array_merge(array($principal), $members));
$memberIds = array();
$principalId = null;
while($row = $$result->fetchRow()) {
if ($row['uri'] == $principal) {
$principalId = $row['id'];
}
else{
$memberIds[] = $row['id'];
}
}
if (!$principalId) throw new Sabre_DAV_Exception('Principal not found');
// Wiping out old members
$query = OC_DB::prepare('DELETE FROM *PREFIX*principalgroups WHERE principal_id = ?');
$query->execute(array($principalID));
$query = OC_DB::prepare('INSERT INTO *PREFIX*principalgroups (principal_id, member_id) VALUES (?, ?);');
foreach($memberIds as $memberId) {
$query->execute(array($principalId, $memberId));
}
throw new Sabre_DAV_Exception('Setting members of the group is not supported yet');
}
}

View File

@ -151,21 +151,75 @@ class OC_Template{
* "admin".
*/
public function __construct( $app, $name, $renderas = "" ){
// Get the right template folder
$template = OC::$SERVERROOT."/core/templates/";
// Read the selected theme from the config file
$theme=OC_Config::getValue( "theme" );
// Read the detected formfactor and use the right file name.
$formfactor=$_SESSION['formfactor'];
if($formfactor=='default') {
$fext='';
}elseif($formfactor=='mobile') {
$fext='.mobile';
}elseif($formfactor=='tablet') {
$fext='.tablet';
}elseif($formfactor=='standalone') {
$fext='.standalone';
}else{
$fext='';
}
// Check if it is a app template or not.
if( $app != "" ){
// Check if the app is in the app folder
// Check if the app is in the app folder or in the root
if( file_exists( OC::$SERVERROOT."/apps/$app/templates/" )){
$template = OC::$SERVERROOT."/apps/$app/templates/";
// Check if the template is overwritten by the selected theme
if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php" )){
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php" )){
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php";
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
}elseif( OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php" ){
$template = OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/apps/$app/templates/";
}else{
$template = OC::$SERVERROOT."/apps/$app/templates/"."$name.php";
$path = OC::$SERVERROOT."/apps/$app/templates/";
}
}else{
// Check if the template is overwritten by the selected theme
if( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php" )){
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php" )){
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php";
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
}elseif( file_exists( OC::$SERVERROOT."/$app/templates/"."$name$fext.php" )){
$template = OC::$SERVERROOT."/$app/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/$app/templates/";
}else{
$template = OC::$SERVERROOT."/$app/templates/"."$name.php";
$path = OC::$SERVERROOT."/$app/templates/";
}
}
else{
$template = OC::$SERVERROOT."/$app/templates/";
}else{
// Check if the template is overwritten by the selected theme
if( file_exists( OC::$SERVERROOT."/themes/$theme/core/templates/"."$name$fext.php" )){
$template = OC::$SERVERROOT."/themes/$theme/core/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/themes/$theme/core/templates/";
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/core/templates/"."$name.php" )){
$template = OC::$SERVERROOT."/themes/$theme/core/templates/"."$name.php";
$path = OC::$SERVERROOT."/themes/$theme/core/templates/";
}elseif( file_exists( OC::$SERVERROOT."/core/templates/"."$name$fext.php" )){
$template = OC::$SERVERROOT."/core/templates/"."$name$fext.php";
$path = OC::$SERVERROOT."/core/templates/";
}else{
$template = OC::$SERVERROOT."/core/templates/"."$name.php";
$path = OC::$SERVERROOT."/core/templates/";
}
}
// Templates have the ending .php
$path = $template;
$template .= "$name.php";
// Set the private data
$this->renderas = $renderas;
@ -265,31 +319,93 @@ class OC_Template{
}else{
$page = new OC_Template( "core", "layout.guest" );
}
// Read the selected theme from the config file
$theme=OC_Config::getValue( "theme" );
// Add the css and js files
// Read the detected formfactor and use the right file name.
$formfactor=$_SESSION['formfactor'];
if($formfactor=='default') {
$fext='';
}elseif($formfactor=='mobile') {
$fext='.mobile';
}elseif($formfactor=='tablet') {
$fext='.tablet';
}elseif($formfactor=='standalone') {
$fext='.standalone';
}else{
$fext='';
}
// Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){
if(is_file(OC::$SERVERROOT."/apps/$script.js" )){
if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" );
}elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
}
elseif(is_file(OC::$SERVERROOT."/$script.js" )){
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script.js" );
}elseif(is_file(OC::$SERVERROOT."/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script.js" );
}
else{
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script.js" );
}elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" );
}else{
$page->append( "jsfiles", OC::$WEBROOT."/core/$script.js" );
}
}
// Add the css files
foreach(OC_Util::$styles as $style){
if(is_file(OC::$SERVERROOT."/apps/$style.css" )){
if(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
}
elseif(is_file(OC::$SERVERROOT."/$style.css" )){
}elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style.css" );
}
else{
}elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" );
}else{
$page->append( "cssfiles", OC::$WEBROOT."/core/$style.css" );
}
}
// Add the theme css files. you can override the default values here
if(!empty($theme)) {
foreach(OC_Util::$styles as $style){
if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/apps/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/apps/$style.css" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/$style.css" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/core/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/core/$style.css" );
}
}
}
// Add custom headers
$page->assign('headers',$this->headers);
foreach(OC_Util::$headers as $header){

7
themes/README Normal file
View File

@ -0,0 +1,7 @@
This is the themes folder. Themes can be used to customize the look and feel of ownCloud without the need to patch the source code.
Themes can be placed in this folder with the name of the theme as foldername. The theme can be activated by putting
"theme" => 'themename', into the config.php file.
The folder structure of a theme is exactly the same as the main ownCloud structure. You can override js files and templates with own versions. css files are loaded additionaly to the default files so you can override css properties.
Themes should be developed here: https://gitorious.org/owncloud/themes
You can also find a super simple example there