Changeset 676 for trunk/services
- Timestamp:
- May 3, 2019 2:43:15 AM (5 years ago)
- Location:
- trunk/services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/services/admins.php
r601 r676 79 79 $page = new PageNumbers(); 80 80 $page->setPerPage(getFormData('per_page'), 50); 81 $page->setPageNumber(getFormData('page_number' ));81 $page->setPageNumber(getFormData('page_number', (getFormData('sort') ? 1 : null))); 82 82 83 83 // Query parameters to retain only locally. 84 84 $locally_carried_queries = array( 85 85 'search_query', 86 'break_list_cache' => $app->validBoomerangURL('accounts'), 86 87 ); 87 88 … … 129 130 130 131 case 'insert' : 131 if (getFormdata(' cancel', false)) {132 if (getFormdata('btn_cancel', false)) { 132 133 if ($app->validBoomerangURL('admins')) { 133 134 // Display boomerang page. … … 145 146 } else { 146 147 $admin_id = insertRecord(getFormData()); 147 if (getFormdata(' repeat', false)) {148 if (getFormdata('btn_repeat', false)) { 148 149 // Display function again. 149 150 $app->dieURL($_SERVER['PHP_SELF'] . '?op=add', $locally_carried_queries); … … 158 159 159 160 case 'update' : 160 if (getFormdata(' reset', false)) {161 if (getFormdata('btn_reset', false)) { 161 162 $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__); 162 163 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'), $locally_carried_queries); 163 164 } 164 if (getFormdata(' cancel', false)) {165 if (getFormdata('btn_cancel', false)) { 165 166 // Remove lock 166 167 $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), getFormData('admin_id')); … … 181 182 } else { 182 183 updateRecord(getFormData()); 183 if (getFormdata(' repeat', false)) {184 if (getFormdata('btn_repeat', false)) { 184 185 // Display edit function with next available ID. 185 186 $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"); … … 208 209 *****************************************************************************/ 209 210 211 $nav->set('body_id', 'admins'); 212 210 213 include 'header.ihtml'; 211 214 $app->carryQuery($locally_carried_queries); … … 230 233 } 231 234 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.")); 233 236 234 237 $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank.")); 235 238 $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters.")); 236 239 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 } 239 246 240 247 $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters.")); … … 266 273 'modified_datetime' => '', 267 274 'new_op' => 'insert', 275 'user_type' => '', 268 276 'submit_buttons' => array( 269 array('name' => ' submit', 'value' => _("Add Administrator"), 'class' => 'small button', 'accesskey' => 's'),270 array('name' => ' repeat', 'value' => _("Add & 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 & repeat"), 'accesskey' => 'r'), 279 array('name' => 'btn_cancel', 'class' => 'secondary', 'value' => _("Cancel"), 'accesskey' => 'c'), 272 280 ), 273 281 ); … … 298 306 if (!$frm = mysql_fetch_assoc($qid)) { 299 307 $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__); 301 309 $app->dieBoomerangURL('admins', $locally_carried_queries); 302 310 } … … 310 318 'old_username' => $frm['username'], 311 319 'username' => '', 312 // 'userpass' => '****************',320 'userpass' => '', 313 321 'first_name' => '', 314 322 'last_name' => '', … … 317 325 'last_login_datetime' => '', 318 326 'last_access_datetime' => '', 319 'last_login_ip' => ' 0.0.0.0',327 'last_login_ip' => '', 320 328 'added_by_user_id' => '', 321 329 'modified_by_user_id' => '', … … 325 333 'old_username' => $frm['username'], 326 334 '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'), 331 339 ), 332 ), $frm , array('userpass' => 'â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢'));340 ), $frm); 333 341 334 342 return $frm; … … 360 368 if (! list($name) = mysql_fetch_row($qid)) { 361 369 $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__); 363 371 $app->dieBoomerangURL('admins', $locally_carried_queries); 364 372 } … … 368 376 list($num_admins) = mysql_fetch_row($qid); 369 377 if ($num_admins <= 1) { 370 // There must always be at least one adm nistrator!378 // There must always be at least one administrator! 371 379 $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__); 372 380 } else if ($auth->get('user_id') == $id) { … … 495 503 } 496 504 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 497 510 // Count the total number of records so we can do something about the page numbers. 498 511 $qid = $db->query(" … … 522 535 "; 523 536 524 // Use a ca shhash to determine if the result-set has changed.537 // Use a cache hash to determine if the result-set has changed. 525 538 // A unique key for this query, with the total_items in case db records 526 539 // were added since the last cache. This identifies a unique set of … … 536 549 // First try to return from the cache. 537 550 if ($cache->exists('list')) { 538 $list = $cache->get('list'); 539 return $list; 551 return $cache->get('list'); 540 552 } 541 553 542 554 // The list was not cached, so issue the real query. 543 555 $qid = $db->query($sql); 556 $list = array(); 544 557 while ($row = mysql_fetch_assoc($qid)) { 545 558 $list[] = $row; -
trunk/services/templates/admin_form.ihtml
r497 r676 34 34 <div class="medium-5 large-3 columns end"> 35 35 <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 } ?> 37 40 </div> 38 41 </div>
Note: See TracChangeset
for help on using the changeset viewer.