Latest build bug

edited March 2013 in Bug Reports
I just updated to the latest build and found that I can't access my advanced module in the CMS. Not sure what happened though. :(
Once I changed back to the previous build I had it worked again, unfortunately the update I was looking for won't work until I can get the new build.

Just an FYI.

Thanks.
«1

Comments

  • edited March 2013
    I've also noticed that in form_builder, 'type' => 'text' give you a 'textfield' instead of text input.
    'type' => 'textarea' shows as it should.
    What 'type' is supposed to give you a standard input?

    I'm seeing the same thing with 'type' => 'file' which shows up as 'type' => 'asset'.
    'type' => 'asset' shows as it should.
    kinda odd?
  • edited March 2013
    What specifically do you mean by you can't access the advanced module? Is it a permission issue, or do you get a 404 error / PHP error, or is it something else?

    With regards to the form fields, 'type' => 'text' has a "representative" assigned to it to show the textarea. This is mainly because of the field type "text" in MySQL and realize it may be a little confusing. If you want a text field, just leave the "type" attribute blank.

    Also, if you are seeing an asset upload instead of "file" field type, it probably is because you have "image" or "img" in your field name. To get around this, you can add the parameter to your field of "ignore_representative" => TRUE.
  • edited 11:34PM
    The message I get when going to one of my advanced modules is:
    An Error Was Encountered<br /> You are missing the module membership.

    But the user_guide module still works fine. Just my user created one.

    Thanks for the tips on those form fields. I'll give that a try! :D
  • edited March 2013
    That error is thrown in the fuel/modules/fuel/controllers/module.php constructor which is used by any simple module (line 50). It's triggered when it can't find the module name based on the uri segments. A few questions:

    1. What is the URI giving you that error?
    2. Is the name of the advanced module "membership" that exists in the folder "fuel/modules/membership"?
    3. Does this advanced module have a model of "membership" (fuel/modules/membership/models/membership_model.php) and is associated with a simple module (sub module) in the simple module config (fuel/modules/membership/config/membership_fuel_modules.php)?
  • edited 11:34PM
    1) /fuel/membership/members
    2) yes
    3) there is no membership_model.php in /fuel/modules/membership/models/ just the models that are routed: members_model.php and groups_model.php.

    What would go in the membership_model.php file since I don't access it directly?
  • edited March 2013
    For #3, that's fine. Do you have "members" added to the fuel/modules/membership/config/membership_fuel_modules.php file?
  • edited March 2013
    my fuel/modules/membership/config/membership_modules.php:
    $config['modules']['members'] = array( 'model_location' => 'membership', 'module_name' => 'Members', 'module_uri' => 'membership/members', 'model_name' => 'members_model', 'nav_selected' => 'membership/members', ); $config['modules']['groups'] = array( 'model_location' => 'membership', 'module_name' => 'Member Groups', 'module_uri' => 'membership/groups', 'model_name' => 'groups_model', 'nav_selected' => 'membership/groups', );

    I don't have a fuel/modules/membership/config/membership_fuel_modules.php
  • edited 11:34PM
    Great... Thanks for the info. I found the issue and have posted a fix.
  • edited 11:34PM
    Yep, that appears to have been it :)
    Thanks.
  • edited March 2013
    Here's 2. Not sure about the second one, but it seems incorrect, so thought I'd include it, plus my workaround in the meantime:
    • So, now that that's out of the way, I went to make sure that a new Fuel user could access all the modules appropriately.

      When I logged in as the new user with proper permissions he was able to access the added simple modules but wasn't able to click/edit any of the rows.

      As for the advanced modules, even though proper permissions were given, he wasn't able to even see those in the list.

      This is probably not related to your update Sunday as today was the first time I've had to use that user in a couple weeks. I even updated with the latest update today which was 5 hours old, but no change.

      I made him SuperAdmin for now, but figured you should be aware.
    • The second one has to do with counting records through the model. ie:$reviews = $CI->reviews_model->find_all($where_clause, 'date_created desc', $limit , $this->input->get('per_page') , 'object'); $record_count = $CI->reviews_model->record_count($where_clause);
      This failed when I had _common_query set to include 2 joins as it wasn't able to include the 2 model's data in the SELECT string and came back with the following error: A Database Error Occurred Error Number: 1054 Unknown column 'restaurants.name' in 'where clause' SELECT * FROM (`testimonials`) WHERE `published` = 'yes' AND `restaurants`.`name` = 'Joe\'s Sandwich Shop' Filename: /home/eng51dev/public_html/restautrade/fuel/modules/fuel/core/MY_Model.php Line Number: 1368
      So, all I did to get around it was a 2nd regular find_all($where_clause) which worked fine.
  • edited March 2013
    I think the first error has to do with the multiple permissions needed for simple modules now. If you look in the permissions module you'll see that they have a create, edit, delete, publish and export permission in some cases for simple modules. There is a command line utility to generate these for you:
    php index.php fuel/generate/simple my_simple_module_name

    For number 2, _common_query is only used for "find_" methods on the model. To use it with record_count, just call _common_query right before it:
    $reviews = $CI->reviews_model->find_all($where_clause, 'date_created desc', $limit , $this->input->get('per_page') , 'object'); $CI->reviews_model->_common_query(); $record_count = $CI->reviews_model->record_count($where_clause);
  • edited March 2013
    #1) So, the only change I "Really" needed to make was when creating permissions for a model to add the following manually after adding the model name:
    • Model: Edit (model/edit)
    • Model: Publish (model/publish)
    • Model: Delete (model/delete)
    • Model: Create (model/create)
    So cool. Too bad when adding a model in the permission section (when not using the command line utility) it couldn't automatically create those, or at least give the option. Just wishful thinking of course :)

    #2) I hadn't realized this. But makes sense and helps me work out a problem I was having too.
  • edited 11:34PM
    So, out of curiosity, what does the advanced module generator do for permissions? I can't figure it out.

    I have my advanced module created already, just need to allow it to be added to a user.

    I noticed when I tried to add the User_manual module to a user I had the same thing happen. But when I used the script to add an advanced module, the permissions were setup correctly.
  • edited 11:34PM
    When you generate an advanced module (e.g. fuel/generate/advanced my_adv_module), it will create a single permission based on the advanced module's name. When you generate a simple module, it will by default generate the other create, edit, publish and delete permissions associated with a simple module (e.g. fuel/generate/simple my_simple_module).

    Also, we've thought about having that auto-generation of those other permissions as well.
  • edited 11:34PM
    So, with my advanced module I was able to get it to show up for the new user on the left nav, but when he clicks on it, it gets the following error:

    An Error Was Encountered You do not have access to this page.
    I changed the permissions as such:
    • Membership (membership)
    • Users (membershp/users)
    • Users: Edit (membership/users/edit)
    etc.

    Still missing something though.

    The advanced module is called Membership with a Users model in the models folder. They are accessible as super admin.
  • edited 11:34PM
    Can you debug the Fuel_admin::validate_user method to see what the name and type permission are being passed in the fuel->auth->has_permission call when accessing that page?
  • edited 11:34PM
    I added
    Fuel_admin::validate_user('membership/members','edit',TRUE);die();
    to my members_model construct. And received no messages at all (for admin and my user).

    Then I added echo 'test';exit(); to Fuel_admin method validate_user() right after the opening of the method. This returned: test to my screen. If I put it within the first if: it returned nothing. This leads me to believe both users have access to model.

    I revoked edit,publish,create,delete access from the user leaving access to members within membership only. There were still no messages, even when testing for 'edit' access. If I removed members from the list, that model isn't visible in the left nav.

    What should I test next?
  • edited 11:34PM
    Actually, what I meant was to exit from within the validate_user method to see what is getting passed to it.
  • edited 11:34PM
    Okay, I just added exit(); at the exit of validate_user without calling it explicitly from members_module. No change, no error message, only the standard error message.
  • edited 11:34PM
    How about at the beginning of the method:
    function validate_user($permission, $type = 'edit', $show_error = TRUE) { echo '<pre>'; print_r($permission); print_r($type); echo '</pre>'; exit(); if (!$this->fuel->auth->has_permission($permission, $type)) { if ($show_error) { show_error(lang('error_no_access')); } else { exit(); } } }
  • edited 11:34PM
    Nothing. It doesn't even touch that method for admin or user.
  • edited 11:34PM
    OK. How about trying the same with the Fuel_auth->has_permission method?
  • edited 11:34PM
    I received the following response which looks like it's for $permission:
    Array ( [0] => members [1] => create [2] => edit [3] => publish [4] => delete [5] => export )

    This was for both admin and user.
  • edited 11:34PM
    I think you are wanting something similar to the blog modules setup. I believe the permissions that you are wanting are:
    members members/create members/edit members/publish members/delete members/export groups groups/create groups/edit groups/publish groups/delete groups/export

    BTW, we've added the ability to generate those other permissions when creating a permission (not on edit).
  • edited 11:34PM
    Okay, I installed the Blog module, tested it and it works as expected.

    I then adjusted my Membership module to match in the config/membership.php and the database/permissions sections, but I'm still missing something.

    I don't understand where the issue is as it looks correct.

    With the setup as you just posted my membership module doesn't even show up for my user (of course it shows for my admin though). It used to show when membership/ was added to the front of each item though.
  • edited 11:34PM
    What are the routes being used for the modules?
  • edited 11:34PM
    my membership_routes.php file has:
    <?php $route[FUEL_ROUTE.'membership'] = 'membership'; $membership_controllers = array('members', 'groups'); foreach($membership_controllers as $c) { $route[FUEL_ROUTE.$route[FUEL_ROUTE.'membership'].'/'.$c] = FUEL_FOLDER.'/module'; $route[FUEL_ROUTE.$route[FUEL_ROUTE.'membership'].'/'.$c.'/(.*)'] = FUEL_FOLDER.'/module/$1'; }</code
  • edited 11:34PM
    You mind sending me a zip file of your module to test out (can be paired down and you can leave any sensitive code out). My email address can be found under my admin profile.
  • edited 11:34PM
    Sent, thanks.
  • edited 11:34PM
    So, apparently in an advanced module the module_fuel_modules.php file needs to have the 'permission' setting set for each nav item.
    ie:
    $config['modules']['members'] = array( 'model_location' => 'membership', 'module_name' => 'Members', 'module_uri' => 'membership/members', 'model_name' => 'members_model', 'nav_selected' => 'membership/members', 'permission' => 'members' );
    Then the permissions can be set simply as admin stated 5 posts up.
    So simple :)
Sign In or Register to comment.