From 351ace3031cf063cef346027ae209d218225242a Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Tue, 24 Mar 2020 15:53:18 +0100 Subject: Rev: 4632 --- .../hu_HU/module-naplo/haladasi/hazifeladat.php | 2 +- .../private/naplo/haladasi/hazifeladat-pre.php | 75 +++++++++++++- .../module-naplo/css/haladasi/hazifeladat.css | 34 ++++++- .../module-naplo/html/haladasi/hazifeladat.phtml | 109 +++++++++++++++++---- 4 files changed, 193 insertions(+), 27 deletions(-) (limited to 'mayor-orig/mayor-naplo/www') diff --git a/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php b/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php index 6799d19e..c9767f65 100644 --- a/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php +++ b/mayor-orig/mayor-naplo/www/lang/hu_HU/module-naplo/haladasi/hazifeladat.php @@ -37,5 +37,5 @@ define('_ALAPADATOK','Óra adatok'); define('_HAZIFELADAT','Házi feladat, Részletek, Referenciák, Hivatkozások'); - + define('_HAZIFELTOLTES','Házi feltöltés (max. 1 file)'); ?> diff --git a/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php b/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php index 28a02d5a..d0f4cb6b 100644 --- a/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php +++ b/mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php @@ -18,12 +18,36 @@ require_once('include/modules/naplo/share/hetes.php'); require_once('include/modules/naplo/share/helyettesitesModifier.php'); require_once('include/modules/naplo/share/file.php'); + require_once('include/share/net/upload.php'); require_once('include/share/date/names.php'); +// config + define('FILE_UPLOAD_DIR',_DOWNLOADDIR.'/private/naplo/haladasi/hazifeladat/'); + $config['lowfreespacelimit'] = 335617790; // 330MB +/* + dump(disk_free_space($config['dir'])); + dump($file_uploads = ini_get('file_uploads')); // must be On + dump($post_max_size = ini_get('post_max_size')); // recommended: 64M + dump($upload_max_filesize = ini_get('upload_max_filesize')); // recommended: 60M + dump(human_filesize(file_upload_max_size())); +*/ + + if (disk_free_space(FILE_UPLOAD_DIR)<$config['lowfreespacelimit']) { + $disableUpload = true; + if (__NAPLOADMIN === true) $_SESSION['alert'][] = 'info:nincs elég szabad hely, ezért nem tudsz filet feltölteni'; + } + if (!ini_get('file_uploads')) { + $disableUpload = true; + if (__NAPLOADMIN === true) $_SESSION['alert'][] = 'info:feltöltés kikapcsolva (file_uploads)'; + } + if ($disableUpload===true) define('FILE_UPLOAD_ENABLED',false); + else define('FILE_UPLOAD_ENABLED',true); +// -- + $ADAT['oraId' ] = $oraId = readVariable($_POST['oraId'],'id',readVariable($_GET['oraId'],'id')); // $ADAT['hazifeladatId' ] = $hazifeladatId = readVariable($_POST['hazifeladatId'],'id', readVariable($_GET['hazifeladatId'],'id')); $ADAT['hazifeladatLeiras' ] = readVariable($_POST['hazifeladatLeiras'],'string'); - $action = readVariable($_POST['action'],'strictstring',null,array('hazifeladatBeiras','hazifeladatKesz')); + $action = readVariable($_POST['action'],'strictstring',null,array('hazifeladatBeiras','hazifeladatKesz','hazifeladatFeltoltes','lattam')); $q = "SELECT hazifeladatId FROM oraHazifeladat WHERE oraId=%u"; $values = array($ADAT['oraId']); @@ -46,12 +70,24 @@ $leiras = readVariable($_POST['oraLeiras'],'string'); updateHaladasiNaploOra($oraId, $leiras); } + } elseif (__TANAR===true && $action=='lattam') { + $lattamDiakIds = readVariable($_POST['lattam'],'id'); + $q = "UPDATE oraHazifeladatDiak SET tanarLattamDt=null WHERE hazifeladatId=%u"; + $values = array($ADAT['hazifeladatId'], $_diakId); + db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); + for ($i=0; $i'naplo','result'=>'update','values'=>$values)); + } } elseif (__DIAK===true) { if (defined('__USERDIAKID') && __USERDIAKID>0) { $diakId=__USERDIAKID; } elseif (defined('__SZULODIAKID') && __SZULODIAKID>0) { $diakId=__SZULODIAKID; } + if ($diakId>0) { $q = "INSERT IGNORE INTO oraHazifeladatDiak (hazifeladatId,diakId,diakLattamDt) VALUES (%u,%u,NOW())"; $values = array($ADAT['hazifeladatId'], $diakId); @@ -64,6 +100,41 @@ db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); } } + + if (FILE_UPLOAD_ENABLED===true && $action=='hazifeladatFeltoltes') { + if (is_array($_FILES) && $_FILES['upfile']['name']!='') { + $FILEADAT['subdir'] = FILE_UPLOAD_DIR; + $ext = filename2ext($_FILES['upfile']['name']); + $ext2 = filemime2ext($_FILES['upfile']['type']); + if ($ext != $ext2) { + // $_SESSION['alert'][] = 'info:file_mime_type_extension_mismatch:'.$ext.':'.$ext2; + if ($ext2!='') $ext = $ext2; + } + $FILEADAT['filename'] = $hazifeladatId.'_'.$diakId.'_'.uniqid().'.'.$ext; + try { + $sikeresFeltoltes = mayorFileUpload($FILEADAT, false); + } catch (Exception $e) { + dump($e); + } + + if ($sikeresFeltoltes===true) { + // --todo unlink existing?-- + + $q = "SELECT hazifeladatDiakFilename FROM oraHazifeladatDiak WHERE hazifeladatId=%u AND diakId=%u"; + $values = array($ADAT['hazifeladatId'],$diakId); + $oldFilename = db_query($q, array('modul'=>'naplo','result'=>'value','values'=>$values)); + + if (file_exists(FILE_UPLOAD_DIR.$oldFilename)) unlink(FILE_UPLOAD_DIR.$oldFilename); + + $origFilename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $_FILES['upfile']['name']); + $origFilename = mb_ereg_replace("([\.]{2,})", '', $_FILES['upfile']['name']); + if ($origFilename=='') $origFilename = $FILEADAT['filename']; + $q = "UPDATE oraHazifeladatDiak SET hazifeladatDiakFilename='%s',hazifeladatDiakOrigFilename='%s' WHERE hazifeladatId=%u AND diakId=%u"; + $values = array($FILEADAT['filename'],$origFilename,$ADAT['hazifeladatId'], $diakId); + db_query($q, array('modul'=>'naplo','result'=>'update','values'=>$values)); + } + } + } $q = "SELECT * FROM oraHazifeladatDiak WHERE hazifeladatId=%u AND diakId=%u"; $values = array($ADAT['hazifeladatId'],$diakId); $ADAT['hazifeladatDiak'] = db_query($q, array('modul'=>'naplo','result'=>'record','values'=>$values)); @@ -78,7 +149,7 @@ if (__TANAR===true || __NAPLOADMIN===true || __VEZETOSEG===true) { $q = "SELECT *,getNev(diakId,'diak') AS diakNev FROM oraHazifeladatDiak WHERE hazifeladatId=%u ORDER BY diakNev"; $values = array($ADAT['hazifeladatId']); - $ADAT['hazifeladatDiak'] = db_query($q, array('debug'=>true,'modul'=>'naplo','result'=>'indexed','values'=>$values)); + $ADAT['hazifeladatDiak'] = db_query($q, array('debug'=>false,'modul'=>'naplo','result'=>'indexed','values'=>$values)); } $ADAT['oraAdat'] = getOraadatById($oraId); diff --git a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css index 1cce1e3e..1169d008 100644 --- a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css +++ b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/css/haladasi/hazifeladat.css @@ -13,7 +13,6 @@ } form button.btnHfStatusz span { color:#eee; } form button.btnHfStatusz.kesz span { color: lightgreen; } - form button.btnHfStatusz:hover { background-color:lightgreen; color:black; @@ -23,9 +22,38 @@ background-color: orange; } form button.btnHfStatusz:hover span { color: white; } - form button.btnHfStatusz.kesz:hover span { color: orange } + + + +/*---*/ + form button.btnLattamStatusz { + background-color: #eee; + border-radius: 2px; + border: solid 1px #888; + color: #888; + padding:2px 18px 2px 4px; + } + form button.btnLattamStatusz:hover { + background-color:lightgreen; + color:black; + border-color:black; + } + form button.btnLattamStatusz span { color:#eee; } + form button.btnLattamStatusz:hover span { color: white; } + + form button.btnLattamStatusz.lattam { background-color: lightgreen; color:white; } + form button.btnLattamStatusz.lattam span { color: white; } + form button.btnLattamStatusz.lattam:hover {background-color: orange;} + form button.btnLattamStatusz.lattam:hover span { color: orange } + + table.hazifeladatDiak { margin:auto; background-color: #eee;} - table.hazifeladatDiak thead tr th { background-color: #4caf50; color:white; font-weight:normal;} + table.hazifeladatDiak thead tr th { background-color: #4caf50; color:white; font-weight:normal; padding: 2px 4px;} table.hazifeladatDiak tbody tr td { background-color: white; font-weight:normal; padding: 2px 4px;} + + + table.hazifeladatDiak tr td a, fieldset.adatok a { color: black; } + table.hazifeladatDiak tr td a:hover, fieldset.adatok a:hover { text-decoration:underline; color: cornflowerblue; } + diff --git a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml index c5a26c13..a8540faa 100644 --- a/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml +++ b/mayor-orig/mayor-naplo/www/skin/classic/module-naplo/html/haladasi/hazifeladat.phtml @@ -2,25 +2,21 @@ function putHazifeladat($ADAT) { -/* echo ''; -*/ echo '
'._ALAPADATOK.''."\n"; - echo ($ADAT['oraAdat']['dt']).' ('.$ADAT['oraAdat']['dt'].'), '.$ADAT['oraAdat']['ora'].'. '._ORA.' – '.$ADAT['oraAdat']['tankorNev'].' – '.$ADAT['oraAdat']['kiCn']; + echo ''; + echo ($ADAT['oraAdat']['dt']).' ('.$ADAT['oraAdat']['dt'].'), '.$ADAT['oraAdat']['ora'].'. '._ORA; + echo ''; + echo ' – '.$ADAT['oraAdat']['tankorNev'].''; + echo ' – '.$ADAT['oraAdat']['kiCn'].''; // echo '

'.$ADAT['oraAdat']['leiras'].'

'; echo '
'."\n"; - if (__DIAK===true) { + if (__DIAK===true) { //////////////////////////////////////////////////////////////////////////////////////////////// if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') $_class = "kesz"; - if ($skin != 'ajax') formBegin(array('class'=>'hazifeladat')); echo '
'.ucfirst(_TANANYAG).''."\n"; if ($ADAT['oraAdat']['leiras']=='') { echo '

még nincs kitöltve

'; } @@ -33,19 +29,64 @@ else { echo ($ADAT['hazifeladatAdat']['hazifeladatLeiras']); } echo '
'."\n"; - if ($ADAT['hazifeladatId']>0) { - echo '
'; - echo ''; - if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { - echo ''; + + + if ($ADAT['hazifeladatDiak']['hazifeladatId']>0) { + + echo '
'._HAZIFELTOLTES.''."\n"; + echo formBegin(array('enctype'=>'multipart/form-data')); + + if (FILE_UPLOAD_ENABLED===false || $ADAT['hazifeladatDiak']['tanarLattamDt']!='' || $ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + if (FILE_UPLOAD_ENABLED===false) $mert = ', mert a feltöltés le van tiltva'; + elseif ($ADAT['hazifeladatDiak']['tanarLattamDt']!='') $mert = ', mert már láttamozta a tanár'; + elseif ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') $mert = ', mert már késznek jelölted a feladatot'; + echo '

nem tudsz új filet feltölteni'.$mert.'

'; } else { - echo ''; + echo '
'; + echo ''; + echo ' (maximum méret: '.human_filesize(file_upload_max_size()).')'; + if ($ADAT['hazifeladatDiak']['hazifeladatDiakFilename']!='') { + $submitSzoveg = 'a korábbi feltöltés cseréje'; + } else { + $submitSzoveg = 'feltöltés'; + } + echo ' '; + echo '
'; + } + + if ($ADAT['hazifeladatDiak']['hazifeladatDiakFilename']!='') { + $ADAT['dir'] = 'naplo/haladasi/hazifeladat'; + $ADAT['file'] = $ADAT['hazifeladatDiak']['hazifeladatDiakFilename']; + $href = href('index.php?page=session&f=download&dir='.$ADAT['dir'].'&file='.$ADAT['file'].'&download=true'); + echo '

Feltöltve:

'; + echo ''; + } + + echo formEnd(); + echo '
'; + + formBegin(array('class'=>'hazifeladat')); + if ($ADAT['hazifeladatId']>0) { + echo '
'; + echo ''; + if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + echo ''; + } else { + echo ''; + } + echo '
'; } - echo '
'; + echo formEnd(); + + } - - echo formEnd(); - } else { + + } else { //////////////////////////////////////////////////////////////////////////////////// echo ''; if ($skin != 'ajax') formBegin(array('class'=>'hazifeladat')); echo ''; @@ -108,9 +149,12 @@ if (count($ADAT['hazifeladatDiak'])==0) return false; + echo formBegin(); + echo ''; + echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; for ($i=0; $i'.$D['diakLattamDt'].''; echo ''; echo ''; + + $ADAT['dir'] = 'naplo/haladasi/hazifeladat'; + $ADAT['file'] = $D['hazifeladatDiakFilename']; + $href = href('index.php?page=session&f=download&dir='.$ADAT['dir'].'&file='.$ADAT['file'].'&download=true'); + echo ''; + echo ''; echo ''; } echo '
diákláttastátusz
diákláttastátuszcsatolmányláttam
'.$D['hazifeladatDiakStatus'].''.$D['hazifeladatDiakMegjegyzes'].''; + if ($D['hazifeladatDiakOrigFilename']!='') { + echo ''.htmlspecialchars($D['hazifeladatDiakOrigFilename']).' '; + } + echo ''; +// if ($ADAT['hazifeladatDiak']['hazifeladatDiakStatus']=='kész') { + if (__TANAR===true) { + if ($D['tanarLattamDt']=='') { + echo ''; + } else { + echo ''; + } + } else { + if ($D['tanarLattamDt']!='') {echo '';} + } +// } + echo '
'; + echo formEnd(); } ?> -- cgit v1.2.3