aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/mayor-naplo/www/policy
diff options
context:
space:
mode:
Diffstat (limited to 'mayor-orig/mayor-naplo/www/policy')
-rw-r--r--mayor-orig/mayor-naplo/www/policy/private/naplo/haladasi/hazifeladat-pre.php75
1 files changed, 73 insertions, 2 deletions
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<count($lattamDiakIds); $i++) {
+ $_diakId = $lattamDiakIds[$i];
+ $q = "UPDATE oraHazifeladatDiak SET tanarLattamDt=NOW() WHERE hazifeladatId=%u AND diakId=%u";
+ $values = array($ADAT['hazifeladatId'], $_diakId);
+ db_query($q, array('modul'=>'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);