From 94b405b64fdd1427873e49888fb0527640a10eb6 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 3 Mar 2011 21:25:22 +0100 Subject: [PATCH 1/5] Make it possible to use several datadirs. This could be useful if the user does not want his gallery images on the webdav storage. --- lib/base.php | 19 +++++++++---------- lib/template.php | 2 -- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/base.php b/lib/base.php index ac293cf193..e379a4ba61 100644 --- a/lib/base.php +++ b/lib/base.php @@ -88,6 +88,7 @@ oc_require_once('ocs.php'); oc_require_once('connect.php'); oc_require_once('remotestorage.php'); oc_require_once('plugin.php'); +oc_require_once('helper.php'); OC_PLUGIN::loadPlugins(); @@ -139,7 +140,7 @@ class OC_UTIL { private static $fsSetup=false; // Can be set up - public static function setupFS( $user = "" ){// configure the initial filesystem based on the configuration + public static function setupFS( $user = "", $root = "files" ){// configure the initial filesystem based on the configuration if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble return false; } @@ -166,11 +167,9 @@ class OC_UTIL { //first set up the local "root" storage and the backupstorage if needed $rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY)); if($CONFIG_ENABLEBACKUP){ - if(!is_dir($CONFIG_BACKUPDIRECTORY)){ - mkdir($CONFIG_BACKUPDIRECTORY); - } - if(!is_dir($CONFIG_BACKUPDIRECTORY.'/'.$user )){ - mkdir($CONFIG_BACKUPDIRECTORY.'/'.$user ); + // This creates the Directorys recursively + if(!is_dir( "$CONFIG_BACKUPDIRECTORY/$user/$root" )){ + mkdir( "$CONFIG_BACKUPDIRECTORY/$user/$root", 0x777, true ); } $backupStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_BACKUPDIRECTORY)); $backup=new OC_FILEOBSERVER_BACKUP(array('storage'=>$backupStorage)); @@ -178,9 +177,9 @@ class OC_UTIL { } OC_FILESYSTEM::mount($rootStorage,'/'); - $CONFIG_DATADIRECTORY=$CONFIG_DATADIRECTORY_ROOT.'/'.$user; - if(!is_dir($CONFIG_DATADIRECTORY)){ - mkdir($CONFIG_DATADIRECTORY); + $CONFIG_DATADIRECTORY = "$CONFIG_DATADIRECTORY_ROOT/$user/$root"; + if( !is_dir( $CONFIG_DATADIRECTORY )){ + mkdir( $CONFIG_DATADIRECTORY, 0x777, true ); } //set up the other storages according to the system settings @@ -197,7 +196,7 @@ class OC_UTIL { } //jail the user into his "home" directory - OC_FILESYSTEM::chroot('/'.$user); + OC_FILESYSTEM::chroot("/$user/$root"); self::$fsSetup=true; } } diff --git a/lib/template.php b/lib/template.php index 79899efee4..cd576a89f9 100644 --- a/lib/template.php +++ b/lib/template.php @@ -21,8 +21,6 @@ * */ -oc_include_once( "helper.php" ); - /** * */ From ae5dc3efdffef75c48e5ef7cac6b40cd5720442b Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 3 Mar 2011 21:55:32 +0100 Subject: [PATCH 2/5] New classes for owncloud: OC_APP for applications, OC_PREFERENCES for user preferences --- admin/{appinfo.php => appinfo/app.php} | 2 +- admin/index.php | 2 +- files/appinfo.php | 6 ---- files/appinfo/app.php | 7 ++++ lib/app.php | 40 +++++++++++++++++++++++ lib/appconfig.php | 11 ------- lib/base.php | 29 +++------------- lib/preferences.php | 35 ++++++++++++++++++++ log/{appinfo.php => appinfo/app.php} | 2 +- settings/{appinfo.php => appinfo/app.php} | 2 +- 10 files changed, 91 insertions(+), 45 deletions(-) rename admin/{appinfo.php => appinfo/app.php} (85%) delete mode 100644 files/appinfo.php create mode 100644 files/appinfo/app.php create mode 100644 lib/app.php create mode 100644 lib/preferences.php rename log/{appinfo.php => appinfo/app.php} (61%) rename settings/{appinfo.php => appinfo/app.php} (60%) diff --git a/admin/appinfo.php b/admin/appinfo/app.php similarity index 85% rename from admin/appinfo.php rename to admin/appinfo/app.php index 0b2e4dbf85..befe8e678f 100644 --- a/admin/appinfo.php +++ b/admin/appinfo/app.php @@ -1,6 +1,6 @@ "admin", "name" => "Administration" )); +OC_APP::register( array( "id" => "admin", "name" => "Administration" )); if( OC_USER::ingroup( $_SESSION['username'], 'admin' )) { OC_UTIL::addNavigationEntry( array( "app" => "admin", "file" => "index.php", "name" => "Administration" )); diff --git a/admin/index.php b/admin/index.php index cfcb70d056..96fa200724 100644 --- a/admin/index.php +++ b/admin/index.php @@ -30,7 +30,7 @@ if( !OC_USER::isLoggedIn() || !OC_USER::ingroup( $_SESSION['username'], 'admin' $adminpages = array(); -foreach( OC_UTIL::$adminpages as $i ){ +foreach( OC_APP::list() as $i ){ // Do some more work here soon $adminpages[] = $i; } diff --git a/files/appinfo.php b/files/appinfo.php deleted file mode 100644 index 44a533cf4a..0000000000 --- a/files/appinfo.php +++ /dev/null @@ -1,6 +0,0 @@ - "files", "name" => "Files" )); -OC_UTIL::addNavigationEntry( array( "app" => "files", "file" => "index.php", "name" => "Files" )); - -?> diff --git a/files/appinfo/app.php b/files/appinfo/app.php new file mode 100644 index 0000000000..aa0054fc43 --- /dev/null +++ b/files/appinfo/app.php @@ -0,0 +1,7 @@ + "files", "name" => "Files" )); +OC_UTIL::addNavigationEntry( array( "app" => "files", "file" => "index.php", "name" => "Files" )); +OC_UTIL::addAdminPage( array( "app" => "files", "file" => "admin.php", "name" => "Files" )); + +?> diff --git a/lib/app.php b/lib/app.php new file mode 100644 index 0000000000..181af8a4fa --- /dev/null +++ b/lib/app.php @@ -0,0 +1,40 @@ + diff --git a/lib/appconfig.php b/lib/appconfig.php index f1bccc0a25..844d4cf54e 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -1,16 +1,5 @@ $CONFIG_BACKUPDIRECTORY)); $backup=new OC_FILEOBSERVER_BACKUP(array('storage'=>$backupStorage)); @@ -179,7 +169,7 @@ class OC_UTIL { $CONFIG_DATADIRECTORY = "$CONFIG_DATADIRECTORY_ROOT/$user/$root"; if( !is_dir( $CONFIG_DATADIRECTORY )){ - mkdir( $CONFIG_DATADIRECTORY, 0x777, true ); + mkdir( $CONFIG_DATADIRECTORY, 0x755, true ); } //set up the other storages according to the system settings @@ -253,15 +243,6 @@ class OC_UTIL { OC_UTIL::$adminpages[] = $entry; } - /** - * add application - * - * @param array $entry - */ - public static function addApplication( $entry){ - OC_UTIL::$applications[] = $entry; - } - /** * add an entry to the personal menu * diff --git a/lib/preferences.php b/lib/preferences.php new file mode 100644 index 0000000000..bd4ff55cc5 --- /dev/null +++ b/lib/preferences.php @@ -0,0 +1,35 @@ + diff --git a/log/appinfo.php b/log/appinfo/app.php similarity index 61% rename from log/appinfo.php rename to log/appinfo/app.php index e4ffa79efe..292d59ee57 100644 --- a/log/appinfo.php +++ b/log/appinfo/app.php @@ -1,6 +1,6 @@ "log", "name" => "Log" )); +OC_APP::register( array( "id" => "log", "name" => "Log" )); OC_UTIL::addNavigationEntry( array( "app" => "log", "file" => "index.php", "name" => "Log" )); ?> diff --git a/settings/appinfo.php b/settings/appinfo/app.php similarity index 60% rename from settings/appinfo.php rename to settings/appinfo/app.php index 232aaa0f0e..0db9944157 100644 --- a/settings/appinfo.php +++ b/settings/appinfo/app.php @@ -1,6 +1,6 @@ "settings", "name" => "Settings" )); +OC_APP::register( array( "id" => "settings", "name" => "Settings" )); OC_UTIL::addNavigationEntry( array( "app" => "settings", "file" => "index.php", "name" => "Settings" )); ?> From f7f957abb92e5ce359d7eafa136406822fee0a51 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 3 Mar 2011 23:08:11 +0100 Subject: [PATCH 3/5] Base for a more flexible navigation --- admin/appinfo/app.php | 10 +++++----- admin/img/navicon.png | Bin 0 -> 874 bytes admin/index.php | 2 +- admin/templates/index.php | 2 +- files/appinfo/app.php | 7 ++++--- files/img/navicon.png | Bin 0 -> 635 bytes img/actions/arrow-down.png | Bin 0 -> 525 bytes img/actions/arrow-left.png | Bin 0 -> 512 bytes img/actions/arrow-right.png | Bin 0 -> 527 bytes img/actions/arrow-up.png | Bin 0 -> 484 bytes lib/app.php | 12 +++++++----- lib/base.php | 10 +++++----- log/appinfo/app.php | 4 ++-- settings/appinfo/app.php | 2 +- templates/layout.admin.php | 7 +++---- templates/layout.user.php | 4 ++-- 16 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 admin/img/navicon.png create mode 100644 files/img/navicon.png create mode 100644 img/actions/arrow-down.png create mode 100644 img/actions/arrow-left.png create mode 100644 img/actions/arrow-right.png create mode 100644 img/actions/arrow-up.png diff --git a/admin/appinfo/app.php b/admin/appinfo/app.php index befe8e678f..3221e276c5 100644 --- a/admin/appinfo/app.php +++ b/admin/appinfo/app.php @@ -1,12 +1,12 @@ "admin", "name" => "Administration" )); +OC_APP::register( array( "order" => 1, "id" => "admin", "name" => "Administration" )); if( OC_USER::ingroup( $_SESSION['username'], 'admin' )) { - OC_UTIL::addNavigationEntry( array( "app" => "admin", "file" => "index.php", "name" => "Administration" )); + OC_UTIL::addNavigationEntry( array( "id" => "admin_index", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "index.php" ), "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ), "name" => "Administration" )); } -OC_UTIL::addAdminPage( array( "app" => "admin", "file" => "system.php", "name" => "System Settings" )); -OC_UTIL::addAdminPage( array( "app" => "admin", "file" => "users.php", "name" => "Users" )); -OC_UTIL::addAdminPage( array( "app" => "admin", "file" => "plugins.php", "name" => "Plugins" )); +OC_UTIL::addAdminPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System settings" )); +OC_UTIL::addAdminPage( array( "order" => 2, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users" )); +OC_UTIL::addAdminPage( array( "order" => 3, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins" )); ?> diff --git a/admin/img/navicon.png b/admin/img/navicon.png new file mode 100644 index 0000000000000000000000000000000000000000..f2c7c0867f657da1209816b3c410d61c2d1df9a1 GIT binary patch literal 874 zcmV-w1C{)VP)6SW2UXoB(ijskm7m_3- zVjoJPw2LC?L{tLtOAZvAmZG?6(U*aR&N;8I>$W-Bmiv&Xx#l*yd@$Wb+iY!fZ?DE+ zh*&>(Zs$Db|D40~Jb+;sJZ^1`+8h7XL?Y3($;ru4m0DHkvjK{t-Bzm=8FIo}Lp~nVF}RN+sC0ZD6%o;iuhBd@q;JEG;dq z@0Z{Yo(bXhopLFc%gr|#4fRf^vvtj|7UXezc5OD>j$_C1L#NY;X3^PZ3?~2%fZM#d zNHH@$PI|exm_H_w0EtBMh{a-#Mxznq{$22c0EfWi@iGz;n1usE0pu4HLQ#g<+>o<) z))#!FKzn<8UJN}(JuoOFhJ}S=#L*|kpg@^|4Mjxm`o@T5E4%% zgVAX0Q7g1Vs;ONMIn9e)yh~mf;RcAn55Jezb)$pd;myv;!tguCDk>^o`Fzn45HIfx zbh^HCv!FAsu-_4j&G~;@t zQy9F?tu4sEMN8Gb1O2)T2}Dp7C7VnpxmvAOkjdoxp`oEG&CShexVj4tP+ovM;NBxV zjR+ -
  • ">
  • +
  • ">
  • diff --git a/files/appinfo/app.php b/files/appinfo/app.php index aa0054fc43..8b1a806b7b 100644 --- a/files/appinfo/app.php +++ b/files/appinfo/app.php @@ -1,7 +1,8 @@ "files", "name" => "Files" )); -OC_UTIL::addNavigationEntry( array( "app" => "files", "file" => "index.php", "name" => "Files" )); -OC_UTIL::addAdminPage( array( "app" => "files", "file" => "admin.php", "name" => "Files" )); +OC_APP::register( array( "order" => 2, "id" => "files", "name" => "Files" )); + +OC_UTIL::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "navicon.png" ), "name" => "Files" )); +OC_UTIL::addAdminPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files" )); ?> diff --git a/files/img/navicon.png b/files/img/navicon.png new file mode 100644 index 0000000000000000000000000000000000000000..9ee717c8b124c186edfd629c70d83ebc3dfc6b4e GIT binary patch literal 635 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJbFq_W2nPqp?T7vkfLzW3kH}&M z2FBeW%xLxI@gtz1WQl7;NpOBzNqJ&XDnogBxn5>oc5!lIL8@MUQTpt6Hc~*<;sHJ( zuK)l4PfAbIH!(A^ur#%@Hn+92u(P+cwX=3`aCCKX_ww-e^YQWb@d*s{3-I+1@(&0N z1+w*x4D<{Pl2TKWQd1L>k`j`W(lRmp{}_Vo7i2AT{sFeo%IG}t#*k0BwGA)%B3Xe7|6w9K?DE1vv<)M879;%J7F;=Gd5 z%!-Pfnwo-!hT_IFu9lXvj;_|uo~|xuhTh)pIYGP&7S3G~z_2!iVOQJbd`*@#Ck@o;`o@ z`pw(VU%veQ^9L9vOH|^o0K-wbB*-tAp`rm5^j)~}^XIQ$fByb`P`a@KsBFEbi(^Q| zt<;|Dd`$rYF6;M}zuBvu9_+>u2KDjwcG z>uT>9#rA3W?4o~P+fJClr!T8}$ zJCS$qI^o{LM uTFAdLcI_93TAP57bSXBm$5B#$KQr0RRZpyT(^LaGox#)9&t;ucLK6VI&jeEd literal 0 HcmV?d00001 diff --git a/img/actions/arrow-down.png b/img/actions/arrow-down.png new file mode 100644 index 0000000000000000000000000000000000000000..03f201428ade2247beda4510d7d026239ce76e95 GIT binary patch literal 525 zcmV+o0`mQdP)9=F*v&h)z;9gN*xgu->v1X*39s!zo=YGCdZI$o{A0eS z3zwhoU88+%XSRQB@3F;HT_~_lg{` zH*{|g3fzPm2EqFieQI+mpEMh-aV}Hi4(`1L@lj0Tg|E1le8E3>2FG*_kR-#~ZFC9I P00000NkvXXu0mjfgP`0> literal 0 HcmV?d00001 diff --git a/img/actions/arrow-left.png b/img/actions/arrow-left.png new file mode 100644 index 0000000000000000000000000000000000000000..b56cfee03dfefe9ff8f2c5e7e2a8a0bb0b15ba6e GIT binary patch literal 512 zcmV+b0{{JqP)qm|rIM*THKYbgj#5EThHVGp>QQ+y$SGVUd5n>Vi^Dhi? z=Gp7p`&O_%-wyUezg*(nRzm^8q$r;Q0FLwje&-*R0-@+#lQ?Ps0000pf9L*rlU&o38m%ZUnjts@YN3Td9RC#dB77qOajaU&u6O)=K#zfzH-=kSAiP1c8rUMV0-#Lev z8NDFz0Gg#tWInR=YylWcD~l^XV;^H%^n>Whf)-}LP;Mc&JbXC(o2IG%X@Uq)yez_n zoyg8+-z1WWKa`0RBbh$8C34Rcj#RA+eYcCV{7O06WHTD-0gS$h;5 zR8G#OIM3y-4@oE?$NnX7{r7hFyjq^%RW73g|9zv%hvq;uXumZ#(FHxf^BsRnl`~7B R;>7>}002ovPDHLkV1m8G+5Z3l literal 0 HcmV?d00001 diff --git a/img/actions/arrow-up.png b/img/actions/arrow-up.png new file mode 100644 index 0000000000000000000000000000000000000000..5e423213fbd735f153563b7655bda918cafc868a GIT binary patch literal 484 zcmV2#k(t%MMgP62BupmrE z3A4dqMLPHf#CH&45wS=UU%*E&Nb1j`L7Vrz_qruaRK+5GPtJ6bUrtWWVGsoP4F-Te zEZ`Cs^P6KUXv3E~-~z{n;@JyNc)Sj3~hw%vQoHD)>z zaEo*@&S`#lG^Qh(Op)rTX<4pw-s*iTFfYyB;&?Gni$e7%FiA9{O=(ExBD4?M3OL8* z>51tTC+-MsYWTJf?P?$e)T0m5PFk~KvwP!H0cTh!7K(eh;hfOaP*TC`_TcyVKmtG- zxOHp7cfATLX8A+#zO=$f;jA=SGL^5;iZ()tsQ?E+tR;9WGi!)+B7Mjm_9H~1g@yG@ zG83;}RPh+5F6(H>2A;c~5fQx*PXfY_kWxYfg0ZM;-#6~I0j$2>0Yfm49{hwOG=h+S a@JuhD6KyhT2soDj0000 "index.php?logout=1", "name" => "Logout" )); +OC_UTIL::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" ); OC_UTIL::addStyle( "jquery-ui-1.8.10.custom" ); OC_UTIL::addStyle( "styles" ); -// Require all appinfo.php -OC_APP::init(); +// Load Apps +OC_APP::loadApps(); // check if the server is correctly configured for ownCloud OC_UTIL::checkserver(); @@ -239,7 +239,7 @@ class OC_UTIL { * * @param array $entry */ - public static function addAdminPage( $entry){ + public static function addAdminPage( $entry ){ OC_UTIL::$adminpages[] = $entry; } diff --git a/log/appinfo/app.php b/log/appinfo/app.php index 292d59ee57..e639982a89 100644 --- a/log/appinfo/app.php +++ b/log/appinfo/app.php @@ -1,6 +1,6 @@ "log", "name" => "Log" )); -OC_UTIL::addNavigationEntry( array( "app" => "log", "file" => "index.php", "name" => "Log" )); +OC_APP::register( array( "order" => 1, "id" => "log", "name" => "Log" )); +OC_UTIL::addPersonalMenuEntry( array( "order" => 2, "href" => OC_HELPER::linkTo( "log", "index.php" ), "name" => "Log" )); ?> diff --git a/settings/appinfo/app.php b/settings/appinfo/app.php index 0db9944157..c43d47f0dd 100644 --- a/settings/appinfo/app.php +++ b/settings/appinfo/app.php @@ -1,6 +1,6 @@ "settings", "name" => "Settings" )); -OC_UTIL::addNavigationEntry( array( "app" => "settings", "file" => "index.php", "name" => "Settings" )); +OC_UTIL::addPersonalMenuEntry( array( "order" => 1, "href" => OC_HELPER::linkTo( "settings", "index.php" ), "name" => "Settings" )); ?> diff --git a/templates/layout.admin.php b/templates/layout.admin.php index b4fcc91588..849ed6656b 100644 --- a/templates/layout.admin.php +++ b/templates/layout.admin.php @@ -25,7 +25,7 @@ Username @@ -34,9 +34,8 @@
    diff --git a/templates/layout.user.php b/templates/layout.user.php index 0643c99e93..ff845a9b95 100644 --- a/templates/layout.user.php +++ b/templates/layout.user.php @@ -25,7 +25,7 @@ Username
    @@ -35,7 +35,7 @@ From f042e85d412fb323e5d3bb3e70d9d4ffa00a7907 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 3 Mar 2011 23:08:54 +0100 Subject: [PATCH 4/5] Beginning of some ajax features and an admin page for files --- files/admin.php | 39 ++++++++++++++++++++++++ files/ajax/delete.php | 27 +++++++++++++++++ files/ajax/list.php | 36 ++++++++++++++++++++++ files/ajax/rename.php | 28 +++++++++++++++++ files/download.php | 45 +++++++++++++++++++++++++++ files/settings.php | 64 +++++++++++++++++++++++++++++++++++++++ files/templates/admin.php | 19 ++++++++++++ 7 files changed, 258 insertions(+) create mode 100644 files/admin.php create mode 100644 files/ajax/delete.php create mode 100644 files/ajax/list.php create mode 100644 files/ajax/rename.php create mode 100644 files/download.php create mode 100644 files/settings.php create mode 100644 files/templates/admin.php diff --git a/files/admin.php b/files/admin.php new file mode 100644 index 0000000000..4c442c4b11 --- /dev/null +++ b/files/admin.php @@ -0,0 +1,39 @@ +. +* +*/ + + +// Init owncloud +require_once('../lib/base.php'); +oc_require( 'template.php' ); + +// Check if we are a user +if( !OC_USER::isLoggedIn() || !OC_USER::ingroup( $_SESSION['username'], 'admin' )){ + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +// return template +$tmpl = new OC_TEMPLATE( "files", "admin", "admin" ); +$tmpl->printPage(); + +?> diff --git a/files/ajax/delete.php b/files/ajax/delete.php new file mode 100644 index 0000000000..113476f025 --- /dev/null +++ b/files/ajax/delete.php @@ -0,0 +1,27 @@ + "error", "data" => array( "message" => "Authentication error" ))); + exit(); +} + +// Get data +$dir = $_GET["dir"]; +$file = $_GET["file"]; + +// Delete +if( OC_FILES::delete( $dir, $file )){ + echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file ))); +} +else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete file" ))); +} + +?> diff --git a/files/ajax/list.php b/files/ajax/list.php new file mode 100644 index 0000000000..4694f84283 --- /dev/null +++ b/files/ajax/list.php @@ -0,0 +1,36 @@ + "error", "data" => array( "message" => "Authentication error" ))); + exit(); +} + +// Load the files +$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; + +$files = array(); +foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){ + $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] ); + $files[] = $i; +} + +// Make breadcrumb +$breadcrumb = array(); +$pathtohere = "/"; +foreach( explode( "/", $dir ) as $i ){ + if( $i != "" ){ + $pathtohere .= "$i/"; + $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); + } +} + +echo json_encode( array( "status" => "success", "data" => array( "files" => $files, "breadcrumb" => $breadcrumb ))); + +?> diff --git a/files/ajax/rename.php b/files/ajax/rename.php new file mode 100644 index 0000000000..86cb7944a8 --- /dev/null +++ b/files/ajax/rename.php @@ -0,0 +1,28 @@ + "error", "data" => "Authentication error" )); + exit(); +} + +// Get data +$dir = $_GET["dir"]; +$file = $_GET["file"]; +$newname = $_GET["newname"]; + +// Delete +if( OC_FILES::move( $dir, $file, $dir, $newname )) { + echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); +} +else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to rename file" ))); +} + +?> diff --git a/files/download.php b/files/download.php new file mode 100644 index 0000000000..d6d39c8212 --- /dev/null +++ b/files/download.php @@ -0,0 +1,45 @@ +. +* +*/ + +// Init owncloud +require_once('../lib/base.php'); +oc_require( 'template.php' ); + +// Check if we are a user +if( !OC_USER::isLoggedIn()){ + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +$filename = $_GET["file"]; + +$ftype=OC_FILESYSTEM::getMimeType( $filename ); + +header('Content-Type:'.$ftype); +header('Expires: 0'); +header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); +header('Pragma: public'); +header('Content-Length: '.OC_FILESYSTEM::filesize($filename)); + +OC_FILESYSTEM::readfile( $filename ); +?> diff --git a/files/settings.php b/files/settings.php new file mode 100644 index 0000000000..25a9f0297d --- /dev/null +++ b/files/settings.php @@ -0,0 +1,64 @@ +. +* +*/ + + +// Init owncloud +require_once('../lib/base.php'); +oc_require( 'template.php' ); + +// Check if we are a user +if( !OC_USER::isLoggedIn()){ + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +// Load the files we need +OC_UTIL::addStyle( "files", "files" ); +OC_UTIL::addScript( "files", "files" ); + +// Load the files +$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; + +$files = array(); +foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){ + $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] ); + $files[] = $i; +} + +// Make breadcrumb +$breadcrumb = array(); +$pathtohere = "/"; +foreach( explode( "/", $dir ) as $i ){ + if( $i != "" ){ + $pathtohere .= "$i/"; + $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); + } +} + +// return template +$tmpl = new OC_TEMPLATE( "files", "index", "user" ); +$tmpl->assign( "files", $files ); +$tmpl->assign( "breadcrumb", $breadcrumb ); +$tmpl->printPage(); + +?> diff --git a/files/templates/admin.php b/files/templates/admin.php new file mode 100644 index 0000000000..811b48af02 --- /dev/null +++ b/files/templates/admin.php @@ -0,0 +1,19 @@ + +

    Admin

    + +
    + Allow public folders
    + + (if public is enabled)
    + separated from webdav storage
    + let the user decide
    + folder "/public" in webdav storage
    + (endif)
    + + Allow downloading shared files
    + Allow uploading in shared directory
    +
    From ab22dfde8a2b34b14c8024d68a16131fc7deefa5 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 3 Mar 2011 23:09:36 +0100 Subject: [PATCH 5/5] A sample app, at the moment far from showing everything possible --- skeleton/admin.php | 56 ++++++++++++++++++++++++++++ skeleton/appinfo/app.sample.php | 15 ++++++++ skeleton/css/skeleton.css | 4 ++ skeleton/css/special.css | 3 ++ skeleton/img/put_images_here.txt | 1 + skeleton/index.php | 64 ++++++++++++++++++++++++++++++++ skeleton/js/app.js | 3 ++ skeleton/templates/admin.php | 8 ++++ skeleton/templates/index.php | 12 ++++++ 9 files changed, 166 insertions(+) create mode 100644 skeleton/admin.php create mode 100644 skeleton/appinfo/app.sample.php create mode 100644 skeleton/css/skeleton.css create mode 100644 skeleton/css/special.css create mode 100644 skeleton/img/put_images_here.txt create mode 100644 skeleton/index.php create mode 100644 skeleton/js/app.js create mode 100644 skeleton/templates/admin.php create mode 100644 skeleton/templates/index.php diff --git a/skeleton/admin.php b/skeleton/admin.php new file mode 100644 index 0000000000..f237e84d85 --- /dev/null +++ b/skeleton/admin.php @@ -0,0 +1,56 @@ +. +* +*/ + +// Do not prepare the file system (for demonstration purpose) +// We HAVE TO set this var before including base.php +$RUNTIME_NOSETUPFS = true; + +// Init owncloud +require_once('../lib/base.php'); + +// We need the file system although we said do not load it! Do it by hand now +OC_UTIL::setupFS(); + +// We load OC_TEMPLATE, too. This one is not loaded by base +oc_require( 'template.php' ); + +// The user should have admin rights. This is an admin page! +if( !OC_USER::isLoggedIn() || !OC_USER::ingroup( $_SESSION['username'], 'admin' )){ + // Bad boy! Go to the very first page of owncloud + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +// Do some crazy Stuff over here +$myvar = 2; +$myarray = array( "foo" => array( 0, 1, 2 ), "bar" => "baz" ); + +// Preparing for output! +$tmpl = new OC_TEMPLATE( "skeleton", "admin", "admin" ); // Programname, template, mode +// Assign the vars +$tmpl->assign( "var", $myvar ); +$tmpl->assign( "array", $myarray ); +// Print page +$tmpl->printPage(); + +?> diff --git a/skeleton/appinfo/app.sample.php b/skeleton/appinfo/app.sample.php new file mode 100644 index 0000000000..12db7154c2 --- /dev/null +++ b/skeleton/appinfo/app.sample.php @@ -0,0 +1,15 @@ + "skeleton", "name" => "Files", "order" => 1000 )); + +// Add application to navigation +OC_UTIL::addNavigationEntry( array( "id" => "skeleton_index", "order" => 1000, "href" => OC_HELPER::linkTo( "skeleton", "index.php" ), "icon" => OC_HELPER::imagePath( "skeleton", "app.png" ), "name" => "Example app" )); + +// Add an admin page +OC_UTIL::addAdminPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "skeleton", "admin.php" ), "name" => "Example app options" )); + +?> diff --git a/skeleton/css/skeleton.css b/skeleton/css/skeleton.css new file mode 100644 index 0000000000..aa68a8be86 --- /dev/null +++ b/skeleton/css/skeleton.css @@ -0,0 +1,4 @@ +/* + * To include this css file, call "OC_UTIL::addStyle( "skeleton", "skeleton" )" + * in your app. (appname) (cssname) + */ \ No newline at end of file diff --git a/skeleton/css/special.css b/skeleton/css/special.css new file mode 100644 index 0000000000..8fd75917bf --- /dev/null +++ b/skeleton/css/special.css @@ -0,0 +1,3 @@ +/* + * If you want to you can use more css files ... + */ diff --git a/skeleton/img/put_images_here.txt b/skeleton/img/put_images_here.txt new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/skeleton/img/put_images_here.txt @@ -0,0 +1 @@ + diff --git a/skeleton/index.php b/skeleton/index.php new file mode 100644 index 0000000000..25a9f0297d --- /dev/null +++ b/skeleton/index.php @@ -0,0 +1,64 @@ +. +* +*/ + + +// Init owncloud +require_once('../lib/base.php'); +oc_require( 'template.php' ); + +// Check if we are a user +if( !OC_USER::isLoggedIn()){ + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +// Load the files we need +OC_UTIL::addStyle( "files", "files" ); +OC_UTIL::addScript( "files", "files" ); + +// Load the files +$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; + +$files = array(); +foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){ + $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] ); + $files[] = $i; +} + +// Make breadcrumb +$breadcrumb = array(); +$pathtohere = "/"; +foreach( explode( "/", $dir ) as $i ){ + if( $i != "" ){ + $pathtohere .= "$i/"; + $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); + } +} + +// return template +$tmpl = new OC_TEMPLATE( "files", "index", "user" ); +$tmpl->assign( "files", $files ); +$tmpl->assign( "breadcrumb", $breadcrumb ); +$tmpl->printPage(); + +?> diff --git a/skeleton/js/app.js b/skeleton/js/app.js new file mode 100644 index 0000000000..5d5b668eeb --- /dev/null +++ b/skeleton/js/app.js @@ -0,0 +1,3 @@ +// Include this file whenever you need it. A simple +// "OC_UTIL::addScript( "skeleton", "app" )" will do this. +// Put your jquery-Stuff here diff --git a/skeleton/templates/admin.php b/skeleton/templates/admin.php new file mode 100644 index 0000000000..63fcd5cd39 --- /dev/null +++ b/skeleton/templates/admin.php @@ -0,0 +1,8 @@ + +

    Admin

    diff --git a/skeleton/templates/index.php b/skeleton/templates/index.php new file mode 100644 index 0000000000..f8d8440817 --- /dev/null +++ b/skeleton/templates/index.php @@ -0,0 +1,12 @@ + +

    Skeleton

    + + +

    + + +