set_focus('tab', 'users', null); if (!can_perform('canadminusers')) { admin_login(); } // ################################################################### /** * Generate an inline checkbox * * @access public * * @param string Name * @param bool Checked? * * @return string HTML checkbxo */ function draw_checkbox($name, $checked) { return ""; } // ################################################################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'modify'; } // ################################################################### if ($_REQUEST['do'] == 'kill') { $user = new UserAPI($bugsys); $user->set('userid', $bugsys->in['userid']); $user->set_condition(); $user->delete(); $admin->redirect('user.php'); } // ################################################################### if ($_REQUEST['do'] == 'delete') { $admin->page_confirm(_('Are you sure you want to delete this user?'), 'user.php', 'kill', array('userid' => $bugsys->input_clean('userid', TYPE_UINT))); } // ################################################################### if ($_POST['do'] == 'insert') { $user = new UserAPI($bugsys); $user->set('displayname', $bugsys->in['displayname']); $user->set('email', $bugsys->in['email']); $user->set('showemail', $bugsys->in['showemail']); $user->set('showcolors', $bugsys->in['showcolors']); $user->set('usergroupid', $bugsys->in['usergroupid']); $user->set('groupids', $bugsys->in['groupids']); $user->set('languageid', $bugsys->in['languageid']); $user->set('timezone', $bugsys->in['timezone']); $user->set('usedst', $bugsys->in['usedst']); $user->set('password', $bugsys->in['password']); $user->set('hidestatuses', $bugsys->in['hidestatuses']); $user->set('defaultsortkey', $bugsys->in['defaultsortkey']); $user->set('defaultsortas', $bugsys->in['defaultsortas']); $user->insert(); // post_insert will set the email options... so we now have to dump them $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->insertid); $bugsys->input_clean('emailopts', TYPE_INT); if (is_array($bugsys->in['emailopts'])) { foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) { $bitmask = 0; foreach ($bitarr AS $option => $yes) { $bitmask += $option * $yes; } $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $user->insertid . ", $relation, $bitmask)"); } } $admin->redirect('user.php?do=edit&userid=' . $user->insertid); } // ################################################################### if ($_POST['do'] == 'update') { $user = new UserAPI($bugsys); $user->set('userid', $bugsys->in['userid']); $user->set_condition(); $user->set('displayname', $bugsys->in['displayname']); $user->set('email', $bugsys->in['email']); $user->set('showemail', $bugsys->in['showemail']); $user->set('showcolors', $bugsys->in['showcolors']); $user->set('usergroupid', $bugsys->in['usergroupid']); $user->set('groupids', $bugsys->in['groupids']); $user->set('languageid', $bugsys->in['languageid']); $user->set('timezone', $bugsys->in['timezone']); $user->set('usedst', $bugsys->in['usedst']); $user->set('password', $bugsys->in['password']); $user->set('hidestatuses', $bugsys->in['hidestatuses']); $user->set('defaultsortkey', $bugsys->in['defaultsortkey']); $user->set('defaultsortas', $bugsys->in['defaultsortas']); $user->update(); $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->values['userid']); $bugsys->input_clean('emailopts', TYPE_INT); if (is_array($bugsys->in['emailopts'])) { foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) { $bitmask = 0; foreach ($bitarr AS $option => $yes) { $bitmask += $option * $yes; } $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $user->values['userid'] . ", $relation, $bitmask)"); } } $admin->redirect('user.php?do=edit&userid=' . $user->objdata['userid']); } // ################################################################### if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add') { $add = ($_REQUEST['do'] == 'add'); $edit = (!$add); if ($edit) { NavLinks::usersEdit($bugsys->in['userid']); $navigator->set_focus('link', 'users-pages-users', 'users-pages'); $user = new UserAPI($bugsys); $user->set('userid', $bugsys->in['userid']); $user->set_condition(); $user->fetch(); } else { NavLinks::usersAdd(); $navigator->set_focus('link', 'users-add', 'users'); } $admin->page_start(($add ? _('Add User') : _('Edit User'))); $admin->form_start('user.php', ($add ? 'insert' : 'update')); if ($edit) { $admin->form_hidden_field('userid', $user->objdata['userid']); } $admin->table_start(); $admin->table_head(($add ? _('Add User') : sprintf(_('Edit User (userid: %1$s)'), $user->objdata['userid']))); $admin->row_input(_('Display Name'), 'displayname', $user->objdata['displayname']); $admin->row_input(_('Email'), 'email', $user->objdata['email']); $admin->row_input(($add ? _('Password') : _('Password (Leave blank for no change)')), 'password'); foreach ($bugsys->datastore['usergroup'] AS $group) { $admin->list_item($group['title'], $group['usergroupid'], ($user->objdata['usergroupid'] == $group['usergroupid'])); } $admin->row_list(_('Primary Usergroup'), 'usergroupid'); $ids = explode(',', $user->objdata['groupids']); foreach ($bugsys->datastore['usergroup'] AS $id => $group) { if ($id == $user->objdata['usergroupid']) { continue; } $admin->list_item($group['title'], $group['usergroupid'], in_array($id, $ids)); } $admin->row_checkbox(_('Secondary Usergroups'), 'groupids'); $admin->row_yesno(_('Show Email Publicly'), 'showemail', $user->objdata['showemail']); $admin->row_yesno(_('Show Status Colors on Bug Listings'), 'showcolors', $user->objdata['showcolors']); foreach ($bugsys->datastore['language'] AS $language) { $admin->list_item($language['title'], $language['languageid'], ($user->objdata['languageid'] == $language['languageid'])); } $admin->row_list(_('Language'), 'languageid'); foreach ($datef->fetch_timezone_list() AS $value => $string) { $admin->list_item($string, $value, ($user->objdata['timezone'] == $value)); } $admin->row_list(_('Timezone'), 'timezone'); $admin->row_yesno(_('Observe Daylight Savings Time (DST)'), 'usedst', $user->objdata['usedst']); $admin->row_text(_('Hidden Statuses on Bug Listing'), construct_option_select('hidestatuses', $bugsys->datastore['status'], $user->objdata['hidestatuses'], 'statusid', 'status', 0, true)); $admin->row_text(_('Default Sort Order Column'), construct_option_select('defaultsortkey', ListSorter::fetch_by_text(false), $user->objdata['defaultsortkey'])); $admin->row_text(_('Default Sort Order Direction'), construct_option_select('defaultsortas', ListSorter::fetch_as_text(false), $user->objdata['defaultsortas'])); $admin->table_end(); // ------------------------------------------------------------------- $admin->table_start(false); $admin->table_head(_('Email Options'), 6); if ($user->objdata['userid']) { $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->objdata['userid']); while ($opt = $db->fetch_array($options)) { foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) { foreach ($bugsys->emailoptions['relations'] AS $name => $relation) { if ($opt['mask'] & $notif AND $opt['relation'] == $relation) { $checked["$relation"]["$notif"] = HTML_CHECKED; } } } } } $admin->table_column_head(array('', _('Reporter'), _('Assignee'), _('Favorite'), _('Voter'), _('Commenter'))); // ------------------------------------------------------------------- $admin->row_text(_('New bug is added'), '