$retval = json_encode($data); break; case 'updatefile': $textvars = array('filetitle' => $_POST['filetitle'], 'description' => $_POST['description'], 'tags' => $_POST['tags'], 'approved' => $_POST['approved'], 'vernote' => $_POST['version_note']); $intvars = array('folder' => $_POST['folder'], 'fid' => $_POST['id'], 'version' => $_POST['version']); $filter->setCheckhtml(false); // Need to disable HTML filter or even new lines are removed $filter->cleanData('int', $intvars); $filter->cleanData('text', $textvars); $_CLEAN = $filter->normalize($filter->getDbData('', '', false)); $_WEB = $filter->normalize($filter->getWebData()); $data['tagerror'] = ''; $query = DB_query("SELECT fname,cid,version FROM {$_TABLES['nxfile_files']} WHERE fid={$_CLEAN['fid']}"); list($fname, $cid, $curVersion) = DB_fetchArray($query); $tagcloud = new nexfileTagCloud(); if (fm_getPermission($cid, 'view', 0, false) and !$tagcloud->update_tags($_CLEAN['fid'], $_POST['tags'])) { $data['tagerror'] = 'Tags not added - Group view perms requried'; } $date = time(); $filemoved = false; if ($_CLEAN['approved'] == 'false') { $sql = "UPDATE {$_TABLES['nxfile_filesubmissions']} SET title='{$_CLEAN['filetitle']}', description='{$_CLEAN['description']}', "; $sql .= "version_note='{$_CLEAN['vernote']}', cid={$_CLEAN['folder']}, tags='{$_CLEAN['tags']}' WHERE id={$_CLEAN['fid']} "; DB_query($sql); fm_updateAuditLog("Updated File Submission ID: {$_CLEAN['fid']}"); $data['cid'] = $_CLEAN['folder']; $data['tags'] = $_CLEAN['tags']; } else { // Allow updating the category, title, description and image for the current version and primary file record if ($_CLEAN['version'] == $curVersion) { $newcid = $_CLEAN['folder'];
function nexdocsrv_approveFileSubmission($id) { global $_TABLES, $_CONF, $_FMCONF; $query = DB_query("SELECT fid,cid,fname,tempname,title,description,tags,ftype,size,version,version_note,submitter,date,version_ctl,notify FROM {$_TABLES['nxfile_filesubmissions']} WHERE id={$id}"); list($fid, $cid, $fname, $tmpname, $title, $description, $tags, $ftype, $fsize, $version, $verNote, $submitter, $date, $versionmgmt, $notify) = DB_fetchARRAY($query); $data = array(); // Check if there have been multiple submission requests for the same file and thus have same new version # if ($version == 1) { if ($ftype == 'file') { $curfile = "{$_FMCONF['storage_path']}{$cid}/submissions/{$tmpname}"; $newfile = "{$_FMCONF['storage_path']}{$cid}/{$fname}"; $rename = @rename($curfile, $newfile); } DB_query("INSERT INTO {$_TABLES['nxfile_files']} (cid,fname,title,version,ftype,size,submitter,status,date,version_ctl)\r\n VALUES ('{$cid}','{$fname}','{$title}','1','{$ftype}','{$fsize}','{$submitter}',1,'{$date}','{$versionmgmt}')"); $newfid = DB_insertId(); DB_query("INSERT INTO {$_TABLES['nxfile_filedetail']} (fid,description,hits,rating,votes,comments)\r\n VALUES ('{$newfid}','{$description}',0,0,0,0)"); DB_query("INSERT INTO {$_TABLES['nxfile_fileversions']} (fid,fname,ftype,version,notes,size,date,uid,status)\r\n VALUES ('{$newfid}','{$uploadfilename}','{$ftype}','1','{$verNote}','{$fsize}','{$date}','{$submitter}',1)"); } else { // Need to rename the current versioned file if ($ftype == 'file') { $curfile = $_CONF['path_html'] . 'nexfile/data/' . $cid . '/submissions/' . $tmpname; $newfile = $_CONF['path_html'] . 'nexfile/data/' . $cid . '/' . $fname; $rename = @rename($curfile, $newfile); } DB_query("INSERT INTO {$_TABLES['nxfile_fileversions']} (fid,fname,ftype,version,notes,size,date,uid,status)\r\n VALUES ('{$fid}','{$fname}','{$ftype}','{$version}','{$verNote}','{$fsize}','{$date}','{$submitter}','1')"); DB_query("UPDATE {$_TABLES['nxfile_files']} SET fname='{$fname}',version='{$version}', date='{$date}' WHERE fid={$fid}"); $newfid = $fid; } if ($newfid > 0) { $tagcloud = new nexfileTagCloud(); // Update tags table and return tags formated as required $tagcloud->update_tags($newfid, $tags); // Send out notifications of approval fm_sendNotification($newfid, "2"); DB_query("DELETE FROM {$_TABLES['nxfile_filesubmissions']} WHERE id={$id}"); // Optionally add notification records and send out notifications to all users with view access to this new file if (DB_getItem($_TABLES['nxfile_categories'], 'auto_create_notifications', "cid='{$cid}'") == 1) { fm_autoCreateNotifications($fid, $cid); } // Send out notifications of update to all subscribed users fm_sendNotification($newfid, "1"); return true; } else { return false; } }