HOW TO create a login system for calendar

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

Moderator: alexandrleonenko

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

HOW TO create a login system for calendar

Postby administrator » Apr 19th, '11, 20:54

Step 1. Download attached zip file.
php-calendar-with-login.zip
(3.99 KiB) Downloaded 362 times


Step 2. Perform all needed changed according to these instructions:

Code: Select all

1. Add to calendar.class.php following methods and properties:

    //login vars
    private $_islogged = false;
    private $_isadmin = false;
    private $_private_cat_id;


    //login functions
    function setIsLogged($islogged = false){
        $this->_islogged = $islogged;
    }

    function setIsAdmin($isadmin = false){
        $this->_isadmin = $isadmin;
    }

    function getIsLogged(){
        return $this->_islogged;
    }

    function getIsAdmin(){
        return $this->_isadmin;
    }

    function getPrivateCategoryID(){
        return $this->_private_cat_id;
    }

    function setPrivateCategoryID($private_category_id = 1){
        $this->_private_cat_id = $private_category_id;
    }

2. Modify functions that draw calendar: DrawWeek(), GetEventsListForMonth(),...
   in this way:
   
    if(!$this->getIsLogged()){
       $sql .= " and ".DB_PREFIX."events_categories.id != " . $this->getPrivateCategoryID();
    }
    $sql .= " ORDER BY ".DB_PREFIX."calendar.id ASC";


3. In sample.php file change if($username == "admin" && $password == "test"){ ... }
   according to your needs

4. In sample.php file change $objCalendar->setPrivateCategoryID(4);
   according to yuor needs.

Return to “ApPHP Calendar {HOW TO}”