/**
  * \brief Delete
  * Creates a job to detele the folder
  *
  * \param $folderpk - the folder_pk to remove
  * \return NULL on success, string on failure.
  */
 function Delete($folderpk, $Depends = NULL)
 {
     global $SysConf;
     /* Can't remove top folder */
     if ($folderpk == FolderGetTop()) {
         $text = _("Can Not Delete Root Folder");
         return $text;
     }
     /* Get the folder's name */
     $FolderName = FolderGetName($folderpk);
     /* Prepare the job: job "Delete" */
     $user_pk = $SysConf['auth']['UserId'];
     $jobpk = JobAddJob($user_pk, "Delete Folder: {$FolderName}");
     if (empty($jobpk) || $jobpk < 0) {
         $text = _("Failed to create job record");
         return $text;
     }
     /* Add job: job "Delete" has jobqueue item "delagent" */
     $jqargs = "DELETE FOLDER {$folderpk}";
     $jobqueuepk = JobQueueAdd($jobpk, "delagent", $jqargs, NULL, NULL);
     if (empty($jobqueuepk)) {
         $text = _("Failed to place delete in job queue");
         return $text;
     }
     return NULL;
 }
Esempio n. 2
0
 /**
  * \brief Delete
  * Creates a job to detele the folder
  *
  * \param $folderpk - the folder_pk to remove
  * \return NULL on success, string on failure.
  */
 function Delete($folderpk, $userId)
 {
     /* Can't remove top folder */
     if ($folderpk == FolderGetTop()) {
         $text = _("Can Not Delete Root Folder");
         return $text;
     }
     /* Get the folder's name */
     $FolderName = FolderGetName($folderpk);
     /* Prepare the job: job "Delete" */
     $groupId = Auth::getGroupId();
     $jobpk = JobAddJob($userId, $groupId, "Delete Folder: {$FolderName}");
     if (empty($jobpk) || $jobpk < 0) {
         $text = _("Failed to create job record");
         return $text;
     }
     /* Add job: job "Delete" has jobqueue item "delagent" */
     $jqargs = "DELETE FOLDER {$folderpk}";
     $jobqueuepk = JobQueueAdd($jobpk, "delagent", $jqargs, NULL, NULL);
     if (empty($jobqueuepk)) {
         $text = _("Failed to place delete in job queue");
         return $text;
     }
     /* Tell the scheduler to check the queue. */
     $success = fo_communicate_with_scheduler("database", $output, $error_msg);
     if (!$success) {
         return $error_msg . "\n" . $output;
     }
     return NULL;
 }
Esempio n. 3
0
 /**
  * \brief Generate the text for this plugin.
  */
 public function Output()
 {
     /* If this is a POST, then process the request. */
     $FolderSelectId = GetParm('selectfolderid', PARM_INTEGER);
     if (empty($FolderSelectId)) {
         $FolderSelectId = FolderGetTop();
     }
     $FolderId = GetParm('oldfolderid', PARM_INTEGER);
     $NewName = GetParm('newname', PARM_TEXT);
     $NewDesc = GetParm('newdesc', PARM_TEXT);
     if (!empty($FolderId)) {
         $FolderSelectId = $FolderId;
         $rc = $this->Edit($FolderId, $NewName, $NewDesc);
         if ($rc == 1) {
             /* Need to refresh the screen */
             $text = _("Folder Properties changed");
             $this->vars["message"] = $text;
         }
     }
     /* Get the folder info */
     $sql = 'SELECT * FROM folder WHERE folder_pk = $1;';
     $Folder = $this->dbManager->getSingleRow($sql, array($FolderSelectId), __METHOD__ . "getFolderRow");
     /* Display the form */
     $formVars["onchangeURI"] = Traceback_uri() . "?mod=" . $this->Name . "&selectfolderid=";
     $formVars["folderListOption"] = FolderListOption(-1, 0, 1, $FolderSelectId);
     $formVars["folder_name"] = $Folder['folder_name'];
     $formVars["folder_desc"] = $Folder['folder_desc'];
     return $this->renderString("admin-folder-edit-form.html.twig", $formVars);
 }
 /**
  * \brief Given a folder's ID and a TargetId, move
  * the folder from the old patent to the TargetId!
  * Includes idiot checking since the input comes from stdin.
  * 
  * \return 1 if renamed, 0 if failed.
  */
 function Move($FolderId, $NewParentId)
 {
     global $Plugins;
     global $PG_CONN;
     /* Check the name */
     if (empty($NewParentId)) {
         return 0;
     }
     if ($FolderId == $NewParentId) {
         return 0;
     }
     // already there
     if ($FolderId == FolderGetTop()) {
         return 0;
     }
     // cannot move folder root
     /* Both folders must exist */
     $sql = "SELECT * FROM folder where folder_pk = '{$FolderId}';";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $Row = pg_fetch_assoc($result);
     if ($Row['folder_pk'] != $FolderId) {
         pg_free_result($result);
         return 0;
     }
     pg_free_result($result);
     /* Second folder exist? */
     $sql = "SELECT * FROM folder where folder_pk = '{$NewParentId}';";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $Row = pg_fetch_assoc($result);
     if ($Row['folder_pk'] != $NewParentId) {
         pg_free_result($result);
         return 0;
     }
     pg_free_result($result);
     /* Do the move */
     $Sql = "SELECT * from foldercontents WHERE child_id = '{$FolderId}' AND foldercontents_mode = '1';";
     $result = pg_query($PG_CONN, $Sql);
     DBCheckResult($result, $Sql, __FILE__, __LINE__);
     $Row = pg_fetch_assoc($result);
     $fc_pk = $Row['foldercontents_pk'];
     pg_free_result($result);
     $Sql = "UPDATE foldercontents SET parent_fk = '{$NewParentId}' WHERE child_id = '{$FolderId} ' AND foldercontents_pk = '{$fc_pk}' AND foldercontents_mode = '1'";
     $result = pg_query($PG_CONN, $Sql);
     DBCheckResult($result, $Sql, __FILE__, __LINE__);
     pg_free_result($result);
     return 1;
 }
Esempio n. 5
0
 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $folderId = intval($request->get('folder'));
     if (empty($folderId)) {
         $folderId = FolderGetTop();
     }
     $uploadId = intval($request->get('upload'));
     $agents = $request->get('agents') ?: '';
     if (!empty($uploadId) && !empty($agents) && is_array($agents)) {
         $rc = $this->agentsAdd($uploadId, $agents, $request);
         if (empty($rc)) {
             $status = GetRunnableJobList();
             $scheduler_msg = empty($status) ? _("Is the scheduler running? ") : '';
             $url = Traceback_uri() . "?mod=showjobs&upload={$uploadId}";
             $text = _("Your jobs have been added to job queue.");
             $linkText = _("View Jobs");
             $msg = "{$scheduler_msg}" . "{$text} <a href=\"{$url}\">{$linkText}</a>";
             $vars['message'] = $msg;
         } else {
             $text = _("Scheduling of Agent(s) failed: ");
             $vars['message'] = $text . $rc;
         }
     }
     $vars['uploadScript'] = ActiveHTTPscript("Uploads");
     $vars['agentScript'] = ActiveHTTPscript("Agents");
     $vars['folderId'] = $folderId;
     $vars['folderListOptions'] = FolderListOption(-1, 0, 1, $folderId);
     $vars['folderListUploads'] = FolderListUploads_perm($folderId, Auth::PERM_WRITE);
     $vars['baseUri'] = Traceback_uri();
     $vars['uploadId'] = $uploadId;
     $parmAgentList = MenuHook::getAgentPluginNames("ParmAgents");
     $out = '<ol>';
     $parmAgentFoots = '';
     foreach ($parmAgentList as $parmAgent) {
         $agent = plugin_find($parmAgent);
         $out .= "<br/><b>" . $agent->AgentName . ":</b><br/>";
         $out .= $agent->renderContent($vars);
         $parmAgentFoots .= $agent->renderFoot($vars);
     }
     $out .= '</ol>';
     $vars['out'] = $out;
     $vars['outFoot'] = '<script language="javascript"> ' . $parmAgentFoots . '</script>';
     return $this->render('agent_adder.html.twig', $this->mergeWithDefault($vars));
 }
Esempio n. 6
0
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     $FolderId = GetParm("folder", PARM_INTEGER);
     if (empty($FolderId)) {
         $FolderId = FolderGetTop();
     }
     $V = '';
     $uploadList = FolderListUploads_perm($FolderId, Auth::PERM_WRITE);
     foreach ($uploadList as $upload) {
         $V .= "<option value='" . $upload['upload_pk'] . "'>";
         $V .= htmlentities($upload['name']);
         if (!empty($upload['upload_desc'])) {
             $V .= " (" . htmlentities($upload['upload_desc']) . ")";
         }
         if (!empty($upload['upload_ts'])) {
             $V .= " :: " . htmlentities($upload['upload_ts']);
         }
         $V .= "</option>\n";
     }
     return new Response($V, Response::HTTP_OK, array('Content-type' => 'text/plain'));
 }
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     global $Plugins;
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             $FolderId = GetParm("folder", PARM_INTEGER);
             if (empty($FolderId)) {
                 $FolderId = FolderGetTop();
             }
             $List = FolderListUploads_perm($FolderId, PERM_WRITE);
             foreach ($List as $L) {
                 $V .= "<option value='" . $L['upload_pk'] . "'>";
                 $V .= htmlentities($L['name']);
                 if (!empty($L['upload_desc'])) {
                     $V .= " (" . htmlentities($L['upload_desc']) . ")";
                 }
                 if (!empty($L['upload_ts'])) {
                     $V .= " :: " . htmlentities($L['upload_ts']);
                 }
                 $V .= "</option>\n";
             }
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
Esempio n. 8
0
/**
 * \brief Get an array of all the folders from a $RootFolder on down.
 * Recursive.  This is typically used to build a select list of folder names.
 *
 * \param $RootFolder default is entire software repository
 * \param $FolderArray returned array of folder_pk=>folder_name's
 *
 * \return $FolderArray of {folder_pk=>folder_name, folder_pk=>folder_name, ...}
 * in folder order.
 * If no folders are in the list, an empty array is returned.
 *
 * \todo Possibly this could be a common function and FolderListOption() could 
 *       use this for its data.  In general data collection and data formatting
 *       should be separate functions.
 */
function GetFolderArray($RootFolder, &$FolderArray)
{
    global $PG_CONN;
    if ($RootFolder == "-1") {
        $RootFolder = FolderGetTop();
    }
    if (empty($RootFolder)) {
        return $FolderArray;
    }
    /* Load this folder's name */
    $sql = "SELECT folder_name, folder_pk FROM folder WHERE folder_pk={$RootFolder} LIMIT 1;";
    $result = pg_query($PG_CONN, $sql);
    DBCheckResult($result, $sql, __FILE__, __LINE__);
    $row = pg_fetch_assoc($result);
    pg_free_result($result);
    $Name = trim($row['folder_name']);
    $FolderArray[$row['folder_pk']] = $row['folder_name'];
    /* Load any subfolders */
    $sql = "SELECT folder.folder_pk, folder.folder_name,\n            foldercontents.parent_fk\n            FROM folder, foldercontents\n            WHERE foldercontents.foldercontents_mode = " . FolderDao::MODE_FOLDER . "\n            AND foldercontents.parent_fk ={$RootFolder}\n            AND foldercontents.child_id = folder.folder_pk\n            AND folder.folder_pk is not null\n            ORDER BY folder_name";
    $result = pg_query($PG_CONN, $sql);
    DBCheckResult($result, $sql, __FILE__, __LINE__);
    if (pg_num_rows($result) > 0) {
        while ($row = pg_fetch_assoc($result)) {
            GetFolderArray($row['folder_pk'], $FolderArray);
        }
    }
    pg_free_result($result);
}
Esempio n. 9
0
/**
 * \brief Given a folder path, return the folder_pk.
 * 
 * \param $FolderPath - path from -f
 * \param $Parent - parent folder of $FolderPath
 * 
 * \return folder_pk, 1: 'Software Repository', others: specified folder 
 * \note If any part of the folder path does not exist, thenscp cp2foss will create it.
 * This is recursive!
 */
