Public Member Functions | Data Fields

Database Class Reference

Public Member Functions

 database ($DP_dlI)
 Constructor.
 disconnect ()
 Destructor.
 isConnected ()
 Checks if connected to database.
 dbError ()
 Returns the text of the error message from previous operation.
 applyChangedDate ($a_user_id, $a_date_id, $a_timestamp)
 Deletes a changed date by id and user_id.
 discardChangedDate ($a_user_id, $a_date_id, $a_timestamp)
 Changes a changed date to a negative date by user_id and date_id.
 getChangedDates ($a_user_id, $a_status)
 Fetches changed dp_dates by user_id and status.
 getDates ($a_user_id, $a_begin, $a_end, $a_keyword_ids)
 Fetches all single dp_dates from the database.
 getFullDayDates ($a_user_id, $a_begin, $a_end, $a_keyword_ids)
 Fetches all single whole day dp_dates from the database.
 getRotationDates ($a_user_id, $a_begin, $a_end, $a_keyword_ids)
 Fetches all rotation dp_dates from the database.
 getFullDayRotationDates ($a_user_id, $a_begin, $a_end, $a_keyword_ids)
 Fetches all whole day rotation dp_dates from the database.
 getDate ($a_date_id, $a_user_id)
 Returns all data about a date_id and the keyword_id and dp_keyword of a specific user.
 getNegRotationDates ($a_user_id, $a_begin, $a_end)
 Fetches all negative rotation dp_dates from the database.
 getUserGroups ($a_user_id)
 Returns all groups which are owned by the user.
 addKeyword ($a_user_id, $a_keyword)
 Adds a dp_keyword to the table of dp_keywords.
 getKeywords ($a_user_id)
 Fetches all dp_keywords associated to an user_id.
 delKeyword ($a_keyword_id)
 Deletes a dp_keyword from the table of dp_keywords.
 updateKeyword ($a_keyword_id, $a_keyword)
 Updates a dp_keyword in the table of dp_keywords.
 getGroupDates ($a_group_id, $a_begin, $a_end)
 Fetches all dates of a group from the database.
 getGroupRotationDates ($a_group_id, $a_begin, $a_end)
 Fetches all rotation dp_dates from the database.
 getGroupName ($a_group_id)
 Fetches the name of a group according to its group_id from the database.
 addStartEnd ($a_user_id, $a_start, $a_end)
 Adds starttime and endtime to the table of dp_properties.
 getStartEnd ($a_user_id)
 Fetches the starttime and endtime associated to an user_id from the table of dp_properties.
 updateStartEnd ($a_properties_id, $a_start, $a_end)
 Updates the starttime and endtime from the table of dp_properties.
 addDate ($a_begin, $a_end, $a_group_id, $a_user_id, $a_created, $a_rotation, $a_end_rotation, $a_shorttext, $a_text, $a_keyword_id)
 Adds a date to the table of dp_dates.
 updateDate ($a_date_id, $a_begin, $a_end, $a_user_id, $a_changed, $a_rotation, $a_end_rotation, $a_shorttext, $a_text)
 Alters a date in the table of dp_dates.
 delDate ($a_date_id, $a_user_id, $a_timestamp)
 Deletes a date by id and user_id.
 updateKeyword2Date ($a_user_id, $a_date_id, $a_keyword_id)
 Updates a the allocation of a dp_keyword to a date.
 cleanDatabase ()
 Cleans the database of garbage.

Data Fields

 $dlI = false

Detailed Description

Definition at line 38 of file class.Database.php.


Member Function Documentation

Database::addDate ( a_begin,
a_end,
a_group_id,
a_user_id,
a_created,
a_rotation,
a_end_rotation,
a_shorttext,
a_text,
a_keyword_id 
)

Adds a date to the table of dp_dates.

Parameters:
int begin
int end
int group_id
int user_id
int created
int rotation
string shorttext
string text
int keyword_id
Returns:
int error_code

Definition at line 725 of file class.Database.php.

References $result, $users, and ilCalInterface::getOtherMembers().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_begin) && isset($a_end) && isset($a_group_id) && isset($a_user_id) && isset($a_created) && isset($a_rotation) && isset($a_end_rotation) && isset($a_shorttext) && isset($a_keyword_id)) //Checks if connected to database and if all parameters are set except the text
                {
                        $result = mysql_query ("SELECT begin FROM ".$this->dbase_cscw.".dp_dates WHERE begin = '".$a_begin."' AND end = '".$a_end."' AND group_id = '".$a_group_id."' AND user_id = '".$a_user_id."' AND rotation = '".$a_rotation."' AND shorttext = '".$a_shorttext."' AND text = '".$a_text."' AND end_rotation = '".$a_end_rotation."'", $this->dlI);       //Verifies that date does not exist in table of dp_dates
                        $test = mysql_fetch_array($result);
                        mysql_free_result ($result);
                        if ($a_begin != $test[0])       //Checks if date is already in table of dp_dates (see SQL-query)
                        {
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_dates (id, begin, end, group_id, user_id, created, changed, rotation, shorttext, text, end_rotation) VALUES ('', '".$a_begin."', '".$a_end."' , '".$a_group_id."', '".$a_user_id."', '".$a_created."' , '".$a_created."' , '".$a_rotation."' , '".$a_shorttext."', '".$a_text."', '".$a_end_rotation."')", $this->dlI);      //Inserts date into table of dp_dates
                                if (mysql_errno ($this->dlI) == 0) $return = 0;
                                $result = mysql_query ("SELECT id FROM ".$this->dbase_cscw.".dp_dates WHERE begin = '".$a_begin."' AND end = '".$a_end."' AND group_id = '".$a_group_id."' AND user_id = '".$a_user_id."' AND rotation = '".$a_rotation."' AND shorttext = '".$a_shorttext."' AND text = '".$a_text."' AND end_rotation = '".$a_end_rotation."'", $this->dlI);  //Get date_id of the inserted date
                                $date_id = mysql_fetch_array($result);
                                mysql_free_result ($result);
                                if ($a_keyword_id != '0') mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_keywords (id, date_id, keyword_id) VALUES ('', '".$date_id[0]."', '".$a_keyword_id."')", $this->dlI);      //Insert dp_keyword allocation into the table of dp_keywords if dp_keyword is set
                                if ($a_group_id != '0') //Checks if date is a date of a group
                                {
                                        $users = false;
                                        $users = ilCalInterface::getOtherMembers($a_group_id, $a_user_id);      //Gets all other members of this group from database via the interface class
                                        if($users) {
                                                for ($i = 0; $i < count($users); $i++)
                                                {
                                                        mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_changed_dates (id, user_id, date_id, status, timestamp) VALUES ('', '".$users[$i]."', '".$date_id[0]."', '0', '0')", $this->dlI);    //Inserts a "new" date into the table of changed dp_dates
                                                        mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_neg_dates (id, date_id, user_id, timestamp) VALUES ('', '".$date_id[0]."', '".$users[$i]."', '0')", $this->dlI);     //Inserts a negative date into the table of negative dp_dates
                                                }
                                        }
                                }
                        }
                        else $return = 1;       //Errorcode 1 = Date exists already
                }
                else $return = 2;       //No DB-connection or one or more parameters missing
                return $return;
        }//end function

Here is the call graph for this function:

Database::addKeyword ( a_user_id,
a_keyword 
)

Adds a dp_keyword to the table of dp_keywords.

Parameters:
int user_id
string dp_keyword
Returns:
bool

Definition at line 463 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_keyword))        //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT id FROM ".$this->dbase_cscw.".dp_keyword WHERE user_id = '".$a_user_id."' AND keyword = '".$a_keyword."'", $this->dlI);  //Verfies that this dp_keyword does not exist already
                        if (mysql_fetch_array($result) == false)
                        {
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_keyword (id, user_id, keyword) VALUES ('', '".$a_user_id."', '".$a_keyword."')", $this->dlI);        //Inserts the dp_keyword into the dp_keyword table
                                if (mysql_errno ($this->dlI) == 0) return true;
                                else return false;
                        }
                        else
                        {
                                return true;
                        }
                        mysql_free_result ($result);
                }
                else
                {
                        return false;
                }
        }//end function

Database::addStartEnd ( a_user_id,
a_start,
a_end 
)

Adds starttime and endtime to the table of dp_properties.

Parameters:
int user_id
int start
int end
Returns:
bool

Definition at line 642 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_start) && isset($a_end)) //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT id FROM ".$this->dbase_cscw.".dp_properties WHERE user_id = '".$a_user_id."' AND dv_starttime  = '".$a_start."' AND dv_endtime  = '".$a_end."'", $this->dlI);    //Verfies that this start&endtime does not exist already
                        if (mysql_fetch_array($result) == false)
                        {
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_properties (id, user_id, dv_starttime, dv_endtime) VALUES ('', '".$a_user_id."', '".$a_start."', '".$a_end."')", $this->dlI);        //Inserts the start- and endtime into the table of dp_properties
                                if (mysql_errno ($this->dlI) == 0) return true;
                                else return false;
                        }
                        else
                        {
                                return true;
                        }
                        mysql_free_result ($result);
                }
                else
                {
                        return false;
                }
        }//end function

Database::applyChangedDate ( a_user_id,
a_date_id,
a_timestamp 
)

Deletes a changed date by id and user_id.

Parameters:
int user_id
int date_id
int timestamp
Returns:
bool

Definition at line 104 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_date_id) && isset($a_timestamp)) //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT status FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);    //Gets the status of the supplied date_id from database
                        $status = mysql_fetch_array($result);
                        mysql_free_result ($result);
                        if ($status[0] == '0')  //Status of the date = new
                        {
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);  //Delete all entries for this user and date from the table of negative dp_dates
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete all entries for this user and date from the table of changed dp_dates
                                if (mysql_errno ($this->dlI) == 0) return true;
                        }
                        elseif ($status[0] == '1')      //Status of the date = changed
                        {
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);  //Delete all entries for this user and date from the table of negative dp_dates
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete all entries for this user and date from the table of changed dp_dates
                                if (mysql_errno ($this->dlI) == 0) return true;
                        }
                        else
                        {
                                return true;
                        }
                }
                else
                {
                        return false;
                }
        }//end function

Database::cleanDatabase (  ) 

Cleans the database of garbage.

Returns:
bool

Definition at line 964 of file class.Database.php.

