21 define(
"TITLE_USER_ADD", _(
"Add A User"));
29 function __construct()
31 $this->Name =
"user_add";
32 $this->Title = TITLE_USER_ADD;
33 $this->MenuList =
"Admin::Users::Add";
35 parent::__construct();
36 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
52 $text = _(
"NO DB connection!");
53 echo
"<pre>$text\n</pre>";
62 $Seed = rand() . rand();
63 $Hash = sha1($Seed . $Pass);
74 $text = _(
"Username must be specified. Not added.");
78 if (strlen($User) > 64) {
79 $text = _(
"Username exceed 64 characters. Not added.");
83 if ($Pass != $Pass2) {
84 $text = _(
"Passwords did not match. Not added.");
89 $text = _(
"Email must be specified. Not added.");
94 if (! filter_var($Email, FILTER_VALIDATE_EMAIL)) {
95 $text = _(
"Invalid email address. Not added.");
100 $email_count = $this->
dbManager->getSingleRow(
101 "SELECT COUNT(*) as count FROM users WHERE user_email = $1 LIMIT 1;",
102 array($Email))[
"count"];
103 if ($email_count > 0) {
104 $text = _(
"Email address already exists. Not added.");
109 $row = $this->
dbManager->getSingleRow(
"SELECT * FROM users WHERE LOWER(user_name) = LOWER($1) LIMIT 1;",
110 array($User), $stmt = __METHOD__ .
".getUserIfExisting");
111 if (! empty($row[
'user_name'])) {
112 $text = _(
"User already exists. Not added.");
119 if (empty($Email_notify) || empty($Email)) {
123 $ErrMsg =
add_user($User, $Desc, $Seed, $Hash, $Perm, $Email, $Email_notify,
124 $agentList, $Folder, $default_bucketpool_fk);
130 public function Output()
134 if (! empty($User)) {
139 $this->vars[
'message'] =
"$text $User $text1.";
141 $this->vars[
'message'] = $rc;
145 $V =
"<form name='formy' method='POST'>\n";
146 $V.= _(
"To create a new user, enter the following information:<P />\n");
147 $Style =
"<tr><td colspan=2 style='background:black;'></td></tr><tr>";
148 $V.=
"<table style='border:1px solid black; text-align:left; background:lightyellow;' width='75%'>";
150 $text = _(
"Username");
151 $V.=
"$Style<th width='25%' >$text</th>";
152 $V.=
"<td><input type='text' value='$Val' name='username' size=20></td>\n";
155 $text = _(
"Description, full name, contact, etc. (optional)");
156 $V.=
"$Style<th>$text</th>\n";
157 $V.=
"<td><input type='text' name='description' value='$Val' size=60></td>\n";
160 $text = _(
"Email address");
161 $V .=
"$Style<th>$text</th>\n";
162 $V.=
"<td><input type='text' name='email' value='$Val' size=60></td>\n";
164 $text = _(
"Access level");
165 $V.=
"$Style<th>$text</th>";
166 $V.=
"<td><select name='permission'>\n";
167 $text = _(
"None (very basic, no database access)");
169 $text = _(
"Read-only (read, but no writes or downloads)");
170 $V.=
"<option selected value='" .
PLUGIN_DB_READ .
"'>$text</option>\n";
171 $text = _(
"Read-Write (read, download, or edit information)");
173 $text = _(
"Clearing Administrator (read, download, edit information and edit decisions)");
174 $V.=
"<option value='" . PLUGIN_DB_CADMIN .
"'>$text</option>\n";
175 $text = _(
"Full Administrator (all access including adding and deleting users)");
177 $V.=
"</select></td>\n";
179 $text = _(
"User root folder");
180 $V.=
"$Style<th>$text";
182 $V.=
"<td><select name='folder' class='ui-render-select2'>";
184 $V.=
"</select></td>\n";
186 $text = _(
"Password (optional)");
187 $V.=
"$Style<th>$text</th><td><input type='password' name='pass1' size=20></td>\n";
189 $text = _(
"Re-enter password");
190 $V.=
"$Style<th>$text</th><td><input type='password' name='pass2' size=20></td>\n";
192 $text = _(
"E-mail Notification");
193 $text1 = _(
"Check to enable email notification when upload scan completes .");
194 $V .=
"$Style<th>$text</th><td><input type='checkbox'" .
195 "name='enote' value='y' checked='checked'>" .
198 $text = _(
"Agents selected by default when uploading");
199 $V .=
"$Style<th>$text\n</th><td> ";
200 $V.=
AgentCheckBoxMake(-1, array(
"agent_unpack",
"agent_adj2nest",
"wget_agent"));
203 $text = _(
"Default bucketpool");
204 $V.=
"$Style<th>$text</th>";
206 $default_bucketpool_fk = 0;
210 $V.=
"</table border=0><P />";
212 $text = _(
"Add User");
213 $V.=
"<input type='submit' value='$text'>\n";
SelectBucketPool($selected, $active='Y')
Return a select list containing all the active bucketpool's.
userAgents()
Read the UI form and format the user selected agents into a comma separated list. ...
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
FolderListOption($ParentFolder, $Depth, $IncludeTop=1, $SelectId=-1, $linkParent=false, $OldParent=0)
Create the folder tree, using OPTION tags.
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
AgentCheckBoxMake($upload_pk, $SkipAgents=array(), $specified_username="")
Generate a checkbox list of available agents.
add_user($User, $Desc, $Seed, $Hash, $Perm, $Email, $Email_notify, $agentList, $Folder, $default_bucketpool_fk='')
Add a user.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
#define PLUGIN_DB_NONE
Plugin requires no DB permission.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
char * trim(char *ptext)
Trimming whitespace.