Skip to content

edit by margarett -- Custom Actions Mod#1

Open
margarett wants to merge 7 commits into
illori:masterfrom
margarett:master
Open

edit by margarett -- Custom Actions Mod#1
margarett wants to merge 7 commits into
illori:masterfrom
margarett:master

Conversation

@margarett
Copy link
Copy Markdown

  • remove CA from ACP
  • create permissions to create, edit and remove CA's
  • CA's ordered in a single menu

Signed-off-by: margarett bruno.m.alves@gmail.com

* remove CA from ACP
* create permissions to create, edit and remove CA's
* CA's ordered in a single menu

Signed-off-by: margarett <bruno.m.alves@gmail.com>
@illori
Copy link
Copy Markdown
Owner

illori commented Nov 28, 2013

<require-file name="files/CustomAction.php" destination="$sourcedir" /> <require-file name="files/CustomAction.template.php" destination="$themedir" />

those files are not in a files folder so the install fails on that part.

@margarett
Copy link
Copy Markdown
Author

Ups 👅 That got lost in the installer-combination between what I've done and what was already done :(
I've fixed it locally, but can only submit later ;)

Signed-off-by: margarett <bruno.m.alves@gmail.com>
@illori
Copy link
Copy Markdown
Owner

illori commented Dec 2, 2013

as admin i can not view the button in the menu to add/control the mod. giving permissions to a user to create custom actions and edit, they can not view the button in the menu either, once i created an action then the button shows but only if the action is set to show the menu button.

i assume the edit url is http://localhost:8080/github2.1/index.php?action=ca_edit

going to that url i get

Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND), expecting ')' in F:\wamp\www\github2.1\Sources\CustomAction.php on line 319

it should be

elseif (!empty($context['user']['id']) && ($context['user']['id'] == $row['id_author'])) //am I the author? If so, of course I can read

then i get
Unknown column 'ca.id_author' in 'field list'
File: F:\wamp\www\github2.1\Sources\CustomAction.php
Line: 313
SELECT ca.id_action, ca.name, ca.url, ca.action_type, COUNT(sa.id_action) AS sub_actions,
ca.enabled, ca.permissions_mode, ca.id_author
FROM smf1_custom_actions AS ca
LEFT JOIN smf1_custom_actions AS sa ON (ca.id_action = sa.id_parent)
WHERE ca.id_parent = 0
GROUP BY ca.id_action, ca.name, ca.url, ca.action_type, ca.enabled
ORDER BY ca.name
LIMIT 0, 25
when i go to action=ca_list

my smf1_custom_actions table does not have id_author in the table

if i tell the package manager to remove the data then the id_author column is added but not on a "reinstall"

when i go to ca_edit and create a new action, the permissions mode is grayed out as an admin and i can not select who can view the page

now that i created a page and set it to show the button my user that has permission to create new actions can create them

my user that can only edit their own actions can view the one the admin use created.

also we may want to consider a way to limit who can create html and php actions.

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 2, 2013

line 406 CustomAction.php undefined permission_mode for all users

Invalid argument supplied for foreach()
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Themes/default/ManagePermissions.template.php
Line: 1015

Undefined index: ca_temp
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Sources/ManagePermissions.php
Line: 1841

@margarett
Copy link
Copy Markdown
Author

as admin i can not view the button in the menu to add/control the mod. giving permissions to a user to create custom actions and edit, they can not view the button in the menu either, once i created an action then the button shows but only if the action is set to show the menu button.

Fixed. Duh!

i assume the edit url is http://localhost:8080/github2.1/index.php?action=ca_edit
going to that url i get
Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND), expecting ')' in F:\wamp\www\github2.1\Sources\CustomAction.php on line 319

It is. I can't reproduce that, it opens the page clearly, no errors reported. But looking at the line, there was a parenthesis out of place, yes :P XAMPP doesn't complaint about that :P
Fixed

Unknown column 'ca.id_author' in 'field list'

Yes, you really have to recreate the table (meaning, delete it before installing the MOD. I'm not yet familiar with the "database flow" on MOD install/uninstall :(

when i go to ca_edit and create a new action, the permissions mode is grayed out as an admin and i can not select who can view the page

Fixed (not thoroughly tested, though)

Have to reboot the computer :tongue but I'll continue in a minute

@margarett
Copy link
Copy Markdown
Author

my user that can only edit their own actions can view the one the admin use created.

Could not reproduce :(

line 406 CustomAction.php undefined permission_mode for all users

Invalid argument supplied for foreach()
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Themes/default/ManagePermissions.template.php
Line: 1015

Undefined index: ca_temp
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Sources/ManagePermissions.php
Line: 1841

Could not reproduce :(

I'm updating the package, can you completely uninstall (probably get a fresh SMF copy from GH), including database, and retry?

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

did you commit your changes? i dont see any showing up since you fixed the installer

@margarett
Copy link
Copy Markdown
Author

Just updated now. I thought I commited but I didn't. This GH stuff is still pretty new to me 👅

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

the normal user i have can still see the action that the admin made...

might also be nice to see who created the pages in the list

and still i have those errors posted above about permissions_mode, undefined index:ca_temp and invalid argument supplied for foreach()

@margarett
Copy link
Copy Markdown
Author

the normal user i have can still see the action that the admin made...

Check if the user is not part of several groups. I can't really reproduce that :(
Or if your action (admin created) isn't really visible to everyone or to the groups that test user belongs...

and still i have those errors posted above about permissions_mode, undefined index:ca_temp and invalid argument supplied for foreach()

And I still can't see this happening. Can you clear your log and try to see in which action this happens? I usually do this with 2 open tabs (or 2 browsers for different users) and, each time I do something in the forum, I refresh the error log in the second tab/browser...

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

the action created by the admin is visible to all groups, but it should only be able to be edited by the admin or the person that created it.

Undefined index: permissions_mode
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Sources/CustomAction.php
Line: 407

2: Invalid argument supplied for foreach()
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Themes/default/ManagePermissions.template.php
Line: 1015

8: Undefined index: ca_temp
http://localhost:8080/github2.1/index.php?action=ca_edit
File: F:/wamp/www/github2.1/Sources/ManagePermissions.php
Line: 1841

the errors only show up when the test user creates an action not the admin user.

@margarett
Copy link
Copy Markdown
Author

Got it, thanks. Working on it

edit: dang, no idea why this happens :(

@margarett
Copy link
Copy Markdown
Author

I think I fixed undefined/invalid issues now. Scrambling with permissions is really tricky :P
Now, onto the test user who can see everything :)

@margarett
Copy link
Copy Markdown
Author

Ah, it's per design, it's not really a bug :)

//We need to process what we read. if ($row['permissions_mode'] == 0) //everyone can read so let it be :)
So I assumed that, if an action can be seen by anyone, it should appear on the list.
OK, so the "Modify" link shouldn't really be there but, if you click it, you receive an error "You are not allowed to".
I am still do find out how to work with that stupid list function (and it's a SMF function, but it really gets to my nerves :))

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

thanks for looking into it.

@margarett
Copy link
Copy Markdown
Author

Submitting now ;)

Signed-off-by: margarett <bruno.m.alves@gmail.com>
@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

2: Invalid argument supplied for foreach()
http://localhost:8080/github2.1/index.php?action=ca_edit;id_action=2
File: F:/wamp/www/github2.1/Themes/default/ManagePermissions.template.php
Line: 1015

8: Undefined index: ca_2
http://localhost:8080/github2.1/index.php?action=ca_edit;id_action=2
File: F:/wamp/www/github2.1/Sources/ManagePermissions.php
Line: 1841

the user is not able to edit the admin's action that is good.

also there is no check if an existing action with the same name already exists.

@margarett
Copy link
Copy Markdown
Author

What were you doing when such error appears?

The check for same name is a "todo". First we need to have the "ground" stable. That, the appearance of the buttons, etc...

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

looks like creating an action with my test account

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

no it was editing the article with the test user.

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

article was created with the test user

if admin edits it no errors

@margarett
Copy link
Copy Markdown
Author

Same permission trick as before :s

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

i will check it out again tomorrow

Signed-off-by: margarett <bruno.m.alves@gmail.com>
@margarett
Copy link
Copy Markdown
Author

I've fixed it already.
Next step is to allow the user to choose the groups when editing the action. So we'll leave it as default when creating (to everyone) and then the user can edit it and then choose the grups.
If I can still master this permissions issue, it might be possible to do it directly when creating the action. We'll see ;)

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 3, 2013

i thought we said that only admin should change who can view the action?

@margarett
Copy link
Copy Markdown
Author

If you test this and find no bugs, I'd suggest you to merge it now so that you can add your stuff.
I remember you already fixed the layout some time ago and this "graphics" part is really not my thing, so I could use some help from here ;-)

Anyway, from what I've seen, (and from what I understand, which is not much) there are several issues that need to be addressed:

  • we need to get the correct classes in use and fix index.css (or to create a new .css file) because some of them are now invalid and/or out of place
  • we need to remove all of that "span" mess and create dd/dt/dd as it seems more simple to format the layout and it's for sure "cleaner"

On the create action, the boxes should be bigger. BBC should be more or less same size as the normal post box (and it would be gold if we could add the BBC buttons 😄 ). For PHP/HTML, since it uses 2 boxes, they should be one-on-top-of the other, again, full size as it should be a real PITA to have code in such a small textbox...

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

remove the span stuff where? in the template ? i was the one that added the spans to make it look better then it did in the old version.

where is your code?

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

or is there no new code since the last?

@margarett
Copy link
Copy Markdown
Author

Latest commit was yesterday:

margarett added a commit 16 hours ago

Default type is now BBC, except for admin

Now I was searching on what to do next, but I hate this graphics stuff 👅
I am comparing, eg, to the "add membergroup" page in admin. In ManageMembergroups.template.php, they use something like this:
<div class="windowbg"> <div class="content"> <dl class="settings"> <dt> <label for="group_name_input"><strong>', $txt['membergroups_group_name'], ':</strong></label> </dt> <dd> <input type="text" name="group_name" id="group_name_input" size="30" class="input_text" /> </dd>';
And this results in a perfectly aligned structure for input of the action configuration. Then, the boxes should probably be included in "divs" or keep the "spans". But this graphics stuff is way over my head :P

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

make an issue on that over at the 2.1 repo

@margarett
Copy link
Copy Markdown
Author

Now you got me lost :P
An issue about what?

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

the template in manageMembergroups.template.php so they can add the spans. unless you mean i need to add spans somwhere?

@margarett
Copy link
Copy Markdown
Author

No, we're in circles :P

The template at ManageMembergroups is fine. We need to fix our template to remove the spans and use the dl/dt/dd operators to better align the action options ;)
Doing it like this also helps us with CSS because the classes for those already exist ;-)
By action options I mean the upper part of our "create action" template.

