Blog Authors vs FUEL Users

edited September 2015 in Modules
Hey all,

I've been looking at the blog module and it looks really nice. Although, I'd like to let other authors contribute on my blog so they are able to log in, create posts, verify comments on their posts, and edit only their posts. I think I'll manage to do this with Fuel with a bit of work, but I'm wondering what is the difference between authors and users? It seems that I can't let authors log in, only users. So what should I be looking at to make this possible? (if it is possible)

Best,
Aaron

Comments

  • edited 8:37PM
    The FUEL blog requires an author to have access to the admin area which means they need to be a FUEL user with the appropriate blog permissions. Then under the Blot Authors area, you associate that FUEL user to that blog author.

    There is a develop branch to the Blog that has a bunch of changes that you may want to look at and includes a "limit_to_user" option that allows you to limit the authors to see only the posts they want.
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module/tree/develop
  • edited September 2015
    Ah okay, nice! I can follow that, although I didn't notice the "User" field before, and imo it seems a bit more powerful to have Users and assign Authors to them anyway (so you can have some Authors with Users with access to certain Authors and also no access to other parts of the admin area).

    I found `_limit_to_user()` in the Base_module_model class. Is this what you meant? I would guess I am going to be editing list_items() or adding the $limit_to_user_field variable in the Blog_posts_model at fuel/modules/blog/models/blog_posts_model.php (If so, do you perhaps have an example or docs covering this? Just not quite sure where to go from here).

    Thanks!
  • edited 8:37PM
    The Base_module_model::limit_to_user property is meant to limit the records to the author. To avoid needing to modify the Base_module_model::limit_to_user property, there is a limit_to_user value that can be set in the blog config. If you pull from the develop branch for Blog, you can copy the fuel/modules/blog/config/blog.php to fuel/application/config/blog.php and modify the limit_to_user value by setting it to TRUE.
  • edited September 2015
    Oh excuse me, I thought you were talking about the Fuel repo and I was already on the develop branch for that. I've switched over to the blog module branch develop although I've ran into something.

    With settings > blog > limit to user selected, and fuel/modules/blog/config/blog.php copied over to fuel/application/config/blog.php, I'm not able to create a new post or view previously published posts when using a non super admin account. I get:
    A Database Error Occurred` Error Number: 1066 Not unique table/alias: 'fuel_users' SELECT fuel_blog_posts.*, fuel_blog_users.display_name, CONCAT(fuel_users.first_name, " ", fuel_users.last_name) as author_name, YEAR(fuel_blog_posts.publish_date) as year, DATE_FORMAT(fuel_blog_posts.publish_date, "%m") as month, DATE_FORMAT(fuel_blog_posts.publish_date, "%d") as day FROM (`fuel_blog_posts`) LEFT JOIN `fuel_users` ON `fuel_users`.`id` = `author_id` LEFT JOIN `fuel_categories` ON `fuel_categories`.`id` = `fuel_blog_posts`.`category_id` LEFT JOIN `fuel_relationships` ON `fuel_relationships`.`candidate_key` = `fuel_blog_posts`.`id` AND fuel_relationships.candidate_table = "fuel_blog_posts" AND fuel_relationships.foreign_table = "fuel_tags" LEFT JOIN `fuel_blog_users` ON `fuel_blog_users`.`fuel_user_id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_users` ON `fuel_users`.`id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_tags` ON `fuel_tags`.`id` = `fuel_relationships`.`foreign_key` WHERE `fuel_blog_posts`.`slug` = 'test' AND `fuel_users`.`id` = 3 GROUP BY `fuel_blog_posts`.`id` LIMIT 1 Filename: /fuel/modules/fuel/core/MY_Model.php Line Number: 477

    Although this is successful with a super-admin OR by turning off the 'limit to user' option. Anything else I should be looking out for?
  • edited 8:37PM
    Thanks for the report. I've posted a fix in the develop branch of the blog for that SQL issue.
  • edited September 2015
    Hey,

    Thanks for the quick update! I'm still getting a bit of an issue though. I now get this when creating a new blog post as a super-admin:

    A Database Error Occurred Error Number: 1054 Unknown column 'fuel_users.first_name' in 'field list' SELECT fuel_blog_posts.*, fuel_blog_users.display_name, CONCAT(fuel_users.first_name, " ", fuel_users.last_name) as author_name, YEAR(fuel_blog_posts.publish_date) as year, DATE_FORMAT(fuel_blog_posts.publish_date, "%m") as month, DATE_FORMAT(fuel_blog_posts.publish_date, "%d") as day FROM (`fuel_blog_posts`) LEFT JOIN `fuel_categories` ON `fuel_categories`.`id` = `fuel_blog_posts`.`category_id` LEFT JOIN `fuel_relationships` ON `fuel_relationships`.`candidate_key` = `fuel_blog_posts`.`id` AND fuel_relationships.candidate_table = "fuel_blog_posts" AND fuel_relationships.foreign_table = "fuel_tags" LEFT JOIN `fuel_blog_users` ON `fuel_blog_users`.`fuel_user_id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_tags` ON `fuel_tags`.`id` = `fuel_relationships`.`foreign_key` WHERE `fuel_blog_posts`.`slug` = 'admin-test' GROUP BY `fuel_blog_posts`.`id` LIMIT 1 Filename: /Users/aaronharding/Sites/devisionarissen.nl/fuel/modules/fuel/core/MY_Model.php Line Number: 477

    and creating a blog post as a normal user just refreshes the page, even though the post was successful. I also can't see posts made by this normal user when visiting the /blog/posts views, I can only see those posts as the super-admin.

    I ran these commands to update, and the pull was successful.

    cd fuel/modules/blog git pull
  • edited 8:37PM
    There looks to be a conflict with how the base_module_model and the blog_posts_model are joining the fuel_users table. I've posted a fix to both the develop branches of FUEL and the Blog which should help. Basically the limit_to_user table join on the base_module_model is now aliased so it doesn't conflict.
  • edited 8:37PM
    Oh great, thanks! I'm up to date on develop in both fuel and blog, and the error has gone and I can now successfully post as a super admin. Although posting as a regular user I see no posts at all when on the /blog/posts view, it just says "No data to display". Qhen I go to create a new post as a regular user, the form just refreshes onto itself with no success message even though I can see the entry appear in the database and also in the /blog/posts view logged in as a super admin.

    So,

    1) Can't see *any* blog posts as a non super-admin, it just displays "No data to display"
    2) Can't post as a non super-admin, the page just refreshes

    Is this something I've done?

    Appreciate all your help so far,
  • edited 8:37PM
    Did you run all the SQL updates for the blog in the fuel/modules/blog/install/ folder?
  • edited 8:37PM
    Oh, I didn't realise the SQL updates were different. I switched branches on the blog submodule, and didn't run through those updates.

    ran the uninstall.sql from the master branch, then ran both install sql files from https://github.com/daylightstudio/FUEL-CMS-Blog-Module/tree/develop/install

    Now it's working! Thanks for the help.

    :)
Sign In or Register to comment.