HOW TO integrate Calendar into protected area

Talk and info about common issues and learn how to do almost anything with ApPHP Calendar

Moderator: alexandrleonenko

administrator
Site Admin
Site Admin
Posts: 6011
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO integrate Calendar into protected area

Postby administrator » Apr 9th, '10, 09:34

If you want to integrate ApPHP Calendar (version Pro) into protected area you have to perform following steps:

1. INSTALLATION.
Install Calendar on your server, using installation guide.

2. SETTING UP USER'S ACCESS
Create a table of users, that will have access to the Calendar.
Now, if you want to distinct users by giving them different access levels (for example: Main Admin and Simple Admin),
you have to retrieve logged user status and apply it to Calendar operations. Let see it with the following example:

Code: Select all

   $status = "Main Admin"; // or Simple Admin

   if($status == "Main Admin"){
      $add_operations = true;
      $edit_operations = true;
      $delete_operations = true;
   }else{
      $add_operations = false;
      $edit_operations = true;
      $delete_operations = false;
  }


Now we have to assign these values to Calendar operations:

Code: Select all

    ## +-- Categories Actions & Operations ------------------------------------
    ##  *** set (allow) calendar categories operations
    $cat_operations = array(
        "add"=> $add_operations,
        "edit"=> $edit_operations,
        "details"=>true,
        "delete"=> $delete_operations,
        "manage"=>true,
        "allow_colors"=>true
    );
    $objCalendar->SetCategoriesOperations($cat_operations);

    ##  *** set (allow) calendar events operations
    $events_operations = array(
        "add"=> $add_operations,
        "edit"=> $edit_operations,
        "details"=>true,
        "delete"=>$delete_operations,
        "manage"=>true,
        "events_statistics"=>true,
        "printing"=>true
    );
    $objCalendar->SetEventsOperations($events_operations);


Of course, you may define access to different operations according to your needs, not just was shown above.

3. LINKING EVENTS TO USERS
Now, if you want to allow user to insert only his own events - you have to pass to Calendar his ID.

This the example shows how we do this, if user ID stored in some SESSION variable .

Code: Select all

  ## +-- Users Settings -----------------------------------------------------
  ## *** set user ID (must be numeric value)
  $user_id = $_SESSION['logged_user_id'];
  $objCalendar->SetUserID($user_id);   


Of course, retrieving of user ID depended on your system settings.

Return to “ApPHP Calendar {HOW TO}”