function GetFolder($FolderPath, $Parent = NULL)
{
    global $PG_CONN;
    global $Verbose;
    global $Test;
    if (empty($Parent)) {
        $Parent = FolderGetTop();
    }
    /*/ indicates it's the root folder. Empty folder path ends recursion. */
    if ($FolderPath == '/') {
        return $Parent;
    }
    if (empty($FolderPath)) {
        return $Parent;
    }
    list($folderHead, $folderTail) = explode('/', $FolderPath, 2);
    if (empty($folderHead)) {
        return GetFolder($folderTail, $Parent);
    }
    /* See if it exists */
    $SQLFolder = str_replace("'", "''", $folderHead);
    $SQL = "SELECT * FROM folder\n  INNER JOIN foldercontents ON child_id = folder_pk\n  AND foldercontents_mode = '1'\n  WHERE foldercontents.parent_fk = '{$Parent}' AND folder_name='{$SQLFolder}'";
    if ($Verbose) {
        print "SQL=\n{$SQL}\n";
    }
    $result = pg_query($PG_CONN, $SQL);
    DBCheckResult($result, $SQL, __FILE__, __LINE__);
    $row = pg_fetch_assoc($result);
    $row_count = pg_num_rows($result);
    if ($row_count <= 0) {
        /* Need to create folder */
        global $Plugins;
        $P =& $Plugins[plugin_find_id("folder_create")];
        if (empty($P)) {
            print "FATAL: Unable to find folder_create plugin.\n";
            exit(1);
        }
        if ($Verbose) {
            print "Folder not found: Creating {$folderHead}\n";
        }
        if (!$Test) {
            $P->create($Parent, $folderHead, "");
            pg_free_result($result);
            $result = pg_query($PG_CONN, $SQL);
            DBCheckResult($result, $SQL, __FILE__, __LINE__);
            $row = pg_fetch_assoc($result);
        }
    }
    $Parent = $row['folder_pk'];
    pg_free_result($result);
    return GetFolder($folderTail, $Parent);
}
Esempio n. 10
0
/**
 * \brief Given a folder path, return the folder_pk.
 * 
 * \param $FolderPath - path from -f
 * \param $Parent - parent folder of $FolderPath
 * 
 * \return folder_pk, 1: 'Software Repository', others: specified folder 
 * \note If any part of the folder path does not exist, thenscp cp2foss will create it.
 * This is recursive!
 */
