Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\OC\Settings\Personal: Emit 'preRenderForm' event before rendering the personal settings form #6363

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,10 @@ public function __construct($webRoot, \OC\Config $config) {
$c->getThemingDefaults(),
$c->getAppManager()
);
$manager->listen('\OC\Settings\Personal', 'preFormRender', function (callable $cb) {
// Emit event publicly
\OC_Hook::emit('\OC\Settings\Personal', 'preFormRender', $cb);
});
return $manager;
});
$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
Expand Down
20 changes: 19 additions & 1 deletion lib/private/Settings/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace OC\Settings;

use OC\Accounts\AccountManager;
use OC\Hooks\PublicEmitter;
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\Encryption\IManager as EncryptionManager;
Expand All @@ -41,7 +42,15 @@
use OCP\Settings\IManager;
use OCP\Settings\ISection;

class Manager implements IManager {
/**
* Settings Manager
*
* Hooks available in scope \OC\Settings\Personal:
* - preFormRender(callable $cb)
*
* @package OC\Settings
*/
class Manager extends PublicEmitter implements IManager {
/** @var ILogger */
private $log;
/** @var IDBConnection */
Expand Down Expand Up @@ -417,6 +426,15 @@ private function getBuiltInPersonalSettings($section) {
$this->l
);
$forms[$form->getPriority()] = [$form];

$this->emit('\OC\Settings\Personal', 'preFormRender', array(function($form) use(&$forms) {
$prio = $form->getPriority();
if (isset($forms[$prio])) {
$forms[$prio][] = $form;
} else {
$forms[$prio] = [$form];
}
}));
}
if($section === 'security') {
/** @var ISettings $form */
Expand Down
6 changes: 6 additions & 0 deletions lib/public/Settings/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
namespace OCP\Settings;

/**
* Settings Manager
*
* Hooks available in scope \OC\Settings\Personal:
* - preFormRender(callable $cb)
*
* @package OC\Settings
* @since 9.1
*/
interface IManager {
Expand Down