function getInstance() { if (!isset(self::$instance[get_class()])) { self::$instance = new Tradefields(); } return self::$instance; }
* * @version $Revision: 2205 $ */ require "../libraries/common.inc.php"; require "room.share.php"; require PHPB2B_ROOT . 'libraries/page.class.php'; check_permission("offer"); $tpl_file = "offer"; $page = new Pages(); uses("trade", "tradefield", "product", "tag", "attachment", "form", "typeoption", "point", "industry", "area"); $attachment = new Attachment("pic"); $area = new Areas(); $industry = new Industries(); $form = new Forms(); $point = new Points(); $tradefield = new Tradefields(); $tag = new Tags(); $trade = new Trades(); $trade_controller = new Trade(); $typeoption = new Typeoption(); $conditions = array(); $conditions[] = "member_id = " . $the_memberid; setvar("TradeTypes", $trade_controller->getTradeTypes()); setvar("TradeNames", $trade_controller->getTradeTypeNames()); $tmp_personalinfo = $memberinfo; setvar("MemberInfo", $tmp_personalinfo); $expires = $trade_controller->getOfferExpires(); setvar("TradeTypes", $trade_controller->getTradeTypes()); setvar("PhoneTypes", $typeoption->get_cache_type("phone_type")); setvar("ImTypes", $typeoption->get_cache_type("im_type")); setvar("OfferExpires", $expires);
function Add($params = '') { $result = false; if (!empty($this->params['expire_days'])) { $trade_controller =& Trade::getInstance(); if (array_key_exists($this->params['expire_days'], $trade_controller->getOfferExpires())) { $this->params['data']['trade']['expire_time'] = $this->timestamp + 24 * 3600 * $_POST['expire_days']; $this->params['data']['trade']['expire_days'] = $_POST['expire_days']; } else { $this->params['data']['trade']['expire_time'] = $this->timestamp + 24 * 3600 * 10; $this->params['data']['trade']['expire_days'] = 10; } } $this->params['data']['trade']['submit_time'] = $this->params['data']['trade']['created'] = $this->params['data']['trade']['modified'] = $this->timestamp; $this->params['data']['trade']['ip_addr'] = pb_get_client_ip('str'); if (isset($this->params['data']['trade']['title'])) { $trade_info = $this->params['data']['trade']; $result = $this->save($trade_info); $key = $this->table_name . "_id"; $last_tradeid = $this->{$key}; $_this =& Tradefields::getInstance(); $_this->params['data']['tradefield']['trade_id'] = $last_tradeid; $tradefield_info = $_this->params['data']['tradefield'] + $this->params['data']['tradefield']; $_this->primaryKey = "trade_id"; $_this->save($tradefield_info); } return $result; }
function add() { global $G; require CLASS_PATH . "validation.class.php"; $validate = new Validation(); uses("trade", "member", "tradefield", "tag"); $tag = new Tags(); $offer = $tradefield = new Tradefields(); $member = new Members(); $trade = new Trades(); if (isset($_POST['visit_post'])) { capt_check("capt_post_free"); pb_submit_check('visit_post'); $_POST['data']['trade']['title'] = pb_lang_merge($_POST['data']['multi']); $trade->setParams(); $tradefield->setParams(); $if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']); if (!empty($if_title_exists)) { $trade->validationErrors[] = L("semilar_offer_post"); } if (!$validate->notEmpty($trade->params['data']['trade']['title'])) { $trade->validationErrors[] = L("title_cant_be_empty"); } $trade->params['expire_days'] = $_POST['expire_days']; $if_check = $G['setting']['vis_post_check']; $msg = null; $words = $trade->dbstuff->GetArray("SELECT * FROM {$trade->table_prefix}words"); if (!empty($words)) { foreach ($words as $word_val) { if (!empty($word_val['title'])) { str_replace($word_val['title'], "***", $trade->params['data']['trade']['title']); str_replace($word_val['title'], "***", $trade->params['data']['trade']['content']); } } $item['forbid_word'] = implode("\r\n", $tmp_str); } if ($if_check) { $trade->params['data']['trade']['status'] = 0; $msg = 'pls_wait_for_check'; } else { $trade->params['data']['trade']['status'] = 1; $msg = 'success'; } if (!empty($trade->validationErrors)) { setvar("item", am($trade->params['data']['trade'], $tradefield->params['data']['tradefield'])); setvar("Errors", $validate->show($trade)); render("offer/post"); } else { $trade->params['data']['trade']['industry_id'] = implode(",", $_POST['industry']['id']); $trade->params['data']['trade']['area_id'] = implode(",", $_POST['area']['id']); $result = $trade->Add(); if ($result) { flash($msg); } else { flash(); } } } }
require "../libraries/common.inc.php"; require "../share.inc.php"; require LIB_PATH . "validation.class.php"; $validate = new Validation(); if (session_id() == '') { require_once LIB_PATH . "session_php.class.php"; $session = new PbSessions(); } uses("trade", "member", "tradefield", "tag", "typeoption"); $tag = new Tags(); $offer = new Tradefields(); $typeoption = new Typeoption(); $member = new Members(); $trade = new Trades(); $trade_controller = new Trade(); $tradefield = new Tradefields(); $expires = $trade_controller->getOfferExpires(); setvar("Genders", $typeoption->get_cache_type("gender", null, array("0", "-1"))); setvar("PhoneTypes", $typeoption->get_cache_type("phone_type")); setvar("ImTypes", $typeoption->get_cache_type("im_type")); $if_visit_post = $_PB_CACHE['setting']['vis_post']; if (!$if_visit_post) { $smarty->flash('visitor_forbid', URL, 0); } capt_check("capt_post_free"); if (isset($_POST['visit_post'])) { pb_submit_check('visit_post'); $trade->setParams(); $tradefield->setParams(); $if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']); if (!empty($if_title_exists)) {