Location: PHPKode > projects > Maian Gallery > maian_gallery/admin/classes/class_cats.inc.php
<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: hide@address.com
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: class_cats.inc.php
  Description: Category Class

  ++++++++++++++++++++++++++++++++++++++++*/


class cats extends genericOptions {

var $prefix;
var $comments;

// Add category..
function add_cat_sql($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("INSERT INTO ".$this->prefix."categories (
               catname,
               comments,
               keywords,
               description,
               en_cat,
               en_comments,
               en_slideshow,
               en_watermarks,
               parent,
               child,
               folder,
               mp3
               ) VALUES (
               '{$DATA['cat']}',
               '{$DATA['comments']}',
               '{$DATA['keywords']}',
               '{$DATA['description']}',
               '".(isset($DATA['en_cat']) ? '1' : '0')."',
               '".(isset($DATA['en_comments']) ? '1' : '0')."',
               '".(isset($DATA['en_slideshow']) ? '1' : '0')."',
               '".(isset($DATA['en_watermarks']) ? '1' : '0')."',
               '".($DATA['type']=='parent' ? '1' : '0')."',
               '".(ctype_digit($DATA['type']) ? $DATA['type'] : '0')."',
               '".$this->removeTrailingSlash($DATA['folder'])."',
               '{$DATA['mp3']}'
               )") or die(mysql_error());
}

// Update category..
function update_cat_sql($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."categories SET
               catname        = '{$DATA['cat']}',
               comments       = '{$DATA['comments']}',
               keywords       = '{$DATA['keywords']}',
               description    = '{$DATA['description']}',
               en_cat         = '".(isset($DATA['en_cat']) ? '1' : '0')."',
               en_comments    = '".(isset($DATA['en_comments']) ? '1' : '0')."',
               en_slideshow   = '".(isset($DATA['en_slideshow']) ? '1' : '0')."',
               en_watermarks  = '".(isset($DATA['en_watermarks']) ? '1' : '0')."',
               parent         = '".($DATA['type']=='parent' ? '1' : '0')."',
               child          = '".(ctype_digit($DATA['type']) ? $DATA['type'] : '0')."',
               folder         = '".$this->removeTrailingSlash($DATA['folder'])."',
               mp3            = '{$DATA['mp3']}'
               WHERE id       = '{$DATA['edit']}'
               LIMIT 1
               ") or die(mysql_error());
               
  // Update images status for this category..
  mysql_query("UPDATE ".$this->prefix."images SET
               enabled    = '".(isset($DATA['en_cat']) ? '1' : '0')."'
               WHERE cat  = '{$DATA['edit']}'
               ") or die(mysql_error());             
}

// Delete category/children..
function delete_cat_sql($id,$extended=false)
{
  $id = (int)$id;
  
  mysql_query("DELETE FROM ".$this->prefix."categories WHERE id = '{$id}' LIMIT 1") or die(mysql_error());
  
  if ($extended) {
    mysql_query("DELETE FROM ".$this->prefix."categories WHERE child = '{$id}'") or die(mysql_error());
  }
}

}

?>
Return current item: Maian Gallery