Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jake on Aug 18, 2009 05:43
open dhtmlx forum
Still no success

Thanks for the reply. However I still didn't success with even calling the default_values() method. (I don't understand why, the syntax seems correct to me.) Both methods are inside Calendar_Controller class:

  public function events()
  {
    require_once 'media/calendar/connector/scheduler_connector.php';    
    $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');
            
      $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);
      
    $new_cal = new Calendar_Controller();
    $scheduler->event->attach("beforeProcessing",array($new_cal,"default_values"));
      
      $scheduler->render_sql("select * from events_shared where userId = ".$user_id,"event_id","start_date,end_date,text,event_type,userId");
  }


    protected function default_values($action)
    {    
      $this->track('Called default_values with user id '.$this->user->id);
        $event_type = $action->get_value("event_type");
        if ($event_type == "")
            $event_type = 0;
            
        $action->set_value("userId",$this->user->id);
    }


Inside default_values() I call my own logging function that basically will write the user id to database, just to let me know that the function was called for sure.

I don't get any errors, and my events are saved but with userId=0, instead of the current user id, which is another sign that tells us that the function isn't called.

I tried both with creating a new instance (as in the example) and with sending '$this'. No success. What are your ideas? Thank you!
Answer posted by Support on Aug 18, 2009 07:55
>>I don't get any errors
Is log.txt doesn't contain any error info as well? Connector catches run-time error to prevent xml output corruption, but saves error info in defined log

I'm not quite sure, but you can try to change the access level of default_values method to the "public"
Answer posted by Jake on Aug 19, 2009 04:42
Thanks a lot for your idea, it worked indeed! The method has to be public to be accessible from the outside of the class (e.g. by an AJAX call). I assumed that default_values() was an internal method, only called from within the class, and hence the protected level would be enough. But as it turns out, we are making an AJAX call with POST data to default_values, and it needs to be public. Thanks again!