0){ array_unshift($sections, $children); } } if($section['parent_id'] == -1 || $section == '' ){ Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = -1 ORDER BY priority, name;", FALSE); $categories = Renderosity\Facades\DB::getResults(); array_unshift($sections, $categories); return false; } return recursion_section($section['parent_id'], 0); } /////////////////////////////////////////////////// //RETURN PARENT SECTIONS /////////////////////////////////////////////////// function get_parent_sections( $parent_id = -1 ){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." ORDER BY priority, name", FALSE); $parent_sections = Renderosity\Facades\DB::getResults(); return $parent_sections; } /////////////////////////////////////////////////// //AJAX SECTION LOAD /////////////////////////////////////////////////// if(isset($_POST['get_sections'])){ $cats = get_parent_sections($_POST['section_id']); exit(json_encode(array( 'success' => true, 'data' => array("sections" => $cats) ))); } /////////////////////////////////////////////////// //DISPLAY CATEGORIES /////////////////////////////////////////////////// function display_categories($parent_id=-1){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." ORDER BY priority, name;"); if(Renderosity\Facades\DB::rowCount() > 0){ echo ''; }elseif($parent_id == -1){ echo 'There are no categories yet.'; } } /////////////////////////////////////////////////// //DISPLAY CATEGORIES FOR SELECT /////////////////////////////////////////////////// function display_categories_select($parent_id=-1, $depth=0){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." AND section_id <> ".$_GET['delete']." ORDER BY priority, name;"); if(Renderosity\Facades\DB::rowCount() > 0){ foreach(Renderosity\Facades\DB::getResults() as $row){ echo ''; echo display_categories_select($row['section_id'], $depth + 1); } } } ?>in_roles($tutorial->get('approve_permission')))) bw_go(bw_href_prefix().'/mod/tutorial/'); //Update Tutorial Views DB::execute("SELECT * FROM tutorial_view WHERE user_id = ".intval($_SESSION['UserId'])." AND tutorial_id = ".intval($_GET['tutorial_id']), FALSE); if(DB::rowCount() == 0){ DB::execute("INSERT INTO tutorial_view (tutorial_id, user_id, date_first, date_last) VALUES (".intval($_GET['tutorial_id']).", ".intval($_SESSION['UserId']).", now(), now());"); DB::execute("UPDATE tutorial_tutorial SET view_cnt = view_cnt + 1, last_view = now() WHERE tutorial_id = ".intval($_GET['tutorial_id']), FALSE); $tut['view_cnt']++; }else{ DB::execute("UPDATE tutorial_view SET date_last = now() WHERE user_id = ".intval($_SESSION['UserId'])." AND tutorial_id = ".intval($_GET['tutorial_id']).";"); } #Redirect if Offsite if($tut['type'] == 'offsite'){ bw_go($tut['url_offsite']); } #Get author username $tut['username'] = username($tut['user_id']); #Get tutorial comments DB::execute("SELECT a.*, b.username, b.avatar_url FROM tutorial_comment a join bwcore_member b on a.user_id = b.userid WHERE a.tutorial_id = ".$tut['tutorial_id']." ORDER BY date_create desc;"); $tutorial_comments = DB::getResults(); //Paging if(!is_numeric($_GET['page_number']) || $_GET['page_number'] < 0){ $_GET['page_number'] = 1; } Pager::records_per_page(1); DB::execute("SELECT count(*) as total FROM tutorial_page WHERE tutorial_id = ".intval($_GET['tutorial_id']).";"); Pager::records(DB::getAtIndex(0,'total')); DB::execute("SELECT * FROM tutorial_page WHERE tutorial_id = ".intval($_GET['tutorial_id'])." AND page_number = ".$_GET['page_number']); $page = DB::getAtIndex(0); ?> Renderosity Tutorials - Renderosity - 3D Models, 3D Content, 3D Software, and 3D Art