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

Template variable in the link #64

Closed
pierreozoux opened this issue Nov 17, 2017 · 3 comments · Fixed by #66
Closed

Template variable in the link #64

pierreozoux opened this issue Nov 17, 2017 · 3 comments · Fixed by #66
Assignees

Comments

@pierreozoux
Copy link
Member

I'm a Nextcloud admin.
I'd like to put links under quota that point to my billing system.
My billing system expects an email in the url for the bill.

Implementation proposal

We create a function that allow Nextcloud admin to have special chars in the url, like say {{ email }}, and this would be replaced at runtime, by the actual email of the user.

so then, in the admin settings, I'd write:

https://example.org/buy_now/?email={{ email }}

And as a user, when I click on the link, I'd go to:

https://example.org/buy_now/?email=pierre@ozoux.net

What do you think about this feature?

@nickvergessen
Copy link
Member

Sounds doable. I guess we should support email and user id for now?

@pierreozoux
Copy link
Member Author

pierreozoux commented Nov 17, 2017

I'd actually need First and Last name too.
I actually would like to implement it.

I thought about a "dirty" way, using js, and modify at print time.
But I guess, it would be better to do it server side.

I'm quiet new to Nextcloud app dev, so if you could point to similar code, would be really helpful.

And also, what do you think about the formalism? {{ email }} is good, or do we use something else in different places?

Thanks a lot for your help!

@pierreozoux pierreozoux self-assigned this Nov 17, 2017
@nickvergessen
Copy link
Member

And also, what do you think about the formalism? {{ email }} is good, or do we use something else in different places?

I would use what we do in JS code everywhere: {email}, etc.

I'd actually need First and Last name too.

So email, userId and displayName?

I actually would like to implement it.

Cool 😎

So let me give you some hints:

  1. You need to inject OCP\IUserSession into OCA\External\Controller\APIController, like it is currently done with SitesManager.
  2. In the function get(your other modifications take place:
    1. you need to get the IUser object from the IUserSession
    2. in the foreach you need to add a str_replace() to replace the placeholders with the values of the IUser object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants