Changeset 21
- Timestamp:
- Nov 17, 2005 7:37:40 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/module_maker/skel/adm_list.ihtml
r20 r21 12 12 <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '—', city, '—', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?> 13 13 </select> 14 <input type="submit" name="list"value="<?php echo _("Search"); ?>" />14 <input type="submit" value="<?php echo _("Search"); ?>" /> 15 15 </div> 16 16 </form> -
trunk/bin/module_maker/skel/admin.php
r20 r21 216 216 if (!$frm = mysql_fetch_assoc($qid)) { 217 217 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 218 App::raiseMsg(sprintf(_("The requested record %s could not be found "), $id), MSG_ERR, __FILE__, __LINE__);218 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 219 219 App::dieBoomerangURL(); 220 220 } … … 244 244 if ($lock->isLocked() && !$lock->isMine()) { 245 245 $lock->dieErrorPage(); 246 } else {247 // Break the cache because we are changing the list data. 248 SessionCache::breakCache($_SERVER['PHP_SELF']);249 250 // Get the information for this object.251 $qid = DB::query("252 SELECT <##>253 FROM %DB_TBL%254 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'255 ");256 if (! list($name) = mysql_fetch_row($qid)) {257 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);258 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__);259 App::dieBoomerangURL();260 }261 262 // Delete the record.263 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'");264 265 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);266 267 // Unlock record. 268 $lock->remove();269 }246 } 247 248 // Break the cache because we are changing the list data. 249 SessionCache::breakCache($_SERVER['PHP_SELF']); 250 251 // Get the information for this object. 252 $qid = DB::query(" 253 SELECT <##> 254 FROM %DB_TBL% 255 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "' 256 "); 257 if (! list($name) = mysql_fetch_row($qid)) { 258 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 259 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 260 App::dieBoomerangURL(); 261 } 262 263 // Delete the record. 264 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'"); 265 266 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 267 268 // Unlock record. 269 $lock->remove(); 270 270 } 271 271 … … 297 297 if ($lock->isLocked() && !$lock->isMine()) { 298 298 $lock->dieErrorPage(); 299 } else { 300 // Break the cache because we are changing the list data. 301 SessionCache::breakCache($_SERVER['PHP_SELF']); 299 } 300 301 // Break the cache because we are changing the list data. 302 SessionCache::breakCache($_SERVER['PHP_SELF']); 302 303 303 304 %UPDATE% 304 305 // Create version. 306 $version = RecordVersion::getInstance($GLOBALS['auth']); 307 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']); 308 309 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__); 310 311 // Unlock record. 312 $lock->remove(); 313 } 305 306 // Create version. 307 $version = RecordVersion::getInstance($GLOBALS['auth']); 308 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']); 309 310 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__); 311 312 // Unlock record. 313 $lock->remove(); 314 314 } 315 315 -
trunk/bin/module_maker/sql.cli.php
r20 r21 127 127 continue; 128 128 } 129 $key_eq_val .= $comma . "\n 129 $key_eq_val .= $comma . "\n $k = $v"; 130 130 $comma = ','; 131 131 } 132 132 echo <<<E_O_F 133 134 135 136 137 133 // Update record data. 134 DB::query(" 135 UPDATE $db_tbl SET$key_eq_val 136 WHERE $primary_key = '" . addslashes(\$frm['$primary_key']) . "' 137 "); 138 138 E_O_F; 139 139 } -
trunk/css/admin.inc.css
r20 r21 115 115 float: left; 116 116 width: 9em; 117 margin: 0 ;117 margin: 0 0 10px 0; 118 118 border-right: 1px solid gray; 119 119 padding: 0; … … 142 142 text-decoration: none; 143 143 padding: 1px; 144 } 145 146 #leftnav #navlist li.label 147 { 148 color: #999; 149 padding-top: 10px; 150 font-size: 75%; 151 font-weight: bold; 144 152 } 145 153 -
trunk/css/utilities.inc.css
r20 r21 41 41 input.tiny, textarea.tiny 42 42 { 43 width: 5em;43 width: 4.75em; 44 44 } 45 45 -
trunk/docs/revision_history.txt
r20 r21 23 23 - RecordVersion 24 24 - SessionCache 25 - Upload 25 26 26 27 One application will always have distinct: … … 53 54 - do not need to be set in any specific order 54 55 - missing vars are dynamically accounted for. 55 56 57 Auth_SQL object: 58 - Modified to set the auth-type within the object. We needed to use one object name ($auth) for all instances so we can use template that use this variable name commonly. login.php, lock.php, versions.php, password.php -- all in the codebase services will be used globally on multiple sites and need this variable name set. 59 56 60 DB object: 57 61 - Self contained class for DB functions. db::query is the only necessary function. Maintains connections and state independent of App. -
trunk/lib/SessionCache.inc.php
r20 r21 13 13 { 14 14 var $_params = array( 15 'enabled' => true, 15 16 'soft_limit' => 204800, 16 17 'hard_limit' => 4194304, … … 43 44 function setParam($params) 44 45 { 46 if (!isset($this) || !is_a($this, 'SessionCache')) { 47 $this =& SessionCache::getInstance(); 48 } 49 45 50 if (isset($params) && is_array($params)) { 46 51 // Merge new parameters with old overriding only those passed. … … 60 65 function getParam($param) 61 66 { 67 if (!isset($this) || !is_a($this, 'SessionCache')) { 68 $this =& SessionCache::getInstance(); 69 } 70 62 71 if (isset($this->_params[$param])) { 63 72 return $this->_params[$param]; … … 86 95 function putCache($var, $var_id, $force_it_in=false) 87 96 { 88 $cache =& SessionCache::getInstance(); 97 if (!isset($this) || !is_a($this, 'SessionCache')) { 98 $this =& SessionCache::getInstance(); 99 } 100 101 if (!$this->getParam('enabled')) { 102 return false; 103 } 89 104 90 105 $var_id = md5($var_id); … … 92 107 $serialized_var_len = strlen($serialized_var); 93 108 94 if ($serialized_var_len >= $ cache->getParam('soft_limit') && !$force_it_in) {95 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $ cache->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);96 return false; 97 } 98 99 if ($serialized_var_len >= $ cache->getParam('hard_limit')) {100 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $ cache->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);109 if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) { 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 111 return false; 112 } 113 114 if ($serialized_var_len >= $this->getParam('hard_limit')) { 115 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 101 116 return false; 102 117 } … … 107 122 unset($_SESSION['_session_cache'][$var_id]); 108 123 // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least. 109 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $ cache->getParam('soft_limit')110 && sizeof($_SESSION['_session_cache']) >= $ cache->getParam('min_items')) {124 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 125 && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) { 111 126 array_shift($_SESSION['_session_cache']); 112 127 } … … 133 148 function getCache($var_id) 134 149 { 150 if (!isset($this) || !is_a($this, 'SessionCache')) { 151 $this =& SessionCache::getInstance(); 152 } 153 154 if (!$this->getParam('enabled')) { 155 return false; 156 } 157 135 158 $var_id = md5($var_id); 136 159 if (isset($_SESSION['_session_cache'][$var_id])) { … … 155 178 function isCached($var_id) 156 179 { 180 if (!isset($this) || !is_a($this, 'SessionCache')) { 181 $this =& SessionCache::getInstance(); 182 } 183 184 if (!$this->getParam('enabled')) { 185 return false; 186 } 187 157 188 $var_id = md5($var_id); 158 189 return isset($_SESSION['_session_cache'][$var_id]); -
trunk/lib/TemplateGlue.inc.php
r20 r21 72 72 return $enum[1]; 73 73 } else { 74 App::logMsg(sprintf('No set or enum fields found.', null), LOG_DEBUG, __FILE__, __LINE__); 74 75 return false; 75 76 } … … 87 88 $values = getSetEnumFieldValues($db_table, $db_col); 88 89 if ($values === false) { 89 ?><option value=""> <?php echo _("n/a"); ?></option>90 ?><option value=""> </option> 90 91 <?php 91 92 return false; -
trunk/services/admins.php
r20 r21 196 196 } 197 197 198 // If the username was changed during edit, verify.199 198 if (getFormData('user_type') == 'root' && 'root' != $auth->getVal('user_type')) { 200 199 $fv->addError('user_type', sprintf(_("You do not have clearance to create a user with root privileges."), null)); … … 267 266 if (!$frm = mysql_fetch_assoc($qid)) { 268 267 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 269 App::raiseMsg(sprintf(_("The requested record %s could not be found "), $id), MSG_ERR, __FILE__, __LINE__);268 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 270 269 App::dieBoomerangURL(); 271 270 } … … 312 311 if ($lock->isLocked() && !$lock->isMine()) { 313 312 $lock->dieErrorPage(); 313 } 314 315 // Break the cache because we are changing the list data. 316 SessionCache::breakCache($_SERVER['PHP_SELF']); 317 318 // Get the information for this object. 319 $qid = DB::query(" 320 SELECT username, user_type from admin_tbl 321 WHERE admin_id = '" . addslashes($id) . "' 322 "); 323 if (! list($name, $user_type) = mysql_fetch_row($qid)) { 324 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 325 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 326 App::dieBoomerangURL(); 327 } 328 329 // Get the information for this object. 330 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); 331 list($num_admins) = mysql_fetch_row($qid); 332 if ('root' == $user_type && 'root' != $auth->getVal('user_type')) { 333 // Only root users can delete root users! 334 App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__); 335 } else if ($num_admins <= 1) { 336 // There must always be at least one admnistrator! 337 App::raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__); 338 } else if ($auth->getVal('user_id') == $id) { 339 // Do not delete yourself! 340 App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__); 314 341 } else { 315 // Break the cache because we are changing the list data. 316 SessionCache::breakCache($_SERVER['PHP_SELF']); 317 318 // Get the information for this object. 319 $qid = DB::query(" 320 SELECT username, user_type from admin_tbl 321 WHERE admin_id = '" . addslashes($id) . "' 322 "); 323 if (! list($name, $user_type) = mysql_fetch_row($qid)) { 324 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 325 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); 326 App::dieBoomerangURL(); 327 } 328 329 // Get the information for this object. 330 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); 331 list($num_admins) = mysql_fetch_row($qid); 332 if ('root' == $user_type && 'root' != $auth->getVal('user_type')) { 333 // Only root users can delete root users! 334 App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__); 335 } else if ($num_admins <= 1) { 336 // There must always be at least one admnistrator! 337 App::raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__); 338 } else if ($auth->getVal('user_id') == $id) { 339 // Do not delete yourself! 340 App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__); 341 } else { 342 // Delete the record. 343 DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . addslashes($id) . "'"); 344 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 345 } 346 347 // Unlock record. 348 $lock->remove(); 349 } 342 // Delete the record. 343 DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . addslashes($id) . "'"); 344 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 345 } 346 347 // Unlock record. 348 $lock->remove(); 350 349 } 351 350 … … 399 398 if ($lock->isLocked() && !$lock->isMine()) { 400 399 $lock->dieErrorPage(); 401 } else {402 // Break the cache because we are changing the list data. 403 SessionCache::breakCache($_SERVER['PHP_SELF']);404 405 // If the userpass is left blank or with the filler **** characters, we don't want to update it.406 if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) {407 // Set user password.408 $auth->setPassword($frm['admin_id'], $frm['userpass']);409 }410 411 // Update record data.412 DB::query("413 UPDATE admin_tbl SET414 username = '" . addslashes($frm['username']) . "',415 first_name = '" . addslashes($frm['first_name']) . "',416 last_name = '" . addslashes($frm['last_name']) . "',417 email = '" . addslashes($frm['email']) . "',418 user_type = '" . addslashes($frm['user_type']) . "',419 modified_by_user_id = '" . addslashes($auth->getVal('user_id')) . "',420 modified_datetime = NOW()421 WHERE admin_id = '" . addslashes($frm['admin_id']) . "'422 ");423 424 // Create version. 425 $version = RecordVersion::getInstance($GLOBALS['auth']);426 $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);427 428 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 429 430 // Unlock record. 431 $lock->remove();432 }400 } 401 402 // Break the cache because we are changing the list data. 403 SessionCache::breakCache($_SERVER['PHP_SELF']); 404 405 // If the userpass is left blank or with the filler **** characters, we don't want to update it. 406 if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) { 407 // Set user password. 408 $auth->setPassword($frm['admin_id'], $frm['userpass']); 409 } 410 411 // Update record data. 412 DB::query(" 413 UPDATE admin_tbl SET 414 username = '" . addslashes($frm['username']) . "', 415 first_name = '" . addslashes($frm['first_name']) . "', 416 last_name = '" . addslashes($frm['last_name']) . "', 417 email = '" . addslashes($frm['email']) . "', 418 user_type = '" . addslashes($frm['user_type']) . "', 419 modified_by_user_id = '" . addslashes($auth->getVal('user_id')) . "', 420 modified_datetime = NOW() 421 WHERE admin_id = '" . addslashes($frm['admin_id']) . "' 422 "); 423 424 // Create version. 425 $version = RecordVersion::getInstance($GLOBALS['auth']); 426 $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']); 427 428 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 429 430 // Unlock record. 431 $lock->remove(); 433 432 } 434 433 -
trunk/services/templates/admin_list.ihtml
r20 r21 8 8 9 9 <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" /> 10 <input type="submit" name="list"value="<?php echo _("Search"); ?>" />10 <input type="submit" value="<?php echo _("Search"); ?>" /> 11 11 </div> 12 12 -
trunk/services/versions.php
r20 r21 79 79 if ($lock->isLocked() && !$lock->isMine()) { 80 80 $lock->dieErrorPage(); 81 } 82 83 if ($v = $version->restore($version_id)) { 84 // Create version of this restored record as the "current" version. 85 $version->create($record_table, $record_key, $record_val, $v['version_title']); 86 App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__); 87 App::dieBoomerangURL('versions', array('break_list_cache'=>'true', false)); 81 88 } else { 82 if ($v = $version->restore($version_id)) { 83 // Create version of this restored record as the "current" version. 84 $version->create($record_table, $record_key, $record_val, $v['version_title']); 85 App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__); 86 App::dieBoomerangURL('versions', array('break_list_cache'=>'true', false)); 87 } else { 88 App::raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__); 89 App::dieURL($_SERVER['PHP_SELF']); 90 } 89 App::raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__); 90 App::dieURL($_SERVER['PHP_SELF']); 91 91 } 92 92 break;
Note: See TracChangeset
for help on using the changeset viewer.