Ha, just remembered, I need to fix the possibility to add actions with the same name!

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

the old mod was using tables, i am not that familiar with tables or dl/dt/dd's i just made the page match the existing formats on other admin pages

@margarett
Copy link
Copy Markdown
Author

Oh :P So we saw different admin pages, then :P

There is no harm in using tables if the content is tabbed ;-)

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

there is an issue when it looks ugly. go install the old mod from the mod site on 2.0 and check it out.

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

Notice: Undefined index: custom_action_only_admin_change_permissions in F:\wamp\www\github2.1\Themes\default\CustomAction.template.php on line 107

@margarett
Copy link
Copy Markdown
Author

Missed that language string in the install file :( I fixed it here, offline, when I commit will be there already. I'm thinking in include a dedicated language file for easy maintenance :)
You can add it to Modifications.english.php, if you like. Careful because the MOD will not delete that string as it was not put there by it
$txt['custom_action_only_admin_change_permissions'] = 'Custom Pages are, by default, visible to anyone. Please contact an Administrator if you want to restrict this.';

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

do we want normal users to be able to toggle the enabled box? i am thinking it may be useful to just allow admin to handle that, maybe also show menu button as well.

@margarett
Copy link
Copy Markdown
Author

Actually I thought about that, and I think it does make sense. Imagine that if the user wants to create an action but wants to have non-default visibility.
So, he creates it, not enabled, then asks the admin to change the visibility and to enable it.

This brings me to another issue :( The actual visibility setting will ALWAYS set it to everyone, every time a non-admin user edits an action. Even if the admin had it set to "groups", then the save will overwrite that and put it back to "everyone".
Hummm, have to think about this...

@margarett
Copy link
Copy Markdown
Author

Not quite ready to merge, then :P

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

and one more thing, on the action list can you add the author of the action?

@margarett
Copy link
Copy Markdown
Author

Yes, that's on the "todo list". But that also messes with that "createList" function, the one that keeps banging my mind :P

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 6, 2013

you could always ask for help if you need it on the forum.

@margarett
Copy link
Copy Markdown
Author

Yup, will do that. Later, though, we still have things to polish (and everytime I think "almost done", something comes up. I wonder how developers feel :P )

@margarett
Copy link
Copy Markdown
Author

Time to go to bed. I'm reviewing hard the CustomAction.php source file.
I'll be writting it a little bit as the Post.php file, with separate functions to display and actually save the data, so that you can go back to the form in case of errors.
Imagine you write a full BBC custom page, then you submit it and it "dies" on an error like, say... action URL already exists (just created that :P ). So you click "Back" and puffff, all you data is gone :P Not a good idea, hey?

@margarett
Copy link
Copy Markdown
Author

I have the feeling I bit more that I can chew :P :P :P

I hope you're not in a hurry :)

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 10, 2013

i am not as long as 2.1 is not released :P

@margarett
Copy link
Copy Markdown
Author

Jeez, what a pain :P
That's really THE hardest thing I've done in SMF, period :P

Still trying to work out something here. I need not only to make it work but I also need to do something that "moves" to keep motivation. AAAAARGGGG!!!!! 👊

@margarett
Copy link
Copy Markdown
Author

Starts too look better. Finally :P
http://s23.postimg.org/ov3hl85i3/img1.png

I'm still just on the layout thing. I still need to go again through all the database operations because I broke all of this when re-writing it :P

When this is again "workable", we need to go through the debug all over again :P Not so sure if this was a good idea now, was it? :)
I will probably create a temporary repo for this new version and then we can work through it with GH's issues, instead of a huuuuge conversation. When we finish, then you can merge it here and I'll delete that.
What do you think?

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 16, 2013

whatever works for you.

@margarett
Copy link
Copy Markdown
Author

Howdy :)

