]> source.dussan.org Git - nextcloud-server.git/commitdiff
porting the hooks and starting with the templates
authorFrank Karlitschek <frank@owncloud.org>
Sat, 5 May 2012 08:18:45 +0000 (10:18 +0200)
committerFrank Karlitschek <frank@owncloud.org>
Sat, 5 May 2012 08:18:45 +0000 (10:18 +0200)
13 files changed:
apps/calendar/appinfo/app.php
apps/calendar/index.php
apps/calendar/lib/app.php
apps/contacts/appinfo/app.php
apps/files_archive/appinfo/app.php
apps/files_encryption/appinfo/app.php
apps/files_sharing/appinfo/app.php
apps/files_sharing/lib_share.php
apps/files_versions/appinfo/app.php
apps/gallery/lib/hooks_handlers.php
apps/media/lib_media.php
lib/public/template.php [new file with mode: 0644]
lib/public/util.php

index 7b5db834fb5838ca4bd050b8a2510b6fa13edc8a..b02fc602c6b33cf63c60380c398d5008575f0656 100755 (executable)
@@ -7,7 +7,7 @@ OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
 OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
 OC::$CLASSPATH['OC_Calendar_Share'] = 'apps/calendar/lib/share.php';
 OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
-OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
+OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
 OCP\Util::addscript('calendar','loader');
 OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min");
 OCP\Util::addStyle("3rdparty", "chosen/chosen");
index 3a3915b96697cb6b6f20029db4d2b71fcf29f7c3..5aee5f6ace81be3842263e268d94fb8b34ff6e8b 100755 (executable)
@@ -25,7 +25,7 @@ foreach($calendars as $calendar){
 $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true');
 $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
 
-OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources));
+OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
 $categories = OC_Calendar_App::getCategoryOptions();
 
 //Fix currentview for fullcalendar
index f955c59603da39ff070bfaafdc8a1c7bab401880..eb440b5794bff95c51cfa51cec3dc97635eb2415 100755 (executable)
@@ -338,7 +338,7 @@ class OC_Calendar_App{
                                OCP\Response::setETagHeader($calendar['ctag']);
                                $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end);
                        } else {
-                               OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
+                               OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
                        }
                }
                return $events;
index 4808ea5fa835d872ba44b98d92b418f7bca49dd1..e5e1d572f2dde32d9b3da4aa5c4c13cb0b43e112 100755 (executable)
@@ -5,9 +5,9 @@ OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
 OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
 OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
 OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
-OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser');
-OC_HOOK::connect('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
-OC_HOOK::connect('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');
+OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser');
+OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
+OCP\Util::connectHook('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');
 
 OCP\App::register( array(
   'order' => 10,
index 0b156ced277660046c11250fff7171761d81e30b..67376c4a03acf913e9c254e07ba6b67196d952a5 100755 (executable)
@@ -8,6 +8,6 @@
 
 OC::$CLASSPATH['OC_Filestorage_Archive']='apps/files_archive/lib/storage.php';
 
-OC_Hook::connect('OC_Filesystem','get_mountpoint','OC_Filestorage_Archive','autoMount');
+OCP\Util::connectHook('OC_Filesystem','get_mountpoint','OC_Filestorage_Archive','autoMount');
 
 OCP\Util::addscript( 'files_archive', 'archive' );
index 02fc9dfa2673ad71240d9ab2d5f0d670b758fe79..679d0b95edcbdf743921db4aa3ebc39672ad38e0 100755 (executable)
@@ -6,7 +6,7 @@ OC::$CLASSPATH['OC_FileProxy_Encryption'] = 'apps/files_encryption/lib/proxy.php
 
 OC_FileProxy::register(new OC_FileProxy_Encryption());
 
-OC_Hook::connect('OC_User','post_login','OC_Crypt','loginListener');
+OCP\Util::connectHook('OC_User','post_login','OC_Crypt','loginListener');
 
 stream_wrapper_register('crypt','OC_CryptStream');
 
index f80bdb9e195085c3ca7f9a96a3eebbe0805dc275..bd81a45cc555408be0881f747c047fe0f1fb530a 100755 (executable)
@@ -4,12 +4,12 @@ require_once('apps/files_sharing/sharedstorage.php');
 
 OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
 OCP\App::registerAdmin('files_sharing', 'settings');
-OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
-OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
-OC_Hook::connect("OC_Filesystem", "post_write", "OC_Share", "updateItem");
-OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser');
-OC_Hook::connect('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare');
-OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare');
+OCP\Util::connectHook("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
+OCP\Util::connectHook("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
+OCP\Util::connectHook("OC_Filesystem", "post_write", "OC_Share", "updateItem");
+OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser');
+OCP\Util::connectHook('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare');
+OCP\Util::connectHook('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare');
 $dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
 if ($dir != '/Shared' || OCP\Config::getAppValue('files_sharing', 'resharing', 'yes') == 'yes') {
        OCP\Util::addscript("files_sharing", "share");
index fe8aa64fa813a7765ee7a6bc4bf217a4e0c620ae..71cca3097764c1f2f015bb43b14ce0bf246c6aaa 100755 (executable)
@@ -410,7 +410,7 @@ class OC_Share {
                $source = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['path']);
                if ($target = self::getTarget($source)) {
                        // Forward hook to notify of changes to target file
-                       OC_Hook::emit("OC_Filesystem", "post_delete", array('path' => $target));
+                       OCP\Util::emitHook("OC_Filesystem", "post_delete", array('path' => $target));
                        $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?");
                        $query->execute(array(strlen($source), $source, OCP\USER::getUser()));
                }
@@ -432,7 +432,7 @@ class OC_Share {
                $source = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['path']);
                if ($target = self::getTarget($source)) {
                        // Forward hook to notify of changes to target file
-                       OC_Hook::emit("OC_Filesystem", "post_write", array('path' => $target));
+                       OCP\Util::emitHook("OC_Filesystem", "post_write", array('path' => $target));
                }
        }
 
index ebaa7ee0e7e70cfb35bfc303d473d8cbfccf8dfc..fd3f78ab5758c392a4319bc18310eb1c49ef069c 100755 (executable)
@@ -12,7 +12,7 @@ OCP\App::registerAdmin('files_versions', 'settings');
 OCP\Util::addscript('files_versions', 'versions');
 
 // Listen to write signals
-OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook");
+OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook");
 
 
 
index 678d3fe7531920c23396f97e374bdfeeaa3afb01..6391e9f4e54d3a30c225fef7fe0c8f1408605100 100755 (executable)
@@ -21,9 +21,9 @@
 * 
 */
 
-OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OC_Gallery_Hooks_Handlers", "addPhotoFromPath");
-OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, "OC_Gallery_Hooks_Handlers", "removePhoto");
-//OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto");
+OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OC_Gallery_Hooks_Handlers", "addPhotoFromPath");
+OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, "OC_Gallery_Hooks_Handlers", "removePhoto");
+//OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto");
 
 require_once(OC::$CLASSPATH['OC_Gallery_Album']);
 require_once(OC::$CLASSPATH['OC_Gallery_Photo']);
index 94c3fabe8a06c529e18cf58ac10f503e66c69f18..71069fdf4b9c8ef325c006ec79e8f40e8c901c8c 100755 (executable)
 */
 
 //we need to have the sha256 hash of passwords for ampache
-OC_Hook::connect('OC_User','post_login','OC_MEDIA','loginListener');
+OCP\Util::connectHook('OC_User','post_login','OC_MEDIA','loginListener');
 
 //connect to the filesystem for auto updating
-OC_Hook::connect('OC_Filesystem','post_write','OC_MEDIA','updateFile');
+OCP\Util::connectHook('OC_Filesystem','post_write','OC_MEDIA','updateFile');
 
 //listen for file deletions to clean the database if a song is deleted
-OC_Hook::connect('OC_Filesystem','post_delete','OC_MEDIA','deleteFile');
+OCP\Util::connectHook('OC_Filesystem','post_delete','OC_MEDIA','deleteFile');
 
 //list for file moves to update the database
-OC_Hook::connect('OC_Filesystem','post_rename','OC_MEDIA','moveFile');
+OCP\Util::connectHook('OC_Filesystem','post_rename','OC_MEDIA','moveFile');
 
 class OC_MEDIA{
        /**
diff --git a/lib/public/template.php b/lib/public/template.php
new file mode 100644 (file)
index 0000000..eefd2a0
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+* ownCloud
+*
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Template Class
+ *
+ */
+
+// use OCP namespace for all classes that are considered public. 
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP;
+
+
+/**
+ * @brief make OC_Helper::imagePath available as a simple function
+ * @param $app app
+ * @param $image image
+ * @returns link to the image
+ *
+ * For further information have a look at OC_Helper::imagePath
+ */
+function image_path( $app, $image ){
+       return(image_path( $app, $image ));
+}
+
+
+
+class Template extends OC_Template {
+
+
+
+
+
+}
+
+?>
index a65b9aa262723fa41baa6518ad4b691313643426..f5b8e798bb4eefe32f0d973fbc0ade2a8ba8af6d 100644 (file)
@@ -191,8 +191,37 @@ class Util {
                return(\OC_Helper::computerFileSize( $str ));
        }
 
+       /**
+        * @brief connects a function to a hook
+        * @param $signalclass class name of emitter
+        * @param $signalname name of signal
+        * @param $slotclass class name of slot
+        * @param $slotname name of slot
+        * @returns true/false
+        *
+        * This function makes it very easy to connect to use hooks.
+        *
+        * TODO: write example
+        */
+       static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ){
+               return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname ));
+       }
 
 
+       /**
+        * @brief emitts a signal
+        * @param $signalclass class name of emitter
+        * @param $signalname name of signal
+        * @param $params defautl: array() array with additional data
+        * @returns true if slots exists or false if not
+        *
+        * Emits a signal. To get data from the slot use references!
+        *
+        * TODO: write example
+        */
+       static public function emitHook( $signalclass, $signalname, $params = array()){
+               return(\OC_Hook::emit( $signalclass, $signalname, $params ));
+       }
 
 
 }