function testAddBannerTypes() { $this->banner_type = 'Welcome'; //Add banner type add_banner_type($this->banner_type, 0, 100, 100, 100, 0); // Test the benner was actually created $this->assertTrue(100 == $GLOBALS['FORUM_DB']->query_value('banner_types', 't_image_width', array('id' => $this->banner_type))); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_banners($db, $table_prefix, $file_base) { require_code('banners2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'banner_types', NULL, NULL, true); if (is_null($rows)) { return; } foreach ($rows as $row) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('banner_types', 'id', array('id' => $row['id'])); if (is_null($test)) { add_banner_type($row['id'], $row['t_is_textual'], $row['t_image_width'], $row['t_image_height'], $row['t_max_file_size'], $row['t_comcode_inline']); } } $rows = $db->query('SELECT * FROM ' . $table_prefix . 'banners', NULL, NULL, true); if (is_null($rows)) { return; } $on_same_msn = $this->on_same_msn($file_base); foreach ($rows as $row) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $row['name'])); if (is_null($test)) { $submitter = $on_same_msn ? $row['submitter'] : import_id_remap_get('member', $row['submitter'], true); if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } add_banner($row['name'], $row['img_url'], array_key_exists('b_title_text', $row) ? $row['b_title_text'] : '', $this->get_lang_string($db, $row['caption']), $row['campaign_remaining'], $row['site_url'], $row['importance_modulus'], $row['notes'], $row['the_type'], $row['expiry_date'], $submitter, $row['validated'], $row['b_type'], $row['add_date'], $row['hits_from'], $row['hits_to'], $row['views_from'], $row['views_to'], $row['edit_date']); } } $rows = $db->query('SELECT * FROM ' . $table_prefix . 'banner_clicks', NULL, NULL, true); if (is_null($rows)) { return; } foreach ($rows as $row) { $c_member_id = $on_same_msn ? $row['c_member_id'] : import_id_remap_get('member', $row['c_member_id'], true); if (is_null($c_member_id)) { $c_member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $GLOBALS['SITE_DB']->query_insert('banner_clicks', array('c_date_and_time' => $row['c_date_and_time'], 'c_member_id' => $c_member_id, 'c_ip_address' => $row['c_ip_address'], 'c_source' => $row['c_source'], 'c_banner_id' => $row['c_banner_id'])); } }
/** * Standard aed_module add actualiser. * * @return array A pair: The entry added, description about usage */ function add_actualisation() { $id = post_param('new_id'); $is_textual = post_param_integer('is_textual', 0); $image_width = post_param_integer('image_width'); $image_height = post_param_integer('image_height'); $max_file_size = post_param_integer('max_file_size'); $comcode_inline = post_param_integer('comcode_inline', 0); add_banner_type($id, $is_textual, $image_width, $image_height, $max_file_size, $comcode_inline); return array($id, do_lang_tempcode('ADD_BANNER_TEMPLATING')); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_banners($db, $table_prefix, $old_base_dir) { require_code('banners2'); $categories = $db->query("SELECT title,id FROM " . $table_prefix . "categories WHERE section='com_banner'"); foreach ($categories as $category) { $cat_title = $category['title']; $category_exist = $GLOBALS['SITE_DB']->query_value_null_ok('banner_types', 'id', array('id' => $category['title'])); if (is_null($category_exist)) { add_banner_type($cat_title, 1, 160, 600, 70, 1); } $rows = $db->query("SELECT b.publish_down ,b.bid,c.title,b.name, b.clickurl, b.imageurl,b.date,bc.contact,bc.extrainfo,bc.email,b.showBanner,b.clicks,b.impmade FROM " . $table_prefix . "banner b INNER JOIN " . $table_prefix . "bannerclient bc ON b.cid=bc.cid INNER JOIN " . $table_prefix . "categories c ON b.catid=c.id AND c.title='" . db_escape_string($cat_title) . "' AND c.title <> ''"); foreach ($rows as $row) { $name = $row['name'] . strval($row['bid']); $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $name)); if (is_null($test)) { if ($row['imageurl'] != '') { $newimagepath = get_custom_file_base() . '/uploads/banners/' . rawurldecode($row['imageurl']); $newimage = $row['imageurl']; $oldimagepath = $old_base_dir . "/images/banners/" . rawurldecode($row['imageurl']); @copy($oldimagepath, $newimagepath); } else { $newimage = ''; } $type = 0; // Permanent $campaignremaining = 0; // Irrelevant $caption = $row['name']; $end_date = $this->mysql_time_to_timestamp($row['publish_down']); if ($end_date === false) { $end_date = NULL; } $url = $row['clickurl']; $image_url = $newimage; $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['contact']); if (is_null($member)) { $member = get_member(); } $desc = $row['email'] . chr(10) . $row['extrainfo']; $desc = html_to_comcode($desc); add_banner($name, $image_url, '', $caption, $campaignremaining, $url, 10, $desc, $type, $end_date, $member, 1, $cat_title, NULL, 0, 0, $row['clicks'], 0, $row['impmade']); } } } $row_start = 0; $rows = array(); do { $rows = $db->query("SELECT u.id, u.username, u.password, u.email, u.id, u.registerDate, u.lastvisitDate, u.sendEmail FROM " . $table_prefix . "bannerclient AS b INNER JOIN " . $table_prefix . "users AS u ON b.contact=u.name", 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['id']), $test); continue; } $primary_group = get_first_default_group(); $custom_fields = array(); $datetimearr = explode(' ', $row['registerDate']); $datearr = explode('-', $datetimearr[0]); $timearr = explode(':', $datetimearr[1]); $date = $datearr[2]; $month = $datearr[1]; $year = $datearr[0]; $hour = $timearr[0]; $min = $timearr[1]; $sec = $timearr[2]; $register_date = mktime($hour, $min, $sec, $month, $date, $year); $datetimearr = explode(' ', $row['lastvisitDate']); $datearr = explode('-', $datetimearr[0]); $timearr = explode(':', $datetimearr[1]); $date = $datearr[2]; $month = $datearr[1]; $year = $datearr[0]; $hour = $timearr[0]; $min = $timearr[1]; $sec = $timearr[2]; $last_visit_date = mktime($hour, $min, $sec, $month, $date, $year); $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $id_new = ocf_make_member($row['username'], $row['password'], $row['email'], NULL, NULL, NULL, NULL, $custom_fields, NULL, $primary_group, 1, $register_date, $last_visit_date, '', NULL, '', 0, 0, 1, $row['name'], '', '', 1, 1, NULL, $row['sendEmail'], $row['sendEmail'], '', NULL, '', FALSE, NULL, '', 1, $last_visit_date, $id, 0, '*', ''); import_id_remap_put('member', strval($row['id']), $id_new); } $row_start += 200; } while (count($rows) > 0); }