Exemple #1
0
         // Set status of file to 1 - online
         $sql = "INSERT INTO {$_TABLES['nxfile_files']} (cid,fname,title,version,ftype,size,mimetype,extension,submitter,status,date) ";
         $sql .= "VALUES ({$_CLEAN['cid']},'{$uploadfilename}','{$_CLEAN['filetitle']}','1','file',";
         $sql .= "'{$filesize}','{$mimetype}','{$fileExtension}',{$uid},1,'{$date}')";
         DB_query($sql);
         $fid = DB_insertId();
         // New File ID
         $tagcloud = new nexfileTagCloud();
         // Update tags table and return tags formated as required
         $tagcloud->update_tags($fid, $_POST['tags']);
         DB_query("INSERT INTO {$_TABLES['nxfile_filedetail']} (fid,description,hits,rating,votes,comments)\r\n                    VALUES ('{$fid}','{$_CLEAN['description']}','0','0','0','0')");
         DB_query("INSERT INTO {$_TABLES['nxfile_fileversions']} (fid,fname,ftype,version,notes,size,date,uid,status)\r\n                    VALUES ('{$fid}','{$uploadfilename}','file','1','{$_CLEAN['vernote']}','{$filesize}','{$date}','{$uid}','1')");
         PLG_itemSaved($fid, 'nexfile_filesaved');
         // 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={$_CLEAN['cid']}") == 1) {
             fm_autoCreateNotifications($fid, $_CLEAN['cid']);
         }
         // Send out notifications of update
         if ($_POST['notify'] == "true") {
             fm_sendNotification($fid);
         }
         fm_updateAuditLog("Direct upload of File ID: {$fid}, in Category: {$_CLEAN['cid']}");
         $data['error'] = 'File successfully uploaded';
         $data['retcode'] = 200;
     } else {
         $data['retcode'] = 400;
         // Needed to trim the last charcter off for some reason, as it was causing the JS success code to fail
         $data['error'] = str_replace(array('<BR>', '<br>'), ' ', $GLOBALS['fm_errmsg']);
         $data['error'] = substr($data['error'], 0, strlen($data['error']) - 1);
     }
 } elseif (fm_getPermission($_CLEAN['cid'], 'upload') and !empty($uploadfilename)) {
Exemple #2
0
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;
    }
}