Author Topic: Admin Panel : Creating a proper admin panel.  (Read 27741 times)

0 Members and 1 Guest are viewing this topic.

Offline r][m

  • Tireless poster
  • ****
  • Posts: 347
    • View Profile
Re: Admin Panel : Add User To Group
« Reply #75 on: June 07, 2009, 05:37:23 PM »
For those who haven't added a Admin Panel section that adds a user to a specific group
copy the text file attached, to your Admin Panel section. You will need to add the link to
the Admin Panel page,  your own css link, and change
{.if not | {.match|USER1;USER2|%user%.}| {:{.$error.}:} |
I find it quite useful when adding a new user, to be able to add them to a pre-defined
group, at least at first.
This is based on the early version of the Admin Panel posted by Mars.

Help ! please
I've tried to assemble a macro that would list the members of each group,
by group, as "Group 1: seth;tom;bill" "Group 2: joe;andy" so when I add a
new user he will show in the listing for the group he's added to.
I've tried combinations of
" {.member of |"  &  " {.get | accounts |"   etc,
but with no luck. " get | accounts"   produces a full list, but its ordered by
by the user window list, not by which group a user actually belongs to.
 
Rejetto, Mars, anyone have an example?
« Last Edit: June 07, 2009, 06:41:02 PM by r][m »

Offline bacter

  • Operator
  • Tireless poster
  • *****
  • Posts: 682
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #76 on: June 07, 2009, 08:37:34 PM »
I have some macros that allow you to get the lists you want.

In the first place, the macro used to prepare the lists. I load this module when needed in [special:begin].

Code: [Select]
{.comment|------------------------------------------------------------------
macros related to users and groups
creates a list that is easy to use as csv
Note for group naming:
*name = regular group (associated to site, directory)
#name = attribute group (has no acces to anyting, is uses to distinguish
  users with special rights or tastes
examples: #auxadm - allowed to add accounts to his regular group(s)
          #techie - template shows only to them things like speeds,users conected,downloadcounters etc.
--------------------------------------------------------------------.}
{.set|accgroups|{.get|accounts|groups.}.}
{.set|accusers|{.get|accounts|users.}.}
{.set|tg|{.^accgroups.}.}
{.set|ng|{.add|{.count substring|*|{.^accgroups.}.}|{.count substring|#|{.^accgroups.}.}.}.}
{.set|group|.}
{.for|ii|1|{.^ng.}|
{:
{.set|tg2|{.substring||;|{.^tg.}.}.}{.set|tg|{.replace|{.^tg2.};||{.^tg.}.}.}
{.set append|group|[{.cut|2||{.^tg2.}.}:.}
{.set|tus|{.^accusers.}.}
{.set|nu|{.count substring|;|{.^accusers.}.}.}
{.for|jj|0|{.^nu.}|
{:
{.set|tu2|{.substring||;|{.^tus.}.}.}
{.if|{.member of|{.^tg2.}|user={.^tu2.}.}|{:{.set append |group|{.^tu2.};.}:}.}
{.set|tus|{.replace|{.^tu2.};||{.^tus.}.}.}
:}.}
:}.}
{.set append |group|][not in group:.}
{.set|tus|{.^accusers.}.}
{.for|jj|0|{.^nu.}|
{:
{.set|tu2|{.substring||;|{.^tus.}.}.}{.set|tus|{.replace|{.^tu2.};||{.^tus.}.}.}
{.if not|{.pos|{.^tu2.}|{.^group.}.}|{:{.set append |group|{.^tu2.};.}:}.}
:}.}
{.set append |group|].}


here you have some code to show your lists of user groups in different manners (to be placed or called in the section where you want to show the list in your template):

Code: [Select]
        Total groups:{.^ng.}<br />
Groups: {.^accgroups.}<br />
Users: {.replace|;|, |{.^accusers.}.}<br />
Full list:{.replace|;|, |{.get|accounts.}.}<br />
{.comment| the showcsv.. macros are in a separate macro module.}
{.^showcsvrows|{.replace|[|<br />|{.^group.}.}.}
{.^showcsvtable|{.replace|;| - |{.replace|:|,|{.^group.}.}.}.}

To see better the list or even a table, you can use and adapt to your need the following showcsv.. macros (must also be placed before first use!):

Code: [Select]
{.set|showcsvrows|{:{.replace|][|]<br />[|$1.}:}.}
{.set|showcsvtable|{:
{.set|ttab|{.replace|]|</td></tr>|$1.}.}
{.set|ttab|{.replace|[|<tr><td nowrap>|{.^ttab.}.}.}
{.set|ttab|{.replace|,|</td><td nowrap>|{.^ttab.}.}.}
<table border="1">{.^ttab.}</table>
:}.}

that's all  :)
your computer has no brain - use your own !

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #77 on: June 07, 2009, 10:22:08 PM »
wow bacter

let me suggest you a facility
{.set|#extract till|{:{.set|#temp|{.substring||$1|{.^$2.}.}.}{.set|$2|{.cut|{.add|2|{.length|var=#temp.}.}||{.^$2.}.}.}{.^#temp.}{.set|#asdtemp.}:}/set.}

so that you can
{.set|#gs|{.get|accounts|groups.}.}
{.while|#gs|{:{.^#extract till|;|#gs.} :}.}


i used #static vars because i used the "run script".

Offline bacter

  • Operator
  • Tireless poster
  • *****
  • Posts: 682
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #78 on: June 07, 2009, 11:16:55 PM »
Thank you rejetto.

All ideas to improve speed and size are welcome  :).
Specially, as my macro-modules grow and grow. My templates seems not to be html with macro, but will end up being macro-scripts with some html. ;D

Also it's a good idea to use static vars for the lists - but my macro-scripts came from pre-static time  :).
your computer has no brain - use your own !

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #79 on: June 08, 2009, 10:58:24 AM »
i don't suggest using them for this purpose.
i justified the fact i used them.

Offline bacter

  • Operator
  • Tireless poster
  • *****
  • Posts: 682
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #80 on: June 08, 2009, 11:51:12 AM »
Rejetto,

I understood that you used static vars only because you used 'run script', but as there may be more uses for this lists, it would be enough to build the list only when hfs starts and if users are added ore removed, so static var seems not to be a bad idea.

By the way, as i don't know the delphi-compiler, i would like to know if there is a any size limit for a single or list variable, as i project to load some huge files (several Mbytes) y want to process. If there are no limits, y will try to do all processes with macros, otherwise y would use the output of C or tcl programs started with {.exec.}.   
your computer has no brain - use your own !

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #81 on: June 08, 2009, 12:11:40 PM »
no limits i know.
would you have speed problems, let me know.

Offline r][m

  • Tireless poster
  • ****
  • Posts: 347
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #82 on: June 08, 2009, 04:36:33 PM »
WOW....indeed !
Bacter, thanks for sharing. I'll give your code a try,
although I must confess I'd hoped for something
much simpler.  :)

Offline DjNelutzu

  • Occasional poster
  • *
  • Posts: 24
    • View Profile
Re: Admin Panel : Creating a proper admin panel.
« Reply #83 on: August 22, 2010, 11:18:00 AM »
and the final code would be all that is needed for administrators panel?