Add an event for differents users, how save it in DB ?

Hi everybody,

I checked different topic until January and I haven’t found my solution, I hope you can help me.

My application contains different user who are working together sometimes. Each user access to his scheduler. During events creation, I want that an user can choose who is concerned by. Here is my lightbox :


“Utilisateurs” means “Users”

My question is : Where and how can I get back the values of the multiselect ?

Currently, each user can insert, update and delete an event and see only his events. I use three tables :

users : user_id, user_name, user_firstname
events_users : user_id, event_id
events : event_id, start_date, end_date, event_text

I hope I was clear. :slight_smile:

Check “share events” sample, which is included in the package, it implements similar scenario, for it, client side code loads data from two data feed

a) events which created by user
b) other events, in readonly mode

in you case you can load in second data feed events which are created by different users by have the reference to the current user. ( render_sql with joined tables )

Thanks for helping ! It works perfectly.

Here is my solution (server side) :

[code]
// Display function
function default_values($action){
$idutil = $action->get_value(“idutil”); // idutil : name of my selection “map_to”
if($idutil == “”){
$idutil = intval($_SESSION[‘num’]);
}
$action->set_value(“idutil”, $idutil);
}

// Insert function
function insert_related($action){
global $scheduler;

 $idutil = $action->get_value("idutil");
 $idutil = preg_split("/,/",$idutil,-1,PREG_SPLIT_NO_EMPTY);
 if($action->get_status() == "inserted"){
      $evenementDAO = new evenementDAO();
      $idevent = $evenementDAO->getMaxIdEvenement();
      foreach($idutil as $userid){
           $scheduler->sql->query("INSERT INTO evenement_utilisateur (idutil, idevenement) VALUES (".$userid.",".$idevent.");");
      }    
 }

}[/code]

Now, I’m doing a multiresource view with the initials of each user on the event. If I have some problems I tell you in another post.