root/trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php @ 938

Revision 938, 25.3 KB (checked in by max-horvath, 7 years ago)

"2006-02-04 Max Horvath <max.horvath@…>

  • MainUI class now uses Smarty templates to render HTML pages
  • display of debug messages by using $_REQUESTdebug_request? on any page is now only possible for a super admin
  • caching class now supports lifetime of a cache and every data type supported by PHP (except the resource-type)
  • Content class caches available content plugins for 7 days if caching has been enabled -> results in a nice speed-up on every page call because of 17 saved filesystem queries
  • converted Security class to PHP5 style and it's functions to static functions
  • fixed broken HTMLeditor support
  • implemented PEAR::HTML_Safe cache support - if PEAR::HTML_Safe has been installed it strips down all potentially dangerous content within HTML that has been entered using the content plugins Langstring, TrivialLangstring? and HTMLeditor
  • moved /wifidog/include/HTMLeditor to /wifidog/content/HTMLeditor
  • fixed thrown exception in path_defines_base.php (sprintf() was used uncorrectly)
  • template for definition of SYSTEM_PATH has been added to config.php for easier definiton when path detection failes
  • from now on caching is enabled by default in config.php - it means that WiFiDog caching features will automaticly be used if PEAR::Cache_Lite has been installed"
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5// +-------------------------------------------------------------------+
6// | WiFiDog Authentication Server                                     |
7// | =============================                                     |
8// |                                                                   |
9// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10// | portal suite.                                                     |
11// +-------------------------------------------------------------------+
12// | PHP version 5 required.                                           |
13// +-------------------------------------------------------------------+
14// | Homepage:     http://www.wifidog.org/                             |
15// | Source Forge: http://sourceforge.net/projects/wifidog/            |
16// +-------------------------------------------------------------------+
17// | This program is free software; you can redistribute it and/or     |
18// | modify it under the terms of the GNU General Public License as    |
19// | published by the Free Software Foundation; either version 2 of    |
20// | the License, or (at your option) any later version.               |
21// |                                                                   |
22// | This program is distributed in the hope that it will be useful,   |
23// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25// | GNU General Public License for more details.                      |
26// |                                                                   |
27// | You should have received a copy of the GNU General Public License |
28// | along with this program; if not, contact:                         |
29// |                                                                   |
30// | Free Software Foundation           Voice:  +1-617-542-5942        |
31// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33// |                                                                   |
34// +-------------------------------------------------------------------+
35
36/**
37 * @package    WiFiDogAuthServer
38 * @subpackage ContentClasses
39 * @author     Benoit Gregoire <bock@step.polymtl.ca>
40 * @copyright  2004-2006 Benoit Gregoire, Technologies Coeus inc.
41 * @version    Subversion $Id$
42 * @link       http://www.wifidog.org/
43 */
44
45/**
46 * Load required classes
47 */
48require_once('classes/Cache.php');
49require_once('classes/HtmlSafe.php');
50require_once('classes/LocaleList.php');
51
52
53/**
54 * Représente un Langstring en particulier, ne créez pas un objet langstrings
55 * si vous n'en avez pas spécifiquement besoin
56 *
57 * @package    WiFiDogAuthServer
58 * @subpackage ContentClasses
59 * @author     Benoit Gregoire <bock@step.polymtl.ca>
60 * @copyright  2004-2006 Benoit Gregoire, Technologies Coeus inc.
61 */
62class Langstring extends Content {
63    /**
64     * HTML allowed to be used
65     */
66    const ALLOWED_HTML_TAGS = "<a><br><b><h1><h2><h3><h4><i><img><li><ol><p><strong><u><ul><li>";
67
68    /**
69     * Constructor
70     *
71     * @param string $content_id Content id
72     *
73     * @access public
74     */
75    public function __construct($content_id)
76    {
77        // Define globals
78        global $db;
79
80        parent::__construct($content_id);
81        $this->mBd = &$db;
82    }
83
84    /**
85     * Retourne la première chaîne disponible dans la langue par défaut de
86     * l'usager (si disponible), sinon dans la même langue majeure, sinon
87     * la première chaîne disponible
88     *
89     * @return string Chaîne UTF-8 retournée
90     *
91     * @access public
92     */
93    public function getString()
94    {
95        // Init values
96        $retval = null;
97        $row = null;
98        $_useCache = false;
99        $_cachedData = null;
100
101        // Create new cache objects
102        $_cacheLanguage = new Cache('langstrings_' . $this->id . '_substring_' . substr(Locale :: getCurrentLocale()->getId(), 0, 2) . '_string', $this->id);
103        $_cache = new Cache('langstrings_' . $this->id . '_substring__string', $this->id);
104
105        // Check if caching has been enabled.
106        if ($_cacheLanguage->isCachingEnabled) {
107            if ($_cachedData = $_cacheLanguage->getCachedData()) {
108                // Return cached data.
109                $_useCache = true;
110                $retval = $_cachedData;
111            } else {
112                // Language specific cached data has not been found.
113                // Try to get language independent cached data.
114                if ($_cachedData = $_cache->getCachedData()) {
115                    // Return cached data.
116                    $_useCache = true;
117                    $retval = $_cachedData;
118                }
119            }
120        }
121
122        if (!$_useCache) {
123            //Get user's prefered language
124            $sql = "SELECT value, locales_id, \n";
125            $sql .= Locale :: getSqlCaseStringSelect(Locale :: getCurrentLocale()->getId());
126            $sql .= " as score FROM langstring_entries WHERE langstring_entries.langstrings_id = '{$this->id}' AND value!='' ORDER BY score LIMIT 1";
127            $this->mBd->execSqlUniqueRes($sql, $row, false);
128
129            if ($row == null) {
130                $retval = "(Langstring vide)";
131            } else {
132                $retval = $row['value'];
133
134                // Check if caching has been enabled.
135                if ($_cache->isCachingEnabled) {
136                    // Save data into cache, because it wasn't saved into cache before.
137                    $_cache->saveCachedData($retval);
138                }
139            }
140        }
141
142        return $retval;
143    }
144
145    /**
146     * Ajoute une chaîne de caractère au Langstring
147     *
148     * @param string $string             La chaîne de caractère à ajouter.  Si la chaîne
149     *                                   est vide ('') ou null, la fonction retourne sans
150     *                                   toucher à la base de donnée
151     * @param string $locale             La langue régionale de la chaîne ajoutée, exemple:
152     *                                   'fr_CA', peut être NULL
153     * @param bool   $allow_empty_string Allow to store an empty string
154     *
155     * @return bool True si une chaîne a été ajoutée à la base de donnée,
156     * false autrement.
157     *
158     * @access public
159     */
160    public function addString($string, $locale, $allow_empty_string = false)
161    {
162        // Init values
163        $retval = false;
164        $id = 'NULL';
165        $idSQL = $id;
166
167        if ($locale) {
168            $language = new Locale($locale);
169            $id = $language->GetId();
170            $idSQL = "'".$id."'";
171        }
172
173        if ($allow_empty_string || ($string != null && $string != '')) {
174            $string = $this->mBd->escapeString($string);
175            $this->mBd->execSqlUpdate("INSERT INTO langstring_entries (langstring_entries_id, langstrings_id, locales_id, value) VALUES ('".get_guid()."', '$this->id', $idSQL , '$string')", FALSE);
176
177            // Create new cache object.
178            $_cache = new Cache('langstrings_' . $this->id . '_substring_' .  $id . '_string', $this->id);
179
180            // Check if caching has been enabled.
181            if ($_cache->isCachingEnabled) {
182                // Remove old cached data.
183                $_cache->eraseCachedData();
184
185                // Save data into cache.
186                $_cache->saveCachedData($string);
187            }
188
189            $retval = true;
190        }
191
192        return $retval;
193    }
194
195    /**
196     * Updates the string associated with the locale
197     *
198     * @param string $string La chaîne de caractère à ajouter. Si la chaîne
199     *                       est vide ('') ou null, la fonction retourne
200     *                       sans toucher à la base de donnée
201     * @param string $locale La langue régionale de la chaîne ajoutée,
202     *                       exemple: 'fr_CA', peut être NULL
203     *
204     * @return bool True si une chaîne a été ajoutée à la base de donnée, false autrement.
205     *
206     * @access public
207     */
208    public function UpdateString($string, $locale)
209    {
210        // Init values
211        $retval = false;
212        $id = 'NULL';
213        $row = null;
214
215        if ($locale) {
216            $language = new Locale($locale);
217            $id = $language->GetId();
218            $idSQL = "'" . $id . "'";
219        }
220
221        if ($string != null && $string != '') {
222            $string = $this->mBd->escapeString($string);
223            // If the update returns 0 ( no update ), try inserting the record
224            $this->mBd->execSqlUniqueRes("SELECT * FROM langstring_entries WHERE locales_id = $idSQL AND langstrings_id = '$this->id'", $row, false);
225
226            if ($row != null) {
227                $this->mBd->execSqlUpdate("UPDATE langstring_entries SET value = '$string' WHERE langstrings_id = '$this->id' AND locales_id = $idSQL", false);
228
229                // Create new cache object.
230                $_cache = new Cache('langstrings_' . $this->id . '_substring_' .  $id . '_string', $this->id);
231
232                // Check if caching has been enabled.
233                if ($_cache->isCachingEnabled) {
234                    // Remove old cached data.
235                    $_cache->eraseCachedData();
236
237                    // Save data into cache.
238                    $_cache->saveCachedData($string);
239                }
240            } else {
241                $this->addString($string, $locale);
242            }
243
244            $retval = true;
245        }
246
247        return $retval;
248    }
249
250    /**
251     * Affiche l'interface d'administration de l'objet
252     *
253     * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE
254     *                               pour voir toutes les chaînes, LARGE pour
255     *                               avoir un textarea.
256     * @param int    $num_nouveau    Nombre de champ à afficher pour entrer de
257     *                               nouvelles chaîne en une seule opération
258     *
259     * @return string HTML code of administration interface
260     *
261     * @access public
262     */
263    public function getAdminUI($type_interface = "LARGE", $num_nouveau = 1)
264    {
265        // Init values.
266        $html = '';
267        $result = "";
268        //$variantsCounter = 0;
269        //$_hideNewContent = false;
270
271        $html .= "<div class='admin_class'>Langstring (".get_class($this)." instance)</div>\n";
272        $html .= "<div class='admin_section_container'>\n";
273
274        $html .= _("Only these HTML tags are allowed : ").htmlentities(self :: ALLOWED_HTML_TAGS);
275
276        $liste_languages = new LocaleList();
277        $sql = "SELECT * FROM langstring_entries WHERE langstring_entries.langstrings_id = '$this->id' ORDER BY locales_id";
278        $this->mBd->execSql($sql, $result, FALSE); //echo "type_interface: $type_interface\n";
279
280        $html .= "<ul class='admin_section_list'>\n";
281
282        if ($result != null) {
283            while (list ($key, $value) = each($result)) {
284//                The next lines are a preview of a new suggested input mode
285//                ==========================================================
286//
287//                // Increase variants counter
288//                $variantsCounter++;
289//
290//                // Hide new content input
291//                $_hideNewContent = true;
292//
293//                $html .= "<li class='admin_section_list_item'>\n";
294//                $html .= "<div class='admin_section_data'>\n";
295//
296//                if ($type_interface == 'LARGE') {
297//                    $html .= "<textarea name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' cols='60' rows='3'>".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."</textarea>\n";
298//                } else {
299//                    $html .= "<input type='text' name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' size='44' value='".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."'>\n";
300//                }
301//
302//                $html .= "<div class='admin_section_data' id='langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section' style='display: none;'>\n";
303//                $html .= $liste_languages->GenererFormSelect("$value[locales_id]", "langstrings_".$this->id."_substring_$value[langstring_entries_id]_language", 'Langstring::AfficherInterfaceAdmin', TRUE);
304//                $html .= "</div>\n";
305//
306//                $html .= "</div>\n";
307//                $html .= "<div class='admin_section_tools'>\n";
308//                $name = "langstrings_".$this->id."_substring_$value[langstring_entries_id]_erase";
309//
310//                // Choose language button
311//                $html .= "<a href='javascript:showHideView(\"langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section\", \"langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section_image\");'><img src='" . BASE_SSL_PATH . "images/icons/language.gif' id='langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section_image' class='admin_section_button' alt='"._("Choose language")."' title='"._("Choose language")."'></a>";
312//
313//                // Add string button
314//                if (count($result) == $variantsCounter) {
315//                    // This is the last string variant - show "add string" button.
316//                    $html .= "<a href='javascript:showHideView(\"langstrings_".$this->id."_add_new_entry_view\", \"langstrings_".$this->id."_add_new_entry_image\");'><img src='" . BASE_SSL_PATH . "images/icons/add.gif' id='langstrings_".$this->id."_add_new_entry_image' class='admin_section_button' alt='"._("Add new string")."' title='"._("Add new string")."'></a>";
317//                } else {
318//                    $html .= "<img src='" . BASE_SSL_PATH . "images/icons/add.gif' id='langstrings_".$this->id."_add_new_entry_image' class='admin_section_button_disabled' alt='"._("Add new string")."' title='"._("Add new string")."'>";
319//                }
320//
321//                // Delete string button
322//                $html .= "<input type='image' name='$name' class='admin_section_button' src='" . BASE_SSL_PATH . "images/icons/delete.gif' alt='"._("Delete string")."' title='"._("Delete string")."'>";
323//
324//                $html .= "</div>\n";
325//                $html .= "</li>\n";
326
327                $html .= "<li class='admin_section_list_item'>\n";
328                $html .= "<div class='admin_section_data'>\n";
329
330                $html .= $liste_languages->GenererFormSelect("$value[locales_id]", "langstrings_".$this->id."_substring_$value[langstring_entries_id]_language", 'Langstring::AfficherInterfaceAdmin', TRUE);
331
332                if ($type_interface == 'LARGE') {
333                    $html .= "<textarea name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' cols='60' rows='3'>".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."</textarea>\n";
334                } else {
335                    $html .= "<input type='text' name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' size='44' value='".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."'>\n";
336                }
337
338                $html .= "</div>\n";
339                $html .= "<div class='admin_section_tools'>\n";
340
341                $name = "langstrings_".$this->id."_substring_$value[langstring_entries_id]_erase";
342
343                $html .= "<input type='submit' name='$name' value='"._("Delete string")."'>";
344                $html .= "</div>\n";
345                $html .= "</li>\n";
346            }
347        }
348
349//        The next lines are a preview of a new suggested input mode
350//        ==========================================================
351//
352//        //Nouvelles chaîne
353//        $locale = LocaleList :: GetDefault();
354//
355//        $html .= "<li class='admin_section_list_item' id='langstrings_".$this->id."_add_new_entry_view'" . ($_hideNewContent ? " style='display: none;'" : "") . ">\n";
356//        $html .= "<div class='admin_section_data'>\n";
357//
358//        $new_substring_name = "langstrings_".$this->id."_substring_new_string";
359//
360//        if ($type_interface == 'LARGE') {
361//            $html .= "<textarea name='$new_substring_name' cols='60' rows='3'></textarea>\n";
362//        } else {
363//            $html .= "<input type='text' name='$new_substring_name' size='44' value=''>\n";
364//        }
365//
366//        $html .= "<div class='admin_section_data' id='langstrings_".$this->id."_substring_new_language_section'>\n";
367//        $html .= "<img src='" . BASE_SSL_PATH . "images/icons/language.gif' id='langstrings_".$this->id."_substring_new_language_section_image' class='admin_section_button' alt='"._("Choose language")."' title='"._("Choose language")."'>";
368//        $html .= $liste_languages->GenererFormSelect($locale, "langstrings_".$this->id."_substring_new_language", 'Langstring::AfficherInterfaceAdmin', TRUE);
369//        $html .= "</div>\n";
370//
371//        $html .= "</div>\n";
372//        $html .= "<div class='admin_section_tools'>\n";
373//
374//        $new_substring_submit_name = "langstrings_".$this->id."_add_new_entry";
375//
376//        // Add string button
377//        $html .= "<input type='image' name='$new_substring_submit_name' class='admin_section_button' src='" . BASE_SSL_PATH . "images/icons/add.gif' alt='"._("Add new string")."' title='"._("Add new string")."'>";
378//
379//        $html .= "</div>\n";
380//        $html .= "</li>\n";
381//
382//        $html .= "</ul>\n";
383//        $html .= "</div>\n";
384
385        //Nouvelles chaîne
386        $locale = LocaleList :: GetDefault();
387        $html .= "<li class='admin_section_list_item'>\n";
388        $html .= "<div class='admin_section_data'>\n";
389
390        $html .= $liste_languages->GenererFormSelect($locale, "langstrings_".$this->id."_substring_new_language", 'Langstring::AfficherInterfaceAdmin', TRUE);
391        $new_substring_name = "langstrings_".$this->id."_substring_new_string";
392
393        if ($type_interface == 'LARGE') {
394            $html .= "<textarea name='$new_substring_name' cols='60' rows='3'></textarea>\n";
395        } else {
396            $html .= "<input type='text' name='$new_substring_name' size='44' value=''>\n";
397        }
398
399        $html .= "</div>\n";
400        $html .= "<div class='admin_section_tools'>\n";
401
402        $new_substring_submit_name = "langstrings_".$this->id."_add_new_entry";
403
404        $html .= "<input type='submit' name='$new_substring_submit_name' value='"._("Add new string")."'>";
405        $html .= "</div>\n";
406        $html .= "</li>\n";
407
408        $html .= "</ul>\n";
409        $html .= "</div>\n";
410
411        return parent :: getAdminUI($html);
412    }
413
414    /**
415     * Processes the input of the administration interface for Langstring
416     *
417     * @return void
418     *
419     * @access public
420     */
421    public function processAdminUI()
422    {
423        // Init values.
424        $result = null;
425
426        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) {
427            parent :: processAdminUI();
428            $generateur_form_select = new FormSelectGenerator();
429            $sql = "SELECT * FROM langstring_entries WHERE langstring_entries.langstrings_id = '$this->id'";
430            $this->mBd->execSql($sql, $result, FALSE);
431
432            if ($result != null) {
433                while (list ($key, $value) = each($result)) {
434                    $language = $generateur_form_select->getResult("langstrings_".$this->id."_substring_$value[langstring_entries_id]_language", 'Langstring::AfficherInterfaceAdmin');
435
436                    if (empty ($language)) {
437                        $language = '';
438                        $languageSQL = 'NULL';
439                    } else {
440                        $languageSQL = "'".$language."'";
441                    }
442
443                    if (!empty ($_REQUEST["langstrings_".$this->id."_substring_$value[langstring_entries_id]_erase"]) && $_REQUEST["langstrings_".$this->id."_substring_$value[langstring_entries_id]_erase"] == true) {
444                        $this->mBd->execSqlUpdate("DELETE FROM langstring_entries WHERE langstrings_id = '$this->id' AND langstring_entries_id='$value[langstring_entries_id]'", FALSE);
445
446                        // Create new cache object.
447                        $_cache = new Cache('langstrings_' . $this->id . '_substring_' .  $language . '_string', $this->id);
448
449                        // Check if caching has been enabled.
450                        if ($_cache->isCachingEnabled) {
451                            // Remove old cached data.
452                            $_cache->eraseCachedData();
453                        }
454                    } else {
455                        // Strip HTML tags !
456                        $string = $_REQUEST["langstrings_".$this->id."_substring_$value[langstring_entries_id]_string"];
457                        $string = $this->mBd->escapeString(strip_tags($string, self :: ALLOWED_HTML_TAGS));
458
459                        // If PEAR::HTML_Safe is available strips down all potentially dangerous content
460                        $_HtmlSafe = new HtmlSafe();
461
462                        if ($_HtmlSafe->isHtmlSafeEnabled) {
463                            // Add "embed" and "object" to the default set of dangerous tags
464                            $_HtmlSafe->setDeleteTags(array("embed", "object"), true);
465
466                            // Strip HTML
467                            $string = $_HtmlSafe->parseHtml($string);
468                        }
469
470                        $this->mBd->execSqlUpdate("UPDATE langstring_entries SET locales_id = $languageSQL , value = '$string' WHERE langstrings_id = '$this->id' AND langstring_entries_id='$value[langstring_entries_id]'", FALSE);
471
472                        // Create new cache object.
473                        $_cache = new Cache('langstrings_' . $this->id . '_substring_' .  $language . '_string', $this->id);
474
475                        // Check if caching has been enabled.
476                        if ($_cache->isCachingEnabled) {
477                            // Remove old cached data.
478                            $_cache->eraseCachedData();
479
480                            // Save data into cache.
481                            $_cache->saveCachedData($string);
482                        }
483                    }
484                }
485            }
486
487            //Ajouter nouvelles chaîne(s) si champ non vide ou si l'usager a appuyé sur le bouton ajouter
488            $new_substring_name = "langstrings_".$this->id."_substring_new_string";
489            $new_substring_submit_name = "langstrings_".$this->id."_add_new_entry";
490
491            if ((isset ($_REQUEST[$new_substring_submit_name]) && $_REQUEST[$new_substring_submit_name] == true) || !empty ($_REQUEST[$new_substring_name])) {
492                $language = $generateur_form_select->getResult("langstrings_".$this->id."_substring_new_language", 'Langstring::AfficherInterfaceAdmin');
493
494                if (empty ($language)) {
495                    $language = null;
496                }
497
498                $this->addString($_REQUEST[$new_substring_name], $language, true);
499            }
500        }
501    }
502
503    /**
504     * Retreives the user interface of this object.
505     *
506     * Anything that overrides this method should call the parent method with
507     * it's output at the END of processing.
508     *
509     * @param string $subclass_admin_interface HTML content of the interface
510     *                                         element of a children
511     *
512     * @return string The HTML fragment for this interface
513     *
514     * @access public
515     */
516    public function getUserUI($subclass_user_interface = null)
517    {
518        // Init values
519        $html = '';
520
521        $html .= "<div class='user_ui_container'>\n";
522        $html .= "<div class='user_ui_object_class'>Langstring (".get_class($this)." instance)</div>\n";
523        $html .= "<div class='langstring'>\n";
524        $html .= $this->getString();
525        $html .= $subclass_user_interface;
526        $html .= "</div>\n";
527        $html .= "</div>\n";
528
529        return parent::getUserUI($html);
530    }
531
532    /**
533     * Reloads the object from the database.
534     *
535     * Should normally be called after a set operation.
536     *
537     * This function is private because calling it from a subclass will call
538     * the constructor from the wrong scope
539     *
540     * @return void
541     *
542     * @access private
543     */
544    private function refresh()
545    {
546        $this->__construct($this->id);
547    }
548
549    /**
550     * Deletes a Langstring object
551     *
552     * @param string $errmsg Reference to error message
553     *
554     * @return bool True if deletion was successful
555     *
556     * @access public
557     * @internal Persistent content will not be deleted
558     */
559    public function delete(&$errmsg)
560    {
561        // Init values.
562        $_retval = false;
563
564        if ($this->isPersistent()) {
565            $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)");
566        } else {
567            global $db;
568
569            if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) {
570                $_sql = "DELETE FROM content WHERE content_id='$this->id'";
571                $db->execSqlUpdate($_sql, false);
572                $_retval = true;
573
574                // Create new cache object.
575                $_cache = new Cache('all', $this->id);
576
577                // Check if caching has been enabled.
578                if ($_cache->isCachingEnabled) {
579                    // Remove old cached data.
580                    $_cache->eraseCachedGroupData();
581                }
582            } else {
583                $errmsg = _("Access denied (not owner of content)");
584            }
585        }
586
587        return $_retval;
588    }
589
590}
591
592/*
593 * Local variables:
594 * tab-width: 4
595 * c-basic-offset: 4
596 * c-hanging-comment-ender-p: nil
597 * End:
598 */
599
600?>
Note: See TracBrowser for help on using the browser.