コード例 #1
0
 /**
  * @param int $order_status_id
  * @param array $data
  */
 public function editOrderStatus($order_status_id, $data)
 {
     $language_id = $this->language->getContentLanguageID();
     if ($data['name']) {
         $this->language->updateDescriptions('order_statuses', array('order_status_id' => (int) $order_status_id, 'language_id' => (int) $language_id), array($language_id => array('name' => $data['name'])));
     }
     $status_text_id = preformatTextID($data['status_text_id']);
     if ($status_text_id) {
         $sql = "UPDATE " . $this->db->table('order_status_ids') . "\n\t\t\t\t\tSET status_text_id = '" . $this->db->escape($status_text_id) . "'\n\t\t\t\t\tWHERE order_status_id = '" . $order_status_id . "'";
         $this->db->query($sql);
     }
     $this->cache->remove('localization');
 }
コード例 #2
0
 public function addStatus($order_status_id, $status_text_id)
 {
     $order_status_id = (int) $order_status_id;
     //preformat text_id at first
     $status_text_id = preformatTextID($status_text_id);
     if (in_array($order_status_id, array_keys($this->statuses)) || in_array($status_text_id, $this->statuses)) {
         $error_text = 'Error: Cannot add new order status with id ' . $order_status_id . ' and text id ' . $status_text_id . ' into AOrderStatus class.';
         $e = new AError($error_text);
         $e->toLog()->toDebug();
         return false;
     }
     if (!$status_text_id) {
         $error_text = 'Error: Cannot add new order status with id ' . $order_status_id . ' and empty text id';
         $e = new AError($error_text);
         $e->toLog()->toDebug();
         return false;
     }
     $this->statuses[$order_status_id] = $status_text_id;
     return true;
 }
 private function _getCustomBlockInfo4Xml($custom_block_id)
 {
     $custom_block_id = (int) $custom_block_id;
     $sql = "SELECT bd.*, l.directory as language_name, cb.block_id, b.block_txt_id as base_block_txt_id\n\t\t\t\tFROM " . DB_PREFIX . "block_descriptions bd\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "custom_blocks cb ON cb.custom_block_id = bd.custom_block_id\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "blocks b ON b.block_id = cb.block_id\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "languages l ON l.language_id = bd.language_id\n\t\t\t\tWHERE bd.custom_block_id = '" . (int) $custom_block_id . "'\n\t\t\t\tORDER BY bd.language_id";
     $result = $this->db->query($sql);
     if (!$result->num_rows) {
         return array();
     }
     $output['custom_block_txt_id'] = preformatTextID($result->rows[0]['name']) . "_" . $custom_block_id;
     /**
      * @deprecated
      * TODO : need to delete processing of tags <kind> from layout manager in the future
      */
     $output['kind'] = 'custom';
     $output['type'] = $result->rows[0]['base_block_txt_id'];
     foreach ($result->rows as $row) {
         $output['block_descriptions']['block_description'][] = array('language' => $row['language_name'], 'name' => array('@cdata' => $row['name']), 'title' => array('@cdata' => $row['title']), 'block_wrapper' => array('@cdata' => $row['block_wrapper']), 'block_framed' => array('@cdata' => $row['block_framed']), 'description' => array('@cdata' => $row['description']), 'content' => array('@cdata' => $row['content']));
     }
     $placeholder = $this->_getBlockInfo4Xml($this->placeholder_block_id);
     $output['installed']['placeholder'][] = $placeholder['block_txt_id'];
     return $output;
 }
