You are not logged in! If you have not registered yet then click here to join the community!

TOLRA Community Forums


Go Back   TOLRA Community Forums > TOLRA Products (PHP Scripts) > Web Directory Script > Directory Script Mods

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 16-01-2010, 05:03 PM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
I've not tested it, but if you replace the contents of plus2desc.php with the following then it should work only for the admin user with no trace of the information on the public area.
PHP Code:
<?php

/**
 * Extension to add 2 extra description fields to each listing.
 *
 * - Data is stored in the table plus2desc
 * - The template variables {$plus2desc1} and {$plus2desc2} need to be placed on t!wddetail.html
 *
 * Copyright (c) 2008 - 2010 TOLRA Micro Systems Limited. All rights reserved.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

define('PLUS2DESCLENGTH'4096);

class 
plus2desc {

    var 
$fields = array();

    
/**
     * Create the extra fields for the new listing.
     *
     * @param array $data Event data
     */
    
function listing_added($data) {
        global 
$g_queryCount;
        
$g_queryCount++;
        
mysql_query("INSERT INTO " $data['dirclient']->prefix "plus2desc (id) VALUES('" $data['id'] . "')"$data['dirclient']->dbLink);
    }

    
/**
     * Delete the extra fields for the deleted listing.
     *
     * @param array $data Event data
     */
    
function listing_deleted($data) {
        global 
$g_queryCount;
        
$g_queryCount++;
        
mysql_query("DELETE FROM " $data['dirclient']->prefix "plus2desc WHERE id='" $data['id'] . "'"$data['dirclient']->dbLink);
    }

    
/**
     * Load the extra fields from the database into the object
     *
     * @param array $data Event data
     */
    
function fields_load($data) {
        global 
$g_queryCount;
        
$g_queryCount++;
        
$result mysql_query("SELECT desc1,desc2 FROM " $data['dirclient']->prefix "plus2desc WHERE id='" $data['id'] . "'"$data['dirclient']->dbLink);
        
$this->fields mysql_fetch_assoc($result);
        
mysql_free_result($result);
    }

    
/**
     * Draw the extra input fields.
     *
     * @param array $data Event data
     */
    
function fields_draw($data) {
        
// If 1st call initialise data
        
if(is_null($data['fields'])) {
            
$this->fields['desc1'] = $this->fields['desc2'] = '';

            
// If editing load data from db
            
if($data['id'])
                
$this->fields_load($data);
        }
        
// Save data submitted
        
else if($data['mode'] == 'admin') {
            if(isset(
$data['fields']['ExtraDescription1'])) $this->fields['desc1'] = bbcodeXHTML::BtoX(preg_replace("/(\r\n)|\n|\s{2,}/"' 'trim($data['fields']['ExtraDescription1'])));
            if(isset(
$data['fields']['ExtraDescription2'])) $this->fields['desc2'] = bbcodeXHTML::BtoX(preg_replace("/(\r\n)|\n|\s{2,}/"' 'trim($data['fields']['ExtraDescription2'])));
        }
    
        if(
$data['mode'] == 'admin') {
    
?>
            <tr>
                <td><label for="Extra_Description_1__txt_max<?php echo PLUS2DESCLENGTH?>">Extra Description 1:</label></td>
                <td><textarea name="Extra_Description_1__txt_max<?php echo PLUS2DESCLENGTH?>" id="Extra_Description_1__txt_max<?php echo PLUS2DESCLENGTH?>" rows="8" cols="50" tabindex="<?php echo $data['tabindex']++; ?>"><?php echo afHTMLChars(bbcodeXHTML::XtoB($this->fields['desc1'])); ?></textarea></td>
            </tr>
            <tr>
                <td><label for="Extra_Description_2__txt_max<?php echo PLUS2DESCLENGTH?>">Extra Description 2:</label></td>
                <td><textarea name="Extra_Description_2__txt_max<?php echo PLUS2DESCLENGTH?>" id="Extra_Description_2__txt_max<?php echo PLUS2DESCLENGTH?>" rows="8" cols="50" tabindex="<?php echo $data['tabindex']++; ?>"><?php echo afHTMLChars(bbcodeXHTML::XtoB($this->fields['desc2'])); ?></textarea></td>
            </tr>
    <?php
        
}
    }

    
/**
     * Store the current fields into the database.
     *
     * @param array $data Event data
     */
    
function fields_store($data) {
        global 
$g_queryCount;
        
$g_queryCount++;
        
mysql_query("UPDATE " $data['dirclient']->prefix "plus2desc SET desc1='" .
                    
mysql_real_escape_string($this->fields['desc1'], $data['dirclient']->dbLink) .
                    
"',desc2='" mysql_real_escape_string($this->fields['desc2'], $data['dirclient']->dbLink) . "' WHERE id='" $data['id'] . "'"$data['dirclient']->dbLink);
    }

    
/**
     * Build the validation for the input
     *
     * @param array $data Event data
     */
    
function fields_validate($data) {
        if(
$data['mode'] == 'admin') {
            
$data['field_validation'] = array_merge($data['field_validation'], array(
                
'Extra_Description_1__txt_max' PLUS2DESCLENGTH,
                
'Extra_Description_2__txt_max' PLUS2DESCLENGTH
            
));
        }
    }

    
/**
     * Serialise the field data to storage.
     *
     * @param array $data Event data
     */
    
function fields_serialize($data) {
        
$data['store'][get_class($this)] = serialize($this->fields);
    }

    
/**
     * Unserialise the field data from storage.
     *
     * @param array $data Event data
     */
    
function fields_unserialize($data) {
        
$this->fields unserialize($data['store'][get_class($this)]);
    }

    
/**
     * Optimise the database table.
     *
     * @param array $data Event data
     */
    
function fields_optimizedb($data) {
        global 
$g_queryCount;
        
$g_queryCount++;
        
mysql_query('OPTIMIZE TABLE ' $data['dirclient']->prefix 'plus2desc'$data['dirclient']->dbLink);
    }

    
/**
     * Draw the detail.
     *
     * @param array $data Event data
     */
    
function draw_detail($data) {
    }
}

?>
Reply With Quote
Sponsored Links
  #12  
Old 27-04-2010, 03:27 PM
incom incom is offline
Junior Member
 
Join Date: Apr 2010
Posts: 4
Search not working with Plus 2 Description Mod, Address mod data. please include these data in search function to make use these mods in a better way
Reply With Quote
  #13  
Old 27-04-2010, 04:15 PM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
You can't use the built in search to search these additional fields as that requires all the search code be modified and modified after each upgrade, you can however use Google search on your site as it can search everything.
Reply With Quote
Reply

Bookmarks

Tags
description, mod

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:25 AM.