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

Override params.php Without Affecting Other Plugins #15

Closed
aljawaid opened this issue Jan 15, 2023 · 12 comments
Closed

Override params.php Without Affecting Other Plugins #15

aljawaid opened this issue Jan 15, 2023 · 12 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@aljawaid
Copy link
Owner

About the core, what if I override the step 2?

autosubtasks overrides the params.php but what if i override step 2, which is action_creation/event.php ? then in that override, we say, if this plugin then process and go to MY params file, otherwise leave it as it is.... this will then be picked up by autosubtasks and overridden.

<div class="page-header">
    <h2><?= t('Choose an event') ?></h2>
</div>

// SO IF WE DO AN `IF` STATEMENT HERE WITH MAYBE A CUSTOM CONTROLLER...
IF ...EXISTS PLUGIN/KANBOARDEMAILHOSTORY
     then duse my controller to send my version of the params file, otherwise....
ELSE... BELOW IS DEFAULT CODE

<form method="post" action="<?= $this->url->href('ActionCreationController', 'params', array('project_id' => $project['id'])) ?>">
    <?= $this->form->csrf() ?>

    <?= $this->form->hidden('action_name', $values) ?>

    <?= $this->form->label(t('Action'), 'action_name') ?>
    <?= $this->form->select('action_name', $available_actions, $values, array(), array('disabled')) ?>

    <?= $this->form->label(t('Event'), 'event_name') ?>
    <?= $this->form->select('event_name', $events, $values) ?>

    <div class="form-help">
        <?= t('When the selected event occurs execute the corresponding action.') ?>
    </div>

    <?= $this->modal->submitButtons(array(
        'submitLabel' => t('Next step')
    )) ?>
</form>

Originally posted by @aljawaid in #12 (reply in thread)

@aljawaid aljawaid added this to the Override Parameters File milestone Jan 15, 2023
@aljawaid aljawaid added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Jan 15, 2023
aljawaid added a commit that referenced this issue Jan 15, 2023
- WIP #15
- Reverts `Plugin.php` in 408723f
- #12
aljawaid added a commit that referenced this issue Jan 15, 2023
aljawaid added a commit that referenced this issue Jan 15, 2023
aljawaid added a commit that referenced this issue Jan 15, 2023
@aljawaid
Copy link
Owner Author

@creecros please check, I think I am done

aljawaid added a commit that referenced this issue Jan 15, 2023
aljawaid added a commit that referenced this issue Jan 15, 2023
aljawaid added a commit that referenced this issue Jan 16, 2023
aljawaid added a commit that referenced this issue Jan 16, 2023
aljawaid added a commit that referenced this issue Jan 16, 2023
- Add `if` for code block specific to this plugin
- WIP #15
- #10
aljawaid added a commit that referenced this issue Jan 16, 2023
@aljawaid
Copy link
Owner Author

oh crap, after doing all this work I think I have messed up...!

  • What's the alternative for file_exists ? Because, if installed it will exist, but that will mean that Autosubtasks (installed) wont be able to override template at all... I need something like 'if this plugin is being used to access this action'
  • also, i tried resetting the param file because the project identifier checkbox in the options is shown as a select list of the projects... i think that has something to do with the rendering of my controller but i dont know where to look.
  • the placeholder works/shows up but with file_exists I fear it will show for every plugin and every text box in the action forms if this plugin is installed...

I dunno, my head is messed up now

@aljawaid
Copy link
Owner Author

image

  • is the last select because i used 'plugin' => 'KanboardEmailHistory'?
    <form method="post" action="<?= $this->url->href('EmailHistoryController', 'parameters', array('project_id' => $project['id'], 'plugin' => 'KanboardEmailHistory')) ?>">

@creecros
Copy link
Collaborator

oh crap, after doing all this work I think I have messed up...!

  • What's the alternative for file_exists ? Because, if installed it will exist, but that will mean that Autosubtasks (installed) wont be able to override template at all... I need something like 'if this plugin is being used to access this action'
  • also, i tried resetting the param file because the project identifier checkbox in the options is shown as a select list of the projects... i think that has something to do with the rendering of my controller but i dont know where to look.
  • the placeholder works/shows up but with file_exists I fear it will show for every plugin and every text box in the action forms if this plugin is installed...

I dunno, my head is messed up now

it's okay, at least you learned something and got a little practice.

as for file_exists. I'm not aware of that php method, 'if this plugin is being used to access this action'. maybe in the next php release?

@creecros
Copy link
Collaborator

ewww...I just thought of it though. I guess it does exist.

@creecros
Copy link
Collaborator

creecros commented Jan 16, 2023

ewww...I just thought of it though. I guess it does exist.

opp, nevermind, that won't work.

@creecros
Copy link
Collaborator

well crap, maybe....ya, I think so.

OK, here's my thought.

include a hidden field in the action...and use that in the check to determine if it is coming from your plugin action. if so, have your controller use your params.php, if not, use normal params.php.

@aljawaid
Copy link
Owner Author

well crap, maybe....ya, I think so.

OK, here's my thought.

include a hidden field in the action...and use that in the check to determine if it is coming from your plugin action. if so, have your controller use your params.php, if not, use normal params.php.

I have no idea how to do that. Thinking of packing it in.

@aljawaid
Copy link
Owner Author

well crap, maybe....ya, I think so.

OK, here's my thought.

include a hidden field in the action...and use that in the check to determine if it is coming from your plugin action. if so, have your controller use your params.php, if not, use normal params.php.

Could you explain this a bit more please

@aljawaid
Copy link
Owner Author

aljawaid commented Jan 16, 2023

well crap, maybe....ya, I think so.

OK, here's my thought.

include a hidden field in the action...and use that in the check to determine if it is coming from your plugin action. if so, have your controller use your params.php, if not, use normal params.php.

@creecros what would the value be?
<?= $this->form->hidden('kanboardemailhistory_check', $values) ?>

This is what I am thinking...

  1. add above hidden field in step 1 action_creation/create.php
  2. in step 2 event.php change the if file_exists to 'if hidden field = true/yes' then show my form with my params, else show the default form for the default params
  3. i dont think the controller would need to be changed then

@aljawaid
Copy link
Owner Author

@creecros could i use this for the check?

<?php if ($this->app->checkMenuSelection('ActionController'))

so if i do it as mycontroller.. do you think it would work?

@aljawaid
Copy link
Owner Author

ooooh... I think I might have done it.... testing... standby caller

aljawaid added a commit that referenced this issue Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants