本文整理汇总了PHP中cw_array2insert函数的典型用法代码示例。如果您正苦于以下问题:PHP cw_array2insert函数的具体用法?PHP cw_array2insert怎么用?PHP cw_array2insert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cw_array2insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cw_file_area_save
function cw_file_area_save($type, $for_customer_id, $data)
{
global $tables, $customer_id, $var_dirs, $app_dir;
$insert = array('customer_id' => $for_customer_id, 'by_customer_id' => $customer_id, 'filename' => $data['filename'], 'date' => cw_core_get_time(), 'md5' => md5(file_get_contents($data['file_path'])));
if ($data['descr']) {
$insert['descr'] = $data['descr'];
}
if ($data['id']) {
$insert['id'] = $data['id'];
}
$file_id = cw_array2insert($type, $insert);
if ($file_id) {
$file_info = explode('.', $data['filename'], 2);
$stored_file_name = $file_info[0] . '_' . $file_id . '.' . $file_info[1];
$files_dir = $var_dirs['documents'] . '/' . $type;
if (!is_dir($files_dir)) {
@mkdir($files_dir);
}
$new_file_path = $files_dir . '/' . $stored_file_name;
@copy($data['file_path'], $new_file_path);
@unlink($data['file_path']);
$new_file_path = cw_relative_path($new_file_path, $app_dir);
db_query("update " . $tables[$type] . " set file_path='" . addslashes($new_file_path) . "' where file_id='{$file_id}'");
}
return $file_id;
}
示例2: cw_save_salesman_order
function cw_save_salesman_order($cart_tmp, $doc_id = 0)
{
$salesman_order = array();
$products = $cart_tmp['products'];
$save_fields = array('product_id', 'productcode', 'product', 'warehouse', 'taxed_price', 'taxes', 'extra_data', 'catalog_price', 'product_options', 'amount', 'new', 'free_price', 'price', 'items_in_stock');
if (is_array($products)) {
foreach ($products as $k => $v) {
if ($v['deleted']) {
unset($products[$k]);
continue;
}
foreach ($v as $field => $val) {
if (!in_array($field, $save_fields)) {
unset($products[$k][$field]);
}
}
}
}
$salesman_order['cart'] = addslashes(serialize($products));
$salesman_order['customer_id'] = $cart_tmp['customer_id'];
$salesman_order['salesman_customer_id'] = $cart_tmp['salesman_customer_id'];
$salesman_order['status'] = 0;
if ($doc_id) {
$salesman_order['id'] = $doc_id;
}
return cw_array2insert('salesman_orders', $salesman_order, true);
}
示例3: cw_barcode_create_template
function cw_barcode_create_template($title)
{
$to_insert = array('data' => addslashes(serialize(array('rows' => 5, 'cols' => 10, 'width' => 100, 'height' => 100))), 'layout' => 'barcode', 'title' => $title);
$layout_id = cw_array2insert('layouts', $to_insert);
$to_insert = array('layout_id' => $layout_id, 'template' => 'addons/barcode/layout.tpl', 'class' => 'barcode_layout');
cw_array2insert('layouts_templates', $to_insert);
return $layout_id;
}
示例4: add
function add()
{
global $added_data, $REQUEST_METHOD;
if ($REQUEST_METHOD == "POST") {
$added_data['default_status'] = serialize($added_data['default_status']);
cw_array2insert('product_stages_library', $added_data);
cw_header_location("index.php?target=product_stages");
}
}
示例5: product_stages_add
function product_stages_add()
{
global $new_product_stage, $REQUEST_METHOD, $product_id, $default_status;
if ($REQUEST_METHOD == "POST") {
$new_stage_data = array('product_id' => $product_id, 'stage_lib_id' => $new_product_stage['stage_lib_id'], 'period' => $new_product_stage['period'], 'status' => !empty($default_status['new_product_stage']) ? '-1' : (!empty($new_product_stage['status']) ? serialize($new_product_stage['status']) : ''), 'active' => !empty($new_product_stage['active']) ? 1 : 0);
cw_array2insert('product_stages_product_settings', $new_stage_data);
cw_header_location("index.php?target=products&mode=details&product_id={$product_id}&js_tab=product_stages");
}
}
示例6: cw_array2insert_esc
function cw_array2insert_esc($tab, $arr)
{
foreach ($arr as $k => $v) {
if (preg_match("'\\''", $v)) {
$arr[$k] = addslashes($v);
}
}
return cw_array2insert($tab, $arr);
}
示例7: cw_add_class_data
function cw_add_class_data($data, $product_id)
{
global $tables;
# Update class data
$comp = $data['class'];
$comp['product_id'] = $product_id;
cw_unset($comp, "product_option_id");
$comp = cw_addslashes($comp);
$product_option_id = cw_query_first_cell("SELECT product_option_id FROM {$tables['product_options']} WHERE class = '{$comp['class']}' AND product_id = '{$comp['product_id']}'");
$is_new = empty($product_option_id);
if (!empty($product_option_id)) {
cw_array2update("product_options", $comp, "product_option_id = '{$product_option_id}'");
} else {
$product_option_id = cw_array2insert("product_options", $comp);
}
# Update class multilanguage data
db_query("DELETE FROM {$tables['product_options_lng']} WHERE product_option_id = '{$product_option_id}'");
foreach ($data['product_options_lng'] as $v) {
$v['product_option_id'] = $product_option_id;
$v = cw_addslashes($v);
cw_array2insert("product_options_lng", $v, true);
}
# Update class options
$ids = array();
foreach ($data['product_options_values'] as $k => $opt) {
$opt['product_option_id'] = $product_option_id;
$old_option_id = $opt['option_id'];
cw_unset($opt, "option_id");
$opt = cw_addslashes($opt);
$option_id = cw_query_first_cell("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND name = '{$opt['name']}'");
if (empty($option_id)) {
$option_id = cw_array2insert("product_options_values", $opt);
} else {
cw_array2update("product_options_values", $opt, "option_id = '{$option_id}'");
}
$ids[$old_option_id] = $option_id;
}
# Update class option multilanguage data
db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id = '{$option_id}'");
foreach ($data['product_options_values_lng'] as $v) {
if (!isset($ids[$v['option_id']])) {
continue;
}
$v['option_id'] = $ids[$v['option_id']];
$v = cw_addslashes($v);
cw_array2insert("product_options_values_lng", $v, true);
}
# Detect and delete old product option class options
$ids = cw_query_column("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id NOT IN ('" . implode("','", $ids) . "')");
if (!empty($ids)) {
db_query("DELETE FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id IN ('" . implode("','", $ids) . "')");
db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id IN ('" . implode("','", $ids) . "')");
db_query("DELETE FROM {$tables['products_options_ex']} WHERE option_id IN ('" . implode("','", $ids) . "')");
}
}
示例8: add_video
function add_video($product_id)
{
global $new_video;
assert('!empty($product_id) /* ' . __FUNCTION__ . ' */');
$new_video['product_id'] = $product_id;
$new_video_id = cw_array2insert('product_video', $new_video, false, array('product_id', 'pos', 'title', 'descr', 'code'));
if ($new_video_id) {
cw_add_top_message('Video added');
}
return $new_video_id;
}
示例9: cw_send_simple_mail
function cw_send_simple_mail($from, $to, $subject, $body, $extra_headers = array(), $files = array())
{
global $current_language;
if (empty($to)) {
return;
}
$to = cw_real_mail_address($to);
$language = $language ? $language : $current_language;
$_files = implode(",", $files);
cw_array2insert('mail_spool', cw_addslashes(array('mail_from' => $from, 'mail_to' => $to, 'subject' => $subject, 'body' => $body, 'crypted' => false, 'files' => $_files)));
return;
}
示例10: cw_serials_add
function cw_serials_add($customer_id, $product_id, $serial)
{
global $tables;
$count = cw_query_first_cell("select count(*) from {$tables['serial_numbers']} where sn='{$serial}' and product_id='{$product_id}'");
if ($count) {
return false;
}
$serial = trim($serial);
if (empty($serial)) {
return true;
}
$to_insert = array('sn' => $serial, 'product_id' => $product_id, 'doc_id' => 0, 'warehouse_customer_id' => $customer_id, 'date' => time());
cw_array2insert('serial_numbers', $to_insert);
return true;
}
示例11: dashboard_action_update
function dashboard_action_update()
{
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
dashboard_redirect();
}
$dashboard = $_POST['dashboard'];
if (empty($dashboard)) {
dashboard_redirect();
}
foreach ($dashboard as $name => $dash) {
$data = array('name' => $name, 'pos' => intval($dash['pos']), 'active' => intval($dash['active']));
cw_array2insert('dashboard', $data, true);
}
$top_message = array('content' => cw_get_langvar_by_name('msg_ppd_filetypes_updated_succes'), 'type' => 'I');
dashboard_redirect();
}
示例12: cw_system_messages_add
function cw_system_messages_add($code, $msg, $type = SYSTEM_MESSAGE_COMMON, $severity = SYSTEM_MESSAGE_INFO)
{
global $tables;
$code = mysql_real_escape_string($code);
$msg = mysql_real_escape_string($msg);
$type = intval($type);
$existing = cw_query_first("SELECT code, hidden FROM {$tables['system_messages']} WHERE code='{$code}'");
$data = array('date' => cw_core_get_time(), 'message' => $msg, 'type' => $type, 'severity' => $severity);
if ($existing) {
$ret = cw_array2update('system_messages', $data, "code='{$code}'");
} else {
$data['code'] = $code;
$data['hidden'] = 0;
$ret = cw_array2insert('system_messages', $data);
}
return $ret;
}
示例13: cw_objects_add_to_set
function cw_objects_add_to_set($objects, $type = 'P')
{
global $tables, $customer_id;
if (is_array($objects) && count($objects)) {
$objects = array_unique($objects);
$objects = array_filter($objects, function ($object) {
return !empty($object) && is_numeric($object);
});
if (count($objects)) {
foreach ($objects as $object) {
if (!cw_objects_check_exist($object, $type)) {
cw_array2insert("objects_set", array("object_id" => $object, "customer_id" => $customer_id, "set_type" => $type));
}
}
return TRUE;
}
}
return FALSE;
}
示例14: cw_messages_create_new_message
function cw_messages_create_new_message($customer_id, $sender_name, $recipient_id, $recipient_email, $subject, $body, $conversation_id)
{
global $config, $current_location;
cw_load('email');
// sent message (incoming folder)
$new_message_id = cw_array2insert('messages', array('subject' => $subject, 'body' => $body, 'sender_id' => $customer_id, 'recipient_id' => $recipient_id, 'sending_date' => cw_core_get_time(), 'conversation_id' => !empty($conversation_id) ? $conversation_id : 0, 'conversation_customer_id' => $recipient_id));
// duplicate for sent folder
$current_conversation_id = !empty($conversation_id) ? $conversation_id : $new_message_id;
$duplicate_message_id = cw_array2insert('messages', array('subject' => $subject, 'body' => $body, 'sender_id' => $customer_id, 'recipient_id' => $recipient_id, 'sending_date' => cw_core_get_time(), 'read_status' => 1, 'conversation_id' => $current_conversation_id, 'conversation_customer_id' => $customer_id, 'type' => 2, 'link_id' => $new_message_id));
// unite message if they have not been united
$data = array('link_id' => $duplicate_message_id);
if (empty($conversation_id)) {
$data['conversation_id'] = $new_message_id;
}
cw_array2update('messages', $data, "message_id = '{$new_message_id}'");
// send notification email to recipient
// notification is sent from system email and says about new received message from Sender at <sitename>
$from = $config['Company']['site_administrator'];
/*
$mail_subject = "The notification of a new message";
$mail_body = '<b>You have received a new message from "' . $sender_name . '" at <a href="' . $current_location . '">';
$mail_body .= $config['Company']['company_name'] . '</a></b><br />';
$mail_body .= '<b>Subject:</b> ' . $subject . '<br />';
$mail_body .= '<b>Body:</b> ' . nl2br($body) . '<br />';
$mail_body .= '<a href="' . $current_location . '/index.php?target=message_box&mode=new';
$mail_body .= '&contact_id=' . $customer_id . '&conversation_id=' . $current_conversation_id . '">Link to reply</a><br />';
cw_send_simple_mail($from, $recipient_email, $mail_subject, $mail_body);
*/
global $smarty;
$smarty->assign('sender_name', $sender_name);
$smarty->assign('current_location', $current_location);
$smarty->assign('config', $config);
$smarty->assign('subject', $subject);
$smarty->assign('body', $body);
$smarty->assign('customer_id', $customer_id);
$smarty->assign('recipient_id', $recipient_id);
$smarty->assign('current_conversation_id', $current_conversation_id);
$smarty->assign('new_message_id', $new_message_id);
cw_call('cw_send_mail', array($from, $recipient_email, 'addons/messaging_system/mail/new_message_subj.tpl', 'addons/messaging_system/mail/new_message.tpl'));
return $new_message_id;
}
示例15: on_profile_modify
function on_profile_modify($customer_id, $profile)
{
if (!isset($profile['mailing_list'])) {
return true;
}
$user = \Customer\get($customer_id);
if (empty($user)) {
return null;
}
global $tables;
db_query("DELETE FROM {$tables['newslist_subscription']} WHERE email='{$user['email']}' AND list_id NOT IN ('" . join("','", array_keys($profile['mailing_list'])) . "')");
foreach ($profile['mailing_list'] as $lid => $v) {
if (!is_numeric($lid) || $lid < 1) {
continue;
}
$is_subscribed = (bool) cw_query("SELECT list_id FROM {$tables['newslist_subscription']} WHERE email='{$user['email']}' AND list_id='{$lid}'");
if (!$is_subscribed && $v) {
$data = array('list_id' => $lid, 'email' => $user['email']);
cw_array2insert('newslist_subscription', $data);
}
}
}