References $result, $row, and $users.

        {
                if (isset($this->dlI))  //Checks if connected to database
                {
                        $groups = ilCalInterface::getGroups();  //Gets all groups of the system
                        $ago = strtotime ("-6 month");  //Sets the time which date have to be ago to be deleted
                        $tobedeleted = false;
                        
                        $result = mysql_query ("SELECT DISTINCT id FROM ".$this->dbase_cscw.".dp_dates WHERE rotation != '0' AND end_rotation <= '".$ago."'", $this->dlI);      //Gets all single dp_dates that are older than 6 month
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $tobedeleted[$i] = $row[0];
                        }
                        mysql_free_result ($result);
                        
                        $result = mysql_query ("SELECT DISTINCT id FROM ".$this->dbase_cscw.".dp_dates WHERE rotation = '0' AND end <= '".$ago."'", $this->dlI);                //Gets all rotating dp_dates that are older than 6 month
                        for ($i = 0, $temp = false; $row = mysql_fetch_array($result); $i++)
                        {
                                $temp[$i] = $row[0];
                        }
                        $tobedeleted = array_merge ($tobedeleted, $temp);
                        mysql_free_result ($result);
                        
                        $result = mysql_query ("SELECT DISTINCT id FROM ".$this->dbase_cscw.".dp_dates WHERE user_id NOT IN ('-1','".implode("','",$users)."')", $this->dlI);   //Gets all dp_dates where user has been deleted
                        for ($i = 0, $temp = false; $row = mysql_fetch_array($result); $i++)
                        {
                                $temp[$i] = $row[0];
                        }
                        $tobedeleted = array_merge ($tobedeleted, $temp);
                        mysql_free_result ($result);
                        
                        $result = mysql_query ("SELECT DISTINCT id FROM ".$this->dbase_cscw.".dp_dates WHERE group_id NOT IN ('".$this->alluser_id."','".implode("','",$groups)."')", $this->dlI);      //Gets all dp_dates where group has been deleted
                        for ($i = 0, $temp = false; $row = mysql_fetch_array($result); $i++)
                        {
                                $temp[$i] = $row[0];
                        }
                        $tobedeleted = array_merge ($tobedeleted, $temp);
                        mysql_free_result ($result);
                        
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_dates WHERE id IN ('-1','".implode("','",$tobedeleted)."')", $this->dlI);    //Delete all collected dp_dates from the table of dp_dates
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id IN ('-1','".implode("','",$tobedeleted)."')", $this->dlI);               //Delete all collected dp_dates from the table of changed dp_dates
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id IN ('-1','".implode("','",$tobedeleted)."')", $this->dlI);   //Delete all collected dp_dates from the table of negative dp_dates
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id IN ('-1','".implode("','",$tobedeleted)."')", $this->dlI);            //Delete all collected dp_dates from the table of dp_keywords
                                                
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id NOT IN ('-1','".implode("','",$users)."')", $this->dlI); //Delete all entries of deleted users from the table of changed dp_dates
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE user_id NOT IN ('-1','".implode("','",$users)."')", $this->dlI);     //Delete all entries of deleted users from the table of negative dp_dates
                        
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keyword WHERE user_id NOT IN ('-1','".implode("','",$users)."')", $this->dlI);       //Delete all entries of deleted users from the table dp_keyword
                        
                        $result = mysql_query ("SELECT DISTINCT id FROM ".$this->dbase_cscw.".dp_keyword", $this->dlI); //Gets all keyword_ids
                        for ($i = 0, $tobedeleted = false; $row = mysql_fetch_array($result); $i++)
                        {
                                $tobedeleted[$i] = $row[0];
                        }
                        mysql_free_result ($result);

                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE keyword_id NOT IN ('-1','".implode("','",$tobedeleted)."')", $this->dlI);     //Deletes all entries of deleted dp_keywords from the table dp_keywords
                        
                        return true;            
                }
                else
                {
                        return false;
                }
        }//end function

Database::database ( DP_dlI  ) 

Constructor.

Definition at line 53 of file class.Database.php.

References $DP_dlI.

        {
                $this->dlI                      = $DP_dlI;      //Connect to database
                $this->alluser_id       = ALLUSERID;
        }

Database::dbError (  ) 

Returns the text of the error message from previous operation.

Returns:
string

Definition at line 91 of file class.Database.php.

        {
                return mysql_error();
        }//end function 

Database::delDate ( a_date_id,
a_user_id,
a_timestamp 
)

Deletes a date by id and user_id.

Parameters:
int date_id
int user_id
int timestamp
Returns:
bool

Definition at line 830 of file class.Database.php.

References $result, $users, ilCalInterface::getNumOfMembers(), and ilCalInterface::getOtherMembers().

        {
                if (isset($this->dlI) && isset($a_date_id) && isset($a_user_id) && isset($a_timestamp)) //Checks if connected to database and if all parameters are set
                {
                        $date = false;
                        $result = mysql_query ("SELECT group_id, user_id, rotation FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);       //Gets the group_id, user_id, rotation and date_id of this date from the table of dp_dates
                        $date = mysql_fetch_row($result);
                        mysql_free_result ($result);
                        if ($date[0] == 0 && $a_user_id == $date[1]) //Not a date of a group / user is owner of the date
                        {
                                if ($a_timestamp != 0 && $date[2] != 0) //Single rotating date
                                {
                                        mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_neg_dates (id, date_id, user_id, timestamp) VALUES ('', '".$a_date_id."', '".$a_user_id."' , '".$a_timestamp."')", $this->dlI);      //Insert a negative single rotating date into the table of negative dp_dates
                                }
                                else //Whole rotating date or single date
                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);                     //Deletes all traces of this date from all tables
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."'", $this->dlI);    //              /
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id = '".$a_date_id."'", $this->dlI);     //      /
                                }
                                $return = true;
                        }
                        elseif ($date[0] != 0) //Date of a group
                        {
                                if ($a_timestamp == 0)  //Whole rotating date or single date
                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$a_user_id."'", $this->dlI); //Delete all entries of this date for this user from the table of changed dp_dates
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$a_user_id."'", $this->dlI);     //Delete all entries of this date for this user from the table of negative dp_dates
                                        $result = mysql_query ("SELECT DISTINCT dp_keywords.keyword_id FROM ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE dp_keywords.date_id = '".$a_date_id."' AND dp_keyword.id = dp_keywords.keyword_id AND dp_keyword.user_id = '".$a_user_id."'", $this->dlI);        //Get keyword_id of this date for this date
                                        $keyword_id = mysql_fetch_array($result);
                                        mysql_free_result ($result);
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id = '".$a_date_id."' AND keyword_id = '".$keyword_id[0]."'", $this->dlI);       //Delete association of this dp_keyword to this date from the table of dp_keywords
                                }
                                else    //Single rotating date
                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$a_user_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete this single rotation date for this user from the table of changed dp_dates
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$a_user_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);  //Delete this single rotation date for this user from the table of negative dp_dates
                                }
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_neg_dates (id, date_id, user_id, timestamp) VALUES ('', '".$a_date_id."', '".$a_user_id."' , '".$a_timestamp."')", $this->dlI);      
                                //Inserts a negative date into the table of negative dp_dates
                                if ($a_user_id == $date[1])     //User is owner of date
                                {

                                        $users = false;
                                        $users = ilCalInterface::getOtherMembers($date[0], $a_user_id); //Gets all other members of this group from database via the interface class
                                        if($users) {
                                                for ($i = 0; $i < count($users); $i++)
                                                {
                                                //Date has been deleted by member
                                                $test = false;
                                                $test2 = false;
                                                $result = mysql_query ("SELECT DISTINCT date_id FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."'", $this->dlI);
                                                $test = mysql_fetch_array($result);
                                                mysql_free_result ($result);
                                                $result = mysql_query ("SELECT DISTINCT date_id, status FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."'", $this->dlI);
                                                $test2 = mysql_fetch_row($result);
                                                mysql_free_result ($result);
                                                        if ($a_timestamp == 0)  //Whole rotating date or single date
                                                        {
                                                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."'", $this->dlI); //Delete all entries of this date for this member from the table of changed dp_dates
                                                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."'", $this->dlI);     //Delete all entries of this date for this member from the table of negative dp_dates
                                                        }
                                                        else    //Single rotating date
                                                        {
                                                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete this single rotation date for this member from the table of changed dp_dates
                                                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."' AND timestamp = '".$a_timestamp."'", $this->dlI);  //Delete this single rotation date for this member from the table of negative dp_dates
                                                        }

                                                        if ($test2[1] != "0") {mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_changed_dates (id, user_id, date_id, status, timestamp) VALUES ('', '".$users[$i]."', '".$a_date_id."' , '2', '".$a_timestamp."')", $this->dlI);      //Inserts a "deleted" date for this member into the table of changed dp_dates
                                                        }
                                                }
                                        }
                                }
                                $result = mysql_query ("SELECT DISTINCT count(id) as numOfNegDates FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND timestamp = '0'", $this->dlI);  //Counts how many users have deleted this date
                                $numOfNegDates = mysql_fetch_array($result);
                                mysql_free_result ($result);

                                if ($numOfNegDates[0] >= ilCalInterface::getNumOfMembers($date[0]))     //Checks if the number of users who have deleted this date is equal to the number of members of this group

                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);                             //Deletes all traces of this date from all tables
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."'", $this->dlI);        //                      /
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."'", $this->dlI);            //              /
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id = '".$a_date_id."'", $this->dlI);             //      /
                                }
                                $return = true; 
                        }       
                        else
                        {
                                $return = false;
                        }
                }
                else
                {
                        $return = false;
                }
                return $return;
        }//end function

Here is the call graph for this function:

Database::delKeyword ( a_keyword_id  ) 

Deletes a dp_keyword from the table of dp_keywords.

Parameters:
int keyword_id
Returns:
bool

Definition at line 517 of file class.Database.php.

        {
                if (isset($this->dlI) && isset($a_keyword_id))  //Checks if connected to database and if all parameters are set
                {
                        $return = false;
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keyword WHERE id = '".$a_keyword_id."'", $this->dlI);        //Deletes the dp_keyword from the dp_keyword table
                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE keyword_id = '".$a_keyword_id."'", $this->dlI);       //Deletes all assigned entries in the table of dp_keywords
                        if (mysql_errno ($this->dlI) == 0) $return = true;
                }
                else
                {
                        $return = false;
                }
                return $return;
        }//end function

Database::discardChangedDate ( a_user_id,
a_date_id,
a_timestamp 
)

Changes a changed date to a negative date by user_id and date_id.

Parameters:
int user_id
int date_id
int timestamp
Returns:
bool

Definition at line 142 of file class.Database.php.

References $result, and ilCalInterface::getNumOfMembers().

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_date_id) && isset($a_timestamp)) //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT status FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);    //Gets the status of the supplied date_id from database
                        $status = mysql_fetch_array($result);
                        mysql_free_result ($result);
                        if ($status[0] == '0')  //Status of the date = new
                        {
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete all entries for this user and date from the table of changed dp_dates
                                if (mysql_errno ($this->dlI) == 0) return true;
                        }
                        elseif ($status[0] == '1')      //Status of the date = changed
                        {
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete all entries for this user and date from the table of changed dp_dates
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_neg_dates (id, date_id, user_id, timestamp) VALUES ('', '".$a_date_id."', '".$a_user_id."', '".$a_timestamp."')", $this->dlI);               //Inserts a negative date for this user and date into the table of negative dp_dates
                                if (mysql_errno ($this->dlI) == 0) return true;
                        }
                        elseif ($status[0] == '2')      //Status of the date = deleted
                        {
                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE user_id = '".$a_user_id."' AND date_id = '".$a_date_id."' AND timestamp = '".$a_timestamp."'", $this->dlI);      //Delete all entries for this user and date from the table of changed dp_dates
                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_neg_dates (id, date_id, user_id, timestamp) VALUES ('', '".$a_date_id."', '".$a_user_id."', '".$a_timestamp."')", $this->dlI);               //Inserts a negative date for this user and date into the table of negative dp_dates
                                $result = mysql_query ("SELECT DISTINCT group_id FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI); //Get the group_id of this date from database
                                $group_id = mysql_fetch_array($result);
                                mysql_free_result ($result);
                                $result = mysql_query ("SELECT DISTINCT count(id) as numOfNegDates FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND timestamp = '0'", $this->dlI);  //Counts how many users have deleted this date
                                $numOfNegDates = mysql_fetch_array($result);
                                mysql_free_result ($result);
                                if ($numOfNegDates[0] >= ilCalInterface::getNumOfMembers($group_id[0])) //Checks if the number of users who have deleted this date is equal to the number of members of this group
                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);                             //Deletes all traces of this date from all tables
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."'", $this->dlI);        //                      /
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."'", $this->dlI);            //              /
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id = '".$a_date_id."'", $this->dlI);             //      /
                                }

                                return true;
                        }
                        else
                        {
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::disconnect (  ) 

Destructor.

Returns:
boolean

Definition at line 64 of file class.Database.php.

        {
                mysql_close($this->dlI);        //Closes connection to database
        }       

Database::getChangedDates ( a_user_id,
a_status 
)

Fetches changed dp_dates by user_id and status.

Parameters:
int user_id
int status
Returns:
array

Definition at line 198 of file class.Database.php.

References $result, and $row.

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_status)) //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.shorttext, dp_dates.group_id, dp_dates.rotation, dp_changed_dates.timestamp FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_changed_dates WHERE dp_changed_dates.user_id = '".$a_user_id."' AND dp_changed_dates.status = '".$a_status."' AND dp_changed_dates.date_id = dp_dates.id ORDER BY dp_dates.begin, dp_dates.end DESC", $this->dlI);     //Gets all information on all changed dp_dates for this user according to its status from the table of dp_dates
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Database::getDate ( a_date_id,
a_user_id 
)

