/**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     /* Get array of groups that this user is an admin of */
     $groupsWhereUserIsAdmin = GetGroupArray(Auth::getUserId());
     if (empty($groupsWhereUserIsAdmin)) {
         $text = _("You have no permission to manage any group.");
         return $this->render('include/base.html.twig', $this->mergeWithDefault(array('content' => $text)));
     }
     $folder_pk = intval($request->get('folder'));
     $upload_pk = intval($request->get('upload'));
     $perm_upload_pk = intval($request->get('permupk'));
     $perm = intval($request->get('perm'));
     $newgroup = intval($request->get('newgroup'));
     $newperm = intval($request->get('newperm'));
     $public_perm = $request->get('public', -1);
     /* @var $folderDao FolderDao */
     $folderDao = $this->getObject('dao.folder');
     $root_folder_pk = $folderDao->getRootFolder(Auth::getUserId())->getId();
     if (empty($folder_pk)) {
         $folder_pk = $root_folder_pk;
     }
     $UploadList = FolderListUploads_perm($folder_pk, Auth::PERM_WRITE);
     if (empty($upload_pk) && !empty($UploadList)) {
         $upload_pk = $UploadList[0]['upload_pk'];
     }
     if (!empty($perm_upload_pk)) {
         $this->uploadPermDao->updatePermissionId($perm_upload_pk, $perm);
     } else {
         if (!empty($newgroup) && !empty($newperm)) {
             $this->insertPermission($newgroup, $upload_pk, $newperm, $UploadList);
             $newperm = $newgroup = 0;
         } else {
             if ($public_perm >= 0) {
                 $this->uploadPermDao->setPublicPermission($upload_pk, $public_perm);
             }
         }
     }
     $vars = array('folderStructure' => $folderDao->getFolderStructure($root_folder_pk), 'groupArray' => $groupsWhereUserIsAdmin, 'uploadId' => $upload_pk, 'folderId' => $folder_pk, 'baseUri' => Traceback_uri() . '?mod=upload_permissions', 'newPerm' => $newperm, 'newGroup' => $newgroup, 'uploadList' => $UploadList, 'permNames' => $GLOBALS['PERM_NAMES']);
     if (!empty($UploadList)) {
         $vars['publicPerm'] = $this->uploadPermDao->getPublicPermission($upload_pk);
         $permGroups = $this->uploadPermDao->getPermissionGroups($upload_pk);
         $vars['permGroups'] = $permGroups;
         $additableGroups = array(0 => '-- select group --');
         foreach ($groupsWhereUserIsAdmin as $gId => $gName) {
             if (!array_key_exists($gId, $permGroups)) {
                 $additableGroups[$gId] = $gName;
             }
         }
         $vars['additableGroups'] = $additableGroups;
     }
     $vars['gumJson'] = json_encode($this->getGroupMembers($groupsWhereUserIsAdmin));
     if (!empty($upload_pk)) {
         $vars['permNamesWithReuse'] = $this->getPermNamesWithReuse($upload_pk);
     }
     return $this->render('upload_permissions.html.twig', $this->mergeWithDefault($vars));
 }
示例#2
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));
 }
示例#3
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;
 }
 function Output()
 {
     global $PG_CONN;
     global $PERM_NAMES;
     /* GET parameters */
     $folder_pk = GetParm('folder', PARM_INTEGER);
     $upload_pk = GetParm('upload', PARM_INTEGER);
     $users_group_pk = GetParm('group_pk', PARM_INTEGER);
     $group_pk = GetParm('group', PARM_INTEGER);
     $perm_upload_pk = GetParm('permupk', PARM_INTEGER);
     $perm = GetParm('perm', PARM_INTEGER);
     $newgroup = GetParm('newgroup', PARM_INTEGER);
     $newperm = GetParm('newperm', PARM_INTEGER);
     $public_perm = GetParm('public', PARM_INTEGER);
     // start building the output buffer
     $V = "";
     /* If perm_upload_pk is passed in, update either the perm or group_pk */
     $sql = "";
     if (!empty($perm_upload_pk)) {
         if ($perm === 0) {
             $sql = "delete from perm_upload where perm_upload_pk='{$perm_upload_pk}'";
         } else {
             if (!empty($perm)) {
                 $sql = "update perm_upload set perm='{$perm}' where perm_upload_pk='{$perm_upload_pk}'";
             } else {
                 if (!empty($group_pk)) {
                     $sql = "update perm_upload set group_fk='{$group_pk}' where perm_upload_pk='{$perm_upload_pk}'";
                 }
             }
         }
         if (!empty($sql)) {
             $result = @pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             pg_free_result($result);
         }
     } else {
         if (!empty($newgroup) and !empty($newperm)) {
             // before inserting this new record, delete any record for the same upload and group since
             // that would be a duplicate
             $sql = "delete from perm_upload where upload_fk={$upload_pk} and group_fk={$newgroup}";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             pg_free_result($result);
             // Don't insert a PERM_NONE.  NONE is the default
             if ($newperm != PERM_NONE) {
                 $sql = "insert into perm_upload (perm, upload_fk, group_fk) values ({$newperm}, {$upload_pk}, {$newgroup})";
                 $result = pg_query($PG_CONN, $sql);
                 DBCheckResult($result, $sql, __FILE__, __LINE__);
                 pg_free_result($result);
             }
             $newperm = $newgroup = 0;
         } else {
             if (!empty($public_perm)) {
                 $sql = "update upload set public_perm='{$public_perm}' where upload_pk='{$upload_pk}'";
                 $result = pg_query($PG_CONN, $sql);
                 DBCheckResult($result, $sql, __FILE__, __LINE__);
                 pg_free_result($result);
             }
         }
     }
     $root_folder_pk = GetUserRootFolder();
     if (empty($folder_pk)) {
         $folder_pk = $root_folder_pk;
     }
     // Get folder array folder_pk => folder_name
     $FolderArray = array();
     GetFolderArray($root_folder_pk, $FolderArray);
     /* define js_url */
     $V .= js_url();
     $text = _("Select the folder that contains the upload:  \n");
     $V .= "{$text}";
     /*** Display folder select list, on change request new page with folder= in url ***/
     $url = Traceback_uri() . "?mod=upload_permissions&folder=";
     $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
     $V .= Array2SingleSelect($FolderArray, "folderselect", $folder_pk, false, false, $onchange);
     /*** Display upload select list, on change, request new page with new upload= in url ***/
     $text = _("Select the upload you wish to edit:  \n");
     $V .= "<br>{$text}";
     // Get list of all upload records in this folder that the user has PERM_ADMIN
     $UploadList = FolderListUploads_perm($folder_pk, PERM_ADMIN);
     /*
     if (empty($UploadList))
     {
     echo "You have no uploads in this folder for which you are an admin.  Hit the back button";
     return;
     }
     */
     // Make data array for upload select list.  Key is upload_pk, value is a composite
     // of the upload_filename and upload_ts.
     // Note that $UploadList may be empty so $UploadArray will be empty
     $UploadArray = array();
     foreach ($UploadList as $UploadRec) {
         $SelectText = htmlentities($UploadRec['name']);
         if (!empty($UploadRec['upload_ts'])) {
             $SelectText .= ", " . substr($UploadRec['upload_ts'], 0, 19);
         }
         $UploadArray[$UploadRec['upload_pk']] = $SelectText;
     }
     /* Get selected upload info to display*/
     if (empty($upload_pk)) {
         // no upload selected, so use the top one in the select list
         reset($UploadArray);
         $upload_pk = key($UploadArray);
     }
     /* Upload select list */
     $url = Traceback_uri() . "?mod=upload_permissions&folder={$folder_pk}&upload=";
     $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
     $V .= Array2SingleSelect($UploadArray, "uploadselect", $upload_pk, false, false, $onchange);
     /* Get permissions for this upload */
     if (!empty($UploadArray)) {
         // Get upload.public_perm
         $sql = "select public_perm from upload where upload_pk='{$upload_pk}'";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $Row = pg_fetch_all($result);
         $public_perm = $Row[0]['public_perm'];
         pg_free_result($result);
         $text1 = _("Public Permission");
         $V .= "<p>{$text1} &nbsp;";
         $url = Traceback_uri() . "?mod=upload_permissions&folder={$folder_pk}&upload={$upload_pk}&public=";
         $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
         $V .= Array2SingleSelect($PERM_NAMES, "publicpermselect", $public_perm, false, false, $onchange);
         $sql = "select perm_upload_pk, perm, group_pk, group_name from groups, perm_upload where group_fk=group_pk and upload_fk='{$upload_pk}'";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $PermArray = pg_fetch_all($result);
         pg_free_result($result);
         /* Get master array of groups */
         $sql = "select group_pk, group_name from groups order by group_name";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $GroupArray = array();
         while ($GroupRow = pg_fetch_assoc($result)) {
             $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name'];
         }
         pg_free_result($result);
         /* Permissions Table */
         $V .= "<p><table border=1>";
         $GroupText = _("Group");
         $PermText = _("Permission");
         $V .= "<tr><th>{$GroupText}</th><th>{$PermText}</th></tr>";
         foreach ($PermArray as $PermRow) {
             $V .= "<tr>";
             $V .= "<td>";
             // group
             $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&permupk={$PermRow['perm_upload_pk']}&group=";
             $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
             $V .= Array2SingleSelect($GroupArray, "groupselect", $PermRow['group_pk'], false, false, $onchange);
             $V .= "</td>";
             $V .= "<td>";
             // permission
             $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&permupk={$PermRow['perm_upload_pk']}&perm=";
             $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
             $V .= Array2SingleSelect($PERM_NAMES, "permselect", $PermRow['perm'], false, false, $onchange);
             $V .= "</td>";
             $V .= "</tr>";
         }
         /* Print one extra row for adding perms */
         $V .= "<tr>";
         $V .= "<td>";
         // group
         $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&newperm={$newperm}&newgroup=";
         $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
         $Selected = empty($newgroup) ? "" : $newgroup;
         $V .= Array2SingleSelect($GroupArray, "groupselectnew", $Selected, true, false, $onchange);
         $V .= "</td>";
         $V .= "<td>";
         // permission
         $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&newgroup={$newgroup}&newperm=";
         $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
         $Selected = empty($newperm) ? "" : $newperm;
         $V .= Array2SingleSelect($PERM_NAMES, "permselectnew", $Selected, false, false, $onchange);
         $V .= "</td>";
         $V .= "</tr>";
         $V .= "</table>";
         $text = _("All upload permissions take place immediately when a value is changed.  There is no submit button.");
         $V .= "<p>" . $text;
         $text = _("Add new groups on the last line.");
         $V .= "<br>" . $text;
     } else {
         $text = _("You have no permission to change permissions on any upload in this folder.");
         $V .= "<p>{$text}<p>";
     }
     $V .= "<hr>";
     $V .= $this->DisplayGroupMembership();
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \brief Generate the text for this plugin.
  */
 public function Output()
 {
     $V = "";
     /* If this is a POST, then process the request. */
     $uploadpk = GetParm('upload', PARM_INTEGER);
     if (!empty($uploadpk)) {
         $rc = $this->Delete($uploadpk);
         if (empty($rc)) {
             /* Need to refresh the screen */
             $URL = Traceback_uri() . "?mod=showjobs&upload={$uploadpk} ";
             $LinkText = _("View Jobs");
             $text = _("Deletion added to job queue.");
             $msg = "{$text} <a href={$URL}>{$LinkText}</a>";
             $V .= displayMessage($msg);
         } else {
             $text = _("Deletion Scheduling 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.formy.upload.innerHTML = Uploads.responseText;\n";
     $V .= "    document.getElementById('uploaddiv').innerHTML = '<BR><select name=\\'upload\\' size=\\'10\\'>' + Uploads.responseText + '</select><P />';\n";
     /* Add new options */
     $V .= "    }\n";
     $V .= "  }\n";
     $V .= "</script>\n";
     /* Build HTML form */
     $V .= "<form name='formy' method='post'>\n";
     // no url = this url
     $text = _("Select the uploaded file to");
     $text1 = _("delete");
     $V .= "{$text} <em>{$text1}</em>\n";
     $V .= "<ul>\n";
     $text = _("This will");
     $text1 = _("delete");
     $text2 = _("the upload file!");
     $V .= "<li>{$text} <em>{$text1}</em> {$text2}\n";
     $text = _("Be very careful with your selection since you can delete a lot of work!\n");
     $V .= "<li>{$text}";
     $text = _("All analysis only associated with the deleted upload file will also be deleted.\n");
     $V .= "<li>{$text}";
     $text = _("THERE IS NO UNDELETE. When you select something to delete, it will be removed from the database and file repository.\n");
     $V .= "<li>{$text}";
     $V .= "</ul>\n";
     $text = _("Select the uploaded file to delete:");
     $V .= "<P>{$text}<P>\n";
     $V .= "<ol>\n";
     $text = _("Select the folder containing the file to delete: ");
     $V .= "<li>{$text}";
     $V .= "<select name='folder' ";
     $V .= "onLoad='Uploads_Get((\"" . Traceback_uri() . "?mod=upload_options&folder=-1' ";
     $V .= "onChange='Uploads_Get(\"" . Traceback_uri() . "?mod=upload_options&folder=\" + this.value)'>\n";
     $root_folder_pk = GetUserRootFolder();
     $V .= FolderListOption($root_folder_pk, 0);
     $V .= "</select><P />\n";
     $text = _("Select the uploaded project to delete:");
     $V .= "<li>{$text}";
     $V .= "<div id='uploaddiv'>\n";
     $V .= "<BR><select name='upload' size='10'>\n";
     $List = FolderListUploads_perm($root_folder_pk, 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']) . ")";
         }
         if (!empty($L['upload_ts'])) {
             $V .= " :: " . substr($L['upload_ts'], 0, 19);
         }
         $V .= "</option>\n";
     }
     $V .= "</select><P />\n";
     $V .= "</div>\n";
     $V .= "</ol>\n";
     $text = _("Delete");
     $V .= "<input type='submit' value='{$text}!'>\n";
     $V .= "</form>\n";
     return $V;
 }
 function Output()
 {
     global $PG_CONN;
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     $folder_pk = GetParm('folder', PARM_TEXT);
     $FolderSelectId = GetParm('selectfolderid', PARM_INTEGER);
     if (empty($FolderSelectId)) {
         $FolderSelectId = GetUserRootFolder();
     }
     $NewName = GetArrayVal("newname", $_POST);
     $NewDesc = GetArrayVal("newdesc", $_POST);
     $upload_pk = GetArrayVal("upload_pk", $_POST);
     if (empty($upload_pk)) {
         $upload_pk = GetParm('upload', PARM_INTEGER);
     }
     /* Check Upload permission */
     if (!empty($upload_pk)) {
         $UploadPerm = GetUploadPerm($upload_pk);
         if ($UploadPerm < PERM_WRITE) {
             $text = _("Permission Denied");
             echo "<h2>{$text}<h2>";
             return;
         }
     }
     $rc = $this->UpdateUploadProperties($upload_pk, $NewName, $NewDesc);
     if ($rc == 0) {
         $text = _("Nothing to Change");
         $V .= displayMessage($text);
     } else {
         if ($rc == 1) {
             $text = _("Upload Properties successfully changed");
             $V .= displayMessage($text);
         }
     }
     /* define js_url */
     $V .= js_url();
     /* Build the HTML form */
     $V .= "<form name='formy' method='post'>\n";
     // no url = this url
     $V .= "<ol>\n";
     $text = _("Select the folder that contains the upload:  \n");
     $V .= "<li>{$text}";
     /*** Display folder select list, on change request new page with folder= in url ***/
     $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";
     /*** Display upload select list, on change, request new page with new upload= in url ***/
     $text = _("Select the upload you wish to edit:  \n");
     $V .= "<li>{$text}";
     // Get list of all upload records in this folder
     $UploadList = FolderListUploads_perm($FolderSelectId, PERM_WRITE);
     // Make data array for upload select list.  Key is upload_pk, value is a composite
     // of the upload_filename and upload_ts.
     $UploadArray = array();
     foreach ($UploadList as $UploadRec) {
         $SelectText = htmlentities($UploadRec['name']);
         if (!empty($UploadRec['upload_ts'])) {
             $SelectText .= ", " . substr($UploadRec['upload_ts'], 0, 19);
         }
         $UploadArray[$UploadRec['upload_pk']] = $SelectText;
     }
     /* Get selected upload info to display*/
     if (empty($upload_pk)) {
         // no upload selected, so use the top one in the select list
         reset($UploadArray);
         $upload_pk = key($UploadArray);
     }
     if ($upload_pk) {
         // case where upload is set in the URL
         $sql = "SELECT * FROM upload WHERE upload_pk = '{$upload_pk}'";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         if (pg_num_rows($result) == 0) {
             /* Bad upload_pk */
             $text = _("Missing upload.");
             $V .= displayMessage($text);
             pg_free_result($result);
             return 0;
         }
         $UploadRec = pg_fetch_assoc($result);
         pg_free_result($result);
         $V .= "<INPUT type='hidden' name='upload_pk' value='{$upload_pk}' />\n";
     } else {
         // no uploads in the folder
         $UploadRec = array();
     }
     $url = Traceback_uri() . "?mod=upload_properties&folder={$folder_pk}&upload=";
     $onchange = "onchange=\"js_url(this.value, '{$url}')\"";
     $V .= Array2SingleSelect($UploadArray, "uploadselect", $upload_pk, false, false, $onchange);
     /* Input upload_filename */
     $text = _("Upload name:  \n");
     $V .= "<li>{$text}";
     if (empty($UploadRec['upload_filename'])) {
         $upload_filename = "";
     } else {
         $upload_filename = htmlentities($UploadRec['upload_filename']);
     }
     $V .= "<INPUT type='text' name='newname' size=40 value='{$upload_filename}' />\n";
     /* Input upload_desc */
     $text = _("Upload description:  \n");
     $V .= "<li>{$text}";
     if (empty($UploadRec['upload_desc'])) {
         $upload_desc = "";
     } else {
         $upload_desc = htmlentities($UploadRec['upload_desc'], ENT_QUOTES);
     }
     $V .= "<INPUT type='text' name='newdesc' size=60 value='{$upload_desc}' />\n";
     $V .= "</ol>\n";
     $text = _("Edit");
     $V .= "<input type='submit' value='{$text}!'>\n";
     $V .= "</form>\n";
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
示例#8
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;
 }
 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;
 }
 /**
  * \brief Generate the text for this plugin.
  */
 function Output()
 {
     global $Plugins;
     global $PG_CONN;
     global $PERM_NAMES;
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             $text = _("Move upload to different folder.");
             $V .= "<H2>{$text}</H1>\n";
             /* If this is a POST, then process the request. */
             $OldFolderId = GetParm('oldfolderid', PARM_INTEGER);
             $UploadId = GetParm('uploadid', PARM_INTEGER);
             $TargetFolderId = GetParm('targetfolderid', PARM_INTEGER);
             if (!empty($OldFolderId) && !empty($TargetFolderId)) {
                 /* check upload permission */
                 $UploadPerm = GetUploadPerm($UploadId);
                 if ($UploadPerm < PERM_WRITE) {
                     $text = _("Permission Denied");
                     echo "<h2>{$text}<h2>";
                     return;
                 }
                 $rc = $this->Move($UploadId, $TargetFolderId, $OldFolderId);
                 if ($rc == 1) {
                     /* Need to refresh the screen */
                     $sql = "SELECT * FROM folder where folder_pk = '{$TargetFolderId}';";
                     $result = pg_query($PG_CONN, $sql);
                     DBCheckResult($result, $sql, __FILE__, __LINE__);
                     $NRow = pg_fetch_assoc($result);
                     pg_free_result($result);
                     $sql = "SELECT pfile_fk FROM upload WHERE upload_pk='{$UploadId}';";
                     $result = pg_query($PG_CONN, $sql);
                     DBCheckResult($result, $sql, __FILE__, __LINE__);
                     $row = pg_fetch_assoc($result);
                     pg_free_result($result);
                     $pfileNum = $row['pfile_fk'];
                     $sql = "SELECT ufile_name FROM uploadtree WHERE " . "upload_fk='{$UploadId}' and pfile_fk={$pfileNum};";
                     $result = pg_query($PG_CONN, $sql);
                     DBCheckResult($result, $sql, __FILE__, __LINE__);
                     $row = pg_fetch_assoc($result);
                     pg_free_result($result);
                     $base = basename($row['ufile_name']);
                     $sql = "SELECT * FROM folder where folder_pk = '{$OldFolderId}';";
                     $result = pg_query($PG_CONN, $sql);
                     DBCheckResult($result, $sql, __FILE__, __LINE__);
                     $ORow = pg_fetch_assoc($result);
                     pg_free_result($result);
                     $text = _("Moved");
                     $text1 = _("from folder");
                     $text2 = _("to folder");
                     $success = "{$text} {$base} {$text1} {$ORow['folder_name']} {$text2} {$NRow['folder_name']}";
                     $V .= displayMessage($success);
                 }
             }
             /* 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 name=\\'uploadid\\'>' + Uploads.responseText + '</select><P />';\n";
             /* Add new options */
             $V .= "    }\n";
             $V .= "  }\n";
             $V .= "</script>\n";
             /* Build the  HTML form */
             $V .= "<form name='formy' method='post'>\n";
             // no url = this url
             /* Display the form */
             $V .= "<form method='post'>\n";
             // no url = this url
             $V .= "<ol>\n";
             $text = _("Select the folder containing the upload you wish to move:  \n");
             $V .= "<li>{$text}";
             $V .= "<select name='oldfolderid'\n";
             $V .= "onLoad='Uploads_Get((\"" . Traceback_uri() . "?mod=upload_options&folder=-1' ";
             $V .= "onChange='Uploads_Get(\"" . Traceback_uri() . "?mod=upload_options&folder=\" + this.value)'>\n";
             $root_folder_pk = GetUserRootFolder();
             $V .= FolderListOption($root_folder_pk, 0);
             $V .= "</select><P />\n";
             $text = _("Select the upload you wish to move:  \n");
             $V .= "<li>{$text}";
             $V .= "<div id='uploaddiv'>\n";
             $V .= "<select name='uploadid'>\n";
             $List = FolderListUploads_perm($root_folder_pk, 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 .= " :: " . substr($L['upload_ts'], 0, 19);
                 }
                 $V .= "</option>\n";
             }
             $V .= "</select><P />\n";
             $V .= "</div>\n";
             $text = _("Select the destination folder:  \n");
             $V .= "<li>{$text}";
             $V .= "<select name='targetfolderid'>\n";
             $V .= FolderListOption($root_folder_pk, 0);
             $V .= "</select><P />\n";
             $V .= "</ol>\n";
             $text = "Move";
             $V .= "<input type='submit' value='{$text}!'>\n";
             $V .= "</form>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }