EIOS/inc/portfolio.php

212 lines
7.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
session_start();
$info = array();
//портфолио
//если не указано конкретное портфолио, то выводим несколько последних
if (!isset($_GET['page'])){
$portfolio = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_portfolio WHERE LENGTH(about)>=100 ORDER BY id DESC LIMIT 60';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['user'] = get_user($val['id_user']);
$val['student'] = get_student($val['id_user']);
//указываем информацию об образовании - названии специальности
$rez_edu = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_areas WHERE code = "'.$val['student']['specialnost'].'" ');
$val['edu'] = $rez_edu[1]['name'];
$val['kurs'] = courseOfGruppa($val['student']['id_grupp']);
$val['about'] = html_entity_decode($val['about']);
$val['languages'] = html_entity_decode($val['languages']);
if (!(isset($_POST['search']))) $portfolio[] = $val;
else{
$order_is = 1; //можно публиковать
if ($_POST['course'] > 0) { if ($val['kurs'] == $_POST['course']) $order_is = 1; else $order_is = 0; }
if ($order_is == 1) if ($_POST['area'] > 0) { if ($rez_edu[1]['id'] == $_POST['area']) $order_is = 1; else $order_is = 0; }
if ($order_is == 1) $portfolio[] = $val;
}
//else return;
}
}
//специальности
$areas = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_areas ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$areas[] = $val;
}
}
/*echo '<pre>';
print_r($_POST);
echo '</pre>';*/
//$smarty->assign('post', $_POST);
$smarty->assign('areas', $areas);
$smarty->assign('portfolio', $portfolio);
$smarty->assign('control', $control);
} else{ //вывод детального портфолио
$id = (int) $_GET['page'];
$sql = 'SELECT * FROM '.$ST['dbpf'].'_portfolio WHERE id_user = "'.$id.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$rez[1]['user'] = get_user($rez[1]['id_user']);
$rez[1]['student'] = get_student($rez[1]['id_user']);
$rez[1]['about'] = html_entity_decode($rez[1]['about']);
$rez[1]['languages'] = html_entity_decode($rez[1]['languages']);
$rez[1]['pc'] = html_entity_decode($rez[1]['pc']);
//указываем информацию об образовании - названии специальности
$rez_edu = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_areas WHERE code = "'.$rez[1]['student']['specialnost'].'" ');
$rez[1]['edu'] = $rez_edu[1]['name'];
$rez[1]['kurs'] = courseOfGruppa($rez[1]['student']['id_grupp']);
//теперь смотрим достижения
$rez[1]['achievements'] = array();
$sql_ach = 'SELECT * FROM '.$ST['dbpf'].'_achievements WHERE id_user = "'.$id.'" ';
//echo $sql_ach;
$rez_ach = $DB->QUR_SEL($sql_ach);
if ($rez_ach){
foreach ($rez_ach as $key_ach => $val) if ($key_ach){
$val['date_p'] = date('d.m.Y', $val['date_p']);
$rez[1]['achievements'][$val['region']][] = $val;
//$rez[1]['achievements'][] = $val;
}
}
//смотрим успеваемость
$rez[1]['marks'] = array();
$sql_mark = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id_user = "'.$id.'" GROUP BY name ORDER BY semestr DESC ';
$rez_mark = $DB->QUR_SEL($sql_mark);
if ($rez_mark){
foreach ($rez_mark as $key_m => $val) if ($key_m){
$rez[1]['marks'][] = $val;
}
}
//студенческие работы
$rez[1]['studwork'] = array();
$sql_studwork = 'SELECT * FROM '.$ST['dbpf'].'_studwork WHERE id_user = "'.$id.'" ORDER BY semestr DESC ';
$rez_studwork = $DB->QUR_SEL($sql_studwork);
if ($rez_studwork){
foreach ($rez_studwork as $key_s => $val) if ($key_s){
$rez[1]['studwork'][] = $val;
}
}
}
//echo '<pre>'; print_r($rez); echo '</pre>';
$smarty->assign('portfolio', $rez[1]);
$smarty->assign('id_portfolio', $id);
}
/*ВСЕ ЧТО НИЖЕ - УЖЕ НЕАКТУАЛЬНО
if(isset($_POST['save_portfolio'])){
//данные в формтае bl_номер блока it_номер пункта
$rez = $DB->QUR('DELETE FROM '.$ST['dbpf'].'_trudo_portfolio WHERE id_user='.$_SESSION['user']['id'].'');
$id_block=0; $id_item=0; $pos=0;
foreach($_POST as $key => $val)if($key!='save_portfolio'){
$t=explode('_',$key);
if($id_block==$t[1] && $id_item==$t[3]) $pos++; else $pos=0;
$id_block=$t[1]; $id_item=$t[3];
foreach($val as $k => $v){
$znach = addslashes(htmlspecialchars($v));
if ($znach!=''){
$sql = 'INSERT INTO '.$ST['dbpf'].'_trudo_portfolio VALUES (0,'.mktime().','.$_SESSION['user']['id'].','.$id_block.','.$id_item.',"'.$znach.'",'.$pos.');';
$rez = $DB->QUR($sql);
}
}
}
save_logs('Анкета портфолио пользователя '.$_SESSION['user']['id'].' сохранена');
}
//print_r($_GET);
if(isset($_GET['page'])){
if($_GET['page']=='make'){
$info['descrip'] = '<p>В данном разделе необходимо заполнить анкету для портфолио.</p><p>Ваше портфолио будет доступно по ссылке вида <a href="http://learn.mkgtu.ru/pf/'.$_SESSION['user']['id'].'/">http://learn.mkgtu.ru/pf/'.$_SESSION['user']['id'].'/</a></p>';
if (isset($_GET['des'])){}
$info['blocks']=array();
$info['blocks']=recursiv_show();
$info['portfo']=get_portfolio($_SESSION['user']['id']);
$smarty->assign('info',$info);
$maincontent = $smarty->fetch('tpl_portfolio.html');
}
if($_GET['page']=='showuser'){
$id=(int)$_GET['id'];
$info['blocks']=recursiv_show();
$info['portfo']=get_portfolio($id);
$smarty->assign('info',$info);
$maincontent = $smarty->fetch('tpl_portfolio_show.html');
}
}
function recursiv($par=0,$old=0,$id=0){//отображение в древовидной структуре данных блоков для ВЫБОРА
global $ST,$DB; $out = '';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_trudo_blocks WHERE par='.$par.' ORDER BY pos, name ASC';
$rez = $DB->QUR_SEL($sql);
if($rez)foreach($rez as $key => $val)if($key){
if ($val['par'] == $old) $old--;
$out .= '<option value="'.$val['id'].'"'; if ($val['id'] == $id) $out .= ' SELECTED'; $out .= '>';
for($i=0;$i<=$old;$i++) $out .= '--'; $out .= $val['name'].'</option>';
$out .= recursiv($val['id'],$val['par'],$id);
}
return $out;
}
function recursiv_show($par=0,$old=0){//отображение в древовидной структуре данных блоков ОТОБРАЖЕНИЕ
global $ST,$DB; $out = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_trudo_blocks WHERE par='.$par.' ORDER BY pos, name ASC';
$rez = $DB->QUR_SEL($sql);
if($rez)foreach($rez as $key => $val)if($key){
$out[$key]['id']=$val['id'];
$out[$key]['name']=$val['name'];
$out[$key]['type']=$val['type'];
$out[$key]['sub'] = recursiv_show($val['id'],$val['par']);
$out[$key]['items'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_trudo_items WHERE id_block='.$val['id'].' ORDER BY pos, name ASC';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1)foreach($rez1 as $key1 => $val1)if($key1){
$out[$key]['items'][] = $val1;
}
}
return $out;
}
function get_portfolio($id_user){//ПОЛУЧЕНИЕ ПОРТФОЛИО ПОЛЬЗОВАТЕЛЯ
global $ST,$DB; $out = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_trudo_portfolio WHERE id_user='.$id_user.' ORDER BY id_block,id_item,pos,data_c';
$rez = $DB->QUR_SEL($sql);
if($rez)foreach($rez as $key => $val)if($key){
$val['data']=date('H:i:s d.m.Y',$val['data_c']);
$val['znach']=stripslashes($val['znach']);
$out[$val['id_block']][$val['id_item']][]=$val;
}
//print_r($out);
return $out;
}
function get_type($id=0){
$out=array();
$type=array(0=>'Одиночный',1=>'Добавляемый');
foreach($type as $key => $val){
$out[$key]['id']=$key;
$out[$key]['name']=$val;
if ($id==$key) $out[$key]['sele']=1; else $out[$key]['sele']=0;
}
return $out;
}*/
?>