Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
Filtering by User - Almost there...

 
Post new topic   Reply to topic     Forum Index -> Hacking Thyme
View previous topic :: View next topic  
Author Message
kingb



Joined: 15 May 2008
Posts: 4

PostPosted: Fri May 16, 2008 1:42 pm    Post subject: Filtering by User - Almost there... Reply with quote

Hi

I've added additional event fields for 'coach' and "assistants1-5" and have created a drop-down that ties into the user table so that I can populate these fields with user id numbers. This way I can assign several (up to six) people to each event.

What I'd like to do now is edit the main event query so that (except admin) when people login they will only see events which they are a assigned to. Does anyone know where the main event queries live or are they part of the encoded files?

Thanks in advance.

PS: once I'm finished, I'll happily make available any code that I've modified -of if someone wants to check it out now, pm me.

Kevin
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Fri May 16, 2008 3:06 pm    Post subject: Reply with quote

Hi,

I've updated Thyme's code to include support for a $_cal_user->filter string. Make sure you are up to date in Admin -> Installer -> Updates. Specifically include/classes/class.event_matrix.php.

You can then modify include/classes/class.user.php at line 178 to do something like this:

Code:

if(!$this->admin) {
   $this->filter = "field1 = {$this->id} or field2 = {$this->id}";
}


Let me know if you have any questions / trouble.
Back to top
View user's profile Send private message Visit poster's website
kingb



Joined: 15 May 2008
Posts: 4

PostPosted: Fri May 16, 2008 6:30 pm    Post subject: Reply with quote

Ian - WOW - Most excellent support!!! Works like a charm.

Plus, I think we've created a very useful hack that can allow admins to control access to events on a very granular level.

I'll post my hacks shortly to db and template files shortly....
Back to top
View user's profile Send private message
kingb



Joined: 15 May 2008
Posts: 4

PostPosted: Sat May 31, 2008 2:25 am    Post subject: Reply with quote

As promised, here's my hacks. The goal of this exercise is to allow you to limit access to individual events to several users (up to 6 in this example). This process will add a new tab to the edit event view and add a new section while viewing events. Further, the tab in the edit view will have a pull-down menu which will a read from the built in user table and allow you to assign a user(s) to the event. You may need to tweak some code to taste for your individual needs. Enjoy!!!

Kevin

In "event_view_tpl.php" add a new section
Code:
   
   #############################
   #
   ## Coaches and Assistant
   #
   #############################

   if (($_cal_event->coach != "") &&
         ($_cal_event->assistant01 != "") &&
      ($_cal_event->assistant02 != "") &&
      ($_cal_event->assistant03 != "") &&
      ($_cal_event->assistant04 != "") &&
      ($_cal_event->assistant05 != ""))
   {

      function get_coach($cid) {
            $query_coach = "SELECT name FROM thyme_Users WHERE id = '$cid'";
            $coach = mysql_query($query_coach) or die(mysql_error());
            $row_coach = mysql_fetch_assoc($coach);
            return $row_coach['name'];
      }
      $_cal_tmpl->new_section("Coaches");
        $_cal_tmpl->row_header_width = 1;
      
         if ($_cal_event->coach != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->coach));
         if ($_cal_event->assistant01 != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->assistant01));
         if ($_cal_event->assistant02 != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->assistant02));
         if ($_cal_event->assistant03 != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->assistant03));
         if ($_cal_event->assistant04 != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->assistant04));
         if ($_cal_event->assistant05 != '0') $_cal_tmpl->section_row("  Coach", get_coach($_cal_event->assistant05));
      
      $_cal_tmpl->end_section();
   }


in the "event_edit_tpl.php" file add a new tab
Code:

   ##########################
   #
   ### Coaches
   #
   #########################################

   $_cal_tmpl->new_section('Coaches');

         $_cal_tmpl->section_spacer();

   $query_user = "SELECT id, name, access_lvl FROM thyme_Users ORDER BY name";
   $user = mysql_query($query_user) or die(mysql_error());
   $row_user = mysql_fetch_assoc($user);
   while ($row_user = mysql_fetch_assoc($user))
      {
        if (($row_user['id'] != '1') && ($row_user['access_lvl'] != '2')) {
         $users[$row_user['id']] = $row_user['name'];
        }
      }
   
      $_cal_tmpl->section_row("Coach 1", $_cal_form->select("coach", array('('._NONE_.')') + $users));

      $_cal_tmpl->section_row("Coach 2", $_cal_form->select("assistant01", array('('._NONE_.')') + $users));
      $_cal_tmpl->section_row("Coach 3", $_cal_form->select("assistant02", array('('._NONE_.')') + $users));
      $_cal_tmpl->section_row("Coach 4", $_cal_form->select("assistant03", array('('._NONE_.')') + $users));
      $_cal_tmpl->section_row("Coach 5", $_cal_form->select("assistant04", array('('._NONE_.')') + $users));
      $_cal_tmpl->section_row("Coach 6", $_cal_form->select("assistant05", array('('._NONE_.')') + $users));

      $_cal_tmpl->section_row("", ' ');

   
    $_cal_tmpl->end_section();


Add the filter to the "class.user.php" file around line 178
Code:

   if(!$this->admin) {
      $this->filter = "coach = {$this->id} or
                     assistant01 = {$this->id} or
                     assistant02 = {$this->id} or
                     assistant03 = {$this->id} or
                     assistant04 = {$this->id} or
                     assistant05 = {$this->id}
                  ";
   }


Then make the necessary changes to your "_Events" table.
Code:

ALTER TABLE thyme_Events ADD coach int(11);
ALTER TABLE thyme_Events ADD assistant01 int(11);
ALTER TABLE thyme_Events ADD assistant02 int(11);
ALTER TABLE thyme_Events ADD assistant03 int(11);
ALTER TABLE thyme_Events ADD assistant04 int(11);
ALTER TABLE thyme_Events ADD assistant05 int(11);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Hacking Thyme All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.