Merge pull request #349 from TheSerapher/issue-347

Remove PHP Warnings from worker page
This commit is contained in:
Sebastian Grewe 2013-07-03 05:21:56 -07:00
commit d6ab09b5b7
2 changed files with 7 additions and 4 deletions

View File

@ -154,6 +154,10 @@ class Worker {
**/ **/
public function addWorker($account_id, $workerName, $workerPassword) { public function addWorker($account_id, $workerName, $workerPassword) {
$this->debug->append("STA " . __METHOD__, 4); $this->debug->append("STA " . __METHOD__, 4);
if (empty($workerName) || empty($workerPassword)) {
$this->setErrorMessage('Worker and password may not be empty');
return false;
}
$username = $this->user->getUserName($account_id); $username = $this->user->getUserName($account_id);
$workerName = "$username.$workerName"; $workerName = "$username.$workerName";
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, username, password) VALUES(?, ?, ?)"); $stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, username, password) VALUES(?, ?, ?)");
@ -181,7 +185,6 @@ class Worker {
if ($this->checkStmt($stmt)) { if ($this->checkStmt($stmt)) {
$stmt->bind_param('ii', $account_id, $id); $stmt->bind_param('ii', $account_id, $id);
if ($stmt->execute() && $stmt->affected_rows == 1) { if ($stmt->execute() && $stmt->affected_rows == 1) {
$stmt->close;
return true; return true;
} else { } else {
$this->setErrorMessage( 'Unable to delete worker' ); $this->setErrorMessage( 'Unable to delete worker' );

View File

@ -18,8 +18,8 @@
{section worker $WORKERS} {section worker $WORKERS}
{assign var="username" value="."|escape|explode:$WORKERS[worker].username:2} {assign var="username" value="."|escape|explode:$WORKERS[worker].username:2}
<tr> <tr>
<td{if $WORKERS[worker].active} style="color: orange"{/if}>{$username.0|escape}.<input name="data[{$WORKERS[worker].id}][username]" value="{$username.1|escape}" size="10" /></td> <td{if $WORKERS[worker].active} style="color: orange"{/if}>{$username.0|escape}.<input name="data[{$WORKERS[worker].id}][username]" value="{$username.1|escape}" size="10" required/></td>
<td><input type="text" name="data[{$WORKERS[worker].id}][password]" value="{$WORKERS[worker].password|escape}" size="10"></td> <td><input type="text" name="data[{$WORKERS[worker].id}][password]" value="{$WORKERS[worker].password|escape}" size="10" required></td>
<td class="center"><img src="{$PATH}/images/{if $WORKERS[worker].active}success{else}error{/if}.gif" /></td> <td class="center"><img src="{$PATH}/images/{if $WORKERS[worker].active}success{else}error{/if}.gif" /></td>
<td class="center"> <td class="center">
<input type="checkbox" name="data[{$WORKERS[worker].id}][monitor]" value="1" id="data[{$WORKERS[worker].id}][monitor]" {if $WORKERS[worker].monitor}checked{/if} /> <input type="checkbox" name="data[{$WORKERS[worker].id}][monitor]" value="1" id="data[{$WORKERS[worker].id}][monitor]" {if $WORKERS[worker].monitor}checked{/if} />
@ -43,7 +43,7 @@
<input type="hidden" name="page" value="{$smarty.request.page}"> <input type="hidden" name="page" value="{$smarty.request.page}">
<input type="hidden" name="action" value="{$smarty.request.action}"> <input type="hidden" name="action" value="{$smarty.request.action}">
<input type="hidden" name="do" value="add"> <input type="hidden" name="do" value="add">
{$smarty.session.USERDATA.username}.<input type="text" name="username" value="user" size="10" maxlength="20"> · <input type="text" name="password" value="password" size="10" maxlength="20">&nbsp;<input type="submit" value="Add New Worker" style="padding:5px;"> {$smarty.session.USERDATA.username}.<input type="text" name="username" value="user" size="10" maxlength="20" required> · <input type="text" name="password" value="password" size="10" maxlength="20" required>&nbsp;<input type="submit" value="Add New Worker" style="padding:5px;">
</form> </form>
</center> </center>
{include file="global/block_footer.tpl"} {include file="global/block_footer.tpl"}