function GetFolder($FolderPath, $Parent = NULL)
{
    $dbManager = $GLOBALS['container']->get('db.manager');
    global $Verbose;
    global $Test;
    if (empty($Parent)) {
        $Parent = FolderGetTop();
    }
    /*/ indicates it's the root folder. Empty folder path ends recursion. */
    if ($FolderPath == '/') {
        return $Parent;
    }
    if (empty($FolderPath)) {
        return $Parent;
    }
    list($folderHead, $folderTail) = explode('/', $FolderPath, 2);
    if (empty($folderHead)) {
        return GetFolder($folderTail, $Parent);
    }
    /* See if it exists */
    $SQL = "SELECT folder_pk FROM folder\n  INNER JOIN foldercontents ON child_id = folder_pk\n  AND foldercontents_mode = '1'\n  WHERE foldercontents.parent_fk = \$1 AND folder_name = \$2";
    if ($Verbose) {
        print "SQL=\n{$SQL}\n\$1={$Parent}\n\$2={$folderHead}\n";
    }
    $row = $dbManager->getSingleRow($SQL, array($Parent, $folderHead), __METHOD__ . ".GetFolder.exists");
    if (empty($row)) {
        /* Need to create folder */
        global $Plugins;
        $P =& $Plugins[plugin_find_id("folder_create")];
        if (empty($P)) {
            print "FATAL: Unable to find folder_create plugin.\n";
            exit(1);
        }
        if ($Verbose) {
            print "Folder not found: Creating {$folderHead}\n";
        }
        if (!$Test) {
            $P->create($Parent, $folderHead, "");
            $row = $dbManager->getSingleRow($SQL, array($Parent, $folderHead), __METHOD__ . ".GetFolder.exists");
        }
    }
    $Parent = $row['folder_pk'];
    return GetFolder($folderTail, $Parent);
}
Esempio n. 11
0
 /**
  * \brief Generate the text for this plugin.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /* If this is a POST, then process the request. */
             $Folder = GetParm('folder', PARM_INTEGER);
             if (empty($Folder)) {
                 $Folder = FolderGetTop();
             }
             $uploadpk = GetParm('upload', PARM_INTEGER);
             if (array_key_exists('agents', $_REQUEST)) {
                 $agents = $_POST['agents'];
             } else {
                 $agents = '';
             }
             if (!empty($uploadpk) && !empty($agents) && is_array($agents)) {
                 $rc = $this->AgentsAdd($uploadpk, $agents);
                 if (empty($rc)) {
                     $URL = Traceback_uri() . "?mod=showjobs&upload={$uploadpk} ";
                     /* Need to refresh the screen */
                     $text = _("Your jobs have been added to job queue.");
                     $LinkText = _("View Jobs");
                     $msg = "{$text} <a href={$URL}>{$LinkText}</a>";
                     $V .= displayMessage($msg);
                 } else {
                     $text = _("Scheduling of Agent(s) failed: ");
                     $V .= displayMessage($text . $rc);
                 }
             }
             /**
              * Create the AJAX (Active HTTP) javascript for doing the reply
              * and showing the response. 
              */
             $V .= ActiveHTTPscript("Uploads");
             $V .= "<script language='javascript'>\n";
             $V .= "function Uploads_Reply()\n";
             $V .= "  {\n";
             $V .= "  if ((Uploads.readyState==4) && (Uploads.status==200))\n";
             $V .= "    {\n";
             /* Remove all options */
             $V .= "    document.getElementById('uploaddiv').innerHTML = '<select size=\\'10\\' name=\\'upload\\' onChange=\\'Agents_Get(\"" . Traceback_uri() . "?mod=upload_agent_options&upload=\" + this.value)\\'>' + Uploads.responseText + '</select><P />';\n";
             //$V .= "alert(document.getElementById('uploaddiv').innerHTML)\n";
             $V .= "    document.getElementById('agentsdiv').innerHTML = '';\n";
             /* Add new options */
             $V .= "    }\n";
             $V .= "  }\n";
             $V .= "</script>\n";
             $V .= ActiveHTTPscript("Agents");
             $V .= "<script language='javascript'>\n";
             $V .= "function Agents_Reply()\n";
             $V .= "  {\n";
             $V .= "  if ((Agents.readyState==4) && (Agents.status==200))\n";
             $V .= "    {\n";
             /* Remove all options */
             $V .= "    document.getElementById('agentsdiv').innerHTML = '<select multiple size=\\'10\\' id=\\'agents\\' name=\\'agents[]\\'>' + Agents.responseText + '</select>';\n";
             /* Add new options */
             $V .= "    }\n";
             $V .= "  }\n";
             $V .= "</script>\n";
             /*************************************************************/
             /* Display the form */
             $V .= "<form name='formy' method='post'>\n";
             // no url = this url
             $V .= _("Select an uploaded file for additional analysis.\n");
             $V .= "<ol>\n";
             $text = _("Select the folder containing the upload you wish to analyze:");
             $V .= "<li>{$text}<br>\n";
             $V .= "<select name='folder'\n";
             $V .= "onLoad='Uploads_Get((\"" . Traceback_uri() . "?mod=upload_options&folder={$Folder}' ";
             $V .= "onChange='Uploads_Get(\"" . Traceback_uri() . "?mod=upload_options&folder=\" + this.value)'>\n";
             $V .= FolderListOption(-1, 0, 1, $Folder);
             $V .= "</select><P />\n";
             $text = _("Select the upload to analyze:");
             $V .= "<li>{$text}<br>";
             $V .= "<div id='uploaddiv'>\n";
             $V .= "<select size='10' name='upload' onChange='Agents_Get(\"" . Traceback_uri() . "?mod=upload_agent_options&upload=\" + this.value)'>\n";
             $List = FolderListUploads_perm($Folder, PERM_WRITE);
             foreach ($List as $L) {
                 $V .= "<option value='" . $L['upload_pk'] . "'>";
                 $V .= htmlentities($L['name']);
                 if (!empty($L['upload_desc'])) {
                     $V .= " (" . htmlentities($L['upload_desc']) . ")";
                 }
                 $V .= "</option>\n";
             }
             $V .= "</select><P />\n";
             $V .= "</div>\n";
             $text = _("Select additional analysis.");
             $V .= "<li>{$text}<br>\n";
             $V .= "<div id='agentsdiv'>\n";
             $V .= "<select multiple size='10' id='agents' name='agents[]'></select>\n";
             $V .= "</div>\n";
             $V .= "</ol>\n";
             $text = _("Analyze");
             $V .= "<input type='submit' value='{$text}!'>\n";
             $V .= "</form>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \brief Generate the text for this plugin.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     global $PG_CONN;
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /* If this is a POST, then process the request. */
             $FolderSelectId = GetParm('selectfolderid', PARM_INTEGER);
             if (empty($FolderSelectId)) {
                 $FolderSelectId = FolderGetTop();
             }
             $FolderId = GetParm('oldfolderid', PARM_INTEGER);
             $NewName = GetParm('newname', PARM_TEXT);
             $NewDesc = GetParm('newdesc', PARM_TEXT);
             if (!empty($FolderId)) {
                 $FolderSelectId = $FolderId;
                 $rc = $this->Edit($FolderId, $NewName, $NewDesc);
                 if ($rc == 1) {
                     /* Need to refresh the screen */
                     $text = _("Folder Properties changed");
                     $V .= displayMessage($text);
                 }
             }
             $V .= _("<p>The folder properties that can be changed are the folder name and\n     description.  First select the folder to edit. Then enter the new values.\n     If no value is entered, then the corresponding field will not be changed.</p>");
             /* Get the folder info */
             $sql = "SELECT * FROM folder WHERE folder_pk = '{$FolderSelectId}';";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             $Folder = pg_fetch_assoc($result);
             pg_free_result($result);
             /* Display the form */
             $V .= "<form method='post'>\n";
             // no url = this url
             $V .= "<ol>\n";
             $text = _("Select the folder to edit:  \n");
             $V .= "<li>{$text}";
             $Uri = Traceback_uri() . "?mod=" . $this->Name . "&selectfolderid=";
             $V .= "<select name='oldfolderid' onChange='window.location.href=\"{$Uri}\" + this.value'>\n";
             $V .= FolderListOption(-1, 0, 1, $FolderSelectId);
             $V .= "</select><P />\n";
             $text = _("Change folder name:  \n");
             $V .= "<li>{$text}";
             $V .= "<INPUT type='text' name='newname' size=40 value=\"" . htmlentities($Folder['folder_name'], ENT_COMPAT) . "\" />\n";
             $text = _("Change folder description:  \n");
             $V .= "<P /><li>{$text}";
             $V .= "<INPUT type='text' name='newdesc' size=60 value=\"" . htmlentities($Folder['folder_desc'], ENT_COMPAT) . "\" />\n";
             $V .= "</ol>\n";
             $text = _("Edit");
             $V .= "<input type='submit' value='{$text}!'>\n";
             $V .= "</form>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
Esempio n. 13
0
 public function Output()
 {
     $V = "";
     $upload_id = GetParm('upload', PARM_INTEGER);
     $manage = GetParm('manage', PARM_TEXT);
     /* If this is a POST, then process the request. */
     $Folder = GetParm('folder', PARM_INTEGER);
     if (empty($Folder)) {
         $Folder = FolderGetTop();
     }
     $rc = $this->ManageTag($Folder, $upload_id, $manage);
     if (1 == $rc) {
         $text1 = _("all uploads in folder");
         $text2 = _("in folder");
         $folder_path = FolderGetName($Folder);
         $upload_name = GetUploadName($upload_id);
         if (empty($upload_id)) {
             $text = $text1;
         } else {
             $text = "'{$upload_name}' {$text2}";
         }
         $Msg = "{$manage} {$text} '{$folder_path}'";
         $this->vars['message'] = $Msg;
         // reset form fields
     }
     /**
      * Create the AJAX (Active HTTP) javascript for doing the reply
      * and showing the response.
      * get upload list under one folder
      */
     $V .= ActiveHTTPscript("Uploads");
     $V .= "<script language='javascript'>\n";
     $V .= "function Uploads_Reply()\n";
     $V .= "  {\n";
     $V .= "  if ((Uploads.readyState==4) && (Uploads.status==200))\n";
     $V .= "    {\n";
     $V .= "    document.getElementById('tagdiv').innerHTML = '<select size=\\'10\\' name=\\'upload\\' onChange=\\'Tagging_Get(\"" . Traceback_uri() . "?mod=upload_tagging&upload=\" + this.value)\\'>' + Uploads.responseText+ '</select><P/>';\n";
     $V .= "    document.getElementById('manage_tag').style.display= 'none';\n";
     $V .= "    document.getElementById('manage_tag_all').style.display= 'block';\n";
     $V .= "    }\n";
     $V .= "  }\n";
     $V .= "</script>\n";
     /** select one upload */
     $V .= ActiveHTTPscript("Tagging");
     $V .= "<script language='javascript'>\n";
     $V .= "function Tagging_Reply()\n";
     $V .= "  {\n";
     $V .= "  if ((Tagging.readyState==4) && (Tagging.status==200))\n";
     $V .= "    {\n";
     $V .= "    document.getElementById('manage_tag_all').style.display= 'none';\n";
     $V .= "    document.getElementById('manage_tag').style.display= 'block';\n";
     $V .= "    document.getElementById('manage_tag').innerHTML = Tagging.responseText;\n";
     $V .= "    }\n";
     $V .= "  }\n";
     $V .= "</script>\n";
     $V .= "<form name='formy' method='post'>\n";
     // no url = this url
     $V .= _("Displaying tags while browsing can be slow for large uploads.  This interface allows you to select an upload to disable (or enable) the tag display.  By default the tag display is enabled.<p>\n");
     $V .= "<ol>\n";
     $text = _("Select the folder containing the upload you wish to enable/disable:");
     $V .= "<li>{$text}<br>\n";
     $V .= "<select name='folder'\n";
     $V .= "onLoad='Uploads_Get((\"" . Traceback_uri() . "?mod=upload_options&folder={$Folder}' ";
     $V .= "onChange='Uploads_Get(\"" . Traceback_uri() . "?mod=upload_options&folder=\" + this.value)'>\n";
     $V .= FolderListOption(-1, 0, 1, $Folder);
     $V .= "</select><P />\n";
     $text = _("Select the upload to  enable/disable:");
     $V .= "<li>{$text}<br>";
     $V .= "<div id='tagdiv'>\n";
     $V .= "<select size='10' name='upload' onChange='Tagging_Get(\"" . Traceback_uri() . "?mod=upload_tagging&upload=\" + this.value)'>\n";
     $List = FolderListUploads_perm($Folder, Auth::PERM_WRITE);
     foreach ($List as $L) {
         $V .= "<option value='" . $L['upload_pk'] . "'>";
         $V .= htmlentities($L['name']);
         if (!empty($L['upload_desc'])) {
             $V .= " (" . htmlentities($L['upload_desc']) . ")";
         }
         $V .= "</option>\n";
     }
     $V .= "</select><P />\n";
     $V .= "</div>\n";
     $V .= "<div id='manage_tag_all'>";
     $text = _("Disable");
     $V .= "<input type='submit' name='manage'  value='{$text}'>\n";
     $text = _("Enable");
     $V .= "<input type='submit' name='manage' value='{$text}'>\n";
     $V .= "</div>";
     $V .= "<div id='manage_tag'>";
     $V .= "</div>";
     return $V;
 }