static function showItemBL($id, $catid, $printItem) { global $mainframe, $database, $my, $acl, $option; global $mosConfig_shownoauth, $mosConfig_live_site, $mosConfig_absolute_path; global $cur_template, $Itemid, $booklibrary_configuration; //print_r($printItem);exit; //for 1.6 $mosConfig_live_site = JURI::root(true); $doc = JFactory::getDocument(); $doc->addStyleSheet($mosConfig_live_site . '/components/com_booklibrary/includes/custom.css'); $path_way = $mainframe->getPathway(); // variant 2 // -- PHP_booklibrary::addTitleAndMetaTags(); if (!empty($catid)) { $query = "SELECT * FROM #__booklibrary_main_categories WHERE id='{$catid}'"; $database->setQuery($query); $category = $database->loadObjectList(); $category = $category[0]; PHP_booklibrary::constructPathway($category); $path_way->addItem($category->title, sefRelToAbs('index.php?option=' . $option . '&task=showCategory&catid=' . $catid . '&Itemid=' . $Itemid)); // for 1.6 } //Record the hit $sql2 = "UPDATE #__booklibrary SET featured_clicks = featured_clicks - 1 WHERE featured_clicks > 0 and id = " . $id . ""; $database->setQuery($sql2); $database->query(); $sql = "UPDATE #__booklibrary SET hits = hits + 1 WHERE id = " . $id . ""; $database->setQuery($sql); $database->query(); $sql3 = "UPDATE #__booklibrary SET featured_shows = featured_shows - 1 WHERE featured_shows > 0"; $database->setQuery($sql3); $database->query(); //load the book $book = new mosBookLibrary($database); $book->load($id); //check access to book $access = $book->getAccessBook(); //print_r($access);exit; if (!isset($my->id)) { //for 1.6 $my->id = 0; } $query = "SELECT * FROM #__booklibrary_main_categories WHERE id='{$catid}'"; $database->setQuery($query); $category = $database->loadObjectList(); if (isset($category[0])) { $category = $category[0]; } else { echo _BOOKLIBRARY_ERROR_ACCESS_PAGE; return; } $path_way->addItem($book->title, ' '); // for 1.6 //end check access to book $session = JFactory::getSession(); $session->get("obj_book", $book); // Parameters // $menu = new mosMenu( $database ); // //$menu = new JTableMenu( $database ); // for 1.6 // // $menu->load( $Itemid ); // $params = new mosParameters( $menu->params ); if (version_compare(JVERSION, '3.0', 'ge')) { $menu = new JTableMenu($database); $menu->load($Itemid); $params = new JRegistry(); $params->loadString($menu->params); } else { $menu = new mosMenu($database); $menu->load($GLOBALS['Itemid']); $params = new mosParameters($menu->params); } $menu_name = set_header_name_bl($menu, $Itemid); $params->def('header', $menu_name); //for 1.6 $params->def('pageclass_sfx', ''); if (!isset($my->id)) { //for 1.6 $my->id = 0; } if ($GLOBALS['lendstatus_show']) { $params->def('show_lendstatus', 1); if (checkAccessBL($GLOBALS['lendrequest_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_lendrequest', 1); } } if ($GLOBALS['reviews_show']) { $params->def('show_reviews', 1); if (checkAccessBL($GLOBALS['reviews_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_inputreviews', 1); } } if ($GLOBALS['ebooks_show']) { $params->def('show_ebookstatus', 1); if (checkAccessBL($GLOBALS['ebooks_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_ebooksrequest', 1); } } if ($GLOBALS['price_show']) { $params->def('show_pricestatus', 1); if (checkAccessBL($GLOBALS['price_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_pricerequest', 1); } } //------------------------------------- begin add for Manager : buttons ****************************** if ($GLOBALS['print_pdf_show']) { $params->def('show_print_pdf', 1); if (checkAccessBL($GLOBALS['print_pdf_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_input_print_pdf', 1); } } if ($GLOBALS['print_view_show']) { $params->def('show_print_view', 1); if (checkAccessBL($GLOBALS['print_view_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_input_print_view', 1); } } if ($GLOBALS['mail_to_show']) { $params->def('show_mail_to', 1); if (checkAccessBL($GLOBALS['mail_to_registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $params->def('show_input_mail_to', 1); } } //------------------------------------------ end add for Manager : buttons ****************************** //************ begin add button 'buy now' *************************** if ($GLOBALS['buy_now_show']) { $params->def('show_buy_now', 1); $s = explode(',', $GLOBALS['buy_now_allow_categories']); foreach ($s as $i) { if ($i == $catid || $i == -2) { $params->def('show_input_buy_now', 1); break; } } } //************ end add button 'buy now' ******************************** //************ begin add button 'buy now vm' *************************** //************ end add button 'buy now vm' ******************************** $params->def('pageclass_sfx', ''); $params->def('item_description', 1); $params->def('lend_request', $GLOBALS['lendrequest_registrationlevel']); $params->def('show_ebook', $GLOBALS['ebooks_show']); $params->def('show_price', $GLOBALS['price_show']); $params->def('back_button', $mainframe->getCfg('back_button')); // page header $currentcat = new stdClass(); $currentcat->header = ''; if (@$currentcat->name != '') { $currentcat->header = $currentcat->name; } else { $currentcat->header = $params->get('header'); } $currentcat->header = $currentcat->header . ($currentcat->header != '' ? ": " : '') . $book->title; //get language List $retVal1 = mosBooklibraryOthers::getLanguageArray(); $book_lang = null; for ($i = 0, $n = count($retVal1); $i < $n; $i++) { $help = $retVal1[$i]; if ($book->language == $help[0]) { $book_lang = $help[1]; break; } } if ($book->rating == 0) { $database->setQuery("SELECT ROUND(avg(rating) ) FROM #__booklibrary_review WHERE fk_bookid = " . $book->id . " group by fk_bookid "); $book->rating = $database->loadResult(); if ($book->rating == null) { $book->rating = 0; } } $database->setQuery("SELECT username FROM #__users WHERE email='{$book->owneremail}'"); $book->ownername = $database->loadResult(); // show the book // for 1.6 // get a category list which the book is connected to $s = getWhereUsergroupsString("mc"); // get user acces level $query_c = "SELECT * FROM #__booklibrary_categories AS bc\n LEFT JOIN #__booklibrary_main_categories AS mc\n ON bc.catid=mc.id AND ({$s})\n WHERE bc.bookid=" . $book->id; $database->setQuery($query_c); $categories = $database->loadObjectList(); // -- //---------------------------------------------------------------- $params->def('view01', "{loadposition com_booklibrary_view_book_01}"); $params->def('view02', "{loadposition com_booklibrary_view_book_02}"); $params->def('view03', "{loadposition com_booklibrary_view_book_03}"); $params->def('viewdescription', "{loadposition com_booklibrary_view_book_description}"); $params->def('view04', "{loadposition com_booklibrary_view_book_04}"); $params->def('view05', "{loadposition com_booklibrary_view_book_05}"); $params->def('view06', "{loadposition com_booklibrary_view_book_06}"); $params->def('view07', "{loadposition com_booklibrary_view_book_07}"); // if ($layout == ''){ // $params2 = unserialize($category->params2); // $layout = $params2->view_book; // } // if ($layout == '') // $layout = 'default'; // $params2 = unserialize($category->params2); // // if($layout == null) // { // $layout = "default"; // } // else // { // if($params2 == null) // { // $layout = "default"; // } // else // { // $layout = $params2->view_book; // } // } $query = "SELECT * FROM #__booklibrary_main_categories WHERE id=" . $catid; $database->setQuery($query); $catid = $database->loadObjectList(); //print_r($catid);exit; $params2 = unserialize($catid[0]->params2); //print_r($params2);exit; if (!$params2 == null) { //print_r($catid); //print_r($a); $layout = $params2->view_book; //print_r($layout); //exit; } else { $layout = "default"; } //-------------------- //get owner if ($book->owner_id != 0 && $booklibrary_configuration['owner']['show'] != '0') { $query = "SELECT name, email FROM #__users WHERE id = " . $book->owner_id . ""; $database->setQuery($query); $user_b = $database->loadObject(); $book->user_b = $user_b; } //-------------------- //ebook urls $query = "select * " . " from #__booklibrary_files AS s " . " where s.fk_book_id=" . $book->id . " ORDER BY s.id "; $database->setQuery($query); $row = $database->loadObjectList(); //print_r($row);exit; $book->ebookURL = $row; switch ($printItem) { default: HTML_booklibrary::displayBook($book, $tabclass, $params, $currentcat, $categories, $ratinglist, $book_lang, $id, $catid, $layout); break; } //---------------------------------------------------------------------- }