Don't think I forgot this. I've been working on it. Unfortunately I've had little time and I stumbled on a LOT of new things for me :P
I think I finished the new page for action creation/edition but there is still a lot to do :(

  • I need to re-write most of the "custom edit" function because I changed field names and I changed some fundamental "flow" on data
  • I need to create an alternative to "allowedTo(action)" because I removed that crappy inline permissions (no more admin token ;)) This means that I'm no longer using SMF's permissions --> less database load but more manual programming :P

We'll get there. But I need time, really...
The MOD is so broken now that I have nothing to send you :P

@margarett
Copy link
Copy Markdown
Author

UPDATE !!! :)
So, I was finally able to save a new custom action :) All new template, all new "Edit" function (not really, really new, but who cares? :)). I still need to work on the delete part and, as I told you in the previous message, to redo the permissions part of the thing.

It still requires some work. A lot of it, really 👅

@illori
Copy link
Copy Markdown
Owner

illori commented Dec 26, 2013

but you are getting there, that is good.

@margarett
Copy link
Copy Markdown
Author

Yup, it is :) Unfortunately I'm having almost no time to play with this. And due to the complexity involved (to me, at least ehehheh) it's not something I can pick when I have like 30 minutes to spare :)

Now I just did some "aesthetic", just-for-fun changes: linktree (not yet in every functions) and the "Custom Actions" menu button is active when a "ca-related-action" is being performed :P
And now, hop to bed :P Tomorrow the day starts very early...
Cheers ;-)

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