本文整理汇总了PHP中insert_lang函数的典型用法代码示例。如果您正苦于以下问题:PHP insert_lang函数的具体用法?PHP insert_lang怎么用?PHP insert_lang使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert_lang函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
parent::setUp();
require_code('ecommerce');
require_code('catalogues');
require_code('catalogues2');
require_code('shopping');
require_lang('catalogues');
require_lang('shopping');
require_lang('ecommerce');
if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'storetesting' . strval(get_member()))))) {
actual_delete_catalogue('storetesting' . strval(get_member()));
}
$this->access_mapping = array(db_get_first_id() => 4);
// Creating cms catalogues object
require_code('cms/pages/modules/cms_catalogues.php');
$this->cms_cat = new Module_cms_catalogues();
//Creating Shopping cart object
require_code('site/pages/modules/shopping.php');
$this->shopping_cart = new Module_shopping();
$username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
$this->category_id = actual_add_catalogue('storetesting' . strval(get_member()), insert_lang(do_lang('DEFAULT_CATALOGUE_PRODUCTS_TITLE'), 2), '', 0, 1, '', 0, 1);
$fields = array(array('ECOM_CAT_product_title', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1, 1), array('ECOM_CAT_item_code', 'ECOM_CATD_item_code', 'random', 0, 1, 1, 1), array('ECOM_CAT_price_pre_tax', 'ECOM_CATD_price_pre_tax', 'float', 0, 1, 1, 1), array('ECOM_CAT_stock_level', 'ECOM_CATD_stock_level', 'integer', 0, 0, 1, 0), array('ECOM_CAT_stock_level_warn_at', 'ECOM_CATD_stock_level_warn_at', 'integer', 0, 0, 0, 0), array('ECOM_CAT_stock_level_maintain', 'ECOM_CATD_stock_level_maintain', 'tick', 0, 1, 0, 0), array('ECOM_CAT_tax_type', 'ECOM_CATD_tax_type', 'list', 0, 1, 0, 0, "0%|5%|17.5%", 0), array('ECOM_CAT_image', 'ECOM_CATD_image', 'picture', 0, 0, 1, 1), array('ECOM_CAT_weight', 'ECOM_CATD_weight', 'float', 0, 1, 0, 0), array('ECOM_CAT_description', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1, 1, 1));
foreach ($fields as $i => $field) {
actual_add_catalogue_field('storetesting' . strval(get_member()), lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2] == 'tick' ? 'list' : $field[2], $i, $field[3], $field[5], $field[6], $field[2] == 'tick' ? do_lang('NO') . '|' . do_lang('YES') : (array_key_exists(7, $field) ? $field[7] : ''), $field[4], array_key_exists(5, $field) ? $field[5] : 0, array_key_exists(5, $field) ? $field[5] : 0);
}
$catalogue_name = 'storetesting' . strval(get_member());
//Set Sample post values
$fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name));
foreach ($fields as $key => $val) {
$type = $val['cf_type'];
$id = $val['id'];
switch ($type) {
case 'integer':
$_POST['field_' . strval($id)] = 4;
break;
case 'short_trans':
$_POST['field_' . strval($id)] = 'Test field value';
break;
case 'long_trans':
$_POST['field_' . strval($id)] = 'Test field value';
break;
case 'float':
$_POST['field_' . strval($id)] = 68.34999999999999;
break;
case 'list':
if ($val['cf_order'] = 6) {
//Order 6 is tax
$_POST['field_' . strval($id)] = 'Arizona=7.8%';
} elseif ($val['cf_order'] = 5) {
//Order 5 yes keep stock "yes/no"
$_POST['field_' . strval($id)] = 'yes';
}
break;
}
}
$map = $this->cms_cat->get_set_field_map($catalogue_name);
$this->product_id = actual_add_catalogue_entry($this->category_id, $validated = 0, $notes = 'test note', $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $map);
}
示例2: install
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
{
if (is_null($upgrade_from)) {
$GLOBALS['SITE_DB']->create_table('classifieds_prices', array('id' => '*AUTO', 'c_catalogue_name' => 'ID_TEXT', 'c_days' => 'INTEGER', 'c_label' => 'SHORT_TRANS', 'c_price' => 'REAL'));
$GLOBALS['SITE_DB']->create_index('classifieds_prices', 'c_catalogue_name', array('c_catalogue_name'));
require_lang('classifieds');
$prices = array('ONE_WEEK' => array(0.0, 7), 'ONE_MONTH' => array(5.0, 30), 'THREE_MONTHS' => array(12.0, 90), 'SIX_MONTHS' => array(20.0, 180), 'ONE_YEAR' => array(32.0, 365));
foreach ($prices as $level => $bits) {
list($price, $days) = $bits;
$GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => 'classifieds', 'c_days' => $days, 'c_label' => insert_lang(do_lang('CLASSIFIEDS_DEFAULT_PRICE_LEVEL_' . $level), 2), 'c_price' => $price));
}
}
}
示例3: import_custom_comcode
/**
* 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_custom_comcode($db, $table_prefix, $old_base_dir)
{
$rows = $db->query('SELECT * FROM ' . $table_prefix . 'custom_bbcode');
foreach ($rows as $row) {
if (import_check_if_imported('custom_comcode', strval($row['bbcode_id']))) {
continue;
}
global $VALID_COMCODE_TAGS;
$test = $GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode', 'tag_tag', array('tag_tag' => $row['bbcode_tag']));
if (array_key_exists($row['bbcode_tag'], $VALID_COMCODE_TAGS) || !is_null($test)) {
import_id_remap_put('custom_comcode', strval($row['bbcode_id']), 1);
continue;
}
$GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => $row['bbcode_tag'], 'tag_title' => insert_lang($row['bbcode_title'], 3), 'tag_description' => insert_lang($row['bbcode_desc'], 3), 'tag_replace' => $row['bbcode_replace'], 'tag_example' => $row['bbcode_example'], 'tag_parameters' => '', 'tag_enabled' => 1, 'tag_dangerous_tag' => 0, 'tag_block_tag' => 0, 'tag_textual_tag' => 1));
import_id_remap_put('custom_comcode', strval($row['bbcode_id']), 1);
}
}
示例4: ocf_make_forum
/**
* Make a forum.
*
* @param SHORT_TEXT The name of the forum.
* @param SHORT_TEXT The description for the forum.
* @param ?AUTO_LINK What forum category the forum will be filed with (NULL: this is the root forum).
* @param ?array Permission map (NULL: do it the standard way, outside of this function). This parameter is for import/compatibility only and works upon an emulation of 'access levels' (ala ocPortal 2.5/2.6), and it is recommended to use the normal aed_module functionality for permissions setting.
* @param ?AUTO_LINK The ID of the parent forum (NULL: this is the root forum).
* @param integer The position of this forum relative to other forums viewable on the same screen (if parent forum hasn't specified automatic ordering).
* @param BINARY Whether post counts will be incremented if members post in the forum.
* @param BINARY Whether the ordering of subforums is done automatically, alphabetically).
* @param LONG_TEXT The question that is shown for newbies to the forum (blank: none).
* @param SHORT_TEXT The answer to the question (blank: no specific answer.. if there's a 'question', it just requires a click-through).
* @param SHORT_TEXT Either blank for no redirection, the ID of another forum we are mirroring, or a URL to redirect to.
* @param ID_TEXT The order the topics are shown in, by default.
* @param BINARY Whether the forum is threaded.
* @return AUTO_LINK The ID of the newly created forum.
*/
function ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position = 1, $post_count_increment = 1, $order_sub_alpha = 0, $intro_question = '', $intro_answer = '', $redirection = '', $order = 'last_post', $is_threaded = 0)
{
if ($category_id == -1) {
$category_id = NULL;
}
if ($parent_forum == -1) {
$parent_forum = NULL;
}
if (get_page_name() != 'admin_import') {
if (!is_null($category_id) && function_exists('ocf_ensure_category_exists')) {
ocf_ensure_category_exists($category_id);
}
if (!is_null($parent_forum) && function_exists('ocf_ensure_forum_exists')) {
ocf_ensure_forum_exists($parent_forum);
}
}
$forum_id = $GLOBALS['FORUM_DB']->query_insert('f_forums', array('f_name' => $name, 'f_description' => insert_lang($description, 2, $GLOBALS['FORUM_DB']), 'f_category_id' => $category_id, 'f_parent_forum' => $parent_forum, 'f_position' => $position, 'f_order_sub_alpha' => $order_sub_alpha, 'f_post_count_increment' => $post_count_increment, 'f_intro_question' => insert_lang($intro_question, 3, $GLOBALS['FORUM_DB']), 'f_intro_answer' => $intro_answer, 'f_cache_num_topics' => 0, 'f_cache_num_posts' => 0, 'f_cache_last_topic_id' => NULL, 'f_cache_last_forum_id' => NULL, 'f_cache_last_title' => '', 'f_cache_last_time' => NULL, 'f_cache_last_username' => '', 'f_cache_last_member_id' => NULL, 'f_redirection' => $redirection, 'f_order' => $order, 'f_is_threaded' => $is_threaded), true);
// Set permissions
if (!is_null($access_mapping)) {
$groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(false, true);
foreach (array_keys($groups) as $group_id) {
$level = 0;
// No-access
if (array_key_exists($group_id, $access_mapping)) {
$level = $access_mapping[$group_id];
}
if ($level >= 1) {
$GLOBALS['FORUM_DB']->query_insert('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($forum_id), 'group_id' => $group_id));
if ($level == 1) {
$GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'submit_lowrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 0));
$GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'submit_midrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 0));
}
if ($level >= 3) {
$GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'bypass_validation_lowrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 1));
}
if ($level >= 4) {
$GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'bypass_validation_midrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 1));
}
// 2=May post, [3=May post instantly , 4=May start topics instantly , 5=Moderator -- these ones will not be treated specially, so as to avoid overriding permissions unnecessary - let the admins configure it optimally manually]
}
}
}
log_it('ADD_FORUM', strval($forum_id), $name);
return $forum_id;
}
示例5: ocf_make_multi_moderation
/**
* Add a multi moderation to the system.
*
* @param SHORT_TEXT The name of the multi moderation.
* @param LONG_TEXT The post text to add when applying (blank: don't add a post).
* @param ?AUTO_LINK The forum to move the topic when applying (NULL: do not move).
* @param ?BINARY The pin state after applying (NULL: unchanged).
* @param ?BINARY The sink state after applying (NULL: unchanged).
* @param ?BINARY The open state after applying (NULL: unchanged).
* @param SHORT_TEXT The forum multi code for where this multi moderation may be applied.
* @param SHORT_TEXT The title suffix.
* @return AUTO_LINK The ID of the multi moderation just added.
*/
function ocf_make_multi_moderation($name, $post_text, $move_to, $pin_state, $sink_state, $open_state, $forum_multi_code = '*', $title_suffix = '')
{
if ($move_to == -1) {
$move_to = NULL;
}
if ($pin_state == -1) {
$pin_state = NULL;
}
if ($open_state == -1) {
$open_state = NULL;
}
if ($sink_state == -1) {
$sink_state = NULL;
}
$id = $GLOBALS['FORUM_DB']->query_insert('f_multi_moderations', array('mm_name' => insert_lang($name, 3, $GLOBALS['FORUM_DB']), 'mm_post_text' => $post_text, 'mm_move_to' => $move_to, 'mm_pin_state' => $pin_state, 'mm_sink_state' => $sink_state, 'mm_open_state' => $open_state, 'mm_forum_multi_code' => $forum_multi_code, 'mm_title_suffix' => $title_suffix), true);
log_it('ADD_MULTI_MODERATION', strval($id), $name);
return $id;
}
示例6: seo_meta_set_for_explicit
/**
* Explictly sets the meta information for the specified resource.
*
* @param ID_TEXT The type of resource (e.g. download)
* @param ID_TEXT The ID of the resource
* @param SHORT_TEXT The keywords to use
* @param SHORT_TEXT The description to use
*/
function seo_meta_set_for_explicit($type, $id, $keywords, $description)
{
if ($description == STRING_MAGIC_NULL) {
return;
}
if ($keywords == STRING_MAGIC_NULL) {
return;
}
$description = str_replace(chr(10), ' ', $description);
$rows = $GLOBALS['SITE_DB']->query_select('seo_meta', array('meta_keywords', 'meta_description'), array('meta_for_type' => $type, 'meta_for_id' => $id), '', 1);
if (array_key_exists(0, $rows)) {
lang_remap($rows[0]['meta_keywords'], $keywords);
lang_remap($rows[0]['meta_description'], $description);
} else {
$GLOBALS['SITE_DB']->query_insert('seo_meta', array('meta_for_type' => $type, 'meta_for_id' => $id, 'meta_keywords' => insert_lang($keywords, 2), 'meta_description' => insert_lang($description, 2)));
}
if (function_exists('decache')) {
decache('side_tag_cloud');
}
if (function_exists('persistant_cache_delete')) {
persistant_cache_delete(array('seo', $type, $id));
}
}
示例7: install
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
{
if (!is_null($upgrade_from) && $upgrade_from < 5) {
$GLOBALS['SITE_DB']->delete_table_field('ticket_types', 'send_sms_to');
}
if (!is_null($upgrade_from) && $upgrade_from < 4) {
$GLOBALS['SITE_DB']->add_table_field('ticket_types', 'guest_emails_mandatory', 'BINARY', 0);
$GLOBALS['SITE_DB']->add_table_field('ticket_types', 'search_faq', 'BINARY', 0);
$GLOBALS['SITE_DB']->add_table_field('ticket_types', 'cache_lead_time', '?TIME');
}
if ($upgrade_from < 3 || is_null($upgrade_from)) {
add_specific_permission('SUPPORT_TICKETS', 'support_operator', false);
}
if (is_null($upgrade_from) || $upgrade_from < 4) {
add_config_option('TICKET_MEMBER_FORUMS', 'ticket_member_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS');
add_config_option('TICKET_TYPE_FORUMS', 'ticket_type_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS');
$GLOBALS['SITE_DB']->create_table('tickets', array('ticket_id' => '*SHORT_TEXT', 'topic_id' => 'AUTO_LINK', 'forum_id' => 'AUTO_LINK', 'ticket_type' => 'SHORT_TRANS'));
}
if (!is_null($upgrade_from) && $upgrade_from < 2) {
$GLOBALS['SITE_DB']->query_update('config', array('eval' => 'return do_lang(\'NEW_TICKET_WELCOME\');'), array('the_name' => 'ticket_text'), '', 1);
if ($GLOBALS['OPTIONS']['ticket_text']['c_set'] == 1) {
set_option('ticket_text', '[html]' . get_option('ticket_text') . '[/html]');
} else {
set_option('ticket_text', do_lang('NEW_TICKET_WELCOME'));
}
return;
}
require_lang('tickets');
if (is_null($upgrade_from)) {
$GLOBALS['SITE_DB']->create_table('ticket_types', array('ticket_type' => '*SHORT_TRANS', 'guest_emails_mandatory' => 'BINARY', 'search_faq' => 'BINARY', 'cache_lead_time' => '?TIME'));
$groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
$default_types = array('TT_OTHER', 'TT_COMPLAINT');
foreach ($default_types as $type) {
$GLOBALS['SITE_DB']->query_insert('ticket_types', array('ticket_type' => insert_lang(do_lang($type), 1), 'guest_emails_mandatory' => 0, 'search_faq' => 0, 'cache_lead_time' => NULL));
foreach (array_keys($groups) as $id) {
$GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'tickets', 'category_name' => do_lang($type), 'group_id' => $id));
}
}
add_config_option('PAGE_TEXT', 'ticket_text', 'transtext', 'return do_lang(\'NEW_TICKET_WELCOME\');', 'FEATURE', 'SUPPORT_TICKETS');
add_config_option('TICKET_FORUM_NAME', 'ticket_forum_name', 'forum', 'require_lang(\'tickets\'); return do_lang(\'TICKET_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'SUPPORT_TICKETS');
add_specific_permission('SUPPORT_TICKETS', 'view_others_tickets', false);
add_menu_item_simple('main_website', NULL, 'SUPPORT_TICKETS', '_SEARCH:tickets:type=misc');
}
}
示例8: ocf_switch
/**
* Special import-esque function to aid switching to OCF after importing forum previously served by a forum driver.
*
* @return tempcode Information about progress
*/
function ocf_switch()
{
$out = new ocp_tempcode();
$todos = array('USER' => array('member', db_get_first_id(), NULL), 'GROUP' => array('group', NULL, 'group_id'));
foreach ($todos as $db_abstraction => $definition) {
list($import_code, $default_id, $field_name_also) = $definition;
$count = 0;
$extra = is_null($field_name_also) ? '' : ' OR ' . db_string_equal_to('m_name', $field_name_also);
$fields = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE (NOT (m_table LIKE \'' . db_encode_like('f_%') . '\')) AND (' . db_string_equal_to('m_type', $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '*' . $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '?' . $db_abstraction) . $extra . ')');
foreach ($fields as $field) {
if ($field['m_table'] == 'stats') {
continue;
}
// Lots of data and it's not important
//echo '(working) '.$field['m_table'].'/'.$field['m_name'].'<br />';
$values = $GLOBALS['SITE_DB']->query_select($field['m_table'], array('*'));
foreach ($values as $value) {
$current = $value[$field['m_name']];
$remapped = import_id_remap_get($import_code, $current, true);
if (is_null($remapped)) {
$remapped = $default_id;
}
if (!is_null($remapped)) {
$value2 = $value;
$value2[$field['m_name']] = -$remapped;
$c = $GLOBALS['SITE_DB']->query_update($field['m_table'], $value2, $value, '', NULL, NULL, true, true);
if (is_null($c)) {
$GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
} else {
$count += $c;
}
} else {
$GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
}
}
$GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' SET ' . $field['m_name'] . '=-' . $field['m_name'] . ' WHERE ' . $field['m_name'] . '<0');
}
$out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_' . $db_abstraction, $count == 0 ? '?' : strval($count))));
}
// info.php
global $FILE_BASE;
$info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php';
$info = @fopen($FILE_BASE . '/' . $info_file, 'wt') or intelligent_write_error($FILE_BASE . '/' . $info_file);
fwrite($info, "<" . "?php\n");
global $SITE_INFO;
$SITE_INFO['forum_type'] = 'ocf';
$SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
$SITE_INFO['db_forums'] = $SITE_INFO['db_site'];
$SITE_INFO['db_forums_host'] = array_key_exists('db_site_host', $SITE_INFO) ? $SITE_INFO['db_site_host'] : 'localhost';
$SITE_INFO['db_forums_user'] = $SITE_INFO['db_site_user'];
$SITE_INFO['db_forums_password'] = $SITE_INFO['db_site_password'];
$SITE_INFO['board_prefix'] = get_base_url();
foreach ($SITE_INFO as $key => $val) {
$_val = str_replace('\\', '\\\\', $val);
fwrite($info, '$SITE_INFO[\'' . $key . '\']=\'' . $_val . "';\n");
}
fwrite($info, "?" . ">\n");
fclose($info);
fix_permissions($FILE_BASE . '/' . $info_file);
sync_file($FILE_BASE . '/' . $info_file);
$out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_INFO')));
$LANG = get_site_default_lang();
$trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG);
$GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1));
require_code('menus2');
add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':forumview', 0, 1);
return $out;
}
示例9: set_keys_access
/**
* The actualiser to set match-key access.
*
* @return tempcode The UI
*/
function set_keys_access()
{
$GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/matchkeysecurity';
$GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions';
$title = get_page_title('PAGE_MATCH_KEY_ACCESS');
// Delete to cleanup
$GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name LIKE \'' . db_encode_like('%:%') . '\'');
$mkeylang = collapse_2d_complexity('id', 'k_message', $GLOBALS['SITE_DB']->query_select('match_key_messages', array('id', 'k_message')));
$GLOBALS['SITE_DB']->query_delete('match_key_messages');
$groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
foreach ($_POST as $key => $val) {
if (get_magic_quotes_gpc()) {
$val = stripslashes($val);
}
// See if we can tidy it back to a page-link (assuming it's not one already)
$page_link = url_to_pagelink($val, true);
if ($page_link != '') {
$val = $page_link;
}
if (substr($key, 0, 4) == 'key_' && $val != '') {
foreach (array_keys($groups) as $gid) {
if (post_param_integer('p_' . substr($key, 4) . '__' . strval($gid), 0) == 1) {
$GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => '/', 'page_name' => $val, 'group_id' => $gid));
}
}
}
if (substr($key, 0, 5) == 'mkey_' && $val != '') {
$id = substr($key, 5);
if (substr($id, 0, 4) == 'new_' || !array_key_exists(intval($id), $mkeylang)) {
$GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => insert_lang(post_param('msg_' . $id), 2), 'k_match_key' => $val));
} else {
$GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => lang_remap($mkeylang[intval($id)], post_param('msg_' . $id)), 'k_match_key' => $val));
unset($mkeylang[intval($id)]);
}
}
}
foreach ($mkeylang as $lid) {
delete_lang($lid);
}
decache('main_sitemap');
breadcrumb_set_parents(array(array('_SELF:_SELF:keys', do_lang_tempcode('PAGE_MATCH_KEY_ACCESS'))));
breadcrumb_set_self(do_lang_tempcode('DONE'));
// Show it worked / Refresh
$url = build_url(array('page' => '_SELF', 'type' => 'keys'), '_SELF');
return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
}
示例10: read_in_data
/**
* Read in data posted by an add/edit form
*
* @param boolean Whether to insert unknown workflows into the database. For adding this should be true, otherwise false (the default)
* @return array (workflow_id, workflow_name, array(approval point IDs=>names), default)
*/
function read_in_data($insert_if_needed = false)
{
require_lang('workflows');
// Grab the given name. We allow spaces, letters and numbers.
$name = implode(' ', array_map('strip_tags', explode(' ', trim(post_param('name')))));
// Look for an existing workflow with this name
$workflows = get_all_workflows();
if (in_array($name, $workflows)) {
// Found one, use it
$workflow_id = current(array_keys($workflows, $name));
} elseif ($insert_if_needed) {
// Couldn't find any. Let's make one, with a dummy approval point.
// HACKHACK We should use a normalised table with an ID column
$workflow_id = insert_lang($name, 3);
$GLOBALS['SITE_DB']->query_insert('workflow_requirements', array('workflow_name' => $workflow_id, 'is_default' => 0, 'the_position' => 0, 'workflow_approval_name' => 0));
} else {
warn_exit(do_lang('_MISSING_RESOURCE', $name));
}
// Grab all of the requested points
$points = array_map('trim', explode("\n", trim(post_param('points'))));
// Discard whitespace
$temp_points = array();
foreach ($points as $p) {
if (strlen(trim($p)) > 0) {
$temp_points[] = trim($p);
}
}
$points = $temp_points;
unset($temp_points);
// Clean them up a bit. We'll allow spaces, but no other punctuation.
$clean_points = array();
foreach ($points as $p) {
$clean_points[] = implode(' ', array_map('strip_tags', explode(' ', $p)));
}
$points = $clean_points;
unset($clean_points);
// Find any points which are already defined
$all_points = get_all_approval_points();
$point_ids = array();
foreach ($points as $p) {
if (in_array($p, array_values($all_points))) {
// This already exists. Use the existing version.
$point_id = current(array_keys($all_points, $p));
$point_ids[$point_id] = $p;
} else {
// This doesn't exist yet. Define it now.
// HACKHACK We should use a normalised table with an ID field
$point_id = insert_lang($p, 3);
$point_ids[$point_id] = $p;
}
// Make sure that there are groups allowed to approve this point
$this_key = NULL;
foreach (array_keys($_POST) as $post_key) {
if (strpos($post_key, 'code_') === 0) {
$this_key = intval(str_replace('code_', '', $post_key));
} elseif (strpos($post_key, 'redef_') === 0) {
$this_key = intval(str_replace('redef_', '', $post_key));
}
}
if (is_null($this_key)) {
// If we can't find any then it may be that the browser didn't send
// us the ticks, since the user didn't change them (notably Chrome
// does this).
// If this is the case then we leave existing points alone...
$has_defaults = $GLOBALS['SITE_DB']->query_select('workflow_requirements', array('*'), array('workflow_approval_name' => $point_id));
if (count($has_defaults) > 0) {
continue;
} else {
// ... but this is an error is there are no existing permissions
// Clean up any dummies we made
$GLOBALS['SITE_DB']->query_delete('workflow_requirements', array('workflow_approval_name' => 0));
warn_exit(do_lang('WORKFLOW_POINT_MUST_HAVE_GROUP', $p));
}
}
// Clear previous permissions for this approval point
$GLOBALS['SITE_DB']->query_delete('workflow_permissions', array('workflow_approval_name' => $point_id));
// Insert the new permissions for this approval point
if (array_key_exists('groups_' . strval($this_key), $_POST)) {
foreach ($_POST['groups_' . strval($this_key)] as $k => $v) {
$GLOBALS['SITE_DB']->query_insert('workflow_permissions', array('usergroup' => intval($k), 'workflow_approval_name' => $point_id, 'validated' => 1));
}
}
if (array_key_exists('redef_groups_' . strval($this_key), $_POST)) {
foreach ($_POST['redef_groups_' . strval($this_key)] as $k => $v) {
$GLOBALS['SITE_DB']->query_insert('workflow_permissions', array('usergroup' => intval($k), 'workflow_approval_name' => $point_id, 'validated' => 1));
}
}
}
// Now replace the workflow requirements. Add the new points (existing
// instances will be replaced, so we don't need to worry about duplicates)
$point_names = array_flip($point_ids);
$points_we_want = array();
foreach ($points as $p) {
add_requirement_to_workflow($point_names[$p], $workflow_id);
//.........这里部分代码省略.........
示例11: add_menu_item
/**
* Add a menu item.
*
* @param SHORT_TEXT The name of the menu to add the item to.
* @param integer The relative order of this item on the menu.
* @param ?AUTO_LINK The menu item ID of the parent branch of the menu item (NULL: is on root).
* @param SHORT_TEXT The caption.
* @param SHORT_TEXT The URL (in entry point form).
* @param BINARY Whether people who may not view the entry point do not see the link.
* @param SHORT_TEXT Match-keys to identify what pages the item is shown on.
* @param BINARY Whether it is an expanded branch.
* @param BINARY Whether the link will open in a new window.
* @param SHORT_TEXT The tooltip (blank: none).
* @return AUTO_LINK The ID of the newly added menu item.
*/
function add_menu_item($menu, $order, $parent, $caption, $url, $check_permissions, $page_only, $expanded, $new_window, $caption_long)
{
$id = $GLOBALS['SITE_DB']->query_insert('menu_items', array('i_menu' => $menu, 'i_order' => $order, 'i_parent' => $parent, 'i_caption' => insert_lang($caption, 1), 'i_caption_long' => insert_lang($caption_long, 1), 'i_url' => $url, 'i_check_permissions' => $check_permissions, 'i_page_only' => $page_only, 'i_expanded' => $expanded, 'i_new_window' => $new_window, 'i_theme_img_code' => ''), true);
log_it('ADD_MENU_ITEM', strval($id), $caption);
return $id;
}
示例12: post_param
$label = post_param('label_' . $matches[1] . '_' . $matches[2], '');
$price = post_param('price_' . $matches[1] . '_' . $matches[2], '');
if ($catalogue != '' && $days != '' && $label != '' && $price != '') {
if ($matches[1] == 'existing') {
$_label = $GLOBALS['SITE_DB']->query_value_null_ok('classifieds_prices', 'c_label', array('id' => intval($matches[2])));
if (is_null($_label)) {
$matches[1] = 'new';
}
// Was lost, so add as new
}
if ($matches[1] == 'existing') {
// Edit
$GLOBALS['SITE_DB']->query_update('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => lang_remap($_label, $label), 'c_price' => floatval($price)), array('id' => intval($matches[2])), '', 1);
} else {
// Add
$GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => insert_lang($label, 2), 'c_price' => floatval($price)));
}
} else {
if ($matches[1] == 'existing') {
// Delete
$GLOBALS['SITE_DB']->query_delete('classifieds_prices', array('id' => intval($matches[2])), '', 1);
}
}
}
}
attach_message(do_lang_tempcode('SUCCESS', 'inform'));
}
$title = get_page_title('CLASSIFIEDS');
$_prices = $GLOBALS['SITE_DB']->query_select('classifieds_prices', array('*'), NULL, 'ORDER BY c_catalogue_name,c_days,c_price');
$prices = array();
foreach ($_prices as $_price) {
示例13: add_actualisation
/**
* Standard aed_module add actualiser.
*
* @return ID_TEXT The entry added
*/
function add_actualisation()
{
$tag = post_param('tag');
require_code('type_validation');
if (!is_alphanumeric($tag, true)) {
warn_exit(do_lang_tempcode('BAD_CODENAME'));
}
global $VALID_COMCODE_TAGS;
$test = $GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode', 'tag_tag', array('tag_tag' => $tag));
if (array_key_exists($tag, $VALID_COMCODE_TAGS) || !is_null($test)) {
warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($tag)));
}
$GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => $tag, 'tag_title' => insert_lang(post_param('title'), 3), 'tag_description' => insert_lang(post_param('description'), 3), 'tag_replace' => post_param('replace'), 'tag_example' => post_param('example'), 'tag_parameters' => post_param('parameters'), 'tag_enabled' => post_param_integer('enabled', 0), 'tag_dangerous_tag' => post_param_integer('dangerous_tag', 0), 'tag_block_tag' => post_param_integer('block_tag', 0), 'tag_textual_tag' => post_param_integer('textual_tag', 0)));
log_it('ADD_' . $this->lang_type, $tag);
return $tag;
}
示例14: import_news_and_categories
/**
* 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_news_and_categories($db, $table_prefix, $old_base_dir)
{
require_code('news');
require_code('galleries2');
//check is the comment forum configured in ocPortal
$this->test_for_comments_forum();
// Can we comment the news?
$com = 1;
$forum_name = get_option('comments_forum_name');
ocf_over_msn();
//used to fixed the correct forum prefix
$forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
ocf_over_local();
//used to fixed the correct forum prefix
/* old import reviews code, as part of the news. NOTE: now they are imported as catalogues entries
// Reviews (imports into 'community')
$rows=$db->query('SELECT r.id AS review_id, r.title AS review_title, r.description AS review_description, r.field1 AS rf1, r.field2 AS rf2, r.field3 AS rf3, r.field4 AS rf4, r.field5 AS rf5, r.field6 AS rf6, r.field7 AS rf7, r.*, rc.title AS rc_title, rc.description AS rc_description, rc.field1 AS rcf1, rc.field2 AS rcf2, rc.field3 AS rcf3, rc.field4 AS rcf4, rc.field5 AS rcf5, rc.field6 AS rcf6, rc.field7 AS rcf7, rc.* FROM '.$table_prefix.'reviews r LEFT JOIN '.$table_prefix.'reviews_sections rc ON r.id_cat=rc.id');
foreach ($rows as $row)
{
$cat_id=$this->get_news_category_id($row['review_title'],'community');
$review_description=$row['review_description'];
for ($i=1;$i<=7;$i++)
{
if (strlen($row[strval('rcf'.$i)])>0)
{
$review_description.=chr(10).$row[strval('rcf'.$i)].': '.$row[strval('rf'.$i)];
}
}
$review_description.=chr(10).'Views: '.strval(intval($row['click']));
ocf_over_msn(); //used to fixed the correct forum prefix
$new_id=add_news($row['review_title'],html_to_comcode($review_description),$row['idauth'],$row['validate'],$com,1,1,'',html_to_comcode($row['review']),$cat_id,array(),$row['date'],get_member(),$row['click']);
ocf_over_local(); //used to fixed the correct forum prefix
// Comments
$comments=$db->query('SELECT * FROM '.$table_prefix.'reviews_comments WHERE id='.strval($row['review_id']).' ORDER BY data');
if (!is_null($forum_id))
{
foreach ($comments as $comment)
{
$member=$comment['id_autore']; //$GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']);
ocf_over_msn(); //used to fixed the correct forum prefix
if (is_null($member)) $member=$GLOBALS['FORUM_DRIVER']->get_guest_id();
ocf_over_local(); //used to fixed the correct forum prefix
$title='';
$post=$comment['testo'];
$content_url=build_url(array('page'=>'news','id'=>$new_id,'type'=>'view'),get_module_zone('news'));
ocf_over_msn(); //used to fixed the correct forum prefix
$GLOBALS['FORUM_DRIVER']->make_post_forum_topic(
$forum_name,
'news_'.strval($new_id),
$member,
$title,
html_to_comcode($post),
$row['title'],
do_lang('COMMENT'),
$content_url->evaluate()
);
ocf_over_local(); //used to fixed the correct forum prefix
}
}
} end of old import reviews code */
// Blogs (imports into community for author)
$rows = $db->query('SELECT * FROM ' . $table_prefix . 'blog');
foreach ($rows as $row) {
$blog_cat_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $row['creato']));
$row['titolo'] = @html_entity_decode($row['titolo'], ENT_QUOTES, get_charset());
ocf_over_msn();
//used to fixed the correct forum prefix
$submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['autore']);
if (is_null($submitting_member_id)) {
$submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
}
ocf_over_local();
//used to fixed the correct forum prefix
if (is_null($blog_cat_id)) {
ocf_over_msn();
//used to fixed the correct forum prefix
$p_nc_title = insert_lang($row['titolo'], 2);
ocf_over_local();
//used to fixed the correct forum prefix
$blog_cat_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitting_member_id), true);
ocf_over_msn();
//used to fixed the correct forum prefix
$groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
ocf_over_local();
//used to fixed the correct forum prefix
foreach (array_keys($groups) as $group_id) {
//.........这里部分代码省略.........
示例15: add_event_type
/**
* Add a calendar event type.
*
* @param SHORT_TEXT The title of the event type
* @param ID_TEXT The theme image code
* @param URLPATH URL to external feed to associate with this event type
* @return AUTO_LINK The ID of the event type
*/
function add_event_type($title, $logo, $external_feed = '')
{
$id = $GLOBALS['SITE_DB']->query_insert('calendar_types', array('t_title' => insert_lang($title, 2), 't_logo' => $logo, 't_external_feed' => $external_feed), true);
log_it('ADD_EVENT_TYPE', strval($id), $title);
return $id;
}