Implementing DHTMLXScheduler in an object oriented applicati

Hi!

I am trying to get a working connection between my multi-user application written in PHP (using a object oriented framework called Kohana). I was trying to re-implement one of your samples, that one located in /samples/customization/shared_events/. The data loads correctly from the database for the correct user and it looks great so far. But when I try to edit an existing or add a new event, I run into problems. The only message I get is an alert box saying “Error type: LoadXML Description: Incorrect XML”. I am not sure what it means and the log says nothing more about this specific issue.



The problem might be the following. (This is the function that corresponds to your event.php, so I call this e.g. calendar/events/?userId=2):



public function events()

{

$server = Kohana::config(‘database.default.connection.host’);

    $user     = Kohana::config(‘database.default.connection.user’);

     $pass     = Kohana::config(‘database.default.connection.pass’);

     $db_name= Kohana::config(‘database.default.connection.database’);

    

include (‘media/calendar/connector/scheduler_connector.php’);    

    

    $res=mysql_connect($server, $user, $pass);

    mysql_select_db($db_name);

        

    $user_id = intval($_GET[‘user’]);

    

    $scheduler = new schedulerConnector($res);

    //$scheduler->enable_log(“log.txt”,true);

    

    $scheduler->event->attach(“beforeProcessing”,“default_values”);

    

    $scheduler->render_sql("select * from events_shared where userId = ".$user_id,“event_id”,“start_date,end_date,text,event_type,userId”);

}



The important thing is that this function is inside a class, named Calendar. So, as I said, I call calendar/event/?userId=2 instead of event.php?userId=2. I think though that there is a problem on this line: $scheduler->event->attach(“beforeProcessing”,“default_values”); . I had to lift off the default_values() function to the calendar class, since it couldn’t be placed just inside my events() function. In your sample this wasn’t a problem, because events.php is not a class, so a can appear pretty much anywhere.



Now I am wondering what you think about this and if I can get this to work in any way. I already tried calling $this->default_values but there seems to be a problem with parseing as the function is not called from my Calendar class, so $this does not refer to the class which hosts my default_values() function.



Hope to hear from you soon, and thank you for a great product.



Sincerely,

Jacob

If a method of class need to be assigned to an event, you can use next syntax

$scheduler->event->attach(“beforeProcessing”,array($class_object,“default_values”));

The syntax is the same as for call_user_func
php.net/call_user_func