Bonjour,
Par défaut il n'y a pas de champs "téléphone" dans le dépôt d'une annonce...
Nous allons donc créer ce champs...
Tout d'abord éditez le fichier : oc-include/osclass/installer/
struct.sqlCREATE 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(45) NULL, <------------ insérez cette ligne
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',
En ce qui concerne la BDD, voici ce que j'ai fais :
je suis allez sur ma BDD, j'ai ouvert la table
oc_t_item --> Ajouter après
s_contact_email et j'ai rempli les champs :
Validez
---
Éditez le fichier : oc-includes/osclass/model/
item.phpfunction __construct()
{
parent::__construct();
$this->setTableName('t_item');
$this->setPrimaryKey('pk_i_id');
$array_fields = array(
'pk_i_id',
'fk_i_user_id',
'fk_i_category_id',
'dt_pub_date',
'dt_mod_date',
'f_price',
'i_price',
'fk_c_currency_code',
's_contact_name',
's_contact_email',
's_contact_phone', <---------------- insérez cette ligne
'b_premium',
's_ip',
'b_enabled',
'b_active',
'b_spam',
's_secret',
'b_show_email',
'dt_expiration'
);
$this->setFields($array_fields);
}
Éditez le fichier : oc-includes/osclass/helpers/
hitems.phpInsérez ce code
function osc_item_contact_phone() {
return (string) osc_item_field("s_contact_phone");
}
Éditez le fichier : oc-includes/osclass/helpers/
hpremium.phpInsérez ce code
function osc_premium_contact_phone() {
return (string) osc_premium_field("s_contact_phone");
}
Éditez le fichier : oc-includes/osclass/
ItemActions.phpRemplacez le code
$contactName = 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'] ) ) );
Par
$contactName = 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'] ) ) );
---
ce code
$this->manager->insert(array(
'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' => $enabled,
'b_show_email' => $aItem['showEmail'],
'b_spam' => $is_spam,
's_ip' => $aItem['s_ip']
));
par
$this->manager->insert(array(
'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' => $enabled,
'b_show_email' => $aItem['showEmail'],
'b_spam' => $is_spam,
's_ip' => $aItem['s_ip']
));
---
Le code
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
par
$flash_error .=
((!osc_validate_text($aItem['contactPhone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
((!osc_validate_max($aItem['contactPhone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
---
Le code
if($aItem['userId'] != '') {
$user = User::newInstance()->findByPrimaryKey( $aItem['userId'] );
$aItem['userId'] = $aItem['userId'];
$aItem['contactName'] = $user['s_name'];
$aItem['contactEmail'] = $user['s_email'];
} else {
$aItem['userId'] = NULL;
}
par
if($aItem['userId'] != '') {
$user = User::newInstance()->findByPrimaryKey( $aItem['userId'] );
$aItem['userId'] = $aItem['userId'];
$aItem['contactName'] = $user['s_name'];
$aItem['contactEmail'] = $user['s_email'];
$aItem['contactPhone'] = ($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land'];
} else {
$aItem['userId'] = NULL;
}
---
le code
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'];
}
par
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'];
}
---
le code
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
par
$flash_error .=
((!osc_validate_text($aItem['contactPhone'], 7, false)) ? _m("Phone Number too short.") . PHP_EOL : '' ) .
((!osc_validate_max($aItem['contactPhone'], 20)) ? _m("Phone Number too long.") . PHP_EOL : '' );
$_meta = Field::newInstance()->findByCategory($aItem['catId']);
$meta = Params::getParam("meta");
---
le code
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');
}
par
if($userId != null) {
$aItem['contactName'] = $data['s_name'];
$aItem['contactEmail'] = $data['s_email'];
$aItem['contactPhone'] = ($data['s_phone_mobile'])? $data['s_phone_mobile'] : $data['s_phone_land'];
Params::setParam('contactName', $data['s_name']);
Params::setParam('contactEmail', $data['s_email']);
Params::setParam('contactPhone', ($data['s_phone_mobile'])? $data['s_phone_mobile'] : $data['s_phone_land']);
} else {
$aItem['contactName'] = Params::getParam('contactName');
$aItem['contactEmail'] = Params::getParam('contactEmail');
$aItem['contactPhone'] = Params::getParam('contactPhone');
}
Éditez le fichier : oc-includes/osclass/frm/
item.form.class.phpinsérez le code
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;
}