At your themes folder, go to item-post.php and add this code where you want the box for contact phone to appear (in this version, the code has a button for hide or show the contact phone in the item page):
<div class="row">
<label for="contactPhone"><?php _e('Phone', 'modern'); ?> *</label>
<?php ItemForm::contact_phone_text(); ?>
</div>
<div class="row">
<div style="width: 120px;text-align: right;float:left;">
<?php ItemForm::show_phone_checkbox(); ?>
</div>
<label for="showPhone" style="width: 250px;"><?php _e('Show e-mail on the listing page', 'modern'); ?></label>
</div>
Go to you themes folder, item.php and add this where you want the contact phone to appear:
<?php if( osc_item_show_phone() ) { ?>
<p class="phone"><?php _e('Phone', 'modern'); ?>: <?php echo osc_item_contact_phone(); ?></p>
<?php } ?>
Now, the hard part. Go to osclass/oc-includes/osclass/frm and open Item.form.class.php. Add:
static public function contact_phone_text($item = null) {
if($item==null) { $item = osc_item(); };
if( Session::newInstance()->_getForm('contactPhone') != "" ) {
$item['s_contact_phone'] = Session::newInstance()->_getForm('contactPhone');
}
parent::generic_input_text('contactPhone', (isset($item['s_contact_phone'])) ? $item['s_contact_phone'] : null);
return true;
}
static public function show_phone_checkbox($item = null) {
if($item==null) { $item = osc_item(); };
if( Session::newInstance()->_getForm('showPhone') != 0) {
$item['b_show_phone'] = Session::newInstance()->_getForm('showPhone');
}
parent::generic_input_checkbox('showPhone', '1', (isset($item['b_show_phone']) ) ? $item['b_show_phone'] : false );
return true;
}
Now go to osclass/oc-includes/osclass/ItemActions.php
Change this:
if($userId != null) {
$aItem['contactName'] = $data['s_name'];
$aItem['contactEmail'] = $data['s_email'];
Params::setParam('contactName', $data['s_name']);
Params::setParam('contactEmail', $data['s_email']);
} else {
$aItem['contactName'] = Params::getParam('contactName');
$aItem['contactEmail'] = Params::getParam('contactEmail');
}
For this:
if($userId != null) {
$aItem['contactName'] = $data['s_name'];
$aItem['contactEmail'] = $data['s_email'];
Params::setParam('contactName', $data['s_name']);
Params::setParam('contactEmail', $data['s_email']);
} else {
$aItem['contactName'] = Params::getParam('contactName');
$aItem['contactEmail'] = Params::getParam('contactEmail');
$aItem['contactPhone'] = Params::getParam('contactPhone');
}
This:
$aItem['price'] = !is_null($aItem['price']) ? strip_tags( trim( $aItem['price'] ) ) : $aItem['price'];
$contactName = osc_sanitize_name( strip_tags( trim( $aItem['contactName'] ) ) );
$contactEmail = strip_tags( trim( $aItem['contactEmail'] ) );
$aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
$aItem['address'] = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );
For this:
$aItem['price'] = !is_null($aItem['price']) ? strip_tags( trim( $aItem['price'] ) ) : $aItem['price'];
$contactName = osc_sanitize_name( strip_tags( trim( $aItem['contactName'] ) ) );
$contactEmail = strip_tags( trim( $aItem['contactEmail'] ) );
$contactPhone = strip_tags( trim( $aItem['contactPhone'] ) );
$aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
$aItem['address'] = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );
This:
'fk_i_user_id' => $aItem['userId'],
'dt_pub_date' => date('Y-m-d H:i:s'),
'fk_i_category_id' => $aItem['catId'],
'i_price' => $aItem['price'],
'fk_c_currency_code' => $aItem['currency'],
's_contact_name' => $contactName,
's_contact_email' => $contactEmail,
's_secret' => $code,
'b_active' => ($active=='ACTIVE'?1:0),
'b_enabled' => 1,
'b_show_email' => $aItem['showEmail'],
's_ip' => $aItem['s_ip']
For this:
'fk_i_user_id' => $aItem['userId'],
'dt_pub_date' => date('Y-m-d H:i:s'),
'fk_i_category_id' => $aItem['catId'],
'i_price' => $aItem['price'],
'fk_c_currency_code' => $aItem['currency'],
's_contact_name' => $contactName,
's_contact_email' => $contactEmail,
's_contact_phone' => $contactPhone,
's_secret' => $code,
'b_active' => ($active=='ACTIVE'?1:0),
'b_enabled' => 1,
'b_show_email' => $aItem['showEmail'],
'b_show_phone' => $aItem['showPhone'],
's_ip' => $aItem['s_ip']
This:
if( $this->is_admin ) {
$aUpdate['fk_i_user_id'] = $aItem['userId'];
$aUpdate['s_contact_name'] = $aItem['contactName'];
$aUpdate['s_contact_email'] = $aItem['contactEmail'];
} else {
$aUpdate['s_ip'] = $aItem['s_ip'];
}
For this:
if( $this->is_admin ) {
$aUpdate['fk_i_user_id'] = $aItem['userId'];
$aUpdate['s_contact_name'] = $aItem['contactName'];
$aUpdate['s_contact_email'] = $aItem['contactEmail'];
$aUpdate['s_contact_phone'] = $aItem['contactPhone'];
} else {
$aUpdate['s_ip'] = $aItem['s_ip'];
}
Now in osclass/oc-includes/osclass/installer/struct.sql. Modify this:
CREATE TABLE /*TABLE_PREFIX*/t_item (
pk_i_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
fk_i_user_id INT(10) UNSIGNED NULL,
fk_i_category_id INT(10) UNSIGNED NOT NULL,
dt_pub_date DATETIME NOT NULL,
dt_mod_date DATETIME NULL,
f_price FLOAT NULL,
i_price BIGINT(20) NULL,
fk_c_currency_code CHAR(3) NULL,
s_contact_name VARCHAR(100) NULL,
s_contact_email VARCHAR(140) NULL,
s_ip VARCHAR(64) NOT NULL DEFAULT '',
b_premium TINYINT(1) NOT NULL DEFAULT 0,
b_enabled TINYINT(1) NOT NULL DEFAULT 1,
b_active TINYINT(1) NOT NULL DEFAULT 0,
b_spam TINYINT(1) NOT NULL DEFAULT 0,
s_secret VARCHAR(40) NULL,
b_show_email TINYINT(1) NULL,
dt_expiration datetime NOT NULL DEFAULT '9999-12-31 23:59:59',
PRIMARY KEY (pk_i_id),
FOREIGN KEY (fk_i_user_id) REFERENCES /*TABLE_PREFIX*/t_user (pk_i_id),
FOREIGN KEY (fk_i_category_id) REFERENCES /*TABLE_PREFIX*/t_category (pk_i_id),
FOREIGN KEY (fk_c_currency_code) REFERENCES /*TABLE_PREFIX*/t_currency (pk_c_code),
INDEX (fk_i_user_id),
INDEX idx_s_contact_email (s_contact_email(10)),
INDEX (fk_i_category_id),
INDEX (fk_c_currency_code),
INDEX idx_pub_date (dt_pub_date),
INDEX idx_price (i_price)
) ENGINE=InnoDB DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';
For this:
CREATE TABLE /*TABLE_PREFIX*/t_item (
pk_i_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
fk_i_user_id INT(10) UNSIGNED NULL,
fk_i_category_id INT(10) UNSIGNED NOT NULL,
dt_pub_date DATETIME NOT NULL,
dt_mod_date DATETIME NULL,
f_price FLOAT NULL,
i_price BIGINT(20) NULL,
fk_c_currency_code CHAR(3) NULL,
s_contact_name VARCHAR(100) NULL,
s_contact_email VARCHAR(140) NULL,
s_contact_phone VARCHAR(15) NULL,
s_ip VARCHAR(64) NOT NULL DEFAULT '',
b_premium TINYINT(1) NOT NULL DEFAULT 0,
b_enabled TINYINT(1) NOT NULL DEFAULT 1,
b_active TINYINT(1) NOT NULL DEFAULT 0,
b_spam TINYINT(1) NOT NULL DEFAULT 0,
s_secret VARCHAR(40) NULL,
b_show_email TINYINT(1) NULL,
b_show_phone TINYINT(1) NULL,
dt_expiration datetime NOT NULL DEFAULT '9999-12-31 23:59:59',
PRIMARY KEY (pk_i_id),
FOREIGN KEY (fk_i_user_id) REFERENCES /*TABLE_PREFIX*/t_user (pk_i_id),
FOREIGN KEY (fk_i_category_id) REFERENCES /*TABLE_PREFIX*/t_category (pk_i_id),
FOREIGN KEY (fk_c_currency_code) REFERENCES /*TABLE_PREFIX*/t_currency (pk_c_code),
INDEX (fk_i_user_id),
INDEX idx_s_contact_email (s_contact_email(10)),
INDEX (fk_i_category_id),
INDEX (fk_c_currency_code),
INDEX idx_pub_date (dt_pub_date),
INDEX idx_price (i_price)
) ENGINE=InnoDB DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';
In helpers, open hPreference.php. And add:
function osc_contact_phone() {
return(getPreference('contactPhone'));
}
And, still in the helpers paste, open hItems.php and add this:
function osc_item_show_phone() {
return (boolean) osc_item_field("b_show_phone");
}
Very IMPORTANT - go to your themes folder and open style.css Add this code:
.add_item input#showPhone { border:1px solid #BBB; padding:7px 7px 6px; width:20px; }