Changeset 676 for trunk/services


Ignore:
Timestamp:
May 3, 2019 2:43:15 AM (5 years ago)
Author:
anonymous
Message:

Update admins.php. Fix $safe_http_host

Location:
trunk/services
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/services/admins.php

    r601 r676  
    7979$page = new PageNumbers();
    8080$page->setPerPage(getFormData('per_page'), 50);
    81 $page->setPageNumber(getFormData('page_number'));
     81$page->setPageNumber(getFormData('page_number', (getFormData('sort') ? 1 : null)));
    8282
    8383// Query parameters to retain only locally.
    8484$locally_carried_queries = array(
    8585    'search_query',
     86    'break_list_cache' => $app->validBoomerangURL('accounts'),
    8687);
    8788
     
    129130
    130131case 'insert' :
    131     if (getFormdata('cancel', false)) {
     132    if (getFormdata('btn_cancel', false)) {
    132133        if ($app->validBoomerangURL('admins')) {
    133134            // Display boomerang page.
     
    145146    } else {
    146147        $admin_id = insertRecord(getFormData());
    147         if (getFormdata('repeat', false)) {
     148        if (getFormdata('btn_repeat', false)) {
    148149            // Display function again.
    149150            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add', $locally_carried_queries);
     
    158159
    159160case 'update' :
    160     if (getFormdata('reset', false)) {
     161    if (getFormdata('btn_reset', false)) {
    161162        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
    162163        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'), $locally_carried_queries);
    163164    }
    164     if (getFormdata('cancel', false)) {
     165    if (getFormdata('btn_cancel', false)) {
    165166        // Remove lock
    166167        $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), getFormData('admin_id'));
     
    181182    } else {
    182183        updateRecord(getFormData());
    183         if (getFormdata('repeat', false)) {
     184        if (getFormdata('btn_repeat', false)) {
    184185            // Display edit function with next available ID.
    185186            $qid = $db->query("SELECT " . $auth->getParam('db_primary_key') . " FROM " . $auth->getParam('db_table') . " WHERE " . $auth->getParam('db_primary_key') . " > '" . $db->escapeString(getFormData('admin_id')) . "' ORDER BY " . $auth->getParam('db_primary_key') . " ASC LIMIT 1");
     
    208209 *****************************************************************************/
    209210
     211$nav->set('body_id', 'admins');
     212
    210213include 'header.ihtml';
    211214$app->carryQuery($locally_carried_queries);
     
    230233    }
    231234
    232     $fv->numericRange('admin_id', 0, 32767, _("<strong>Admin id</strong> must be a valid number between 0 and 32767."));
     235    $fv->numericRange('admin_id', 0, 32767, _("<strong>Admin ID</strong> must be a valid number between 0 and 32767."));
    233236
    234237    $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank."));
    235238    $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters."));
    236239
    237     $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank."));
    238     $fv->stringLength('userpass', 8, 36, _("<strong>Passwords</strong> must be between 8 and 36 characters long."));
     240    if ('insert' == getFormData('op')) {
     241        $fv->isEmpty('userpass', _("<strong>Password</strong> cannot be blank."));
     242    }
     243    if ('update' == getFormData('op') && strlen(getFormData('userpass')) > 0) {
     244        $fv->stringLength('userpass', 8, 100, _("<strong>Password</strong> must be between 8 and 100 characters long."));
     245    }
    239246
    240247    $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters."));
     
    266273        'modified_datetime' => '',
    267274        'new_op' => 'insert',
     275        'user_type' => '',
    268276        'submit_buttons' => array(
    269             array('name' => 'submit', 'value' => _("Add Administrator"), 'class' => 'small button', 'accesskey' => 's'),
    270             array('name' => 'repeat', 'value' => _("Add &amp; repeat"), 'class' => 'small button secondary', 'accesskey' => 'r'),
    271             array('name' => 'cancel', 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c'),
     277            array('name' => 'btn_submit', 'value' => _("Add Administrator"), 'accesskey' => 's'),
     278            array('name' => 'btn_repeat', 'class' => 'secondary', 'value' => _("Add &amp; repeat"), 'accesskey' => 'r'),
     279            array('name' => 'btn_cancel', 'class' => 'secondary', 'value' => _("Cancel"), 'accesskey' => 'c'),
    272280        ),
    273281    );
     
    298306    if (!$frm = mysql_fetch_assoc($qid)) {
    299307        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    300         $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     308        $app->raiseMsg(sprintf(_("The requested user %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    301309        $app->dieBoomerangURL('admins', $locally_carried_queries);
    302310    }
     
    310318        'old_username' => $frm['username'],
    311319        'username' => '',
    312 //         'userpass' => '****************',
     320        'userpass' => '',
    313321        'first_name' => '',
    314322        'last_name' => '',
     
    317325        'last_login_datetime' => '',
    318326        'last_access_datetime' => '',
    319         'last_login_ip' => '0.0.0.0',
     327        'last_login_ip' => '',
    320328        'added_by_user_id' => '',
    321329        'modified_by_user_id' => '',
     
    325333        'old_username' => $frm['username'],
    326334        'submit_buttons' => array(
    327             array('name' => 'submit', 'value' => _("Save changes"), 'class' => 'small button', 'accesskey' => 's'),
    328             array('name' => 'repeat', 'value' => _("Save & edit next"), 'class' => 'small button secondary', 'accesskey' => 'e'),
    329             array('name' => 'reset', 'value' => _("Reset"), 'class' => 'small button secondary', 'accesskey' => 'r'),
    330             array('name' => 'cancel', 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c'),
     335            array('name' => 'btn_submit', 'value' => _("Save changes"), 'accesskey' => 's'),
     336            array('name' => 'btn_repeat', 'class' => 'secondary', 'value' => _("Save & edit next"), 'accesskey' => 'e'),
     337            array('name' => 'btn_reset', 'class' => 'secondary', 'value' => _("Reset"), 'accesskey' => 'r'),
     338            array('name' => 'btn_cancel', 'class' => 'secondary', 'value' => _("Cancel"), 'accesskey' => 'c'),
    331339        ),
    332     ), $frm, array('userpass' => '•••••••••••••••'));
     340    ), $frm);
    333341
    334342    return $frm;
     
    360368    if (! list($name) = mysql_fetch_row($qid)) {
    361369        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    362         $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     370        $app->raiseMsg(sprintf(_("The requested user %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    363371        $app->dieBoomerangURL('admins', $locally_carried_queries);
    364372    }
     
    368376    list($num_admins) = mysql_fetch_row($qid);
    369377    if ($num_admins <= 1) {
    370         // There must always be at least one admnistrator!
     378        // There must always be at least one administrator!
    371379        $app->raiseMsg(_("You cannot delete the only user in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__);
    372380    } else if ($auth->get('user_id') == $id) {
     
    495503    }
    496504
     505    if (getFormData('filter_user_type', false)) {
     506        // Limit by filter.
     507        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " " . $auth->getParam('db_table') . ".user_type = '" . $db->escapeString(getFormData('filter_user_type')) . "'";
     508    }
     509
    497510    // Count the total number of records so we can do something about the page numbers.
    498511    $qid = $db->query("
     
    522535    ";
    523536
    524     // Use a cash hash to determine if the result-set has changed.
     537    // Use a cache hash to determine if the result-set has changed.
    525538    // A unique key for this query, with the total_items in case db records
    526539    // were added since the last cache. This identifies a unique set of
     
    536549    // First try to return from the cache.
    537550    if ($cache->exists('list')) {
    538         $list = $cache->get('list');
    539         return $list;
     551        return $cache->get('list');
    540552    }
    541553
    542554    // The list was not cached, so issue the real query.
    543555    $qid = $db->query($sql);
     556    $list = array();
    544557    while ($row = mysql_fetch_assoc($qid)) {
    545558        $list[] = $row;
  • trunk/services/templates/admin_form.ihtml

    r497 r676  
    3434            <div class="medium-5 large-3 columns end">
    3535                <label for="userpass" class="<?php $fv->err('userpass'); ?>"><?php echo _("Password"); ?></label>
    36                 <input type="password" class="sc-small" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>" />
     36                <input type="password" class="sc-small" size="50" name="userpass" value="" />
     37                <?php if ('add' != getFormData('op') && 'insert' != getFormData('op')) { ?>
     38                    <div class="sc-help"><?php echo _("Leave blank unless setting a new password."); ?></div>
     39                <?php } ?>
    3740            </div>
    3841        </div>
Note: See TracChangeset for help on using the changeset viewer.