@@ -122,7 +122,7 @@ |
||
| 122 | 122 | /** |
| 123 | 123 | * Mise à jour des stocks pour chaque livre composant la commande |
| 124 | 124 | * @param integer $cmd_id Identifiant de la commande |
| 125 | - * @return void |
|
| 125 | + * @return boolean |
|
| 126 | 126 | */ |
| 127 | 127 | public function updateStocks($cmd_id) |
| 128 | 128 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | include_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
| 37 | 37 | if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) { |
| 38 | - include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 38 | + include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,29 +43,29 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class bookshop_commands extends Bookshop_Object |
| 45 | 45 | { |
| 46 | - public function __construct() |
|
| 47 | - { |
|
| 48 | - $this->initVar('cmd_id', XOBJ_DTYPE_INT, null, false); |
|
| 49 | - $this->initVar('cmd_uid', XOBJ_DTYPE_INT, null, false); |
|
| 50 | - $this->initVar('cmd_date', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 51 | - $this->initVar('cmd_state', XOBJ_DTYPE_INT, null, false); |
|
| 52 | - $this->initVar('cmd_ip', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 53 | - $this->initVar('cmd_lastname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 54 | - $this->initVar('cmd_firstname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 55 | - $this->initVar('cmd_adress', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 56 | - $this->initVar('cmd_zip', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 57 | - $this->initVar('cmd_town', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 58 | - $this->initVar('cmd_country', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 59 | - $this->initVar('cmd_telephone', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 60 | - $this->initVar('cmd_email', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 61 | - $this->initVar('cmd_articles_count', XOBJ_DTYPE_INT, null, false); |
|
| 62 | - $this->initVar('cmd_total', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 63 | - $this->initVar('cmd_shipping', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 64 | - $this->initVar('cmd_bill', XOBJ_DTYPE_INT, null, false); |
|
| 65 | - $this->initVar('cmd_password', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 66 | - $this->initVar('cmd_text', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 67 | - $this->initVar('cmd_cancel', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 68 | - } |
|
| 46 | + public function __construct() |
|
| 47 | + { |
|
| 48 | + $this->initVar('cmd_id', XOBJ_DTYPE_INT, null, false); |
|
| 49 | + $this->initVar('cmd_uid', XOBJ_DTYPE_INT, null, false); |
|
| 50 | + $this->initVar('cmd_date', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 51 | + $this->initVar('cmd_state', XOBJ_DTYPE_INT, null, false); |
|
| 52 | + $this->initVar('cmd_ip', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 53 | + $this->initVar('cmd_lastname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 54 | + $this->initVar('cmd_firstname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 55 | + $this->initVar('cmd_adress', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 56 | + $this->initVar('cmd_zip', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 57 | + $this->initVar('cmd_town', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 58 | + $this->initVar('cmd_country', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 59 | + $this->initVar('cmd_telephone', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 60 | + $this->initVar('cmd_email', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 61 | + $this->initVar('cmd_articles_count', XOBJ_DTYPE_INT, null, false); |
|
| 62 | + $this->initVar('cmd_total', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 63 | + $this->initVar('cmd_shipping', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 64 | + $this->initVar('cmd_bill', XOBJ_DTYPE_INT, null, false); |
|
| 65 | + $this->initVar('cmd_password', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 66 | + $this->initVar('cmd_text', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 67 | + $this->initVar('cmd_cancel', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 68 | + } |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -73,99 +73,99 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | class BookshopBookshop_commandsHandler extends Bookshop_XoopsPersistableObjectHandler |
| 75 | 75 | { |
| 76 | - /** |
|
| 77 | - * @param $db |
|
| 78 | - */ |
|
| 79 | - public function __construct($db) |
|
| 80 | - { // Table Classe Id |
|
| 81 | - parent::__construct($db, 'bookshop_commands', 'bookshop_commands', 'cmd_id'); |
|
| 82 | - } |
|
| 76 | + /** |
|
| 77 | + * @param $db |
|
| 78 | + */ |
|
| 79 | + public function __construct($db) |
|
| 80 | + { // Table Classe Id |
|
| 81 | + parent::__construct($db, 'bookshop_commands', 'bookshop_commands', 'cmd_id'); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Indique si c'est la premi�re commande d'un client |
|
| 86 | - * |
|
| 87 | - * @param integer $uid Identifiant de l'utilisateur |
|
| 88 | - * @return boolean Indique si c'est le cas ou pas |
|
| 89 | - */ |
|
| 90 | - public function isFirstCommand($uid) |
|
| 91 | - { |
|
| 92 | - $critere = new Criteria('cmd_uid', (int)$uid, '='); |
|
| 93 | - if ($this->getCount($critere) > 0) { |
|
| 94 | - return true; |
|
| 95 | - } else { |
|
| 96 | - return false; |
|
| 97 | - } |
|
| 98 | - } |
|
| 84 | + /** |
|
| 85 | + * Indique si c'est la premi�re commande d'un client |
|
| 86 | + * |
|
| 87 | + * @param integer $uid Identifiant de l'utilisateur |
|
| 88 | + * @return boolean Indique si c'est le cas ou pas |
|
| 89 | + */ |
|
| 90 | + public function isFirstCommand($uid) |
|
| 91 | + { |
|
| 92 | + $critere = new Criteria('cmd_uid', (int)$uid, '='); |
|
| 93 | + if ($this->getCount($critere) > 0) { |
|
| 94 | + return true; |
|
| 95 | + } else { |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 100 | + /** |
|
| 101 | 101 | * Indique si un livre a déajà été acheté par un utilisateur |
| 102 | - * |
|
| 103 | - * @param integer $uid Identifiant de l'utilisateur |
|
| 104 | - * @param integer $bookId Identifiant du livre |
|
| 105 | - * @return boolean Indique si c'est le cas ou pas |
|
| 106 | - */ |
|
| 107 | - public function BookAlreadyBought($uid, $bookId) |
|
| 108 | - { |
|
| 109 | - $sql = 'SELECT Count(*) as cpt FROM ' . $this->db->prefix('bookshop_caddy') . ' c, ' . $this->db->prefix('bookshop_commands') . ' f WHERE c.caddy_book_id = ' . (int)$bookId . ' AND c.caddy_cmd_id = f.cmd_id AND f.cmd_uid = ' . (int)$uid; |
|
| 110 | - $result = $this->db->query($sql); |
|
| 111 | - if (!$result) { |
|
| 112 | - return 0; |
|
| 113 | - } |
|
| 114 | - list($count) = $this->db->fetchRow($result); |
|
| 115 | - if ($count > 0) { |
|
| 116 | - return true; |
|
| 117 | - } else { |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 120 | - } |
|
| 102 | + * |
|
| 103 | + * @param integer $uid Identifiant de l'utilisateur |
|
| 104 | + * @param integer $bookId Identifiant du livre |
|
| 105 | + * @return boolean Indique si c'est le cas ou pas |
|
| 106 | + */ |
|
| 107 | + public function BookAlreadyBought($uid, $bookId) |
|
| 108 | + { |
|
| 109 | + $sql = 'SELECT Count(*) as cpt FROM ' . $this->db->prefix('bookshop_caddy') . ' c, ' . $this->db->prefix('bookshop_commands') . ' f WHERE c.caddy_book_id = ' . (int)$bookId . ' AND c.caddy_cmd_id = f.cmd_id AND f.cmd_uid = ' . (int)$uid; |
|
| 110 | + $result = $this->db->query($sql); |
|
| 111 | + if (!$result) { |
|
| 112 | + return 0; |
|
| 113 | + } |
|
| 114 | + list($count) = $this->db->fetchRow($result); |
|
| 115 | + if ($count > 0) { |
|
| 116 | + return true; |
|
| 117 | + } else { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 122 | + /** |
|
| 123 | 123 | * Mise à jour des stocks pour chaque livre composant la commande |
| 124 | - * @param integer $cmd_id Identifiant de la commande |
|
| 125 | - * @return void |
|
| 126 | - */ |
|
| 127 | - public function updateStocks($cmd_id) |
|
| 128 | - { |
|
| 129 | - global $h_bookshop_caddy, $h_bookshop_books; |
|
| 130 | - // Recherche de tous les livres du caddy |
|
| 131 | - $caddy = $h_bookshop_caddy->getCaddyFromCommand($cmd_id); |
|
| 132 | - $tblTmp = $tblBooks = array(); |
|
| 133 | - foreach ($caddy as $item) { |
|
| 134 | - $tblTmp[] = $item->getVar('caddy_book_id'); |
|
| 135 | - } |
|
| 136 | - // Chargement de tous les livres |
|
| 137 | - $critere = new Criteria('book_id', '(' . implode(',', $tblTmp) . ')', 'IN'); |
|
| 138 | - $tblBooks = $h_bookshop_books->getObjects($critere, true); |
|
| 124 | + * @param integer $cmd_id Identifiant de la commande |
|
| 125 | + * @return void |
|
| 126 | + */ |
|
| 127 | + public function updateStocks($cmd_id) |
|
| 128 | + { |
|
| 129 | + global $h_bookshop_caddy, $h_bookshop_books; |
|
| 130 | + // Recherche de tous les livres du caddy |
|
| 131 | + $caddy = $h_bookshop_caddy->getCaddyFromCommand($cmd_id); |
|
| 132 | + $tblTmp = $tblBooks = array(); |
|
| 133 | + foreach ($caddy as $item) { |
|
| 134 | + $tblTmp[] = $item->getVar('caddy_book_id'); |
|
| 135 | + } |
|
| 136 | + // Chargement de tous les livres |
|
| 137 | + $critere = new Criteria('book_id', '(' . implode(',', $tblTmp) . ')', 'IN'); |
|
| 138 | + $tblBooks = $h_bookshop_books->getObjects($critere, true); |
|
| 139 | 139 | // Boucle sur le caddy pour mettre à jour les quantités |
| 140 | - foreach ($caddy as $item) { |
|
| 141 | - if (isset($tblBooks[$item->getVar('caddy_book_id')])) { |
|
| 142 | - $book = $tblBooks[$item->getVar('caddy_book_id')]; |
|
| 143 | - $h_bookshop_books->decreaseStock($book, $item->getVar('caddy_qte')); |
|
| 140 | + foreach ($caddy as $item) { |
|
| 141 | + if (isset($tblBooks[$item->getVar('caddy_book_id')])) { |
|
| 142 | + $book = $tblBooks[$item->getVar('caddy_book_id')]; |
|
| 143 | + $h_bookshop_books->decreaseStock($book, $item->getVar('caddy_qte')); |
|
| 144 | 144 | $h_bookshop_books->verifyLowStock($book); // Vérification du stock d'alerte |
| 145 | - } |
|
| 146 | - } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - return true; |
|
| 149 | - } |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 151 | + /** |
|
| 152 | 152 | * Validation d'une commande et mise à jour des stocks |
| 153 | - * |
|
| 154 | - * @param integer $cmd_id Identifiant de la commande |
|
| 155 | - * @return boolean Indique si la validation de la commande s'est bien faite ou pas |
|
| 156 | - */ |
|
| 157 | - public function validateCommand($cmd_id) |
|
| 158 | - { |
|
| 159 | - $retval = false; |
|
| 160 | - $commande =& $this->get($cmd_id); |
|
| 161 | - if (is_object($commande)) { |
|
| 162 | - $commande->setVar('cmd_state', COMMAND_STATE_VALIDATED); |
|
| 163 | - $retval = $this->insert($commande, true); |
|
| 164 | - if ($retval) { |
|
| 165 | - $this->updateStocks($cmd_id); |
|
| 166 | - } |
|
| 167 | - } |
|
| 153 | + * |
|
| 154 | + * @param integer $cmd_id Identifiant de la commande |
|
| 155 | + * @return boolean Indique si la validation de la commande s'est bien faite ou pas |
|
| 156 | + */ |
|
| 157 | + public function validateCommand($cmd_id) |
|
| 158 | + { |
|
| 159 | + $retval = false; |
|
| 160 | + $commande =& $this->get($cmd_id); |
|
| 161 | + if (is_object($commande)) { |
|
| 162 | + $commande->setVar('cmd_state', COMMAND_STATE_VALIDATED); |
|
| 163 | + $retval = $this->insert($commande, true); |
|
| 164 | + if ($retval) { |
|
| 165 | + $this->updateStocks($cmd_id); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - return $retval; |
|
| 170 | - } |
|
| 169 | + return $retval; |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 28 | 28 | |
| 29 | -define('COMMAND_STATE_NOINFORMATION', 0); // Pas encore d'informations sur la commande |
|
| 30 | -define("COMMAND_STATE_VALIDATED", 1); // Commande validée par Paypal |
|
| 31 | -define('COMMAND_STATE_PENDING', 2); // En attente |
|
| 32 | -define('COMMAND_STATE_FAILED', 3); // Echec |
|
| 33 | -define("COMMAND_STATE_CANCELED", 4); // Annulée |
|
| 34 | -define('COMMAND_STATE_FRAUD', 5); // Fraude |
|
| 29 | +define('COMMAND_STATE_NOINFORMATION', 0); // Pas encore d'informations sur la commande |
|
| 30 | +define("COMMAND_STATE_VALIDATED", 1); // Commande validée par Paypal |
|
| 31 | +define('COMMAND_STATE_PENDING', 2); // En attente |
|
| 32 | +define('COMMAND_STATE_FAILED', 3); // Echec |
|
| 33 | +define("COMMAND_STATE_CANCELED", 4); // Annulée |
|
| 34 | +define('COMMAND_STATE_FRAUD', 5); // Fraude |
|
| 35 | 35 | |
| 36 | -include_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
| 36 | +include_once XOOPS_ROOT_PATH.'/kernel/object.php'; |
|
| 37 | 37 | if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) { |
| 38 | - include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 38 | + include_once XOOPS_ROOT_PATH.'/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function BookAlreadyBought($uid, $bookId) |
| 108 | 108 | { |
| 109 | - $sql = 'SELECT Count(*) as cpt FROM ' . $this->db->prefix('bookshop_caddy') . ' c, ' . $this->db->prefix('bookshop_commands') . ' f WHERE c.caddy_book_id = ' . (int)$bookId . ' AND c.caddy_cmd_id = f.cmd_id AND f.cmd_uid = ' . (int)$uid; |
|
| 109 | + $sql = 'SELECT Count(*) as cpt FROM '.$this->db->prefix('bookshop_caddy').' c, '.$this->db->prefix('bookshop_commands').' f WHERE c.caddy_book_id = '.(int)$bookId.' AND c.caddy_cmd_id = f.cmd_id AND f.cmd_uid = '.(int)$uid; |
|
| 110 | 110 | $result = $this->db->query($sql); |
| 111 | 111 | if (!$result) { |
| 112 | 112 | return 0; |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | $tblTmp[] = $item->getVar('caddy_book_id'); |
| 135 | 135 | } |
| 136 | 136 | // Chargement de tous les livres |
| 137 | - $critere = new Criteria('book_id', '(' . implode(',', $tblTmp) . ')', 'IN'); |
|
| 137 | + $critere = new Criteria('book_id', '('.implode(',', $tblTmp).')', 'IN'); |
|
| 138 | 138 | $tblBooks = $h_bookshop_books->getObjects($critere, true); |
| 139 | 139 | // Boucle sur le caddy pour mettre à jour les quantités |
| 140 | 140 | foreach ($caddy as $item) { |
| 141 | 141 | if (isset($tblBooks[$item->getVar('caddy_book_id')])) { |
| 142 | 142 | $book = $tblBooks[$item->getVar('caddy_book_id')]; |
| 143 | 143 | $h_bookshop_books->decreaseStock($book, $item->getVar('caddy_qte')); |
| 144 | - $h_bookshop_books->verifyLowStock($book); // Vérification du stock d'alerte |
|
| 144 | + $h_bookshop_books->verifyLowStock($book); // Vérification du stock d'alerte |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | public function validateCommand($cmd_id) |
| 158 | 158 | { |
| 159 | 159 | $retval = false; |
| 160 | - $commande =& $this->get($cmd_id); |
|
| 160 | + $commande = & $this->get($cmd_id); |
|
| 161 | 161 | if (is_object($commande)) { |
| 162 | 162 | $commande->setVar('cmd_state', COMMAND_STATE_VALIDATED); |
| 163 | 163 | $retval = $this->insert($commande, true); |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | * @param integer $book_id Identifiant du livre |
| 67 | 67 | * @param integer $totalVotes Variable passée par référence et devant contenir le nombre total de votes du livre |
| 68 | 68 | * @param integer $sumRating Variable passée par référence et devant contenir le cumul des votes |
| 69 | - * @return none Rien |
|
| 69 | + * @return integer|null Rien |
|
| 70 | 70 | */ |
| 71 | 71 | public function getCountRecordSumRating($book_id, &$totalVotes, &$sumRating) |
| 72 | 72 | { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | include_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
| 30 | 30 | if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) { |
| 31 | - include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 31 | + include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class bookshop_votedata extends Bookshop_Object |
| 38 | 38 | { |
| 39 | - public function __construct() |
|
| 40 | - { |
|
| 41 | - $this->initVar('vote_ratingid', XOBJ_DTYPE_INT, null, false); |
|
| 42 | - $this->initVar('vote_book_id', XOBJ_DTYPE_INT, null, false); |
|
| 43 | - $this->initVar('vote_uid', XOBJ_DTYPE_INT, null, false); |
|
| 44 | - $this->initVar('vote_rating', XOBJ_DTYPE_INT, null, false); |
|
| 45 | - $this->initVar('vote_ratinghostname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 46 | - $this->initVar('vote_ratingtimestamp', XOBJ_DTYPE_INT, null, false); |
|
| 47 | - } |
|
| 39 | + public function __construct() |
|
| 40 | + { |
|
| 41 | + $this->initVar('vote_ratingid', XOBJ_DTYPE_INT, null, false); |
|
| 42 | + $this->initVar('vote_book_id', XOBJ_DTYPE_INT, null, false); |
|
| 43 | + $this->initVar('vote_uid', XOBJ_DTYPE_INT, null, false); |
|
| 44 | + $this->initVar('vote_rating', XOBJ_DTYPE_INT, null, false); |
|
| 45 | + $this->initVar('vote_ratinghostname', XOBJ_DTYPE_TXTBOX, null, false); |
|
| 46 | + $this->initVar('vote_ratingtimestamp', XOBJ_DTYPE_INT, null, false); |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -52,52 +52,52 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | class BookshopBookshop_votedataHandler extends Bookshop_XoopsPersistableObjectHandler |
| 54 | 54 | { |
| 55 | - /** |
|
| 56 | - * @param $db |
|
| 57 | - */ |
|
| 58 | - public function __construct($db) |
|
| 59 | - { // Table Classe Id |
|
| 60 | - parent::__construct($db, 'bookshop_votedata', 'bookshop_votedata', 'vote_ratingid'); |
|
| 61 | - } |
|
| 55 | + /** |
|
| 56 | + * @param $db |
|
| 57 | + */ |
|
| 58 | + public function __construct($db) |
|
| 59 | + { // Table Classe Id |
|
| 60 | + parent::__construct($db, 'bookshop_votedata', 'bookshop_votedata', 'vote_ratingid'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Renvoie le nombre total de votes pour un livre ainsi que la sommes des votes |
|
| 65 | - * |
|
| 66 | - * @param integer $book_id Identifiant du livre |
|
| 63 | + /** |
|
| 64 | + * Renvoie le nombre total de votes pour un livre ainsi que la sommes des votes |
|
| 65 | + * |
|
| 66 | + * @param integer $book_id Identifiant du livre |
|
| 67 | 67 | * @param integer $totalVotes Variable passée par référence et devant contenir le nombre total de votes du livre |
| 68 | 68 | * @param integer $sumRating Variable passée par référence et devant contenir le cumul des votes |
| 69 | - * @return none Rien |
|
| 70 | - */ |
|
| 71 | - public function getCountRecordSumRating($book_id, &$totalVotes, &$sumRating) |
|
| 72 | - { |
|
| 73 | - $sql = 'SELECT count( * ) AS cpt, sum( vote_rating ) AS sum_rating FROM ' . $this->table . ' WHERE vote_book_id = ' . (int)$book_id; |
|
| 74 | - $result = $this->db->query($sql); |
|
| 75 | - if (!$result) { |
|
| 76 | - return 0; |
|
| 77 | - } else { |
|
| 78 | - $myrow = $this->db->fetchArray($result); |
|
| 79 | - $totalVotes = $myrow['cpt']; |
|
| 80 | - $sumRating = $myrow['sum_rating']; |
|
| 81 | - } |
|
| 82 | - } |
|
| 69 | + * @return none Rien |
|
| 70 | + */ |
|
| 71 | + public function getCountRecordSumRating($book_id, &$totalVotes, &$sumRating) |
|
| 72 | + { |
|
| 73 | + $sql = 'SELECT count( * ) AS cpt, sum( vote_rating ) AS sum_rating FROM ' . $this->table . ' WHERE vote_book_id = ' . (int)$book_id; |
|
| 74 | + $result = $this->db->query($sql); |
|
| 75 | + if (!$result) { |
|
| 76 | + return 0; |
|
| 77 | + } else { |
|
| 78 | + $myrow = $this->db->fetchArray($result); |
|
| 79 | + $totalVotes = $myrow['cpt']; |
|
| 80 | + $sumRating = $myrow['sum_rating']; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Returns the (x) last votes |
|
| 86 | - * |
|
| 87 | - * @param integer $start Starting position |
|
| 88 | - * @param integer $limit count of items to return |
|
| 89 | - * @return array Array of votedata objects |
|
| 90 | - */ |
|
| 91 | - public function getLastVotes($start = 0, $limit = 0) |
|
| 92 | - { |
|
| 93 | - $tbl_datas = array(); |
|
| 94 | - $criteria = new Criteria('vote_ratingid', 0, '<>'); |
|
| 95 | - $criteria->setLimit($limit); |
|
| 96 | - $criteria->setStart($start); |
|
| 97 | - $criteria->setSort('vote_ratingtimestamp'); |
|
| 98 | - $criteria->setOrder('DESC'); |
|
| 99 | - $tbl_datas =& $this->getObjects($criteria, true); |
|
| 84 | + /** |
|
| 85 | + * Returns the (x) last votes |
|
| 86 | + * |
|
| 87 | + * @param integer $start Starting position |
|
| 88 | + * @param integer $limit count of items to return |
|
| 89 | + * @return array Array of votedata objects |
|
| 90 | + */ |
|
| 91 | + public function getLastVotes($start = 0, $limit = 0) |
|
| 92 | + { |
|
| 93 | + $tbl_datas = array(); |
|
| 94 | + $criteria = new Criteria('vote_ratingid', 0, '<>'); |
|
| 95 | + $criteria->setLimit($limit); |
|
| 96 | + $criteria->setStart($start); |
|
| 97 | + $criteria->setSort('vote_ratingtimestamp'); |
|
| 98 | + $criteria->setOrder('DESC'); |
|
| 99 | + $tbl_datas =& $this->getObjects($criteria, true); |
|
| 100 | 100 | |
| 101 | - return $tbl_datas; |
|
| 102 | - } |
|
| 101 | + return $tbl_datas; |
|
| 102 | + } |
|
| 103 | 103 | } |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
| 28 | 28 | |
| 29 | -include_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
| 29 | +include_once XOOPS_ROOT_PATH.'/kernel/object.php'; |
|
| 30 | 30 | if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) { |
| 31 | - include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 31 | + include_once XOOPS_ROOT_PATH.'/modules/bookshop/class/PersistableObjectHandler.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function getCountRecordSumRating($book_id, &$totalVotes, &$sumRating) |
| 72 | 72 | { |
| 73 | - $sql = 'SELECT count( * ) AS cpt, sum( vote_rating ) AS sum_rating FROM ' . $this->table . ' WHERE vote_book_id = ' . (int)$book_id; |
|
| 73 | + $sql = 'SELECT count( * ) AS cpt, sum( vote_rating ) AS sum_rating FROM '.$this->table.' WHERE vote_book_id = '.(int)$book_id; |
|
| 74 | 74 | $result = $this->db->query($sql); |
| 75 | 75 | if (!$result) { |
| 76 | 76 | return 0; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $criteria->setStart($start); |
| 97 | 97 | $criteria->setSort('vote_ratingtimestamp'); |
| 98 | 98 | $criteria->setOrder('DESC'); |
| 99 | - $tbl_datas =& $this->getObjects($criteria, true); |
|
| 99 | + $tbl_datas = & $this->getObjects($criteria, true); |
|
| 100 | 100 | |
| 101 | 101 | return $tbl_datas; |
| 102 | 102 | } |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | /** |
| 110 | 110 | * retrieve an object |
| 111 | 111 | * |
| 112 | - * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor |
|
| 112 | + * @param integer $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor |
|
| 113 | 113 | * @param bool $as_object whether to return an object or an array |
| 114 | 114 | * @return mixed reference to the object, FALSE if failed |
| 115 | 115 | */ |
@@ -31,20 +31,20 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class Bookshop_Object extends XoopsObject |
| 33 | 33 | { |
| 34 | - /** |
|
| 35 | - * @param string $format |
|
| 36 | - * |
|
| 37 | - * @return array |
|
| 38 | - */ |
|
| 39 | - public function toArray($format = 's') |
|
| 40 | - { |
|
| 41 | - $ret = array(); |
|
| 42 | - foreach ($this->vars as $k => $v) { |
|
| 43 | - $ret[$k] = $this->getVar($k, $format); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - return $ret; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * @param string $format |
|
| 36 | + * |
|
| 37 | + * @return array |
|
| 38 | + */ |
|
| 39 | + public function toArray($format = 's') |
|
| 40 | + { |
|
| 41 | + $ret = array(); |
|
| 42 | + foreach ($this->vars as $k => $v) { |
|
| 43 | + $ret[$k] = $this->getVar($k, $format); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + return $ret; |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,523 +55,523 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | class Bookshop_XoopsPersistableObjectHandler extends XoopsObjectHandler |
| 57 | 57 | { |
| 58 | - /**#@+ |
|
| 58 | + /**#@+ |
|
| 59 | 59 | * Information about the class, the handler is managing |
| 60 | 60 | * |
| 61 | 61 | * @var string |
| 62 | 62 | */ |
| 63 | - public $table; |
|
| 64 | - protected $keyName; |
|
| 65 | - protected $className; |
|
| 66 | - protected $identifierName; |
|
| 67 | - protected $cacheOptions = array(); |
|
| 68 | - /**#@-*/ |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Constructor - called from child classes |
|
| 72 | - * |
|
| 73 | - * @param object $db {@link XoopsDatabase} object |
|
| 74 | - * @param string $tablename Name of database table |
|
| 75 | - * @param string $classname Name of Class, this handler is managing |
|
| 76 | - * @param string $keyname Name of the property, holding the key |
|
| 77 | - * |
|
| 78 | - * @param bool $idenfierName |
|
| 79 | - * |
|
| 80 | - */ |
|
| 81 | - public function __construct($db, $tablename, $classname, $keyname, $idenfierName = false) |
|
| 82 | - { |
|
| 83 | - parent::__construct($db); |
|
| 84 | - $this->table = $db->prefix($tablename); |
|
| 85 | - $this->keyName = $keyname; |
|
| 86 | - $this->className = $classname; |
|
| 87 | - if ($idenfierName != false) { |
|
| 88 | - $this->identifierName = $idenfierName; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * create a new object |
|
| 94 | - * |
|
| 95 | - * @param bool $isNew Flag the new objects as "new"? |
|
| 96 | - * |
|
| 97 | - * @return object |
|
| 98 | - */ |
|
| 99 | - public function create($isNew = true) |
|
| 100 | - { |
|
| 101 | - $obj = new $this->className(); |
|
| 102 | - if ($isNew === true) { |
|
| 103 | - $obj->setNew(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $obj; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * retrieve an object |
|
| 111 | - * |
|
| 112 | - * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor |
|
| 113 | - * @param bool $as_object whether to return an object or an array |
|
| 114 | - * @return mixed reference to the object, FALSE if failed |
|
| 115 | - */ |
|
| 116 | - public function &get($id, $as_object = true) |
|
| 117 | - { |
|
| 118 | - if (is_array($this->keyName)) { |
|
| 119 | - $criteria = new CriteriaCompo(); |
|
| 120 | - $vnb = count($this->keyName); |
|
| 121 | - for ($i = 0; $i < $vnb; ++$i) { |
|
| 122 | - $criteria->add(new Criteria($this->keyName[$i], (int)$id[$i])); |
|
| 123 | - } |
|
| 124 | - } else { |
|
| 125 | - $criteria = new Criteria($this->keyName, (int)$id); |
|
| 126 | - } |
|
| 127 | - $criteria->setLimit(1); |
|
| 128 | - $obj_array =& $this->getObjects($criteria, false, $as_object); |
|
| 129 | - if (count($obj_array) != 1) { |
|
| 130 | - $ret = null; |
|
| 131 | - } else { |
|
| 132 | - $ret =& $obj_array[0]; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - return $ret; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * retrieve objects from the database |
|
| 140 | - * |
|
| 141 | - * @param null|CriteriaElement $criteria {@link CriteriaElement} conditions to be met |
|
| 142 | - * @param bool $id_as_key use the ID as key for the array? |
|
| 143 | - * @param bool $as_object return an array of objects? |
|
| 144 | - * |
|
| 145 | - * @return array |
|
| 146 | - */ |
|
| 147 | - public function &getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) |
|
| 148 | - { |
|
| 149 | - $ret = array(); |
|
| 150 | - $limit = $start = 0; |
|
| 151 | - $sql = 'SELECT * FROM ' . $this->table; |
|
| 152 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 153 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 154 | - if ($criteria->getSort() != '') { |
|
| 155 | - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 156 | - } |
|
| 157 | - $limit = $criteria->getLimit(); |
|
| 158 | - $start = $criteria->getStart(); |
|
| 159 | - } |
|
| 160 | - $result = $this->db->query($sql, $limit, $start); |
|
| 161 | - if (!$result) { |
|
| 162 | - return $ret; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $ret = $this->convertResultSet($result, $id_as_key, $as_object); |
|
| 166 | - |
|
| 167 | - return $ret; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Convert a database resultset to a returnable array |
|
| 172 | - * |
|
| 173 | - * @param object $result database resultset |
|
| 174 | - * @param bool $id_as_key - should NOT be used with joint keys |
|
| 175 | - * @param bool $as_object |
|
| 176 | - * |
|
| 177 | - * @return array |
|
| 178 | - */ |
|
| 179 | - public function convertResultSet($result, $id_as_key = false, $as_object = true) |
|
| 180 | - { |
|
| 181 | - $ret = array(); |
|
| 182 | - while ($myrow = $this->db->fetchArray($result)) { |
|
| 183 | - $obj = $this->create(false); |
|
| 184 | - $obj->assignVars($myrow); |
|
| 185 | - if (!$id_as_key) { |
|
| 186 | - if ($as_object) { |
|
| 187 | - $ret[] =& $obj; |
|
| 188 | - } else { |
|
| 189 | - $row = array(); |
|
| 190 | - $vars = $obj->getVars(); |
|
| 191 | - $tbl_tmp = array_keys($vars); |
|
| 192 | - foreach ($tbl_tmp as $i) { |
|
| 193 | - $row[$i] = $obj->getVar($i); |
|
| 194 | - } |
|
| 195 | - $ret[] = $row; |
|
| 196 | - } |
|
| 197 | - } else { |
|
| 198 | - if ($as_object) { |
|
| 199 | - $ret[$myrow[$this->keyName]] =& $obj; |
|
| 200 | - } else { |
|
| 201 | - $row = array(); |
|
| 202 | - $vars = $obj->getVars(); |
|
| 203 | - $tbl_tmp = array_keys($vars); |
|
| 204 | - foreach ($tbl_tmp as $i) { |
|
| 205 | - $row[$i] = $obj->getVar($i); |
|
| 206 | - } |
|
| 207 | - $ret[$myrow[$this->keyName]] = $row; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - unset($obj); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return $ret; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * get IDs of objects matching a condition |
|
| 218 | - * |
|
| 219 | - * @param object $criteria {@link CriteriaElement} to match |
|
| 220 | - * @return array of object IDs |
|
| 221 | - */ |
|
| 222 | - public function getIds($criteria = null) |
|
| 223 | - { |
|
| 224 | - $sql = 'SELECT ' . $this->keyName . ' FROM ' . $this->table; |
|
| 225 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 226 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 227 | - } |
|
| 228 | - $result = $this->db->query($sql); |
|
| 229 | - $ret = array(); |
|
| 230 | - while ($myrow = $this->db->fetchArray($result)) { |
|
| 231 | - $ret[] = $myrow[$this->keyName]; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $ret; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS |
|
| 239 | - * |
|
| 240 | - * @param object $criteria {@link CriteriaElement} conditions to be met |
|
| 241 | - * @param int $limit Max number of objects to fetch |
|
| 242 | - * @param int $start Which record to start at |
|
| 243 | - * |
|
| 244 | - * @return array |
|
| 245 | - */ |
|
| 246 | - public function getList($criteria = null, $limit = 0, $start = 0) |
|
| 247 | - { |
|
| 248 | - $ret = array(); |
|
| 249 | - if ($criteria == null) { |
|
| 250 | - $criteria = new CriteriaCompo(); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if ($criteria->getSort() == '') { |
|
| 254 | - $criteria->setSort($this->identifierName); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - $sql = 'SELECT ' . $this->keyName; |
|
| 258 | - if (!empty($this->identifierName)) { |
|
| 259 | - $sql .= ', ' . $this->identifierName; |
|
| 260 | - } |
|
| 261 | - $sql .= ' FROM ' . $this->table; |
|
| 262 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 263 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 264 | - if ($criteria->getSort() != '') { |
|
| 265 | - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 266 | - } |
|
| 267 | - $limit = $criteria->getLimit(); |
|
| 268 | - $start = $criteria->getStart(); |
|
| 269 | - } |
|
| 270 | - $result = $this->db->query($sql, $limit, $start); |
|
| 271 | - if (!$result) { |
|
| 272 | - return $ret; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $myts = MyTextSanitizer::getInstance(); |
|
| 276 | - while ($myrow = $this->db->fetchArray($result)) { |
|
| 277 | - //identifiers should be textboxes, so sanitize them like that |
|
| 278 | - $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->htmlSpecialChars($myrow[$this->identifierName]); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - return $ret; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * count objects matching a condition |
|
| 286 | - * |
|
| 287 | - * @param object $criteria {@link CriteriaElement} to match |
|
| 288 | - * @return int count of objects |
|
| 289 | - */ |
|
| 290 | - public function getCount($criteria = null) |
|
| 291 | - { |
|
| 292 | - $field = ''; |
|
| 293 | - $groupby = false; |
|
| 294 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 295 | - if ($criteria->groupby != '') { |
|
| 296 | - $groupby = true; |
|
| 297 | - $field = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table; |
|
| 301 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 302 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 303 | - if ($criteria->groupby != '') { |
|
| 304 | - $sql .= $criteria->getGroupby(); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - $result = $this->db->query($sql); |
|
| 308 | - if (!$result) { |
|
| 309 | - return 0; |
|
| 310 | - } |
|
| 311 | - if ($groupby == false) { |
|
| 312 | - list($count) = $this->db->fetchRow($result); |
|
| 313 | - |
|
| 314 | - return $count; |
|
| 315 | - } else { |
|
| 316 | - $ret = array(); |
|
| 317 | - while (list($id, $count) = $this->db->fetchRow($result)) { |
|
| 318 | - $ret[$id] = $count; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return $ret; |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * delete an object from the database |
|
| 327 | - * |
|
| 328 | - * @param XoopsObject $obj reference to the object to delete |
|
| 329 | - * @param bool $force |
|
| 330 | - * @return bool FALSE if failed. |
|
| 331 | - */ |
|
| 332 | - public function delete(XoopsObject $obj, $force = false) |
|
| 333 | - { |
|
| 334 | - if (is_array($this->keyName)) { |
|
| 335 | - $clause = array(); |
|
| 336 | - $vnb = count($this->keyName); |
|
| 337 | - for ($i = 0; $i < $vnb; ++$i) { |
|
| 338 | - $clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 339 | - } |
|
| 340 | - $whereclause = implode(' AND ', $clause); |
|
| 341 | - } else { |
|
| 342 | - $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 343 | - } |
|
| 344 | - $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause; |
|
| 345 | - if (false != $force) { |
|
| 346 | - $result = $this->db->queryF($sql); |
|
| 347 | - } else { |
|
| 348 | - $result = $this->db->query($sql); |
|
| 349 | - } |
|
| 350 | - if (!$result) { |
|
| 351 | - return false; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - return true; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Quickly insert a record like this $myobject_handler->quickInsert('field1' => field1value, 'field2' => $field2value) |
|
| 359 | - * |
|
| 360 | - * @param array $vars Array containing the fields name and value |
|
| 361 | - * @param bool $force whether to force the query execution despite security settings |
|
| 362 | - * @return bool @link insert's value |
|
| 363 | - */ |
|
| 364 | - public function quickInsert($vars = null, $force = false) |
|
| 365 | - { |
|
| 366 | - $object = $this->create(true); |
|
| 367 | - $object->setVars($vars); |
|
| 368 | - $retval = $this->insert($object, $force); |
|
| 369 | - unset($object); |
|
| 370 | - |
|
| 371 | - return $retval; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * insert a new object in the database |
|
| 376 | - * |
|
| 377 | - * @param XoopsObject $obj reference to the object |
|
| 378 | - * @param bool $force whether to force the query execution despite security settings |
|
| 379 | - * @param bool $checkObject check if the object is dirty and clean the attributes |
|
| 380 | - * @return bool FALSE if failed, TRUE if already present and unchanged or successful |
|
| 381 | - */ |
|
| 382 | - |
|
| 383 | - public function insert(XoopsObject $obj, $force = false, $checkObject = true) |
|
| 384 | - { |
|
| 385 | - if ($checkObject != false) { |
|
| 386 | - if (!is_object($obj)) { |
|
| 387 | - echo '<br><h1>Error, not object</h1>'; |
|
| 388 | - |
|
| 389 | - return false; |
|
| 390 | - } |
|
| 391 | - /** |
|
| 392 | - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 |
|
| 393 | - */ |
|
| 63 | + public $table; |
|
| 64 | + protected $keyName; |
|
| 65 | + protected $className; |
|
| 66 | + protected $identifierName; |
|
| 67 | + protected $cacheOptions = array(); |
|
| 68 | + /**#@-*/ |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Constructor - called from child classes |
|
| 72 | + * |
|
| 73 | + * @param object $db {@link XoopsDatabase} object |
|
| 74 | + * @param string $tablename Name of database table |
|
| 75 | + * @param string $classname Name of Class, this handler is managing |
|
| 76 | + * @param string $keyname Name of the property, holding the key |
|
| 77 | + * |
|
| 78 | + * @param bool $idenfierName |
|
| 79 | + * |
|
| 80 | + */ |
|
| 81 | + public function __construct($db, $tablename, $classname, $keyname, $idenfierName = false) |
|
| 82 | + { |
|
| 83 | + parent::__construct($db); |
|
| 84 | + $this->table = $db->prefix($tablename); |
|
| 85 | + $this->keyName = $keyname; |
|
| 86 | + $this->className = $classname; |
|
| 87 | + if ($idenfierName != false) { |
|
| 88 | + $this->identifierName = $idenfierName; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * create a new object |
|
| 94 | + * |
|
| 95 | + * @param bool $isNew Flag the new objects as "new"? |
|
| 96 | + * |
|
| 97 | + * @return object |
|
| 98 | + */ |
|
| 99 | + public function create($isNew = true) |
|
| 100 | + { |
|
| 101 | + $obj = new $this->className(); |
|
| 102 | + if ($isNew === true) { |
|
| 103 | + $obj->setNew(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $obj; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * retrieve an object |
|
| 111 | + * |
|
| 112 | + * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor |
|
| 113 | + * @param bool $as_object whether to return an object or an array |
|
| 114 | + * @return mixed reference to the object, FALSE if failed |
|
| 115 | + */ |
|
| 116 | + public function &get($id, $as_object = true) |
|
| 117 | + { |
|
| 118 | + if (is_array($this->keyName)) { |
|
| 119 | + $criteria = new CriteriaCompo(); |
|
| 120 | + $vnb = count($this->keyName); |
|
| 121 | + for ($i = 0; $i < $vnb; ++$i) { |
|
| 122 | + $criteria->add(new Criteria($this->keyName[$i], (int)$id[$i])); |
|
| 123 | + } |
|
| 124 | + } else { |
|
| 125 | + $criteria = new Criteria($this->keyName, (int)$id); |
|
| 126 | + } |
|
| 127 | + $criteria->setLimit(1); |
|
| 128 | + $obj_array =& $this->getObjects($criteria, false, $as_object); |
|
| 129 | + if (count($obj_array) != 1) { |
|
| 130 | + $ret = null; |
|
| 131 | + } else { |
|
| 132 | + $ret =& $obj_array[0]; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + return $ret; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * retrieve objects from the database |
|
| 140 | + * |
|
| 141 | + * @param null|CriteriaElement $criteria {@link CriteriaElement} conditions to be met |
|
| 142 | + * @param bool $id_as_key use the ID as key for the array? |
|
| 143 | + * @param bool $as_object return an array of objects? |
|
| 144 | + * |
|
| 145 | + * @return array |
|
| 146 | + */ |
|
| 147 | + public function &getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) |
|
| 148 | + { |
|
| 149 | + $ret = array(); |
|
| 150 | + $limit = $start = 0; |
|
| 151 | + $sql = 'SELECT * FROM ' . $this->table; |
|
| 152 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 153 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 154 | + if ($criteria->getSort() != '') { |
|
| 155 | + $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 156 | + } |
|
| 157 | + $limit = $criteria->getLimit(); |
|
| 158 | + $start = $criteria->getStart(); |
|
| 159 | + } |
|
| 160 | + $result = $this->db->query($sql, $limit, $start); |
|
| 161 | + if (!$result) { |
|
| 162 | + return $ret; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $ret = $this->convertResultSet($result, $id_as_key, $as_object); |
|
| 166 | + |
|
| 167 | + return $ret; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Convert a database resultset to a returnable array |
|
| 172 | + * |
|
| 173 | + * @param object $result database resultset |
|
| 174 | + * @param bool $id_as_key - should NOT be used with joint keys |
|
| 175 | + * @param bool $as_object |
|
| 176 | + * |
|
| 177 | + * @return array |
|
| 178 | + */ |
|
| 179 | + public function convertResultSet($result, $id_as_key = false, $as_object = true) |
|
| 180 | + { |
|
| 181 | + $ret = array(); |
|
| 182 | + while ($myrow = $this->db->fetchArray($result)) { |
|
| 183 | + $obj = $this->create(false); |
|
| 184 | + $obj->assignVars($myrow); |
|
| 185 | + if (!$id_as_key) { |
|
| 186 | + if ($as_object) { |
|
| 187 | + $ret[] =& $obj; |
|
| 188 | + } else { |
|
| 189 | + $row = array(); |
|
| 190 | + $vars = $obj->getVars(); |
|
| 191 | + $tbl_tmp = array_keys($vars); |
|
| 192 | + foreach ($tbl_tmp as $i) { |
|
| 193 | + $row[$i] = $obj->getVar($i); |
|
| 194 | + } |
|
| 195 | + $ret[] = $row; |
|
| 196 | + } |
|
| 197 | + } else { |
|
| 198 | + if ($as_object) { |
|
| 199 | + $ret[$myrow[$this->keyName]] =& $obj; |
|
| 200 | + } else { |
|
| 201 | + $row = array(); |
|
| 202 | + $vars = $obj->getVars(); |
|
| 203 | + $tbl_tmp = array_keys($vars); |
|
| 204 | + foreach ($tbl_tmp as $i) { |
|
| 205 | + $row[$i] = $obj->getVar($i); |
|
| 206 | + } |
|
| 207 | + $ret[$myrow[$this->keyName]] = $row; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + unset($obj); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return $ret; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * get IDs of objects matching a condition |
|
| 218 | + * |
|
| 219 | + * @param object $criteria {@link CriteriaElement} to match |
|
| 220 | + * @return array of object IDs |
|
| 221 | + */ |
|
| 222 | + public function getIds($criteria = null) |
|
| 223 | + { |
|
| 224 | + $sql = 'SELECT ' . $this->keyName . ' FROM ' . $this->table; |
|
| 225 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 226 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 227 | + } |
|
| 228 | + $result = $this->db->query($sql); |
|
| 229 | + $ret = array(); |
|
| 230 | + while ($myrow = $this->db->fetchArray($result)) { |
|
| 231 | + $ret[] = $myrow[$this->keyName]; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return $ret; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS |
|
| 239 | + * |
|
| 240 | + * @param object $criteria {@link CriteriaElement} conditions to be met |
|
| 241 | + * @param int $limit Max number of objects to fetch |
|
| 242 | + * @param int $start Which record to start at |
|
| 243 | + * |
|
| 244 | + * @return array |
|
| 245 | + */ |
|
| 246 | + public function getList($criteria = null, $limit = 0, $start = 0) |
|
| 247 | + { |
|
| 248 | + $ret = array(); |
|
| 249 | + if ($criteria == null) { |
|
| 250 | + $criteria = new CriteriaCompo(); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if ($criteria->getSort() == '') { |
|
| 254 | + $criteria->setSort($this->identifierName); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + $sql = 'SELECT ' . $this->keyName; |
|
| 258 | + if (!empty($this->identifierName)) { |
|
| 259 | + $sql .= ', ' . $this->identifierName; |
|
| 260 | + } |
|
| 261 | + $sql .= ' FROM ' . $this->table; |
|
| 262 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 263 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 264 | + if ($criteria->getSort() != '') { |
|
| 265 | + $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 266 | + } |
|
| 267 | + $limit = $criteria->getLimit(); |
|
| 268 | + $start = $criteria->getStart(); |
|
| 269 | + } |
|
| 270 | + $result = $this->db->query($sql, $limit, $start); |
|
| 271 | + if (!$result) { |
|
| 272 | + return $ret; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $myts = MyTextSanitizer::getInstance(); |
|
| 276 | + while ($myrow = $this->db->fetchArray($result)) { |
|
| 277 | + //identifiers should be textboxes, so sanitize them like that |
|
| 278 | + $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->htmlSpecialChars($myrow[$this->identifierName]); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + return $ret; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * count objects matching a condition |
|
| 286 | + * |
|
| 287 | + * @param object $criteria {@link CriteriaElement} to match |
|
| 288 | + * @return int count of objects |
|
| 289 | + */ |
|
| 290 | + public function getCount($criteria = null) |
|
| 291 | + { |
|
| 292 | + $field = ''; |
|
| 293 | + $groupby = false; |
|
| 294 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 295 | + if ($criteria->groupby != '') { |
|
| 296 | + $groupby = true; |
|
| 297 | + $field = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table; |
|
| 301 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 302 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 303 | + if ($criteria->groupby != '') { |
|
| 304 | + $sql .= $criteria->getGroupby(); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + $result = $this->db->query($sql); |
|
| 308 | + if (!$result) { |
|
| 309 | + return 0; |
|
| 310 | + } |
|
| 311 | + if ($groupby == false) { |
|
| 312 | + list($count) = $this->db->fetchRow($result); |
|
| 313 | + |
|
| 314 | + return $count; |
|
| 315 | + } else { |
|
| 316 | + $ret = array(); |
|
| 317 | + while (list($id, $count) = $this->db->fetchRow($result)) { |
|
| 318 | + $ret[$id] = $count; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return $ret; |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * delete an object from the database |
|
| 327 | + * |
|
| 328 | + * @param XoopsObject $obj reference to the object to delete |
|
| 329 | + * @param bool $force |
|
| 330 | + * @return bool FALSE if failed. |
|
| 331 | + */ |
|
| 332 | + public function delete(XoopsObject $obj, $force = false) |
|
| 333 | + { |
|
| 334 | + if (is_array($this->keyName)) { |
|
| 335 | + $clause = array(); |
|
| 336 | + $vnb = count($this->keyName); |
|
| 337 | + for ($i = 0; $i < $vnb; ++$i) { |
|
| 338 | + $clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 339 | + } |
|
| 340 | + $whereclause = implode(' AND ', $clause); |
|
| 341 | + } else { |
|
| 342 | + $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 343 | + } |
|
| 344 | + $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause; |
|
| 345 | + if (false != $force) { |
|
| 346 | + $result = $this->db->queryF($sql); |
|
| 347 | + } else { |
|
| 348 | + $result = $this->db->query($sql); |
|
| 349 | + } |
|
| 350 | + if (!$result) { |
|
| 351 | + return false; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + return true; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Quickly insert a record like this $myobject_handler->quickInsert('field1' => field1value, 'field2' => $field2value) |
|
| 359 | + * |
|
| 360 | + * @param array $vars Array containing the fields name and value |
|
| 361 | + * @param bool $force whether to force the query execution despite security settings |
|
| 362 | + * @return bool @link insert's value |
|
| 363 | + */ |
|
| 364 | + public function quickInsert($vars = null, $force = false) |
|
| 365 | + { |
|
| 366 | + $object = $this->create(true); |
|
| 367 | + $object->setVars($vars); |
|
| 368 | + $retval = $this->insert($object, $force); |
|
| 369 | + unset($object); |
|
| 370 | + |
|
| 371 | + return $retval; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * insert a new object in the database |
|
| 376 | + * |
|
| 377 | + * @param XoopsObject $obj reference to the object |
|
| 378 | + * @param bool $force whether to force the query execution despite security settings |
|
| 379 | + * @param bool $checkObject check if the object is dirty and clean the attributes |
|
| 380 | + * @return bool FALSE if failed, TRUE if already present and unchanged or successful |
|
| 381 | + */ |
|
| 382 | + |
|
| 383 | + public function insert(XoopsObject $obj, $force = false, $checkObject = true) |
|
| 384 | + { |
|
| 385 | + if ($checkObject != false) { |
|
| 386 | + if (!is_object($obj)) { |
|
| 387 | + echo '<br><h1>Error, not object</h1>'; |
|
| 388 | + |
|
| 389 | + return false; |
|
| 390 | + } |
|
| 391 | + /** |
|
| 392 | + * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 |
|
| 393 | + */ |
|
| 394 | 394 | // if (!is_a($obj, $this->className)) { |
| 395 | 395 | // $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); |
| 396 | 396 | |
| 397 | - if (!(class_exists($this->className) && $obj instanceof $this->className)) { |
|
| 398 | - $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); |
|
| 399 | - |
|
| 400 | - return false; |
|
| 401 | - } |
|
| 402 | - if (!$obj->isDirty()) { |
|
| 403 | - $obj->setErrors('Not dirty'); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith |
|
| 404 | - |
|
| 405 | - return true; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - if (!$obj->cleanVars()) { |
|
| 409 | - foreach ($obj->getErrors() as $oneerror) { |
|
| 410 | - echo '<br><h2>' . $oneerror . '</h2>'; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - return false; |
|
| 414 | - } |
|
| 415 | - foreach ($obj->cleanVars as $k => $v) { |
|
| 416 | - if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) { |
|
| 417 | - $cleanvars[$k] = (int)$v; |
|
| 418 | - } elseif (is_array($v)) { |
|
| 419 | - $cleanvars[$k] = $this->db->quoteString(implode(',', $v)); |
|
| 420 | - } else { |
|
| 421 | - $cleanvars[$k] = $this->db->quoteString($v); |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - if (isset($cleanvars['dohtml'])) { // Modification Herv� to be able to use dohtml |
|
| 425 | - unset($cleanvars['dohtml']); |
|
| 426 | - } |
|
| 427 | - if ($obj->isNew()) { |
|
| 428 | - if (!is_array($this->keyName)) { |
|
| 429 | - if ($cleanvars[$this->keyName] < 1) { |
|
| 430 | - $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq'); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($cleanvars)) . ') VALUES (' . implode(',', array_values($cleanvars)) . ')'; |
|
| 434 | - } else { |
|
| 435 | - $sql = 'UPDATE ' . $this->table . ' SET'; |
|
| 436 | - foreach ($cleanvars as $key => $value) { |
|
| 437 | - if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) { |
|
| 438 | - continue; |
|
| 439 | - } |
|
| 440 | - if (isset($notfirst)) { |
|
| 441 | - $sql .= ','; |
|
| 442 | - } |
|
| 443 | - $sql .= ' ' . $key . ' = ' . $value; |
|
| 444 | - $notfirst = true; |
|
| 445 | - } |
|
| 446 | - if (is_array($this->keyName)) { |
|
| 447 | - $whereclause = ''; |
|
| 448 | - $vnb = count($this->keyName); |
|
| 449 | - for ($i = 0; $i < $vnb; ++$i) { |
|
| 450 | - if ($i > 0) { |
|
| 451 | - $whereclause .= ' AND '; |
|
| 452 | - } |
|
| 453 | - $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 454 | - } |
|
| 455 | - } else { |
|
| 456 | - $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 457 | - } |
|
| 458 | - $sql .= ' WHERE ' . $whereclause; |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - if (false != $force) { |
|
| 462 | - $result = $this->db->queryF($sql); |
|
| 463 | - } else { |
|
| 464 | - $result = $this->db->query($sql); |
|
| 465 | - } |
|
| 466 | - if (!$result) { |
|
| 467 | - return false; |
|
| 468 | - } |
|
| 469 | - if ($obj->isNew() && !is_array($this->keyName)) { |
|
| 470 | - $obj->assignVar($this->keyName, $this->db->getInsertId()); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - return true; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Change a value for objects with a certain criteria |
|
| 478 | - * |
|
| 479 | - * @param string $fieldname Name of the field |
|
| 480 | - * @param string $fieldvalue Value to write |
|
| 481 | - * @param object $criteria {@link CriteriaElement} |
|
| 482 | - * |
|
| 483 | - * @param bool $force |
|
| 484 | - * |
|
| 485 | - * @return bool |
|
| 486 | - */ |
|
| 487 | - public function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false) |
|
| 488 | - { |
|
| 489 | - $set_clause = $fieldname . ' = '; |
|
| 490 | - if (is_numeric($fieldvalue)) { |
|
| 491 | - $set_clause .= $fieldvalue; |
|
| 492 | - } elseif (is_array($fieldvalue)) { |
|
| 493 | - $set_clause .= $this->db->quoteString(implode(',', $fieldvalue)); |
|
| 494 | - } else { |
|
| 495 | - $set_clause .= $this->db->quoteString($fieldvalue); |
|
| 496 | - } |
|
| 497 | - $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause; |
|
| 498 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 499 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 500 | - } |
|
| 501 | - if (false != $force) { |
|
| 502 | - $result = $this->db->queryF($sql); |
|
| 503 | - } else { |
|
| 504 | - $result = $this->db->query($sql); |
|
| 505 | - } |
|
| 506 | - if (!$result) { |
|
| 507 | - return false; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - return true; |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * delete all objects meeting the conditions |
|
| 515 | - * |
|
| 516 | - * @param object $criteria {@link CriteriaElement} with conditions to meet |
|
| 517 | - * @return bool |
|
| 518 | - */ |
|
| 519 | - |
|
| 520 | - public function deleteAll($criteria = null) |
|
| 521 | - { |
|
| 522 | - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 523 | - $sql = 'DELETE FROM ' . $this->table; |
|
| 524 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 525 | - if (!$this->db->queryF($sql)) { |
|
| 526 | - return false; |
|
| 527 | - } |
|
| 528 | - $rows = $this->db->getAffectedRows(); |
|
| 529 | - |
|
| 530 | - return $rows > 0 ? $rows : true; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - return false; |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * Compare two objects and returns, in an array, the differences |
|
| 538 | - * |
|
| 539 | - * @param XoopsObject $old_object The first object to compare |
|
| 540 | - * @param XoopsObject $new_object The new object |
|
| 541 | - * @return array differences key = fieldname, value = array('old_value', 'new_value') |
|
| 542 | - */ |
|
| 543 | - public function compareObjects($old_object, $new_object) |
|
| 544 | - { |
|
| 545 | - $ret = array(); |
|
| 546 | - $vars_name = array_keys($old_object->getVars()); |
|
| 547 | - foreach ($vars_name as $one_var) { |
|
| 548 | - if ($old_object->getVar($one_var, 'f') == $new_object->getVar($one_var, 'f')) { |
|
| 549 | - } else { |
|
| 550 | - $ret[$one_var] = array($old_object->getVar($one_var), $new_object->getVar($one_var)); |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - return $ret; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * Get distincted values of a field in the table |
|
| 559 | - * |
|
| 560 | - * @param string $field Field's name |
|
| 561 | - * @param string $format Format in wich we want the datas |
|
| 562 | - * @return array containing the distinct values |
|
| 563 | - */ |
|
| 564 | - public function getDistincts($field, $format = 's') |
|
| 565 | - { |
|
| 566 | - $sql = 'SELECT ' . $this->keyName . ', ' . $field . ' FROM ' . $this->table . ' GROUP BY ' . $field . ' ORDER BY ' . $field; |
|
| 567 | - $result = $this->db->query($sql); |
|
| 568 | - $ret = array(); |
|
| 569 | - $obj = new $this->className(); |
|
| 570 | - while ($myrow = $this->db->fetchArray($result)) { |
|
| 571 | - $obj->setVar($field, $myrow[$field]); |
|
| 572 | - $ret[$myrow[$this->keyName]] = $obj->getVar($field, $format); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - return $ret; |
|
| 576 | - } |
|
| 397 | + if (!(class_exists($this->className) && $obj instanceof $this->className)) { |
|
| 398 | + $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); |
|
| 399 | + |
|
| 400 | + return false; |
|
| 401 | + } |
|
| 402 | + if (!$obj->isDirty()) { |
|
| 403 | + $obj->setErrors('Not dirty'); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith |
|
| 404 | + |
|
| 405 | + return true; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + if (!$obj->cleanVars()) { |
|
| 409 | + foreach ($obj->getErrors() as $oneerror) { |
|
| 410 | + echo '<br><h2>' . $oneerror . '</h2>'; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + return false; |
|
| 414 | + } |
|
| 415 | + foreach ($obj->cleanVars as $k => $v) { |
|
| 416 | + if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) { |
|
| 417 | + $cleanvars[$k] = (int)$v; |
|
| 418 | + } elseif (is_array($v)) { |
|
| 419 | + $cleanvars[$k] = $this->db->quoteString(implode(',', $v)); |
|
| 420 | + } else { |
|
| 421 | + $cleanvars[$k] = $this->db->quoteString($v); |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + if (isset($cleanvars['dohtml'])) { // Modification Herv� to be able to use dohtml |
|
| 425 | + unset($cleanvars['dohtml']); |
|
| 426 | + } |
|
| 427 | + if ($obj->isNew()) { |
|
| 428 | + if (!is_array($this->keyName)) { |
|
| 429 | + if ($cleanvars[$this->keyName] < 1) { |
|
| 430 | + $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq'); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($cleanvars)) . ') VALUES (' . implode(',', array_values($cleanvars)) . ')'; |
|
| 434 | + } else { |
|
| 435 | + $sql = 'UPDATE ' . $this->table . ' SET'; |
|
| 436 | + foreach ($cleanvars as $key => $value) { |
|
| 437 | + if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) { |
|
| 438 | + continue; |
|
| 439 | + } |
|
| 440 | + if (isset($notfirst)) { |
|
| 441 | + $sql .= ','; |
|
| 442 | + } |
|
| 443 | + $sql .= ' ' . $key . ' = ' . $value; |
|
| 444 | + $notfirst = true; |
|
| 445 | + } |
|
| 446 | + if (is_array($this->keyName)) { |
|
| 447 | + $whereclause = ''; |
|
| 448 | + $vnb = count($this->keyName); |
|
| 449 | + for ($i = 0; $i < $vnb; ++$i) { |
|
| 450 | + if ($i > 0) { |
|
| 451 | + $whereclause .= ' AND '; |
|
| 452 | + } |
|
| 453 | + $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 454 | + } |
|
| 455 | + } else { |
|
| 456 | + $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 457 | + } |
|
| 458 | + $sql .= ' WHERE ' . $whereclause; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if (false != $force) { |
|
| 462 | + $result = $this->db->queryF($sql); |
|
| 463 | + } else { |
|
| 464 | + $result = $this->db->query($sql); |
|
| 465 | + } |
|
| 466 | + if (!$result) { |
|
| 467 | + return false; |
|
| 468 | + } |
|
| 469 | + if ($obj->isNew() && !is_array($this->keyName)) { |
|
| 470 | + $obj->assignVar($this->keyName, $this->db->getInsertId()); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + return true; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Change a value for objects with a certain criteria |
|
| 478 | + * |
|
| 479 | + * @param string $fieldname Name of the field |
|
| 480 | + * @param string $fieldvalue Value to write |
|
| 481 | + * @param object $criteria {@link CriteriaElement} |
|
| 482 | + * |
|
| 483 | + * @param bool $force |
|
| 484 | + * |
|
| 485 | + * @return bool |
|
| 486 | + */ |
|
| 487 | + public function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false) |
|
| 488 | + { |
|
| 489 | + $set_clause = $fieldname . ' = '; |
|
| 490 | + if (is_numeric($fieldvalue)) { |
|
| 491 | + $set_clause .= $fieldvalue; |
|
| 492 | + } elseif (is_array($fieldvalue)) { |
|
| 493 | + $set_clause .= $this->db->quoteString(implode(',', $fieldvalue)); |
|
| 494 | + } else { |
|
| 495 | + $set_clause .= $this->db->quoteString($fieldvalue); |
|
| 496 | + } |
|
| 497 | + $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause; |
|
| 498 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 499 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 500 | + } |
|
| 501 | + if (false != $force) { |
|
| 502 | + $result = $this->db->queryF($sql); |
|
| 503 | + } else { |
|
| 504 | + $result = $this->db->query($sql); |
|
| 505 | + } |
|
| 506 | + if (!$result) { |
|
| 507 | + return false; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + return true; |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + /** |
|
| 514 | + * delete all objects meeting the conditions |
|
| 515 | + * |
|
| 516 | + * @param object $criteria {@link CriteriaElement} with conditions to meet |
|
| 517 | + * @return bool |
|
| 518 | + */ |
|
| 519 | + |
|
| 520 | + public function deleteAll($criteria = null) |
|
| 521 | + { |
|
| 522 | + if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|
| 523 | + $sql = 'DELETE FROM ' . $this->table; |
|
| 524 | + $sql .= ' ' . $criteria->renderWhere(); |
|
| 525 | + if (!$this->db->queryF($sql)) { |
|
| 526 | + return false; |
|
| 527 | + } |
|
| 528 | + $rows = $this->db->getAffectedRows(); |
|
| 529 | + |
|
| 530 | + return $rows > 0 ? $rows : true; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + return false; |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * Compare two objects and returns, in an array, the differences |
|
| 538 | + * |
|
| 539 | + * @param XoopsObject $old_object The first object to compare |
|
| 540 | + * @param XoopsObject $new_object The new object |
|
| 541 | + * @return array differences key = fieldname, value = array('old_value', 'new_value') |
|
| 542 | + */ |
|
| 543 | + public function compareObjects($old_object, $new_object) |
|
| 544 | + { |
|
| 545 | + $ret = array(); |
|
| 546 | + $vars_name = array_keys($old_object->getVars()); |
|
| 547 | + foreach ($vars_name as $one_var) { |
|
| 548 | + if ($old_object->getVar($one_var, 'f') == $new_object->getVar($one_var, 'f')) { |
|
| 549 | + } else { |
|
| 550 | + $ret[$one_var] = array($old_object->getVar($one_var), $new_object->getVar($one_var)); |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + return $ret; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * Get distincted values of a field in the table |
|
| 559 | + * |
|
| 560 | + * @param string $field Field's name |
|
| 561 | + * @param string $format Format in wich we want the datas |
|
| 562 | + * @return array containing the distinct values |
|
| 563 | + */ |
|
| 564 | + public function getDistincts($field, $format = 's') |
|
| 565 | + { |
|
| 566 | + $sql = 'SELECT ' . $this->keyName . ', ' . $field . ' FROM ' . $this->table . ' GROUP BY ' . $field . ' ORDER BY ' . $field; |
|
| 567 | + $result = $this->db->query($sql); |
|
| 568 | + $ret = array(); |
|
| 569 | + $obj = new $this->className(); |
|
| 570 | + while ($myrow = $this->db->fetchArray($result)) { |
|
| 571 | + $obj->setVar($field, $myrow[$field]); |
|
| 572 | + $ret[$myrow[$this->keyName]] = $obj->getVar($field, $format); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + return $ret; |
|
| 576 | + } |
|
| 577 | 577 | } |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | $criteria = new Criteria($this->keyName, (int)$id); |
| 126 | 126 | } |
| 127 | 127 | $criteria->setLimit(1); |
| 128 | - $obj_array =& $this->getObjects($criteria, false, $as_object); |
|
| 128 | + $obj_array = & $this->getObjects($criteria, false, $as_object); |
|
| 129 | 129 | if (count($obj_array) != 1) { |
| 130 | 130 | $ret = null; |
| 131 | 131 | } else { |
| 132 | - $ret =& $obj_array[0]; |
|
| 132 | + $ret = & $obj_array[0]; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $ret; |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $ret = array(); |
| 150 | 150 | $limit = $start = 0; |
| 151 | - $sql = 'SELECT * FROM ' . $this->table; |
|
| 151 | + $sql = 'SELECT * FROM '.$this->table; |
|
| 152 | 152 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 153 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 153 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 154 | 154 | if ($criteria->getSort() != '') { |
| 155 | - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 155 | + $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder(); |
|
| 156 | 156 | } |
| 157 | 157 | $limit = $criteria->getLimit(); |
| 158 | 158 | $start = $criteria->getStart(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $obj->assignVars($myrow); |
| 185 | 185 | if (!$id_as_key) { |
| 186 | 186 | if ($as_object) { |
| 187 | - $ret[] =& $obj; |
|
| 187 | + $ret[] = & $obj; |
|
| 188 | 188 | } else { |
| 189 | 189 | $row = array(); |
| 190 | 190 | $vars = $obj->getVars(); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | } else { |
| 198 | 198 | if ($as_object) { |
| 199 | - $ret[$myrow[$this->keyName]] =& $obj; |
|
| 199 | + $ret[$myrow[$this->keyName]] = & $obj; |
|
| 200 | 200 | } else { |
| 201 | 201 | $row = array(); |
| 202 | 202 | $vars = $obj->getVars(); |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public function getIds($criteria = null) |
| 223 | 223 | { |
| 224 | - $sql = 'SELECT ' . $this->keyName . ' FROM ' . $this->table; |
|
| 224 | + $sql = 'SELECT '.$this->keyName.' FROM '.$this->table; |
|
| 225 | 225 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 226 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 226 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 227 | 227 | } |
| 228 | 228 | $result = $this->db->query($sql); |
| 229 | 229 | $ret = array(); |
@@ -254,15 +254,15 @@ discard block |
||
| 254 | 254 | $criteria->setSort($this->identifierName); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - $sql = 'SELECT ' . $this->keyName; |
|
| 257 | + $sql = 'SELECT '.$this->keyName; |
|
| 258 | 258 | if (!empty($this->identifierName)) { |
| 259 | - $sql .= ', ' . $this->identifierName; |
|
| 259 | + $sql .= ', '.$this->identifierName; |
|
| 260 | 260 | } |
| 261 | - $sql .= ' FROM ' . $this->table; |
|
| 261 | + $sql .= ' FROM '.$this->table; |
|
| 262 | 262 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 263 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 263 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 264 | 264 | if ($criteria->getSort() != '') { |
| 265 | - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
| 265 | + $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder(); |
|
| 266 | 266 | } |
| 267 | 267 | $limit = $criteria->getLimit(); |
| 268 | 268 | $start = $criteria->getStart(); |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 295 | 295 | if ($criteria->groupby != '') { |
| 296 | 296 | $groupby = true; |
| 297 | - $field = $criteria->groupby . ', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used |
|
| 297 | + $field = $criteria->groupby.', '; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | - $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table; |
|
| 300 | + $sql = 'SELECT '.$field.'COUNT(*) FROM '.$this->table; |
|
| 301 | 301 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 302 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 302 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 303 | 303 | if ($criteria->groupby != '') { |
| 304 | 304 | $sql .= $criteria->getGroupby(); |
| 305 | 305 | } |
@@ -335,13 +335,13 @@ discard block |
||
| 335 | 335 | $clause = array(); |
| 336 | 336 | $vnb = count($this->keyName); |
| 337 | 337 | for ($i = 0; $i < $vnb; ++$i) { |
| 338 | - $clause[] = $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 338 | + $clause[] = $this->keyName[$i].' = '.$obj->getVar($this->keyName[$i]); |
|
| 339 | 339 | } |
| 340 | 340 | $whereclause = implode(' AND ', $clause); |
| 341 | 341 | } else { |
| 342 | - $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 342 | + $whereclause = $this->keyName.' = '.$obj->getVar($this->keyName); |
|
| 343 | 343 | } |
| 344 | - $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $whereclause; |
|
| 344 | + $sql = 'DELETE FROM '.$this->table.' WHERE '.$whereclause; |
|
| 345 | 345 | if (false != $force) { |
| 346 | 346 | $result = $this->db->queryF($sql); |
| 347 | 347 | } else { |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | // $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); |
| 396 | 396 | |
| 397 | 397 | if (!(class_exists($this->className) && $obj instanceof $this->className)) { |
| 398 | - $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); |
|
| 398 | + $obj->setErrors(get_class($obj).' Differs from '.$this->className); |
|
| 399 | 399 | |
| 400 | 400 | return false; |
| 401 | 401 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | if (!$obj->cleanVars()) { |
| 409 | 409 | foreach ($obj->getErrors() as $oneerror) { |
| 410 | - echo '<br><h2>' . $oneerror . '</h2>'; |
|
| 410 | + echo '<br><h2>'.$oneerror.'</h2>'; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | return false; |
@@ -427,12 +427,12 @@ discard block |
||
| 427 | 427 | if ($obj->isNew()) { |
| 428 | 428 | if (!is_array($this->keyName)) { |
| 429 | 429 | if ($cleanvars[$this->keyName] < 1) { |
| 430 | - $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq'); |
|
| 430 | + $cleanvars[$this->keyName] = $this->db->genId($this->table.'_'.$this->keyName.'_seq'); |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | - $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($cleanvars)) . ') VALUES (' . implode(',', array_values($cleanvars)) . ')'; |
|
| 433 | + $sql = 'INSERT INTO '.$this->table.' ('.implode(',', array_keys($cleanvars)).') VALUES ('.implode(',', array_values($cleanvars)).')'; |
|
| 434 | 434 | } else { |
| 435 | - $sql = 'UPDATE ' . $this->table . ' SET'; |
|
| 435 | + $sql = 'UPDATE '.$this->table.' SET'; |
|
| 436 | 436 | foreach ($cleanvars as $key => $value) { |
| 437 | 437 | if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) { |
| 438 | 438 | continue; |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | if (isset($notfirst)) { |
| 441 | 441 | $sql .= ','; |
| 442 | 442 | } |
| 443 | - $sql .= ' ' . $key . ' = ' . $value; |
|
| 443 | + $sql .= ' '.$key.' = '.$value; |
|
| 444 | 444 | $notfirst = true; |
| 445 | 445 | } |
| 446 | 446 | if (is_array($this->keyName)) { |
@@ -450,12 +450,12 @@ discard block |
||
| 450 | 450 | if ($i > 0) { |
| 451 | 451 | $whereclause .= ' AND '; |
| 452 | 452 | } |
| 453 | - $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); |
|
| 453 | + $whereclause .= $this->keyName[$i].' = '.$obj->getVar($this->keyName[$i]); |
|
| 454 | 454 | } |
| 455 | 455 | } else { |
| 456 | - $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); |
|
| 456 | + $whereclause = $this->keyName.' = '.$obj->getVar($this->keyName); |
|
| 457 | 457 | } |
| 458 | - $sql .= ' WHERE ' . $whereclause; |
|
| 458 | + $sql .= ' WHERE '.$whereclause; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | if (false != $force) { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | public function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false) |
| 488 | 488 | { |
| 489 | - $set_clause = $fieldname . ' = '; |
|
| 489 | + $set_clause = $fieldname.' = '; |
|
| 490 | 490 | if (is_numeric($fieldvalue)) { |
| 491 | 491 | $set_clause .= $fieldvalue; |
| 492 | 492 | } elseif (is_array($fieldvalue)) { |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | } else { |
| 495 | 495 | $set_clause .= $this->db->quoteString($fieldvalue); |
| 496 | 496 | } |
| 497 | - $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause; |
|
| 497 | + $sql = 'UPDATE '.$this->table.' SET '.$set_clause; |
|
| 498 | 498 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 499 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 499 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 500 | 500 | } |
| 501 | 501 | if (false != $force) { |
| 502 | 502 | $result = $this->db->queryF($sql); |
@@ -520,8 +520,8 @@ discard block |
||
| 520 | 520 | public function deleteAll($criteria = null) |
| 521 | 521 | { |
| 522 | 522 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
| 523 | - $sql = 'DELETE FROM ' . $this->table; |
|
| 524 | - $sql .= ' ' . $criteria->renderWhere(); |
|
| 523 | + $sql = 'DELETE FROM '.$this->table; |
|
| 524 | + $sql .= ' '.$criteria->renderWhere(); |
|
| 525 | 525 | if (!$this->db->queryF($sql)) { |
| 526 | 526 | return false; |
| 527 | 527 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | */ |
| 564 | 564 | public function getDistincts($field, $format = 's') |
| 565 | 565 | { |
| 566 | - $sql = 'SELECT ' . $this->keyName . ', ' . $field . ' FROM ' . $this->table . ' GROUP BY ' . $field . ' ORDER BY ' . $field; |
|
| 566 | + $sql = 'SELECT '.$this->keyName.', '.$field.' FROM '.$this->table.' GROUP BY '.$field.' ORDER BY '.$field; |
|
| 567 | 567 | $result = $this->db->query($sql); |
| 568 | 568 | $ret = array(); |
| 569 | 569 | $obj = new $this->className(); |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | /** |
| 53 | 53 | * @param null $fichier |
| 54 | 54 | * |
| 55 | - * @return bool|string |
|
| 55 | + * @return string |
|
| 56 | 56 | */ |
| 57 | 57 | public function getfile($fichier = null) |
| 58 | 58 | { |
@@ -29,67 +29,67 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class bookshop_registryfile |
| 31 | 31 | { |
| 32 | - public $filename; // Nom du fichier à traiter |
|
| 32 | + public $filename; // Nom du fichier à traiter |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param null $fichier |
|
| 36 | - */ |
|
| 37 | - public function __construct($fichier = null) |
|
| 38 | - { |
|
| 39 | - $this->setfile($fichier); |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * @param null $fichier |
|
| 36 | + */ |
|
| 37 | + public function __construct($fichier = null) |
|
| 38 | + { |
|
| 39 | + $this->setfile($fichier); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param null $fichier |
|
| 44 | - */ |
|
| 45 | - public function setfile($fichier = null) |
|
| 46 | - { |
|
| 47 | - if ($fichier) { |
|
| 48 | - $this->filename = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 49 | - } |
|
| 50 | - } |
|
| 42 | + /** |
|
| 43 | + * @param null $fichier |
|
| 44 | + */ |
|
| 45 | + public function setfile($fichier = null) |
|
| 46 | + { |
|
| 47 | + if ($fichier) { |
|
| 48 | + $this->filename = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @param null $fichier |
|
| 54 | - * |
|
| 55 | - * @return bool|string |
|
| 56 | - */ |
|
| 57 | - public function getfile($fichier = null) |
|
| 58 | - { |
|
| 59 | - $fw = ''; |
|
| 60 | - if (!$fichier) { |
|
| 61 | - $fw = $this->filename; |
|
| 62 | - } else { |
|
| 63 | - $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 64 | - } |
|
| 65 | - if (file_exists($fw)) { |
|
| 66 | - return file_get_contents($fw); |
|
| 67 | - } else { |
|
| 68 | - return ''; |
|
| 69 | - } |
|
| 70 | - } |
|
| 52 | + /** |
|
| 53 | + * @param null $fichier |
|
| 54 | + * |
|
| 55 | + * @return bool|string |
|
| 56 | + */ |
|
| 57 | + public function getfile($fichier = null) |
|
| 58 | + { |
|
| 59 | + $fw = ''; |
|
| 60 | + if (!$fichier) { |
|
| 61 | + $fw = $this->filename; |
|
| 62 | + } else { |
|
| 63 | + $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 64 | + } |
|
| 65 | + if (file_exists($fw)) { |
|
| 66 | + return file_get_contents($fw); |
|
| 67 | + } else { |
|
| 68 | + return ''; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param $content |
|
| 74 | - * @param null $fichier |
|
| 75 | - * |
|
| 76 | - * @return bool |
|
| 77 | - */ |
|
| 78 | - public function savefile($content, $fichier = null) |
|
| 79 | - { |
|
| 80 | - $fw = ''; |
|
| 81 | - if (!$fichier) { |
|
| 82 | - $fw = $this->filename; |
|
| 83 | - } else { |
|
| 84 | - $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 85 | - } |
|
| 86 | - if (file_exists($fw)) { |
|
| 87 | - @unlink($fw); |
|
| 88 | - } |
|
| 89 | - $fp = fopen($fw, 'w') || exit('Error, impossible to create the file ' . $this->filename); |
|
| 90 | - fwrite($fp, $content); |
|
| 91 | - fclose($fp); |
|
| 72 | + /** |
|
| 73 | + * @param $content |
|
| 74 | + * @param null $fichier |
|
| 75 | + * |
|
| 76 | + * @return bool |
|
| 77 | + */ |
|
| 78 | + public function savefile($content, $fichier = null) |
|
| 79 | + { |
|
| 80 | + $fw = ''; |
|
| 81 | + if (!$fichier) { |
|
| 82 | + $fw = $this->filename; |
|
| 83 | + } else { |
|
| 84 | + $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 85 | + } |
|
| 86 | + if (file_exists($fw)) { |
|
| 87 | + @unlink($fw); |
|
| 88 | + } |
|
| 89 | + $fp = fopen($fw, 'w') || exit('Error, impossible to create the file ' . $this->filename); |
|
| 90 | + fwrite($fp, $content); |
|
| 91 | + fclose($fp); |
|
| 92 | 92 | |
| 93 | - return true; |
|
| 94 | - } |
|
| 93 | + return true; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | class bookshop_registryfile |
| 31 | 31 | { |
| 32 | - public $filename; // Nom du fichier à traiter |
|
| 32 | + public $filename; // Nom du fichier à traiter |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @param null $fichier |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function setfile($fichier = null) |
| 46 | 46 | { |
| 47 | 47 | if ($fichier) { |
| 48 | - $this->filename = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 48 | + $this->filename = XOOPS_UPLOAD_PATH.'/'.$fichier; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if (!$fichier) { |
| 61 | 61 | $fw = $this->filename; |
| 62 | 62 | } else { |
| 63 | - $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 63 | + $fw = XOOPS_UPLOAD_PATH.'/'.$fichier; |
|
| 64 | 64 | } |
| 65 | 65 | if (file_exists($fw)) { |
| 66 | 66 | return file_get_contents($fw); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | if (!$fichier) { |
| 82 | 82 | $fw = $this->filename; |
| 83 | 83 | } else { |
| 84 | - $fw = XOOPS_UPLOAD_PATH . '/' . $fichier; |
|
| 84 | + $fw = XOOPS_UPLOAD_PATH.'/'.$fichier; |
|
| 85 | 85 | } |
| 86 | 86 | if (file_exists($fw)) { |
| 87 | 87 | @unlink($fw); |
| 88 | 88 | } |
| 89 | - $fp = fopen($fw, 'w') || exit('Error, impossible to create the file ' . $this->filename); |
|
| 89 | + $fp = fopen($fw, 'w') || exit('Error, impossible to create the file '.$this->filename); |
|
| 90 | 90 | fwrite($fp, $content); |
| 91 | 91 | fclose($fp); |
| 92 | 92 | |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | * Calcul de la réduction |
| 529 | 529 | * |
| 530 | 530 | * @param float $price Le montant dont on veut calculer la réduction |
| 531 | - * @param integer $dicount Le montant de la rédution, par exemple 10 pour 10% |
|
| 531 | + * @param integer $discount Le montant de la rédution, par exemple 10 pour 10% |
|
| 532 | 532 | * @return float Le montant de la réduction |
| 533 | 533 | */ |
| 534 | 534 | function bookshop_getDiscountedPrice($price, $discount) |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | /** |
| 696 | 696 | * Verify that the current user is a member of the Admin group |
| 697 | 697 | * |
| 698 | - * @return booleean Admin or not |
|
| 698 | + * @return boolean Admin or not |
|
| 699 | 699 | */ |
| 700 | 700 | function bookshop_isAdmin() |
| 701 | 701 | { |
@@ -723,7 +723,6 @@ discard block |
||
| 723 | 723 | * Indique si l'utilisateur courant fait partie d'une groupe donné (avec gestion de cache) |
| 724 | 724 | * |
| 725 | 725 | * @param int $group |
| 726 | - * @param integer $groupe Groupe recherché |
|
| 727 | 726 | * @return boolean vrai si l'utilisateur fait partie du groupe, faux sinon |
| 728 | 727 | */ |
| 729 | 728 | function bookshop_isMemberOfGroup($group = 0) |
@@ -41,31 +41,31 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function bookshop_getmoduleoption($option, $repmodule = 'bookshop') |
| 43 | 43 | { |
| 44 | - global $xoopsModuleConfig, $xoopsModule; |
|
| 45 | - static $tbloptions = array(); |
|
| 46 | - if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
|
| 47 | - return $tbloptions[$option]; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $retval = false; |
|
| 51 | - if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { |
|
| 52 | - if (isset($xoopsModuleConfig[$option])) { |
|
| 53 | - $retval = $xoopsModuleConfig[$option]; |
|
| 54 | - } |
|
| 55 | - } else { |
|
| 56 | - $module_handler = xoops_getHandler('module'); |
|
| 57 | - $module =& $module_handler->getByDirname($repmodule); |
|
| 58 | - $config_handler = xoops_getHandler('config'); |
|
| 59 | - if ($module) { |
|
| 60 | - $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 61 | - if (isset($moduleConfig[$option])) { |
|
| 62 | - $retval = $moduleConfig[$option]; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - $tbloptions[$option] = $retval; |
|
| 67 | - |
|
| 68 | - return $retval; |
|
| 44 | + global $xoopsModuleConfig, $xoopsModule; |
|
| 45 | + static $tbloptions = array(); |
|
| 46 | + if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
|
| 47 | + return $tbloptions[$option]; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $retval = false; |
|
| 51 | + if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { |
|
| 52 | + if (isset($xoopsModuleConfig[$option])) { |
|
| 53 | + $retval = $xoopsModuleConfig[$option]; |
|
| 54 | + } |
|
| 55 | + } else { |
|
| 56 | + $module_handler = xoops_getHandler('module'); |
|
| 57 | + $module =& $module_handler->getByDirname($repmodule); |
|
| 58 | + $config_handler = xoops_getHandler('config'); |
|
| 59 | + if ($module) { |
|
| 60 | + $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 61 | + if (isset($moduleConfig[$option])) { |
|
| 62 | + $retval = $moduleConfig[$option]; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + $tbloptions[$option] = $retval; |
|
| 67 | + |
|
| 68 | + return $retval; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function bookshop_is_x22() |
| 77 | 77 | { |
| 78 | - $x22 = false; |
|
| 79 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 80 | - if (substr($xv, 2, 1) == '2') { |
|
| 81 | - $x22 = true; |
|
| 82 | - } |
|
| 78 | + $x22 = false; |
|
| 79 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 80 | + if (substr($xv, 2, 1) == '2') { |
|
| 81 | + $x22 = true; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - return $x22; |
|
| 84 | + return $x22; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -97,84 +97,84 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | function bookshop_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '') |
| 99 | 99 | { |
| 100 | - $editor = false; |
|
| 101 | - $x22 = bookshop_is_x22(); |
|
| 102 | - $editor_configs = array(); |
|
| 103 | - $editor_configs['name'] = $name; |
|
| 104 | - $editor_configs['value'] = $value; |
|
| 105 | - $editor_configs['rows'] = 35; |
|
| 106 | - $editor_configs['cols'] = 60; |
|
| 107 | - $editor_configs['width'] = $width; |
|
| 108 | - $editor_configs['height'] = $height; |
|
| 109 | - |
|
| 110 | - $editor_option = bookshop_getmoduleoption('bl_form_options'); |
|
| 111 | - |
|
| 112 | - switch (strtolower($editor_option)) { |
|
| 113 | - case 'spaw': |
|
| 114 | - if (!$x22) { |
|
| 115 | - if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) { |
|
| 116 | - include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php'); |
|
| 117 | - $editor = new XoopsFormSpaw($caption, $name, $value); |
|
| 118 | - } |
|
| 119 | - } else { |
|
| 120 | - $editor = new XoopsFormEditor($caption, 'spaw', $editor_configs); |
|
| 121 | - } |
|
| 122 | - break; |
|
| 123 | - |
|
| 124 | - case 'fck': |
|
| 125 | - if (!$x22) { |
|
| 126 | - if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) { |
|
| 127 | - include_once(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php'); |
|
| 128 | - $editor = new XoopsFormFckeditor($caption, $name, $value); |
|
| 129 | - } |
|
| 130 | - } else { |
|
| 131 | - $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs); |
|
| 132 | - } |
|
| 133 | - break; |
|
| 134 | - |
|
| 135 | - case 'htmlarea': |
|
| 136 | - if (!$x22) { |
|
| 137 | - if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) { |
|
| 138 | - include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'); |
|
| 139 | - $editor = new XoopsFormHtmlarea($caption, $name, $value); |
|
| 140 | - } |
|
| 141 | - } else { |
|
| 142 | - $editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs); |
|
| 143 | - } |
|
| 144 | - break; |
|
| 145 | - |
|
| 146 | - case 'dhtml': |
|
| 147 | - if (!$x22) { |
|
| 148 | - $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental); |
|
| 149 | - } else { |
|
| 150 | - $editor = new XoopsFormEditor($caption, 'dhtmltextarea', $editor_configs); |
|
| 151 | - } |
|
| 152 | - break; |
|
| 153 | - |
|
| 154 | - case 'textarea': |
|
| 155 | - $editor = new XoopsFormTextArea($caption, $name, $value); |
|
| 156 | - break; |
|
| 157 | - |
|
| 158 | - case 'tinyeditor': |
|
| 159 | - if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
|
| 160 | - include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
|
| 161 | - $editor = new XoopsFormTinyeditorTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => $width, 'height' => $height)); |
|
| 162 | - } |
|
| 163 | - break; |
|
| 164 | - |
|
| 165 | - case 'koivi': |
|
| 166 | - if (!$x22) { |
|
| 167 | - if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) { |
|
| 168 | - include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php'); |
|
| 169 | - $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '250px', ''); |
|
| 170 | - } |
|
| 171 | - } else { |
|
| 172 | - $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs); |
|
| 173 | - } |
|
| 174 | - break; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $editor; |
|
| 100 | + $editor = false; |
|
| 101 | + $x22 = bookshop_is_x22(); |
|
| 102 | + $editor_configs = array(); |
|
| 103 | + $editor_configs['name'] = $name; |
|
| 104 | + $editor_configs['value'] = $value; |
|
| 105 | + $editor_configs['rows'] = 35; |
|
| 106 | + $editor_configs['cols'] = 60; |
|
| 107 | + $editor_configs['width'] = $width; |
|
| 108 | + $editor_configs['height'] = $height; |
|
| 109 | + |
|
| 110 | + $editor_option = bookshop_getmoduleoption('bl_form_options'); |
|
| 111 | + |
|
| 112 | + switch (strtolower($editor_option)) { |
|
| 113 | + case 'spaw': |
|
| 114 | + if (!$x22) { |
|
| 115 | + if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) { |
|
| 116 | + include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php'); |
|
| 117 | + $editor = new XoopsFormSpaw($caption, $name, $value); |
|
| 118 | + } |
|
| 119 | + } else { |
|
| 120 | + $editor = new XoopsFormEditor($caption, 'spaw', $editor_configs); |
|
| 121 | + } |
|
| 122 | + break; |
|
| 123 | + |
|
| 124 | + case 'fck': |
|
| 125 | + if (!$x22) { |
|
| 126 | + if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) { |
|
| 127 | + include_once(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php'); |
|
| 128 | + $editor = new XoopsFormFckeditor($caption, $name, $value); |
|
| 129 | + } |
|
| 130 | + } else { |
|
| 131 | + $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs); |
|
| 132 | + } |
|
| 133 | + break; |
|
| 134 | + |
|
| 135 | + case 'htmlarea': |
|
| 136 | + if (!$x22) { |
|
| 137 | + if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) { |
|
| 138 | + include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'); |
|
| 139 | + $editor = new XoopsFormHtmlarea($caption, $name, $value); |
|
| 140 | + } |
|
| 141 | + } else { |
|
| 142 | + $editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs); |
|
| 143 | + } |
|
| 144 | + break; |
|
| 145 | + |
|
| 146 | + case 'dhtml': |
|
| 147 | + if (!$x22) { |
|
| 148 | + $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental); |
|
| 149 | + } else { |
|
| 150 | + $editor = new XoopsFormEditor($caption, 'dhtmltextarea', $editor_configs); |
|
| 151 | + } |
|
| 152 | + break; |
|
| 153 | + |
|
| 154 | + case 'textarea': |
|
| 155 | + $editor = new XoopsFormTextArea($caption, $name, $value); |
|
| 156 | + break; |
|
| 157 | + |
|
| 158 | + case 'tinyeditor': |
|
| 159 | + if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
|
| 160 | + include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
|
| 161 | + $editor = new XoopsFormTinyeditorTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => $width, 'height' => $height)); |
|
| 162 | + } |
|
| 163 | + break; |
|
| 164 | + |
|
| 165 | + case 'koivi': |
|
| 166 | + if (!$x22) { |
|
| 167 | + if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) { |
|
| 168 | + include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php'); |
|
| 169 | + $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '250px', ''); |
|
| 170 | + } |
|
| 171 | + } else { |
|
| 172 | + $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs); |
|
| 173 | + } |
|
| 174 | + break; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $editor; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | function bookshop_JavascriptLinkConfirm($msg, $form = false) |
| 192 | 192 | { |
| 193 | - if (!$form) { |
|
| 194 | - return "onclick=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 195 | - } else { |
|
| 196 | - return "onSubmit=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 197 | - } |
|
| 193 | + if (!$form) { |
|
| 194 | + return "onclick=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 195 | + } else { |
|
| 196 | + return "onSubmit=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 197 | + } |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -205,30 +205,30 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | function bookshop_IP() |
| 207 | 207 | { |
| 208 | - $proxy_ip = ''; |
|
| 209 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 210 | - $proxy_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 211 | - } elseif (!empty($_SERVER['HTTP_X_FORWARDED'])) { |
|
| 212 | - $proxy_ip = $_SERVER['HTTP_X_FORWARDED']; |
|
| 213 | - } elseif (!empty($_SERVER['HTTP_FORWARDED_FOR'])) { |
|
| 214 | - $proxy_ip = $_SERVER['HTTP_FORWARDED_FOR']; |
|
| 215 | - } elseif (!empty($_SERVER['HTTP_FORWARDED'])) { |
|
| 216 | - $proxy_ip = $_SERVER['HTTP_FORWARDED']; |
|
| 217 | - } elseif (!empty($_SERVER['HTTP_VIA'])) { |
|
| 218 | - $proxy_ip = $_SERVER['HTTP_VIA']; |
|
| 219 | - } elseif (!empty($_SERVER['HTTP_X_COMING_FROM'])) { |
|
| 220 | - $proxy_ip = $_SERVER['HTTP_X_COMING_FROM']; |
|
| 221 | - } elseif (!empty($_SERVER['HTTP_COMING_FROM'])) { |
|
| 222 | - $proxy_ip = $_SERVER['HTTP_COMING_FROM']; |
|
| 223 | - } |
|
| 224 | - $regs = array(); |
|
| 225 | - if (!empty($proxy_ip) && $is_ip = preg_match('/^([0-9]{1,3}\.){3,3}[0-9]{1,3}/', $proxy_ip, $regs) && count($regs) > 0) { |
|
| 226 | - $the_IP = $regs[0]; |
|
| 227 | - } else { |
|
| 228 | - $the_IP = $_SERVER['REMOTE_ADDR']; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $the_IP; |
|
| 208 | + $proxy_ip = ''; |
|
| 209 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 210 | + $proxy_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 211 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED'])) { |
|
| 212 | + $proxy_ip = $_SERVER['HTTP_X_FORWARDED']; |
|
| 213 | + } elseif (!empty($_SERVER['HTTP_FORWARDED_FOR'])) { |
|
| 214 | + $proxy_ip = $_SERVER['HTTP_FORWARDED_FOR']; |
|
| 215 | + } elseif (!empty($_SERVER['HTTP_FORWARDED'])) { |
|
| 216 | + $proxy_ip = $_SERVER['HTTP_FORWARDED']; |
|
| 217 | + } elseif (!empty($_SERVER['HTTP_VIA'])) { |
|
| 218 | + $proxy_ip = $_SERVER['HTTP_VIA']; |
|
| 219 | + } elseif (!empty($_SERVER['HTTP_X_COMING_FROM'])) { |
|
| 220 | + $proxy_ip = $_SERVER['HTTP_X_COMING_FROM']; |
|
| 221 | + } elseif (!empty($_SERVER['HTTP_COMING_FROM'])) { |
|
| 222 | + $proxy_ip = $_SERVER['HTTP_COMING_FROM']; |
|
| 223 | + } |
|
| 224 | + $regs = array(); |
|
| 225 | + if (!empty($proxy_ip) && $is_ip = preg_match('/^([0-9]{1,3}\.){3,3}[0-9]{1,3}/', $proxy_ip, $regs) && count($regs) > 0) { |
|
| 226 | + $the_IP = $regs[0]; |
|
| 227 | + } else { |
|
| 228 | + $the_IP = $_SERVER['REMOTE_ADDR']; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $the_IP; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -242,23 +242,23 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | function bookshop_set_metas($page_title = '', $meta_description = '', $meta_keywords = '') |
| 244 | 244 | { |
| 245 | - global $xoTheme, $xoTheme, $xoopsTpl; |
|
| 246 | - $xoopsTpl->assign('xoops_pagetitle', $page_title); |
|
| 247 | - if (isset($xoTheme) && is_object($xoTheme)) { |
|
| 248 | - if (!empty($meta_keywords)) { |
|
| 249 | - $xoTheme->addMeta('meta', 'keywords', $meta_keywords); |
|
| 250 | - } |
|
| 251 | - if (!empty($meta_description)) { |
|
| 252 | - $xoTheme->addMeta('meta', 'description', $meta_description); |
|
| 253 | - } |
|
| 254 | - } elseif (isset($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions |
|
| 255 | - if (!empty($meta_keywords)) { |
|
| 256 | - $xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); |
|
| 257 | - } |
|
| 258 | - if (!empty($meta_description)) { |
|
| 259 | - $xoopsTpl->assign('xoops_meta_description', $meta_description); |
|
| 260 | - } |
|
| 261 | - } |
|
| 245 | + global $xoTheme, $xoTheme, $xoopsTpl; |
|
| 246 | + $xoopsTpl->assign('xoops_pagetitle', $page_title); |
|
| 247 | + if (isset($xoTheme) && is_object($xoTheme)) { |
|
| 248 | + if (!empty($meta_keywords)) { |
|
| 249 | + $xoTheme->addMeta('meta', 'keywords', $meta_keywords); |
|
| 250 | + } |
|
| 251 | + if (!empty($meta_description)) { |
|
| 252 | + $xoTheme->addMeta('meta', 'description', $meta_description); |
|
| 253 | + } |
|
| 254 | + } elseif (isset($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions |
|
| 255 | + if (!empty($meta_keywords)) { |
|
| 256 | + $xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); |
|
| 257 | + } |
|
| 258 | + if (!empty($meta_description)) { |
|
| 259 | + $xoopsTpl->assign('xoops_meta_description', $meta_description); |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -272,53 +272,53 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | function bookshop_send_email_from_tpl($tpl_name, $recipients, $subject, $variables) |
| 274 | 274 | { |
| 275 | - global $xoopsConfig; |
|
| 276 | - include_once XOOPS_ROOT_PATH . '/class/xoopsmailer.php'; |
|
| 277 | - if (!is_array($recipients)) { |
|
| 278 | - if (trim($recipients) == '') { |
|
| 279 | - return false; |
|
| 280 | - } |
|
| 281 | - } else { |
|
| 282 | - if (count($recipients) == 0) { |
|
| 283 | - return false; |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - if (function_exists('xoops_getMailer')) { |
|
| 287 | - $xoopsMailer =& xoops_getMailer(); |
|
| 288 | - } else { |
|
| 289 | - $xoopsMailer =& getMailer(); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - $xoopsMailer->useMail(); |
|
| 293 | - $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/bookshop/language/' . $xoopsConfig['language'] . '/mail_template'); |
|
| 294 | - $xoopsMailer->setTemplate($tpl_name); |
|
| 295 | - $xoopsMailer->setToEmails($recipients); |
|
| 296 | - // Change ! |
|
| 297 | - //$xoopsMailer->setFromEmail('[email protected]'); |
|
| 298 | - //$xoopsMailer->setFromName('PhotoSports'); |
|
| 299 | - $xoopsMailer->setSubject($subject); |
|
| 300 | - foreach ($variables as $key => $value) { |
|
| 301 | - $xoopsMailer->assign($key, $value); |
|
| 302 | - } |
|
| 303 | - $res = $xoopsMailer->send(); |
|
| 304 | - unset($xoopsMailer); |
|
| 305 | - |
|
| 306 | - $fp = @fopen(XOOPS_UPLOAD_PATH . '/logmail_bookshop.txt', 'a'); |
|
| 307 | - if ($fp) { |
|
| 308 | - fwrite($fp, str_repeat('-', 120) . "\n"); |
|
| 309 | - fwrite($fp, date('d/m/Y H:i:s') . "\n"); |
|
| 310 | - fwrite($fp, 'Nom du template : ' . $tpl_name . "\n"); |
|
| 311 | - fwrite($fp, 'Sujet du mail : ' . $subject . "\n"); |
|
| 312 | - if (is_array($recipients)) { |
|
| 313 | - fwrite($fp, 'Destinaire(s) du mail : ' . implode(',', $recipients) . "\n"); |
|
| 314 | - } else { |
|
| 315 | - fwrite($fp, 'Destinaire(s) du mail : ' . $recipients . "\n"); |
|
| 316 | - } |
|
| 317 | - fwrite($fp, 'Variables transmises : ' . implode(',', $variables) . "\n"); |
|
| 318 | - fclose($fp); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return $res; |
|
| 275 | + global $xoopsConfig; |
|
| 276 | + include_once XOOPS_ROOT_PATH . '/class/xoopsmailer.php'; |
|
| 277 | + if (!is_array($recipients)) { |
|
| 278 | + if (trim($recipients) == '') { |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 281 | + } else { |
|
| 282 | + if (count($recipients) == 0) { |
|
| 283 | + return false; |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + if (function_exists('xoops_getMailer')) { |
|
| 287 | + $xoopsMailer =& xoops_getMailer(); |
|
| 288 | + } else { |
|
| 289 | + $xoopsMailer =& getMailer(); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + $xoopsMailer->useMail(); |
|
| 293 | + $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/bookshop/language/' . $xoopsConfig['language'] . '/mail_template'); |
|
| 294 | + $xoopsMailer->setTemplate($tpl_name); |
|
| 295 | + $xoopsMailer->setToEmails($recipients); |
|
| 296 | + // Change ! |
|
| 297 | + //$xoopsMailer->setFromEmail('[email protected]'); |
|
| 298 | + //$xoopsMailer->setFromName('PhotoSports'); |
|
| 299 | + $xoopsMailer->setSubject($subject); |
|
| 300 | + foreach ($variables as $key => $value) { |
|
| 301 | + $xoopsMailer->assign($key, $value); |
|
| 302 | + } |
|
| 303 | + $res = $xoopsMailer->send(); |
|
| 304 | + unset($xoopsMailer); |
|
| 305 | + |
|
| 306 | + $fp = @fopen(XOOPS_UPLOAD_PATH . '/logmail_bookshop.txt', 'a'); |
|
| 307 | + if ($fp) { |
|
| 308 | + fwrite($fp, str_repeat('-', 120) . "\n"); |
|
| 309 | + fwrite($fp, date('d/m/Y H:i:s') . "\n"); |
|
| 310 | + fwrite($fp, 'Nom du template : ' . $tpl_name . "\n"); |
|
| 311 | + fwrite($fp, 'Sujet du mail : ' . $subject . "\n"); |
|
| 312 | + if (is_array($recipients)) { |
|
| 313 | + fwrite($fp, 'Destinaire(s) du mail : ' . implode(',', $recipients) . "\n"); |
|
| 314 | + } else { |
|
| 315 | + fwrite($fp, 'Destinaire(s) du mail : ' . $recipients . "\n"); |
|
| 316 | + } |
|
| 317 | + fwrite($fp, 'Variables transmises : ' . implode(',', $variables) . "\n"); |
|
| 318 | + fclose($fp); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return $res; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -328,30 +328,30 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | function bookshop_updateCache() |
| 330 | 330 | { |
| 331 | - global $xoopsModule; |
|
| 332 | - $folder = $xoopsModule->getVar('dirname'); |
|
| 333 | - $tpllist = array(); |
|
| 334 | - include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
|
| 335 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 336 | - $tplfile_handler = xoops_getHandler('tplfile'); |
|
| 337 | - $tpllist = $tplfile_handler->find(null, null, null, $folder); |
|
| 338 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache |
|
| 339 | - |
|
| 340 | - // Remove cache for each page. |
|
| 341 | - foreach ($tpllist as $onetemplate) { |
|
| 342 | - if ($onetemplate->getVar('tpl_type') === 'module') { |
|
| 343 | - // Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code |
|
| 344 | - $files_del = array(); |
|
| 345 | - $files_del = glob(XOOPS_CACHE_PATH . '/*' . $onetemplate->getVar('tpl_file') . '*'); |
|
| 346 | - if (count($files_del) > 0 && is_array($files_del)) { |
|
| 347 | - foreach ($files_del as $one_file) { |
|
| 348 | - if (is_file($one_file)) { |
|
| 349 | - unlink($one_file); |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 331 | + global $xoopsModule; |
|
| 332 | + $folder = $xoopsModule->getVar('dirname'); |
|
| 333 | + $tpllist = array(); |
|
| 334 | + include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
|
| 335 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 336 | + $tplfile_handler = xoops_getHandler('tplfile'); |
|
| 337 | + $tpllist = $tplfile_handler->find(null, null, null, $folder); |
|
| 338 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache |
|
| 339 | + |
|
| 340 | + // Remove cache for each page. |
|
| 341 | + foreach ($tpllist as $onetemplate) { |
|
| 342 | + if ($onetemplate->getVar('tpl_type') === 'module') { |
|
| 343 | + // Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code |
|
| 344 | + $files_del = array(); |
|
| 345 | + $files_del = glob(XOOPS_CACHE_PATH . '/*' . $onetemplate->getVar('tpl_file') . '*'); |
|
| 346 | + if (count($files_del) > 0 && is_array($files_del)) { |
|
| 347 | + foreach ($files_del as $one_file) { |
|
| 348 | + if (is_file($one_file)) { |
|
| 349 | + unlink($one_file); |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function bookshop_make_infotips($text) |
| 364 | 364 | { |
| 365 | - $infotips = bookshop_getmoduleoption('infotips'); |
|
| 366 | - if ($infotips > 0) { |
|
| 367 | - $myts = MyTextSanitizer::getInstance(); |
|
| 365 | + $infotips = bookshop_getmoduleoption('infotips'); |
|
| 366 | + if ($infotips > 0) { |
|
| 367 | + $myts = MyTextSanitizer::getInstance(); |
|
| 368 | 368 | |
| 369 | - return $myts->htmlSpecialChars(xoops_substr(strip_tags($text), 0, $infotips)); |
|
| 370 | - } |
|
| 369 | + return $myts->htmlSpecialChars(xoops_substr(strip_tags($text), 0, $infotips)); |
|
| 370 | + } |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -379,8 +379,8 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | function bookshop_redirect($message = '', $url = 'index.php', $time = 2) |
| 381 | 381 | { |
| 382 | - redirect_header($url, $time, $message); |
|
| 383 | - exit(); |
|
| 382 | + redirect_header($url, $time, $message); |
|
| 383 | + exit(); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -390,18 +390,18 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | function bookshop_get_module() |
| 392 | 392 | { |
| 393 | - static $mymodule; |
|
| 394 | - if (!isset($mymodule)) { |
|
| 395 | - global $xoopsModule; |
|
| 396 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == BOOKSHOP_DIRNAME) { |
|
| 397 | - $mymodule =& $xoopsModule; |
|
| 398 | - } else { |
|
| 399 | - $hModule = xoops_getHandler('module'); |
|
| 400 | - $mymodule = $hModule->getByDirname(BOOKSHOP_DIRNAME); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - return $mymodule; |
|
| 393 | + static $mymodule; |
|
| 394 | + if (!isset($mymodule)) { |
|
| 395 | + global $xoopsModule; |
|
| 396 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == BOOKSHOP_DIRNAME) { |
|
| 397 | + $mymodule =& $xoopsModule; |
|
| 398 | + } else { |
|
| 399 | + $hModule = xoops_getHandler('module'); |
|
| 400 | + $mymodule = $hModule->getByDirname(BOOKSHOP_DIRNAME); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + return $mymodule; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -411,13 +411,13 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | function bookshop_get_module_name() |
| 413 | 413 | { |
| 414 | - static $module_name; |
|
| 415 | - if (!isset($module_name)) { |
|
| 416 | - $mymodule = bookshop_get_module(); |
|
| 417 | - $module_name = $mymodule->getVar('name'); |
|
| 418 | - } |
|
| 414 | + static $module_name; |
|
| 415 | + if (!isset($module_name)) { |
|
| 416 | + $mymodule = bookshop_get_module(); |
|
| 417 | + $module_name = $mymodule->getVar('name'); |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - return $module_name; |
|
| 420 | + return $module_name; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -430,40 +430,40 @@ discard block |
||
| 430 | 430 | function bookshop_makeSEOurl($content, $urw = 1) |
| 431 | 431 | { |
| 432 | 432 | $s = "ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜŸÑàáâãäåòóôõöøèéêëçìíîïùúûüÿñ '()"; |
| 433 | - $r = 'AAAAAAOOOOOOEEEECIIIIUUUUYNaaaaaaooooooeeeeciiiiuuuuyn----'; |
|
| 434 | - $content = strtr($content, $s, $r); |
|
| 435 | - $content = strip_tags($content); |
|
| 436 | - $content = strtolower($content); |
|
| 437 | - $content = htmlentities($content); |
|
| 438 | - $content = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/', '$1', $content); |
|
| 439 | - $content = html_entity_decode($content); |
|
| 440 | - $content = preg_replace('/quot/i', ' ', $content); |
|
| 441 | - $content = preg_replace("/'/i", ' ', $content); |
|
| 442 | - $content = preg_replace('/-/i', ' ', $content); |
|
| 443 | - $content = preg_replace('/[[:punct:]]/i', '', $content); |
|
| 444 | - |
|
| 445 | - // Selon option mais attention au fichier .htaccess ! |
|
| 446 | - //$content = eregi_replace('[[:digit:]]','', $content); |
|
| 447 | - $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); // moi |
|
| 448 | - |
|
| 449 | - $words = explode(' ', $content); |
|
| 450 | - $keywords = ''; |
|
| 451 | - foreach ($words as $word) { |
|
| 452 | - if (strlen($word) >= $urw) { |
|
| 453 | - $keywords .= '-' . trim($word); |
|
| 454 | - } |
|
| 455 | - } |
|
| 456 | - if (!$keywords) { |
|
| 457 | - $keywords = '-'; |
|
| 458 | - } |
|
| 459 | - // Supprime les tirets en double |
|
| 460 | - $keywords = str_replace('--', '-', $keywords); |
|
| 433 | + $r = 'AAAAAAOOOOOOEEEECIIIIUUUUYNaaaaaaooooooeeeeciiiiuuuuyn----'; |
|
| 434 | + $content = strtr($content, $s, $r); |
|
| 435 | + $content = strip_tags($content); |
|
| 436 | + $content = strtolower($content); |
|
| 437 | + $content = htmlentities($content); |
|
| 438 | + $content = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/', '$1', $content); |
|
| 439 | + $content = html_entity_decode($content); |
|
| 440 | + $content = preg_replace('/quot/i', ' ', $content); |
|
| 441 | + $content = preg_replace("/'/i", ' ', $content); |
|
| 442 | + $content = preg_replace('/-/i', ' ', $content); |
|
| 443 | + $content = preg_replace('/[[:punct:]]/i', '', $content); |
|
| 444 | + |
|
| 445 | + // Selon option mais attention au fichier .htaccess ! |
|
| 446 | + //$content = eregi_replace('[[:digit:]]','', $content); |
|
| 447 | + $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); // moi |
|
| 448 | + |
|
| 449 | + $words = explode(' ', $content); |
|
| 450 | + $keywords = ''; |
|
| 451 | + foreach ($words as $word) { |
|
| 452 | + if (strlen($word) >= $urw) { |
|
| 453 | + $keywords .= '-' . trim($word); |
|
| 454 | + } |
|
| 455 | + } |
|
| 456 | + if (!$keywords) { |
|
| 457 | + $keywords = '-'; |
|
| 458 | + } |
|
| 459 | + // Supprime les tirets en double |
|
| 460 | + $keywords = str_replace('--', '-', $keywords); |
|
| 461 | 461 | // Supprime un éventuel tiret à la fin de la chaine |
| 462 | - if (substr($keywords, strlen($keywords) - 1, 1) == '-') { |
|
| 463 | - $keywords = substr($keywords, 0, strlen($keywords) - 1); |
|
| 464 | - } |
|
| 462 | + if (substr($keywords, strlen($keywords) - 1, 1) == '-') { |
|
| 463 | + $keywords = substr($keywords, 0, strlen($keywords) - 1); |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - return $keywords; |
|
| 466 | + return $keywords; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -473,9 +473,9 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | function bookshop_setCSS() |
| 475 | 475 | { |
| 476 | - global $xoopsTpl; |
|
| 477 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 478 | - $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 476 | + global $xoopsTpl; |
|
| 477 | + $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 478 | + $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -486,10 +486,10 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | function bookshop_makeHrefTitle($title) |
| 488 | 488 | { |
| 489 | - $s = "\"'"; |
|
| 490 | - $r = ' '; |
|
| 489 | + $s = "\"'"; |
|
| 490 | + $r = ' '; |
|
| 491 | 491 | |
| 492 | - return strtr($title, $s, $r); |
|
| 492 | + return strtr($title, $s, $r); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | function bookshop_formatMoney($ttc) |
| 502 | 502 | { |
| 503 | - $retval = sprintf('%0.' . bookshop_getmoduleoption('decimals_count') . 'f', $ttc); |
|
| 503 | + $retval = sprintf('%0.' . bookshop_getmoduleoption('decimals_count') . 'f', $ttc); |
|
| 504 | 504 | |
| 505 | - return $retval; |
|
| 505 | + return $retval; |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -516,12 +516,12 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | function bookshop_getTTC($ht, $vat, $edit = false) |
| 518 | 518 | { |
| 519 | - $ttc = $ht * (1 + ($vat / 100)); |
|
| 520 | - if (!$edit) { |
|
| 521 | - return bookshop_formatMoney($ttc); |
|
| 522 | - } else { |
|
| 523 | - return $ttc; |
|
| 524 | - } |
|
| 519 | + $ttc = $ht * (1 + ($vat / 100)); |
|
| 520 | + if (!$edit) { |
|
| 521 | + return bookshop_formatMoney($ttc); |
|
| 522 | + } else { |
|
| 523 | + return $ttc; |
|
| 524 | + } |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | */ |
| 534 | 534 | function bookshop_getDiscountedPrice($price, $discount) |
| 535 | 535 | { |
| 536 | - return $price - ($price * ($discount / 100)); |
|
| 536 | + return $price - ($price * ($discount / 100)); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | function bookshop_getVAT($ht, $vat) |
| 547 | 547 | { |
| 548 | - return ($ht * $vat) / 100; |
|
| 548 | + return ($ht * $vat) / 100; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
@@ -557,9 +557,9 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | function bookshop_getHT($ttc, $vat) |
| 559 | 559 | { |
| 560 | - $ht = $ttc / (1 + ($vat / 100)); |
|
| 560 | + $ht = $ttc / (1 + ($vat / 100)); |
|
| 561 | 561 | |
| 562 | - return bookshop_formatMoney($ht); |
|
| 562 | + return bookshop_formatMoney($ht); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
@@ -570,70 +570,70 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | function bookshop_createmeta_keywords($content) |
| 572 | 572 | { |
| 573 | - $keywordscount = bookshop_getmoduleoption('metagen_maxwords'); |
|
| 574 | - $keywordsorder = bookshop_getmoduleoption('metagen_order'); |
|
| 575 | - |
|
| 576 | - $tmp = array(); |
|
| 577 | - // Search for the "Minimum keyword length" |
|
| 578 | - if (isset($_SESSION['bookshop_keywords_limit'])) { |
|
| 579 | - $limit = $_SESSION['bookshop_keywords_limit']; |
|
| 580 | - } else { |
|
| 581 | - $config_handler = xoops_getHandler('config'); |
|
| 582 | - $xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
| 583 | - $limit = $xoopsConfigSearch['keyword_min']; |
|
| 584 | - $_SESSION['bookshop_keywords_limit'] = $limit; |
|
| 585 | - } |
|
| 586 | - $myts = MyTextSanitizer::getInstance(); |
|
| 587 | - $content = str_replace('<br>', ' ', $content); |
|
| 588 | - $content = $myts->undoHtmlSpecialChars($content); |
|
| 589 | - $content = strip_tags($content); |
|
| 590 | - $content = strtolower($content); |
|
| 591 | - $search_pattern = array(' ', "\t", "\r\n", "\r", "\n", ',', '.', "'", ';', ':', ')', '(', '"', '?', '!', '{', '}', '[', ']', '<', '>', '/', '+', '-', '_', '\\', '*'); |
|
| 592 | - $replace_pattern = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); |
|
| 593 | - $content = str_replace($search_pattern, $replace_pattern, $content); |
|
| 594 | - $keywords = explode(' ', $content); |
|
| 595 | - switch ($keywordsorder) { |
|
| 596 | - case 0: // Ordre d'apparition dans le texte |
|
| 597 | - $keywords = array_unique($keywords); |
|
| 598 | - break; |
|
| 573 | + $keywordscount = bookshop_getmoduleoption('metagen_maxwords'); |
|
| 574 | + $keywordsorder = bookshop_getmoduleoption('metagen_order'); |
|
| 575 | + |
|
| 576 | + $tmp = array(); |
|
| 577 | + // Search for the "Minimum keyword length" |
|
| 578 | + if (isset($_SESSION['bookshop_keywords_limit'])) { |
|
| 579 | + $limit = $_SESSION['bookshop_keywords_limit']; |
|
| 580 | + } else { |
|
| 581 | + $config_handler = xoops_getHandler('config'); |
|
| 582 | + $xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
| 583 | + $limit = $xoopsConfigSearch['keyword_min']; |
|
| 584 | + $_SESSION['bookshop_keywords_limit'] = $limit; |
|
| 585 | + } |
|
| 586 | + $myts = MyTextSanitizer::getInstance(); |
|
| 587 | + $content = str_replace('<br>', ' ', $content); |
|
| 588 | + $content = $myts->undoHtmlSpecialChars($content); |
|
| 589 | + $content = strip_tags($content); |
|
| 590 | + $content = strtolower($content); |
|
| 591 | + $search_pattern = array(' ', "\t", "\r\n", "\r", "\n", ',', '.', "'", ';', ':', ')', '(', '"', '?', '!', '{', '}', '[', ']', '<', '>', '/', '+', '-', '_', '\\', '*'); |
|
| 592 | + $replace_pattern = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); |
|
| 593 | + $content = str_replace($search_pattern, $replace_pattern, $content); |
|
| 594 | + $keywords = explode(' ', $content); |
|
| 595 | + switch ($keywordsorder) { |
|
| 596 | + case 0: // Ordre d'apparition dans le texte |
|
| 597 | + $keywords = array_unique($keywords); |
|
| 598 | + break; |
|
| 599 | 599 | case 1: // Ordre de fréquence des mots |
| 600 | - $keywords = array_count_values($keywords); |
|
| 601 | - asort($keywords); |
|
| 602 | - $keywords = array_keys($keywords); |
|
| 603 | - break; |
|
| 600 | + $keywords = array_count_values($keywords); |
|
| 601 | + asort($keywords); |
|
| 602 | + $keywords = array_keys($keywords); |
|
| 603 | + break; |
|
| 604 | 604 | case 2: // Ordre inverse de la fréquence des mots |
| 605 | - $keywords = array_count_values($keywords); |
|
| 606 | - arsort($keywords); |
|
| 607 | - $keywords = array_keys($keywords); |
|
| 608 | - break; |
|
| 609 | - } |
|
| 610 | - // Remove black listed words |
|
| 611 | - if (xoops_trim(bookshop_getmoduleoption('metagen_blacklist')) != '') { |
|
| 612 | - $metagen_blacklist = str_replace("\r", '', bookshop_getmoduleoption('metagen_blacklist')); |
|
| 613 | - $metablack = explode("\n", $metagen_blacklist); |
|
| 614 | - array_walk($metablack, 'trim'); |
|
| 615 | - $keywords = array_diff($keywords, $metablack); |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - foreach ($keywords as $keyword) { |
|
| 619 | - if (strlen($keyword) >= $limit && !is_numeric($keyword)) { |
|
| 620 | - $tmp[] = $keyword; |
|
| 621 | - } |
|
| 622 | - } |
|
| 623 | - $tmp = array_slice($tmp, 0, $keywordscount); |
|
| 624 | - if (count($tmp) > 0) { |
|
| 625 | - return implode(',', $tmp); |
|
| 626 | - } else { |
|
| 627 | - if (!isset($config_handler) || !is_object($config_handler)) { |
|
| 628 | - $config_handler = xoops_getHandler('config'); |
|
| 629 | - } |
|
| 630 | - $xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER); |
|
| 631 | - if (isset($xoopsConfigMetaFooter['meta_keywords'])) { |
|
| 632 | - return $xoopsConfigMetaFooter['meta_keywords']; |
|
| 633 | - } else { |
|
| 634 | - return ''; |
|
| 635 | - } |
|
| 636 | - } |
|
| 605 | + $keywords = array_count_values($keywords); |
|
| 606 | + arsort($keywords); |
|
| 607 | + $keywords = array_keys($keywords); |
|
| 608 | + break; |
|
| 609 | + } |
|
| 610 | + // Remove black listed words |
|
| 611 | + if (xoops_trim(bookshop_getmoduleoption('metagen_blacklist')) != '') { |
|
| 612 | + $metagen_blacklist = str_replace("\r", '', bookshop_getmoduleoption('metagen_blacklist')); |
|
| 613 | + $metablack = explode("\n", $metagen_blacklist); |
|
| 614 | + array_walk($metablack, 'trim'); |
|
| 615 | + $keywords = array_diff($keywords, $metablack); |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + foreach ($keywords as $keyword) { |
|
| 619 | + if (strlen($keyword) >= $limit && !is_numeric($keyword)) { |
|
| 620 | + $tmp[] = $keyword; |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + $tmp = array_slice($tmp, 0, $keywordscount); |
|
| 624 | + if (count($tmp) > 0) { |
|
| 625 | + return implode(',', $tmp); |
|
| 626 | + } else { |
|
| 627 | + if (!isset($config_handler) || !is_object($config_handler)) { |
|
| 628 | + $config_handler = xoops_getHandler('config'); |
|
| 629 | + } |
|
| 630 | + $xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER); |
|
| 631 | + if (isset($xoopsConfigMetaFooter['meta_keywords'])) { |
|
| 632 | + return $xoopsConfigMetaFooter['meta_keywords']; |
|
| 633 | + } else { |
|
| 634 | + return ''; |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -644,11 +644,11 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | function bookshop_getUsersFromGroup($group_id) |
| 646 | 646 | { |
| 647 | - $tbl_users = array(); |
|
| 648 | - $member_handler = xoops_getHandler('member'); |
|
| 649 | - $tbl_users = $member_handler->getUsersByGroup($group_id, true); |
|
| 647 | + $tbl_users = array(); |
|
| 648 | + $member_handler = xoops_getHandler('member'); |
|
| 649 | + $tbl_users = $member_handler->getUsersByGroup($group_id, true); |
|
| 650 | 650 | |
| 651 | - return $tbl_users; |
|
| 651 | + return $tbl_users; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
@@ -659,13 +659,13 @@ discard block |
||
| 659 | 659 | */ |
| 660 | 660 | function bookshop_getEmailsFromGroup($group_id) |
| 661 | 661 | { |
| 662 | - $ret = array(); |
|
| 663 | - $tbl_users = bookshop_getUsersFromGroup($group_id); |
|
| 664 | - foreach ($tbl_users as $user) { |
|
| 665 | - $ret[] = $user->getVar('email'); |
|
| 666 | - } |
|
| 662 | + $ret = array(); |
|
| 663 | + $tbl_users = bookshop_getUsersFromGroup($group_id); |
|
| 664 | + foreach ($tbl_users as $user) { |
|
| 665 | + $ret[] = $user->getVar('email'); |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - return $ret; |
|
| 668 | + return $ret; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | /** |
@@ -676,20 +676,20 @@ discard block |
||
| 676 | 676 | */ |
| 677 | 677 | function bookshop_post_it($datastream, $url) |
| 678 | 678 | { |
| 679 | - $url = preg_replace('@^http://@i', '', $url); |
|
| 680 | - $host = substr($url, 0, strpos($url, '/')); |
|
| 681 | - $uri = strstr($url, '/'); |
|
| 682 | - $reqbody = ''; |
|
| 683 | - foreach ($datastream as $key => $val) { |
|
| 684 | - if (!empty($reqbody)) { |
|
| 685 | - $reqbody .= '&'; |
|
| 686 | - } |
|
| 687 | - $reqbody .= $key . '=' . urlencode($val); |
|
| 688 | - } |
|
| 689 | - $contentlength = strlen($reqbody); |
|
| 690 | - $reqheader = "POST $uri HTTP/1.1\r\n" . "Host: $host\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Content-Length: $contentlength\r\n\r\n" . "$reqbody\r\n"; |
|
| 691 | - |
|
| 692 | - return $reqheader; |
|
| 679 | + $url = preg_replace('@^http://@i', '', $url); |
|
| 680 | + $host = substr($url, 0, strpos($url, '/')); |
|
| 681 | + $uri = strstr($url, '/'); |
|
| 682 | + $reqbody = ''; |
|
| 683 | + foreach ($datastream as $key => $val) { |
|
| 684 | + if (!empty($reqbody)) { |
|
| 685 | + $reqbody .= '&'; |
|
| 686 | + } |
|
| 687 | + $reqbody .= $key . '=' . urlencode($val); |
|
| 688 | + } |
|
| 689 | + $contentlength = strlen($reqbody); |
|
| 690 | + $reqheader = "POST $uri HTTP/1.1\r\n" . "Host: $host\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Content-Length: $contentlength\r\n\r\n" . "$reqbody\r\n"; |
|
| 691 | + |
|
| 692 | + return $reqheader; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -699,24 +699,24 @@ discard block |
||
| 699 | 699 | */ |
| 700 | 700 | function bookshop_isAdmin() |
| 701 | 701 | { |
| 702 | - global $xoopsUser, $xoopsModule; |
|
| 703 | - if (is_object($xoopsUser)) { |
|
| 704 | - if (in_array(XOOPS_GROUP_ADMIN, $xoopsUser->getGroups())) { |
|
| 705 | - return true; |
|
| 706 | - } else { |
|
| 707 | - if (isset($xoopsModule)) { |
|
| 708 | - if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
|
| 709 | - return true; |
|
| 710 | - } else { |
|
| 711 | - return false; |
|
| 712 | - } |
|
| 713 | - } else { |
|
| 714 | - return false; |
|
| 715 | - } |
|
| 716 | - } |
|
| 717 | - } else { |
|
| 718 | - return false; |
|
| 719 | - } |
|
| 702 | + global $xoopsUser, $xoopsModule; |
|
| 703 | + if (is_object($xoopsUser)) { |
|
| 704 | + if (in_array(XOOPS_GROUP_ADMIN, $xoopsUser->getGroups())) { |
|
| 705 | + return true; |
|
| 706 | + } else { |
|
| 707 | + if (isset($xoopsModule)) { |
|
| 708 | + if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
|
| 709 | + return true; |
|
| 710 | + } else { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 713 | + } else { |
|
| 714 | + return false; |
|
| 715 | + } |
|
| 716 | + } |
|
| 717 | + } else { |
|
| 718 | + return false; |
|
| 719 | + } |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -728,24 +728,24 @@ discard block |
||
| 728 | 728 | */ |
| 729 | 729 | function bookshop_isMemberOfGroup($group = 0) |
| 730 | 730 | { |
| 731 | - global $xoopsUser; |
|
| 732 | - static $tblBuffer = array(); |
|
| 733 | - $retval = false; |
|
| 734 | - if (is_object($xoopsUser)) { |
|
| 735 | - $uid = $xoopsUser->getVar('uid'); |
|
| 736 | - } else { |
|
| 737 | - $uid = 0; |
|
| 738 | - } |
|
| 739 | - if (is_array($tblBuffer) && array_key_exists($group, $tblBuffer)) { |
|
| 740 | - $retval = $tblBuffer[$group]; |
|
| 741 | - } else { |
|
| 742 | - $member_handler = xoops_getHandler('member'); |
|
| 743 | - $tblGroups = $member_handler->getGroupsByUser($uid, false); // Renvoie un tableau d'ID (de groupes) |
|
| 744 | - $retval = in_array($group, $tblGroups); |
|
| 745 | - $tblBuffer[$group] = $retval; |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - return $retval; |
|
| 731 | + global $xoopsUser; |
|
| 732 | + static $tblBuffer = array(); |
|
| 733 | + $retval = false; |
|
| 734 | + if (is_object($xoopsUser)) { |
|
| 735 | + $uid = $xoopsUser->getVar('uid'); |
|
| 736 | + } else { |
|
| 737 | + $uid = 0; |
|
| 738 | + } |
|
| 739 | + if (is_array($tblBuffer) && array_key_exists($group, $tblBuffer)) { |
|
| 740 | + $retval = $tblBuffer[$group]; |
|
| 741 | + } else { |
|
| 742 | + $member_handler = xoops_getHandler('member'); |
|
| 743 | + $tblGroups = $member_handler->getGroupsByUser($uid, false); // Renvoie un tableau d'ID (de groupes) |
|
| 744 | + $retval = in_array($group, $tblGroups); |
|
| 745 | + $tblBuffer[$group] = $retval; |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + return $retval; |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
@@ -755,17 +755,17 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | function bookshop_needsAsterisk() |
| 757 | 757 | { |
| 758 | - if (bookshop_is_x22()) { |
|
| 759 | - return false; |
|
| 760 | - } |
|
| 761 | - if (strpos(strtolower(XOOPS_VERSION), 'legacy') === false) { |
|
| 762 | - $xv = xoops_trim(str_replace('XOOPS ', '', XOOPS_VERSION)); |
|
| 763 | - if ((int)substr($xv, 4, 2) >= 17) { |
|
| 764 | - return false; |
|
| 765 | - } |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - return true; |
|
| 758 | + if (bookshop_is_x22()) { |
|
| 759 | + return false; |
|
| 760 | + } |
|
| 761 | + if (strpos(strtolower(XOOPS_VERSION), 'legacy') === false) { |
|
| 762 | + $xv = xoops_trim(str_replace('XOOPS ', '', XOOPS_VERSION)); |
|
| 763 | + if ((int)substr($xv, 4, 2) >= 17) { |
|
| 764 | + return false; |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + return true; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -777,20 +777,20 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | function bookshop_formMarkRequiredFields(&$sform) |
| 779 | 779 | { |
| 780 | - if (bookshop_needsAsterisk()) { |
|
| 781 | - $tblRequired = array(); |
|
| 782 | - foreach ($sform->getRequired() as $item) { |
|
| 783 | - $tblRequired[] = $item->_name; |
|
| 784 | - } |
|
| 785 | - $tblElements = array(); |
|
| 786 | - $tblElements = &$sform->getElements(); |
|
| 787 | - $cnt = count($tblElements); |
|
| 788 | - for ($i = 0; $i < $cnt; ++$i) { |
|
| 789 | - if (is_object($tblElements[$i]) && in_array($tblElements[$i]->_name, $tblRequired)) { |
|
| 790 | - $tblElements[$i]->_caption .= ' *'; |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - return $sform; |
|
| 780 | + if (bookshop_needsAsterisk()) { |
|
| 781 | + $tblRequired = array(); |
|
| 782 | + foreach ($sform->getRequired() as $item) { |
|
| 783 | + $tblRequired[] = $item->_name; |
|
| 784 | + } |
|
| 785 | + $tblElements = array(); |
|
| 786 | + $tblElements = &$sform->getElements(); |
|
| 787 | + $cnt = count($tblElements); |
|
| 788 | + for ($i = 0; $i < $cnt; ++$i) { |
|
| 789 | + if (is_object($tblElements[$i]) && in_array($tblElements[$i]->_name, $tblRequired)) { |
|
| 790 | + $tblElements[$i]->_caption .= ' *'; |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + return $sform; |
|
| 796 | 796 | } |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | 56 | $module_handler = xoops_getHandler('module'); |
| 57 | - $module =& $module_handler->getByDirname($repmodule); |
|
| 57 | + $module = & $module_handler->getByDirname($repmodule); |
|
| 58 | 58 | $config_handler = xoops_getHandler('config'); |
| 59 | 59 | if ($module) { |
| 60 | - $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 60 | + $moduleConfig = & $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
| 61 | 61 | if (isset($moduleConfig[$option])) { |
| 62 | 62 | $retval = $moduleConfig[$option]; |
| 63 | 63 | } |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | switch (strtolower($editor_option)) { |
| 113 | 113 | case 'spaw': |
| 114 | 114 | if (!$x22) { |
| 115 | - if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) { |
|
| 116 | - include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php'); |
|
| 115 | + if (is_readable(XOOPS_ROOT_PATH.'/class/spaw/formspaw.php')) { |
|
| 116 | + include_once(XOOPS_ROOT_PATH.'/class/spaw/formspaw.php'); |
|
| 117 | 117 | $editor = new XoopsFormSpaw($caption, $name, $value); |
| 118 | 118 | } |
| 119 | 119 | } else { |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | case 'fck': |
| 125 | 125 | if (!$x22) { |
| 126 | - if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) { |
|
| 127 | - include_once(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php'); |
|
| 126 | + if (is_readable(XOOPS_ROOT_PATH.'/class/fckeditor/formfckeditor.php')) { |
|
| 127 | + include_once(XOOPS_ROOT_PATH.'/class/fckeditor/formfckeditor.php'); |
|
| 128 | 128 | $editor = new XoopsFormFckeditor($caption, $name, $value); |
| 129 | 129 | } |
| 130 | 130 | } else { |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | case 'htmlarea': |
| 136 | 136 | if (!$x22) { |
| 137 | - if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) { |
|
| 138 | - include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'); |
|
| 137 | + if (is_readable(XOOPS_ROOT_PATH.'/class/htmlarea/formhtmlarea.php')) { |
|
| 138 | + include_once(XOOPS_ROOT_PATH.'/class/htmlarea/formhtmlarea.php'); |
|
| 139 | 139 | $editor = new XoopsFormHtmlarea($caption, $name, $value); |
| 140 | 140 | } |
| 141 | 141 | } else { |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | break; |
| 157 | 157 | |
| 158 | 158 | case 'tinyeditor': |
| 159 | - if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
|
| 160 | - include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
|
| 159 | + if (is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
|
| 160 | + include_once XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
|
| 161 | 161 | $editor = new XoopsFormTinyeditorTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => $width, 'height' => $height)); |
| 162 | 162 | } |
| 163 | 163 | break; |
| 164 | 164 | |
| 165 | 165 | case 'koivi': |
| 166 | 166 | if (!$x22) { |
| 167 | - if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) { |
|
| 168 | - include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php'); |
|
| 167 | + if (is_readable(XOOPS_ROOT_PATH.'/class/wysiwyg/formwysiwygtextarea.php')) { |
|
| 168 | + include_once(XOOPS_ROOT_PATH.'/class/wysiwyg/formwysiwygtextarea.php'); |
|
| 169 | 169 | $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '250px', ''); |
| 170 | 170 | } |
| 171 | 171 | } else { |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | function bookshop_JavascriptLinkConfirm($msg, $form = false) |
| 192 | 192 | { |
| 193 | 193 | if (!$form) { |
| 194 | - return "onclick=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 194 | + return "onclick=\"javascript:return confirm('".str_replace("'", ' ', $msg)."')\""; |
|
| 195 | 195 | } else { |
| 196 | - return "onSubmit=\"javascript:return confirm('" . str_replace("'", ' ', $msg) . "')\""; |
|
| 196 | + return "onSubmit=\"javascript:return confirm('".str_replace("'", ' ', $msg)."')\""; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | function bookshop_send_email_from_tpl($tpl_name, $recipients, $subject, $variables) |
| 274 | 274 | { |
| 275 | 275 | global $xoopsConfig; |
| 276 | - include_once XOOPS_ROOT_PATH . '/class/xoopsmailer.php'; |
|
| 276 | + include_once XOOPS_ROOT_PATH.'/class/xoopsmailer.php'; |
|
| 277 | 277 | if (!is_array($recipients)) { |
| 278 | 278 | if (trim($recipients) == '') { |
| 279 | 279 | return false; |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | if (function_exists('xoops_getMailer')) { |
| 287 | - $xoopsMailer =& xoops_getMailer(); |
|
| 287 | + $xoopsMailer = & xoops_getMailer(); |
|
| 288 | 288 | } else { |
| 289 | - $xoopsMailer =& getMailer(); |
|
| 289 | + $xoopsMailer = & getMailer(); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $xoopsMailer->useMail(); |
| 293 | - $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/bookshop/language/' . $xoopsConfig['language'] . '/mail_template'); |
|
| 293 | + $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH.'/modules/bookshop/language/'.$xoopsConfig['language'].'/mail_template'); |
|
| 294 | 294 | $xoopsMailer->setTemplate($tpl_name); |
| 295 | 295 | $xoopsMailer->setToEmails($recipients); |
| 296 | 296 | // Change ! |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | $res = $xoopsMailer->send(); |
| 304 | 304 | unset($xoopsMailer); |
| 305 | 305 | |
| 306 | - $fp = @fopen(XOOPS_UPLOAD_PATH . '/logmail_bookshop.txt', 'a'); |
|
| 306 | + $fp = @fopen(XOOPS_UPLOAD_PATH.'/logmail_bookshop.txt', 'a'); |
|
| 307 | 307 | if ($fp) { |
| 308 | - fwrite($fp, str_repeat('-', 120) . "\n"); |
|
| 309 | - fwrite($fp, date('d/m/Y H:i:s') . "\n"); |
|
| 310 | - fwrite($fp, 'Nom du template : ' . $tpl_name . "\n"); |
|
| 311 | - fwrite($fp, 'Sujet du mail : ' . $subject . "\n"); |
|
| 308 | + fwrite($fp, str_repeat('-', 120)."\n"); |
|
| 309 | + fwrite($fp, date('d/m/Y H:i:s')."\n"); |
|
| 310 | + fwrite($fp, 'Nom du template : '.$tpl_name."\n"); |
|
| 311 | + fwrite($fp, 'Sujet du mail : '.$subject."\n"); |
|
| 312 | 312 | if (is_array($recipients)) { |
| 313 | - fwrite($fp, 'Destinaire(s) du mail : ' . implode(',', $recipients) . "\n"); |
|
| 313 | + fwrite($fp, 'Destinaire(s) du mail : '.implode(',', $recipients)."\n"); |
|
| 314 | 314 | } else { |
| 315 | - fwrite($fp, 'Destinaire(s) du mail : ' . $recipients . "\n"); |
|
| 315 | + fwrite($fp, 'Destinaire(s) du mail : '.$recipients."\n"); |
|
| 316 | 316 | } |
| 317 | - fwrite($fp, 'Variables transmises : ' . implode(',', $variables) . "\n"); |
|
| 317 | + fwrite($fp, 'Variables transmises : '.implode(',', $variables)."\n"); |
|
| 318 | 318 | fclose($fp); |
| 319 | 319 | } |
| 320 | 320 | |
@@ -331,18 +331,18 @@ discard block |
||
| 331 | 331 | global $xoopsModule; |
| 332 | 332 | $folder = $xoopsModule->getVar('dirname'); |
| 333 | 333 | $tpllist = array(); |
| 334 | - include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
|
| 335 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 334 | + include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php'; |
|
| 335 | + include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
| 336 | 336 | $tplfile_handler = xoops_getHandler('tplfile'); |
| 337 | 337 | $tpllist = $tplfile_handler->find(null, null, null, $folder); |
| 338 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache |
|
| 338 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache |
|
| 339 | 339 | |
| 340 | 340 | // Remove cache for each page. |
| 341 | 341 | foreach ($tpllist as $onetemplate) { |
| 342 | 342 | if ($onetemplate->getVar('tpl_type') === 'module') { |
| 343 | 343 | // Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code |
| 344 | 344 | $files_del = array(); |
| 345 | - $files_del = glob(XOOPS_CACHE_PATH . '/*' . $onetemplate->getVar('tpl_file') . '*'); |
|
| 345 | + $files_del = glob(XOOPS_CACHE_PATH.'/*'.$onetemplate->getVar('tpl_file').'*'); |
|
| 346 | 346 | if (count($files_del) > 0 && is_array($files_del)) { |
| 347 | 347 | foreach ($files_del as $one_file) { |
| 348 | 348 | if (is_file($one_file)) { |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | if (!isset($mymodule)) { |
| 395 | 395 | global $xoopsModule; |
| 396 | 396 | if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == BOOKSHOP_DIRNAME) { |
| 397 | - $mymodule =& $xoopsModule; |
|
| 397 | + $mymodule = & $xoopsModule; |
|
| 398 | 398 | } else { |
| 399 | 399 | $hModule = xoops_getHandler('module'); |
| 400 | 400 | $mymodule = $hModule->getByDirname(BOOKSHOP_DIRNAME); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | function bookshop_makeSEOurl($content, $urw = 1) |
| 431 | 431 | { |
| 432 | - $s = "ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜŸÑàáâãäåòóôõöøèéêëçìíîïùúûüÿñ '()"; |
|
| 432 | + $s = "ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜŸÑàáâãäåòóôõöøèéêëçìíîïùúûüÿñ '()"; |
|
| 433 | 433 | $r = 'AAAAAAOOOOOOEEEECIIIIUUUUYNaaaaaaooooooeeeeciiiiuuuuyn----'; |
| 434 | 434 | $content = strtr($content, $s, $r); |
| 435 | 435 | $content = strip_tags($content); |
@@ -444,13 +444,13 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | // Selon option mais attention au fichier .htaccess ! |
| 446 | 446 | //$content = eregi_replace('[[:digit:]]','', $content); |
| 447 | - $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); // moi |
|
| 447 | + $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); // moi |
|
| 448 | 448 | |
| 449 | 449 | $words = explode(' ', $content); |
| 450 | 450 | $keywords = ''; |
| 451 | 451 | foreach ($words as $word) { |
| 452 | 452 | if (strlen($word) >= $urw) { |
| 453 | - $keywords .= '-' . trim($word); |
|
| 453 | + $keywords .= '-'.trim($word); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | if (!$keywords) { |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | function bookshop_setCSS() |
| 475 | 475 | { |
| 476 | 476 | global $xoopsTpl; |
| 477 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 477 | + $url = BOOKSHOP_URL.'assets/css/bookshop.css'; |
|
| 478 | 478 | $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
| 479 | 479 | } |
| 480 | 480 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | function bookshop_formatMoney($ttc) |
| 502 | 502 | { |
| 503 | - $retval = sprintf('%0.' . bookshop_getmoduleoption('decimals_count') . 'f', $ttc); |
|
| 503 | + $retval = sprintf('%0.'.bookshop_getmoduleoption('decimals_count').'f', $ttc); |
|
| 504 | 504 | |
| 505 | 505 | return $retval; |
| 506 | 506 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | $limit = $_SESSION['bookshop_keywords_limit']; |
| 580 | 580 | } else { |
| 581 | 581 | $config_handler = xoops_getHandler('config'); |
| 582 | - $xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
| 582 | + $xoopsConfigSearch = & $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
| 583 | 583 | $limit = $xoopsConfigSearch['keyword_min']; |
| 584 | 584 | $_SESSION['bookshop_keywords_limit'] = $limit; |
| 585 | 585 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | if (!isset($config_handler) || !is_object($config_handler)) { |
| 628 | 628 | $config_handler = xoops_getHandler('config'); |
| 629 | 629 | } |
| 630 | - $xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER); |
|
| 630 | + $xoopsConfigMetaFooter = & $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER); |
|
| 631 | 631 | if (isset($xoopsConfigMetaFooter['meta_keywords'])) { |
| 632 | 632 | return $xoopsConfigMetaFooter['meta_keywords']; |
| 633 | 633 | } else { |
@@ -684,10 +684,10 @@ discard block |
||
| 684 | 684 | if (!empty($reqbody)) { |
| 685 | 685 | $reqbody .= '&'; |
| 686 | 686 | } |
| 687 | - $reqbody .= $key . '=' . urlencode($val); |
|
| 687 | + $reqbody .= $key.'='.urlencode($val); |
|
| 688 | 688 | } |
| 689 | 689 | $contentlength = strlen($reqbody); |
| 690 | - $reqheader = "POST $uri HTTP/1.1\r\n" . "Host: $host\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Content-Length: $contentlength\r\n\r\n" . "$reqbody\r\n"; |
|
| 690 | + $reqheader = "POST $uri HTTP/1.1\r\n"."Host: $host\n"."Content-Type: application/x-www-form-urlencoded\r\n"."Content-Length: $contentlength\r\n\r\n"."$reqbody\r\n"; |
|
| 691 | 691 | |
| 692 | 692 | return $reqheader; |
| 693 | 693 | } |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $retval = $tblBuffer[$group]; |
| 741 | 741 | } else { |
| 742 | 742 | $member_handler = xoops_getHandler('member'); |
| 743 | - $tblGroups = $member_handler->getGroupsByUser($uid, false); // Renvoie un tableau d'ID (de groupes) |
|
| 743 | + $tblGroups = $member_handler->getGroupsByUser($uid, false); // Renvoie un tableau d'ID (de groupes) |
|
| 744 | 744 | $retval = in_array($group, $tblGroups); |
| 745 | 745 | $tblBuffer[$group] = $retval; |
| 746 | 746 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $op = 'default'; |
| 38 | 38 | if (isset($_POST['op'])) { |
| 39 | - $op = $_POST['op']; |
|
| 39 | + $op = $_POST['op']; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $xoopsTpl->assign('op', $op); |
@@ -48,181 +48,181 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function listCart() |
| 50 | 50 | { |
| 51 | - global $h_bookshop_caddy, $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription; |
|
| 52 | - $h_bookshop_caddy->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription); |
|
| 53 | - $dec = bookshop_getmoduleoption('decimals_count'); |
|
| 54 | - $shippingAmount = sprintf('%0.' . $dec . 'f', $shippingAmount); // Amount of postage |
|
| 55 | - $commandAmount = sprintf('%0.' . $dec . 'f', $commandAmount); // Amount HT command |
|
| 56 | - $vatAmount = sprintf('%0.' . $dec . 'f', $vatAmount); // Amount of VAT |
|
| 57 | - $commandAmountTTC = sprintf('%0.' . $dec . 'f', $commandAmountTTC); // Amount TTC of the order (shipping included) |
|
| 51 | + global $h_bookshop_caddy, $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription; |
|
| 52 | + $h_bookshop_caddy->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription); |
|
| 53 | + $dec = bookshop_getmoduleoption('decimals_count'); |
|
| 54 | + $shippingAmount = sprintf('%0.' . $dec . 'f', $shippingAmount); // Amount of postage |
|
| 55 | + $commandAmount = sprintf('%0.' . $dec . 'f', $commandAmount); // Amount HT command |
|
| 56 | + $vatAmount = sprintf('%0.' . $dec . 'f', $vatAmount); // Amount of VAT |
|
| 57 | + $commandAmountTTC = sprintf('%0.' . $dec . 'f', $commandAmountTTC); // Amount TTC of the order (shipping included) |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $tbl_country = XoopsLists::getCountryList(); |
| 61 | 61 | if (is_object($xoopsUser)) { |
| 62 | - $uid = $xoopsUser->getVar('uid'); |
|
| 62 | + $uid = $xoopsUser->getVar('uid'); |
|
| 63 | 63 | } else { |
| 64 | - $uid = 0; |
|
| 64 | + $uid = 0; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | switch ($op) { |
| 68 | - // **************************************************************************************************************** |
|
| 69 | - case 'default': // Submitting Forms |
|
| 70 | - // **************************************************************************************************************** |
|
| 71 | - if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 72 | - bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 73 | - } |
|
| 74 | - listCart(); |
|
| 75 | - $notFound = true; |
|
| 76 | - |
|
| 77 | - if ($uid > 0) { // Si c'est un utlisateur enregistr�, on recherche dans les anciennes commandes pour pr� remplir les champs |
|
| 78 | - $tblCommand = array(); |
|
| 79 | - $critereUser = new Criteria('cmd_uid', $uid, '='); |
|
| 80 | - $critereUser->setSort('cmd_date'); |
|
| 81 | - $critereUser->setOrder('DESC'); |
|
| 82 | - $critereUser->setLimit(1); |
|
| 83 | - $tblCommand = $h_bookshop_commands->getObjects($critereUser, false); |
|
| 84 | - if (count($tblCommand) > 0) { |
|
| 85 | - $notFound = false; |
|
| 86 | - $commande = $tblCommand[0]; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if ($notFound) { |
|
| 91 | - $commande = $h_bookshop_commands->create(true); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL . 'checkout.php', 'post'); |
|
| 95 | - $sform->addElement(new XoopsFormHidden('op', 'paypal')); |
|
| 96 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 97 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 98 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname')), true); |
|
| 99 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname')), false); |
|
| 100 | - $sform->addElement(new XoopsFormTextArea(_BOOKSHOP_STREET, 'cmd_adress', $commande->getVar('cmd_adress'), 3, 50), true); |
|
| 101 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_CP, 'cmd_zip', 5, 30, $commande->getVar('cmd_zip')), true); |
|
| 102 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_CITY, 'cmd_town', 40, 255, $commande->getVar('cmd_town')), true); |
|
| 103 | - $sform->addElement(new XoopsFormSelectCountry(_BOOKSHOP_COUNTRY, 'cmd_country', $commande->getVar('cmd_country')), true); |
|
| 104 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone')), false); |
|
| 105 | - if ($uid > 0) { |
|
| 106 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email')), true); |
|
| 107 | - } else { |
|
| 108 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, ''), true); |
|
| 109 | - } |
|
| 110 | - $sform->addElement(new XoopsFormRadioYN(_BOOKSHOP_INVOICE, 'cmd_bill', 0), true); |
|
| 111 | - |
|
| 112 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 113 | - $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_SAVE, 'submit'); |
|
| 114 | - $button_tray->addElement($submit_btn); |
|
| 115 | - $sform->addElement($button_tray); |
|
| 116 | - |
|
| 117 | - $sform = bookshop_formMarkRequiredFields($sform); |
|
| 118 | - $xoopsTpl->assign('form', $sform->render()); |
|
| 119 | - break; |
|
| 120 | - |
|
| 121 | - // **************************************************************************************************************** |
|
| 122 | - case 'paypal': // Validation finale avant envoi sur Paypal |
|
| 123 | - // **************************************************************************************************************** |
|
| 124 | - if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 125 | - bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 126 | - } |
|
| 127 | - listCart(); |
|
| 128 | - |
|
| 129 | - $password = md5(xoops_makepass()); |
|
| 130 | - $passwordCancel = md5(xoops_makepass()); |
|
| 131 | - $paypal = new bookshop_paypal(bookshop_getmoduleoption('paypal_test'), bookshop_getmoduleoption('paypal_email'), bookshop_getmoduleoption('paypal_money'), true, $passwordCancel); |
|
| 132 | - |
|
| 133 | - $commande = $h_bookshop_commands->create(true); |
|
| 134 | - $commande->setVars($_POST); |
|
| 135 | - $commande->setVar('cmd_uid', $uid); |
|
| 136 | - $commande->setVar('cmd_date', date('Y-m-d')); |
|
| 137 | - $commande->setVar('cmd_state', COMMAND_STATE_NOINFORMATION); |
|
| 138 | - $commande->setVar('cmd_ip', bookshop_IP()); |
|
| 139 | - $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
|
| 140 | - $commande->setVar('cmd_total', $commandAmountTTC); |
|
| 141 | - $commande->setVar('cmd_shipping', $shippingAmount); |
|
| 142 | - $commande->setVar('cmd_password', $password); |
|
| 143 | - $commande->setVar('cmd_cancel', $passwordCancel); |
|
| 144 | - $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
|
| 145 | - $res = $h_bookshop_commands->insert($commande, true); |
|
| 146 | - if (!$res) { // Si la sauvegarde n'a pas fonctionn� |
|
| 147 | - bookshop_redirect(_BOOKSHOP_ERROR10, BOOKSHOP_URL, 6); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Enregistrement du panier |
|
| 151 | - $msgCommande = ''; |
|
| 152 | - foreach ($cartForTemplate as $line) { |
|
| 153 | - $panier = $h_bookshop_caddy->create(true); |
|
| 154 | - $panier->setVar('caddy_book_id', $line['book_id']); |
|
| 155 | - $panier->setVar('caddy_qte', $line['book_qty']); |
|
| 156 | - $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 157 | - $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
|
| 158 | - $panier->setVar('caddy_shipping', $line['book_shipping_amount']); |
|
| 159 | - $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ') . ' ' . str_pad($line['book_qty'] . ' ' . _BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['book_price_ttc'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . ' ' |
|
| 160 | - . str_pad($line['book_shipping_amount'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . "\n"; |
|
| 161 | - $res = $h_bookshop_caddy->insert($panier, true); |
|
| 162 | - } |
|
| 163 | - $msgCommande .= "\n\n" . _BOOKSHOP_SHIPPING_PRICE . ' ' . $shippingAmount . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 164 | - $msgCommande .= _BOOKSHOP_TOTAL . ' ' . $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 165 | - if (count($discountsDescription) > 0) { |
|
| 166 | - $msgCommande .= "\n\n" . _BOOKSHOP_CART4 . "\n"; |
|
| 167 | - $msgCommande .= implode("\n", $discountsDescription); |
|
| 168 | - $msgCommande .= "\n"; |
|
| 169 | - } |
|
| 170 | - $msg = array(); |
|
| 171 | - $msg['COMMANDE'] = $msgCommande; |
|
| 172 | - $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
|
| 173 | - $msg['NOM'] = $commande->getVar('cmd_lastname'); |
|
| 174 | - $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
|
| 175 | - $msg['ADRESSE'] = $commande->getVar('cmd_adress'); |
|
| 176 | - $msg['CP'] = $commande->getVar('cmd_zip'); |
|
| 177 | - $msg['VILLE'] = $commande->getVar('cmd_town'); |
|
| 178 | - $msg['PAYS'] = $tbl_country[$commande->getVar('cmd_country')]; |
|
| 179 | - $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
|
| 180 | - $msg['EMAIL'] = $commande->getVar('cmd_email'); |
|
| 181 | - $msg['URL_BILL'] = BOOKSHOP_URL . 'invoice.php?command=' . $commande->getVar('cmd_id') . '&pass=' . $password; |
|
| 182 | - $msg['IP'] = bookshop_IP(); |
|
| 183 | - if ($commande->getVar('cmd_bill') == 1) { |
|
| 184 | - $msg['FACTURE'] = _YES; |
|
| 185 | - } else { |
|
| 186 | - $msg['FACTURE'] = _NO; |
|
| 187 | - } |
|
| 188 | - // Envoi du mail au client |
|
| 189 | - bookshop_send_email_from_tpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_BOOKSHOP_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
|
| 190 | - // Envoi du mail au groupe de personne devant recevoir le mail |
|
| 191 | - bookshop_send_email_from_tpl('command_shop.tpl', bookshop_getEmailsFromGroup(bookshop_getmoduleoption('grp_sold')), _BOOKSHOP_NEW_COMMAND, $msg); |
|
| 192 | - |
|
| 193 | - // Presentation of the form to send to Paypal |
|
| 194 | - $payURL = $paypal->getURL(); |
|
| 195 | - |
|
| 196 | - // Final presentation with hidden variables basket ****************************** |
|
| 197 | - $sform = new XoopsThemeForm(_BOOKSHOP_PAY_PAYPAL, 'payform', $payURL, 'post'); |
|
| 198 | - $elements = array(); |
|
| 199 | - $elements = $paypal->getFormContent($commande->getVar('cmd_id'), $commandAmountTTC, $commande->getVar('cmd_email')); |
|
| 200 | - foreach ($elements as $key => $value) { |
|
| 201 | - $sform->addElement(new XoopsFormHidden($key, $value)); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 205 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 206 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_LASTNAME, $commande->getVar('cmd_lastname'))); |
|
| 207 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
|
| 208 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_STREET, $commande->getVar('cmd_adress'))); |
|
| 209 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CP, $commande->getVar('cmd_zip'))); |
|
| 210 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CITY, $commande->getVar('cmd_town'))); |
|
| 211 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_COUNTRY, $tbl_country[$commande->getVar('cmd_country')])); |
|
| 212 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_PHONE, $commande->getVar('cmd_telephone'))); |
|
| 213 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_EMAIL, $commande->getVar('cmd_email'))); |
|
| 214 | - |
|
| 215 | - if ($commande->getVar('cmd_bill') == 0) { |
|
| 216 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _NO)); |
|
| 217 | - } else { |
|
| 218 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _YES)); |
|
| 219 | - } |
|
| 220 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 221 | - $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_PAY_PAYPAL, 'submit'); |
|
| 222 | - $button_tray->addElement($submit_btn); |
|
| 223 | - $sform->addElement($button_tray); |
|
| 224 | - $xoopsTpl->assign('form', $sform->render()); |
|
| 225 | - break; |
|
| 68 | + // **************************************************************************************************************** |
|
| 69 | + case 'default': // Submitting Forms |
|
| 70 | + // **************************************************************************************************************** |
|
| 71 | + if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 72 | + bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 73 | + } |
|
| 74 | + listCart(); |
|
| 75 | + $notFound = true; |
|
| 76 | + |
|
| 77 | + if ($uid > 0) { // Si c'est un utlisateur enregistr�, on recherche dans les anciennes commandes pour pr� remplir les champs |
|
| 78 | + $tblCommand = array(); |
|
| 79 | + $critereUser = new Criteria('cmd_uid', $uid, '='); |
|
| 80 | + $critereUser->setSort('cmd_date'); |
|
| 81 | + $critereUser->setOrder('DESC'); |
|
| 82 | + $critereUser->setLimit(1); |
|
| 83 | + $tblCommand = $h_bookshop_commands->getObjects($critereUser, false); |
|
| 84 | + if (count($tblCommand) > 0) { |
|
| 85 | + $notFound = false; |
|
| 86 | + $commande = $tblCommand[0]; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if ($notFound) { |
|
| 91 | + $commande = $h_bookshop_commands->create(true); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL . 'checkout.php', 'post'); |
|
| 95 | + $sform->addElement(new XoopsFormHidden('op', 'paypal')); |
|
| 96 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 97 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 98 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname')), true); |
|
| 99 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname')), false); |
|
| 100 | + $sform->addElement(new XoopsFormTextArea(_BOOKSHOP_STREET, 'cmd_adress', $commande->getVar('cmd_adress'), 3, 50), true); |
|
| 101 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_CP, 'cmd_zip', 5, 30, $commande->getVar('cmd_zip')), true); |
|
| 102 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_CITY, 'cmd_town', 40, 255, $commande->getVar('cmd_town')), true); |
|
| 103 | + $sform->addElement(new XoopsFormSelectCountry(_BOOKSHOP_COUNTRY, 'cmd_country', $commande->getVar('cmd_country')), true); |
|
| 104 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone')), false); |
|
| 105 | + if ($uid > 0) { |
|
| 106 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email')), true); |
|
| 107 | + } else { |
|
| 108 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, ''), true); |
|
| 109 | + } |
|
| 110 | + $sform->addElement(new XoopsFormRadioYN(_BOOKSHOP_INVOICE, 'cmd_bill', 0), true); |
|
| 111 | + |
|
| 112 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 113 | + $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_SAVE, 'submit'); |
|
| 114 | + $button_tray->addElement($submit_btn); |
|
| 115 | + $sform->addElement($button_tray); |
|
| 116 | + |
|
| 117 | + $sform = bookshop_formMarkRequiredFields($sform); |
|
| 118 | + $xoopsTpl->assign('form', $sform->render()); |
|
| 119 | + break; |
|
| 120 | + |
|
| 121 | + // **************************************************************************************************************** |
|
| 122 | + case 'paypal': // Validation finale avant envoi sur Paypal |
|
| 123 | + // **************************************************************************************************************** |
|
| 124 | + if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 125 | + bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 126 | + } |
|
| 127 | + listCart(); |
|
| 128 | + |
|
| 129 | + $password = md5(xoops_makepass()); |
|
| 130 | + $passwordCancel = md5(xoops_makepass()); |
|
| 131 | + $paypal = new bookshop_paypal(bookshop_getmoduleoption('paypal_test'), bookshop_getmoduleoption('paypal_email'), bookshop_getmoduleoption('paypal_money'), true, $passwordCancel); |
|
| 132 | + |
|
| 133 | + $commande = $h_bookshop_commands->create(true); |
|
| 134 | + $commande->setVars($_POST); |
|
| 135 | + $commande->setVar('cmd_uid', $uid); |
|
| 136 | + $commande->setVar('cmd_date', date('Y-m-d')); |
|
| 137 | + $commande->setVar('cmd_state', COMMAND_STATE_NOINFORMATION); |
|
| 138 | + $commande->setVar('cmd_ip', bookshop_IP()); |
|
| 139 | + $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
|
| 140 | + $commande->setVar('cmd_total', $commandAmountTTC); |
|
| 141 | + $commande->setVar('cmd_shipping', $shippingAmount); |
|
| 142 | + $commande->setVar('cmd_password', $password); |
|
| 143 | + $commande->setVar('cmd_cancel', $passwordCancel); |
|
| 144 | + $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
|
| 145 | + $res = $h_bookshop_commands->insert($commande, true); |
|
| 146 | + if (!$res) { // Si la sauvegarde n'a pas fonctionn� |
|
| 147 | + bookshop_redirect(_BOOKSHOP_ERROR10, BOOKSHOP_URL, 6); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Enregistrement du panier |
|
| 151 | + $msgCommande = ''; |
|
| 152 | + foreach ($cartForTemplate as $line) { |
|
| 153 | + $panier = $h_bookshop_caddy->create(true); |
|
| 154 | + $panier->setVar('caddy_book_id', $line['book_id']); |
|
| 155 | + $panier->setVar('caddy_qte', $line['book_qty']); |
|
| 156 | + $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 157 | + $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
|
| 158 | + $panier->setVar('caddy_shipping', $line['book_shipping_amount']); |
|
| 159 | + $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ') . ' ' . str_pad($line['book_qty'] . ' ' . _BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['book_price_ttc'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . ' ' |
|
| 160 | + . str_pad($line['book_shipping_amount'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . "\n"; |
|
| 161 | + $res = $h_bookshop_caddy->insert($panier, true); |
|
| 162 | + } |
|
| 163 | + $msgCommande .= "\n\n" . _BOOKSHOP_SHIPPING_PRICE . ' ' . $shippingAmount . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 164 | + $msgCommande .= _BOOKSHOP_TOTAL . ' ' . $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 165 | + if (count($discountsDescription) > 0) { |
|
| 166 | + $msgCommande .= "\n\n" . _BOOKSHOP_CART4 . "\n"; |
|
| 167 | + $msgCommande .= implode("\n", $discountsDescription); |
|
| 168 | + $msgCommande .= "\n"; |
|
| 169 | + } |
|
| 170 | + $msg = array(); |
|
| 171 | + $msg['COMMANDE'] = $msgCommande; |
|
| 172 | + $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
|
| 173 | + $msg['NOM'] = $commande->getVar('cmd_lastname'); |
|
| 174 | + $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
|
| 175 | + $msg['ADRESSE'] = $commande->getVar('cmd_adress'); |
|
| 176 | + $msg['CP'] = $commande->getVar('cmd_zip'); |
|
| 177 | + $msg['VILLE'] = $commande->getVar('cmd_town'); |
|
| 178 | + $msg['PAYS'] = $tbl_country[$commande->getVar('cmd_country')]; |
|
| 179 | + $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
|
| 180 | + $msg['EMAIL'] = $commande->getVar('cmd_email'); |
|
| 181 | + $msg['URL_BILL'] = BOOKSHOP_URL . 'invoice.php?command=' . $commande->getVar('cmd_id') . '&pass=' . $password; |
|
| 182 | + $msg['IP'] = bookshop_IP(); |
|
| 183 | + if ($commande->getVar('cmd_bill') == 1) { |
|
| 184 | + $msg['FACTURE'] = _YES; |
|
| 185 | + } else { |
|
| 186 | + $msg['FACTURE'] = _NO; |
|
| 187 | + } |
|
| 188 | + // Envoi du mail au client |
|
| 189 | + bookshop_send_email_from_tpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_BOOKSHOP_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
|
| 190 | + // Envoi du mail au groupe de personne devant recevoir le mail |
|
| 191 | + bookshop_send_email_from_tpl('command_shop.tpl', bookshop_getEmailsFromGroup(bookshop_getmoduleoption('grp_sold')), _BOOKSHOP_NEW_COMMAND, $msg); |
|
| 192 | + |
|
| 193 | + // Presentation of the form to send to Paypal |
|
| 194 | + $payURL = $paypal->getURL(); |
|
| 195 | + |
|
| 196 | + // Final presentation with hidden variables basket ****************************** |
|
| 197 | + $sform = new XoopsThemeForm(_BOOKSHOP_PAY_PAYPAL, 'payform', $payURL, 'post'); |
|
| 198 | + $elements = array(); |
|
| 199 | + $elements = $paypal->getFormContent($commande->getVar('cmd_id'), $commandAmountTTC, $commande->getVar('cmd_email')); |
|
| 200 | + foreach ($elements as $key => $value) { |
|
| 201 | + $sform->addElement(new XoopsFormHidden($key, $value)); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 205 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 206 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_LASTNAME, $commande->getVar('cmd_lastname'))); |
|
| 207 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
|
| 208 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_STREET, $commande->getVar('cmd_adress'))); |
|
| 209 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CP, $commande->getVar('cmd_zip'))); |
|
| 210 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CITY, $commande->getVar('cmd_town'))); |
|
| 211 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_COUNTRY, $tbl_country[$commande->getVar('cmd_country')])); |
|
| 212 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_PHONE, $commande->getVar('cmd_telephone'))); |
|
| 213 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_EMAIL, $commande->getVar('cmd_email'))); |
|
| 214 | + |
|
| 215 | + if ($commande->getVar('cmd_bill') == 0) { |
|
| 216 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _NO)); |
|
| 217 | + } else { |
|
| 218 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _YES)); |
|
| 219 | + } |
|
| 220 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 221 | + $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_PAY_PAYPAL, 'submit'); |
|
| 222 | + $button_tray->addElement($submit_btn); |
|
| 223 | + $sform->addElement($button_tray); |
|
| 224 | + $xoopsTpl->assign('form', $sform->render()); |
|
| 225 | + break; |
|
| 226 | 226 | } |
| 227 | 227 | $title = _BOOKSHOP_VALIDATE_CMD . ' - ' . bookshop_get_module_name(); |
| 228 | 228 | bookshop_set_metas($title, $title); |
@@ -66,163 +66,163 @@ |
||
| 66 | 66 | |
| 67 | 67 | switch ($op) { |
| 68 | 68 | // **************************************************************************************************************** |
| 69 | - case 'default': // Submitting Forms |
|
| 70 | - // **************************************************************************************************************** |
|
| 71 | - if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 72 | - bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 73 | - } |
|
| 74 | - listCart(); |
|
| 75 | - $notFound = true; |
|
| 76 | - |
|
| 77 | - if ($uid > 0) { // Si c'est un utlisateur enregistr�, on recherche dans les anciennes commandes pour pr� remplir les champs |
|
| 78 | - $tblCommand = array(); |
|
| 79 | - $critereUser = new Criteria('cmd_uid', $uid, '='); |
|
| 80 | - $critereUser->setSort('cmd_date'); |
|
| 81 | - $critereUser->setOrder('DESC'); |
|
| 82 | - $critereUser->setLimit(1); |
|
| 83 | - $tblCommand = $h_bookshop_commands->getObjects($critereUser, false); |
|
| 84 | - if (count($tblCommand) > 0) { |
|
| 85 | - $notFound = false; |
|
| 86 | - $commande = $tblCommand[0]; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if ($notFound) { |
|
| 91 | - $commande = $h_bookshop_commands->create(true); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL . 'checkout.php', 'post'); |
|
| 95 | - $sform->addElement(new XoopsFormHidden('op', 'paypal')); |
|
| 96 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 97 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 98 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname')), true); |
|
| 99 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname')), false); |
|
| 100 | - $sform->addElement(new XoopsFormTextArea(_BOOKSHOP_STREET, 'cmd_adress', $commande->getVar('cmd_adress'), 3, 50), true); |
|
| 101 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_CP, 'cmd_zip', 5, 30, $commande->getVar('cmd_zip')), true); |
|
| 102 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_CITY, 'cmd_town', 40, 255, $commande->getVar('cmd_town')), true); |
|
| 103 | - $sform->addElement(new XoopsFormSelectCountry(_BOOKSHOP_COUNTRY, 'cmd_country', $commande->getVar('cmd_country')), true); |
|
| 104 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone')), false); |
|
| 105 | - if ($uid > 0) { |
|
| 106 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email')), true); |
|
| 107 | - } else { |
|
| 108 | - $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, ''), true); |
|
| 109 | - } |
|
| 110 | - $sform->addElement(new XoopsFormRadioYN(_BOOKSHOP_INVOICE, 'cmd_bill', 0), true); |
|
| 111 | - |
|
| 112 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 113 | - $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_SAVE, 'submit'); |
|
| 114 | - $button_tray->addElement($submit_btn); |
|
| 115 | - $sform->addElement($button_tray); |
|
| 116 | - |
|
| 117 | - $sform = bookshop_formMarkRequiredFields($sform); |
|
| 118 | - $xoopsTpl->assign('form', $sform->render()); |
|
| 119 | - break; |
|
| 120 | - |
|
| 121 | - // **************************************************************************************************************** |
|
| 122 | - case 'paypal': // Validation finale avant envoi sur Paypal |
|
| 123 | - // **************************************************************************************************************** |
|
| 124 | - if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 125 | - bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 126 | - } |
|
| 127 | - listCart(); |
|
| 128 | - |
|
| 129 | - $password = md5(xoops_makepass()); |
|
| 130 | - $passwordCancel = md5(xoops_makepass()); |
|
| 131 | - $paypal = new bookshop_paypal(bookshop_getmoduleoption('paypal_test'), bookshop_getmoduleoption('paypal_email'), bookshop_getmoduleoption('paypal_money'), true, $passwordCancel); |
|
| 132 | - |
|
| 133 | - $commande = $h_bookshop_commands->create(true); |
|
| 134 | - $commande->setVars($_POST); |
|
| 135 | - $commande->setVar('cmd_uid', $uid); |
|
| 136 | - $commande->setVar('cmd_date', date('Y-m-d')); |
|
| 137 | - $commande->setVar('cmd_state', COMMAND_STATE_NOINFORMATION); |
|
| 138 | - $commande->setVar('cmd_ip', bookshop_IP()); |
|
| 139 | - $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
|
| 140 | - $commande->setVar('cmd_total', $commandAmountTTC); |
|
| 141 | - $commande->setVar('cmd_shipping', $shippingAmount); |
|
| 142 | - $commande->setVar('cmd_password', $password); |
|
| 143 | - $commande->setVar('cmd_cancel', $passwordCancel); |
|
| 144 | - $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
|
| 145 | - $res = $h_bookshop_commands->insert($commande, true); |
|
| 146 | - if (!$res) { // Si la sauvegarde n'a pas fonctionn� |
|
| 147 | - bookshop_redirect(_BOOKSHOP_ERROR10, BOOKSHOP_URL, 6); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Enregistrement du panier |
|
| 151 | - $msgCommande = ''; |
|
| 152 | - foreach ($cartForTemplate as $line) { |
|
| 153 | - $panier = $h_bookshop_caddy->create(true); |
|
| 154 | - $panier->setVar('caddy_book_id', $line['book_id']); |
|
| 155 | - $panier->setVar('caddy_qte', $line['book_qty']); |
|
| 156 | - $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 157 | - $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
|
| 158 | - $panier->setVar('caddy_shipping', $line['book_shipping_amount']); |
|
| 159 | - $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ') . ' ' . str_pad($line['book_qty'] . ' ' . _BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['book_price_ttc'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . ' ' |
|
| 160 | - . str_pad($line['book_shipping_amount'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . "\n"; |
|
| 161 | - $res = $h_bookshop_caddy->insert($panier, true); |
|
| 162 | - } |
|
| 163 | - $msgCommande .= "\n\n" . _BOOKSHOP_SHIPPING_PRICE . ' ' . $shippingAmount . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 164 | - $msgCommande .= _BOOKSHOP_TOTAL . ' ' . $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 165 | - if (count($discountsDescription) > 0) { |
|
| 166 | - $msgCommande .= "\n\n" . _BOOKSHOP_CART4 . "\n"; |
|
| 167 | - $msgCommande .= implode("\n", $discountsDescription); |
|
| 168 | - $msgCommande .= "\n"; |
|
| 169 | - } |
|
| 170 | - $msg = array(); |
|
| 171 | - $msg['COMMANDE'] = $msgCommande; |
|
| 172 | - $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
|
| 173 | - $msg['NOM'] = $commande->getVar('cmd_lastname'); |
|
| 174 | - $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
|
| 175 | - $msg['ADRESSE'] = $commande->getVar('cmd_adress'); |
|
| 176 | - $msg['CP'] = $commande->getVar('cmd_zip'); |
|
| 177 | - $msg['VILLE'] = $commande->getVar('cmd_town'); |
|
| 178 | - $msg['PAYS'] = $tbl_country[$commande->getVar('cmd_country')]; |
|
| 179 | - $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
|
| 180 | - $msg['EMAIL'] = $commande->getVar('cmd_email'); |
|
| 181 | - $msg['URL_BILL'] = BOOKSHOP_URL . 'invoice.php?command=' . $commande->getVar('cmd_id') . '&pass=' . $password; |
|
| 182 | - $msg['IP'] = bookshop_IP(); |
|
| 183 | - if ($commande->getVar('cmd_bill') == 1) { |
|
| 184 | - $msg['FACTURE'] = _YES; |
|
| 185 | - } else { |
|
| 186 | - $msg['FACTURE'] = _NO; |
|
| 187 | - } |
|
| 188 | - // Envoi du mail au client |
|
| 189 | - bookshop_send_email_from_tpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_BOOKSHOP_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
|
| 190 | - // Envoi du mail au groupe de personne devant recevoir le mail |
|
| 191 | - bookshop_send_email_from_tpl('command_shop.tpl', bookshop_getEmailsFromGroup(bookshop_getmoduleoption('grp_sold')), _BOOKSHOP_NEW_COMMAND, $msg); |
|
| 192 | - |
|
| 193 | - // Presentation of the form to send to Paypal |
|
| 194 | - $payURL = $paypal->getURL(); |
|
| 195 | - |
|
| 196 | - // Final presentation with hidden variables basket ****************************** |
|
| 197 | - $sform = new XoopsThemeForm(_BOOKSHOP_PAY_PAYPAL, 'payform', $payURL, 'post'); |
|
| 198 | - $elements = array(); |
|
| 199 | - $elements = $paypal->getFormContent($commande->getVar('cmd_id'), $commandAmountTTC, $commande->getVar('cmd_email')); |
|
| 200 | - foreach ($elements as $key => $value) { |
|
| 201 | - $sform->addElement(new XoopsFormHidden($key, $value)); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 205 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 206 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_LASTNAME, $commande->getVar('cmd_lastname'))); |
|
| 207 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
|
| 208 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_STREET, $commande->getVar('cmd_adress'))); |
|
| 209 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CP, $commande->getVar('cmd_zip'))); |
|
| 210 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CITY, $commande->getVar('cmd_town'))); |
|
| 211 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_COUNTRY, $tbl_country[$commande->getVar('cmd_country')])); |
|
| 212 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_PHONE, $commande->getVar('cmd_telephone'))); |
|
| 213 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_EMAIL, $commande->getVar('cmd_email'))); |
|
| 214 | - |
|
| 215 | - if ($commande->getVar('cmd_bill') == 0) { |
|
| 216 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _NO)); |
|
| 217 | - } else { |
|
| 218 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _YES)); |
|
| 219 | - } |
|
| 220 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 221 | - $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_PAY_PAYPAL, 'submit'); |
|
| 222 | - $button_tray->addElement($submit_btn); |
|
| 223 | - $sform->addElement($button_tray); |
|
| 224 | - $xoopsTpl->assign('form', $sform->render()); |
|
| 225 | - break; |
|
| 69 | + case 'default': // Submitting Forms |
|
| 70 | + // **************************************************************************************************************** |
|
| 71 | + if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 72 | + bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 73 | + } |
|
| 74 | + listCart(); |
|
| 75 | + $notFound = true; |
|
| 76 | + |
|
| 77 | + if ($uid > 0) { // Si c'est un utlisateur enregistr�, on recherche dans les anciennes commandes pour pr� remplir les champs |
|
| 78 | + $tblCommand = array(); |
|
| 79 | + $critereUser = new Criteria('cmd_uid', $uid, '='); |
|
| 80 | + $critereUser->setSort('cmd_date'); |
|
| 81 | + $critereUser->setOrder('DESC'); |
|
| 82 | + $critereUser->setLimit(1); |
|
| 83 | + $tblCommand = $h_bookshop_commands->getObjects($critereUser, false); |
|
| 84 | + if (count($tblCommand) > 0) { |
|
| 85 | + $notFound = false; |
|
| 86 | + $commande = $tblCommand[0]; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if ($notFound) { |
|
| 91 | + $commande = $h_bookshop_commands->create(true); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL . 'checkout.php', 'post'); |
|
| 95 | + $sform->addElement(new XoopsFormHidden('op', 'paypal')); |
|
| 96 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 97 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 98 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname')), true); |
|
| 99 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname')), false); |
|
| 100 | + $sform->addElement(new XoopsFormTextArea(_BOOKSHOP_STREET, 'cmd_adress', $commande->getVar('cmd_adress'), 3, 50), true); |
|
| 101 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_CP, 'cmd_zip', 5, 30, $commande->getVar('cmd_zip')), true); |
|
| 102 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_CITY, 'cmd_town', 40, 255, $commande->getVar('cmd_town')), true); |
|
| 103 | + $sform->addElement(new XoopsFormSelectCountry(_BOOKSHOP_COUNTRY, 'cmd_country', $commande->getVar('cmd_country')), true); |
|
| 104 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone')), false); |
|
| 105 | + if ($uid > 0) { |
|
| 106 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email')), true); |
|
| 107 | + } else { |
|
| 108 | + $sform->addElement(new XoopsFormText(_BOOKSHOP_EMAIL, 'cmd_email', 50, 255, ''), true); |
|
| 109 | + } |
|
| 110 | + $sform->addElement(new XoopsFormRadioYN(_BOOKSHOP_INVOICE, 'cmd_bill', 0), true); |
|
| 111 | + |
|
| 112 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 113 | + $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_SAVE, 'submit'); |
|
| 114 | + $button_tray->addElement($submit_btn); |
|
| 115 | + $sform->addElement($button_tray); |
|
| 116 | + |
|
| 117 | + $sform = bookshop_formMarkRequiredFields($sform); |
|
| 118 | + $xoopsTpl->assign('form', $sform->render()); |
|
| 119 | + break; |
|
| 120 | + |
|
| 121 | + // **************************************************************************************************************** |
|
| 122 | + case 'paypal': // Validation finale avant envoi sur Paypal |
|
| 123 | + // **************************************************************************************************************** |
|
| 124 | + if ($h_bookshop_caddy->isCartEmpty()) { |
|
| 125 | + bookshop_redirect(_BOOKSHOP_CART_IS_EMPTY, BOOKSHOP_URL, 4); |
|
| 126 | + } |
|
| 127 | + listCart(); |
|
| 128 | + |
|
| 129 | + $password = md5(xoops_makepass()); |
|
| 130 | + $passwordCancel = md5(xoops_makepass()); |
|
| 131 | + $paypal = new bookshop_paypal(bookshop_getmoduleoption('paypal_test'), bookshop_getmoduleoption('paypal_email'), bookshop_getmoduleoption('paypal_money'), true, $passwordCancel); |
|
| 132 | + |
|
| 133 | + $commande = $h_bookshop_commands->create(true); |
|
| 134 | + $commande->setVars($_POST); |
|
| 135 | + $commande->setVar('cmd_uid', $uid); |
|
| 136 | + $commande->setVar('cmd_date', date('Y-m-d')); |
|
| 137 | + $commande->setVar('cmd_state', COMMAND_STATE_NOINFORMATION); |
|
| 138 | + $commande->setVar('cmd_ip', bookshop_IP()); |
|
| 139 | + $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
|
| 140 | + $commande->setVar('cmd_total', $commandAmountTTC); |
|
| 141 | + $commande->setVar('cmd_shipping', $shippingAmount); |
|
| 142 | + $commande->setVar('cmd_password', $password); |
|
| 143 | + $commande->setVar('cmd_cancel', $passwordCancel); |
|
| 144 | + $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
|
| 145 | + $res = $h_bookshop_commands->insert($commande, true); |
|
| 146 | + if (!$res) { // Si la sauvegarde n'a pas fonctionn� |
|
| 147 | + bookshop_redirect(_BOOKSHOP_ERROR10, BOOKSHOP_URL, 6); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Enregistrement du panier |
|
| 151 | + $msgCommande = ''; |
|
| 152 | + foreach ($cartForTemplate as $line) { |
|
| 153 | + $panier = $h_bookshop_caddy->create(true); |
|
| 154 | + $panier->setVar('caddy_book_id', $line['book_id']); |
|
| 155 | + $panier->setVar('caddy_qte', $line['book_qty']); |
|
| 156 | + $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 157 | + $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
|
| 158 | + $panier->setVar('caddy_shipping', $line['book_shipping_amount']); |
|
| 159 | + $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ') . ' ' . str_pad($line['book_qty'] . ' ' . _BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['book_price_ttc'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . ' ' |
|
| 160 | + . str_pad($line['book_shipping_amount'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . "\n"; |
|
| 161 | + $res = $h_bookshop_caddy->insert($panier, true); |
|
| 162 | + } |
|
| 163 | + $msgCommande .= "\n\n" . _BOOKSHOP_SHIPPING_PRICE . ' ' . $shippingAmount . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 164 | + $msgCommande .= _BOOKSHOP_TOTAL . ' ' . $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 165 | + if (count($discountsDescription) > 0) { |
|
| 166 | + $msgCommande .= "\n\n" . _BOOKSHOP_CART4 . "\n"; |
|
| 167 | + $msgCommande .= implode("\n", $discountsDescription); |
|
| 168 | + $msgCommande .= "\n"; |
|
| 169 | + } |
|
| 170 | + $msg = array(); |
|
| 171 | + $msg['COMMANDE'] = $msgCommande; |
|
| 172 | + $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
|
| 173 | + $msg['NOM'] = $commande->getVar('cmd_lastname'); |
|
| 174 | + $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
|
| 175 | + $msg['ADRESSE'] = $commande->getVar('cmd_adress'); |
|
| 176 | + $msg['CP'] = $commande->getVar('cmd_zip'); |
|
| 177 | + $msg['VILLE'] = $commande->getVar('cmd_town'); |
|
| 178 | + $msg['PAYS'] = $tbl_country[$commande->getVar('cmd_country')]; |
|
| 179 | + $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
|
| 180 | + $msg['EMAIL'] = $commande->getVar('cmd_email'); |
|
| 181 | + $msg['URL_BILL'] = BOOKSHOP_URL . 'invoice.php?command=' . $commande->getVar('cmd_id') . '&pass=' . $password; |
|
| 182 | + $msg['IP'] = bookshop_IP(); |
|
| 183 | + if ($commande->getVar('cmd_bill') == 1) { |
|
| 184 | + $msg['FACTURE'] = _YES; |
|
| 185 | + } else { |
|
| 186 | + $msg['FACTURE'] = _NO; |
|
| 187 | + } |
|
| 188 | + // Envoi du mail au client |
|
| 189 | + bookshop_send_email_from_tpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_BOOKSHOP_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
|
| 190 | + // Envoi du mail au groupe de personne devant recevoir le mail |
|
| 191 | + bookshop_send_email_from_tpl('command_shop.tpl', bookshop_getEmailsFromGroup(bookshop_getmoduleoption('grp_sold')), _BOOKSHOP_NEW_COMMAND, $msg); |
|
| 192 | + |
|
| 193 | + // Presentation of the form to send to Paypal |
|
| 194 | + $payURL = $paypal->getURL(); |
|
| 195 | + |
|
| 196 | + // Final presentation with hidden variables basket ****************************** |
|
| 197 | + $sform = new XoopsThemeForm(_BOOKSHOP_PAY_PAYPAL, 'payform', $payURL, 'post'); |
|
| 198 | + $elements = array(); |
|
| 199 | + $elements = $paypal->getFormContent($commande->getVar('cmd_id'), $commandAmountTTC, $commande->getVar('cmd_email')); |
|
| 200 | + foreach ($elements as $key => $value) { |
|
| 201 | + $sform->addElement(new XoopsFormHidden($key, $value)); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 205 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 206 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_LASTNAME, $commande->getVar('cmd_lastname'))); |
|
| 207 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
|
| 208 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_STREET, $commande->getVar('cmd_adress'))); |
|
| 209 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CP, $commande->getVar('cmd_zip'))); |
|
| 210 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_CITY, $commande->getVar('cmd_town'))); |
|
| 211 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_COUNTRY, $tbl_country[$commande->getVar('cmd_country')])); |
|
| 212 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_PHONE, $commande->getVar('cmd_telephone'))); |
|
| 213 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_EMAIL, $commande->getVar('cmd_email'))); |
|
| 214 | + |
|
| 215 | + if ($commande->getVar('cmd_bill') == 0) { |
|
| 216 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _NO)); |
|
| 217 | + } else { |
|
| 218 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_INVOICE, _YES)); |
|
| 219 | + } |
|
| 220 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 221 | + $submit_btn = new XoopsFormButton('', 'post', _BOOKSHOP_PAY_PAYPAL, 'submit'); |
|
| 222 | + $button_tray->addElement($submit_btn); |
|
| 223 | + $sform->addElement($button_tray); |
|
| 224 | + $xoopsTpl->assign('form', $sform->render()); |
|
| 225 | + break; |
|
| 226 | 226 | } |
| 227 | 227 | $title = _BOOKSHOP_VALIDATE_CMD . ' - ' . bookshop_get_module_name(); |
| 228 | 228 | bookshop_set_metas($title, $title); |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * Entering Customer Data + display information entered for validation with redirection to Paypal |
| 28 | 28 | */ |
| 29 | -include __DIR__ . '/header.php'; |
|
| 29 | +include __DIR__.'/header.php'; |
|
| 30 | 30 | $GLOBALS['current_category'] = -1; |
| 31 | 31 | $xoopsOption['template_main'] = 'bookshop_command.tpl'; |
| 32 | -include_once XOOPS_ROOT_PATH . '/header.php'; |
|
| 33 | -include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
| 34 | -include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 35 | -include_once BOOKSHOP_PATH . 'class/bookshop_paypal.php'; |
|
| 32 | +include_once XOOPS_ROOT_PATH.'/header.php'; |
|
| 33 | +include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
| 34 | +include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
| 35 | +include_once BOOKSHOP_PATH.'class/bookshop_paypal.php'; |
|
| 36 | 36 | |
| 37 | 37 | $op = 'default'; |
| 38 | 38 | if (isset($_POST['op'])) { |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | global $h_bookshop_caddy, $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription; |
| 52 | 52 | $h_bookshop_caddy->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription); |
| 53 | 53 | $dec = bookshop_getmoduleoption('decimals_count'); |
| 54 | - $shippingAmount = sprintf('%0.' . $dec . 'f', $shippingAmount); // Amount of postage |
|
| 55 | - $commandAmount = sprintf('%0.' . $dec . 'f', $commandAmount); // Amount HT command |
|
| 56 | - $vatAmount = sprintf('%0.' . $dec . 'f', $vatAmount); // Amount of VAT |
|
| 57 | - $commandAmountTTC = sprintf('%0.' . $dec . 'f', $commandAmountTTC); // Amount TTC of the order (shipping included) |
|
| 54 | + $shippingAmount = sprintf('%0.'.$dec.'f', $shippingAmount); // Amount of postage |
|
| 55 | + $commandAmount = sprintf('%0.'.$dec.'f', $commandAmount); // Amount HT command |
|
| 56 | + $vatAmount = sprintf('%0.'.$dec.'f', $vatAmount); // Amount of VAT |
|
| 57 | + $commandAmountTTC = sprintf('%0.'.$dec.'f', $commandAmountTTC); // Amount TTC of the order (shipping included) |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $tbl_country = XoopsLists::getCountryList(); |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | $commande = $h_bookshop_commands->create(true); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL . 'checkout.php', 'post'); |
|
| 94 | + $sform = new XoopsThemeForm(_BOOKSHOP_PLEASE_ENTER, 'informationfrm', BOOKSHOP_URL.'checkout.php', 'post'); |
|
| 95 | 95 | $sform->addElement(new XoopsFormHidden('op', 'paypal')); |
| 96 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 97 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 96 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC.' '.bookshop_getmoduleoption('money_full'))); |
|
| 97 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount.' '.bookshop_getmoduleoption('money_full'))); |
|
| 98 | 98 | $sform->addElement(new XoopsFormText(_BOOKSHOP_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname')), true); |
| 99 | 99 | $sform->addElement(new XoopsFormText(_BOOKSHOP_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname')), false); |
| 100 | 100 | $sform->addElement(new XoopsFormTextArea(_BOOKSHOP_STREET, 'cmd_adress', $commande->getVar('cmd_adress'), 3, 50), true); |
@@ -153,17 +153,17 @@ discard block |
||
| 153 | 153 | $panier = $h_bookshop_caddy->create(true); |
| 154 | 154 | $panier->setVar('caddy_book_id', $line['book_id']); |
| 155 | 155 | $panier->setVar('caddy_qte', $line['book_qty']); |
| 156 | - $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 156 | + $panier->setVar('caddy_price', $line['book_price_ttc']); // Attention, prix TTC |
|
| 157 | 157 | $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
| 158 | 158 | $panier->setVar('caddy_shipping', $line['book_shipping_amount']); |
| 159 | - $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ') . ' ' . str_pad($line['book_qty'] . ' ' . _BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['book_price_ttc'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . ' ' |
|
| 160 | - . str_pad($line['book_shipping_amount'] . ' ' . bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT) . "\n"; |
|
| 159 | + $msgCommande .= str_pad(wordwrap($line['book_title'], 60), 60, ' ').' '.str_pad($line['book_qty'].' '._BOOKSHOP_COPY_COUNT, 8, ' ', STR_PAD_LEFT).' '.str_pad($line['book_price_ttc'].' '.bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT).' ' |
|
| 160 | + . str_pad($line['book_shipping_amount'].' '.bookshop_getmoduleoption('money_short'), 10, ' ', STR_PAD_LEFT)."\n"; |
|
| 161 | 161 | $res = $h_bookshop_caddy->insert($panier, true); |
| 162 | 162 | } |
| 163 | - $msgCommande .= "\n\n" . _BOOKSHOP_SHIPPING_PRICE . ' ' . $shippingAmount . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 164 | - $msgCommande .= _BOOKSHOP_TOTAL . ' ' . $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full') . "\n"; |
|
| 163 | + $msgCommande .= "\n\n"._BOOKSHOP_SHIPPING_PRICE.' '.$shippingAmount.' '.bookshop_getmoduleoption('money_full')."\n"; |
|
| 164 | + $msgCommande .= _BOOKSHOP_TOTAL.' '.$commandAmountTTC.' '.bookshop_getmoduleoption('money_full')."\n"; |
|
| 165 | 165 | if (count($discountsDescription) > 0) { |
| 166 | - $msgCommande .= "\n\n" . _BOOKSHOP_CART4 . "\n"; |
|
| 166 | + $msgCommande .= "\n\n"._BOOKSHOP_CART4."\n"; |
|
| 167 | 167 | $msgCommande .= implode("\n", $discountsDescription); |
| 168 | 168 | $msgCommande .= "\n"; |
| 169 | 169 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $msg['PAYS'] = $tbl_country[$commande->getVar('cmd_country')]; |
| 179 | 179 | $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
| 180 | 180 | $msg['EMAIL'] = $commande->getVar('cmd_email'); |
| 181 | - $msg['URL_BILL'] = BOOKSHOP_URL . 'invoice.php?command=' . $commande->getVar('cmd_id') . '&pass=' . $password; |
|
| 181 | + $msg['URL_BILL'] = BOOKSHOP_URL.'invoice.php?command='.$commande->getVar('cmd_id').'&pass='.$password; |
|
| 182 | 182 | $msg['IP'] = bookshop_IP(); |
| 183 | 183 | if ($commande->getVar('cmd_bill') == 1) { |
| 184 | 184 | $msg['FACTURE'] = _YES; |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | $sform->addElement(new XoopsFormHidden($key, $value)); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 205 | - $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount . ' ' . bookshop_getmoduleoption('money_full'))); |
|
| 204 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_TOTAL, $commandAmountTTC.' '.bookshop_getmoduleoption('money_full'))); |
|
| 205 | + $sform->addElement(new XoopsFormLabel(_BOOKSHOP_SHIPPING_PRICE, $shippingAmount.' '.bookshop_getmoduleoption('money_full'))); |
|
| 206 | 206 | $sform->addElement(new XoopsFormLabel(_BOOKSHOP_LASTNAME, $commande->getVar('cmd_lastname'))); |
| 207 | 207 | $sform->addElement(new XoopsFormLabel(_BOOKSHOP_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
| 208 | 208 | $sform->addElement(new XoopsFormLabel(_BOOKSHOP_STREET, $commande->getVar('cmd_adress'))); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $xoopsTpl->assign('form', $sform->render()); |
| 225 | 225 | break; |
| 226 | 226 | } |
| 227 | -$title = _BOOKSHOP_VALIDATE_CMD . ' - ' . bookshop_get_module_name(); |
|
| 227 | +$title = _BOOKSHOP_VALIDATE_CMD.' - '.bookshop_get_module_name(); |
|
| 228 | 228 | bookshop_set_metas($title, $title); |
| 229 | 229 | bookshop_setCSS(); |
| 230 | -include_once(XOOPS_ROOT_PATH . '/footer.php'); |
|
| 230 | +include_once(XOOPS_ROOT_PATH.'/footer.php'); |
|
@@ -15,102 +15,102 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function b_bookshop_recomm_show($options) |
| 17 | 17 | { |
| 18 | - // '10|0'; // See 10 books, for all categories or a particular category |
|
| 19 | - global $xoopsConfig, $xoopsTpl; |
|
| 20 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 21 | - $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
|
| 22 | - $tblLivres = $h_bookshop_books->getRecentRecommendedBooks(0, $options[0], $options[1]); |
|
| 23 | - if ($h_bookshop_books->getRecommendedCount() > $options[0]) { // Il y a plus de livres recommand�s dans la BDD que dans le bloc, on affiche donc un lien vers la page des livres recommand�s |
|
| 24 | - $block['showMore'] = true; |
|
| 25 | - } |
|
| 18 | + // '10|0'; // See 10 books, for all categories or a particular category |
|
| 19 | + global $xoopsConfig, $xoopsTpl; |
|
| 20 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 21 | + $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
|
| 22 | + $tblLivres = $h_bookshop_books->getRecentRecommendedBooks(0, $options[0], $options[1]); |
|
| 23 | + if ($h_bookshop_books->getRecommendedCount() > $options[0]) { // Il y a plus de livres recommand�s dans la BDD que dans le bloc, on affiche donc un lien vers la page des livres recommand�s |
|
| 24 | + $block['showMore'] = true; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - if (count($tblLivres) > 0) { |
|
| 28 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 29 | - $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 30 | - $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 31 | - $tblTmp = array(); |
|
| 32 | - foreach ($tblLivres as $item) { |
|
| 33 | - $tblTmp[] = $item->getVar('book_cid'); |
|
| 34 | - $tbl_tmp_vat[] = $item->getVar('book_vat_id'); |
|
| 35 | - $tbl_tmp_lang[] = $item->getVar('book_lang_id'); |
|
| 36 | - $tbl_books_id[] = $item->getVar('book_id'); |
|
| 37 | - } |
|
| 38 | - $tblTmp = array_unique($tblTmp); |
|
| 39 | - $tbl_tmp_vat = array_unique($tbl_tmp_vat); |
|
| 40 | - $tbl_tmp_lang = array_unique($tbl_tmp_lang); |
|
| 27 | + if (count($tblLivres) > 0) { |
|
| 28 | + $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 29 | + $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 30 | + $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 31 | + $tblTmp = array(); |
|
| 32 | + foreach ($tblLivres as $item) { |
|
| 33 | + $tblTmp[] = $item->getVar('book_cid'); |
|
| 34 | + $tbl_tmp_vat[] = $item->getVar('book_vat_id'); |
|
| 35 | + $tbl_tmp_lang[] = $item->getVar('book_lang_id'); |
|
| 36 | + $tbl_books_id[] = $item->getVar('book_id'); |
|
| 37 | + } |
|
| 38 | + $tblTmp = array_unique($tblTmp); |
|
| 39 | + $tbl_tmp_vat = array_unique($tbl_tmp_vat); |
|
| 40 | + $tbl_tmp_lang = array_unique($tbl_tmp_lang); |
|
| 41 | 41 | |
| 42 | - sort($tbl_tmp_lang); |
|
| 43 | - sort($tblTmp); |
|
| 44 | - sort($tbl_tmp_vat); |
|
| 45 | - sort($tbl_books_id); |
|
| 42 | + sort($tbl_tmp_lang); |
|
| 43 | + sort($tblTmp); |
|
| 44 | + sort($tbl_tmp_vat); |
|
| 45 | + sort($tbl_books_id); |
|
| 46 | 46 | |
| 47 | - // Get languages ******************************************* |
|
| 48 | - if (count($tbl_tmp_lang) > 0) { |
|
| 49 | - $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 50 | - } |
|
| 47 | + // Get languages ******************************************* |
|
| 48 | + if (count($tbl_tmp_lang) > 0) { |
|
| 49 | + $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // Get the list of categories **************************** |
|
| 53 | - $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 52 | + // Get the list of categories **************************** |
|
| 53 | + $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 54 | 54 | |
| 55 | - // Get VAT *********************************************** |
|
| 56 | - if (count($tbl_tmp_vat) > 0) { |
|
| 57 | - $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 58 | - } |
|
| 55 | + // Get VAT *********************************************** |
|
| 56 | + if (count($tbl_tmp_vat) > 0) { |
|
| 57 | + $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - // Get the authors, deuxi�me partie ************************** |
|
| 61 | - $tbl_books_auteurs = array(); |
|
| 62 | - $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 63 | - if (count($tbl_auteurs) > 0) { |
|
| 64 | - foreach ($tbl_auteurs as $item) { |
|
| 65 | - $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
|
| 66 | - // Grouping data by book |
|
| 67 | - $tbl_books_auteurs[$item->getVar('ba_book_id')][] = $item; |
|
| 68 | - } |
|
| 69 | - $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
|
| 70 | - sort($tbl_tmp_auteurs); |
|
| 71 | - // Then recovered the information from these authors / translators |
|
| 72 | - $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 73 | - } |
|
| 74 | - foreach ($tblLivres as $item) { |
|
| 75 | - $tbl_tmp = array(); |
|
| 76 | - $tbl_tmp = $item->toArray(); |
|
| 77 | - $tbl_tmp['book_category'] = $tblCategories[$item->getVar('book_cid')]; |
|
| 78 | - $tbl_tmp['book_language'] = $tbl_lang[$item->getVar('book_lang_id')]; |
|
| 79 | - $tbl_tmp['book_vat_rate'] = $tbl_vat[$item->getVar('book_vat_id')]; |
|
| 80 | - $tbl_tmp['book_price_ttc'] = bookshop_getTTC($item->getVar('book_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 81 | - $tbl_tmp['book_discount_price_ttc'] = bookshop_getTTC($item->getVar('book_discount_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 60 | + // Get the authors, deuxi�me partie ************************** |
|
| 61 | + $tbl_books_auteurs = array(); |
|
| 62 | + $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 63 | + if (count($tbl_auteurs) > 0) { |
|
| 64 | + foreach ($tbl_auteurs as $item) { |
|
| 65 | + $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
|
| 66 | + // Grouping data by book |
|
| 67 | + $tbl_books_auteurs[$item->getVar('ba_book_id')][] = $item; |
|
| 68 | + } |
|
| 69 | + $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
|
| 70 | + sort($tbl_tmp_auteurs); |
|
| 71 | + // Then recovered the information from these authors / translators |
|
| 72 | + $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 73 | + } |
|
| 74 | + foreach ($tblLivres as $item) { |
|
| 75 | + $tbl_tmp = array(); |
|
| 76 | + $tbl_tmp = $item->toArray(); |
|
| 77 | + $tbl_tmp['book_category'] = $tblCategories[$item->getVar('book_cid')]; |
|
| 78 | + $tbl_tmp['book_language'] = $tbl_lang[$item->getVar('book_lang_id')]; |
|
| 79 | + $tbl_tmp['book_vat_rate'] = $tbl_vat[$item->getVar('book_vat_id')]; |
|
| 80 | + $tbl_tmp['book_price_ttc'] = bookshop_getTTC($item->getVar('book_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 81 | + $tbl_tmp['book_discount_price_ttc'] = bookshop_getTTC($item->getVar('book_discount_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 82 | 82 | |
| 83 | - // Search for authors / translators |
|
| 84 | - $tbl_join1 = $tbl_join2 = array(); |
|
| 85 | - $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 86 | - $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
|
| 87 | - foreach ($tbl_tmp2 as $oneauthor) { |
|
| 88 | - $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
|
| 89 | - if ($oneauthor->getVar('ba_type') == 1) { |
|
| 90 | - $tbl_livre_auteurs[] = $auteur->toArray(); |
|
| 91 | - $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 92 | - } else { |
|
| 93 | - $tbl_livre_traducteurs[] = $auteur->toArray(); |
|
| 94 | - $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - if (count($tbl_join1) > 0) { |
|
| 98 | - $tbl_tmp['book_joined_authors'] = implode(', ', $tbl_join1); |
|
| 99 | - } |
|
| 100 | - if (count($tbl_join2) > 0) { |
|
| 101 | - $tbl_tmp['book_joined_translators'] = implode(',', $tbl_join2); |
|
| 102 | - } |
|
| 103 | - $tbl_tmp['book_authors'] = $tbl_livre_auteurs; |
|
| 104 | - $tbl_tmp['book_translators'] = $tbl_livre_traducteurs; |
|
| 105 | - // Et on place le tout dans le template |
|
| 106 | - $block['block_books'][] = $tbl_tmp; |
|
| 107 | - } |
|
| 83 | + // Search for authors / translators |
|
| 84 | + $tbl_join1 = $tbl_join2 = array(); |
|
| 85 | + $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 86 | + $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
|
| 87 | + foreach ($tbl_tmp2 as $oneauthor) { |
|
| 88 | + $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
|
| 89 | + if ($oneauthor->getVar('ba_type') == 1) { |
|
| 90 | + $tbl_livre_auteurs[] = $auteur->toArray(); |
|
| 91 | + $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 92 | + } else { |
|
| 93 | + $tbl_livre_traducteurs[] = $auteur->toArray(); |
|
| 94 | + $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + if (count($tbl_join1) > 0) { |
|
| 98 | + $tbl_tmp['book_joined_authors'] = implode(', ', $tbl_join1); |
|
| 99 | + } |
|
| 100 | + if (count($tbl_join2) > 0) { |
|
| 101 | + $tbl_tmp['book_joined_translators'] = implode(',', $tbl_join2); |
|
| 102 | + } |
|
| 103 | + $tbl_tmp['book_authors'] = $tbl_livre_auteurs; |
|
| 104 | + $tbl_tmp['book_translators'] = $tbl_livre_traducteurs; |
|
| 105 | + // Et on place le tout dans le template |
|
| 106 | + $block['block_books'][] = $tbl_tmp; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return $block; |
|
| 110 | - } else { // The list of books is not found (it is not books sold in the stock books) |
|
| 109 | + return $block; |
|
| 110 | + } else { // The list of books is not found (it is not books sold in the stock books) |
|
| 111 | 111 | |
| 112 | - return false; |
|
| 113 | - } |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -120,27 +120,27 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function b_bookshop_recomm_edit($options) |
| 122 | 122 | { |
| 123 | - // '10|0'; // See 10 books, for all categories |
|
| 124 | - global $xoopsConfig; |
|
| 125 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 126 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 127 | - $tblCategories = array(); |
|
| 128 | - $tblCategories = $h_bookshop_cat->GetAllCategories(); |
|
| 129 | - $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
|
| 130 | - $form = ''; |
|
| 131 | - $checkeds = array('', ''); |
|
| 132 | - if (!isset($options[1])) { |
|
| 133 | - $options[1] = 0; |
|
| 134 | - } |
|
| 135 | - $checkeds[$options[1]] = 'checked'; |
|
| 136 | - $form .= "<table border='0'>"; |
|
| 137 | - $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 138 | - //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
|
| 139 | - $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
|
| 140 | - $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 141 | - $form .= '</table>'; |
|
| 123 | + // '10|0'; // See 10 books, for all categories |
|
| 124 | + global $xoopsConfig; |
|
| 125 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 126 | + include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 127 | + $tblCategories = array(); |
|
| 128 | + $tblCategories = $h_bookshop_cat->GetAllCategories(); |
|
| 129 | + $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
|
| 130 | + $form = ''; |
|
| 131 | + $checkeds = array('', ''); |
|
| 132 | + if (!isset($options[1])) { |
|
| 133 | + $options[1] = 0; |
|
| 134 | + } |
|
| 135 | + $checkeds[$options[1]] = 'checked'; |
|
| 136 | + $form .= "<table border='0'>"; |
|
| 137 | + $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 138 | + //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
|
| 139 | + $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
|
| 140 | + $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 141 | + $form .= '</table>'; |
|
| 142 | 142 | |
| 143 | - return $form; |
|
| 143 | + return $form; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | function b_bookshop_recomm_duplicatable($options) |
| 151 | 151 | { |
| 152 | - $options = explode('|', $options); |
|
| 153 | - $block = &b_bookshop_recomm_show($options); |
|
| 152 | + $options = explode('|', $options); |
|
| 153 | + $block = &b_bookshop_recomm_show($options); |
|
| 154 | 154 | |
| 155 | - $tpl = new XoopsTpl(); |
|
| 156 | - $tpl->assign('block', $block); |
|
| 157 | - $tpl->display('db:bookshop_block_recommended.tpl'); |
|
| 155 | + $tpl = new XoopsTpl(); |
|
| 156 | + $tpl->assign('block', $block); |
|
| 157 | + $tpl->display('db:bookshop_block_recommended.tpl'); |
|
| 158 | 158 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | // '10|0'; // See 10 books, for all categories or a particular category |
| 19 | 19 | global $xoopsConfig, $xoopsTpl; |
| 20 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 20 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 21 | 21 | $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
| 22 | 22 | $tblLivres = $h_bookshop_books->getRecentRecommendedBooks(0, $options[0], $options[1]); |
| 23 | 23 | if ($h_bookshop_books->getRecommendedCount() > $options[0]) { // Il y a plus de livres recommand�s dans la BDD que dans le bloc, on affiche donc un lien vers la page des livres recommand�s |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | if (count($tblLivres) > 0) { |
| 28 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 28 | + $url = BOOKSHOP_URL.'assets/css/bookshop.css'; |
|
| 29 | 29 | $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
| 30 | 30 | $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
| 31 | 31 | $tblTmp = array(); |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | // Get languages ******************************************* |
| 48 | 48 | if (count($tbl_tmp_lang) > 0) { |
| 49 | - $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 49 | + $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '('.implode(',', $tbl_tmp_lang).')', 'IN'), true); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Get the list of categories **************************** |
| 53 | - $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 53 | + $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '('.implode(',', $tblTmp).')', 'IN'), true); |
|
| 54 | 54 | |
| 55 | 55 | // Get VAT *********************************************** |
| 56 | 56 | if (count($tbl_tmp_vat) > 0) { |
| 57 | - $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 57 | + $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '('.implode(',', $tbl_tmp_vat).')', 'IN'), true); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Get the authors, deuxi�me partie ************************** |
| 61 | 61 | $tbl_books_auteurs = array(); |
| 62 | - $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 62 | + $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '('.implode(',', $tbl_books_id).')', 'IN'), true); |
|
| 63 | 63 | if (count($tbl_auteurs) > 0) { |
| 64 | 64 | foreach ($tbl_auteurs as $item) { |
| 65 | 65 | $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
| 70 | 70 | sort($tbl_tmp_auteurs); |
| 71 | 71 | // Then recovered the information from these authors / translators |
| 72 | - $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 72 | + $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '('.implode(',', $tbl_tmp_auteurs).')', 'IN'), true); |
|
| 73 | 73 | } |
| 74 | 74 | foreach ($tblLivres as $item) { |
| 75 | 75 | $tbl_tmp = array(); |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Search for authors / translators |
| 84 | 84 | $tbl_join1 = $tbl_join2 = array(); |
| 85 | - $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 85 | + $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 86 | 86 | $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
| 87 | 87 | foreach ($tbl_tmp2 as $oneauthor) { |
| 88 | 88 | $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
| 89 | 89 | if ($oneauthor->getVar('ba_type') == 1) { |
| 90 | 90 | $tbl_livre_auteurs[] = $auteur->toArray(); |
| 91 | - $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 91 | + $tbl_join1[] = $auteur->getVar('auth_firstname').' '.$auteur->getVar('auth_name'); |
|
| 92 | 92 | } else { |
| 93 | 93 | $tbl_livre_traducteurs[] = $auteur->toArray(); |
| 94 | - $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 94 | + $tbl_join2[] = $auteur->getVar('auth_firstname').' '.$auteur->getVar('auth_name'); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | if (count($tbl_join1) > 0) { |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | // '10|0'; // See 10 books, for all categories |
| 124 | 124 | global $xoopsConfig; |
| 125 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 126 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 125 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 126 | + include_once BOOKSHOP_PATH.'class/tree.php'; |
|
| 127 | 127 | $tblCategories = array(); |
| 128 | 128 | $tblCategories = $h_bookshop_cat->GetAllCategories(); |
| 129 | 129 | $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | $checkeds[$options[1]] = 'checked'; |
| 136 | 136 | $form .= "<table border='0'>"; |
| 137 | - $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 137 | + $form .= '<tr><td>'._MB_BOOKSHOP_BOOKS_CNT."</td><td><input type='text' name='options[]' id='options' value='".$options[0]."' /></td></tr>"; |
|
| 138 | 138 | //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
| 139 | 139 | $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
| 140 | - $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 140 | + $form .= '<tr><td>'._MB_BOOKSHOP_CATEGORY.'</td><td>'.$select.'</td></tr>'; |
|
| 141 | 141 | $form .= '</table>'; |
| 142 | 142 | |
| 143 | 143 | return $form; |
@@ -32,68 +32,68 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function b_bookshop_category_show($options) |
| 34 | 34 | { |
| 35 | - global $xoopsTpl; |
|
| 36 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 37 | - $block = array(); |
|
| 38 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 39 | - $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 40 | - $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 35 | + global $xoopsTpl; |
|
| 36 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 37 | + $block = array(); |
|
| 38 | + $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 39 | + $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 40 | + $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 41 | 41 | |
| 42 | - if ((int)$options[0] == 0) { |
|
| 43 | - $block['block_option'] = 0; |
|
| 44 | - if (!isset($GLOBALS['current_category']) || $GLOBALS['current_category'] == -1) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 47 | - $cat_cid = (int)$GLOBALS['current_category']; |
|
| 48 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 42 | + if ((int)$options[0] == 0) { |
|
| 43 | + $block['block_option'] = 0; |
|
| 44 | + if (!isset($GLOBALS['current_category']) || $GLOBALS['current_category'] == -1) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | + $cat_cid = (int)$GLOBALS['current_category']; |
|
| 48 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 49 | 49 | |
| 50 | - if ($cat_cid > 0) { |
|
| 51 | - include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 52 | - $tbl_categories = $tblChilds = $tbl_tmp = array(); |
|
| 53 | - $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
|
| 54 | - $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
|
| 55 | - $tblChilds = $mytree->getAllChild($cat_cid); |
|
| 56 | - //$tblChilds = array_reverse($tblChilds); |
|
| 57 | - foreach ($tblChilds as $item) { |
|
| 58 | - $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 59 | - } |
|
| 60 | - $block['block_categories'] = $tbl_tmp; |
|
| 50 | + if ($cat_cid > 0) { |
|
| 51 | + include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 52 | + $tbl_categories = $tblChilds = $tbl_tmp = array(); |
|
| 53 | + $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
|
| 54 | + $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
|
| 55 | + $tblChilds = $mytree->getAllChild($cat_cid); |
|
| 56 | + //$tblChilds = array_reverse($tblChilds); |
|
| 57 | + foreach ($tblChilds as $item) { |
|
| 58 | + $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 59 | + } |
|
| 60 | + $block['block_categories'] = $tbl_tmp; |
|
| 61 | 61 | |
| 62 | - $category = null; |
|
| 63 | - if ($cat_cid > 0) { |
|
| 64 | - $category = $h_bookshop_cat->get($cat_cid); |
|
| 65 | - if (is_object($category)) { |
|
| 66 | - $block['block_current_category'] = $category->toArray(); |
|
| 67 | - } |
|
| 68 | - } |
|
| 62 | + $category = null; |
|
| 63 | + if ($cat_cid > 0) { |
|
| 64 | + $category = $h_bookshop_cat->get($cat_cid); |
|
| 65 | + if (is_object($category)) { |
|
| 66 | + $block['block_current_category'] = $category->toArray(); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | } else { // On est à la racine, on n'affiche donc que les catégories mères |
| 70 | - $tbl_categories = array(); |
|
| 71 | - $criteria = new Criteria('cat_pid', 0, '='); |
|
| 72 | - $criteria->setSort('cat_title'); |
|
| 73 | - $tbl_categories = $h_bookshop_cat->getObjects($criteria, true); |
|
| 74 | - foreach ($tbl_categories as $item) { |
|
| 75 | - $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 76 | - } |
|
| 77 | - $block['block_categories'] = $tbl_tmp; |
|
| 78 | - } |
|
| 79 | - } else { // Affichage classique |
|
| 80 | - $block['block_option'] = 1; |
|
| 81 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 82 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 83 | - $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
|
| 84 | - $mytree = new Bookshop_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
|
| 85 | - $jump = BOOKSHOP_URL . 'category.php?cat_cid='; |
|
| 86 | - $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; |
|
| 87 | - if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { |
|
| 88 | - $cat_cid = (int)$GLOBALS['current_category']; |
|
| 89 | - } else { |
|
| 90 | - $cat_cid = 0; |
|
| 91 | - } |
|
| 92 | - $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', $cat_cid, false, 0, $additional); |
|
| 93 | - $block['htmlSelect'] = $htmlSelect; |
|
| 94 | - } |
|
| 70 | + $tbl_categories = array(); |
|
| 71 | + $criteria = new Criteria('cat_pid', 0, '='); |
|
| 72 | + $criteria->setSort('cat_title'); |
|
| 73 | + $tbl_categories = $h_bookshop_cat->getObjects($criteria, true); |
|
| 74 | + foreach ($tbl_categories as $item) { |
|
| 75 | + $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 76 | + } |
|
| 77 | + $block['block_categories'] = $tbl_tmp; |
|
| 78 | + } |
|
| 79 | + } else { // Affichage classique |
|
| 80 | + $block['block_option'] = 1; |
|
| 81 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 82 | + include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 83 | + $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
|
| 84 | + $mytree = new Bookshop_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
|
| 85 | + $jump = BOOKSHOP_URL . 'category.php?cat_cid='; |
|
| 86 | + $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; |
|
| 87 | + if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { |
|
| 88 | + $cat_cid = (int)$GLOBALS['current_category']; |
|
| 89 | + } else { |
|
| 90 | + $cat_cid = 0; |
|
| 91 | + } |
|
| 92 | + $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', $cat_cid, false, 0, $additional); |
|
| 93 | + $block['htmlSelect'] = $htmlSelect; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - return $block; |
|
| 96 | + return $block; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function b_bookshop_category_edit($options) |
| 105 | 105 | { |
| 106 | - global $xoopsConfig; |
|
| 107 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 106 | + global $xoopsConfig; |
|
| 107 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 108 | 108 | |
| 109 | - $checkeds = array('', ''); |
|
| 110 | - $checkeds[$options[0]] = 'checked'; |
|
| 111 | - $form = ''; |
|
| 112 | - $form .= '<b>' . _MB_BOOKSHOP_TYPE_BLOCK . "</b><br><input type='radio' name='options[]' id='options[]' value='0' " . $checkeds[0] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK2 . "<br><input type='radio' name='options[]' id='options[]' value='1' " . $checkeds[1] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK1 |
|
| 113 | - . '</td></tr>'; |
|
| 109 | + $checkeds = array('', ''); |
|
| 110 | + $checkeds[$options[0]] = 'checked'; |
|
| 111 | + $form = ''; |
|
| 112 | + $form .= '<b>' . _MB_BOOKSHOP_TYPE_BLOCK . "</b><br><input type='radio' name='options[]' id='options[]' value='0' " . $checkeds[0] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK2 . "<br><input type='radio' name='options[]' id='options[]' value='1' " . $checkeds[1] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK1 |
|
| 113 | + . '</td></tr>'; |
|
| 114 | 114 | |
| 115 | - return $form; |
|
| 115 | + return $form; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function b_bookshop_category_duplicatable($options) |
| 124 | 124 | { |
| 125 | - $options = explode('|', $options); |
|
| 126 | - $block = &b_bookshop_category($options); |
|
| 125 | + $options = explode('|', $options); |
|
| 126 | + $block = &b_bookshop_category($options); |
|
| 127 | 127 | |
| 128 | - $tpl = new XoopsTpl(); |
|
| 129 | - $tpl->assign('block', $block); |
|
| 130 | - $tpl->display('db:bookshop_block_categories.tpl'); |
|
| 128 | + $tpl = new XoopsTpl(); |
|
| 129 | + $tpl->assign('block', $block); |
|
| 130 | + $tpl->display('db:bookshop_block_categories.tpl'); |
|
| 131 | 131 | } |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | function b_bookshop_category_show($options) |
| 34 | 34 | { |
| 35 | 35 | global $xoopsTpl; |
| 36 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 36 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 37 | 37 | $block = array(); |
| 38 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 38 | + $url = BOOKSHOP_URL.'assets/css/bookshop.css'; |
|
| 39 | 39 | $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
| 40 | 40 | $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
| 41 | 41 | |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | $cat_cid = (int)$GLOBALS['current_category']; |
| 48 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 48 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 49 | 49 | |
| 50 | 50 | if ($cat_cid > 0) { |
| 51 | - include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 51 | + include_once XOOPS_ROOT_PATH.'/class/tree.php'; |
|
| 52 | 52 | $tbl_categories = $tblChilds = $tbl_tmp = array(); |
| 53 | 53 | $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
| 54 | 54 | $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
| 55 | 55 | $tblChilds = $mytree->getAllChild($cat_cid); |
| 56 | 56 | //$tblChilds = array_reverse($tblChilds); |
| 57 | 57 | foreach ($tblChilds as $item) { |
| 58 | - $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 58 | + $tbl_tmp[] = "<a href='".$h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title'))."' title='".bookshop_makeHrefTitle($item->getVar('cat_title'))."'>".$item->getVar('cat_title').'</a>'; |
|
| 59 | 59 | } |
| 60 | 60 | $block['block_categories'] = $tbl_tmp; |
| 61 | 61 | |
@@ -72,18 +72,18 @@ discard block |
||
| 72 | 72 | $criteria->setSort('cat_title'); |
| 73 | 73 | $tbl_categories = $h_bookshop_cat->getObjects($criteria, true); |
| 74 | 74 | foreach ($tbl_categories as $item) { |
| 75 | - $tbl_tmp[] = "<a href='" . $h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title')) . "' title='" . bookshop_makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; |
|
| 75 | + $tbl_tmp[] = "<a href='".$h_bookshop_cat->GetCategoryLink($item->getVar('cat_cid'), $item->getVar('cat_title'))."' title='".bookshop_makeHrefTitle($item->getVar('cat_title'))."'>".$item->getVar('cat_title').'</a>'; |
|
| 76 | 76 | } |
| 77 | 77 | $block['block_categories'] = $tbl_tmp; |
| 78 | 78 | } |
| 79 | 79 | } else { // Affichage classique |
| 80 | 80 | $block['block_option'] = 1; |
| 81 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 82 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 81 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 82 | + include_once BOOKSHOP_PATH.'class/tree.php'; |
|
| 83 | 83 | $tbl_categories = $h_bookshop_cat->GetAllCategories(); |
| 84 | 84 | $mytree = new Bookshop_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); |
| 85 | - $jump = BOOKSHOP_URL . 'category.php?cat_cid='; |
|
| 86 | - $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; |
|
| 85 | + $jump = BOOKSHOP_URL.'category.php?cat_cid='; |
|
| 86 | + $additional = "onchange='location=\"".$jump."\"+this.options[this.selectedIndex].value'"; |
|
| 87 | 87 | if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { |
| 88 | 88 | $cat_cid = (int)$GLOBALS['current_category']; |
| 89 | 89 | } else { |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | function b_bookshop_category_edit($options) |
| 105 | 105 | { |
| 106 | 106 | global $xoopsConfig; |
| 107 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 107 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 108 | 108 | |
| 109 | 109 | $checkeds = array('', ''); |
| 110 | 110 | $checkeds[$options[0]] = 'checked'; |
| 111 | 111 | $form = ''; |
| 112 | - $form .= '<b>' . _MB_BOOKSHOP_TYPE_BLOCK . "</b><br><input type='radio' name='options[]' id='options[]' value='0' " . $checkeds[0] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK2 . "<br><input type='radio' name='options[]' id='options[]' value='1' " . $checkeds[1] . ' />' . _MB_BOOKSHOP_TYPE_BLOCK1 |
|
| 112 | + $form .= '<b>'._MB_BOOKSHOP_TYPE_BLOCK."</b><br><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0].' />'._MB_BOOKSHOP_TYPE_BLOCK2."<br><input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1].' />'._MB_BOOKSHOP_TYPE_BLOCK1 |
|
| 113 | 113 | . '</td></tr>'; |
| 114 | 114 | |
| 115 | 115 | return $form; |
@@ -32,98 +32,98 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function b_bookshop_top_show($options) |
| 34 | 34 | { |
| 35 | - // '10|0'; // See 10 books, for all categories or a particular category |
|
| 36 | - global $xoopsConfig, $xoopsTpl; |
|
| 37 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 38 | - $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
|
| 39 | - $tblLivres = $h_bookshop_books->getMostViewedBooks(0, $options[0], $options[1]); |
|
| 40 | - if (count($tblLivres) > 0) { |
|
| 41 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 42 | - $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 43 | - $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 44 | - $tblTmp = array(); |
|
| 45 | - foreach ($tblLivres as $item) { |
|
| 46 | - $tblTmp[] = $item->getVar('book_cid'); |
|
| 47 | - $tbl_tmp_vat[] = $item->getVar('book_vat_id'); |
|
| 48 | - $tbl_tmp_lang[] = $item->getVar('book_lang_id'); |
|
| 49 | - $tbl_books_id[] = $item->getVar('book_id'); |
|
| 50 | - } |
|
| 51 | - $tblTmp = array_unique($tblTmp); |
|
| 52 | - $tbl_tmp_vat = array_unique($tbl_tmp_vat); |
|
| 53 | - $tbl_tmp_lang = array_unique($tbl_tmp_lang); |
|
| 35 | + // '10|0'; // See 10 books, for all categories or a particular category |
|
| 36 | + global $xoopsConfig, $xoopsTpl; |
|
| 37 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 38 | + $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
|
| 39 | + $tblLivres = $h_bookshop_books->getMostViewedBooks(0, $options[0], $options[1]); |
|
| 40 | + if (count($tblLivres) > 0) { |
|
| 41 | + $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 42 | + $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
|
| 43 | + $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
|
| 44 | + $tblTmp = array(); |
|
| 45 | + foreach ($tblLivres as $item) { |
|
| 46 | + $tblTmp[] = $item->getVar('book_cid'); |
|
| 47 | + $tbl_tmp_vat[] = $item->getVar('book_vat_id'); |
|
| 48 | + $tbl_tmp_lang[] = $item->getVar('book_lang_id'); |
|
| 49 | + $tbl_books_id[] = $item->getVar('book_id'); |
|
| 50 | + } |
|
| 51 | + $tblTmp = array_unique($tblTmp); |
|
| 52 | + $tbl_tmp_vat = array_unique($tbl_tmp_vat); |
|
| 53 | + $tbl_tmp_lang = array_unique($tbl_tmp_lang); |
|
| 54 | 54 | |
| 55 | - sort($tbl_tmp_lang); |
|
| 56 | - sort($tblTmp); |
|
| 57 | - sort($tbl_tmp_vat); |
|
| 58 | - sort($tbl_books_id); |
|
| 55 | + sort($tbl_tmp_lang); |
|
| 56 | + sort($tblTmp); |
|
| 57 | + sort($tbl_tmp_vat); |
|
| 58 | + sort($tbl_books_id); |
|
| 59 | 59 | |
| 60 | - // Get languages ******************************************* |
|
| 61 | - if (count($tbl_tmp_lang) > 0) { |
|
| 62 | - $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 63 | - } |
|
| 60 | + // Get languages ******************************************* |
|
| 61 | + if (count($tbl_tmp_lang) > 0) { |
|
| 62 | + $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Get the list of categories **************************** |
|
| 66 | - $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 65 | + // Get the list of categories **************************** |
|
| 66 | + $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 67 | 67 | |
| 68 | - // Get VAT *********************************************** |
|
| 69 | - if (count($tbl_tmp_vat) > 0) { |
|
| 70 | - $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 71 | - } |
|
| 68 | + // Get VAT *********************************************** |
|
| 69 | + if (count($tbl_tmp_vat) > 0) { |
|
| 70 | + $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // Get the authors, deuxi�me partie ************************** |
|
| 74 | - $tbl_books_auteurs = array(); |
|
| 75 | - $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 76 | - if (count($tbl_auteurs) > 0) { |
|
| 77 | - foreach ($tbl_auteurs as $item) { |
|
| 78 | - $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
|
| 79 | - // Grouping data by book |
|
| 80 | - $tbl_books_auteurs[$item->getVar('ba_book_id')][] = $item; |
|
| 81 | - } |
|
| 82 | - $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
|
| 83 | - sort($tbl_tmp_auteurs); |
|
| 84 | - // Then recovered the information from these authors / translators |
|
| 85 | - $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 86 | - } |
|
| 87 | - foreach ($tblLivres as $item) { |
|
| 88 | - $tbl_tmp = array(); |
|
| 89 | - $tbl_tmp = $item->toArray(); |
|
| 90 | - $tbl_tmp['book_category'] = $tblCategories[$item->getVar('book_cid')]; |
|
| 91 | - $tbl_tmp['book_language'] = $tbl_lang[$item->getVar('book_lang_id')]; |
|
| 92 | - $tbl_tmp['book_vat_rate'] = $tbl_vat[$item->getVar('book_vat_id')]; |
|
| 93 | - $tbl_tmp['book_price_ttc'] = bookshop_getTTC($item->getVar('book_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 94 | - $tbl_tmp['book_discount_price_ttc'] = bookshop_getTTC($item->getVar('book_discount_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 73 | + // Get the authors, deuxi�me partie ************************** |
|
| 74 | + $tbl_books_auteurs = array(); |
|
| 75 | + $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 76 | + if (count($tbl_auteurs) > 0) { |
|
| 77 | + foreach ($tbl_auteurs as $item) { |
|
| 78 | + $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
|
| 79 | + // Grouping data by book |
|
| 80 | + $tbl_books_auteurs[$item->getVar('ba_book_id')][] = $item; |
|
| 81 | + } |
|
| 82 | + $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
|
| 83 | + sort($tbl_tmp_auteurs); |
|
| 84 | + // Then recovered the information from these authors / translators |
|
| 85 | + $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 86 | + } |
|
| 87 | + foreach ($tblLivres as $item) { |
|
| 88 | + $tbl_tmp = array(); |
|
| 89 | + $tbl_tmp = $item->toArray(); |
|
| 90 | + $tbl_tmp['book_category'] = $tblCategories[$item->getVar('book_cid')]; |
|
| 91 | + $tbl_tmp['book_language'] = $tbl_lang[$item->getVar('book_lang_id')]; |
|
| 92 | + $tbl_tmp['book_vat_rate'] = $tbl_vat[$item->getVar('book_vat_id')]; |
|
| 93 | + $tbl_tmp['book_price_ttc'] = bookshop_getTTC($item->getVar('book_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 94 | + $tbl_tmp['book_discount_price_ttc'] = bookshop_getTTC($item->getVar('book_discount_price'), $tbl_vat[$item->getVar('book_vat_id')]->getVar('vat_rate')); |
|
| 95 | 95 | |
| 96 | - // Search for authors / translators |
|
| 97 | - $tbl_join1 = $tbl_join2 = array(); |
|
| 98 | - $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 99 | - $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
|
| 100 | - foreach ($tbl_tmp2 as $oneauthor) { |
|
| 101 | - $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
|
| 102 | - if ($oneauthor->getVar('ba_type') == 1) { |
|
| 103 | - $tbl_livre_auteurs[] = $auteur->toArray(); |
|
| 104 | - $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 105 | - } else { |
|
| 106 | - $tbl_livre_traducteurs[] = $auteur->toArray(); |
|
| 107 | - $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - if (count($tbl_join1) > 0) { |
|
| 111 | - $tbl_tmp['book_joined_authors'] = implode(', ', $tbl_join1); |
|
| 112 | - } |
|
| 113 | - if (count($tbl_join2) > 0) { |
|
| 114 | - $tbl_tmp['book_joined_translators'] = implode(',', $tbl_join2); |
|
| 115 | - } |
|
| 116 | - $tbl_tmp['book_authors'] = $tbl_livre_auteurs; |
|
| 117 | - $tbl_tmp['book_translators'] = $tbl_livre_traducteurs; |
|
| 118 | - // Et on place le tout dans le template |
|
| 119 | - $block['block_books'][] = $tbl_tmp; |
|
| 120 | - } |
|
| 96 | + // Search for authors / translators |
|
| 97 | + $tbl_join1 = $tbl_join2 = array(); |
|
| 98 | + $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 99 | + $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
|
| 100 | + foreach ($tbl_tmp2 as $oneauthor) { |
|
| 101 | + $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
|
| 102 | + if ($oneauthor->getVar('ba_type') == 1) { |
|
| 103 | + $tbl_livre_auteurs[] = $auteur->toArray(); |
|
| 104 | + $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 105 | + } else { |
|
| 106 | + $tbl_livre_traducteurs[] = $auteur->toArray(); |
|
| 107 | + $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + if (count($tbl_join1) > 0) { |
|
| 111 | + $tbl_tmp['book_joined_authors'] = implode(', ', $tbl_join1); |
|
| 112 | + } |
|
| 113 | + if (count($tbl_join2) > 0) { |
|
| 114 | + $tbl_tmp['book_joined_translators'] = implode(',', $tbl_join2); |
|
| 115 | + } |
|
| 116 | + $tbl_tmp['book_authors'] = $tbl_livre_auteurs; |
|
| 117 | + $tbl_tmp['book_translators'] = $tbl_livre_traducteurs; |
|
| 118 | + // Et on place le tout dans le template |
|
| 119 | + $block['block_books'][] = $tbl_tmp; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - return $block; |
|
| 123 | - } else { // La liste des livres est introuvable (on ne trouve pas les livres vendus dans le stock des livres) |
|
| 122 | + return $block; |
|
| 123 | + } else { // La liste des livres est introuvable (on ne trouve pas les livres vendus dans le stock des livres) |
|
| 124 | 124 | |
| 125 | - return false; |
|
| 126 | - } |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -133,24 +133,24 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | function b_bookshop_top_edit($options) |
| 135 | 135 | { |
| 136 | - // '10|0'; // See 10 books, for all categories |
|
| 137 | - global $xoopsConfig; |
|
| 138 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 139 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 140 | - $tblCategories = array(); |
|
| 141 | - $tblCategories = $h_bookshop_cat->GetAllCategories(); |
|
| 142 | - $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
|
| 143 | - $form = ''; |
|
| 144 | - $checkeds = array('', ''); |
|
| 145 | - $checkeds[$options[1]] = 'checked'; |
|
| 146 | - $form .= "<table border='0'>"; |
|
| 147 | - $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 148 | - //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
|
| 149 | - $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
|
| 150 | - $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 151 | - $form .= '</table>'; |
|
| 136 | + // '10|0'; // See 10 books, for all categories |
|
| 137 | + global $xoopsConfig; |
|
| 138 | + include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 139 | + include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 140 | + $tblCategories = array(); |
|
| 141 | + $tblCategories = $h_bookshop_cat->GetAllCategories(); |
|
| 142 | + $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
|
| 143 | + $form = ''; |
|
| 144 | + $checkeds = array('', ''); |
|
| 145 | + $checkeds[$options[1]] = 'checked'; |
|
| 146 | + $form .= "<table border='0'>"; |
|
| 147 | + $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 148 | + //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
|
| 149 | + $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
|
| 150 | + $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 151 | + $form .= '</table>'; |
|
| 152 | 152 | |
| 153 | - return $form; |
|
| 153 | + return $form; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function b_bookshop_top_show_duplicatable($options) |
| 161 | 161 | { |
| 162 | - $options = explode('|', $options); |
|
| 163 | - $block = &b_bookshop_top_show($options); |
|
| 162 | + $options = explode('|', $options); |
|
| 163 | + $block = &b_bookshop_top_show($options); |
|
| 164 | 164 | |
| 165 | - $tpl = new XoopsTpl(); |
|
| 166 | - $tpl->assign('block', $block); |
|
| 167 | - $tpl->display('db:bookshop_block_top.tpl'); |
|
| 165 | + $tpl = new XoopsTpl(); |
|
| 166 | + $tpl->assign('block', $block); |
|
| 167 | + $tpl->display('db:bookshop_block_top.tpl'); |
|
| 168 | 168 | } |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | // '10|0'; // See 10 books, for all categories or a particular category |
| 36 | 36 | global $xoopsConfig, $xoopsTpl; |
| 37 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 37 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 38 | 38 | $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); |
| 39 | 39 | $tblLivres = $h_bookshop_books->getMostViewedBooks(0, $options[0], $options[1]); |
| 40 | 40 | if (count($tblLivres) > 0) { |
| 41 | - $url = BOOKSHOP_URL . 'assets/css/bookshop.css'; |
|
| 41 | + $url = BOOKSHOP_URL.'assets/css/bookshop.css'; |
|
| 42 | 42 | $block['nostock_msg'] = bookshop_getmoduleoption('nostock_msg'); |
| 43 | 43 | $xoopsTpl->assign('xoops_module_header', "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
| 44 | 44 | $tblTmp = array(); |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | // Get languages ******************************************* |
| 61 | 61 | if (count($tbl_tmp_lang) > 0) { |
| 62 | - $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '(' . implode(',', $tbl_tmp_lang) . ')', 'IN'), true); |
|
| 62 | + $tbl_lang = $h_bookshop_lang->getObjects(new Criteria('lang_id', '('.implode(',', $tbl_tmp_lang).')', 'IN'), true); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Get the list of categories **************************** |
| 66 | - $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
|
| 66 | + $tblCategories = $h_bookshop_cat->getObjects(new Criteria('cat_cid', '('.implode(',', $tblTmp).')', 'IN'), true); |
|
| 67 | 67 | |
| 68 | 68 | // Get VAT *********************************************** |
| 69 | 69 | if (count($tbl_tmp_vat) > 0) { |
| 70 | - $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '(' . implode(',', $tbl_tmp_vat) . ')', 'IN'), true); |
|
| 70 | + $tbl_vat = $h_bookshop_vat->getObjects(new Criteria('vat_id', '('.implode(',', $tbl_tmp_vat).')', 'IN'), true); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Get the authors, deuxi�me partie ************************** |
| 74 | 74 | $tbl_books_auteurs = array(); |
| 75 | - $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '(' . implode(',', $tbl_books_id) . ')', 'IN'), true); |
|
| 75 | + $tbl_auteurs = $h_bookshop_booksauthors->getObjects(new Criteria('ba_book_id', '('.implode(',', $tbl_books_id).')', 'IN'), true); |
|
| 76 | 76 | if (count($tbl_auteurs) > 0) { |
| 77 | 77 | foreach ($tbl_auteurs as $item) { |
| 78 | 78 | $tbl_tmp_auteurs[] = $item->getVar('ba_auth_id'); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $tbl_tmp_auteurs = array_unique($tbl_tmp_auteurs); |
| 83 | 83 | sort($tbl_tmp_auteurs); |
| 84 | 84 | // Then recovered the information from these authors / translators |
| 85 | - $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '(' . implode(',', $tbl_tmp_auteurs) . ')', 'IN'), true); |
|
| 85 | + $tbl_infos_auteurs = $h_bookshop_authors->getObjects(new Criteria('auth_id', '('.implode(',', $tbl_tmp_auteurs).')', 'IN'), true); |
|
| 86 | 86 | } |
| 87 | 87 | foreach ($tblLivres as $item) { |
| 88 | 88 | $tbl_tmp = array(); |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | // Search for authors / translators |
| 97 | 97 | $tbl_join1 = $tbl_join2 = array(); |
| 98 | - $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 98 | + $tbl_tmp2 = $tbl_books_auteurs[$item->getVar('book_id')]; // Returns a list of all authors / translators of a book |
|
| 99 | 99 | $tbl_livre_auteurs = $tbl_livre_traducteurs = array(); |
| 100 | 100 | foreach ($tbl_tmp2 as $oneauthor) { |
| 101 | 101 | $auteur = $tbl_infos_auteurs[$oneauthor->getVar('ba_auth_id')]; |
| 102 | 102 | if ($oneauthor->getVar('ba_type') == 1) { |
| 103 | 103 | $tbl_livre_auteurs[] = $auteur->toArray(); |
| 104 | - $tbl_join1[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 104 | + $tbl_join1[] = $auteur->getVar('auth_firstname').' '.$auteur->getVar('auth_name'); |
|
| 105 | 105 | } else { |
| 106 | 106 | $tbl_livre_traducteurs[] = $auteur->toArray(); |
| 107 | - $tbl_join2[] = $auteur->getVar('auth_firstname') . ' ' . $auteur->getVar('auth_name'); |
|
| 107 | + $tbl_join2[] = $auteur->getVar('auth_firstname').' '.$auteur->getVar('auth_name'); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | if (count($tbl_join1) > 0) { |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | // '10|0'; // See 10 books, for all categories |
| 137 | 137 | global $xoopsConfig; |
| 138 | - include XOOPS_ROOT_PATH . '/modules/bookshop/include/common.php'; |
|
| 139 | - include_once BOOKSHOP_PATH . 'class/tree.php'; |
|
| 138 | + include XOOPS_ROOT_PATH.'/modules/bookshop/include/common.php'; |
|
| 139 | + include_once BOOKSHOP_PATH.'class/tree.php'; |
|
| 140 | 140 | $tblCategories = array(); |
| 141 | 141 | $tblCategories = $h_bookshop_cat->GetAllCategories(); |
| 142 | 142 | $mytree = new Bookshop_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | $checkeds = array('', ''); |
| 145 | 145 | $checkeds[$options[1]] = 'checked'; |
| 146 | 146 | $form .= "<table border='0'>"; |
| 147 | - $form .= '<tr><td>' . _MB_BOOKSHOP_BOOKS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>"; |
|
| 147 | + $form .= '<tr><td>'._MB_BOOKSHOP_BOOKS_CNT."</td><td><input type='text' name='options[]' id='options' value='".$options[0]."' /></td></tr>"; |
|
| 148 | 148 | //$form .= '<tr><td>'._MB_BOOKSHOP_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0]." />"._MB_BOOKSHOP_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1]." />"._MB_BOOKSHOP_SORT_2.'</td></tr>'; |
| 149 | 149 | $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_BOOKSHOP_ALL_CATEGORIES); |
| 150 | - $form .= '<tr><td>' . _MB_BOOKSHOP_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
|
| 150 | + $form .= '<tr><td>'._MB_BOOKSHOP_CATEGORY.'</td><td>'.$select.'</td></tr>'; |
|
| 151 | 151 | $form .= '</table>'; |
| 152 | 152 | |
| 153 | 153 | return $form; |