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

Conversation

leonklingele-work
Copy link

This allows other apps to hook in and add their own section to the
'Personal Settings' page via:

\OC_Hook::connect('\OC\Settings\Personal', 'preFormRender',\
    $this, 'onPreFormRender');

the personal settings form.

This allows other apps to hook in and add their own section to the
'Personal Settings' page via:

    \OC_Hook::connect('\OC\Settings\Personal', 'preFormRender',\
        $this, 'onPreFormRender');

Signed-off-by: Leon Klingele <leon@struktur.de>
@nickvergessen
Copy link
Member

  1. We don't use emitter stuff anymore, but the symfony event dispatcher
  2. You should be able to register your own setting in your info.xml, for examples see:
    <personal>OCA\Files_External\Settings\Personal</personal>
    <personal-section>OCA\Files_External\Settings\PersonalSection</personal-section>

@leonklingele-work
Copy link
Author

You should be able to register your own setting in your info.xml, for examples see:

This is not what we want to achieve. The info.xml settings you mentioned adds a new tab to the personal settings page, see this screenshot:
nextcloud-personal-settings-new-tab-infoxml

We want to extend the 'Personal Info' page directly as shown here:
nextcoud-personal-settings-pr

I had a discussion with @schiessle about this. Please don't close the PR prematurely.

@codecov
Copy link

codecov bot commented Sep 6, 2017

Codecov Report

Merging #6363 into master will decrease coverage by <.01%.
The diff coverage is 36.36%.

@@             Coverage Diff              @@
##             master    #6363      +/-   ##
============================================
- Coverage     54.49%   54.48%   -0.01%     
- Complexity    21220    21223       +3     
============================================
  Files          1313     1313              
  Lines         82440    82449       +9     
  Branches       1329     1329              
============================================
  Hits          44922    44922              
- Misses        37518    37527       +9
Impacted Files Coverage Δ Complexity Δ
lib/private/Settings/Manager.php 44.35% <0%> (-1.25%) 75 <2> (+3)
lib/private/Server.php 84.12% <100%> (-0.09%) 123 <0> (ø)
apps/files_trashbin/lib/Trashbin.php 72.28% <0%> (-0.25%) 136% <0%> (ø)

@nickvergessen
Copy link
Member

Yeah as mentioned in the chat.
If you dont want your own section, use the existing ones. You can find the IDs in:

0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],

Additional when this is about timezone/date settings, I would hardcode them in since tasks app, activity and others also make use of this.

@leonklingele-work
Copy link
Author

leonklingele-work commented Sep 6, 2017

This is indeed already possible without adding any events.
The solution:

  1. Add this to your info.xml:
<settings>
	<personal>OCA\YOUR_APP_ID\Settings\Personal</personal>
</settings>
  1. Create a Personal class in that namespace which implements OCP\Settings\ISettings, e.g. https://github.com/nextcloud/server/blob/2cb346114685ded69f5291812503c278298c1bce/apps/files_external/lib/Settings/Personal.php
  2. Make sure getSection() returns 'personal-info'
  3. Increase your app's version
  4. Run the upgrader

EDIT:

  • Fix typo
  • Add getSection() step

@MorrisJobke MorrisJobke deleted the personal-settings-hook-preFormRender branch January 12, 2018 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants