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

Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.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 
00034 class ilSurveyPhrases 
00035 {
00043   function ilSurveyPhrases()
00044   {
00045         }
00046         
00056         function &_getAvailablePhrases($useronly = 0)
00057         {
00058                 global $ilUser;
00059                 global $ilDB;
00060                 global $lng;
00061                 
00062                 $phrases = array();
00063     $query = sprintf("SELECT * FROM survey_phrase WHERE defaultvalue = '1' OR owner_fi = %s ORDER BY title",
00064       $ilDB->quote($ilUser->getId())
00065     );
00066     $result = $ilDB->query($query);
00067                 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00068                 {
00069                         if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
00070                         {
00071                                 if (!$useronly)
00072                                 {
00073                                         $phrases[$row->phrase_id] = array(
00074                                                 "title" => $lng->txt($row->title),
00075                                                 "owner" => $row->owner_fi
00076                                         );
00077                                 }
00078                         }
00079                         else
00080                         {
00081                                 if ($ilUser->getId() == $row->owner_fi)
00082                                 {
00083                                         $phrases[$row->phrase_id] = array(
00084                                                 "title" => $row->title,
00085                                                 "owner" => $row->owner_fi
00086                                         );
00087                                 }
00088                         }
00089                 }
00090                 return $phrases;
00091         }
00092         
00102         function &_getCategoriesForPhrase($phrase_id)
00103         {
00104                 global $ilDB;
00105                 global $lng;
00106                 
00107                 $categories = array();
00108     $query = sprintf("SELECT survey_category.* FROM survey_category, survey_phrase_category WHERE survey_phrase_category.category_fi = survey_category.category_id AND survey_phrase_category.phrase_fi = %s ORDER BY survey_phrase_category.sequence",
00109       $ilDB->quote($phrase_id)
00110     );
00111     $result = $ilDB->query($query);
00112                 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00113                 {
00114                         if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
00115                         {
00116                                 $categories[$row->category_id] = $lng->txt($row->title);
00117                         }
00118                         else
00119                         {
00120                                 $categories[$row->category_id] = $row->title;
00121                         }
00122                 }
00123                 return $categories;
00124         }
00125         
00134         function deletePhrases($phrase_array)
00135         {
00136                 global $ilDB;
00137                 
00138                 if ((is_array($phrase_array)) && (count($phrase_array)))
00139                 {
00140                         $query = "DELETE FROM survey_phrase WHERE phrase_id IN ('" . join($phrase_array, "','") . "')";
00141                         $result = $ilDB->query($query);
00142                         $query = "DELETE FROM survey_phrase_category WHERE phrase_fi IN ('" . join($phrase_array, "','") . "')";
00143                         $result = $ilDB->query($query);
00144                 }
00145         }
00146 
00147 }
00148 ?>

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