コード例 #4
0
 /**
  * method inserts new item to the end of menu level
  *
  * @param array $item("item_id"=>"","parent_id"=>"","item_text"=>,"rt"=>"","sort_order"=>"", "item_type" => "")
  * @throws AException
  * @return boolean
  */
 public function insertMenuItem($item = array())
 {
     if (!IS_ADMIN) {
         // forbid for non admin calls
         throw new AException(AC_ERR_LOAD, 'Error: permission denied to change menu');
     }
     //clean text id
     $item["item_id"] = preformatTextID($item["item_id"]);
     $check_array = array("item_id", "item_icon", "item_text", "item_url", "parent_id", "sort_order", "item_type", "item_icon_rl_id");
     if (!$item["item_id"] || !$item["item_text"] || sizeof(array_intersect($check_array, array_keys($item))) < 7) {
         return 'Error: Cannot to add menu item because item array is wrong.';
     }
     if ($item['parent_id'] && !in_array($item['parent_id'], $this->item_ids)) {
         return 'Error: Cannot to add menu item because parent "' . $item['parent_id'] . '" is not exists';
     }
     if (!$item["sort_order"]) {
         // we need to know last order number of children and set new for new item... yet
         $brothers = $this->getMenuChildren($item["parent_id"]);
         $new_sort_order = 0;
         if ($brothers) {
             foreach ($brothers as $brother) {
                 $new_sort_order = $brother['sort_order'] > $new_sort_order ? $brother['sort_order'] : $new_sort_order;
             }
         }
         $new_sort_order += 10;
         $item["sort_order"] = $new_sort_order;
     }
     // concatenate parent_name with item name
     if (!$item['item_type']) {
         $item['item_type'] = 'extension';
     }
     // checks for unique item_id
     if (in_array($item["item_id"], $this->item_ids)) {
         return 'Error: Cannot to add menu item because item with item_id "' . $item["item_id"] . '" is already exists.';
     }
     $row = $item;
     unset($row['item_text']);
     //insert row in storefront
     $result = $this->dataset->addRows(array($row));
     //insert language data in storefront_description
     $item_text = array();
     foreach ($item['item_text'] as $language_id => $text) {
         $item_text[] = array('item_id' => $item['item_id'], 'language_id' => $language_id, 'item_text' => $text);
     }
     $this->dataset_decription->addRows($item_text);
     // rebuild menu var after changing
     $this->_buildMenu();
     $this->registry->get('cache')->delete('storefront_menu');
     return $result;
 }
コード例 #5
0
 private function _filterField($fields, $props, $field_name)
 {
     $output = array();
     foreach ($props as $n => $properties) {
         if (preformatTextID($field_name) == preformatTextID($properties['name']) || is_int(strpos($field_name, 'config_description')) && is_int(strpos($properties['name'], 'config_description'))) {
             $names = array_keys($fields);
             $name = $names[$n];
             $output = array($name => $fields[$name]);
             break;
         }
     }
     return $output;
 }
コード例 #6
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('encryption_data_manager/encryption_data_manager');
     $this->document->setTitle($this->language->get('encryption_data_manager_name'));
     $this->load->model('setting/setting');
     /** @var $enc ASSLEncryption */
     $enc = new ASSLEncryption();
     if (!$enc->active || !$enc->getKeyPath()) {
         $this->error['warning'] = $this->language->get('error_openssl_disabled');
     }
     /** @var $enc_data ADataEncryption */
     $enc_data = new ADataEncryption();
     if (!$enc_data->active) {
         $this->error['warning'] = $this->language->get('error_data_encryption_disabled');
     }
     if ($this->request->is_POST() && $this->_validate()) {
         $this->cache->delete('encryption.keys');
         $new_keys = array();
         foreach ($this->request->post as $key => $value) {
             $matches = array();
             if (preg_match('/^new_key_for_(.*)$/', $key, $matches) && (int) $value > 0) {
                 $new_keys[$matches[1]] = (int) $value;
             }
         }
         if (!empty($this->request->post['key_name'])) {
             //key creation ste
             $this->request->post['key_name'] = preformatTextID($this->request->post['key_name']);
             $keys = $this->_create_key_pair($this->request->post);
             if ($keys['public'] || $keys['private']) {
                 $this->session->data['success'] = sprintf($this->language->get('text_success_key_get'), $keys['public'], $keys['private']);
             } else {
                 $this->error['warning'] = $this->language->get('error_generating_keys_failed');
             }
         } else {
             if (!empty($this->request->post['enc_key'])) {
                 //encryption step
                 $enc_result = $this->_initial_data_encryption($this->request->post);
                 if ($this->request->post['enc_test_mode']) {
                     $this->session->data['success'] = sprintf($this->language->get('text_encryption_test'), implode('<br/>', $enc_result['result']));
                 } else {
                     if (count($enc_result['result']) && !count($enc_result['errors'])) {
                         $this->session->data['success'] = '<br>' . sprintf($this->language->get('text_success_encrypting'), implode('<br/>', $enc_result['result']), $enc_result['key_name']);
                     } else {
                         if (count($enc_result['result']) && count($enc_result['errors'])) {
                             //mixed restult
                             $this->session->data['success'] = '<br>' . sprintf($this->language->get('text_success_encrypting'), implode('<br/>', $enc_result['result']), $enc_result['key_name']);
                             $this->error['warning'] = '<br>' . implode('<br/>', $enc_result['errors']);
                         } else {
                             $this->error['warning'] = $this->language->get('error_encrypting');
                         }
                     }
                 }
             } else {
                 if (count($new_keys)) {
                     //re-encryption step
                     $enc_result = array();
                     foreach ($new_keys as $old_key_id => $new_key_id) {
                         $enc_result = $this->_key_rotation(array('old_key' => $old_key_id, 'new_key' => $new_key_id));
                         if (count($enc_result['result']) && !count($enc_result['errors'])) {
                             $this->session->data['success'] .= sprintf($this->language->get('text_success_encrypting'), implode('<br/>', $enc_result['result']), $enc_result['key_name']);
                         } else {
                             if (count($enc_result['result']) && count($enc_result['errors'])) {
                                 //mixed result
                                 $this->session->data['success'] .= sprintf($this->language->get('text_success_encrypting'), implode('<br/>', $enc_result['result']), $enc_result['key_name']);
                                 $this->error['warning'] = '<br>' . implode('<br/>', $enc_result['errors']);
                             } else {
                                 $this->error['warning'] .= $this->language->get('error_encrypting');
                             }
                         }
                     }
                 } else {
                     $this->error['warning'] = $this->language->get('error_required_data_missing');
                 }
             }
         }
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->data['success'] = $this->session->data['success'];
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('eextension/extensions/extensions'), 'text' => $this->language->get('text_extensions'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('extension/encryption_data_manager'), 'text' => $this->language->get('encryption_data_manager_name'), 'separator' => ' :: ', 'current' => true));
     foreach ($this->fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } else {
             $this->data[$f] = $this->config->get($f);
         }
     }
     //Build sections for display
     $this->data['action'] = $this->html->getSecureURL('extension/encryption_data_manager', '&extension=encryption_data_manager');
     $this->data['cancel'] = $this->html->getSecureURL('extension/encryption_data_manager');
     $this->data['heading_title'] = $this->language->get('text_additional_settings');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/extension/update', '&id=encryption_data_manager');
     //load existing keys.
     $pub_keys_options = $this->_load_key_names($enc, 1);
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'keyRotaionFrm', 'update' => $this->data['update']));
     //encription usage section
     $enc_usage = array();
     $enc_usage['section_id'] = 'enc_usage';
     $enc_usage['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'keyRotaionFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
     $enc_usage['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_encrypt_data')));
     $enc_usage['form']['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset')));
     $enc_usage['name'] = $this->language->get('encryption_usage');
     $enc_usage['form_title'] = $enc_usage['name'];
     //load un-encrepted data usage
     $this->data['unencrypted_stats'] = $this->_load_unencrypted_stats($enc_data);
     //load encrepted data usage
     $usage = $this->_load_usage_details($enc, $enc_data);
     //add new key selector to each row
     foreach ($usage as $i => $u) {
         //remove current key
         $key_list = $pub_keys_options;
         unset($key_list[$u['key_id']]);
         $key_list[0] = "--";
         $usage[$i]['actons'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'new_key_for_' . $u['key_id'], 'options' => $key_list, 'value' => 0));
     }
     $enc_usage['usage_details'] = $usage;
     $this->data['sections'][] = $enc_usage;
     //key generation section
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'keyGenFrm', 'update' => $this->data['update']));
     $key_gen = array();
     $key_gen['section_id'] = 'key_gen';
     $key_gen['name'] = $this->language->get('key_gen_section_name');
     $key_gen['form_title'] = $key_gen['name'];
     $key_gen['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'keyGenFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
     $key_gen['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_generate_keys')));
     $key_gen['form']['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset')));
     $key_gen['form']['fields']['key_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'key_name', 'value' => $this->data['key_name'], 'required' => true));
     $key_gen['form']['fields']['key_length'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'key_length', 'value' => !$this->data['key_length'] ? 2048 : $this->data['key_length']));
     $key_gen['form']['fields']['private_key_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'private_key_type', 'options' => array(OPENSSL_KEYTYPE_RSA => 'OPENSSL_KEYTYPE_RSA'), 'value' => $this->data['private_key_type']));
     /*
     		* Password protected key is not supported 
     		$key_gen['form']['fields']['encrypt_key'] = $form->getFieldHtml(array(
     				'type' => 'checkbox',
     				'name' => 'encrypt_key',
     				'value' => $this->data['encrypt_key'],
     				'style'  => 'btn_switch',
     			));
     $key_gen['form']['fields']['passphrase'] = $form->getFieldHtml(array(
     				'type' => 'input',
     				'name' => 'passphrase',
     				'value' => $this->data['passphrase'],
     			));
     */
     $this->data['sections'][] = $key_gen;
     //data encryption section
     $form2 = new AForm('HT');
     $form2->setForm(array('form_name' => 'dataEncFrm', 'update' => $this->data['update']));
     $data_enc = array();
     $data_enc['section_id'] = 'data_encryption';
     $data_enc['name'] = $this->language->get('data_encryption');
     $data_enc['form_title'] = $data_enc['name'];
     $data_enc['form']['form_open'] = $form2->getFieldHtml(array('type' => 'form', 'name' => 'dataEncFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
     $data_enc['form']['submit'] = $form2->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_encrypt_data')));
     $data_enc['form']['reset'] = $form2->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset')));
     $data_enc['form']['fields']['enc_key'] = $form2->getFieldHtml(array('type' => 'selectbox', 'name' => 'enc_key', 'options' => $pub_keys_options, 'value' => $this->data['enc_key']));
     $data_enc['note'] = $this->language->get('post_encrypting_notice');
     $enc_tables_options = array();
     $enc_config_tables = $enc_data->getEcryptedTables();
     if (has_value($enc_config_tables)) {
         foreach ($enc_config_tables as $table_name) {
             $enc_tables_options[$table_name] = $table_name;
         }
         /*
         //Per table encryption is not suported YET
         $data_enc['form']['fields']['enc_tables'] = $form2->getFieldHtml(array(
         		'type' => 'selectbox',
         		'name' => 'enc_tables',
         		'options' => $enc_tables_options,
         		'value' => $this->data['enc_tables'],
         	));
         */
         $data_enc['form']['fields']['enc_tables'] = implode(', ', $enc_config_tables);
         $data_enc['form']['fields']['enc_test_mode'] = $form2->getFieldHtml(array('type' => 'checkbox', 'name' => 'enc_test_mode', 'value' => $this->data['enc_test_mode'], 'style' => 'btn_switch'));
         $data_enc['form']['fields']['enc_remove_original'] = $form2->getFieldHtml(array('type' => 'checkbox', 'name' => 'enc_remove_original', 'value' => isset($this->data['enc_remove_original']) ? $this->data['enc_remove_original'] : 1));
     } else {
         $data_enc['note'] = "<b>Enable Data Encryption first!<b>";
     }
     $this->data['sections'][] = $data_enc;
     $this->view->batchAssign($this->language->getASet());
     //load tabs controller
     $this->data['groups'][] = 'additional_settings';
     $this->data['link_additional_settings'] = $this->data['add_sett']->href;
     $this->data['active_group'] = 'additional_settings';
     $tabs_obj = $this->dispatch('pages/extension/extension_tabs', array($this->data));
     $this->data['tabs'] = $tabs_obj->dispatchGetOutput();
     unset($tabs_obj);
     $obj = $this->dispatch('pages/extension/extension_summary', array($this->data));
     $this->data['extension_summary'] = $obj->dispatchGetOutput();
     unset($obj);
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/extension/encryption_data_manager.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #7
0
 /**
  * @param string $key
  * @param string|array $value
  * @param array $data
  * @return mixed
  */
 private function _prepareData($key, $value, $data = array())
 {
     switch ($key) {
         case 'extension_txt_id':
             $value = strtolower(preformatTextID($value));
             break;
         case 'copy_default':
             $value = in_array($data['extension_type'], array('template', 'language')) && $value == 1 ? true : false;
             break;
         case 'header_comment':
             $value = trim($value);
             $value = ltrim($value, "<?php\n");
             $value = str_replace("\n\nif (! defined ( 'DIR_CORE' )) {\nheader ( 'Location: static_pages/' );\n}\n\n", '', $value);
             $value = trim($value);
             $value = str_replace(array('<?php', '?>'), '', $value);
             if ($value) {
                 if (substr($value, 0, 2) != '/*') {
                     $value = '/*' . $value;
                 }
                 if (substr($value, -2) != '*/') {
                     $value = $value . '*/';
                 }
             }
             break;
         case 'extension_admin_language_files':
         case 'extension_storefront_language_files':
             foreach ($value as &$val) {
                 $val = strtolower($val);
             }
             unset($val);
             break;
         case 'hook_file':
             $value = trim($value);
             if ($value) {
                 $value = substr($value, -4) != '.php' ? $value . '.php' : $value;
             }
             break;
     }
     return $value;
 }
コード例 #8
0
 /**
  * @param array $data
  */
 function __construct($data)
 {
     if (!isset($data['value'])) {
         $data['value'] = '';
     }
     if (isset($data['required']) && $data['required'] == 1) {
         $data['required'] = 'Y';
     }
     if (isset($data['attr'])) {
         $data['attr'] = ' ' . htmlspecialchars_decode($data['attr']) . ' ';
     }
     $data['registry'] = Registry::getInstance();
     $this->data = $data;
     $this->view = new AView($data['registry'], 0);
     $this->element_id = preformatTextID($data['name']);
     if (isset($data['form'])) {
         $this->element_id = $data['form'] . '_' . $this->element_id;
     }
 }
コード例 #9
0
ファイル: user_ims.php プロジェクト: siddht1/abantecart-src
 public function settings()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $user_id = $this->request->get['user_id'];
     $this->loadModel('user/user');
     $this->loadLanguage('user/user');
     $this->loadLanguage('common/im');
     $user_info = $this->model_user_user->getUser($user_id);
     $this->data['user_id'] = $user_id;
     $sendpoint = $this->request->get['sendpoint'];
     $section = $this->request->get['section'];
     $this->data['text_title'] = '"' . $this->language->get('im_sendpoint_name_' . preformatTextID($sendpoint)) . '"';
     $this->data['text_title'] .= ' ' . sprintf($this->language->get('text_notification_for', 'common/im'), $user_info['username']);
     if ($section) {
         $this->data['text_title'] .= " (" . $this->language->get('text_' . $section) . ")";
     }
     $this->data['action'] = $this->html->getSecureURL('user/user_ims/saveIMSettings', '&user_id=' . $user_id . '&sendpoint=' . $sendpoint . '&section=' . $section);
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'imsetFrm', 'update' => $this->data['action'] . '&qs=1'));
     $this->data['form']['id'] = 'imsetFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'imsetFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"'));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $protocols = $this->im->getProtocols();
     if ($section == 'admin') {
         $all_sendpoints = array_keys($this->im->admin_sendpoints);
     } else {
         if ($section == 'storefront') {
             $all_sendpoints = array_keys($this->im->admin_sendpoints);
         } else {
             $all_sendpoints = array_merge(array_keys($this->im->sendpoints), array_keys($this->im->admin_sendpoints));
         }
     }
     //mark error sendpoints
     if (!in_array($sendpoint, $all_sendpoints)) {
         $this->data['error_warning'] = sprintf($this->language->get('error_unknown_sendpoint'), $sendpoint);
         $this->log->write('IM send point ' . $sendpoint . ' is not in the send points list! ');
     }
     $settings = $this->im->getUserSendPointSettings($this->data['user_id'], '', $sendpoint, $this->session->data['current_store_id']);
     $this->data['form']['fields']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'settings[email]', 'value' => $settings['email']));
     //build prior email list
     $this->data['admin_emails'] = array();
     $ims = $this->im->getUserIMs($user_id, $this->session->data['current_store_id']);
     foreach ($ims as $section) {
         foreach ($section as $rows) {
             foreach ($rows as $row) {
                 if ($row['protocol'] != 'email' || !$row['uri']) {
                     continue;
                 }
                 $this->data['admin_emails'][] = $row['uri'];
             }
         }
     }
     $this->data['admin_emails'][] = $user_info['email'];
     $this->data['admin_emails'][] = $this->config->get('store_main_email');
     $this->data['admin_emails'] = array_unique($this->data['admin_emails']);
     foreach ($protocols as $protocol) {
         $uri = $settings[$protocol];
         $this->data['form']['fields'][$protocol] = $form->getFieldHtml(array('type' => 'input', 'name' => 'settings[' . $protocol . ']', 'value' => $uri));
         $this->data['entry_im_' . $protocol] = $this->language->get('entry_im_' . $protocol);
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('/responses/user/user_im_settings.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #10
0
 /**
  * method inserts new item to the end of menu level
  *
  * @param array $item("item_id"=>"","parent_id"=>"","item_text"=>,"rt"=>"","sort_order"=>"", "item_type" => "")
  * @return boolean
  */
 public function insertMenuItem($item = array())
 {
     $check_array = array("item_id", "item_text", "item_url", "parent_id", "sort_order", "item_type", "item_icon_rl_id");
     //clean text id
     $item["item_id"] = preformatTextID($item["item_id"]);
     if (!$item['item_type']) {
         $item['item_type'] = 'extension';
     }
     if (!$item["item_id"] || !$item["item_text"] || sizeof(array_intersect($check_array, array_keys($item))) < 6) {
         return 'Error: Cannot to add menu item because item array is wrong.';
     }
     if ($item['parent_id'] && !isset($this->menu_items[$item['parent_id']])) {
         return 'Error: Cannot to add menu item because parent "' . $item['parent_id'] . '" is not exists';
     }
     // then insert
     //when autosorting
     if (!$item["sort_order"]) {
         // we need to know last order number of children and set new for new item... yet
         $brothers = $this->getMenuChildren($item["parent_id"]);
         $new_sort_order = 0;
         if ($brothers) {
             foreach ($brothers as $brother) {
                 $new_sort_order = $brother['sort_order'] > $new_sort_order ? $brother['sort_order'] : $new_sort_order;
             }
         }
         $new_sort_order++;
         $item["sort_order"] = $new_sort_order;
     }
     // checks for unique item_id
     if (in_array($item["item_id"], $this->item_ids)) {
         return 'Error: Cannot to add menu item because item with item_id "' . $item["item_id"] . '" is already exists.';
     }
     $result = $this->dataset->addRows(array($item));
     // rebuild menu var after changing
     $this->_build_menu($this->dataset->getRows());
     $this->registry->get('cache')->delete('admin_menu');
     return $result;
 }
コード例 #11
0
ファイル: menu.php プロジェクト: harshzalavadiya/fatak
 public function insert()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->menu = new AMenu_Storefront();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) {
         $languages = $this->language->getAvailableLanguages();
         foreach ($languages as $l) {
             if ($l['language_id'] == $this->session->data['content_language_id']) {
                 continue;
             }
             $this->request->post['item_text'][$l['language_id']] = $this->request->post['item_text'][$this->session->data['content_language_id']];
         }
         //TODO!. Remove post/get update and access in many places. Copy to local array to proccess and work with.
         $this->request->post['item_icon'] = html_entity_decode($this->request->post['item_icon'], ENT_COMPAT, 'UTF-8');
         $textid = preformatTextID($this->request->post['item_id']);
         $result = $this->menu->insertMenuItem(array('item_id' => $textid, 'item_icon' => $this->request->post['item_icon'], 'item_icon_rl_id' => $this->request->post['item_icon_rl_id'], 'item_text' => $this->request->post['item_text'], 'parent_id' => $this->request->post['parent_id'], 'item_url' => $this->request->post['item_url'], 'sort_order' => $this->request->post['sort_order'], 'item_type' => 'core'));
         if ($result !== true) {
             $this->error['warning'] = $result;
         } else {
             $this->session->data['success'] = $this->language->get('text_success');
             $this->redirect($this->html->getSecureURL('design/menu/update', '&item_id=' . $textid));
         }
     }
     $this->_getForm();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #12
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->customer->isLogged()) {
         $this->session->data['redirect'] = $this->html->getSecureURL('account/notification');
         $this->redirect($this->html->getSecureURL('account/login'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('account/customer');
     if ($this->request->is_POST()) {
         $this->model_account_customer->saveCustomerNotificationSettings($this->request->post['settings']);
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getURL('account/account'));
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/notification'), 'text' => $this->language->get('text_notifications'), 'separator' => $this->language->get('text_separator')));
     $form = new AForm();
     $form->setForm(array('form_name' => 'imFrm'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'imFrm', 'action' => $this->html->getSecureURL('account/notification')));
     $protocols = $this->im->getActiveProtocols('storefront');
     $im_drivers = $this->im->getIMDriverObjects();
     //build protocol list
     foreach ($im_drivers as $name => $driver) {
         $this->data['protocols'][$name] = array('name' => $name);
         if (is_object($driver)) {
             $this->data['protocols'][$name]['title'] = $driver->getProtocolTitle();
         }
     }
     $sendpoints = $this->im->sendpoints;
     $all_im_settings = $this->model_account_customer->getCustomerNotificationSettings();
     $customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
     foreach ($sendpoints as $sendpoint => $sendpoint_data) {
         //skip sendpoint for admins and use only storefront => 0
         if (!$sendpoint_data[0]) {
             continue;
         }
         $imsettings = $all_im_settings[$sendpoint];
         $force_arr = $sendpoint_data[0]['force_send'];
         $point = array();
         $point['title'] = $this->language->get('im_sendpoint_name_' . preformatTextID($sendpoint));
         $point['note'] = $this->language->get('im_sendpoint_name_' . preformatTextID($sendpoint) . '_note');
         $point['warn'] = '';
         foreach ($protocols as $protocol) {
             $read_only = '';
             $checked = false;
             if ($imsettings[$protocol]) {
                 $checked = true;
             }
             if (!$customer_info[$protocol]) {
                 $read_only = ' disabled readonly ';
             } else {
                 if (has_value($force_arr) && in_array($protocol, $force_arr)) {
                     $read_only = ' disabled readonly ';
                     $checked = true;
                 }
             }
             $point['values'][$protocol] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'settings[' . $sendpoint . '][' . $protocol . ']', 'value' => '1', 'checked' => $checked, 'attr' => $read_only));
             //adds warning about empty IM address (URI)
             if (!$customer_info[$protocol]) {
                 $point['warn'] .= $this->language->get('im_protocol_' . $protocol . '_empty_warn');
             }
         }
         $this->data['form']['fields']['sendpoints'][$sendpoint] = $point;
     }
     $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'icon' => 'fa fa-check', 'name' => $this->language->get('button_continue')));
     $this->data['back'] = $this->html->getURL('account/account');
     $back = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'icon' => 'fa fa-arrow-left', 'style' => 'button'));
     $this->data['form']['back'] = $back;
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/account/notification.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #13
0
ファイル: menu.php プロジェクト: Cali-gula/abantecart-src
 public function insert()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->menu = new AMenu_Storefront();
     $language_id = $this->language->getContentLanguageID();
     if ($this->request->is_POST() && $this->_validateForm()) {
         $post = $this->request->post;
         $languages = $this->language->getAvailableLanguages();
         foreach ($languages as $l) {
             if ($l['language_id'] == $language_id) {
                 continue;
             }
             $post['item_text'][$l['language_id']] = $post['item_text'][$language_id];
         }
         $post['item_icon'] = html_entity_decode($post['item_icon'], ENT_COMPAT, 'UTF-8');
         $textid = preformatTextID($post['item_id']);
         $result = $this->menu->insertMenuItem(array('item_id' => $textid, 'item_icon' => $post['item_icon'], 'item_icon_rl_id' => $post['item_icon_resource_id'], 'item_text' => $post['item_text'], 'parent_id' => $post['parent_id'], 'item_url' => $post['item_url'], 'sort_order' => $post['sort_order'], 'item_type' => 'core'));
         if ($result !== true) {
             $this->error['warning'] = $result;
         } else {
             $this->session->data['success'] = $this->language->get('text_success');
             $this->redirect($this->html->getSecureURL('design/menu/update', '&item_id=' . $textid));
         }
     }
     $this->_getForm();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #14
0
ファイル: user.php プロジェクト: siddht1/abantecart-src
 public function im()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (isset($this->request->get['user_id'])) {
         $user_id = $this->request->get['user_id'];
     } else {
         $user_id = 0;
     }
     if (!$user_id) {
         $this->redirect($this->html->getSecureURL('user/user'));
     }
     $this->loadLanguage('common/im');
     $this->loadLanguage('user/user');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('user/user');
     $user_info = $this->model_user_user->getUser($user_id);
     $this->view->assign('form_store_switch', $this->html->getStoreSwitcher());
     $this->data['edit_profile_url'] = $this->html->getSecureURL('user/user/update', '&user_id=' . $user_id);
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('user/user'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('user/user/update', '&user='******'text' => sprintf($this->language->get('text_notification_for', 'common/im'), $user_info['username']), 'separator' => ' :: ', 'current' => true));
     $this->data['cancel'] = $this->html->getSecureURL('user/user');
     $this->loadLanguage('common/im');
     $protocols = $this->im->getProtocols();
     $sendpoints = array_merge(array_keys($this->im->sendpoints), array_keys($this->im->admin_sendpoints));
     foreach ($sendpoints as $sendpoint) {
         $ims = $this->im->getUserIMs($user_id, $this->session->data['current_store_id']);
         $imsettings = array_merge((array) $ims['storefront'][$sendpoint], (array) $ims['admin'][$sendpoint]);
         $values = array();
         foreach ($imsettings as $row) {
             if ($row['uri'] && in_array($row['protocol'], $protocols)) {
                 $values[$row['protocol']] = $row['protocol'];
             }
         }
         //send notification id present for admin => 1
         if (!empty($this->im->sendpoints[$sendpoint][1]) || !empty($this->im->admin_sendpoints[$sendpoint][1])) {
             $this->data['sendpoints'][$sendpoint] = array('id' => $sendpoint, 'text' => $this->language->get('im_sendpoint_name_' . preformatTextID($sendpoint)), 'values' => $values);
         }
     }
     $this->data['im_settings_url'] = $this->html->getSecureURL('user/user_ims/settings', '&user_id=' . $user_id);
     $this->data['text_change_im_addresses'] = $this->language->get('text_change_im_addresses');
     $this->view->assign('help_url', $this->gen_help_url('user_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('/pages/user/user_im.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }