예제 #1
0
파일: articles.php 프로젝트: tareqy/Caracal
 /**
  * Save changed group data
  */
 private function saveGroup()
 {
     $manager = ArticleGroupManager::getInstance();
     $id = isset($_REQUEST['id']) ? fix_id($_REQUEST['id']) : null;
     $text_id = escape_chars($_REQUEST['text_id']);
     $title = $this->getMultilanguageField('title');
     $description = $this->getMultilanguageField('description');
     $data = array('text_id' => $text_id, 'title' => $title, 'description' => $description);
     if (is_null($id)) {
         $window = 'article_groups_new';
         $manager->insertData($data);
     } else {
         $window = 'article_groups_change';
         $manager->updateData($data, array('id' => $id));
     }
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_group_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close($window) . ';' . window_ReloadContent('article_groups'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #2
0
파일: backend.php 프로젝트: tareqy/Caracal
 /**
  * Disable specified module and remove it's settings
  */
 private function disableModule_Commit()
 {
     $module_name = fix_chars($_REQUEST['module_name']);
     if (!in_array($module_name, $this->protected_modules)) {
         // module is not protected
         $manager = ModuleManager::getInstance();
         $max_order = $manager->getItemValue("MAX(`order`)", array('preload' => 0));
         if (is_null($max_order)) {
             $max_order = -1;
         }
         $manager->deleteData(array('name' => $module_name));
         if (class_exists($module_name)) {
             $module = call_user_func(array($module_name, 'getInstance'));
             $module->onDisable();
             $message = $this->getLanguageConstant('message_module_disabled');
         } else {
             $message = $this->getLanguageConstant('message_module_not_active');
         }
     } else {
         $message = $this->getLanguageConstant('message_module_protected');
     }
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $message, 'action' => window_Close($this->name . '_module_dialog') . ";" . window_ReloadContent('system_modules'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #3
0
 /**
  * Perform interval removal.
  */
 private function delete_interval_commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = IntervalManager::getInstance();
     $time_manager = IntervalTimeManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $time_manager->deleteData(array('interval' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_interval_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('delivery_intervals_delete') . ';' . window_ReloadContent('delivery_intervals'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #4
0
 /**
  * Perform item removal from specified page
  */
 private function pageItems_Delete_Commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = UserPageItemsManager::getInstance();
     // remove item from database
     $manager->deleteData(array('id' => $id));
     // show message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_page_item_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('user_pages_items_delete') . ';' . window_ReloadContent('user_pages_items'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #5
0
파일: callbox.php 프로젝트: tareqy/Caracal
 /**
  * Save settings.
  */
 private function saveSettings()
 {
     // grab parameters
     $account_id = fix_chars($_REQUEST['account_id']);
     $account_key = fix_chars($_REQUEST['account_key']);
     $account_secret = fix_chars($_REQUEST['account_secret']);
     $include_code = isset($_REQUEST['include_code']) && ($_REQUEST['include_code'] == 'on' || $_REQUEST['include_code'] == '1') ? 1 : 0;
     $this->saveSetting('account_id', $account_id);
     $this->saveSetting('account_key', $account_key);
     $this->saveSetting('account_secret', $account_secret);
     $this->saveSetting('include_code', $include_code);
     // show message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('callbox_settings'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #6
0
 /**
  * Perfrom field removal.
  */
 private function deleteField_Commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = ContactForm_FormFieldManager::getInstance();
     $form = $manager->getItemValue('form', array('id' => $id));
     $manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_field_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('contact_form_fields_delete') . ';' . window_ReloadContent('contact_form_fields_' . $form));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #7
0
 /**
  * Save selection of email templates.
  */
 private function saveTemplateSelection()
 {
     // save configuration
     $template_verify = fix_chars($_REQUEST['template_verify']);
     $template_recovery = fix_chars($_REQUEST['template_recovery']);
     $this->parent->saveTemplateSelection($template_verify, $template_recovery);
     // show message
     $template = new TemplateHandler('message.xml', $this->parent->path . 'templates/');
     $template->setMappedModule($this->parent->name);
     $params = array('message' => $this->parent->getLanguageConstant('message_template_selection_saved'), 'button' => $this->parent->getLanguageConstant('close'), 'action' => window_Close('system_users_email_templates'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #8
0
파일: shop.php 프로젝트: tareqy/Caracal
 /**
  * Save settings
  */
 private function saveSettings()
 {
     // save new settings
     $payment_completed = fix_chars($_REQUEST['payment_completed_template']);
     $recurring_started = fix_chars($_REQUEST['recurring_payment_started_template']);
     $recurring_canceled = fix_chars($_REQUEST['recurring_payment_canceled_template']);
     $shop_location = fix_chars($_REQUEST['shop_location']);
     $fixed_country = fix_chars($_REQUEST['fixed_country']);
     $testing_mode = fix_id($_REQUEST['testing_mode']);
     $this->saveSetting('payment_completed_template', $payment_completed);
     $this->saveSetting('recurring_payment_started_template', $recurring_started);
     $this->saveSetting('recurring_payment_canceled_template', $recurring_canceled);
     $this->saveSetting('shop_location', $shop_location);
     $this->saveSetting('fixed_country', $fixed_country);
     $this->saveSetting('testing_mode', $testing_mode);
     // show message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('shop_settings'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #9
0
 /**
  * Save new or changed API key.
  */
 private function saveApiKey()
 {
     $api_key = fix_chars($_REQUEST['api_key']);
     $this->saveSetting('api_key', $api_key);
     // prepare and parse result message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_api_key_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('page_speed_set_api_key'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #10
0
 /**
  * Present confirmation dialog before logout
  */
 private function logout()
 {
     $template = new TemplateHandler('confirmation.xml', $this->parent->path . 'templates/');
     $template->setMappedModule($this->parent->name);
     $params = array('message' => $this->parent->getLanguageConstant('message_logout'), 'name' => '', 'yes_text' => $this->parent->getLanguageConstant('logout'), 'no_text' => $this->parent->getLanguageConstant('cancel'), 'yes_action' => window_LoadContent('logout_window', backend_UrlMake($this->parent->name, 'logout_commit')), 'no_action' => window_Close('logout_window'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #11
0
 /**
  * Save settings
  */
 private function saveSettings()
 {
     $secret_key = fix_chars($_REQUEST['secret_key']);
     $public_key = fix_chars($_REQUEST['public_key']);
     $this->saveSetting('secret_key', $secret_key);
     $this->saveSetting('public_key', $public_key);
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('stripe'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #12
0
파일: tranzila.php 프로젝트: tareqy/Caracal
 private function saveSettings()
 {
     $terminal_name = fix_chars($_REQUEST['terminal']);
     $this->saveSetting('terminal', $terminal_name);
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('tranzila'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #13
0
파일: mandrill.php 프로젝트: tareqy/Caracal
 /**
  * Save new settings.
  */
 private function saveSettings()
 {
     // save setting
     $this->saveSetting('api_key', fix_chars($_REQUEST['api_key']));
     // show message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('mandrill_settings'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #14
0
파일: paypal.php 프로젝트: tareqy/Caracal
 /**
  * Mark plan as deleted.
  */
 private function deletePlan_Commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = PayPal_PlansManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_plan_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('paypal_recurring_plans_delete') . ';' . window_ReloadContent('paypal_recurring_plans'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
 /**
  * Perform price removal
  */
 private function deletePrice_Commit()
 {
     $manager = ShopDeliveryMethodPricesManager::getInstance();
     $relations_manager = ShopDeliveryItemRelationsManager::getInstance();
     $id = fix_id($_REQUEST['id']);
     $manager->deleteData(array('id' => $id));
     $relations_manager->deleteData(array('price' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->_parent->name);
     $params = array('message' => $this->_parent->getLanguageConstant("message_delivery_price_deleted"), 'button' => $this->_parent->getLanguageConstant("close"), 'action' => window_Close('shop_delivery_price_delete') . ";" . window_ReloadContent('shop_delivery_method_prices'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #16
0
파일: links.php 프로젝트: tareqy/Caracal
 /**
  * Save link group memberships
  */
 private function groupLinksSave()
 {
     $group = fix_id(fix_chars($_REQUEST['group']));
     $membership_manager = LinkMembershipManager::getInstance();
     // fetch all ids being set to specific group
     $link_ids = array();
     foreach ($_REQUEST as $key => $value) {
         if (substr($key, 0, 8) == 'link_id_' && $value == 1) {
             $link_ids[] = fix_id(substr($key, 8));
         }
     }
     // remove old memberships
     $membership_manager->deleteData(array('group' => $group));
     // save new memberships
     foreach ($link_ids as $id) {
         $membership_manager->insertData(array('link' => $id, 'group' => $group));
     }
     // display message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant("message_group_links_updated"), 'button' => $this->getLanguageConstant("close"), 'action' => window_Close('groups_links'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #17
0
 /**
  * Show affiliate information.
  */
 private function showAffiliateInformation()
 {
     global $url_rewrite;
     $manager = AffiliatesManager::getInstance();
     $user_id = $_SESSION['uid'];
     $affiliate = $manager->getSingleItem($manager->getFieldNames(), array('user' => $user_id));
     if (is_object($affiliate)) {
         $template = new TemplateHandler('information.xml', $this->path . 'templates/');
         $template->setMappedModule($this->name);
         if ($affiliate->clicks > 0) {
             $rate = round(100 * $affiliate->conversions / $affiliate->clicks, 2);
         } else {
             $rate = 0;
         }
         $params = array('uid' => $affiliate->uid, 'name' => $affiliate->name, 'clicks' => $affiliate->clicks, 'conversions' => $affiliate->conversions, 'rate' => $rate, 'url_rewrite' => $url_rewrite ? 'true' : 'false', 'cancel_action' => window_Close('affiliate_information'));
         $template->restoreXML();
         $template->setLocalParams($params);
         $template->parse();
     }
 }
예제 #18
0
 /**
  * Save default currency
  */
 private function saveDefault()
 {
     $currency = fix_chars($_REQUEST['currency']);
     $this->_parent->saveDefaultCurrency($currency);
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->_parent->getLanguageConstant('message_default_currency_saved'), 'button' => $this->_parent->getLanguageConstant('close'), 'action' => window_Close('shop_currencies_set_default'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #19
0
파일: tips.php 프로젝트: tareqy/Caracal
 /**
  * Perform tip removal
  */
 private function deleteTip_Commit()
 {
     $id = fix_id(fix_chars($_REQUEST['id']));
     $manager = TipManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant("message_tip_deleted"), 'button' => $this->getLanguageConstant("close"), 'action' => window_Close('tips_delete') . ";" . window_ReloadContent('tips'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #20
0
 /**
  * Perform category removal
  */
 private function deleteCategory_Commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = ShopCategoryManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->_parent->getLanguageConstant('message_category_deleted'), 'button' => $this->_parent->getLanguageConstant('close'), 'action' => window_Close('shop_category_delete') . ";" . window_ReloadContent('shop_categories'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #21
0
 /**
  * Perform manufacturer removal
  */
 private function deleteManufacturer_Commit()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = ShopManufacturerManager::getInstance();
     $item_manager = ShopItemManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $item_manager->updateData(array('manufacturer' => 0), array('manufacturer' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->_parent->getLanguageConstant("message_manufacturer_deleted"), 'button' => $this->_parent->getLanguageConstant("close"), 'action' => window_Close('shop_manufacturer_delete') . ";" . window_ReloadContent('shop_manufacturers'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #22
0
파일: fedex.php 프로젝트: tareqy/Caracal
 /**
  * Save settings.
  */
 private function saveSettings()
 {
     $key = fix_chars($_REQUEST['key']);
     $password = fix_chars($_REQUEST['password']);
     $account = fix_chars($_REQUEST['account']);
     $meter = fix_chars($_REQUEST['meter']);
     $this->saveSetting('fedex_key', $key);
     $this->saveSetting('fedex_password', $password);
     $this->saveSetting('fedex_account', $account);
     $this->saveSetting('fedex_meter', $meter);
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('fedex'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #23
0
 /**
  * Save settings
  */
 private function saveSettings()
 {
     $description = fix_chars($_REQUEST['description']);
     $analytics = fix_chars($_REQUEST['analytics']);
     $analytics_domain = fix_chars($_REQUEST['analytics_domain']);
     $analytics_version = fix_chars($_REQUEST['analytics_version']);
     $wm_tools = fix_chars($_REQUEST['wm_tools']);
     $bing_wm_tools = fix_chars($_REQUEST['bing_wm_tools']);
     $optimizer = fix_chars($_REQUEST['optimizer']);
     $optimizer_key = fix_chars($_REQUEST['optimizer_key']);
     $this->saveSetting('description', $description);
     $this->saveSetting('analytics', $analytics);
     $this->saveSetting('analytics_domain', $analytics_domain);
     $this->saveSetting('analytics_version', $analytics_version);
     $this->saveSetting('wm_tools', $wm_tools);
     $this->saveSetting('bing_wm_tools', $bing_wm_tools);
     $this->saveSetting('optimizer', $optimizer);
     $this->saveSetting('optimizer_key', $optimizer_key);
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('page_settings'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #24
0
파일: comments.php 프로젝트: tareqy/Caracal
 /**
  * Save comment data and send response as JSON Object
  */
 private function saveCommentData()
 {
     if ($this->_canPostComment()) {
         $module = isset($_REQUEST['module']) && !empty($_REQUEST['module']) ? fix_chars($_REQUEST['module']) : null;
         $comment_section = isset($_REQUEST['comment_section']) && !empty($_REQUEST['comment_section']) ? fix_chars($_REQUEST['comment_section']) : null;
         $user = fix_chars($_REQUEST['user']);
         $email = fix_chars($_REQUEST['email']);
         $message = fix_chars($_REQUEST['comment']);
         if (strlen($message) > $this->settings['size_limit']) {
             $tmp = str_split($message, $this->settings['size_limit']);
             $message = $tmp[0];
         }
         if (!is_null($module) || !is_null($comment_section)) {
             $data = array('module' => $module, 'section' => $comment_section, 'user' => $user, 'email' => $email, 'address' => isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'], 'message' => $message, 'visible' => $this->settings['default_visibility']);
             $manager = CommentManager::getInstance();
             $manager->insertData($data);
             $response_message = $this->getLanguageConstant('message_saved');
         } else {
             // invalide module and/or comment section
             $response_message = $this->getLanguageConstant('message_error');
         }
     } else {
         $response_message = str_replace('%t', $this->settings['repost_time'], $this->getLanguageConstant('message_error_repost_time'));
     }
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $reponse_message, 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('comments_settings'));
     $params = array_merge($params, $this->settings);
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #25
0
 /**
  * Import items from uploaded file.
  */
 private function import_from_file()
 {
     global $db, $site_path;
     $gallery = gallery::getInstance();
     $gallery_manager = GalleryManager::getInstance();
     $languages = Language::getLanguages(false);
     $item_manager = ShopItemManager::getInstance();
     $category_manager = ShopCategoryManager::getInstance();
     $property_manager = \Modules\Shop\Property\Manager::getInstance();
     $membership_manager = \ShopItemMembershipManager::getInstance();
     // load categories
     $categories = array();
     $raw_categories = $category_manager->getItems($category_manager->getFieldNames(), array());
     if (count($raw_categories) > 0) {
         foreach ($raw_categories as $category) {
             $categories[$category->id] = $category->title[self::DEFAULT_LANGUAGE];
         }
     }
     // load existing items
     $existing_items = array();
     $items = $item_manager->getItems(array('id', 'uid'), array());
     foreach ($items as $item) {
         $existing_items[$item->uid] = $item->id;
     }
     // load existing images
     $existing_images = array();
     $images = $gallery_manager->getItems(array('group', 'text_id', 'id'), array());
     if (count($images) > 0) {
         foreach ($images as $image) {
             // make sure we have storage array
             if (!array_key_exists($image->group, $existing_images)) {
                 $existing_images[$image->group] = array();
             }
             // add image to the list
             $existing_images[$image->group][$image->id] = $image->text_id;
         }
     }
     $image_list = scandir(_BASEPATH . '/' . $site_path . 'import/');
     // load csv file
     $csv_data = $this->load_csv_file($_FILES['import']['tmp_name']);
     array_shift($csv_data);
     // remove header
     $number_to_import = isset($_REQUEST['number_to_import']) && !empty($_REQUEST['number_to_import']) ? fix_id($_REQUEST['number_to_import']) : count($csv_data);
     $counter = 0;
     foreach ($csv_data as $row) {
         // make sure we are within our limits
         if (++$counter > $number_to_import) {
             break;
         }
         // get item name and description
         $item_name = array_fill(0, count($languages), '');
         $item_name = array_combine($languages, $item_name);
         $item_description = $item_name;
         $item_name['he'] = $db->escape_string($row[self::COL_NAME_HE]);
         $item_name['ru'] = $db->escape_string($row[self::COL_NAME_RU]);
         $item_description['he'] = $db->escape_string($row[self::COL_DESCRIPTION_HE]);
         $item_description['ru'] = $db->escape_string($row[self::COL_DESCRIPTION_RU]);
         // unpack price values
         $prices = explode(',', $row[self::COL_PRICE]);
         $price_names = explode(',', $row[self::COL_SIZE_LABELS]);
         // generate uid and check if item exists in database
         $uid = hash('sha256', 'item_' . $row[self::COL_ID]);
         if (array_key_exists($uid, $existing_items)) {
             $data = array('name' => $item_name, 'description' => $item_description, 'price' => count($prices) > 0 ? floatval($prices[0]) : 0);
             $item_id = $existing_items[$uid];
             $item_manager->updateData($data, array('id' => $item_id));
             $gallery_id = $item_manager->getItemValue('gallery', array('id' => $item_id));
         } else {
             // prepare data
             $data = array('name' => $item_name, 'description' => $item_description, 'price' => count($prices) > 0 ? floatval($prices[0]) : 0, 'colors' => '', 'tax' => 0, 'weight' => 0, 'manufacturer' => 0, 'uid' => $uid);
             // store author of the uploaded item
             $data['author'] = $_SESSION['uid'];
             // create item gallery
             $gallery_id = $gallery->createGallery($item_name);
             $data['gallery'] = $gallery_id;
             // add item to the database
             $item_manager->insertData($data);
             $item_id = $item_manager->getInsertedID();
         }
         // remove existing prices
         $property_manager->deleteData(array('item' => $item_id, 'text_id' => array('operator' => 'LIKE', 'value' => 'price_%')));
         // create price properties
         if (count($prices) > 1) {
             // generate default name
             $price_name = array_fill(0, count($languages), '');
             $price_name = array_combine($languages, $price_name);
             for ($i = 1; $i < count($prices); $i++) {
                 // set and reset specified name
                 if (isset($price_names[$i])) {
                     $price_name[self::DEFAULT_LANGUAGE] = $price_names[$i];
                 } else {
                     $price_name[self::DEFAULT_LANGUAGE] = '';
                 }
                 // prepare data for insertion
                 $price_data = array('item' => $item_id, 'name' => $price_name, 'text_id' => 'price_' . $this->size_names[$i - 1], 'type' => 'decimal', 'value' => serialize(floatval($prices[$i])));
                 // insert new price property
                 $property_manager->insertData($price_data);
             }
         }
         // remove existing category membership
         $membership_manager->deleteData(array('item' => $item_id));
         // assign category membership
         for ($i = self::COL_FIRST_CATEGORY; $i < count($row); $i++) {
             $category_name = $row[$i];
             $category_id = $this->get_category_for_name($categories, $category_name, self::DEFAULT_THRESHOLD);
             if (!is_null($category_id)) {
                 $membership_manager->insertData(array('category' => $category_id, 'item' => $item_id));
             }
         }
         // upload images
         $image_file = mb_strtolower($row[self::COL_IMAGE]);
         $matched_file = $this->match_image_file($image_list, $image_file, 6);
         // we require a valid match
         if (!is_null($matched_file)) {
             $matched_hash = hash('md5', $matched_file);
             $source_path = _BASEPATH . '/' . $site_path . 'import/' . $matched_file;
             $destination_file = hash('md5', $matched_file . strval(time())) . '.' . pathinfo(strtolower($matched_file), PATHINFO_EXTENSION);
             $destination_path = _BASEPATH . '/' . $site_path . 'gallery/images/' . $destination_file;
             $image_already_uploaded = array_key_exists($gallery_id, $existing_images) && !in_array($matched_hash, $existing_images[$gallery_id]);
             $file_size = filesize($source_path);
             // only upload image if it wasn't uploaded already
             if (!$image_already_uploaded && copy($source_path, $destination_path)) {
                 $gallery_manager->insertData(array('group' => $gallery_id, 'title' => $item_name, 'text_id' => $matched_hash, 'size' => $file_size, 'filename' => $destination_file, 'visible' => 1, 'slideshow' => 0, 'protected' => 0));
             }
         }
     }
     // show result message
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant('message_import_complete'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('shop_import_items'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
예제 #26
0
파일: leads.php 프로젝트: tareqy/Caracal
 /**
  * Perform lead type removal
  */
 private function deleteType_commit()
 {
     $id = fix_id(fix_chars($_REQUEST['id']));
     $type_manager = LeadsTypesManager::getInstance();
     $entries_manager = LeadsEntriesManager::getInstance();
     $entry_data_manager = LeadsEntryDataManager::getInstance();
     $entry_ids = array();
     // get list of entries to remove
     $entries = $entries_manager->getItems(array('id'), array('type' => $id));
     if (count($entries) > 0) {
         foreach ($entries as $entry) {
             $entry_ids[] = $entry->id;
         }
     }
     // perform data removal
     if (count($entry_ids) > 0) {
         $entry_data_manager->deleteData(array('entry' => $entry_ids));
     }
     $entries_manager->deleteData(array('type' => $id));
     $type_manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $window_name = 'leads_types_delete';
     $params = array('message' => $this->getLanguageConstant('message_types_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close($window_name) . ";" . window_ReloadContent('leads_types'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }