ℹ️
Welcome to the archive of the old FlatPress support forum. Browse more than a decade of FlatPress wisdom! Login is disabled.

The current FlatPress support forum is available here: forum.flatpress.org
Multiple Administrators
  • Flatpress defaults to a single administrator who's name is added to new entries and static pages. With only one administrator, this is more a nuisance than helpful. Adding additional administrators is cumbersome. The lock file has to be deleted for each new administrator and Flatpress installs a fresh set of default files. Can you suggest a way to streamline this process for sites that add and remove administrators on a regular basis? Also, is there a convenient way to restrict access to certain functions to all but the "primary" administrator. Is there any sort of hierarchy built in other than logged in and not logged in?
  • No there isn't. Flatpress is for one user only. You can add users with set up or you can create an admin panel to registrate users with this function: user_add(array( 'userid' => 'Username', 'password' => 'Password', 'www' => 'http://website', 'email' => 'email@address.tld', ));
  • oonet said: Can you suggest a way to streamline this process for sites that add and remove administrators on a regular basis?

    there is an API for doing that in core.users.php
    oonet said: Also, is there a convenient way to restrict access to certain functions to all but the "primary" administrator. Is there any sort of hierarchy built in other than logged in and not logged in?

    not at the moment
  • pierovdfn said: Flatpress is for one user only.

    New entries (and static pages) include the name of the author. With only one administrator, wouldn't this always be the same thing?
    pierovdfn said: You can add users with set up or you can create an admin panel to registrate users with this function

    It sounds like you have something specific in mind for creating admin panels. How would you suggest I do this? I'm not sure what you mean by an "admin panel."
    NoWhereMan said: there is an API for doing that in core.users.php

  • Yes, I see it. This appears to be the function used by the new admin panel suggested by pierovdfn?
  • oonet said: New entries (and static pages) include the name of the author. With only one administrator, wouldn't this always be the same thing?

    Yes, but this is because you can use templates in different sites.
    oonet said: It sounds like you have something specific in mind for creating admin panels. How would you suggest I do this? I'm not sure what you mean by an "admin panel."

    For example Plugins -> BBCode (see fp-plugins/bbcode/panels/admin.plugin.panel.bbcode.php).
    oonet said: Yes, I see it. This appears to be the function used by the new admin panel suggested by pierovdfn?

    Yes, it is. user_add is declared in core.users.php...
  • pierovdfn said: Yes, but this is because you can use templates in different sites.

    Yes, this is why the template takes the author from a variable. However, on a particular site, the author of everything would always be the same. So it makes sense to suppress the author (remove it from the template) - or not bother having one at all. Is this true, or do you see a use for it that I am missing?
    pierovdfn said: see fp-plugins/bbcode/panels/admin.plugin.panel.bbcode.php

    Yes, I see it. It's not immediately obvious to me what this is doing. Or how it should be used to create multiple administrators more easily.
  • If you make a template for just a site you can write your name instead of $author... However it's a placeholder for the future... Maybe at the beginning Flatpress was for just one user but NoWhereMan thought about a multi user for the future. For the file I suggested you to see: it's the file that creates the BBCode admin panel (Administration Panel -> Plugins -> BBCode on the submenu). Flatpress Admin Panels uses a MVC pattern: this file is the model (setup function and some variables of the class) and the controller (onsubmit for the submit button). The view is the file on tpls. With the same structure you can create an admin panel for users (for example Maintentance -> Users...). Do you know PHP?
  • pierovdfn said: If you make a template for just a site you can write your name instead of $author...
    However it's a placeholder for the future...

    Makes sense. What I found puzzling was that all the themes carefully display the author of each article, even though it is always the same. I would have thought that some of them wouldn't bother.
    pierovdfn said: With the same structure you can create an admin panel for users (for example Maintentance -> Users...).

    I think I understand what you are saying now. I was trying to figure out how the half dozen lines you listed could somehow add a new administrator. You set up the variables, but then, it seems, something has to be done with them. It appears that admin.plugin.panel.bbcode.php is the same as the qspam plugin, plugin.qspam.php. You were suggesting I look at it for an example of how to write a plugin? The difficulty is knowing what variables and functions to use. Not a huge problem, in this case, as there's the setup.php program to work from. I want to create a copy of the script that does nothing but add a new user. I'd like to do this without spending hours reading through all the files in the setup folder. . . . :-)
  • This is the structure of an admin panel, in this case called foo. if(class_exists('AdminPanelAction')) { /** * This class is the class of the panel. */ class admin_plugin_foo extends AdminPanelAction { /** * Every panel has a language file. * With this variable you say to FP System where he * has to search your language file. */ var $langres='plugin:foo'; /** * Here's the list of "commands" you can do in this * panel. * * Here's an example: you can edit, or delete */ var $commands=array('edit', 'delete'); /** * This function is called when the panel is loaded. * Here you can declare vars etc etc. * * You must declare but it can also do nothing. */ function setup() { # We say to Smarty where's the TPL File of the panel. # This file manages HTML of the panel $this->smarty->assign('admin_resource', 'plugin:foo/admin.plugin.foo'); // It means fp-plugins/foo/tpls/admin.plugin.foo.tpl } /** * This function manages the edit command. * Every command must have a param, $id in this case. * * @param string $id: An ID (just for example) * @return integer: (I'll explain later) */ function doedit($id) { } /** * This function manages the delete command. * It's like the edit one. * * @param string $id: An ID (just for example) * @return integer: (I'll explain later) */ function doedit($id) { } /** * This is the main function of the panel. * It's always called. * Here you do all you want. * * @return void */ function main() { # Here you play } /** * This method is called when a post data is submitted. * * @return integer: (I'll explain later) */ function onsubmit() { # Here you play // If it's all ok $this->smarty->assign('success', 1); // Otherwise, if there's an error: $this->smarty->assign('success', -1); } } /** * With this function you add the panel "foo" to the * main panel "plugin". * * You could also add to entry or configuration, modifying * the first param of the function. */ admin_addpanelaction('plugin', 'foo', true); } doedit, dodelete, onsubmit and all other command functions can return 0, 1 and 2. With 0 no redirects are done, with 1 you're redirect to default action of the panel and with 2 you're redirect to the current panel.
  • This helps - thank you :-) A couple of questions. Delete and edit both declare the same function doedit()? What FP functions can be called by plugins? What FP variables are available?
  • No, I've made copy&paste but I haven't changed function name ;) Sorry Delete is dodelete All parts of flatpress can be called by plugins and all its variable. There isn't any sandbox or similar.
  • pierovdfn said: No, I've made copy&paste but I haven't changed function name ;) Sorry
    Delete is dodelete

    Okay, that makes sense :-) So doedit() and dodelete() are called when the admin hits the edit or delete links on an entry or comment? If so, are the run before, after or instead of the default edit and delete procedures?
    pierovdfn said: All parts of flatpress can be called by plugins and all its variable.

    Good. What are the names of these functions and variables, and what do they do?
  • oonet said: So doedit() and dodelete() are called when the admin hits the edit or delete links on an entry or comment? If so, are the run before, after or instead of the default edit and delete procedures?

    They're just names. You can add to $command the item 'fprocks' and handle with dofprocks.
    oonet said: Good. What are the names of these functions and variables, and what do they do?

    They're too much...
  • pierovdfn said: They're just names. You can add to $command the item 'fprocks' and handle with dofprocks.

    So doedit() and dodelete() aren't called by FP, but are suggested names that could as easily be fprocs() or anything else you define in $command? Okay, so what causes these functions to execute?
    pierovdfn said: They're too much...

    I assume you know what they are, though, in order to write new plugins? So how do you figure it out? By reading through the source and making a list of functions and variables by hand? I'm hoping for something less time-consuming :-)
  • oonet said: So how do you figure it out? By reading through the source and making a list of functions and variables by hand?

    This is the way :)
  • pierovdfn said: This is the way :)

    Ouch!
  • This discussion has been closed.
    All Discussions
    Start a New Discussion

    Howdy, Stranger!

    It looks like you're new here. If you want to get involved, click one of these buttons!

    Categories

    In this Discussion