Returns all data about a date_id and the keyword_id and dp_keyword of a specific user.

Parameters:
int date_id
int user_id
Returns:
array

Definition at line 379 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_date_id) && isset($a_user_id))        //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT id as date_id, begin, end, group_id, user_id, created, changed, rotation, shorttext, text, end_rotation FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);  //Gets all information on a date from the table of dp_dates
                        $date = false;
                        $date = mysql_fetch_array($result);
                        mysql_free_result ($result);
                        if ($date)
                        {
                                $result = mysql_query ("SELECT DISTINCT dp_keyword.id as keyword_id, dp_keyword.keyword FROM ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE dp_keywords.date_id = '".$a_date_id."' AND dp_keyword.user_id = '".$a_user_id."' AND dp_keyword.id = dp_keywords.keyword_id", $this->dlI);       //Gets the dedicated keyword_id of the date from the table of dp_keywords
                                $keyword_id = false;
                                $keyword_id = mysql_fetch_array($result);
                                mysql_free_result ($result);
                                if ($keyword_id)
                                {
                                        $date = array_merge ($date, $keyword_id);       //Merges the keyword_id with the other information of the date
                                }
                                return $date;
                        }
                        else
                        {
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }//end function

Database::getDates ( a_user_id,
a_begin,
a_end,
a_keyword_ids 
)

Fetches all single dp_dates from the database.

Parameters:
int user_id
int begin
int end
array keyword_ids
Returns:
array

Definition at line 226 of file class.Database.php.

References $result, $row, and ilCalInterface::getMemberGroups().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_user_id) && isset($a_begin) && isset($a_end) && isset($a_keyword_ids))  //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_neg_dates WHERE dp_neg_dates.user_id = '".$a_user_id."' AND dp_neg_dates.date_id = dp_dates.id AND dp_neg_dates.timestamp = '0'", $this->dlI);        //Gets all negative dp_dates of an user from the table of negative dp_dates
                        $dp_neg_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_neg_dates[$i] = $row[0];
                        }
                        mysql_free_result ($result);
                        $group_ids = ilCalInterface::getMemberGroups($a_user_id);//Gets all groups in which the user is a member via the interface class

                        if ($group_ids == false) $group_ids = array('-2');      //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($dp_neg_dates == false) $dp_neg_dates = array('-2');        //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($a_keyword_ids[0] == '*') $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end > '".$a_end."') AND dp_dates.rotation = '0' AND (dp_dates.end - dp_dates.begin != 86399) ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);        //Gets all dp_dates by user and time period which have the following stats: date is NOT a full day date, date is NOT a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        else                                              $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end > '".$a_end."') AND dp_dates.rotation = '0' AND (dp_dates.end - dp_dates.begin != 86399) AND dp_keywords.keyword_id IN ('!�$%&/=', '".implode("','",$a_keyword_ids)."') AND dp_keywords.date_id = dp_dates.id ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);        //Gets all dp_dates by user, dp_keyword and time period which have the following stats: date is NOT a full day date, date is NOT a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getFullDayDates ( a_user_id,
a_begin,
a_end,
a_keyword_ids 
)

Fetches all single whole day dp_dates from the database.

Parameters:
int user_id
int begin
int end
array keyword_ids
Returns:
array

Definition at line 266 of file class.Database.php.

References $result, $row, and ilCalInterface::getMemberGroups().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_user_id) && isset($a_begin) && isset($a_end) && isset($a_keyword_ids))  //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_neg_dates WHERE dp_neg_dates.user_id = '".$a_user_id."' AND dp_neg_dates.date_id = dp_dates.id  AND dp_neg_dates.timestamp = '0'", $this->dlI);       //Gets all negative dp_dates of an user from the table of negative dp_dates
                        $dp_neg_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_neg_dates[$i] = $row[0];
                        }
                        mysql_free_result ($result);
                        $group_ids = ilCalInterface::getMemberGroups($a_user_id);       //Gets all groups in which the user is a member via the interface class
                        if ($group_ids == false) $group_ids = array('-2');      //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($dp_neg_dates == false) $dp_neg_dates = array('-2');        //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($a_keyword_ids[0] == '*') $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end > '".$a_end."') AND dp_dates.rotation = '0' AND (dp_dates.end - dp_dates.begin = 86399) ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);         //Gets all dp_dates by user and time period which have the following stats: is a full day date, date is NOT a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        else                                              $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end > '".$a_end."') AND dp_dates.rotation = '0' AND (dp_dates.end - dp_dates.begin = 86399) AND dp_keywords.keyword_id IN ('!�$%&/=', '".implode("','",$a_keyword_ids)."') AND dp_keywords.date_id = dp_dates.id ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI); //Gets all dp_dates by user, dp_keyword and time period which have the following stats: date is full day date, date is NOT a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getFullDayRotationDates ( a_user_id,
a_begin,
a_end,
a_keyword_ids 
)

Fetches all whole day rotation dp_dates from the database.

Parameters:
int user_id
int begin
int end
array keyword_ids
Returns:
array

Definition at line 342 of file class.Database.php.

References $result, $row, and ilCalInterface::getMemberGroups().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_user_id) && isset($a_begin) && isset($a_end) && isset($a_keyword_ids))  //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_neg_dates WHERE dp_neg_dates.user_id = '".$a_user_id."' AND dp_neg_dates.timestamp = '0' AND dp_neg_dates.date_id = dp_dates.id", $this->dlI);        //Gets all negative dp_dates of an user from the table of negative dp_dates
                        $dp_neg_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_neg_dates[$i] = $row[0];
                        }
                        mysql_free_result ($result);
                        $group_ids = ilCalInterface::getMemberGroups($a_user_id);       //Gets all groups in which the user is a member via the interface class
                        if ($group_ids == false) $group_ids = array('-2');      //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($dp_neg_dates == false) $dp_neg_dates = array('-2');        //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($a_keyword_ids[0] == '*') $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end_rotation >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end_rotation = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end_rotation > '".$a_end."') AND dp_dates.rotation != '0' AND (dp_dates.end - dp_dates.begin = 86399) ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);   //Gets all dp_dates by user and time period which have the following stats: date is NOT a full day date, date is a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        else                                              $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end_rotation >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end_rotation = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end_rotation > '".$a_end."') AND dp_dates.rotation != '0' AND (dp_dates.end - dp_dates.begin = 86399) AND dp_keywords.keyword_id IN ('!�$%&/=', '".implode("','",$a_keyword_ids)."') AND dp_keywords.date_id = dp_dates.id ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);   //Gets all dp_dates by user, dp_keyword and time period which have the following stats: date is a full day date, date is a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getGroupDates ( a_group_id,
a_begin,
a_end 
)

Fetches all dates of a group from the database.

Parameters:
int group_id
int begin
int end
Returns:
array

Definition at line 565 of file class.Database.php.

References $result, $row, and ilCalInterface::getOtherMembers().

        {       
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_group_id) && isset($a_begin) && isset($a_end))  //Checks if connected to database and if all parameters are set
                {   
                        $user_ids = ilCalInterface::getOtherMembers($a_group_id, -1);   //Gets all members of this group via the interface class
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation  FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id = '".$a_group_id."' OR dp_dates.user_id IN ('".$this->alluser_id."','".implode("','",$user_ids)."')) AND rotation = '0' AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end = '".$a_begin."')  ORDER BY begin, end DESC", $this->dlI);       //Gets all dp_dates by group and time period and all dp_dates of all members of this group which have the following stats: date is NOT a full day date, date is NOT a Rotationdate
                        $dp_dates = false;

                        echo(mysql_error());
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);

                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getGroupName ( a_group_id  ) 

Fetches the name of a group according to its group_id from the database.

Parameters:
int group_ids
Returns:
string

Definition at line 621 of file class.Database.php.

        {
                if (isset($this->dlI) && isset($a_group_id))    //Checks if connected to database and if all parameters are set
                {
                        $groupname = ilCalInterface::getGroupName($a_group_id); //Forwards the request to the interface class
                        return $groupname;
                }
                else
                {
                        return false;
                }
        }//end function

Database::getGroupRotationDates ( a_group_id,
a_begin,
a_end 
)

Fetches all rotation dp_dates from the database.

Parameters:
int group_id
int begin
int end
Returns:
array

Definition at line 595 of file class.Database.php.

References $result, $row, and ilCalInterface::getOtherMembers().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_group_id) && isset($a_begin) && isset($a_end))  //Checks if connected to database and if all parameters are set
                {
                        $user_ids = ilCalInterface::getOtherMembers($a_group_id, -1);   //Gets all members of this group via the interface class
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation  FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id = '".$a_group_id."' OR dp_dates.user_id IN ('".$this->alluser_id."','".implode("','",$user_ids)."')) AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end_rotation >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end_rotation = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end_rotation > '".$a_end."') AND dp_dates.rotation != '0' ORDER BY begin, end DESC", $this->dlI);   
                        //Gets all dp_dates by group and time period and all dp_dates of all members of this group which have the following stats: date is NOT a full day date, date is NOT a Rotationdate
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getKeywords ( a_user_id  ) 

Fetches all dp_keywords associated to an user_id.

Parameters:
int user_id
Returns:
array

Definition at line 492 of file class.Database.php.

References $result, and $row.

        {
                if (isset($this->dlI) && isset($a_user_id))     //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT id as keyword_id, keyword FROM ".$this->dbase_cscw.".dp_keyword WHERE user_id = '".$a_user_id."' ORDER BY keyword", $this->dlI);        //Gets all dp_keywords by user from the dp_keyword table
                        $dp_keywords = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                   $dp_keywords[$i] = $row;
                        }
                        return $dp_keywords;
                        mysql_free_result ($result);
                }
                else
                {
                        return false;
                }
        }//end function

Database::getNegRotationDates ( a_user_id,
a_begin,
a_end 
)

Fetches all negative rotation dp_dates from the database.

Parameters:
int user_id
int begin
int end
Returns:
array

Definition at line 418 of file class.Database.php.

References $result, and $row.

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_user_id) && isset($a_begin) && isset($a_end))   //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation, dp_neg_dates.timestamp FROM ".$this->dbase_cscw.".dp_neg_dates, ".$this->dbase_cscw.".dp_dates WHERE dp_neg_dates.user_id = '".$a_user_id."' AND dp_neg_dates.timestamp != '0' AND (dp_dates.id = dp_neg_dates.date_id AND dp_dates.rotation != '0') AND dp_neg_dates.timestamp between '".$a_begin."' AND '".$a_end."' ORDER BY dp_neg_dates.timestamp", $this->dlI);  //Gets all negative rotation dp_dates by user and time period
                        $dp_neg_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_neg_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_neg_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Database::getRotationDates ( a_user_id,
a_begin,
a_end,
a_keyword_ids 
)

Fetches all rotation dp_dates from the database.

Parameters:
int user_id
int begin
int end
array keyword_ids
Returns:
array

Definition at line 304 of file class.Database.php.

References $result, $row, and ilCalInterface::getMemberGroups().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_user_id) && isset($a_begin) && isset($a_end) && isset($a_keyword_ids))  //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT dp_dates.id FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_neg_dates WHERE dp_neg_dates.user_id = '".$a_user_id."' AND dp_neg_dates.timestamp = '0' AND dp_neg_dates.date_id = dp_dates.id", $this->dlI);        //Gets all negative dp_dates of an user from the table of negative dp_dates
                        $dp_neg_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_neg_dates[$i] = $row[0];
                        }
                        mysql_free_result ($result);
                        $group_ids = ilCalInterface::getMemberGroups($a_user_id);       //Gets all groups in which the user is a member via the interface class
                        if ($group_ids == false) $group_ids = array('-2');              //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($dp_neg_dates == false) $dp_neg_dates = array('-2');        //Adds a dummy to the array to avoid "Cannot implode" errors
                        if ($a_keyword_ids[0] == '*') $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation FROM ".$this->dbase_cscw.".dp_dates WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end_rotation >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end_rotation = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end_rotation > '".$a_end."') AND dp_dates.rotation != '0' AND (dp_dates.end - dp_dates.begin != 86399) ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);  //Gets all dp_dates by user and time period which have the following stats: date is NOT a full day date, date is a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        else                                              $result = mysql_query ("SELECT DISTINCT dp_dates.id as date_id, dp_dates.begin, dp_dates.end, dp_dates.group_id, dp_dates.user_id, dp_dates.shorttext, dp_dates.text, dp_dates.rotation, dp_dates.end_rotation FROM ".$this->dbase_cscw.".dp_dates, ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE (dp_dates.group_id IN ('".$this->alluser_id."','".implode("','",$group_ids)."') OR dp_dates.user_id = '".$a_user_id."') AND dp_dates.id NOT IN ('-2','".implode("','",$dp_neg_dates)."') AND (dp_dates.begin <= '".$a_end."' AND dp_dates.end_rotation >= '".$a_begin."') AND NOT (dp_dates.begin < '".$a_begin."' AND dp_dates.end_rotation = '".$a_begin."') AND NOT (dp_dates.begin = '".$a_end."' AND dp_dates.end_rotation > '".$a_end."') AND dp_dates.rotation != '0' AND (dp_dates.end - dp_dates.begin != 86399) AND dp_keywords.keyword_id IN ('!�$%&/=', '".implode("','",$a_keyword_ids)."') AND dp_keywords.date_id = dp_dates.id ORDER BY dp_dates.begin, dp_dates.end DESC, dp_dates.changed, dp_dates.created", $this->dlI);  //Gets all dp_dates by user, dp_keyword and time period which have the following stats: date is NOT a full day date, date is a rotation date, user is owner of date or user is member in the group of date, NOT in $dp_neg_dates
                        $dp_dates = false;
                        for ($i = 0; $row = mysql_fetch_array($result); $i++)
                        {
                                $dp_dates[$i] = $row;
                        }
                        mysql_free_result ($result);
                        return $dp_dates;
                }
                else
                {
                        return false;
                }
        }//end function

Here is the call graph for this function:

Database::getStartEnd ( a_user_id  ) 

Fetches the starttime and endtime associated to an user_id from the table of dp_properties.

Parameters:
int user_id
Returns:
bool

Definition at line 671 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_user_id))     //Checks if connected to database and if all parameters are set
                {
                        $result = mysql_query ("SELECT DISTINCT id, dv_starttime, dv_endtime FROM ".$this->dbase_cscw.".dp_properties WHERE user_id = '".$a_user_id."'", $this->dlI);   //Gets the start- and endtime for this user from the table of dp_properties
                        if ($times = mysql_fetch_array($result)) return $times;
                        else return false;
                        mysql_free_result ($result);
                }
                else
                {
                        return false;
                }
        }//end function

Database::getUserGroups ( a_user_id  ) 

Returns all groups which are owned by the user.

Parameters:
int user_id
Returns:
array

Definition at line 443 of file class.Database.php.

        {
                if (isset($this->dlI) && isset($a_user_id))     //Checks if connected to database and if all parameters are set
                {
                        $groups = ilCalInterface::getUserGroups($a_user_id);    //Forwards the request to the interface class
                        return $groups;
                }
                else
                {
                        return false;
                }
        }//end function

Database::isConnected (  ) 

Checks if connected to database.

Returns:
bool

Definition at line 74 of file class.Database.php.

        {
                if (isset($this->dlI))  //Checks if connected to database
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }//end function 

Database::updateDate ( a_date_id,
a_begin,
a_end,
a_user_id,
a_changed,
a_rotation,
a_end_rotation,
a_shorttext,
a_text 
)

Alters a date in the table of dp_dates.

Parameters:
int date_id
int begin
int end
int user_id
int changed
int rotation
int end_rotation
string shorttext
string text
Returns:
bool

Definition at line 773 of file class.Database.php.

References $result, $users, and ilCalInterface::getOtherMembers().

        {
                if (isset($this->dlI) && $a_begin <= $a_end && isset($a_date_id) && isset($a_begin) && isset($a_end) && isset($a_user_id) && isset($a_changed) && isset($a_rotation) && isset($a_end_rotation) && isset($a_shorttext))  //Checks if connected to database and if all parameters are set except the text
                {
                        $return = false;
                        $result = mysql_query ("SELECT user_ID, group_ID, begin, end, rotation, end_rotation, shorttext, text FROM ".$this->dbase_cscw.".dp_dates WHERE id = '".$a_date_id."'", $this->dlI);    //Gets the all information of this date from the table of dp_dates
                        $date = mysql_fetch_row($result);
                        mysql_free_result ($result);
                        if ($a_user_id == $date[0] && ($a_begin != $date[2] || $a_end != $date[3] || $a_rotation != $date[4] || $a_end_rotation != $date[5] || $a_shorttext != $date[6] || $a_text != $date[7]))        //User is owner of date
                        {
                                mysql_query ("UPDATE ".$this->dbase_cscw.".dp_dates SET begin = '".$a_begin."', end = '".$a_end."', changed = '".$a_changed."', rotation = '".$a_rotation."', shorttext = '".$a_shorttext."', text = '".$a_text."', end_rotation = '".$a_end_rotation."' WHERE id = '".$a_date_id."'", $this->dlI);     //Update the date in the table of dp_dates
                                if (mysql_errno ($this->dlI) == 0) $return = true;
                                if ($date[1] != '0')    //Date is a date of a group
                                {
                                        $users = false;
                                        $users = ilCalInterface::getOtherMembers($date[1], $a_user_id); //Gets all other members of this group from database via the interface class
                                        if($users) {
                                        for ($i = 0; $i < count($users); $i++)
                                        {
                                                $test = false;
                                                $result2 = mysql_query ("SELECT DISTINCT date_id FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."' AND timestamp = '0' AND status = '0' ", $this->dlI);       //Checks if the date is stated as new date for this user in the table dp_changed_dates
                                                $test = mysql_fetch_array($result2);
                                                mysql_free_result ($result2);
                                                if ($test[0] != $a_date_id)     //Checks if the date is stated as new date for this user in the table dp_changed_dates (see SQL-query)
                                                {
                                                                mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND user_id = '".$users[$i]."' AND timestamp = '0' AND status = '1'", $this->dlI);    //Delete all entries in the table dp_changed_dates for this user which are stated as updated
                                                                mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_changed_dates (id, user_id, date_id, status, timestamp) VALUES ('', '".$users[$i]."', '".$a_date_id."', '1', '0')", $this->dlI);     //Inserts a "updated" date into the table of changed dp_dates
                                                }
                                        }
                                        }
                                }
                                if ($a_rotation != $date[4])    //Rotation has changed
                                {
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_changed_dates WHERE date_id = '".$a_date_id."' AND timestamp != '0'", $this->dlI);   //Delete all single rotating dp_dates from the table of changed dp_dates
                                        mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_neg_dates WHERE date_id = '".$a_date_id."' AND timestamp != '0'", $this->dlI);       //Delete all single rotating dp_dates from the table of negative dp_dates
                                }
                        }
                        else
                        {
                                $return = false;
                        }
                }
                else
                {
                        $return = false;
                }
                return $return;
        }//end function

Here is the call graph for this function:

Database::updateKeyword ( a_keyword_id,
a_keyword 
)

Updates a dp_keyword in the table of dp_keywords.

Parameters:
int keyword_id
string dp_keyword
Returns:
bool

Definition at line 540 of file class.Database.php.

        {
                if (isset($this->dlI) && isset($a_keyword_id) && isset($a_keyword))     //Checks if connected to database and if all parameters are set
                {
                        mysql_query ("UPDATE ".$this->dbase_cscw.".dp_keyword SET keyword = '".$a_keyword."' WHERE id = '".$a_keyword_id."'", $this->dlI);      //Changes the dp_keyword in the dp_keyword table
                        if (mysql_errno ($this->dlI) == 0) return true;
                        else 
                        {
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }//end function

Database::updateKeyword2Date ( a_user_id,
a_date_id,
a_keyword_id 
)

Updates a the allocation of a dp_keyword to a date.

Parameters:
int user_id
int date_id
int keyword_id
Returns:
bool

Definition at line 937 of file class.Database.php.

References $result.

        {
                if (isset($this->dlI) && isset($a_user_id) && isset($a_date_id) && isset($a_keyword_id))        //Checks if connected to database and if all parameters are set
                {
                                $keyword_id_old = false;
                                $result = mysql_query ("SELECT DISTINCT dp_keywords.keyword_id FROM ".$this->dbase_cscw.".dp_keyword, ".$this->dbase_cscw.".dp_keywords WHERE dp_keywords.date_id = '".$a_date_id."' AND dp_keyword.id = dp_keywords.keyword_id AND dp_keyword.user_id = '".$a_user_id."'", $this->dlI);        //Gets the old dp_keyword associated with this date
                                $keyword_id_old = mysql_fetch_array($result);
                                mysql_free_result ($result);
                                if ($a_keyword_id != $keyword_id_old[0])        // If dp_keyword has changed
                                {
                                        if ($a_keyword_id == 0)                          mysql_query ("DELETE FROM ".$this->dbase_cscw.".dp_keywords WHERE date_id = '".$a_date_id."' AND keyword_id = '".$keyword_id_old[0]."'", $this->dlI);  //Delete association from table of dp_keywords
                                        elseif ($keyword_id_old[0] == false) mysql_query ("INSERT INTO ".$this->dbase_cscw.".dp_keywords (id, date_id, keyword_id) VALUES ('', '".$a_date_id."', '".$a_keyword_id."')", $this->dlI);            //Add association from table of dp_keywords
                                        else                                                             mysql_query ("UPDATE ".$this->dbase_cscw.".dp_keywords SET keyword_id = '".$a_keyword_id."' WHERE date_id = '".$a_date_id."' AND keyword_id = '".$keyword_id_old[0]."'", $this->dlI);          //Change association from table of dp_keywords
                                }
                                return true;
                }
                else
                {
                        return false;
                }
        }//end function

Database::updateStartEnd ( a_properties_id,
a_start,
a_end 
)

Updates the starttime and endtime from the table of dp_properties.

Parameters:
int keyword_id
int start
int end
Returns:
bool

Definition at line 694 of file class.Database.php.

        {
                if (isset($this->dlI) && isset($a_properties_id) && isset($a_start) && isset($a_end))   //Checks if connected to database and if all parameters are set
                {
                        mysql_query ("UPDATE ".$this->dbase_cscw.".dp_properties SET dv_starttime = '".$a_start."', dv_endtime = '".$a_end."' WHERE id = '".$a_properties_id."'", $this->dlI);  //Changes the start- and endtime in the table of dp_properties
                        if (mysql_errno ($this->dlI) == 0) return true;
                        else 
                        {
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }//end function


Field Documentation

Database::$dlI = false

Definition at line 47 of file class.Database.php.


The documentation for this class was generated from the following file: