Support » Plugin: Dynamic Time » Category – better functionality

  • Resolved jambo90210

    (@jambo90210)


    We have an existing Timesheet solution on our Joomla website, but now moving to WordPress and have bought your plugin, however there are 2 things that would be good enhancements

    1) Restrict Categories by User, ie user only has access to certain Categories

    2) Display the Categories on the timesheet entry or provide a “hover tip” so user can see what Categories they have entered without having to click into the record.

    Interested in your thoughts.

    Also reading the other comments, it sounded like it would be possible to have the admin functionality on the main webpage (front end) currently only seem to be able to do via backend ?

    Thanks

    Jamie

    • This topic was modified 3 months, 2 weeks ago by jambo90210.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Rhett

    (@rermis)

    Hi Jamie,
    Thank you for your feedback. Yes, displaying categories on hover I agree is an excellent recommendation. Even though categories are available to be seen in the PRO version report level, this makes sense to also make more accessible on the timecard itself. I’ll add this to potential future improvements.

    Category restriction is a less requested feature, and more difficult to implement, but I will make note of your request.

    Admin functionality is purposely isolated to the admin view, since the plugin admin page contains plugin level settings and configuration options for the plugin, it cannot be accessible through itself e.g. a shortcode. However, supervisors can access their assigned employees via the link in the email for quick tasks such as resubmission or approval. Hope this helps!

    Thread Starter jambo90210

    (@jambo90210)

    ok, thanks, understand the Admin part.

    The filtering like I said was a nice feature of the Joomla timesheet, made it easier for the employee’s to pick and also avoids mistakes by picking something they should not.

    Thanks for the reply.

    Plugin Author Rhett

    (@rermis)

    Hi @jambo90210,
    Do you have a custom theme? If so, would you be open to setting dropdown category permissions in code with a brief script? You would potentially be able to manually set permissions on dropdown menu items in a future release. Just checking to see if you are open to that.

    Thread Starter jambo90210

    (@jambo90210)

    Hi Rhett, that sounds like a plan, we have a custom theme which allows custom CSS and Javascripts to be added.
    Great idea. Thanks

    Plugin Author Rhett

    (@rermis)

    Hi Jamie,
    You may now hide or show categories with the following function defined in your custom theme’s functions.php file. This may not be perfect. Default roles are present, and category placeholders can be changed to be specific to your categories.

    
    function dyt_user_cat($c,$userid){
      $c=sanitize_text_field($c);
      $user=get_userdata($userid);
      $roles=implode(',',$user->roles);
    
      if(stripos('|'.'|Admin Category|'.'|',"|$c|")!==false && stripos($roles,'Administrator')===false) return 1; // Hide admin category from all non-Admins
      if(stripos('|'.'|Editor Category|Test Category|'.'|',"|$c|")!==false && stripos($roles,'Editor')===false) return 1; // Hide these categories from all non-Editors
      
      if(stripos('|'.'|Reader Category|'.'|',"|$c|")!==false && stripos($roles,'Editor')!==false) return 1; // Hide these categories from all Editors
      if(stripos('|'.'|Reader Category|'.'|',"|$c|")!==false && stripos($roles,'Administrator')!==false) return 1; // Hide these categories from all Admins
      if(stripos('|'.'|Editor Category|'.'|',"|$c|")!==false && stripos($roles,'Reader')!==false) return 1; // Hide these categories from all Readers
      return 0; // Default show category
    }
    Thread Starter jambo90210

    (@jambo90210)

    Hi Rhett,

    the logic is not really role based it’s person by person, so not sure they will really work, however it did get me thinking..

    Looking at the userdata the description field (bio?), and perhaps that’s an easy way to do it person by person.

    ie

    populate the bio with each of the valid categories for that person.

    then in the function something like this?

    function dyt_user_cat($c,$userid){
    $c=sanitize_text_field($c);
    $user=get_userdata($userid);
    $valid_categories=$user->description);

    if(stripos($valid_categories, $c) == false return 1; // Hide Category

    return 0; // Default show category
    }`

    In the Bio field you would have each valid category as below, not sure if there is a better way of using the stripos as there would be a “new line” as a delimiter or perhaps, I use the pipes “|” as you have in the description .. not sure how the newlines are represented within PHP/wordpress field

    What’s your thoughts?

    CPM-SAP MII Breakfix Support
    CPM-SAP MII Support 2021
    JAFS-RB
    IW-MII-BA

    or

    CPM-SAP MII Breakfix Support|CPM-SAP MII Support 2021|JAFS-RB|IW-MII-BA

    Plugin Author Rhett

    (@rermis)

    Sure, that’s a great solution. It seems it might be tedious from a maintenance standpoint, but it’s perfectly doable and they can be broken up with newlines. I’ll take a look at this the next few days, it may take one more release to implement.

    Plugin Author Rhett

    (@rermis)

    The following function is compatible with v3.8.14 and will pull in line items from the user bio as categories.

    function dyt_user_cat($userid) {
      $cats=get_user_meta($userid,'description',true);
      if(!empty($cats)) return preg_split('/\R/',$cats);
    }

    Hope this helps!

    Thread Starter jambo90210

    (@jambo90210)

    Thanks Rhett, yes it’s tedious but that’s the requirement, there are too many people and differences to use the roles.

    I will give it a bash over the weekend.

    For reference this is the plugin I used with Joomla, it’s feature rich and might give you some good ideas on future possible enhancements.

    https://timeworked4joomla.com/

    You can experience the plugin by logging in also, the passwords for an employee and admin are in the top right.

    Thread Starter jambo90210

    (@jambo90210)

    Hi not sure where I went wrong.. it’s working in the sense there are no categories so it’s calling the function, but I have maintain 2 of the codes in the BIO… Guessing something silly? Thanks

    function dyt_user_cat($c,$userid){
      $c=sanitize_text_field($c);
      $valid_categories=dyt_get_valid_cats($userid);
    //return 0;
    
      if(stripos($valid_categories, $c, 0) == false) return 1; // Hide Category
    
      return 0; // Default show category
    }
    
    function dyt_get_valid_cats($userid){
      $valid_categories=get_user_meta($userid,'description',true);
      if(!empty($cats)) return preg_split('/\R/',$cats);
    }
    
    Thread Starter jambo90210

    (@jambo90210)

    saw one silly mistake.. fixed it, but still no go :-/ variable shoudl of been $cats

    function dyt_user_cat($c,$userid){
      $c=sanitize_text_field($c);
      $valid_categories=dyt_get_valid_cats($userid);
    //return 0;
    
      if(stripos($valid_categories, $c, 0) == false) return 1; // Hide Category
    
      return 0; // Default show category
    }
    
    function dyt_get_valid_cats($userid){
      $cats=get_user_meta($userid,'description',true);
      if(!empty($cats)) return preg_split('/\R/',$cats);
    }
    
    
    Thread Starter jambo90210

    (@jambo90210)

    nailed it.. did not realise the preg_split built an array.. That’s the trouble with not doing this stuff often.. Also found zero returns for the first one which was drama also as that’s “false” so had to deal with that with the &&

    function dyt_user_cat($c,$userid){
      $cat=sanitize_text_field($c);
      $valid_categories=dyt_get_valid_cats($userid);
      
      if( ( array_search($cat, $valid_categories) !== FALSE && ($valid_categories) ) ) return 0; // Keep Category
    
      return 1; // Default hide category
    }
    
    function dyt_get_valid_cats($userid){
      $cats=get_user_meta($userid,'description',true);
      if(!empty($cats)) return preg_split('/\R/',$cats);
    }
    
    Plugin Author Rhett

    (@rermis)

    Awesome, let me know if there’s anything else I can help with!

    Thread Starter jambo90210

    (@jambo90210)

    Hi Rhett, For reference this is the plugin I used with Joomla, it’s feature rich and might give you some good ideas on future possible enhancements, it covers a fews of the requests you have already had, around projects, clients, reporting etc.

    https://timeworked4joomla.com/

    You can experience the plugin by logging in also, the passwords for an employee and admin are in the top right.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.