Changeset 27781 for extensions/MyPiwiShop
- Timestamp:
- Mar 16, 2014, 7:16:27 PM (10 years ago)
- Location:
- extensions/MyPiwiShop
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/MyPiwiShop/admin/MyPiwiShopBatch.php
r27743 r27781 4 4 global $template; 5 5 6 $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;'; 6 //set batch manager 7 $query=' 8 SELECT `id`, `product`, `noteAdmin`, `price` 9 FROM '.MPS_PRODUCT_TABLE.' 10 ORDER BY `order` 11 ;'; 7 12 $result = pwg_query($query); 8 $product = array();9 13 10 while($row = pwg_db_fetch_assoc($result)) {11 $product[]= $row;14 while($row = pwg_db_fetch_assoc($result)) { 15 $product[]= $row; 12 16 } 13 17 14 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 18 $query=' 19 SELECT * 20 FROM '.MPS_CONF_TABLE.' 21 ;'; 15 22 $result = pwg_query($query); 16 while($row = pwg_db_fetch_assoc($result)){ 23 24 while($row = pwg_db_fetch_assoc($result)) { 17 25 $config = $row ; 18 26 } 19 27 20 $template->assign(array( 21 'mps_product' => $product, 22 'mps_conf' => $config 28 //tempate assign 29 $template->assign(array( 30 'mps_product' => $product, 31 'mps_conf' => $config 23 32 )); 24 33 -
extensions/MyPiwiShop/admin/MyPiwiShopBatchUnit.php
r27743 r27781 1 1 <?php 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 /* * 4 *** submit change 5 **/ 3 4 //change product check 5 if(isset($_POST['imgid'])) { 6 $imgid = $_POST['imgid']; 7 $imgen = array($imgid); 8 9 if (!isset($_POST['productcheck'])) { 10 delet_Allproduct_Thisimage($imgid); 11 } else { 12 $product_id = $_POST['productcheck']; 13 add_product_Thisimage($product_id, $imgen); 14 } 15 } 6 16 7 if(isset($_POST['imgid'])) 8 { 9 $imgid = $_POST['imgid']; 10 $imgen = array($imgid); 11 if (!isset($_POST['productcheck'])) { 12 deletThis_image_Allproduct($imgid); 13 } 14 else{ 15 16 $product_id = $_POST['productcheck']; 17 add_product_Thisimage($product_id, $imgen); 18 } 19 } 20 21 22 global $template, $element_ids; 17 //set batch manager unit 18 global $template, $element_ids; 23 19 24 $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;'; 20 $query=' 21 SELECT `id`, `product`, `noteAdmin`, `price` 22 FROM '.MPS_PRODUCT_TABLE.' 23 ORDER BY `order` 24 ;'; 25 25 $result = pwg_query($query); 26 $products = array();27 26 28 27 while($row = pwg_db_fetch_assoc($result)){ 29 $products[]= $row;28 $products[]= $row; 30 29 } 31 30 32 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 33 $result = pwg_query($query); 31 $query=' 32 SELECT * 33 FROM '.MPS_CONF_TABLE.';'; 34 $result = pwg_query($query); 35 34 36 while($row = pwg_db_fetch_assoc($result)){ 35 37 $config = $row ; 36 38 } 37 39 38 $query='40 $query=' 39 41 SELECT i.id, pi.image_id, pi.product_id 40 42 FROM '.IMAGES_TABLE.' AS i … … 43 45 ;'; 44 46 $result = pwg_query($query); 45 $productcheck = array();46 47 47 48 while($row = pwg_db_fetch_assoc($result)){ 48 49 $productcheck[] = $row; 49 50 } 50 51 51 52 53 'mps_products'=> $products,54 'mps_conf'=> $config,55 56 52 //template assign 53 $template->assign(array( 54 'mps_products' => $products, 55 'mps_conf' => $config, 56 'mps_productcheck' => $productcheck, 57 )); 57 58 58 59 -
extensions/MyPiwiShop/admin/config.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 $select_options_currency = array( 5 'AUD'=>'Australian Dollar(AUD)', 6 'BRL'=>'Brazilian Real(BRL)', 7 'CAD'=>'Canadian Dollar(CAD)', 8 'CZK'=>'Czech Koruna(CZK)', 9 'DKK'=>'Danish Krone(DKK)', 10 'EUR'=>'Euro(EUR)', 11 'HKD'=>'Hong Kong Dollar(HKD)', 12 'HUF'=>'Hungarian Forint(HUF)', 13 'ILS'=>'Israeli New Sheqel(ILS)', 14 'JPY'=>'Japanese Yen(JPY)', 15 'MYR'=>'Malaysian Ringgit(MYR)', 16 'MXN'=>'Mexican Peso(MXN)', 17 'NOK'=>'Norwegian Krone(NOK)', 18 'NZD'=>'New Zealand Dollar(NZD)', 19 'PHP'=>'Philippine Peso(PHP)', 20 'PLN'=>'Polish Zloty(PLN)', 21 'GBP'=>'Pound Sterling(GBP)', 22 'SGD'=>'Singapore Dollar(SGD)', 23 'SEK'=>'Swedish Krona(SEK)', 24 'CHF'=>'Swiss Franc(CHF)', 25 'TWD'=>'Taiwan New Dollar(TWD)', 26 'THB'=>'Thai Baht(THB)', 27 'USD'=>'U.S. Dollar(USD)' 28 ); 4 29 5 $select_options_currency=array( 6 'AUD'=>'Australian Dollar(AUD)', 7 'BRL'=>'Brazilian Real(BRL)', 8 'CAD'=>'Canadian Dollar(CAD)', 9 'CZK'=>'Czech Koruna(CZK)', 10 'DKK'=>'Danish Krone(DKK)', 11 'EUR'=>'Euro(EUR)', 12 'HKD'=>'Hong Kong Dollar(HKD)', 13 'HUF'=>'Hungarian Forint(HUF)', 14 'ILS'=>'Israeli New Sheqel(ILS)', 15 'JPY'=>'Japanese Yen(JPY)', 16 'MYR'=>'Malaysian Ringgit(MYR)', 17 'MXN'=>'Mexican Peso(MXN)', 18 'NOK'=>'Norwegian Krone(NOK)', 19 'NZD'=>'New Zealand Dollar(NZD)', 20 'PHP'=>'Philippine Peso(PHP)', 21 'PLN'=>'Polish Zloty(PLN)', 22 'GBP'=>'Pound Sterling(GBP)', 23 'SGD'=>'Singapore Dollar(SGD)', 24 'SEK'=>'Swedish Krona(SEK)', 25 'CHF'=>'Swiss Franc(CHF)', 26 'TWD'=>'Taiwan New Dollar(TWD)', 27 'THB'=>'Thai Baht(THB)', 28 'USD'=>'U.S. Dollar(USD)' 29 ); 30 31 if (isset($_POST['save_config'])) 32 { 33 $PPid = $_POST['PPid']; 34 $currency = $_POST['currency']; 35 $ship = $_POST['ship']; 36 $comm = $_POST['comm']; 37 $tprmulti = $_POST['tprmulti']; 38 $tpruniq = $_POST['tpruniq']; 30 // update config 31 if (isset($_POST['save_config'])) { 32 33 $PPid = $_POST['PPid']; 34 $currency = $_POST['currency']; 35 $ship = $_POST['ship']; 36 $comm = $_POST['comm']; 37 $tprmulti = $_POST['tprmulti']; 38 $tpruniq = $_POST['tpruniq']; 39 39 40 $query='UPDATE '.MPS_CONF_TABLE.' 41 SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\' 42 WHERE id=1;'; 43 $result=pwg_query($query); 44 if($result==1) 40 pwg_query(' 41 UPDATE '.MPS_CONF_TABLE.' 42 SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\' 43 WHERE id = 1 44 ;'); 45 45 46 $page['infos']=l10n('Your configuration settings are saved'); 46 else 47 $page['errors']=l10n('Error'); 47 } 48 48 49 } 49 //set config 50 $query=' 51 SELECT * 52 FROM '.MPS_CONF_TABLE.' 53 ;'; 54 $result = pwg_query($query); 55 56 while($row = pwg_db_fetch_assoc($result)) { 57 $config = $row ; 58 } 50 59 51 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 52 $result = pwg_query($query); 53 while($row = pwg_db_fetch_assoc($result)){ 54 $config = $row ; 55 } 56 57 58 59 $template->assign(array( 60 'mps_currency' => $select_options_currency, 61 'mps_conf' => $config 60 //template assign 61 $template->assign(array( 62 'mps_currency' => $select_options_currency, 63 'mps_conf' => $config 62 64 )); 63 65 64 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl'));66 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl')); -
extensions/MyPiwiShop/admin/home.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 // set home 5 $query=' 6 SELECT * 7 FROM '.MPS_CONF_TABLE.' 8 ;'; 9 $result = pwg_query($query); 10 11 while($row = pwg_db_fetch_assoc($result)) { 12 $config = $row ; 13 } 4 14 5 6 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 7 $result = pwg_query($query); 8 while($row = pwg_db_fetch_assoc($result)){ 9 $config = $row ; 10 } 11 12 13 $template->assign(array( 14 'mps_conf' => $config, 15 'INTRO_CONTENT' => load_language('intro.html', MPS_PATH, array('return'=>true)), 15 //template assign 16 $template->assign(array( 17 'mps_conf' => $config, 18 'INTRO_CONTENT' => load_language('intro.html', MPS_PATH, array('return'=>true)), 16 19 )); 17 20 18 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl'));21 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl')); -
extensions/MyPiwiShop/admin/options.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 4 // define type option 5 5 $select_type_opt=array( 6 6 'select' =>'select', … … 10 10 'checkbox' =>'checkbox', 11 11 ); 12 13 // delete option 14 if(isset($_POST['check'])) { 12 15 13 if(isset($_POST['check'])){14 16 foreach($_POST['check'] AS $delete_id){ 15 17 16 $query='DELETE FROM '.MPS_OPTION_TABLE.' 17 WHERE id = '.$delete_id.';'; 18 pwg_query($query); 18 pwg_query(' 19 DELETE FROM '.MPS_OPTION_TABLE.' 20 WHERE `id` = '.$delete_id.'; 21 '); 19 22 20 $query='DELETE FROM '.MPS_PROD_OPT_TABLE.' 21 WHERE opt_id = '.$delete_id.';'; 22 pwg_query($query); 23 pwg_query(' 24 DELETE FROM '.MPS_PROD_OPT_TABLE.' 25 WHERE `opt_id` = '.$delete_id.'; 26 '); 23 27 24 $query='DELETE FROM '.MPS_OPT_VAL_TABLE.' 25 WHERE select_id = '.$delete_id.';'; 26 pwg_query($query); 28 pwg_query(' 29 DELETE FROM '.MPS_OPT_VAL_TABLE.' 30 WHERE `select_id` = '.$delete_id.'; 31 '); 32 27 33 $page['infos']=l10n('deleted'); 28 34 } 29 } 35 36 } 30 37 31 if (isset($_POST['option_add'])) 32 { 33 if(empty($_POST['id'])) 34 { 38 // add/edit option 39 if (isset($_POST['option_add'])) { 40 41 //add option 42 if(empty($_POST['id'])) { 43 $order = array(); 44 45 $query ='SELECT * 46 FROM '.MPS_OPTION_TABLE.';'; 47 $result = pwg_query($query); 48 49 while($row = pwg_db_fetch_assoc($result)) { 50 $order[] = $row['order']; 51 } 52 53 if (count($order) == 0) { 54 $order = 1; 55 } else { 56 $order = max($order)+1; 57 } 35 58 36 $order = array(); 37 $query ='SELECT * FROM '.MPS_OPTION_TABLE.';'; 38 $result = pwg_query($query); 39 while($row = pwg_db_fetch_assoc($result)){ 40 $order[] = $row['order']; 41 } 42 if (count($order) == 0) { 43 $order = 1; 44 }else{ 45 $order = max($order)+1; 59 $name = $_POST['name']; 60 $type = $_POST['type']; 61 $title = $_POST['title']; 62 63 if(isset($_POST['requi'])) { 64 $requi = $_POST['requi']; 65 } else { 66 $requi = 0; 67 } 68 69 pwg_query(' 70 INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 71 VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\') 72 ;'); 73 74 $select_id = pwg_db_insert_id(); 75 76 if(isset($_POST['val'])) { 77 $val = $_POST['val']; 78 79 foreach($val as $val_ele) { 80 pwg_query(' 81 INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 82 VALUE (\''.$val_ele.'\',\''.$select_id.'\') 83 ;'); 84 } 85 86 } 87 $page['infos']=l10n('Option registered'); 46 88 } 47 89 48 $name = $_POST['name']; 49 $type = $_POST['type']; 50 $title = $_POST['title']; 90 //edit option 91 if(!empty($_POST['id'])) { 92 93 $name = $_POST['name']; 94 $type = $_POST['type']; 95 $title = $_POST['title']; 96 $id = $_POST['id']; 51 97 52 if(isset($_POST['requi'])){ 53 $requi = $_POST['requi']; 54 }else{ 55 $requi = 0; 98 if(isset($_POST['requi'])) { 99 $requi = $_POST['requi']; 100 } else { 101 $requi = 0; 102 } 103 104 pwg_query(' 105 UPDATE '.MPS_OPTION_TABLE.' 106 SET `name` = \''.$name.'\', `type` = \''.$type.'\', `titre` = \''.$title.'\', `requi` = \''.$requi.'\' 107 WHERE `id` = '.$id.' 108 ;'); 109 110 pwg_query(' 111 DELETE FROM '.MPS_OPT_VAL_TABLE.' 112 WHERE `select_id` = '.$id.' 113 ;'); 114 115 if(isset($_POST['val'])){ 116 $val = $_POST['val']; 117 118 foreach($val as $val_ele) 119 { 120 pwg_query(' 121 INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 122 VALUE (\''.$val_ele.'\',\''.$id.'\') 123 ;'); 124 } 125 56 126 } 127 128 $page['infos']=l10n('Option registered'); 129 } 130 } 131 132 // change option order 133 if(isset($_POST['newOrder'])) { 134 135 $newOrder = explode(",", $_POST['newOrder']); 136 $ex = array_pop($newOrder); 137 138 foreach( $newOrder as $order => $id ) { 57 139 140 $order = $order +1; 141 pwg_query(' 142 UPDATE '.MPS_OPTION_TABLE.' 143 SET `order` = \''.$order.'\' 144 WHERE `id` = '.$id.' 145 ;'); 146 } 147 148 $page['infos']=l10n('the order is changed'); 149 } 150 151 // set option 152 $query=' 153 SELECT o.id, o.titre, o.name, o.type, o.requi, o.order, ov.val 154 FROM '.MPS_OPTION_TABLE.' AS o 155 LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id 156 ORDER BY o.order 157 ;'; 158 159 $result = pwg_query($query); 160 while($row = pwg_db_fetch_assoc($result)) { 161 162 if (!isset($option[ $row['id']])) { 163 $option[$row['id']] = array( 164 'id' => $row['id'], 165 'title' => $row['titre'], 166 'name' => $row['name'], 167 'type' => $row['type'], 168 'requi' => $row['requi'], 169 ); 170 } 171 $option[$row['id']]['val'][]=$row['val']; 58 172 59 $query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 60 values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');'; 61 62 pwg_query($query); 63 $select_id = pwg_db_insert_id(); 64 65 if(isset($_POST['val'])){ 66 $val = $_POST['val']; 67 68 69 foreach($val as $val_ele) 70 { 71 $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 72 values (\''.$val_ele.'\',\''.$select_id.'\');'; 73 $result = pwg_query($query); 74 } 75 if($result==1) 76 $page['infos']=l10n('Option registered'); 77 else 78 $page['errors']=l10n('Error'); 79 } 80 } 81 82 if(!empty($_POST['id'])) 83 { 84 85 $name = $_POST['name']; 86 $type = $_POST['type']; 87 $title = $_POST['title']; 88 $id = $_POST['id']; 89 90 if(isset($_POST['requi'])){ 91 $requi = $_POST['requi']; 92 }else{ 93 $requi = 0; 94 } 95 96 $query='UPDATE '.MPS_OPTION_TABLE.' 97 SET name = \''.$name.'\', type = \''.$type.'\', titre = \''.$title.'\', requi = \''.$requi.'\' 98 WHERE id = '.$id.' 99 ;'; 100 pwg_query($query); 101 102 $query='DELETE FROM '.MPS_OPT_VAL_TABLE.' 103 WHERE select_id = '.$id.' 104 ;'; 105 pwg_query($query); 106 107 if(isset($_POST['val'])){ 108 $val = $_POST['val']; 109 110 foreach($val as $val_ele) 111 { 112 113 $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 114 values (\''.$val_ele.'\',\''.$id.'\');'; 115 $result = pwg_query($query); 116 } 117 } 118 $page['infos']=l10n('Option registered'); 119 120 } 121 122 } 123 124 if(isset($_POST['newOrder'])) 125 { 126 $newOrder = explode(",", $_POST['newOrder']); 127 $ex = array_pop($newOrder); 128 129 foreach( $newOrder as $order => $id ) 130 { 131 $order = $order +1; 132 133 $query='UPDATE '.MPS_OPTION_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';'; 134 $result = pwg_query($query); 135 136 $page['infos']=l10n('the order is changed'); 137 138 } 139 } 140 141 $query=' 142 SELECT * FROM '.MPS_OPTION_TABLE.' ORDER BY `order` ;'; 143 144 $option = array(); 145 $result = pwg_query($query); 146 while($row = pwg_db_fetch_assoc($result)){ 147 $query=' 148 SELECT * 149 FROM '.MPS_OPT_VAL_TABLE.' 150 WHERE select_id = '.$row['id'].' 151 ;'; 152 $val = array(); 153 $res = pwg_query($query); 154 while($row1 = pwg_db_fetch_assoc($res)){ 155 $val[]= $row1['val']; 156 } 157 $opt = array("id" =>$row['id'], 158 "title" =>$row['titre'], 159 "name" =>$row['name'], 160 "type" =>$row['type'], 161 "requi" =>$row['requi'], 162 "val" =>$val 163 ); 164 $option[$row['id']] = $opt; 165 166 } 167 168 169 $template->assign(array( 173 } 174 175 //template assign 176 $template->assign(array( 170 177 'mps_option' => $option, 171 178 'mps_type_opt' => $select_type_opt 172 179 )); 173 180 174 175 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl')); 181 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl')); 182 -
extensions/MyPiwiShop/admin/product.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 5 if(isset($_POST['check'])){ 6 foreach($_POST['check'] AS $delete_id){ 7 8 $query='DELETE FROM '.MPS_PRODUCT_TABLE.' 9 WHERE id = '.$delete_id.';'; 10 pwg_query($query); 4 // delete option 5 if(isset($_POST['check'])) { 6 7 foreach($_POST['check'] AS $delete_id) { 8 9 pwg_query(' 10 DELETE FROM '.MPS_PRODUCT_TABLE.' 11 WHERE id = '.$delete_id.' 12 ;'); 13 14 pwg_query(' 15 DELETE FROM '.MPS_PROD_OPT_TABLE.' 16 WHERE product_id = '.$delete_id.' 17 ;'); 18 } 19 11 20 $page['infos']=l10n('deleted'); 12 13 $query='DELETE FROM '.MPS_PROD_OPT_TABLE.' 14 WHERE product_id = '.$delete_id.';'; 15 pwg_query($query); 16 17 21 } 22 23 //Add/Edit product 24 if(isset($_POST['product_add'])) { 25 26 //Add product 27 if (empty($_POST['id'])) { 28 29 $order = array(); 30 $query =' 31 SELECT `order` 32 FROM '.MPS_PRODUCT_TABLE.' 33 ;'; 34 35 $result = pwg_query($query); 36 while($row = pwg_db_fetch_assoc($result)) { 37 $order[] = $row['order']; 38 } 39 if (count($order) == 0) { 40 $order = 1; 41 } else { 42 $order = max($order)+1; 43 } 44 45 $product = $_POST['product']; 46 $noteAdmin = $_POST['noteAdmin']; 47 $price = $_POST['price']; 48 49 50 pwg_query(' 51 INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`) 52 VALUE (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\'); 53 '); 54 $prod = pwg_db_insert_id(); 55 56 if(isset($_POST['opt'])) { 57 $opt = $_POST['opt']; 58 $inserts = array(); 59 60 foreach ($opt as $opt_id) { 61 $inserts[] = array( 62 'opt_id' => $opt_id, 63 'product_id' => $prod, 64 ); 65 } 66 67 mass_inserts( 68 MPS_PROD_OPT_TABLE, 69 array_keys($inserts[0]), 70 $inserts 71 ); 72 } 73 74 $page['infos']=l10n('Product registered'); 75 } 76 77 //Edit product 78 if(!empty($_POST['id'])) { 79 80 $id = $_POST['id']; 81 $product = $_POST['product']; 82 $noteAdmin = $_POST['noteAdmin']; 83 $price = $_POST['price']; 84 85 pwg_query(' 86 UPDATE '.MPS_PRODUCT_TABLE.' 87 SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\' 88 WHERE id = '.$id.' 89 ;'); 90 91 pwg_query(' 92 DELETE FROM '.MPS_PROD_OPT_TABLE.' 93 WHERE `product_id` IN ('.$id.') 94 ;'); 95 96 if(isset($_POST['opt'])) { 97 $opt = $_POST['opt']; 98 $inserts = array(); 99 100 foreach ($opt as $opt_id) { 101 $inserts[] = array( 102 'opt_id' => $opt_id, 103 'product_id' => $id, 104 ); 105 } 106 107 mass_inserts( 108 MPS_PROD_OPT_TABLE, 109 array_keys($inserts[0]), 110 $inserts 111 ); 112 } 113 114 $page['infos']=l10n('Edit'); 115 } 116 117 } 118 119 // Change order 120 if(isset($_POST['newOrder'])) { 121 $newOrder = explode(",", $_POST['newOrder']); 122 $ex = array_pop($newOrder); 123 124 foreach( $newOrder as $order => $id ) { 125 $order = $order +1; 126 127 pwg_query(' 128 UPDATE '.MPS_PRODUCT_TABLE.' 129 SET `order` = \''.$order.'\' 130 WHERE id = '.$id.' 131 ;'); 132 } 133 134 $page['infos']=l10n('the order is changed'); 135 } 136 137 if (isset($_POST['option_add'])) { 138 $order = array(); 139 140 $query ='SELECT * 141 FROM '.MPS_OPTION_TABLE.';'; 142 $result = pwg_query($query); 143 144 while($row = pwg_db_fetch_assoc($result)) { 145 $order[] = $row['order']; 146 } 147 148 if (count($order) == 0) { 149 $order = 1; 150 } else { 151 $order = max($order)+1; 152 } 153 154 $name = $_POST['name']; 155 $type = $_POST['type']; 156 $title = $_POST['title']; 157 158 if(isset($_POST['requi'])) { 159 $requi = $_POST['requi']; 160 } else { 161 $requi = 0; 162 } 163 164 pwg_query(' 165 INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 166 VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\') 167 ;'); 168 169 $select_id = pwg_db_insert_id(); 170 171 if(isset($_POST['val'])) { 172 $val = $_POST['val']; 173 174 foreach($val as $val_ele) { 175 pwg_query(' 176 INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 177 VALUE (\''.$val_ele.'\',\''.$select_id.'\') 178 ;'); 179 } 180 181 } 182 183 echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>'); 184 } 185 186 // set product 187 $query=' 188 SELECT p.id, p.order, p.product, p.noteAdmin, p.price, o.name 189 FROM '.MPS_PRODUCT_TABLE.' AS p 190 LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS op ON op.product_id = p.id 191 LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = op.opt_id 192 ORDER BY p.order 193 ;'; 194 $result = pwg_query($query); 195 196 while($row = pwg_db_fetch_assoc($result)) { 197 198 if (!isset($products[ $row['id']])) { 199 $products[$row['id']] = array( 200 'id' => $row['id'], 201 'product' => $row['product'], 202 'noteAdmin' => $row['noteAdmin'], 203 'price' => $row['price'], 204 ); 18 205 } 19 } 20 21 if(isset($_POST['product_add'])) 22 { 23 if(!empty($_POST['id'])) 24 { 25 $id = $_POST['id']; 26 $product = $_POST['product']; 27 $noteAdmin = $_POST['noteAdmin']; 28 $price = $_POST['price']; 29 30 $query='UPDATE '.MPS_PRODUCT_TABLE.' 31 SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\' 32 WHERE id = '.$id.';'; 33 pwg_query($query); 34 35 $query = 'DELETE FROM '.MPS_PROD_OPT_TABLE.' WHERE product_id IN ('.$id.');'; 36 pwg_query($query); 37 38 if(isset($_POST['opt'])) 39 { 40 $opt = $_POST['opt']; 41 $inserts = array(); 42 foreach ($opt as $opt_id) 43 { 44 $inserts[] = array( 45 'opt_id' => $opt_id, 46 'product_id' => $id, 47 ); 48 } 49 mass_inserts( 50 MPS_PROD_OPT_TABLE, 51 array_keys($inserts[0]), 52 $inserts 53 ); 54 } 55 56 $page['infos']=l10n('Edit'); 57 } 58 59 60 if (empty($_POST['id'])and isset($_POST['product'])and isset($_POST['price'])and is_numeric($_POST['price'])) 61 { 62 $order = array(); 63 $query ='SELECT * FROM '.MPS_PRODUCT_TABLE.';'; 64 $result = pwg_query($query); 65 while($row = pwg_db_fetch_assoc($result)){ 66 $order[] = $row['order']; 67 } 68 if (count($order) == 0) { 69 $order = 1; 70 }else{ 71 $order = max($order)+1; 72 } 73 74 $product = $_POST['product']; 75 $noteAdmin = $_POST['noteAdmin']; 76 $price = $_POST['price']; 77 78 79 $query='INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`) 80 values (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\');'; 81 $result=pwg_query($query); 82 $prod = pwg_db_insert_id(); 83 84 if(isset($_POST['opt'])) 85 { 86 $opt = $_POST['opt']; 87 $inserts = array(); 88 foreach ($opt as $opt_id) 89 { 90 $inserts[] = array( 91 'opt_id' => $opt_id, 92 'product_id' => $prod, 93 ); 94 } 95 mass_inserts( 96 MPS_PROD_OPT_TABLE, 97 array_keys($inserts[0]), 98 $inserts 99 ); 100 } 101 $page['infos']=l10n('Product registered'); 102 } 103 } 104 105 if(isset($_POST['newOrder'])) 106 { 107 $newOrder = explode(",", $_POST['newOrder']); 108 $ex = array_pop($newOrder); 109 110 foreach( $newOrder as $order => $id ) 111 { 112 $order = $order +1; 113 114 $query='UPDATE '.MPS_PRODUCT_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';'; 115 $result = pwg_query($query); 116 117 $page['infos']=l10n('the order is changed'); 118 119 } 120 } 121 122 $select_type_opt=array( 123 'select' =>'select', 124 'radio' =>'radio', 125 'text' =>'text', 126 'textarea' =>'textarea', 127 'checkbox' =>'checkbox', 128 ); 129 130 if (isset($_POST['option_add'])) 131 { 132 $order = array(); 133 $query ='SELECT * FROM '.MPS_OPTION_TABLE.';'; 134 $result = pwg_query($query); 135 while($row = pwg_db_fetch_assoc($result)){ 136 $order[] = $row['order']; 137 } 138 139 if (count($order) == 0) { 140 $order = 1; 141 }else{ 142 $order = max($order)+1; 143 } 144 145 $name = $_POST['name']; 146 $type = $_POST['type']; 147 $title = $_POST['title']; 148 149 if(isset($_POST['requi'])){ 150 $requi = $_POST['requi']; 151 }else{ 152 $requi = 0; 153 } 154 155 156 $query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 157 values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');'; 158 159 pwg_query($query); 160 $select_id = pwg_db_insert_id(); 161 162 if(isset($_POST['val'])){ 163 $val = $_POST['val']; 164 foreach($val as $val_ele) 165 { 166 $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 167 values (\''.$val_ele.'\',\''.$select_id.'\');'; 168 pwg_query($query); 169 } 170 } 171 172 echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>'); 173 174 } 175 176 $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;'; 177 $result = pwg_query($query); 178 $products = array(); 179 while($row = pwg_db_fetch_assoc($result)){ 180 $query=' 181 SELECT * 182 FROM '.MPS_PROD_OPT_TABLE.' AS op 183 JOIN '.MPS_OPTION_TABLE.' AS p ON p.id = op.opt_id 184 WHERE product_id = '.$row['id'].' 185 ;'; 186 $res = pwg_query($query); 187 $opt = array(); 188 while($row1 = pwg_db_fetch_assoc($res)){ 189 $opt[] = $row1['name']; 190 } 191 $row['option'] = $opt ; 192 $products[$row['id']]=$row; 193 } 194 195 196 $query='SELECT * FROM '.MPS_OPTION_TABLE.' ;'; 206 207 $products[$row['id']]['option'][]=$row['name']; 208 } 209 210 $query=' 211 SELECT `id`, `name` 212 FROM '.MPS_OPTION_TABLE.' 213 ;'; 197 214 $result = pwg_query($query); 198 215 $option = array(); 199 while($row = pwg_db_fetch_assoc($result)){ 216 217 while($row = pwg_db_fetch_assoc($result)) { 200 218 $option[$row['id']] = $row['name']; 201 219 } 202 203 $template->assign(array( 204 'mps_product' => $products, 205 'mps_option' => $option, 206 'mps_type_opt' => $select_type_opt, 220 221 $select_type_opt=array( 222 'select' =>'select', 223 'radio' =>'radio', 224 'text' =>'text', 225 'textarea' =>'textarea', 226 'checkbox' =>'checkbox', 227 ); 228 229 //template assign 230 $template->assign(array( 231 'mps_product' => $products, 232 'mps_option' => $option, 233 'mps_type_opt' => $select_type_opt, 207 234 )); 208 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl')); 235 236 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl')); -
extensions/MyPiwiShop/admin/template/product.tpl
r27743 r27781 442 442 <td><span>{$product.product}</span> <a title="{'edit'|translate|escape:'javascript'}" class="prodEdit icon-pencil tabact">{'edit'|translate}</a> <a title="{'duplicate'|translate|escape:'javascript'}" class="prodDupli icon-pencil tabact">{'duplicate'|translate}</a></td> 443 443 <td>{$product.noteAdmin} </td> 444 <td>{foreach from=$product.option item=option name=option}{ $option}/{/foreach}</td>444 <td>{foreach from=$product.option item=option name=option}{if !empty($option)}{$option}/{/if}{/foreach}</td> 445 445 <td>{$product.price} {$mps_conf.currency}</td> 446 446 </tr> -
extensions/MyPiwiShop/include/admin_events.inc.php
r27568 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 /** 5 * admin plugins menu link 6 */ 4 5 // admin plugins menu link 7 6 function mps_admin_plugin_menu_links($menu) 8 7 { … … 15 14 } 16 15 17 18 /** 19 * add an action to the Batch Manager unit 20 */ 21 16 //add an action to the Batch Manager unit 22 17 function mps_loc_end_element_set_unit() 23 18 { … … 25 20 26 21 global $template; 27 $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl')); 28 $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit'); 29 30 $template->set_prefilter('batch_manager_unit', 'batch_unit_form'); 22 $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl')); 23 $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit'); 24 $template->set_prefilter('batch_manager_unit', 'batch_unit_form'); 31 25 } 32 26 33 27 function batch_unit_form($content) 34 28 { 35 36 $search = '#</table>(\s*)</fieldset>#s'; 37 $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"} 38 {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>'; 29 $search = '#</table>(\s*)</fieldset>#s'; 30 $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"} 31 {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>'; 39 32 40 33 return preg_replace($search, $replace, $content); 41 34 } 42 35 43 /** 44 * add an action to the Batch Manager 45 */ 46 36 //add an action to the Batch Manager 47 37 function mps_loc_end_element_set_global() 48 38 { 49 39 include_once(MPS_PATH.'admin/MyPiwiShopBatch.php'); 50 40 51 global $template; 52 53 $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl')); 54 55 $template->append('element_set_global_plugins_actions', array( 56 'ID' => 'mps', 57 'NAME' => l10n('MyPiwiShop'), 58 'CONTENT' => $template->parse('mps_batch_global', true) 59 )); 41 global $template; 42 $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl')); 43 $template->append('element_set_global_plugins_actions', array( 44 'ID' => 'mps', 45 'NAME' => l10n('MyPiwiShop'), 46 'CONTENT' => $template->parse('mps_batch_global', true) 47 )); 60 48 } 61 49 62 /** 63 * perform added action 64 */ 50 // perform added action 65 51 function mps_element_set_global_action($action, $collection) 66 52 { 67 if ($action == 'mps') 68 { 69 global $page; 53 if ($action == 'mps') { 54 global $page; 70 55 71 if (empty($_POST['productcheck'])) 72 { 73 $page['errors'][] = l10n('Select at least one product'); 74 } 75 else if ($_POST['thisprod']=='del') 76 { 77 $product_id = $_POST['productcheck']; 78 deletAll_product_image($product_id, $collection); 79 $page['infos'][] = l10n('Products have been removed for these pictures'); 80 } 81 else 82 { 83 $product_id = $_POST['productcheck']; 84 add_product_image($product_id, $collection); 85 $page['infos'][] = l10n('products have been added to these images'); 86 } 56 if (empty($_POST['productcheck'])) { 57 $page['errors'][] = l10n('Select at least one product'); 58 } else if ($_POST['thisprod']=='del') { 59 $product_id = $_POST['productcheck']; 60 deletAll_product_image($product_id, $collection); 61 $page['infos'][] = l10n('Products have been removed for these pictures'); 62 } else { 63 $product_id = $_POST['productcheck']; 64 add_product_image($product_id, $collection); 65 $page['infos'][] = l10n('products have been added to these images'); 66 } 67 87 68 } 88 89 69 } 90 70 -
extensions/MyPiwiShop/include/functions.inc.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 /** 5 *product/image 6 **/ 4 //add a product to all selected image 7 5 function add_product_image($product, $images) 8 6 { … … 12 10 } 13 11 14 $query = ' 15 DELETE 16 FROM '.MPS_PROD_IMG_TABLE.' 17 WHERE image_id IN ('.implode(',', $images).') 18 AND product_id IN ('.implode(',', $product).') 12 pwg_query(' 13 DELETE 14 FROM '.MPS_PROD_IMG_TABLE.' 15 WHERE image_id IN ('.implode(',', $images).') 16 AND product_id IN ('.implode(',', $product).') 17 ;'); 19 18 20 ;'; 21 pwg_query($query); 22 23 $inserts = array(); 24 foreach ($images as $image_id) 25 { 26 foreach ( array_unique($product) as $product_id) 27 { 28 $inserts[] = array( 29 'image_id' => $image_id, 30 'product_id' => $product_id, 31 ); 32 } 19 foreach ($images as $image_id) { 20 21 foreach ( array_unique($product) as $product_id) { 22 $inserts[] = array( 23 'image_id' => $image_id, 24 'product_id' => $product_id, 25 ); 26 } 33 27 } 34 mass_inserts( 35 MPS_PROD_IMG_TABLE, 36 array_keys($inserts[0]), 37 $inserts 38 ); 28 29 mass_inserts( 30 MPS_PROD_IMG_TABLE, 31 array_keys($inserts[0]), 32 $inserts 33 ); 39 34 } 40 35 41 /** 42 *product/image 43 **/ 36 //delet all product for all selected image 44 37 function deletAll_product_image($product, $images) 45 38 { 46 $query = ' 47 DELETE 48 FROM '.MPS_PROD_IMG_TABLE.' 49 WHERE image_id IN ('.implode(',', $images).') 50 AND product_id IN ('.implode(',', $product).') 51 52 ;'; 53 pwg_query($query); 54 39 pwg_query(' 40 DELETE 41 FROM '.MPS_PROD_IMG_TABLE.' 42 WHERE image_id IN ('.implode(',', $images).') 43 AND product_id IN ('.implode(',', $product).') 44 ;'); 55 45 } 56 46 57 function deletThis_image_Allproduct($images) 47 //delet all product to specific image 48 function delet_Allproduct_Thisimage($images) 58 49 { 59 50 $query = ' … … 67 58 } 68 59 60 //add a product to specific image 69 61 function add_product_Thisimage($product, $images) 70 62 { -
extensions/MyPiwiShop/include/public_events.inc.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 /* 5 * button on album and photos pages 6 */ 4 //button on album and photos pages 7 5 function mps_add_button() 8 6 { 9 7 global $template, $conf; 10 8 11 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 12 $result = pwg_query($query); 13 while($row = pwg_db_fetch_assoc($result)){ 14 $config = $row ; 15 } 9 $query=' 10 SELECT * 11 FROM '.MPS_CONF_TABLE.' 12 ;'; 13 $result = pwg_query($query); 14 15 while($row = pwg_db_fetch_assoc($result)){ 16 $config = $row ; 17 } 16 18 17 18 19 20 21 // $template->assign('MPS_PATH', MPS_PATH); 19 $template->assign(array( 20 'mps_conf' => $config, 21 'MPS_PATH' => MPS_PATH, 22 )); 23 22 24 $template->set_filename('mps_button', realpath(MPS_PATH.'template/button_basket.tpl')); 23 // $template->assign('mps_conf' , $config);24 25 25 $button = $template->parse('mps_button', true); 26 26 27 if (script_basename()=='index') 28 { 27 if (script_basename()=='index') { 29 28 $template->add_index_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL); 30 } 31 else 32 { 29 } else { 33 30 $template->add_picture_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL); 34 31 } 35 32 } 36 33 37 /** 38 * add a forms on photo page 39 */ 40 function mps_loc_end_picture() 34 // add a forms on photo page 35 function mps_init_form_picture() 41 36 { 42 37 global $template; 43 $template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl')); 44 $template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop'); 38 39 $template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl')); 40 $template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop'); 45 41 } 46 42 43 // place on picture page (default theme) 47 44 function mps_picture_form($content) 48 45 { 49 50 46 $search = '#</div>(\s*)</div>(\s*){if isset\(\$COMMENT_COUNT\)}#s'; 47 $replace = '</div>$1</div>$2<div id="MyPiwiShop">{$MPS_CONTENT}</div>{if isset(\$COMMENT_COUNT)}'; 51 48 52 49 return preg_replace($search, $replace, $content); 53 50 } 54 51 52 // place on picture page (piwitheme theme) 55 53 function mps_picture_form_piwitheme($content) 56 54 { 57 58 55 $search = '#{/foreach}(\s*){/foreach}(\s*)</table>(\s*){/if}(\s*)</div>#s'; 56 $replace = '{/foreach}$1{/foreach}$1</table>$1{/if}</div><div class="panelPP"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div>'; 59 57 60 58 $newcont = preg_replace($search, $replace, $content); 61 59 62 63 60 $search = '#<a class="trigger" href="\#">(\s*)infos(\s*)</a>(\s*)#s'; 61 $replace = '<a class="trigger" href="#">infos</a>$1<a class="triggerPP" href="#" >{\'Shop\'|@translate}</a>{footer_script}{literal}$(document).ready(function(){$(".triggerPP").click(function(){$(".panelPP").toggle("fast");$(this).toggleClass("active");return false;});});{/literal}{/footer_script}'; 64 62 65 63 return preg_replace($search, $replace, $newcont); 66 64 } 67 65 66 // place on picture page (stripped theme) 68 67 function mps_picture_form_stripped($content) 69 68 { 70 71 69 $search = '#<div style="clear: both;"></div>(\s*)</div>(\s*)</div>(\s*)</div>(\s*){/if}(\s*)</div>#s'; 70 $replace = '<div style="clear: both;"></div></div>$1</div></div>$2{/if}<div id="Tmps" class="tabBlock"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div></div>'; 72 71 73 72 $newcont = preg_replace($search, $replace, $content); 74 73 75 76 74 $search = '#{/if}(\s*)</ul>(\s*)#s'; 75 $replace = '{/if}$2<li id="tabTmps" class="tabTitle" title="{\'Shop\'|@translate}" name="shop">{\'Shop\'|@translate}</li></ul>'; 77 76 78 77 return preg_replace($search, $replace, $newcont); 79 78 } 80 79 … … 82 81 { 83 82 global $conf, $template, $picture, $user; 84 $image_id = $picture['current']['id']; 83 84 $image_id = $picture['current']['id']; 85 85 86 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 87 $result = pwg_query($query); 88 while($row = pwg_db_fetch_assoc($result)){ 89 $config = $row ; 90 } 86 $query=' 87 SELECT * 88 FROM '.MPS_CONF_TABLE.' 89 ;'; 90 $result = pwg_query($query); 91 92 while($row = pwg_db_fetch_assoc($result)) { 93 $config = $row ; 94 } 91 95 92 93 94 95 96 97 96 $query = ' 97 SELECT * 98 FROM '.MPS_PROD_IMG_TABLE.' AS pi 99 INNER JOIN '.MPS_PRODUCT_TABLE.' AS p ON pi.product_id = p.id 100 WHERE image_id = '.$image_id .' 101 ORDER BY `order` 98 102 ;'; 99 $result = pwg_query($query); 100 $num_rows = pwg_db_num_rows($result); 101 if ($num_rows != 0){ 102 while($row = pwg_db_fetch_assoc($result)){ 103 $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency']; 104 $price[] = $row['price']; 105 } 103 $result = pwg_query($query); 104 $num_rows = pwg_db_num_rows($result); 105 106 if ($num_rows != 0) { 107 while($row = pwg_db_fetch_assoc($result)) { 108 $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency']; 109 $price[] = $row['price']; 110 } 106 111 107 112 108 $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val113 $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val 109 114 FROM '.MPS_PROD_IMG_TABLE.' AS pi 110 LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id 111 LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id 112 LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id 113 LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id 114 WHERE image_id = '.$image_id .' 115 AND po.opt_id IS NOT NULL 116 ;'; 117 118 $result = pwg_query($query); 119 while($row = pwg_db_fetch_assoc($result)){ 120 { 121 if (!isset($products[ $row['product']]['options'][ $row['order'] ])) 122 { 123 $products[ $row['product'] ]['options'][ $row['order'] ] = array( 124 'name' => $row['name'], 125 'type' => $row['type'], 126 'requi' => $row['requi'], 127 'values' => array(), 128 ); 129 } 115 LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id 116 LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id 117 LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id 118 LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id 119 WHERE image_id = '.$image_id .' 120 AND po.opt_id IS NOT NULL 121 ;'; 122 $result = pwg_query($query); 123 124 while($row = pwg_db_fetch_assoc($result)) { 125 { 126 if (!isset($products[ $row['product']]['options'][ $row['order'] ])) { 127 $products[ $row['product'] ]['options'][ $row['order'] ] = array( 128 'name' => $row['name'], 129 'type' => $row['type'], 130 'requi' => $row['requi'], 131 'values' => array(), 132 ); 133 } 134 $products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val']; 135 136 } 137 } 130 138 131 $products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val']; 132 } 133 } 134 if(isset($products)){ 135 $template->assign(array( 136 'mps_options' => $products, 137 )); 138 } 139 140 $template->assign(array( 141 'mps_conf' => $config, 142 'mps_price' => $price, 143 'mps_product' => $product, 144 )); 139 if(isset($products)) { 140 $template->assign(array( 141 'mps_options' => $products, 142 )); 143 } 144 145 $template->assign(array( 146 'mps_conf' => $config, 147 'mps_price' => $price, 148 'mps_product' => $product, 149 )); 145 150 146 147 148 149 $theme = $user['theme']; 150 151 switch ($theme) { 151 $theme = $user['theme']; 152 153 switch ($theme) { 152 154 case 'stripped': 153 154 155 $template->set_prefilter('picture', 'mps_picture_form_stripped'); 156 break; 155 157 case 'PwgCarbon_dft': 156 158 case 'PwgCarbon': … … 159 161 case 'Slimi': 160 162 case 'Slim': 161 162 163 163 $template->set_prefilter('picture', 'mps_picture_form_piwitheme'); 164 $template->assign(array('bypiwitheme'=> 'bypiwitheme')); 165 break; 164 166 default: 165 $template->set_prefilter('picture', 'mps_picture_form'); 166 break; 167 } 168 169 167 $template->set_prefilter('picture', 'mps_picture_form'); 168 break; 170 169 } 170 } 171 171 } 172 172 -
extensions/MyPiwiShop/main.inc.php
r27743 r27781 35 35 add_event_handler('init', 'mps_init'); 36 36 37 if (defined('IN_ADMIN')) 38 { 37 if (defined('IN_ADMIN')) { 39 38 include_once(MPS_PATH . 'include/admin_events.inc.php'); 40 39 … … 47 46 add_event_handler('element_set_global_action', 'mps_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 48 47 add_event_handler('loc_end_element_set_unit', 'mps_loc_end_element_set_unit'); 49 50 } 51 else 52 { 48 } else { 53 49 // file containing all public handlers functions 54 50 include_once(MPS_PATH . 'include/public_events.inc.php'); … … 60 56 // form on photo page 61 57 add_event_handler('loc_end_picture', 'mps_prepar_tpl'); 62 add_event_handler('loc_end_picture', 'mps_ loc_end_picture');58 add_event_handler('loc_end_picture', 'mps_init_form_picture'); 63 59 } 64 60 … … 66 62 include_once(MPS_PATH . 'include/functions.inc.php'); 67 63 68 function mps_init() 69 { 64 function mps_init() { 70 65 global $prefixeTable; 71 66 … … 75 70 $maintain->autoUpdate(MPS_VERSION, 'install'); 76 71 77 $query='SELECT * FROM '.MPS_CONF_TABLE.';'; 78 if(pwg_db_num_rows(pwg_query($query))==0){ 79 single_insert( 80 $prefixeTable."mps_conf", 81 array( 82 'currency' => 'EUR', 83 ) 84 ); 85 } 72 $query=' 73 SELECT * 74 FROM '.MPS_CONF_TABLE.' 75 ;'; 76 77 if(pwg_db_num_rows(pwg_query($query))==0) { 78 single_insert( 79 $prefixeTable."mps_conf", 80 array( 81 'currency' => 'EUR', 82 ) 83 ); 84 } 86 85 87 86 // load plugin language file 88 87 load_language('plugin.lang', MPS_PATH); 89 90 88 } 91 89 -
extensions/MyPiwiShop/maintain.inc.php
r27743 r27781 74 74 ;'); 75 75 76 $this->installed = true; 77 76 $this->installed = true; 78 77 } 79 78 80 81 /** 82 * plugin activation 83 */ 84 function activate($plugin_version, &$errors=array()) 79 function activate($plugin_version, &$errors=array()) 85 80 { 86 87 if (!$this->installed) 88 { 89 $this->install($plugin_version, $errors); 90 } 81 if (!$this->installed) { 82 $this->install($plugin_version, $errors); 83 } 91 84 } 92 85 … … 95 88 } 96 89 97 98 /**99 * plugin uninstallation100 */101 90 function uninstall() 102 91 { … … 109 98 pwg_query('DROP TABLE `'. $prefixeTable .'mps_opt_val`;'); 110 99 pwg_query('DROP TABLE `'. $prefixeTable .'mps_prod_opt`;'); 111 }100 } 112 101 } 113 102
Note: See TracChangeset
for help on using the changeset viewer.