[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/classes/ -> class.globalcontentoperations.inc.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004-6 by Ted Kulp (ted@cmsmadesimple.org)
   4  #This project's homepage is: http://cmsmadesimple.org
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #BUT withOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  #
  19  #$Id$
  20  
  21  /**
  22   * Class for doing html blob related functions.  Maybe of the HtmlBlob object functions are just wrappers around these.
  23   *
  24   * @since        0.6
  25   * @package        CMS
  26   */
  27  
  28  include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.globalcontent.inc.php');
  29  
  30  class GlobalContentOperations
  31  {
  32  
  33      /**
  34       * Prepares an array with the list of the html blobs $userid is an author of 
  35       *
  36       * @returns an array in whose elements are the IDs of the blobs  
  37       * @since 0.11
  38       */
  39  	function AuthorBlobs($userid)
  40      {
  41          global $gCms;
  42          $db = &$gCms->GetDb();
  43          $variables = &$gCms->variables;
  44          if (!isset($variables['authorblobs']))
  45          {
  46              $db = &$gCms->GetDb();
  47              $variables['authorblobs'] = array();
  48  
  49              $query = "SELECT htmlblob_id FROM ".cms_db_prefix()."additional_htmlblob_users WHERE user_id = ?";
  50              $result = &$db->Execute($query, array($userid));
  51  
  52              while ($result && !$result->EOF)
  53              {
  54                  $variables['authorblobs'][] = $result->fields['htmlblob_id'];
  55                  $result->MoveNext();
  56              }
  57          }
  58  
  59          return $variables['authorblobs'];
  60      }
  61  
  62  	function LoadHtmlBlobs()
  63      {
  64          global $gCms;
  65          $db = &$gCms->GetDb();
  66  
  67          $result = array();
  68  
  69          $query = "SELECT htmlblob_id, htmlblob_name, html, owner, modified_date FROM ".cms_db_prefix()."htmlblobs ORDER BY htmlblob_name";
  70          $dbresult = &$db->Execute($query);
  71  
  72          while (isset($dbresult) && !$dbresult->EOF)
  73          {
  74              $oneblob = new GlobalContent();
  75              $oneblob->id = $dbresult->fields['htmlblob_id'];
  76              $oneblob->name = $dbresult->fields['htmlblob_name'];
  77              $oneblob->content = $dbresult->fields['html'];
  78              $oneblob->owner = $dbresult->fields['owner'];
  79              $oneblob->modified_date = $db->UnixTimeStamp($dbresult->fields['modified_date']);
  80              $result[] = $oneblob;
  81              $dbresult->MoveNext();
  82          }
  83  
  84          return $result;
  85      }
  86  
  87  	function LoadHtmlBlobByID($id)
  88      {
  89          $result = false;
  90  
  91          global $gCms;
  92          $db = &$gCms->GetDb();
  93  
  94          $query = "SELECT htmlblob_id, htmlblob_name, html, owner, modified_date FROM ".cms_db_prefix()."htmlblobs WHERE htmlblob_id = ?";
  95          $row = &$db->GetRow($query, array($id));
  96  
  97          if ($row)
  98          {
  99              $oneblob = new GlobalContent();
 100              $oneblob->id = $row['htmlblob_id'];
 101              $oneblob->name = $row['htmlblob_name'];
 102              $oneblob->content = $row['html'];
 103              $oneblob->owner = $row['owner'];
 104              $oneblob->modified_date = $db->UnixTimeStamp($row['modified_date']);
 105              $result =& $oneblob;
 106          }
 107  
 108          return $result;
 109      }
 110  
 111      function &LoadHtmlBlobByName($name)
 112      {
 113          $result = false;
 114  
 115          global $gCms;
 116          $db = &$gCms->GetDb();
 117          $gcbops =& $gCms->GetGlobalContentOperations();
 118          $cache = &$gCms->HtmlBlobCache;
 119  
 120          if (isset($cache[$name]))
 121          {
 122              return $cache[$name];
 123          }
 124  
 125          $query = "SELECT htmlblob_id, htmlblob_name, html, owner, modified_date FROM ".cms_db_prefix()."htmlblobs WHERE htmlblob_name = ?";
 126          $row = &$db->GetRow($query, array($name));
 127  
 128          if ($row)
 129          {
 130              $oneblob = new GlobalContent();
 131              $oneblob->id = $row['htmlblob_id'];
 132              $oneblob->name = $row['htmlblob_name'];
 133              $oneblob->content = $row['html'];
 134              $oneblob->owner = $row['owner'];
 135              $oneblob->modified_date = $db->UnixTimeStamp($row['modified_date']);
 136              $result =& $oneblob;
 137  
 138              if (!isset($cache[$oneblob->name]))
 139              {
 140                  $cache[$oneblob->name] =& $oneblob;
 141              }
 142          }
 143  
 144          return $result;
 145      }
 146  
 147  	function InsertHtmlBlob($htmlblob)
 148      {
 149          $result = -1; 
 150  
 151          global $gCms;
 152          $db = &$gCms->GetDb();
 153  
 154          $new_htmlblob_id = $db->GenID(cms_db_prefix()."htmlblobs_seq");
 155          $time = $db->DBTimeStamp(time());
 156          $query = "INSERT INTO ".cms_db_prefix()."htmlblobs (htmlblob_id, htmlblob_name, html, owner, create_date, modified_date) VALUES (?,?,?,?,".$time.",".$time.")";
 157          $dbresult = $db->Execute($query, array($new_htmlblob_id, $htmlblob->name, $htmlblob->content, $htmlblob->owner));
 158          if ($dbresult !== false)
 159          {
 160              $result = $new_htmlblob_id;
 161          }
 162  
 163          return $result;
 164      }
 165  
 166  	function UpdateHtmlBlob($htmlblob)
 167      {
 168          $result = false; 
 169  
 170          global $gCms;
 171          $db = &$gCms->GetDb();
 172  
 173          $time = $db->DBTimeStamp(time());
 174          $query = "UPDATE ".cms_db_prefix()."htmlblobs SET htmlblob_name = ?, html = ?, owner = ?, modified_date = ".$time." WHERE htmlblob_id = ?";
 175          $dbresult = $db->Execute($query,array($htmlblob->name,$htmlblob->content,$htmlblob->owner,$htmlblob->id));
 176          if ($dbresult !== false)
 177          {
 178              $result = true;
 179          }
 180  
 181          return $result;
 182      }
 183  
 184  	function DeleteHtmlBlobByID($id)
 185      {
 186          $result = false;
 187  
 188          global $gCms;
 189          $db = &$gCms->GetDb();
 190  
 191          $query = "DELETE FROM ".cms_db_prefix()."htmlblobs where htmlblob_id = ?";
 192          $dbresult = $db->Execute($query,array($id));
 193  
 194          if ($dbresult !== false)
 195          {
 196              $result = true;
 197              remove_cross_references_by_child($id, 'global_content');
 198          }
 199  
 200          return $result;
 201      }
 202  
 203  	function CheckExistingHtmlBlobName($name)
 204      {
 205          $result = false;
 206  
 207          global $gCms;
 208          $db = &$gCms->GetDb();
 209  
 210          $query = "SELECT htmlblob_id from ".cms_db_prefix()."htmlblobs WHERE htmlblob_name = ?";
 211          $row = &$db->GetRow($query,array($name));
 212  
 213          if ($row)
 214          {
 215              $result = true; 
 216          }
 217  
 218          return $result;
 219      }
 220  
 221  	function CheckOwnership($id, $user_id)
 222      {
 223          $result = false;
 224  
 225          global $gCms;
 226          $db = &$gCms->GetDb();
 227  
 228          $query = "SELECT htmlblob_id FROM ".cms_db_prefix()."htmlblobs WHERE htmlblob_id = ? AND owner = ?";
 229          $row = &$db->GetRow($query, array($id, $user_id));
 230  
 231          if ($row)
 232          {
 233              $result = true;
 234          }
 235  
 236          return $result;
 237      }
 238  
 239  	function CheckAuthorship($id, $user_id)
 240      {        
 241          global $gCms;
 242          $db = &$gCms->GetDb();
 243          $result = false;
 244  
 245          $query = "SELECT additional_htmlblob_users_id FROM ".cms_db_prefix()."additional_htmlblob_users WHERE htmlblob_id = ? AND user_id = ?";
 246          $row = &$db->GetRow($query, array($id, $user_id));
 247  
 248          if ($row)
 249          {
 250              $result = true;
 251          }
 252  
 253          return $result;
 254      }
 255  
 256  	function ClearAdditionalEditors($id)
 257      {
 258          global $gCms;
 259          $db = &$gCms->GetDb();
 260  
 261          $query = "DELETE FROM ".cms_db_prefix()."additional_htmlblob_users WHERE htmlblob_id = ?";
 262  
 263          $dbresult = $db->Execute($query, array($id));
 264      }
 265  
 266  	function InsertAdditionalEditors($id, $user_id)
 267      {
 268          global $gCms;
 269          $db = &$gCms->GetDb();
 270  
 271          $new_id = $db->GenID(cms_db_prefix()."additional_htmlblob_users_seq");
 272          $query = "INSERT INTO ".cms_db_prefix()."additional_htmlblob_users (additional_htmlblob_users_id, htmlblob_id, user_id) VALUES (?,?,?)";
 273          $dbresult = $db->Execute($query, array($new_id,$id,$user_id));
 274      }
 275  }
 276  
 277  class HtmlBlobOperations extends GlobalContentOperations
 278  {
 279  }
 280  
 281  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7