/** * \brief Generate the text for this plugin. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $PG_CONN; global $PERM_NAMES; $V = ""; switch ($this->OutputType) { case "XML": break; case "HTML": /* If this is a POST, then process the request. */ $User = GetParm('username', PARM_TEXT); if (!empty($User)) { $rc = $this->Edit(); if (empty($rc)) { /* Need to refresh the screen */ $text = _("User information updated."); $V .= displayMessage($text); } else { $V .= displayMessage($rc); } } // Get the user data $sql = "SELECT * FROM users WHERE user_pk='" . @$_SESSION['UserId'] . "';"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $R = pg_fetch_assoc($result); pg_free_result($result); /* Build HTML form */ $V .= "<form name='formy' method='POST'>\n"; // no url = this url /* if login by siteminder, didn't show this in page*/ if (siteminder_check() == -1) { $V .= _("You <font color='red'>must</font> provide your current password in order to make any changes.<br />\n"); $text = _("Enter your password"); $V .= "{$text}: <input type='password' name='pass0' size=20>\n"; $V .= "<hr>\n"; } $V .= _("To change user information, edit the following fields. You do not need to edit every field. Only fields with edits will be changed.<P />\n"); $Style = "<tr><td colspan=2 style='background:black;'></td></tr><tr>"; $V .= "<table style='border:1px solid black; text-align:left; background:lightyellow;' width='100%'>"; $Val = htmlentities($R['user_name'], ENT_QUOTES); $text = _("Username"); $V .= "{$Style}<th width='25%'>{$text}</th>"; $V .= "<td><input type='text' value='{$Val}' name='username' size=20></td>\n"; $V .= "</tr>\n"; $Val = htmlentities($R['user_desc'], ENT_QUOTES); $text = _("Description, full name, contact, etc. (optional) "); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='description' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $Val = htmlentities($R['user_email'], ENT_QUOTES); $text = _("Email address (optional)"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='email' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $text = _("Password"); $text1 = _("Re-enter password"); $V .= "{$Style}<th>{$text}<br>{$text1}</th><td>"; $V .= "<input type='password' name='pass1' size=20><br />\n"; $V .= "<input type='password' name='pass2' size=20></td>\n"; $V .= "</tr>\n"; if (empty($R['email_notify'])) { $Checked = ""; } else { $Checked = "checked='checked'"; } $text = _("E-mail Notification"); $V .= "{$Style}<th>{$text}</th><td>\n"; $V .= "<input name='emailnotify' type='checkbox' {$Checked}>"; $V .= "</tr>\n"; if (@$_SESSION['UserLevel'] > PLUGIN_DB_READ) { $text = _("Default scans"); $V .= "{$Style}<th>{$text}\n</th><td>\n"; /* * added this code so the form makes sense. You can have an admin define default agents * but if you don't have Analyze or better permissions, then those agents are not available to * you! With out this code the default agent text was there, but nothing else... this way * the form at least makes sense. Turns out agent unpack is always around so both * conditions must be checked. */ $AgentList = menu_find("Agents", $Depth); if (!empty($AgentList)) { foreach ($AgentList as $AgentItem) { $uri = $AgentItem->URI; } if ($uri == "agent_unpack" && count($AgentList) == 1) { $text = _("You do not have permission to change your default agents"); $V .= "<h3>{$text}</h3>\n"; } else { $V .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent")); } } $V .= "</td></tr>\n"; $text = _("Default bucketpool"); $V .= "{$Style}<th>{$text}</th>"; $V .= "<td>"; $Val = htmlentities($R['default_bucketpool_fk'], ENT_QUOTES); $V .= SelectBucketPool($Val); $V .= "</td>"; $V .= "</tr>\n"; /* /****** New Upload Group ****** / / * Get master array of groups * / $sql = "select group_pk, group_name from groups order by group_name"; $groupresult = pg_query($PG_CONN, $sql); DBCheckResult($groupresult, $sql, __FILE__, __LINE__); $GroupArray = array(); while ($GroupRow = pg_fetch_assoc($groupresult)) $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name']; pg_free_result($groupresult); $text = _("Group to give access permission for every new upload"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $V .= Array2SingleSelect($GroupArray, "new_upload_group_fk", $R['new_upload_group_fk'], true, false); $V.= "</td>"; $V .= "</tr>\n"; / ****** New Upload Permissions ****** / $text = _("Access Permission to give the above group"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $Selected = (empty($R['new_upload_perm'])) ? -1 : $R['new_upload_perm']; $V .= Array2SingleSelect($PERM_NAMES, "new_upload_perm", $Selected, true, false); $V.= "</td>"; $V .= "</tr>\n"; */ } $V .= "</table><P />"; $text = _("Update Account"); $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 User chooses a bucketpool to duplicate from a select list. * The new bucketpool and bucket_def records will be identical * to the originals except for the primary keys and bucketpool version * (which will be bumped). \n * The user can optionally also set their default bucketpool to the * new one. This is the default. \n * * The user must then manually modify the bucketpool and/or bucketdef * records to create their new (modified) bucketpool. */ public function Output() { global $PROJECTSTATEDIR; /* get the bucketpool_pk to clone */ $bucketpool_pk = GetParm("default_bucketpool_fk", PARM_INTEGER); $UpdateDefault = GetParm("updatedefault", PARM_RAW); if (!empty($bucketpool_pk)) { $msg = ""; $newbucketpool_pk = $this->CloneBucketpool($bucketpool_pk, $UpdateDefault, $msg); $text = _("Your new bucketpool_pk is"); $this->vars['message'] = "{$text} {$newbucketpool_pk}"; } $V = "<p>"; $V .= _("The purpose of this is to facilitate editing an existing bucketpool. Make sure you understand"); $V .= " <a href='http://www.fossology.org/projects/fossology/wiki/Buckets'>"; $V .= _("Creating Bucket Pools"); $V .= "</a> "; $V .= _("before continuing."); $V .= _(" It will explain why you should create a new bucketpool rather than edit an old one that has already recorded results."); $V .= "<p>"; $V .= _("Steps to modify a bucketpool:"); $V .= "<ol>"; $V .= "<li>"; $V .= _("Create a baseline with your current bucketpool. In other words, run a bucket scan on something. If you do this before creating a new modified bucketpool, you can compare the old results with the new to verify it is working as you expect."); $V .= "<li>"; $V .= _("Duplicate the bucketpool (this will increment the bucketpool version and its bucketdef records). You should also check 'Update my default bucketpool' since new bucket jobs only use your default bucketpool."); $V .= "<li>"; $V .= _("Duplicate any bucket scripts that you defined in {$PROJECTSTATEDIR}."); $V .= "<li>"; $V .= _("Manually edit the new bucketpool record, if desired."); $V .= "<li>"; $V .= _("Manually insert/update/delete the new bucketdef records."); $V .= "<li>"; $V .= _("Manually insert a new buckets record in the agent table."); $V .= "<li>"; $V .= _("Queue up the new bucket job in Jobs > Schedule Agents."); $V .= "<li>"; $V .= _("Use Buckets > Compare to compare the new and old runs. Verify the results."); $V .= "<li>"; $V .= _("If you still need to edit the buckets, use Buckets > Remove Bucket Results to remove the previous runs results and repeat starting with editing the bucketpool or def records."); $V .= "<li>"; $V .= _("When the bucket results are what you want, then you can reset all the users of the old bucketpool to the new one (manual sql step)."); $V .= "</ol>"; $V .= "<hr>"; $V .= "<form method='POST'>"; $text = _("Choose the bucketpool to duplicate"); $V .= "{$text} "; $Val = ""; $V .= SelectBucketPool($Val); $V .= "<p>"; $text = _("Update my default bucketpool"); $V .= "<input type='checkbox' name='updatedefault' checked> {$text}."; $V .= "<p>"; $text = _("Submit"); $V .= "<input type='submit' value='{$text}'>"; $V .= "</form>"; return $V; }
public function Output() { /* If this is a POST, then process the request. */ $User = GetParm('username', PARM_TEXT); if (!empty($User)) { $rc = $this->Add(); if (empty($rc)) { $text = _("User"); $text1 = _("added"); $this->vars['message'] = "{$text} {$User} {$text1}."; } else { $this->vars['message'] = $rc; } } $V = "<form name='formy' method='POST'>\n"; $V .= _("To create a new user, enter the following information:<P />\n"); $Style = "<tr><td colspan=2 style='background:black;'></td></tr><tr>"; $V .= "<table style='border:1px solid black; text-align:left; background:lightyellow;' width='75%'>"; $Val = htmlentities(GetParm('username', PARM_TEXT), ENT_QUOTES); $text = _("Username"); $V .= "{$Style}<th width='25%' >{$text}</th>"; $V .= "<td><input type='text' value='{$Val}' name='username' size=20></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('description', PARM_TEXT), ENT_QUOTES); $text = _("Description, full name, contact, etc. (optional)"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='description' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('email', PARM_TEXT), ENT_QUOTES); $text = _("Email address (optional)"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='email' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $text = _("Access level"); $V .= "{$Style}<th>{$text}</th>"; $V .= "<td><select name='permission'>\n"; $text = _("None (very basic, no database access)"); $V .= "<option value='" . PLUGIN_DB_NONE . "'>{$text}</option>\n"; $text = _("Read-only (read, but no writes or downloads)"); $V .= "<option selected value='" . PLUGIN_DB_READ . "'>{$text}</option>\n"; $text = _("Read-Write (read, download, or edit information)"); $V .= "<option value='" . PLUGIN_DB_WRITE . "'>{$text}</option>\n"; $text = _("Full Administrator (all access including adding and deleting users)"); $V .= "<option value='" . PLUGIN_DB_ADMIN . "'>{$text}</option>\n"; $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("User root folder"); $V .= "{$Style}<th>{$text}"; $V .= "</th>"; $V .= "<td><select name='folder'>"; $V .= FolderListOption(-1, 0); $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("Password (optional)"); $V .= "{$Style}<th>{$text}</th><td><input type='password' name='pass1' size=20></td>\n"; $V .= "</tr>\n"; $text = _("Re-enter password"); $V .= "{$Style}<th>{$text}</th><td><input type='password' name='pass2' size=20></td>\n"; $V .= "</tr>\n"; $text = _("E-mail Notification"); $text1 = _("Check to enable email notification when upload scan completes ."); $V .= "{$Style}<th>{$text}</th><td><input type='checkbox'" . "name='enote' value='y' checked='checked'>" . "{$text1}</td>\n"; $V .= "</tr>\n"; $text = _("Agents selected by default when uploading"); $V .= "{$Style}<th>{$text}\n</th><td> "; $V .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent")); $V .= "</td>\n"; $text = _("Default bucketpool"); $V .= "{$Style}<th>{$text}</th>"; $V .= "<td>"; $default_bucketpool_fk = 0; $V .= SelectBucketPool($default_bucketpool_fk); $V .= "</td>"; $V .= "</tr>\n"; $V .= "</table border=0><P />"; $text = _("Add User"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; return $V; }
/** * \brief Display the user record edit form * * \param $UserRec - Database users record for the user to be edited. * \param $SessionIsAdmin - Boolean: This session is by an admin * \return the text of the display form on success, or error on failure. */ private function DisplayForm($UserRec, $SessionIsAdmin) { $vars = array('isSessionAdmin' => $SessionIsAdmin, 'userId' => $UserRec['user_pk']); /* For Admins, get the list of all users * For non-admins, only show themself */ if ($SessionIsAdmin) { $stmt = __METHOD__ . '.asSessionAdmin'; $sql = "SELECT * FROM users ORDER BY user_name"; $this->dbManager->prepare($stmt, $sql); $res = $this->dbManager->execute($stmt); $allUsers = array(); while ($row = $this->dbManager->fetchArray($res)) { $allUsers[$row['user_pk']] = htmlentities($row['user_name']); } $this->dbManager->freeResult($res); $vars['allUsers'] = $allUsers; } $vars['userName'] = $UserRec['user_name']; $vars['userDescription'] = $UserRec['user_desc']; $vars['userEMail'] = $UserRec["user_email"]; $vars['eMailNotification'] = $UserRec['email_notify'] == 'y'; if ($SessionIsAdmin) { $vars['allAccessLevels'] = array(PLUGIN_DB_NONE => _("None (very basic, no database access)"), PLUGIN_DB_READ => _("Read-only (read, but no writes or downloads)"), PLUGIN_DB_WRITE => _("Read-Write (read, download, or edit information)"), PLUGIN_DB_ADMIN => _("Full Administrator (all access including adding and deleting users)")); $vars['accessLevel'] = $UserRec['user_perm']; $SelectedFolderPk = $UserRec['root_folder_fk']; $vars['folderListOption'] = FolderListOption($ParentFolder = -1, $Depth = 0, $IncludeTop = 1, $SelectedFolderPk); } $vars['isBlankPassword'] = $UserRec['_blank_pass'] == 'on'; $vars['agentSelector'] = AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent"), $UserRec['user_name']); $vars['bucketPool'] = SelectBucketPool($UserRec["default_bucketpool_fk"]); return $vars; }
/** * \brief Generate the text for this plugin. */ function Output() { global $PG_CONN; global $PERM_NAMES; 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. */ $User = GetParm('username', PARM_TEXT); if (!empty($User)) { $rc = $this->Add(); if (empty($rc)) { /* Need to refresh the screen */ $text = _("User"); $text1 = _("added"); $V .= displayMessage("{$text} {$User} {$text1}."); } else { $V .= displayMessage($rc); } } $default_bucketpool_fk = 0; /* Build HTML form */ $V .= "<form name='formy' method='POST'>\n"; // no url = this url $V .= _("To create a new user, enter the following information:<P />\n"); $Style = "<tr><td colspan=2 style='background:black;'></td></tr><tr>"; $V .= "<table style='border:1px solid black; text-align:left; background:lightyellow;' width='75%'>"; $Val = htmlentities(GetParm('username', PARM_TEXT), ENT_QUOTES); $text = _("Username"); $V .= "{$Style}<th width='25%' >{$text}</th>"; $V .= "<td><input type='text' value='{$Val}' name='username' size=20></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('description', PARM_TEXT), ENT_QUOTES); $text = _("Description, full name, contact, etc. (optional)"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='description' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('email', PARM_TEXT), ENT_QUOTES); $text = _("Email address (optional)"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='email' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $text = _("Access level"); $V .= "{$Style}<th>{$text}</th>"; $V .= "<td><select name='permission'>\n"; $text = _("None (very basic, no database access)"); $V .= "<option value='" . PLUGIN_DB_NONE . "'>{$text}</option>\n"; $text = _("Read-only (read, but no writes or downloads)"); $V .= "<option selected value='" . PLUGIN_DB_READ . "'>{$text}</option>\n"; $text = _("Read-Write (read, download, or edit information)"); $V .= "<option value='" . PLUGIN_DB_WRITE . "'>{$text}</option>\n"; $text = _("Full Administrator (all access including adding and deleting users)"); $V .= "<option value='" . PLUGIN_DB_ADMIN . "'>{$text}</option>\n"; $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("User root folder"); $V .= "{$Style}<th>{$text}"; $V .= "</th>"; $V .= "<td><select name='folder'>"; $V .= FolderListOption(-1, 0); $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("Password (optional)"); $V .= "{$Style}<th>{$text}</th><td><input type='password' name='pass1' size=20></td>\n"; $V .= "</tr>\n"; $text = _("Re-enter password"); $V .= "{$Style}<th>{$text}</th><td><input type='password' name='pass2' size=20></td>\n"; $V .= "</tr>\n"; $text = _("E-mail Notification"); $text1 = _("Check to enable email notification when upload scan completes ."); $V .= "{$Style}<th>{$text}</th><td><input type='checkbox'" . "name='enote' value='y' checked='checked'>" . "{$text1}</td>\n"; $V .= "</tr>\n"; $text = _("Agents selected by default when uploading"); $V .= "{$Style}<th>{$text}\n</th><td> "; $V .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent")); $V .= "</td>\n"; $text = _("Default bucketpool"); $V .= "{$Style}<th>{$text}</th>"; $V .= "<td>"; $V .= SelectBucketPool($default_bucketpool_fk); $V .= "</td>"; $V .= "</tr>\n"; /* /****** New Upload Group ****** / /* Get master array of groups * / $sql = "select group_pk, group_name from groups order by group_name"; $groupresult = pg_query($PG_CONN, $sql); DBCheckResult($groupresult, $sql, __FILE__, __LINE__); $GroupArray = array(); while ($GroupRow = pg_fetch_assoc($groupresult)) $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name']; pg_free_result($groupresult); $text = _("Group to give access permission for every new upload"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $V .= Array2SingleSelect($GroupArray, "new_upload_group_fk", "", true, false); $V.= "</td>"; $V .= "</tr>\n"; /****** New Upload Permissions ****** / $text = _("Access Permission to give the above group"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $V .= Array2SingleSelect($PERM_NAMES, "new_upload_perm", "", true, false); $V.= "</td>"; $V .= "</tr>\n"; */ $V .= "</table border=0><P />"; $text = _("Add User"); $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 Display the user record edit form * * \param $UserRec - Database users record for the user to be edited. * \param $SessionIsAdmin - Boolean: This session is by an admin * \return the text of the display form on success, or error on failure. */ function DisplayForm($UserRec, $SessionIsAdmin) { global $PG_CONN; $OutS = ""; // Output string /* Build HTML form */ $OutS .= "<form name='user_edit' method='POST'>\n"; $OutS .= "<p><input type='hidden' name='user_pk' value='{$UserRec['user_pk']}'/></p>"; $OutS .= "<p />\n"; if ($SessionIsAdmin) { $OutS .= _("Select the user to edit: "); $OutS .= "<select name='userid' onchange='RefreshPage(this.value);'>\n"; } /* For Admins, get the list of all users * For non-admins, only show themself */ if ($SessionIsAdmin) { $sql = "SELECT * FROM users ORDER BY user_name;"; } else { $sql = "SELECT * FROM users WHERE user_pk='" . $UserRec['user_pk'] . "' ORDER BY user_name;"; } $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); while ($row = pg_fetch_assoc($result)) { $Selected = $row['user_pk'] == $UserRec['user_pk'] ? "Selected" : ""; $OutS .= "<option {$Selected} value='" . $row['user_pk'] . "'>"; $OutS .= htmlentities($row['user_name']); $OutS .= "</option>\n"; } pg_free_result($result); $OutS .= "</select><hr>\n"; $TableStyle = "style='border:1px solid black; border-collapse: collapse; '"; $TRStyle = "style='border:1px solid black; text-align:left; background:lightyellow;'"; $OutS .= "<table {$TableStyle} width='100%'>"; $Field = "user_name"; $Val = htmlentities($UserRec[$Field], ENT_QUOTES); $text = _("Username."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='text' value='{$Val}' name='{$Field}' size=20></td>\n"; $OutS .= "</tr>\n"; $Field = "user_desc"; $Val = htmlentities($UserRec[$Field], ENT_QUOTES); $text = _("Description (name, contact, or other information). This may be blank."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='text' value='{$Val}' name='{$Field}' size=60></td>\n"; $OutS .= "</tr>\n"; $Field = "user_email"; $Val = htmlentities($UserRec[$Field], ENT_QUOTES); $text = _("Email address. This may be blank."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='text' value='{$Val}' name='{$Field}' size=60></td>\n"; $OutS .= "</tr>\n"; $Field = "email_notify"; $Checked = $UserRec[$Field] == 'y' ? "checked" : ""; $text = _("E-mail notification on job completion"); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type=checkbox name='{$Field}' {$Checked}></td>"; $OutS .= "</tr>\n"; if ($SessionIsAdmin) { $Field = "user_perm"; $Val = htmlentities($UserRec[$Field], ENT_QUOTES); $text = _("Select the user's access level."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><select name='{$Field}'>\n"; $text1 = _("None (very basic, no database access)"); $text2 = _("Read-only (read, but no writes or downloads)"); $text4 = _("Read-Write (read, download, or edit information)"); $text9 = _("Full Administrator (all access including adding and deleting users)"); $OutS .= "<option " . ($Val == PLUGIN_DB_NONE ? "selected" : "") . " value='" . PLUGIN_DB_NONE . "'>{$text1}</option>\n"; $OutS .= "<option " . ($Val == PLUGIN_DB_READ ? "selected" : "") . " value='" . PLUGIN_DB_READ . "'>{$text2}</option>\n"; $OutS .= "<option " . ($Val == PLUGIN_DB_WRITE ? "selected" : "") . " value='" . PLUGIN_DB_WRITE . "'>{$text4}</option>\n"; $OutS .= "<option " . ($Val == PLUGIN_DB_ADMIN ? "selected" : "") . " value='" . PLUGIN_DB_ADMIN . "'>{$text9}</option>\n"; $OutS .= "</select></td>\n"; $OutS .= "</tr>\n"; } if ($SessionIsAdmin) { $Field = "root_folder_fk"; $Val = htmlentities($UserRec[$Field], ENT_QUOTES); $text = _("Select the user's top-level folder. Access is restricted to this folder."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><select name='{$Field}'>"; $ParentFolder = -1; $Depth = 0; $IncludeTop = 1; // include top level folder in selecet list $SelectedFolderPk = $UserRec[$Field]; $OutS .= FolderListOption($ParentFolder, $Depth, $IncludeTop, $SelectedFolderPk); $OutS .= "</select></td>\n"; $OutS .= "</tr>\n"; } if ($SessionIsAdmin) { $Checked = $UserRec['_blank_pass'] == 'on' ? "checked" : ""; $text = _("Blank the user's account. This will will set the password to a blank password."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='checkbox' name='_blank_pass' {$Checked} ></td>\n"; $OutS .= "</tr>\n"; } $text = _("Password."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='password' name='_pass1' size=20></td>\n"; $OutS .= "</tr>\n"; $text = _("Re-enter password."); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td><input type='password' name='_pass2' size=20></td>\n"; $OutS .= "</tr>\n"; $Field = "user_agent_list"; $text = _("Default agents selected when uploading data. "); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th><td>"; $OutS .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent"), $UserRec['user_name']); $OutS .= "</td></tr>\n"; $Field = "default_bucketpool_fk"; $text = _("Default bucket pool"); $OutS .= "<tr {$TRStyle}><th width='25%'>{$text}</th>"; $OutS .= "<td>"; $OutS .= SelectBucketPool($UserRec[$Field]); $OutS .= "</td></tr>\n"; $OutS .= "</table><P />"; $text = _("Update Account"); $OutS .= "<input type='submit' name='UpdateBtn' value='{$text}'>\n"; $OutS .= "</form>\n"; return $OutS; }
/** * \brief Generate the text for this plugin. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $PG_CONN; global $PERM_NAMES; $V = ""; switch ($this->OutputType) { case "XML": break; case "HTML": /* If this is a POST, then process the request. */ $UserId = GetParm('userid', PARM_INTEGER); if (!empty($UserId)) { $rc = $this->Edit(); if (empty($rc)) { $sql = "SELECT user_pk, user_name FROM users WHERE user_pk={$UserId};"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $row = pg_fetch_assoc($result); pg_free_result($result); $userName = $row['user_name']; // display status $V .= displayMessage("User {$userName} updated."); } else { $V .= displayMessage($rc); } } /* Get the list of users */ $sql = "SELECT user_pk,user_name,user_desc,user_pass,\n root_folder_fk,user_perm,user_email,email_notify,\n user_agent_list,default_bucketpool_fk,ui_preference,\n new_upload_group_fk, new_upload_perm FROM users WHERE\n user_pk != '" . @$_SESSION['UserId'] . "' ORDER BY user_name;"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $row0 = pg_fetch_assoc($result); /* Create JavaScript for updating users */ $V .= "\n<script language='javascript'>\n"; $V .= "document.onreadystatechange = function(){\n if(document.readyState=='complete'){SetInfo(" . $row0['user_pk'] . ");}\n }"; $V .= "</script>\n"; $V .= "\n<script language='javascript'>\n"; $V .= "var Username = new Array();\n"; $V .= "var Userdesc = new Array();\n"; $V .= "var Useremail = new Array();\n"; $V .= "var Userenote = new Array();\n"; $V .= "var Useragents = new String(\"\");\n"; $V .= "var Userperm = new Array();\n"; $V .= "var Userblock = new Array();\n"; $V .= "var Userfolder = new Array();\n"; $V .= "var default_bucketpool_fk = new Array();\n"; $V .= "var new_upload_group_fk = new Array();\n"; $V .= "var new_upload_perm = new Array();\n"; $V .= "var UiPref = new Array();\n"; pg_result_seek($result, 0); while ($row = pg_fetch_assoc($result)) { $R = $row; //echo "<pre>Users are:\n"; //print_r($R) . "\n</pre>"; $Id = $R['user_pk']; $Val = str_replace('"', "\\\"", $R['user_name']); $V .= "Username[" . $Id . '] = "' . $Val . "\";\n"; $Val = str_replace('"', "\\\"", $R['user_desc']); $V .= "Userdesc[" . $Id . '] = "' . $Val . "\";\n"; $Val = str_replace('"', "\\\"", $R['user_email']); $V .= "Useremail[" . $Id . '] = "' . $Val . "\";\n"; $V .= "Userenote[" . $Id . '] = "' . $R['email_notify'] . "\";\n"; $V .= "UiPref[" . $Id . '] = "' . $R['ui_preference'] . "\";\n"; $V .= "Useragents[" . $Id . '] = "' . $R['user_agent_list'] . "\";\n"; $V .= "Userfolder[" . $Id . '] = "' . $R['root_folder_fk'] . "\";\n"; $V .= "default_bucketpool_fk[" . $Id . '] = "' . $R['default_bucketpool_fk'] . "\";\n"; $V .= "new_upload_group_fk[" . $Id . '] = "' . $R['new_upload_group_fk'] . "\";\n"; $V .= "new_upload_perm[" . $Id . '] = "' . $R['new_upload_perm'] . "\";\n"; $V .= "Userperm[" . $Id . '] = "' . $R['user_perm'] . "\";\n"; if (substr($R['user_pass'], 0, 1) == ' ') { $Block = 1; } else { $Block = 0; } $V .= "Userblock[" . $Id . "] = '{$Block}';\n"; } $V .= "\n function clearBoxes()\n {\n var cbList = document.getElementsByTagName('input');\n for(j=0; j<cbList.length; j++)\n {\n if(cbList[j].getAttribute('type') == 'checkbox')\n {\n var aname = cbList[j].getAttribute('name');\n if(String.search('Check_agent', aname) != -1)\n {\n continue;\n }\n else\n {\n cbList[j].checked=false;\n }\n }\n }\n }\n \n function SetBoxes(id)\n {\n if(!id) { return; }\n\n var prefix='Check_';\n var agents = Useragents[id].split(',');\n\n var cbList = document.getElementsByTagName('input');\n for(j=0; j<cbList.length; j++)\n {\n if(cbList[j].getAttribute('type') == 'checkbox')\n {\n uiName = cbList[j].getAttribute('name');\n if(uiName.search(/Check_agent/) != -1)\n {\n for(i=0; i<agents.length; i++)\n {\n aName = prefix + agents[i];\n // need to remove Check_ from the name\n noCheck = uiName.replace(/Check_/, '');\n if(agents.indexOf(noCheck) == -1)\n {\n cbList[j].checked=false;\n continue;\n }\n else\n {\n cbList[j].checked=true;\n continue;\n }\n }\n }\n }\n }\n }\n \n function SetInfo(id)\n {\n if(id == 0) { clearBoxes(); }\n document.userEditAny.username.value = Username[id];\n document.userEditAny.email.value = Useremail[id];\n document.userEditAny.description.value = Userdesc[id];\n document.userEditAny.permission.value = Userperm[id];\n document.userEditAny.folder.value = Userfolder[id];\n document.userEditAny.default_bucketpool_fk.value = default_bucketpool_fk[id];\n document.userEditAny.new_upload_group_fk.value = new_upload_group_fk[id];\n document.userEditAny.new_upload_perm.value = new_upload_perm[id];\n if (Userblock[id] == 1) { document.userEditAny.block.checked=true; }\n else { document.userEditAny.block.checked=false; }\n if (Userenote[id] == \"\") { document.userEditAny.enote.checked=false; }\n else { document.userEditAny.enote.checked=true; }\n \n if (UiPref[id] == \"\") {\n document.getElementById('simple').checked=true;\n }\n else if (UiPref[id] == 'simple') {\n document.getElementById('original').checked=false;\n document.getElementById('simple').checked=true;\n\t\t }\n\t\t else {\n\t\t document.getElementById('simple').checked=false;\n \t document.getElementById('original').checked=true;\n\t\t }\n \n if(Useragents[id].length == 0)\n {\n clearBoxes();\n }\n else\n {\n SetBoxes(id);\n }\n }\n "; $V .= "</script>\n"; /* Build HTML form */ $V .= "<form name='userEditAny' method='POST'>\n"; // no url = this url if (empty($UserId)) { $UserId = $row0['user_pk']; } $Uri = Traceback_uri(); $V .= "<P />\n"; $text = _("To edit"); $text1 = _("another"); $text2 = _(" user on this system, alter any of the following information."); $V .= "{$text} <strong>{$text1}</strong>{$text2}<P />\n"; $text = _("To edit"); $text1 = _("your"); $text2 = _(" account settings, use"); $text3 = _("Account Settings."); $V .= "{$text} <strong>{$text1}</strong>{$text2}\n <a href='{$Uri}?mod=user_edit_self'>{$text3}</a><P />\n"; $V .= _("Select the user to edit: "); $V .= "<select name='userid' onClick='SetInfo(this.value);' onchange='SetInfo(this.value);'>\n"; //$V .= "<option selected value='0'>--select user--</option>\n"; pg_result_seek($result, 0); while ($row = pg_fetch_assoc($result)) { $Selected = ""; if ($UserId == $row['user_pk']) { $Selected = "selected"; } $V .= "<option {$Selected} value='" . $row['user_pk'] . "'>"; $V .= htmlentities($row['user_name']); $V .= "</option>\n"; } pg_free_result($result); $V .= "</select>\n"; $Style = "<tr><td colspan=3 style='background:black;'></td></tr><tr>"; $V .= "<table style='border:1px solid black; text-align:left; background:lightyellow;' width='100%'>"; $Val = htmlentities(GetParm('username', PARM_TEXT), ENT_QUOTES); $text = _("Change the username."); $V .= "{$Style}<th width='25%'>{$text}</th>"; $V .= "<td><input type='text' value='{$Val}' name='username' size=20></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('description', PARM_TEXT), ENT_QUOTES); $text = _("Change the user's description (name, contact, or other information). This may be blank."); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='description' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $Val = htmlentities(GetParm('email', PARM_TEXT), ENT_QUOTES); $text = _("Change the user's email address. This may be blank."); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td><input type='text' name='email' value='{$Val}' size=60></td>\n"; $V .= "</tr>\n"; $text = _("Select the user's access level."); $V .= "{$Style}<th>{$text}</th>"; $Val = GetParm('permission', PARM_INTEGER); $V .= "<td><select name='permission'>\n"; $text1 = _("None (very basic, no database access)"); $text2 = _("Read-only (read, but no writes or downloads)"); $text3 = _("Download (Read-only, but can download files)"); $text4 = _("Read-Write (read, download, or edit information)"); $text5 = _("Upload (read-write, and permits uploading files)"); $text6 = _("Analyze (... and permits scheduling analysis tasks)"); $text7 = _("Delete (... and permits deleting uploaded files and analysis)"); $text8 = _("Debug (... and allows access to debugging functions)"); $text9 = _("Full Administrator (all access including adding and deleting users)"); $V .= "<option " . ($Val == 0 ? "selected" : "") . " value='" . PLUGIN_DB_NONE . "'>{$text1}</option>\n"; $V .= "<option " . ($Val == 1 ? "selected" : "") . " value='" . PLUGIN_DB_READ . "'>{$text2}</option>\n"; $V .= "<option " . ($Val == 3 ? "selected" : "") . " value='" . PLUGIN_DB_WRITE . "'>{$text4}</option>\n"; $V .= "<option " . ($Val == 10 ? "selected" : "") . " value='" . PLUGIN_DB_ADMIN . "'>{$text9}</option>\n"; $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("Select the user's top-level folder. Access is restricted to this folder."); $V .= "{$Style}<th>{$text}"; $V .= "</th>"; $V .= "<td><select name='folder'>"; $V .= FolderListOption(-1, 0); $V .= "</select></td>\n"; $V .= "</tr>\n"; $text = _("Block the user's account. This will prevent logins."); $V .= "{$Style}<th>{$text}</th><td><input type='checkbox' name='block' value='1'></td>\n"; $text = _("Blank the user's account. This will will set the password to a blank password."); $V .= "{$Style}<th>{$text}</th><td><input type='checkbox' name='blank' value='1'></td>\n"; $text = _("Change the user's password."); $V .= "{$Style}<th>{$text}</th><td><input type='password' name='pass1' size=20></td>\n"; $V .= "</tr>\n"; $text = _("Re-enter the user's password."); $V .= "<tr><th>{$text}</th><td><input type='password' name='pass2' size=20></td>\n"; $V .= "</tr>\n"; $text = _("E-mail Notification"); $V .= "{$Style}<th>{$text}</th><td><input type=checkbox name='enote'"; $V .= "</tr>\n"; $V .= "</tr>\n"; $text = _("Default Agents: Select the agent(s) to automatically run when uploading data. These selections can be changed on the upload screens."); $V .= "{$Style}<th>{$text}\n</th><td> "; $V .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent")); $V .= "</td>\n"; $V .= "</tr>\n"; $Val = GetParm('default_bucketpool_fk', PARM_INTEGER); $text = _("Default bucket pool"); $V .= "{$Style}<th>{$text}</th>\n"; $V .= "<td>"; $V .= SelectBucketPool($Val); $V .= "</td>\n"; $V .= "</tr>\n"; /* / ****** New Upload Group ****** / / * Get master array of groups * / $sql = "select group_pk, group_name from groups order by group_name"; $groupresult = pg_query($PG_CONN, $sql); DBCheckResult($groupresult, $sql, __FILE__, __LINE__); $GroupArray = array(); while ($GroupRow = pg_fetch_assoc($groupresult)) $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name']; pg_free_result($groupresult); $text = _("Group to give access permission for every new upload"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $V .= Array2SingleSelect($GroupArray, "new_upload_group_fk", $R['new_upload_group_fk'], true, false); $V.= "</td>"; $V .= "</tr>\n"; / ****** New Upload Permissions ****** / $text = _("Access Permission to give the above group"); $V.= "$Style<th>$text</th>"; $V.= "<td>"; $Selected = (empty($R['new_upload_perm'])) ? -1 : $R['new_upload_perm']; $V .= Array2SingleSelect($PERM_NAMES, "new_upload_perm", $Selected, true, false); $V.= "</td>"; $V .= "</tr>\n"; */ $text = _("User Interface Options"); $text1 = _("Use the simplified UI (Default)"); $text2 = _("Use the original UI"); //$V .= "$Style<th>$text</th><td><input type='radio'" . "name='whichui' id='simple' value='simple' checked='checked'>" . "{$text1}<br><input type='radio'" . "name='whichui' id='original' value='original'>" . "{$text2}</td>\n"; $V .= "</table><P />"; $text = _("Update Account"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }