本文整理汇总了PHP中OC_Hook::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Hook::connect方法的具体用法?PHP OC_Hook::connect怎么用?PHP OC_Hook::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Hook
的用法示例。
在下文中一共展示了OC_Hook::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
$manager = \OC\Files\Filesystem::getMountManager();
\OC_Hook::clear('OC_Filesystem');
\OC_Hook::connect('OC_Filesystem', 'post_write', '\\OC\\Files\\Cache\\Updater', 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\\OC\\Files\\Cache\\Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\\OC\\Files\\Cache\\Updater', 'renameHook');
\OC_Hook::connect('OC_Filesystem', 'post_touch', '\\OC\\Files\\Cache\\Updater', 'touchHook');
$user = new User($this->getUniqueID('user'), new \OC_User_Dummy());
$this->loginAsUser($user->getUID());
$this->view = new View();
$this->root = new Root($manager, $this->view, $user);
$storage = new Temporary(array());
$subStorage = new Temporary(array());
$this->storages[] = $storage;
$this->storages[] = $subStorage;
$this->root->mount($storage, '/');
$this->root->mount($subStorage, '/substorage/');
}
示例2: globalSetup
/**
* To be called from setupFS trough a hook
*
* Sets up listening to changes made to shares owned by the current user
*/
public function globalSetup()
{
$user = $this->userSession->getUser();
if (!$user) {
return;
}
$recipientPropagator = $this->getSharePropagator($user->getUID());
$watcher = new ChangeWatcher(Filesystem::getView(), $recipientPropagator);
// for marking shares owned by the active user as dirty when a file inside them changes
$this->listenToOwnerChanges($user->getUID(), $user->getUID());
\OC_Hook::connect('OC_Filesystem', 'post_write', $watcher, 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', $watcher, 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', $watcher, 'renameHook');
}
示例3: connectHook
/**
* connects a function to a hook
*
* @param string $signalClass class name of emitter
* @param string $signalName name of signal
* @param string|object $slotClass class name of slot
* @param string $slotName name of slot
* @return bool
*
* This function makes it very easy to connect to use hooks.
*
* TODO: write example
* @since 4.0.0
*/
public static function connectHook($signalClass, $signalName, $slotClass, $slotName)
{
return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
}
示例4: loginListener
* 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 Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
//we need to have the sha256 hash of passwords for ampache
OC_Hook::connect('OC_User', 'post_login', 'OC_MEDIA', 'loginListener');
//connect to the filesystem for auto updating
OC_Hook::connect('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', 'delete', 'OC_MEDIA', 'deleteFile');
//list for file moves to update the database
OC_Hook::connect('OC_Filesystem', 'post_rename', 'OC_MEDIA', 'moveFile');
class OC_MEDIA
{
/**
* get the sha256 hash of the password needed for ampache
* @param array $params, parameters passed from OC_Hook
*/
public static function loginListener($params)
{
if (isset($_POST['user']) and $_POST['password']) {
if (defined("DEBUG") && DEBUG) {
error_log('postlogin');
}
$name = $_POST['user'];
$query = OC_DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?");
$uid = $query->execute(array($name))->fetchAll();
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_media_lib_media.php
示例5: use
*
* This program 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
if (\OC::$server->getConfig()->getSystemValue('updatechecker', true) === true) {
$updater = new \OC\Updater\VersionCheck(\OC::$server->getHTTPClientService(), \OC::$server->getConfig());
$updateChecker = new \OCA\UpdateNotification\UpdateChecker($updater);
$userObject = \OC::$server->getUserSession()->getUser();
if ($userObject !== null) {
if (\OC::$server->getGroupManager()->isAdmin($userObject->getUID())) {
if ($updateChecker->getUpdateState() !== []) {
\OCP\Util::addScript('updatenotification', 'notification');
OC_Hook::connect('\\OCP\\Config', 'js', $updateChecker, 'getJavaScript');
}
\OC_App::registerAdmin('updatenotification', 'admin');
}
}
$manager = \OC::$server->getNotificationManager();
$manager->registerNotifier(function () use($manager) {
return new \OCA\UpdateNotification\Notification\Notifier($manager, \OC::$server->getL10NFactory());
}, function () {
$l = \OC::$server->getL10N('updatenotification');
return ['id' => 'updatenotification', 'name' => $l->t('Update notifications')];
});
}
示例6: registerShareHooks
/**
* register hooks for sharing
*/
public static function registerShareHooks()
{
if (\OC_Config::getValue('installed')) {
OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\\Share', 'post_deleteUser');
OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\\Share', 'post_addToGroup');
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\\Share', 'post_removeFromGroup');
OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\\Share', 'post_deleteGroup');
}
}
示例7:
*
* NOTE: to make sure that the hooks are called everytime that a file is written, the application
* must be registered with type "filesystem". Otherwise, those hooks will be called only when uploading from the web interface
*
* to register the application as a filesystem type, put in info.xml *
* <types><filesystem/></types>
*
*/
#OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, OC\Files\Filesystem::signal_write, "OC_Neurocloud", "beforeFileWrite");
#OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, OC\Files\Filesystem::signal_post_write, "OC_Neurocloud", "afterFileWrite");
OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, 'post_delete', "OC_Neurocloud", "fileDeleted");
OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, OC\Files\Filesystem::signal_post_rename, "OC_Neurocloud", "fileRenamed");
// hooks for delete/rename, do not allow deleting of directory if there is a running job
OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, OC\Files\Filesystem::signal_delete, "OC_Neurocloud", "beforeFileRenameDelete");
OC_Hook::connect(OC\Files\Filesystem::CLASSNAME, OC\Files\Filesystem::signal_rename, "OC_Neurocloud", "beforeFileRenameDelete");
/**
* User hooks:
* - before login, check if the user has a home folder correctly mounted on the kore storage. Abort login if not.
* - before creating the user, generate a RSA private key
* - after deleting the user, delete the private key
*/
OC_Hook::connect("OC_User", "pre_createUser", "OC_Neurocloud", "beforeCreateUser");
OC_Hook::connect("OC_User", "post_deleteUser", "OC_Neurocloud", "afterDeleteUser");
OC_Hook::connect("OC_User", "pre_login", "OC_Neurocloud", "beforeLogin");
/**
* add Javascript code
*/
OC_Util::addScript("neurocloud", "neurocloud");
// register the fileproxy implementation. This subtitutes the old pre/post write hook because of implementation changes of owncloud 5.0.0
include_once 'neurocloud/lib/proxy.php';
OC_FileProxy::register(new NC_FileProxy());
示例8:
*
* 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.
* Tags interface
*
*/
// 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;
// FIXME: Where should I put this? Or should it be implemented as a Listener?
\OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\\Tags', 'post_deleteUser');
/**
* Class for easily tagging objects by their id
*
* A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
* anything else that is either parsed from a vobject or that the user chooses
* to add.
* Tag names are not case-sensitive, but will be saved with the case they
* are entered in. If a user already has a tag 'family' for a type, and
* tries to add a tag named 'Family' it will be silently ignored.
*/
interface ITags
{
/**
* Check if any tags are saved for this type and user.
*
示例9: set_time_limit
<?php
set_time_limit(0);
$RUNTIME_NOAPPS = true;
require_once '../../lib/base.php';
if (OC::checkUpgrade(false)) {
\OC_DB::enableCaching(false);
// initialize the event source before we enter maintenance mode because CSRF protection can terminate the script
$updateEventSource = new OC_EventSource();
OC_Config::setValue('maintenance', true);
$installedVersion = OC_Config::getValue('version', '0.0.0');
$currentVersion = implode('.', OC_Util::getVersion());
OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::WARN);
$watcher = new UpdateWatcher($updateEventSource);
OC_Hook::connect('update', 'success', $watcher, 'success');
OC_Hook::connect('update', 'failure', $watcher, 'failure');
$watcher->success('Turned on maintenance mode');
try {
$result = OC_DB::updateDbFromStructure(OC::$SERVERROOT . '/db_structure.xml');
$watcher->success('Updated database');
// do a file cache upgrade for users with files
// this can take loooooooooooooooooooooooong
__doFileCacheUpgrade($watcher);
} catch (Exception $exception) {
$watcher->failure($exception->getMessage());
}
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
OC_App::checkAppsRequirements();
// load all apps to also upgrade enabled apps
OC_App::loadApps();
OC_Config::setValue('maintenance', false);
示例10:
<?php
OC::$CLASSPATH['OC_Share_Backend_File'] = 'files_sharing/lib/share/file.php';
OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'files_sharing/lib/share/folder.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Shared'] = 'files_sharing/lib/sharedstorage.php';
OC::$CLASSPATH['OC\\Files\\Cache\\Shared_Cache'] = 'files_sharing/lib/cache.php';
OC::$CLASSPATH['OC\\Files\\Cache\\Shared_Permissions'] = 'files_sharing/lib/permissions.php';
OC::$CLASSPATH['OC\\Files\\Cache\\Shared_Updater'] = 'files_sharing/lib/updater.php';
OC::$CLASSPATH['OC\\Files\\Cache\\Shared_Watcher'] = 'files_sharing/lib/watcher.php';
OC::$CLASSPATH['OCA\\Files\\Share\\Api'] = 'files_sharing/lib/api.php';
OC::$CLASSPATH['OCA\\Files\\Share\\Maintainer'] = 'files_sharing/lib/maintainer.php';
OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
OCP\Util::addScript('files_sharing', 'share');
\OC_Hook::connect('OC_Filesystem', 'post_write', '\\OC\\Files\\Cache\\Shared_Updater', 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\\OC\\Files\\Cache\\Shared_Updater', 'postDeleteHook');
\OC_Hook::connect('OC_Filesystem', 'delete', '\\OC\\Files\\Cache\\Shared_Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\\OC\\Files\\Cache\\Shared_Updater', 'renameHook');
\OC_Hook::connect('OCP\\Share', 'post_shared', '\\OC\\Files\\Cache\\Shared_Updater', 'shareHook');
\OC_Hook::connect('OCP\\Share', 'pre_unshare', '\\OC\\Files\\Cache\\Shared_Updater', 'shareHook');
\OC_Hook::connect('OC_Appconfig', 'post_set_value', '\\OCA\\Files\\Share\\Maintainer', 'configChangeHook');
示例11: OC_l10n
<?php
/**
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$l = new OC_l10n('collaboration');
OC::$CLASSPATH['OC_Collaboration_Project'] = 'collaboration/lib/projects.php';
OC::$CLASSPATH['OC_Collaboration_Post'] = 'collaboration/lib/posts.php';
OC::$CLASSPATH['OC_Collaboration_Time'] = 'collaboration/lib/time.php';
OC::$CLASSPATH['OC_Collaboration_Comment'] = 'collaboration/lib/comments.php';
OC::$CLASSPATH['OC_Collaboration_Task'] = 'collaboration/lib/tasks.php';
OC::$CLASSPATH['OC_Collaboration_Mail'] = 'collaboration/lib/mail_templates.php';
OC::$CLASSPATH['OC_Collaboration_Hooks'] = 'collaboration/lib/hooks.php';
OC::$CLASSPATH['OC_Collaboration_Skillset'] = 'collaboration/lib/skillset.php';
OC::$CLASSPATH['OC_Collaboration_Report'] = 'collaboration/lib/reports.php';
OC::$CLASSPATH['OC_Collaboration_Calendar'] = 'collaboration/lib/calendar_support.php';
OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_Collaboration_Hooks', 'notifyUserDeletion');
OC_Hook::connect('OCP\\Share', 'post_shared', 'OC_Collaboration_Hooks', 'notifyFileShare');
$gid = "Collaboration Admin";
if (!OC_Group::groupExists($gid)) {
OC_Group::createGroup($gid);
}
\OCP\App::addNavigationEntry(array('id' => 'collaboration', 'order' => 0, 'href' => \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => '')), 'icon' => \OCP\Util::imagePath('collaboration', 'collaboration.svg'), 'name' => $l->t('Collaboration')));
示例12: array
case 'get_collection':
$data = array();
$data['artists'] = $collection->getArtists();
$data['albums'] = $collection->getAlbums();
$data['songs'] = $collection->getSongs();
\OCP\JSON::encodedPrint($data);
break;
case 'scan':
\OCP\DB::beginTransaction();
set_time_limit(0);
//recursive scan can take a while
$eventSource = new \OC_EventSource();
$watcher = new ScanWatcher($eventSource);
$scanner = new Scanner($collection);
\OC_Hook::connect('media', 'song_count', $watcher, 'count');
\OC_Hook::connect('media', 'song_scanned', $watcher, 'scanned');
$scanner->scanCollection();
$watcher->done();
$eventSource->close();
\OCP\DB::commit();
break;
case 'scanFile':
$scanner = new Scanner($collection);
echo $scanner->scanFile($arguments['path']) ? 'true' : 'false';
break;
case 'get_artists':
\OCP\JSON::encodedPrint($collection->getArtists($arguments['search']));
break;
case 'get_albums':
\OCP\JSON::encodedPrint($collection->getAlbums($arguments['artist'], $arguments['search']));
break;
示例13: testHooks
public function testHooks()
{
if (OC_Filesystem::getView()) {
$user = OC_User::getUser();
} else {
$user = uniqid();
OC_Filesystem::init('/' . $user . '/files');
}
OC_Hook::clear('OC_Filesystem');
OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
$rootView = new OC_FilesystemView('');
$rootView->mkdir('/' . $user);
$rootView->mkdir('/' . $user . '/files');
OC_Filesystem::file_put_contents('/foo', 'foo');
OC_Filesystem::mkdir('/bar');
OC_Filesystem::file_put_contents('/bar//foo', 'foo');
$tmpFile = OC_Helper::tmpFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
OC_Filesystem::file_put_contents('/bar//foo', $fh);
}
示例14: init
//.........这里部分代码省略.........
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
self::initPaths();
// register the stream wrappers
require_once 'streamwrappers.php';
stream_wrapper_register("fakedir", "OC_FakeDirStream");
stream_wrapper_register('static', 'OC_StaticStreamWrapper');
stream_wrapper_register('close', 'OC_CloseStreamWrapper');
self::checkInstalled();
self::checkSSL();
// CSRF protection
if (isset($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
} else {
$referer = '';
}
$refererhost = parse_url($referer);
if (isset($refererhost['host'])) {
$refererhost = $refererhost['host'];
} else {
$refererhost = '';
}
$server = OC_Helper::serverHost();
$serverhost = explode(':', $server);
$serverhost = $serverhost['0'];
if ($_SERVER['REQUEST_METHOD'] == 'POST' and $refererhost != $serverhost) {
$url = OC_Helper::serverProtocol() . '://' . $server . OC::$WEBROOT . '/index.php';
header("Location: {$url}");
exit;
}
self::initSession();
self::initTemplateEngine();
self::checkUpgrade();
$errors = OC_Util::checkServer();
if (count($errors) > 0) {
OC_Template::printGuestPage('', 'error', array('errors' => $errors));
exit;
}
// TODO: we should get rid of this one, too
// WARNING: to make everything even more confusing,
// DATADIRECTORY is a var that changes and DATADIRECTORY_ROOT
// stays the same, but is set by "datadirectory".
// Any questions?
OC::$CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
// User and Groups
if (!OC_Config::getValue("installed", false)) {
$_SESSION['user_id'] = '';
}
OC_User::useBackend(OC_Config::getValue("userbackend", "database"));
OC_Group::useBackend(new OC_Group_Database());
// Set up file system unless forbidden
global $RUNTIME_NOSETUPFS;
if (!$RUNTIME_NOSETUPFS) {
OC_Util::setupFS();
}
// Load Apps
// This includes plugins for users and filesystems as well
global $RUNTIME_NOAPPS;
global $RUNTIME_APPTYPES;
if (!$RUNTIME_NOAPPS) {
if ($RUNTIME_APPTYPES) {
OC_App::loadApps($RUNTIME_APPTYPES);
} else {
OC_App::loadApps();
}
}
// Check for blacklisted files
OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
//make sure temporary files are cleaned up
register_shutdown_function(array('OC_Helper', 'cleanTmp'));
//parse the given parameters
self::$REQUESTEDAPP = isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? str_replace(array('\\0', '/', '\\', '..'), '', strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files');
if (substr_count(self::$REQUESTEDAPP, '?') != 0) {
$app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
$param = substr(self::$REQUESTEDAPP, strpos(self::$REQUESTEDAPP, '?') + 1);
parse_str($param, $get);
$_GET = array_merge($_GET, $get);
self::$REQUESTEDAPP = $app;
$_GET['app'] = $app;
}
self::$REQUESTEDFILE = isset($_GET['getfile']) ? $_GET['getfile'] : null;
if (substr_count(self::$REQUESTEDFILE, '?') != 0) {
$file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?'));
$param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1);
parse_str($param, $get);
$_GET = array_merge($_GET, $get);
self::$REQUESTEDFILE = $file;
$_GET['getfile'] = $file;
}
if (!is_null(self::$REQUESTEDFILE)) {
$subdir = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP . '/' . self::$REQUESTEDFILE;
$parent = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP;
if (!OC_Helper::issubdirectory($subdir, $parent)) {
self::$REQUESTEDFILE = null;
header('HTTP/1.0 404 Not Found');
exit;
}
}
}
示例15: registerShareHooks
/**
* register hooks for sharing
*/
public static function registerShareHooks()
{
OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\\Share', 'post_deleteUser');
OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\\Share', 'post_addToGroup');
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\\Share', 'post_removeFromGroup');
OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\\Share', 'post_deleteGroup');
}