• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Course/classes/Event/class.ilEventParticipants.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 class ilEventParticipants
00034 {
00035         var $ilErr;
00036         var $ilDB;
00037         var $tree;
00038         var $lng;
00039 
00040         var $event_id = null;
00041 
00042         function ilEventParticipants($a_event_id)
00043         {
00044                 global $ilErr,$ilDB,$lng,$tree;
00045 
00046                 $this->ilErr =& $ilErr;
00047                 $this->db  =& $ilDB;
00048                 $this->lng =& $lng;
00049 
00050                 $this->event_id = $a_event_id;
00051                 $this->__read();
00052         }
00053 
00054         function setUserId($a_usr_id)
00055         {
00056                 $this->user_id = $a_usr_id;
00057         }
00058         function getUserId()
00059         {
00060                 return $this->user_id;
00061         }
00062         function setMark($a_mark)
00063         {
00064                 $this->mark = $a_mark;
00065         }
00066         function getMark()
00067         {
00068                 return $this->mark;
00069         }
00070         function setComment($a_comment)
00071         {
00072                 $this->comment = $a_comment;
00073         }
00074         function getComment()
00075         {
00076                 return $this->comment;
00077         }
00078         function setParticipated($a_status)
00079         {
00080                 $this->participated = $a_status;
00081         }
00082         function getParticipated()
00083         {
00084                 return $this->participated;
00085         }
00086         function setRegistered($a_status)
00087         {
00088                 $this->registered = $a_status;
00089         }
00090         function getRegistered()
00091         {
00092                 return $this->registered;
00093         }
00094         function updateUser()
00095         {
00096                 global $ilDB;
00097                 
00098                 $query = "DELETE FROM event_participants ".
00099                         "WHERE event_id = ".$ilDB->quote($this->getEventId())." ".
00100                         "AND usr_id = ".$ilDB->quote($this->getUserId())." ";
00101                 $this->db->query($query);
00102 
00103                 $query = "INSERT INTO event_participants ".
00104                         "SET event_id = ".$ilDB->quote($this->getEventId()).", ".
00105                         "usr_id = ".$ilDB->quote($this->getUserId()).", ".
00106                         "registered = ".$ilDB->quote($this->getRegistered()).", ".
00107                         "participated = ".$ilDB->quote($this->getParticipated()).", ".
00108                         "mark = ".$ilDB->quote($this->getMark()).", ".
00109                         "comment = ".$ilDB->quote($this->getComment())."";
00110                 $this->db->query($query);
00111                 return true;
00112         }
00113 
00114         function getUser($a_usr_id)
00115         {
00116                 return $this->participants[$a_usr_id] ? $this->participants[$a_usr_id] : array();
00117         }
00118 
00119         function getParticipants()
00120         {
00121                 return $this->participants ? $this->participants : array();
00122         }
00123 
00124         function isRegistered($a_usr_id)
00125         {
00126                 return $this->participants[$a_usr_id]['registered'] ? true : false;
00127         }
00128 
00129         function hasParticipated($a_usr_id)
00130         {
00131                 return $this->participants[$a_usr_id]['participated'] ? true : false;
00132         }
00133 
00134         function updateParticipation($a_usr_id,$a_status)
00135         {
00136                 ilEventParticipants::_updateParticipation($a_usr_id,$this->getEventId(),$a_status);
00137         }
00138 
00139         function _updateParticipation($a_usr_id,$a_event_id,$a_status)
00140         {
00141                 global $ilDB;
00142 
00143                 $query = "SELECT * FROM event_participants ".
00144                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00145                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00146                 $res = $ilDB->query($query);
00147                 if($res->numRows())
00148                 {
00149                         $query = "UPDATE event_participants ".
00150                                 "SET participated = ".$ilDB->quote($a_status)." ".
00151                                 "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00152                                 "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00153                         $ilDB->query($query);
00154                 }
00155                 else
00156                 {
00157                         $query = "INSERT INTO event_participants ".
00158                                 "SET registered = '0', ".
00159                                 "participated = ".$ilDB->quote($a_status).", ".
00160                                 "event_id = ".$ilDB->quote($a_event_id).", ".
00161                                 "usr_id = ".$ilDB->quote($a_usr_id)." ";
00162                         $ilDB->query($query);
00163                 }
00164                 return true;
00165         }
00166 
00167         function _getRegistered($a_event_id)
00168         {
00169                 global $ilDB;
00170 
00171                 $query = "SELECT * FROM event_participants ".
00172                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00173                         "AND registered = '1'";
00174                 $res = $ilDB->query($query);
00175                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00176                 {
00177                         $user_ids[] = $row->usr_id;
00178                 }
00179                 return $user_ids ? $user_ids : array();
00180         }
00181 
00182         function _getParticipated($a_event_id)
00183         {
00184                 global $ilDB;
00185 
00186                 $query = "SELECT * FROM event_participants ".
00187                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00188                         "AND participated = '1'";
00189                 $res = $ilDB->query($query);
00190                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00191                 {
00192                         $user_ids[] = $row->usr_id;
00193                 }
00194                 return $user_ids ? $user_ids : array();
00195         }
00196 
00197         function _isRegistered($a_usr_id,$a_event_id)
00198         {
00199                 global $ilDB;
00200 
00201                 $query = "SELECT * FROM event_participants ".
00202                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00203                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00204                 $res = $ilDB->query($query);
00205                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00206                 {
00207                         return (bool) $row->registered;
00208                 }
00209                 return false;
00210         }
00211 
00212         function _register($a_usr_id,$a_event_id)
00213         {
00214                 global $ilDB;
00215 
00216                 $query = "SELECT * FROM event_participants ".
00217                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00218                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00219                 $res = $ilDB->query($query);
00220                 if($res->numRows())
00221                 {
00222                         $query = "UPDATE event_participants ".
00223                                 "SET registered = '1' ".
00224                                 "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00225                                 "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00226                         $ilDB->query($query);
00227                 }
00228                 else
00229                 {
00230                         $query = "INSERT INTO event_participants ".
00231                                 "SET registered = '1', ".
00232                                 "participated = '0', ".
00233                                 "event_id = ".$ilDB->quote($a_event_id).", ".
00234                                 "usr_id = ".$ilDB->quote($a_usr_id)." ";
00235                         $ilDB->query($query);
00236                 }
00237                 return true;
00238         }
00239         function register($a_usr_id)
00240         {
00241                 return ilEventParticipants::_register($a_usr_id,$this->getEventId());
00242         }
00243                         
00244         function _unregister($a_usr_id,$a_event_id)
00245         {
00246                 global $ilDB;
00247 
00248                 $query = "SELECT * FROM event_participants ".
00249                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00250                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00251                 $res = $ilDB->query($query);
00252                 if($res->numRows())
00253                 {
00254                         $query = "UPDATE event_participants ".
00255                                 "SET registered = '0' ".
00256                                 "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00257                                 "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00258                         $ilDB->query($query);
00259                 }
00260                 else
00261                 {
00262                         $query = "INSERT INTO event_participants ".
00263                                 "SET registered = '0', ".
00264                                 "participated = '0' ".
00265                                 "event_id = ".$ilDB->quote($a_event_id).", ".
00266                                 "usr_id = ".$ilDB->quote($a_usr_id)." ";
00267                         $ilDB->query($query);
00268                 }
00269                 return true;
00270         }
00271         function unregister($a_usr_id)
00272         {
00273                 return ilEventParticipants::_unregister($a_usr_id,$this->getEventId());
00274         }
00275 
00276         function _lookupMark($a_event_id,$a_usr_id)
00277         {
00278                 global $ilDB;
00279 
00280                 $query = "SELECT * FROM event_participants ".
00281                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00282                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00283                 $res = $ilDB->query($query);
00284                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00285                 {
00286                         return $row->mark;
00287                 }
00288                 return '';
00289         }
00290         
00291         function _lookupComment($a_event_id,$a_usr_id)
00292         {
00293                 global $ilDB;
00294 
00295                 $query = "SELECT * FROM event_participants ".
00296                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ".
00297                         "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00298                 $res = $ilDB->query($query);
00299                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00300                 {
00301                         return $row->comment;
00302                 }
00303                 return '';
00304         }
00305 
00306 
00307         function getEventId()
00308         {
00309                 return $this->event_id;
00310         }
00311         function setEventId($a_event_id)
00312         {
00313                 $this->event_id = $a_event_id;
00314         }
00315 
00316         function _deleteByEvent($a_event_id)
00317         {
00318                 global $ilDB;
00319 
00320                 $query = "DELETE FROM event_participants ".
00321                         "WHERE event_id = ".$ilDB->quote($a_event_id)." ";
00322                 $ilDB->query($query);
00323                 return true;
00324         }
00325         function _deleteByUser($a_usr_id)
00326         {
00327                 global $ilDB;
00328                 
00329                 $query = "DELETE FROM event_participants ".
00330                         "WHERE usr_id = ".$ilDB->quote($a_usr_id)." ";
00331                 $ilDB->query($query);
00332                 return true;
00333         }
00334 
00335 
00336         // Private
00337         function __read()
00338         {
00339                 global $ilDB;
00340                 
00341                 $query = "SELECT * FROM event_participants ".
00342                         "WHERE event_id = ".$ilDB->quote($this->getEventId())." ";
00343                 $res = $this->db->query($query);
00344                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00345                 {
00346                         $this->participants[$row->usr_id]['usr_id'] = $row->usr_id;
00347                         $this->participants[$row->usr_id]['registered'] = $row->registered;
00348                         $this->participants[$row->usr_id]['participated'] = $row->participated;
00349                         $this->participants[$row->usr_id]['mark'] = $row->mark;
00350                         $this->participants[$row->usr_id]['comment'] = $row->comment;
00351                 }
00352         }
00353 }
00354 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1