function export($option) { global $database, $my, $mainframe, $booklibrary_configuration; $catid = mosGetParam($_POST, 'export_catid', 0); //$lend = mosGetParam($_POST, 'export_lend', null); //$pub = mosGetParam($_POST, 'export_pub', null); $type = mosGetParam($_POST, 'export_type', 0); $where = array(); $wherecatid = ''; if ($catid > 0) { array_push($where, "ac.catid='{$catid}'"); $wherecatid = " AND c.id ='{$catid}'"; } $selectstring = "SELECT a.id FROM #__booklibrary AS a\n \nLEFT JOIN #__booklibrary_categories AS ac ON a.id = ac.bookid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nGROUP BY ac.bookid" . "\nORDER BY a.ordering"; $database->setQuery($selectstring); $booksids = $database->loadResultArray(); if (version_compare(JVERSION, '3.0', 'lt')) { $booksids = $database->loadResultArray(); } else { $booksids = $database->loadColumn(); } echo $database->getErrorMsg(); if ($database->getErrorNum()) { echo $database->stderr(); return; } /*************************************************************************************************/ $cats = ''; if ($type == '4') { $selectstring = "SELECT c.* FROM #__booklibrary_main_categories AS c" . "\nWHERE c.section='com_booklibrary' " . $wherecatid . "\nORDER BY c.parent_id"; $database->setQuery($selectstring); $cats = $database->loadAssocList(); } $order = array("\r\n", "\n", "\r"); $strXmlDoc = ""; $strXmlDoc .= "<?xml version='1.0' encoding='utf-8' ?>\n"; $strXmlDoc .= "<data>\n"; $strXmlDoc .= "<version>" . $booklibrary_configuration['release']['version'] . "</version>\n"; $strXmlDoc .= "<books>\n"; foreach ($booksids as $bid) { $tmp = new mosBooklibrary($database); if ($catid > 0) { $tmp->categs = array($catid); } if ($tmp->load(intval($bid))) { $tmp->title = str_replace('|', '-', $tmp->title); $tmp->title = str_replace('\\n', ' ', $tmp->title); $tmp->title = str_replace('\\r', ' ', $tmp->title); $tmp->comment = str_replace('|', '-', $tmp->comment); $tmp->comment = str_replace('\\n', ' ', $tmp->comment); $tmp->comment = str_replace('\\r', ' ', $tmp->comment); $tmp->featured_clicks = str_replace('|', '-', $tmp->featured_clicks); $tmp->featured_clicks = str_replace($order, ' ', $tmp->featured_clicks); $tmp->featured_shows = str_replace('|', '-', $tmp->featured_shows); $tmp->featured_shows = str_replace($order, ' ', $tmp->featured_shows); //$books[]=$tmp; $strXmlDoc .= $tmp->toXML2(); } } $strXmlDoc .= "</books>\n"; $strXmlDoc2 = ""; $strXmlDoc2 .= "<categories>\n"; if ($type == '4') { foreach ($cats as $cat) { $strXmlDoc2 .= "<category>\n"; foreach ($cat as $field => $value) { $strXmlDoc2 .= '<' . $field . '><![CDATA[' . $value . ']]></' . $field . ">\n"; } $strXmlDoc2 .= "</category>\n"; } } $strXmlDoc2 .= "</categories>\n"; if ($type == '4') { $strXmlDoc .= $strXmlDoc2; } $strXmlDoc .= "</data>\n"; /* print_r(":11111111111111:"); print_r("<pre>"); print_r($cats); print_r("</pre>"); exit; */ /*************************************************************************************************/ /* $books = array(); $order = array("\r\n", "\n", "\r"); foreach($booksids as $bid){ $tmp = new mosBooklibrary($database); // __constructor JTable if($tmp->load(intval($bid))){ $books[]=$tmp; } } //parsing in title and commenr symbol '|' foreach ($books as $key => $book) { $books[$key]->title = str_replace('|', '-', $book->title); $books[$key]->title = str_replace('\n', ' ', $book->title); $books[$key]->title = str_replace('\r', ' ', $book->title); $books[$key]->comment = str_replace('|', '-', $book->comment); $books[$key]->comment = str_replace('\n', ' ', $book->comment); $books[$key]->comment = str_replace('\r', ' ', $book->comment); $books[$key]->featured_clicks = str_replace('|', '-', $books[$key]->featured_clicks); $books[$key]->featured_clicks = str_replace($order, ' ', $books[$key]->featured_clicks); $books[$key]->featured_shows = str_replace('|', '-', $books[$key]->featured_shows); $books[$key]->featured_shows = str_replace($order, ' ', $books[$key]->featured_shows); if ($catid > 0){ $books[$key]->categs = array($catid); } } $cats = ''; if ($type == '4') { $selectstring = "SELECT c.* FROM #__booklibrary_main_categories AS c" . "\nWHERE c.section='com_booklibrary' " . $wherecatid . "\nORDER BY c.parent_id"; $database->setQuery($selectstring); $cats = $database->loadAssocList(); } */ //$retVal = mosBooklibraryImportExport :: exportBooksXML($books, $cats); $retVal = $strXmlDoc; $type2 = 'xml'; switch ($type) { case '1': $type2 = 'csv'; break; case '2': $type2 = 'xml'; break; } $InformationArray = mosBooklibraryImportExport::storeExportFile($retVal, $type2); HTML_booklibrary::showExportResult($InformationArray, $option); }
static function saveLent($option, $bids, $task = "") { global $database, $Itemid; PHP_booklibrary::addTitleAndMetaTags(); $checkB = mosGetParam($_REQUEST, 'checkbook'); if ($checkB != "on") { echo "<script> alert('Select an item to Lend'); window.history.go(-1);</script>\n"; exit; } $data = JFactory::getDBO(); $bookid = mosGetParam($_REQUEST, 'bookid'); $id = mosGetParam($_REQUEST, 'id'); $lend_from = mosGetParam($_REQUEST, 'lend_from'); $lend_until = mosGetParam($_REQUEST, 'lend_until'); if (!is_array($bids) || count($bids) < 1) { echo "<script> alert('Select an item to lend'); window.history.go(-1);</script>\n"; exit; } $lend = new mosBookLibrary_lend($database); if ($task == "edit_lend") { $lend->load($bids[0]); } $query = "SELECT * FROM #__booklibrary_lend where fk_bookid = " . $id . " AND lend_return is NULL "; $data->setQuery($query); $lendTerm = $data->loadObjectList(); if ($lend_from > $lend_until) { echo "<script> alert('" . $lend_from . " more then " . $lend_until . "'); window.history.go(-1); </script>\n"; exit; } $lend_from = substr($lend_from, 0, 10); $lend_until = substr($lend_until, 0, 10); if (isset($lendTerm[0])) { for ($e = 0, $m = count($lendTerm); $e < $m; $e++) { if ($task == "edit_lend" && $bids[0] == $lendTerm[$e]->id) { continue; } $lendTerm[$e]->lend_from = substr($lendTerm[$e]->lend_from, 0, 10); $lendTerm[$e]->lend_until = substr($lendTerm[$e]->lend_until, 0, 10); //check lend if ($lend_from >= $lendTerm[$e]->lend_from && $lend_from <= $lendTerm[$e]->lend_until || $lend_from <= $lendTerm[$e]->lend_from && $lend_until >= $lendTerm[$e]->lend_until || $lend_until >= $lendTerm[$e]->lend_from && $lend_until <= $lendTerm[$e]->lend_until) { echo "<script> alert('Sorry, this item already lend out from " . $lendTerm[$e]->lend_from . " until " . $lendTerm[$e]->lend_until . "'); window.history.go(-1); </script>\n"; exit; } } } //if end if (mosGetParam($_REQUEST, 'lend_from') != "") { $lend->lend_from = data_transformer(mosGetParam($_REQUEST, 'lend_from'), "to"); } else { $lend->lend_from = null; } if (mosGetParam($_REQUEST, 'lend_until') != "") { $lend->lend_until = data_transformer(mosGetParam($_REQUEST, 'lend_until'), "to"); } else { $lend->lend_until = null; } $lend->fk_bookid = $id; $userid = mosGetParam($_REQUEST, 'userid'); if ($userid == "-1") { $lend->user_name = mosGetParam($_REQUEST, 'user_name', ''); $lend->user_email = mosGetParam($_REQUEST, 'user_email', ''); } else { $lend->fk_userid = $userid; } if (!$lend->check($lend)) { echo "<script> alert('" . $lend->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$lend->store()) { echo "<script> alert('" . $lend->getError() . "'); window.history.go(-1); </script>\n"; exit; } $lend->checkin(); $book = new mosBooklibrary($database); $book->load($id); $book->fk_lendid = $lend->id; $book->store(); $book->checkin(); if ($option == 'com_comprofiler') { $link_for_mosRedirect = "index.php?option=" . $option . "&tab=getmybooksTab&Itemid=" . $Itemid; } else { $link_for_mosRedirect = "index.php?option=" . $option . "&view=show_my_books&layout=mybooks"; } //print_r($link_for_mosRedirect);exit; //mosRedirect($link_for_mosRedirect); PHP_booklibrary::showMyBooks($option); }