app.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. OC::$CLASSPATH['OCA\Encryption\Crypt'] = 'apps/files_encryption/lib/crypt.php';
  3. OC::$CLASSPATH['OCA\Encryption\Hooks'] = 'apps/files_encryption/hooks/hooks.php';
  4. OC::$CLASSPATH['OCA\Encryption\Util'] = 'apps/files_encryption/lib/util.php';
  5. OC::$CLASSPATH['OCA\Encryption\Keymanager'] = 'apps/files_encryption/lib/keymanager.php';
  6. OC::$CLASSPATH['OCA\Encryption\Stream'] = 'apps/files_encryption/lib/stream.php';
  7. OC::$CLASSPATH['OCA\Encryption\Proxy'] = 'apps/files_encryption/lib/proxy.php';
  8. OC::$CLASSPATH['OCA\Encryption\Session'] = 'apps/files_encryption/lib/session.php';
  9. OC_FileProxy::register( new OCA\Encryption\Proxy() );
  10. // User-related hooks
  11. OCP\Util::connectHook( 'OC_User', 'post_login', 'OCA\Encryption\Hooks', 'login' );
  12. OCP\Util::connectHook( 'OC_User', 'pre_setPassword', 'OCA\Encryption\Hooks', 'setPassphrase' );
  13. // Sharing-related hooks
  14. OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' );
  15. OCP\Util::connectHook( 'OCP\Share', 'pre_unshare', 'OCA\Encryption\Hooks', 'preUnshare' );
  16. OCP\Util::connectHook( 'OCP\Share', 'pre_unshareAll', 'OCA\Encryption\Hooks', 'preUnshareAll' );
  17. // Webdav-related hooks
  18. OCP\Util::connectHook( 'OC_Webdav_Properties', 'update', 'OCA\Encryption\Hooks', 'updateKeyfile' );
  19. stream_wrapper_register( 'crypt', 'OCA\Encryption\Stream' );
  20. $session = new OCA\Encryption\Session();
  21. if (
  22. ! $session->getPrivateKey( \OCP\USER::getUser() )
  23. && OCP\User::isLoggedIn()
  24. && OCA\Encryption\Crypt::mode() == 'server'
  25. ) {
  26. // Force the user to log-in again if the encryption key isn't unlocked
  27. // (happens when a user is logged in before the encryption app is
  28. // enabled)
  29. OCP\User::logout();
  30. header( "Location: " . OC::$WEBROOT.'/' );
  31. exit();
  32. }
  33. // Register settings scripts
  34. OCP\App::registerAdmin( 'files_encryption', 'settings' );
  35. OCP\App::registerPersonal( 'files_encryption', 'settings-personal' );