Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F775842
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Feb 6, 10:17 AM
Size
63 KB
Mime Type
text/x-diff
Expires
Sat, Feb 8, 10:17 AM (1 d, 18 h)
Engine
blob
Format
Raw Data
Handle
558350
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/RC/core/kernel/session/session.php
===================================================================
--- branches/RC/core/kernel/session/session.php (revision 10371)
+++ branches/RC/core/kernel/session/session.php (revision 10372)
@@ -1,1022 +1,1029 @@
<?php
/*
The session works the following way:
1. When a visitor loads a page from the site the script checks if cookies_on varibale has been passed to it as a cookie.
2. If it has been passed, the script tries to get Session ID (SID) from the request:
3. Depending on session mode the script is getting SID differently.
The following modes are available:
smAUTO - Automatic mode: if cookies are on at the client side, the script relays only on cookies and
ignore all other methods of passing SID.
If cookies are off at the client side, the script relays on SID passed through query string
and referal passed by the client. THIS METHOD IS NOT 100% SECURE, as long as attacker may
get SID and substitude referal to gain access to user' session. One of the faults of this method
is that the session is only created when the visitor clicks the first link on the site, so
there is NO session at the first load of the page. (Actually there is a session, but it gets lost
after the first click because we do not use SID in query string while we are not sure if we need it)
smCOOKIES_ONLY - Cookies only: in this mode the script relays solely on cookies passed from the browser
and ignores all other methods. In this mode there is no way to use sessions for clients
without cookies support or cookies support disabled. The cookies are stored with the
full domain name and path to base-directory of script installation.
smGET_ONLY - GET only: the script will not set any cookies and will use only SID passed in
query string using GET, it will also check referal. The script will set SID at the
first load of the page
smCOOKIES_AND_GET - Combined mode: the script will use both cookies and GET right from the start. If client has
cookies enabled, the script will check SID stored in cookie and passed in query string, and will
use this SID only if both cookie and query string matches. However if cookies are disabled on the
client side, the script will work the same way as in GET_ONLY mode.
4. After the script has the SID it tries to load it from the Storage (default is database)
5. If such SID is found in the database, the script checks its expiration time. If session is not expired, it updates
its expiration, and resend the cookie (if applicable to session mode)
6. Then the script loads all the data (session variables) pertaining to the SID.
Usage:
$session = new Session(smAUTO); //smAUTO is default, you could just leave the brackets empty, or provide another mode
$session->SetCookieDomain('my.domain.com');
$session->SetCookiePath('/myscript');
$session->SetCookieName('my_sid_cookie');
$session->SetGETName('sid');
$session->InitSession();
...
//link output:
echo "<a href='index.php?'". ( $session->NeedQueryString() ? 'sid='.$session->SID : '' ) .">My Link</a>";
*/
//Implements session storage in the database
class SessionStorage extends kDBBase {
var $Expiration;
var $SessionTimeout=0;
var $DirectVars = Array();
var $ChangedDirectVars = Array();
var $PersistentVars = Array ();
var $OriginalData=Array();
var $TimestampField;
var $SessionDataTable;
var $DataValueField;
var $DataVarField;
function Init($prefix,$special)
{
parent::Init($prefix,$special);
$this->setTableName('sessions');
$this->setIDField('sid');
$this->TimestampField = 'expire';
$this->SessionDataTable = 'SessionData';
$this->DataValueField = 'value';
$this->DataVarField = 'var';
}
function setSessionTimeout($new_timeout)
{
$this->SessionTimeout = $new_timeout;
}
function StoreSession(&$session, $additional_fields = Array())
{
if (defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound($this->TableName)) {
return false;
}
$fields_hash = Array (
$this->IDField => $session->SID,
$this->TimestampField => $session->Expiration
);
$this->Conn->doInsert($fields_hash, $this->TableName);
foreach ($additional_fields as $field_name => $field_value) {
$this->SetField($session, $field_name, $field_value);
}
}
function DeleteSession(&$session)
{
$query = ' DELETE FROM '.$this->TableName.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
$this->Conn->Query($query);
$query = ' DELETE FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
$this->Conn->Query($query);
$this->OriginalData = Array();
}
function UpdateSession(&$session, $timeout=0)
{
$this->SetField($session, $this->TimestampField, $session->Expiration);
$query = ' UPDATE '.$this->TableName.' SET '.$this->TimestampField.' = '.$session->Expiration.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
$this->Conn->Query($query);
}
function LocateSession($sid)
{
$query = ' SELECT * FROM '.$this->TableName.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($sid);
$result = $this->Conn->GetRow($query);
if($result===false) return false;
$this->DirectVars = $result;
$this->Expiration = $result[$this->TimestampField];
return true;
}
function GetExpiration()
{
return $this->Expiration;
}
function LoadData(&$session)
{
$query = 'SELECT '.$this->DataValueField.','.$this->DataVarField.' FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
$this->OriginalData = $this->Conn->GetCol($query, $this->DataVarField);
return $this->OriginalData;
}
/**
* Enter description here...
*
* @param Session $session
* @param string $var_name
* @param mixed $default
*/
function GetField(&$session, $var_name, $default = false)
{
return isset($this->DirectVars[$var_name]) ? $this->DirectVars[$var_name] : $default;
//return $this->Conn->GetOne('SELECT '.$var_name.' FROM '.$this->TableName.' WHERE `'.$this->IDField.'` = '.$this->Conn->qstr($session->GetID()) );
}
function SetField(&$session, $var_name, $value)
{
$value_changed = !isset($this->DirectVars[$var_name]) || ($this->DirectVars[$var_name] != $value);
if ($value_changed) {
$this->DirectVars[$var_name] = $value;
$this->ChangedDirectVars[] = $var_name;
$this->ChangedDirectVars = array_unique($this->ChangedDirectVars);
}
//return $this->Conn->Query('UPDATE '.$this->TableName.' SET '.$var_name.' = '.$this->Conn->qstr($value).' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->GetID()) );
}
function SaveData(&$session)
{
if(!$session->SID) return false; // can't save without sid
$ses_data = $session->Data->GetParams();
$replace = '';
foreach ($ses_data as $key => $value)
{
if ( isset($this->OriginalData[$key]) && $this->OriginalData[$key] == $value)
{
continue; //skip unchanged session data
}
else
{
$replace .= sprintf("(%s, %s, %s),",
$this->Conn->qstr($session->SID),
$this->Conn->qstr($key),
$this->Conn->qstr($value));
}
}
$replace = rtrim($replace, ',');
if ($replace != '') {
$query = ' REPLACE INTO '.$this->SessionDataTable. ' ('.$this->IDField.', '.$this->DataVarField.', '.$this->DataValueField.') VALUES '.$replace;
$this->Conn->Query($query);
}
if ($this->ChangedDirectVars) {
$changes = array();
foreach ($this->ChangedDirectVars as $var) {
$changes[] = $var.' = '.$this->Conn->qstr($this->DirectVars[$var]);
}
$query = 'UPDATE '.$this->TableName.' SET '.implode(',', $changes).' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->GetID());
$this->Conn->Query($query);
}
}
function RemoveFromData(&$session, $var)
{
$query = 'DELETE FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID).
' AND '.$this->DataVarField.' = '.$this->Conn->qstr($var);
$this->Conn->Query($query);
unset($this->OriginalData[$var]);
}
function GetFromData(&$session, $var)
{
return getArrayValue($this->OriginalData, $var);
}
function GetExpiredSIDs()
{
$query = ' SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE '.$this->TimestampField.' > '.adodb_mktime();
return $this->Conn->GetCol($query);
}
function DeleteExpired()
{
$expired_sids = $this->GetExpiredSIDs();
if ($expired_sids) {
$sessionlog_table = $this->Application->getUnitOption('session-log', 'TableName');
$session_log_sql =
' UPDATE '.$sessionlog_table.'
SET Status = 2, SessionEnd =
( SELECT '.$this->TimestampField.' - '.$this->SessionTimeout.'
FROM '.$this->TableName.'
WHERE '.$this->IDField.' = '.$sessionlog_table.'.SessionId
)
WHERE Status = 0 AND SessionId IN ('.join(',', $expired_sids).')';
$this->Conn->Query($session_log_sql);
$where_clause = ' WHERE '.$this->IDField.' IN ("'.implode('","',$expired_sids).'")';
$sql = 'DELETE FROM '.$this->SessionDataTable.$where_clause;
$this->Conn->Query($sql);
$sql = 'DELETE FROM '.$this->TableName.$where_clause;
$this->Conn->Query($sql);
// delete debugger ouputs left of expired sessions
foreach ($expired_sids as $expired_sid) {
$debug_file = (defined('WRITEABLE') ? WRITEABLE : FULL_PATH.'/kernel').'/cache/debug_@'.$expired_sid.'@.txt';
if (file_exists($debug_file)) {
@unlink($debug_file);
}
}
}
return $expired_sids;
}
function LoadPersistentVars(&$session)
{
$user_id = $session->RecallVar('user_id');
if ($user_id != -2) {
// root & normal users
$sql = 'SELECT VariableValue, VariableName
FROM '.TABLE_PREFIX.'PersistantSessionData
WHERE PortalUserId = '.$user_id;
$this->PersistentVars = $this->Conn->GetCol($sql, 'VariableName');
}
else {
$this->PersistentVars = Array ();
}
}
/**
* Stores variable to persistent session
*
* @param Session $session
* @param string $var_name
* @param mixed $var_value
*/
function StorePersistentVar(&$session, $var_name, $var_value)
{
$user_id = $session->RecallVar('user_id');
if ($user_id == -2 || $user_id === false) {
// -2 (when not logged in), false (when after u:OnLogout event)
$session->StoreVar($var_name, $var_value);
return ;
}
$this->PersistentVars[$var_name] = $var_value;
$key_clause = 'PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name);
$sql = 'SELECT VariableName
FROM '.TABLE_PREFIX.'PersistantSessionData
WHERE '.$key_clause;
$record_found = $this->Conn->GetOne($sql);
$fields_hash = Array (
'PortalUserId' => $user_id,
'VariableName' => $var_name,
'VariableValue' => $var_value,
);
if ($record_found) {
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'PersistantSessionData', $key_clause);
}
else {
$this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PersistantSessionData');
}
}
/**
* Gets persistent variable
*
* @param Session $session
* @param string $var_name
* @param mixed $default
* @return mixed
*/
function RecallPersistentVar(&$session, $var_name, $default = false)
{
if ($session->RecallVar('user_id') == -2) {
if ($default == '_USE_DEFAULT_USER_DATA_') {
$default = null;
}
return $session->RecallVar($var_name, $default);
}
if (array_key_exists($var_name, $this->PersistentVars)) {
return $this->PersistentVars[$var_name];
}
elseif ($default == '_USE_DEFAULT_USER_DATA_') {
$default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId');
if (!$default_user_id) {
$default_user_id = -1;
}
$sql = 'SELECT VariableValue, VariableName
FROM '.TABLE_PREFIX.'PersistantSessionData
WHERE VariableName = '.$this->Conn->qstr($var_name).' AND PortalUserId = '.$default_user_id;
$value = $this->Conn->GetOne($sql);
$this->PersistentVars[$var_name] = $value;
if ($value !== false) {
$this->StorePersistentVar($session, $var_name, $value); //storing it, so next time we don't load default user setting
}
return $value;
}
else {
return $default;
}
}
function RemovePersistentVar(&$session, $var_name)
{
unset($this->PersistentVars[$var_name]);
$user_id = $session->RecallVar('user_id');
if ($user_id != -2) {
$sql = 'DELETE FROM '.TABLE_PREFIX.'PersistantSessionData
WHERE PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name);
$this->Conn->Query($sql);
}
}
}
define('smAUTO', 1);
define('smCOOKIES_ONLY', 2);
define('smGET_ONLY', 3);
define('smCOOKIES_AND_GET', 4);
class Session extends kBase {
var $Checkers;
var $Mode;
var $OriginalMode = null;
var $GETName = 'sid';
var $CookiesEnabled = true;
var $CookieName = 'sid';
var $CookieDomain;
var $CookiePath;
var $CookieSecure = 0;
var $SessionTimeout = 3600;
var $Expiration;
var $SID;
/**
* Enter description here...
*
* @var SessionStorage
*/
var $Storage;
var $CachedNeedQueryString = null;
var $Data;
function Session($mode=smAUTO)
{
parent::kBase();
$this->SetMode($mode);
}
function SetMode($mode)
{
$this->Mode = $mode;
$this->CachedNeedQueryString = null;
$this->CachedSID = null;
}
function SetCookiePath($path)
{
$this->CookiePath = str_replace(' ', '%20', $path);
}
function SetCookieDomain($domain)
{
$this->CookieDomain = '.'.ltrim($domain, '.');
}
function SetGETName($get_name)
{
$this->GETName = $get_name;
}
function SetCookieName($cookie_name)
{
$this->CookieName = $cookie_name;
}
function InitStorage($special)
{
$this->Storage =& $this->Application->recallObject('SessionStorage.'.$special);
$this->Storage->setSessionTimeout($this->SessionTimeout);
}
function Init($prefix,$special)
{
parent::Init($prefix,$special);
$this->CheckIfCookiesAreOn();
if ($this->CookiesEnabled) $_COOKIE['cookies_on'] = 1;
$this->Checkers = Array();
$this->InitStorage($special);
$this->Data = new Params();
$tmp_sid = $this->GetPassedSIDValue();
$check = $this->Check();
if( !(defined('IS_INSTALL') && IS_INSTALL) )
{
$expired_sids = $this->DeleteExpired();
if ( ( $expired_sids && in_array($tmp_sid,$expired_sids) ) || ( $tmp_sid && !$check ) ) {
$this->SetSession();
$this->Application->HandleEvent($event, 'u:OnSessionExpire');
return ;
}
}
if ($check) {
$this->SID = $this->GetPassedSIDValue();
$this->Refresh();
$this->LoadData();
}
else {
$this->SetSession();
}
if (!is_null($this->OriginalMode)) $this->SetMode($this->OriginalMode);
}
function IsHTTPSRedirect()
{
$http_referer = getArrayValue($_SERVER, 'HTTP_REFERER');
return (
( PROTOCOL == 'https://' && preg_match('#http:\/\/#', $http_referer) )
||
( PROTOCOL == 'http://' && preg_match('#https:\/\/#', $http_referer) )
);
}
function CheckReferer($for_cookies=0)
{
if (!$for_cookies) {
if ( !$this->Application->ConfigValue('SessionReferrerCheck') || $_SERVER['REQUEST_METHOD'] != 'POST') {
return true;
}
}
$path = preg_replace('/admin[\/]{0,1}$/', '', $this->CookiePath); // removing /admin for compatability with in-portal (in-link/admin/add_link.php)
$reg = '#^'.preg_quote(PROTOCOL.ltrim($this->CookieDomain, '.').$path).'#';
return preg_match($reg, getArrayValue($_SERVER, 'HTTP_REFERER') ) || (defined('IS_POPUP') && IS_POPUP);
}
/*function CheckDuplicateCookies()
{
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookie_str = $_SERVER['HTTP_COOKIE'];
$cookies = explode('; ', $cookie_str);
$all_cookies = array();
foreach ($cookies as $cookie) {
list($name, $value) = explode('=', $cookie);
if (isset($all_cookies[$name])) {
//double cookie name!!!
$this->RemoveCookie($name);
}
else $all_cookies[$name] = $value;
}
}
}
function RemoveCookie($name)
{
$path = $_SERVER['PHP_SELF'];
$path_parts = explode('/', $path);
$cur_path = '';
setcookie($name, false, null, $cur_path);
foreach ($path_parts as $part) {
$cur_path .= $part;
setcookie($name, false, null, $cur_path);
$cur_path .= '/';
setcookie($name, false, null, $cur_path);
}
}*/
function CheckIfCookiesAreOn()
{
// $this->CheckDuplicateCookies();
if ($this->Mode == smGET_ONLY)
{
//we don't need to bother checking if we would not use it
$this->CookiesEnabled = false;
return;
}
$http_query =& $this->Application->recallObject('HTTPQuery');
$cookies_on = isset($http_query->Cookie['cookies_on']); // not good here
$get_sid = getArrayValue($http_query->Get, $this->GETName);
if ($this->IsHTTPSRedirect() && $get_sid) { //Redirect from http to https on different domain
$this->OriginalMode = $this->Mode;
$this->SetMode(smGET_ONLY);
}
if (!$cookies_on || $this->IsHTTPSRedirect()) {
//If referer is our server, but we don't have our cookies_on, it's definetly off
$is_install = defined('IS_INSTALL') && IS_INSTALL;
if (!$is_install && $this->CheckReferer(1) && !$this->Application->GetVar('admin') && !$this->IsHTTPSRedirect()) {
$this->CookiesEnabled = false;
}
else {
//Otherwise we still suppose cookies are on, because may be it's the first time user visits the site
//So we send cookies on to get it next time (when referal will tell us if they are realy off
$this->SetCookie('cookies_on', 1, adodb_mktime() + 31104000); //one year should be enough
}
}
else
$this->CookiesEnabled = true;
return $this->CookiesEnabled;
}
/**
* Sets cookie for current site using path and domain
*
* @param string $name
* @param mixed $value
* @param int $expires
*/
function SetCookie($name, $value, $expires = null)
{
setcookie($name, $value, $expires, $this->CookiePath, $this->CookieDomain, $this->CookieSecure);
}
function Check()
{
// we should check referer if cookies are disabled, and in combined mode
// auto mode would detect cookies, get only mode would turn it off - so we would get here
// and we don't care about referal in cookies only mode
if ( $this->Mode != smCOOKIES_ONLY && (!$this->CookiesEnabled || $this->Mode == smCOOKIES_AND_GET) ) {
if (!$this->CheckReferer())
return false;
}
$sid = $this->GetPassedSIDValue();
if (empty($sid)) return false;
//try to load session by sid, if everything is fine
$result = $this->LoadSession($sid);
return $result;
}
function LoadSession($sid)
{
if( $this->Storage->LocateSession($sid) ) {
//if we have session with such SID - get its expiration
$this->Expiration = $this->Storage->GetExpiration();
//If session has expired
if ($this->Expiration < adodb_mktime()) return false;
//Otherwise it's ok
return true;
}
else //fake or deleted due to expiration SID
return false;
}
function GetPassedSIDValue($use_cache = 1)
{
if (!empty($this->CachedSID) && $use_cache) return $this->CachedSID;
$http_query =& $this->Application->recallObject('HTTPQuery');
$get_sid = getArrayValue($http_query->Get, $this->GETName);
if ($this->Application->GetVar('admin') == 1 && $get_sid) {
$sid = $get_sid;
}
else {
switch ($this->Mode) {
case smAUTO:
//Cookies has the priority - we ignore everything else
$sid = $this->CookiesEnabled ? $this->GetSessionCookie() : $get_sid;
break;
case smCOOKIES_ONLY:
$sid = $this->GetSessionCookie();
break;
case smGET_ONLY:
$sid = $get_sid;
break;
case smCOOKIES_AND_GET:
$cookie_sid = $this->GetSessionCookie();
//both sids should match if cookies are enabled
if (!$this->CookiesEnabled || ($cookie_sid == $get_sid))
{
$sid = $get_sid; //we use get here just in case cookies are disabled
}
else
{
$sid = '';
}
break;
}
}
$this->CachedSID = $sid;
return $this->CachedSID;
}
/**
* Returns session id
*
* @return int
* @access public
*/
function GetID()
{
return $this->SID;
}
/**
* Generates new session id
*
* @return int
* @access private
*/
function GenerateSID()
{
list($usec, $sec) = explode(" ",microtime());
$sid_part_1 = substr($usec, 4, 4);
$sid_part_2 = mt_rand(1,9);
$sid_part_3 = substr($sec, 6, 4);
$digit_one = substr($sid_part_1, 0, 1);
if ($digit_one == 0) {
$digit_one = mt_rand(1,9);
$sid_part_1 = ereg_replace("^0","",$sid_part_1);
$sid_part_1=$digit_one.$sid_part_1;
}
$this->setSID($sid_part_1.$sid_part_2.$sid_part_3);
return $this->SID;
}
/**
* Set's new session id
*
* @param int $new_sid
* @access private
*/
function setSID($new_sid)
{
$this->SID=$new_sid;
$this->Application->SetVar($this->GETName,$new_sid);
}
function SetSession()
{
$this->GenerateSID();
$this->Expiration = adodb_mktime() + $this->SessionTimeout;
switch ($this->Mode) {
case smAUTO:
if ($this->CookiesEnabled) {
$this->SetSessionCookie();
}
break;
case smGET_ONLY:
break;
case smCOOKIES_ONLY:
case smCOOKIES_AND_GET:
$this->SetSessionCookie();
break;
}
$this->Storage->StoreSession($this);
if ($this->Application->IsAdmin() || $this->Special == 'admin') {
$this->StoreVar('admin', 1);
}
if ($this->Special != '') {
// front-session called from admin or otherwise, then save it's data
$this->SaveData();
}
$this->Application->resetCounters('UserSession');
}
/**
* Returns SID from cookie
*
* @return int
*/
function GetSessionCookie()
{
$keep_session_on_browser_close = $this->Application->ConfigValue('KeepSessionOnBrowserClose');
if (isset($this->Application->HttpQuery->Cookie[$this->CookieName]) &&
( $keep_session_on_browser_close ||
(
!$keep_session_on_browser_close &&
isset($this->Application->HttpQuery->Cookie[$this->CookieName.'_live'])
&&
$this->Application->HttpQuery->Cookie[$this->CookieName] == $this->Application->HttpQuery->Cookie[$this->CookieName.'_live']
)
)
) {
return $this->Application->HttpQuery->Cookie[$this->CookieName];
}
return false;
}
/**
* Updates SID in cookie with new value
*
*/
function SetSessionCookie()
{
$this->SetCookie($this->CookieName, $this->SID, $this->Expiration);
$this->SetCookie($this->CookieName.'_live', $this->SID);
$_COOKIE[$this->CookieName] = $this->SID; // for compatibility with in-portal
}
/**
* Refreshes session expiration time
*
* @access private
*/
function Refresh()
{
- if ($this->CookiesEnabled) $this->SetSessionCookie(); //we need to refresh the cookie
+ if ($this->Application->GetVar('skip_session_refresh')) {
+ return ;
+ }
+
+ if ($this->CookiesEnabled) {
+ // we need to refresh the cookie
+ $this->SetSessionCookie();
+ }
$this->Storage->UpdateSession($this);
}
function Destroy()
{
$this->Storage->DeleteSession($this);
$this->Data = new Params();
$this->SID = '';
if ($this->CookiesEnabled) $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
$this->SetSession(); //will create a new session
}
function NeedQueryString($use_cache = 1)
{
if ($this->CachedNeedQueryString != null && $use_cache) return $this->CachedNeedQueryString;
$result = false;
switch ($this->Mode)
{
case smAUTO:
if (!$this->CookiesEnabled) $result = true;
break;
/*case smCOOKIES_ONLY:
break;*/
case smGET_ONLY:
case smCOOKIES_AND_GET:
$result = true;
break;
}
$this->CachedNeedQueryString = $result;
return $result;
}
function LoadData()
{
$this->Data->AddParams($this->Storage->LoadData($this));
}
function PrintSession($comment='')
{
if($this->Application->isDebugMode() && constOn('DBG_SHOW_SESSIONDATA')) {
// dump session data
$this->Application->Debugger->appendHTML('SessionStorage ('.$comment.'):');
$session_data = $this->Data->GetParams();
ksort($session_data);
foreach ($session_data as $session_key => $session_value) {
if (IsSerialized($session_value)) {
$session_data[$session_key] = unserialize($session_value);
}
}
$this->Application->Debugger->dumpVars($session_data);
}
if ($this->Application->isDebugMode() && constOn('DBG_SHOW_PERSISTENTDATA')) {
// dump persistent session data
if ($this->Storage->PersistentVars) {
$this->Application->Debugger->appendHTML('Persistant Session:');
$session_data = $this->Storage->PersistentVars;
ksort($session_data);
foreach ($session_data as $session_key => $session_value) {
if (IsSerialized($session_value)) {
$session_data[$session_key] = unserialize($session_value);
}
}
$this->Application->Debugger->dumpVars($session_data);
}
}
}
function SaveData()
{
if (!$this->Application->GetVar('skip_last_template') && $this->Application->GetVar('ajax') != 'yes') {
$this->SaveLastTemplate( $this->Application->GetVar('t') );
}
$this->PrintSession('after save');
$this->Storage->SaveData($this);
}
function SaveLastTemplate($t)
{
// save last_template
$wid = $this->Application->GetVar('m_wid');
$last_env = $this->getLastTemplateENV($t, Array('m_opener' => 'u'));
$last_template = basename($_SERVER['PHP_SELF']).'|'.mb_substr($last_env, mb_strlen(ENV_VAR_NAME) + 1);
$this->StoreVar(rtrim('last_template_'.$wid, '_'), $last_template);
$last_env = $this->getLastTemplateENV($t, null, false);
$last_template = basename($_SERVER['PHP_SELF']).'|'.mb_substr($last_env, mb_strlen(ENV_VAR_NAME) + 1);
$this->StoreVar(rtrim('last_template_popup_'.$wid, '_'), $last_template);
// save other last... variables for mistical purposes (customizations may be)
$this->StoreVar('last_url', $_SERVER['REQUEST_URI']); // needed by ord:StoreContinueShoppingLink
$this->StoreVar('last_env', mb_substr($last_env, mb_strlen(ENV_VAR_NAME)+1));
// save last_template in persistant session
if (!$wid) {
if ($this->Application->IsAdmin()) {
// only for main window, not popups, not login template, not temp mode (used in adm:MainFrameLink tag)
$temp_mode = false;
$passed = explode(',', $this->Application->GetVar('passed'));
foreach ($passed as $passed_prefix) {
if ($this->Application->GetVar($passed_prefix.'_mode')) {
$temp_mode = true;
break;
}
}
if (!$temp_mode) {
if (isset($this->Application->HttpQuery->Get['section'])) {
// check directly in GET, bacause LinkVar (session -> request) used on these vars
$last_template .= '§ion='.$this->Application->GetVar('section').'&module='.$this->Application->GetVar('module');
}
$this->StorePersistentVar('last_template_popup', $last_template);
}
}
elseif ($this->Application->GetVar('admin') == 1) {
$admin_session =& $this->Application->recallObject('Session.admin');
/* @var $admin_ses Session */
$admin_session->StorePersistentVar('last_template_popup', '../'.$last_template);
}
}
}
function getLastTemplateENV($t, $params = null, $encode = true)
{
if (!isset($params)) {
$params = Array ();
}
$params['__URLENCODE__'] = 1; // uses "&" instead of "&" for url part concatenation + replaces "\" to "%5C" (works in HTML)
$ret = $this->Application->BuildEnv($t, $params, 'all');
if (!$encode) {
// cancels 2nd part of replacements, that URLENCODE does
$ret = str_replace('%5C', '\\', $ret);
}
return $ret;
}
function StoreVar($name, $value)
{
$this->Data->Set($name, $value);
}
function StorePersistentVar($name, $value)
{
$this->Storage->StorePersistentVar($this, $name, $value);
}
function LoadPersistentVars()
{
$this->Storage->LoadPersistentVars($this);
}
function StoreVarDefault($name, $value)
{
$tmp = $this->RecallVar($name);
if($tmp === false || $tmp == '')
{
$this->StoreVar($name, $value);
}
}
function RecallVar($name, $default = false)
{
$ret = $this->Data->Get($name);
return ($ret === false) ? $default : $ret;
}
function RecallPersistentVar($name, $default = false)
{
return $this->Storage->RecallPersistentVar($this, $name, $default);
}
function RemoveVar($name)
{
$this->Storage->RemoveFromData($this, $name);
$this->Data->Remove($name);
}
function RemovePersistentVar($name)
{
return $this->Storage->RemovePersistentVar($this, $name);
}
/**
* Ignores session varible value set before
*
* @param string $name
*/
function RestoreVar($name)
{
return $this->StoreVar($name, $this->Storage->GetFromData($this, $name));
}
function GetField($var_name, $default = false)
{
return $this->Storage->GetField($this, $var_name, $default);
}
function SetField($var_name, $value)
{
$this->Storage->SetField($this, $var_name, $value);
}
/**
* Deletes expired sessions
*
* @return Array expired sids if any
* @access private
*/
function DeleteExpired()
{
return $this->Storage->DeleteExpired();
}
/**
* Allows to check if user in this session is logged in or not
*
* @return bool
*/
function LoggedIn()
{
$user_id = $this->RecallVar('user_id');
$ret = $user_id > 0;
if ($this->RecallVar('admin') == 1 && ($user_id == -1)) {
$ret = true;
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: branches/RC/core/kernel/session/session.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.59.2.10
\ No newline at end of property
+1.59.2.11
\ No newline at end of property
Index: branches/RC/core/admin_templates/incs/grid_blocks.tpl
===================================================================
--- branches/RC/core/admin_templates/incs/grid_blocks.tpl (revision 10371)
+++ branches/RC/core/admin_templates/incs/grid_blocks.tpl (revision 10372)
@@ -1,502 +1,512 @@
<inp2:m_DefineElement name="current_page">
<span class="current_page"><inp2:m_param name="page"/></span>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="page">
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>, <inp2:m_param name="ajax"/>)" class="nav_url"><inp2:m_param name="page"/></a>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="next_page">
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>, <inp2:m_param name="ajax"/>)" class="nav_url">></a>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="prev_page">
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>, <inp2:m_param name="ajax"/>)" class="nav_url"><</a>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="next_page_split">
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>, <inp2:m_param name="ajax"/>)" class="nav_url">>></a>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="prev_page_split">
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>, <inp2:m_param name="ajax"/>)" class="nav_url"><<</a>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="search_main_toolbar">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_pagination" SearchPrefixSpecial="" ajax="0">
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="#E0E0DA" border="0" class="<inp2:m_if check="m_ParamEquals" name="no_toolbar" value="no_toolbar" >bordered<inp2:m_else/>pagination_bar</inp2:m_if>">
<tbody>
<tr id="MY_ID">
<td>
<img height="15" src="img/arrow.gif" width="15" align="absmiddle" border="0">
<b class=text><inp2:m_phrase name="la_Page"/></b>
<inp2:{$PrefixSpecial}_PrintPages active_block="current_page" split="10" inactive_block="page" prev_page_block="prev_page" next_page_block="next_page" prev_page_split_block="prev_page_split" next_page_split_block="next_page_split" main_special="$main_special" ajax="$ajax" grid="$grid"/>
</td>
<inp2:m_if check="m_ParamEquals" param="search" value="on">
<inp2:m_if check="m_ParamEquals" name="SearchPrefixSpecial" value="">
<inp2:m_RenderElement name="grid_search" grid="$grid" PrefixSpecial="$PrefixSpecial" ajax="$ajax"/>
<inp2:m_else />
<inp2:m_RenderElement name="grid_search" grid="$grid" PrefixSpecial="$SearchPrefixSpecial" ajax="$ajax"/>
</inp2:m_if>
</inp2:m_if>
<td>
</tr>
</tbody>
</table>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_pagination_elem" ajax="0">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_search" ajax="0">
<td align="right" class="search-cell">
<table cellspacing="0" cellpadding="0">
<tr>
<td><inp2:m_phrase name="la_Search"/>: </td>
<td>
<input type="text" id="<inp2:m_param name="PrefixSpecial"/>_search_keyword" name="<inp2:m_param name="PrefixSpecial"/>_search_keyword" value="<inp2:m_recall var="{$PrefixSpecial}_search_keyword" no_null="no_null" special="1"/>" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);" class="search-box"/>
<input type="text" style="display: none;"/>
</td>
<td style="white-space: nowrap;" id="search_buttons[<inp2:m_param name="PrefixSpecial"/>]">
<div style="white-space: nowrap;"></div>
<script type="text/javascript">
<inp2:m_RenderElement name="grid_search_buttons" pass_params="true"/>
</script>
</td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_search_buttons" PrefixSpecial="" grid="" ajax="1">
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'] = new ToolBar('icon16_');
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].IconSize = {w:22,h:22};
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].UseLabels = false;
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton(
new ToolBarButton(
'search',
'<inp2:m_phrase name="la_ToolTip_Search" escape="1"/>',
function() { search('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>) },
null,
'<inp2:m_param name="PrefixSpecial"/>') );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton(
new ToolBarButton(
'search_reset',
'<inp2:m_phrase name="la_ToolTip_SearchReset" escape="1"/>',
function() { search_reset('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>) },
null,
'<inp2:m_param name="PrefixSpecial"/>') );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].Render(document.getElementById('search_buttons[<inp2:m_param name="PrefixSpecial"/>]'));
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_column_title" use_phrases="1" ajax="0">
<td nowrap="nowrap">
<a href="javascript:resort_grid('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="sort_field"/>', <inp2:m_param name="ajax"/>);"><IMG alt="" src="img/list_arrow_<inp2:{$PrefixSpecial}_order field="$sort_field"/>.gif" border="0" align="absmiddle"><inp2:m_if check="m_ParamEquals" name="use_phrases" value="1"><inp2:m_phrase name="$title"/><inp2:m_else/><inp2:m_param name="title"/></inp2:m_if></a>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_column_title_no_sorting" use_phrases="1">
<td nowrap="nowrap">
<inp2:m_if check="m_ParamEquals" name="use_phrases" value="1"><inp2:m_phrase name="$title"/><inp2:m_else/><inp2:m_param name="title"/></inp2:m_if>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_checkbox_td" format="" module="" >
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath module="$module"/>img/itemicons/<inp2:{$PrefixSpecial}_ItemIcon grid="$grid"/>"></td>
<td><inp2:Field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_checkbox_td_no_icon" format="" >
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><inp2:{$PrefixSpecial}_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="label_grid_checkbox_td" format="" module="" >
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath module="$module"/>img/itemicons/<inp2:{$PrefixSpecial}_ItemIcon grid="$grid"/>"></td>
<td><inp2:{$PrefixSpecial}_field field="$field" no_special="no_special" as_label="as_label" format="$format"/></td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_icon_td" format="" module="" >
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><img src="<inp2:ModulePath module="$module"/>img/itemicons/<inp2:{$PrefixSpecial}_ItemIcon grid="$grid"/>"></td>
<td><inp2:{$PrefixSpecial}_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_radio_td" format="" module="">
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="radio" name="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:{$PrefixSpecial}_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath module="$module"/>img/itemicons/<inp2:{$PrefixSpecial}_ItemIcon grid="$grid"/>"></td>
<td><inp2:Field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_data_td" format="" no_special="" nl2br="" first_chars="" td_style="" currency="">
<td valign="top" class="text" style="<inp2:m_param name="td_style"/>"><inp2:{$PrefixSpecial}_field field="$field" first_chars="$first_chars" currency="$currency" nl2br="$nl2br" grid="$grid" no_special="$no_special" format="$format"/></td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_edit_td" format="" >
<td valign="top" class="text"><input type="text" id="<inp2:{$PrefixSpecial}_InputName field="$field"/>" name="<inp2:{$PrefixSpecial}_InputName field="$field"/>" value="<inp2:{$PrefixSpecial}_field field="$field" grid="$grid" format="$format"/>"></td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_options_td" format="">
<td valign="top" class="text">
<select name="<inp2:InputName field="$field"/>" id="<inp2:InputName field="$field"/>">
<inp2:m_if check="FieldOption" field="$field" option="use_phrases">
<inp2:PredefinedOptions field="$field" block="inp_option_phrase" selected="selected" has_empty="1" empty_value="0"/>
<inp2:m_else/>
<inp2:PredefinedOptions field="$field" block="inp_option_item" selected="selected" has_empty="1" empty_value="0"/>
</inp2:m_if>
</select>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_date_td" format="">
<td valign="top" class="text">
<input type="text" name="<inp2:InputName field="{$field}_date"/>" id="<inp2:InputName field="{$field}_date"/>" value="<inp2:Field field="{$field}_date" format="_regional_InputDateFormat"/>" size="<inp2:Format field="{$field}_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>core/admin_templates/img/calendar_icon.gif"> <span class="small">(<inp2:Format field="{$field}_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:InputName field="{$field}_date"/>", "<inp2:Format field="{$field}_date" input_format="1"/>");
</script>
<input type="hidden" name="<inp2:InputName field="{$field}_time"/>" id="<inp2:InputName field="{$field}_time" input_format="1"/>" value="">
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_data_label_td" >
<td valign="top" class="text"><inp2:{$PrefixSpecial}_field field="$field" grid="$grid" plus_or_as_label="1" no_special="no_special" format="$format"/></td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_data_label_ml_td" format="" >
<td valign="top" class="text">
<span class="<inp2:m_if check="{$SourcePrefix}_HasError" field="$virtual_field">error</inp2:m_if>">
<inp2:{$PrefixSpecial}_Field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/>
</span><inp2:m_if check="{$SourcePrefix}_IsRequired" field="$virtual_field"><span class="error"> *</span></inp2:m_if>:<br />
<inp2:m_if check="FieldEquals" field="$ElementTypeField" value="textarea">
<a href="javascript:PreSaveAndOpenTranslatorCV('<inp2:m_param name="SourcePrefix"/>,<inp2:m_param name="SourcePrefix"/>-cdata', '<inp2:m_param name="SourcePrefix"/>-cdata:cust_<inp2:Field name="CustomFieldId"/>', 'popups/translator', <inp2:$SourcePrefix_Field field="ResourceId"/>, 1);" title="<inp2:m_Phrase label="la_Translate" escape="1"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
<inp2:m_else/>
<a href="javascript:PreSaveAndOpenTranslatorCV('<inp2:m_param name="SourcePrefix"/>,<inp2:m_param name="SourcePrefix"/>-cdata', '<inp2:m_param name="SourcePrefix"/>-cdata:cust_<inp2:Field name="CustomFieldId"/>', 'popups/translator', <inp2:$SourcePrefix_Field field="ResourceId"/>);" title="<inp2:m_Phrase label="la_Translate" escape="1"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
</inp2:m_if>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_column_filter">
<td> </td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_options_filter" use_phrases="0">
<td>
<select <inp2:m_if check="SearchField" field="$filter_field" filter_type="options" grid="$grid">class="filter"</inp2:m_if> name="<inp2:SearchInputName field="$filter_field" filter_type="options" grid="$grid"/>">
<inp2:m_if check="m_ParamEquals" name="use_phrases" value="1" >
<inp2:PredefinedSearchOptions field="$filter_field" block="inp_option_phrase" selected="selected" has_empty="1" empty_value="" filter_type="options" grid="$grid"/>
<inp2:m_else/>
<inp2:PredefinedSearchOptions field="$filter_field" block="inp_option_item" selected="selected" has_empty="1" empty_value="" filter_type="options" grid="$grid"/>
</inp2:m_if>
</select>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_like_filter">
<td>
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="like" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="like" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="like" grid="$grid"/>" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_equals_filter">
<td>
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="equals" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="equals" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="equals" grid="$grid"/>" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_range_filter">
<td>
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="range" type="from" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="range" type="from" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="range" type="from" grid="$grid"/>" size="5" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="range" type="to" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="range" type="to" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="range" type="to" grid="$grid"/>" size="5" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_float_range_filter">
<td>
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="float_range" type="from" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="float_range" type="from" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="float_range" type="from" grid="$grid"/>" size="5" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="float_range" type="to" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="float_range" type="to" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="float_range" type="to" grid="$grid"/>" size="5" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_date_range_filter">
<td>
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="date_range" type="from" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="from" grid="$grid"/>" id="<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="from" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="date_range" type="from" grid="$grid"/>" size="15" datepickerIcon="img/calendar_icon.gif" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
<input type="text" class="flat-input<inp2:m_if check="SearchField" field="$filter_field" filter_type="date_range" type="to" grid="$grid"> filter</inp2:m_if>" name="<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="to" grid="$grid"/>" id="<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="to" grid="$grid"/>" value="<inp2:SearchField field="$filter_field" filter_type="date_range" type="to" grid="$grid"/>" size="15" datepickerIcon="img/calendar_icon.gif" onkeydown="search_keydown(event, '<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>);"/><br />
</td>
<script type="text/javascript">
initCalendar("<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="from" grid="$grid"/>", "<inp2:Format field="{$sort_field}_date" input_format="1"/>");
initCalendar("<inp2:SearchInputName field="$filter_field" filter_type="date_range" type="to" grid="$grid"/>", "<inp2:Format field="{$sort_field}_date" input_format="1"/>");
</script>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="viewmenu_sort_block">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="$title" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:m_param name="sort_field"/>","<inp2:{$PrefixSpecial}_OrderInfo type="direction" pos="1"/>", null, <inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_IsOrder" field="$sort_field" pos="1" >2</inp2:m_if>');
</inp2:m_DefineElement>
<inp2:m_DefineElement name="viewmenu_filter_block">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('<inp2:m_param name="label" js_escape="1"/>','<inp2:m_param name="filter_action"/>','<inp2:m_param name="filter_status"/>');
</inp2:m_DefineElement>
<inp2:m_DefineElement name="viewmenu_filter_separator">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
</inp2:m_DefineElement>
<inp2:m_DefineElement name="viewmenu_declaration" menu_filters="no" menu_sorting="yes" menu_perpage="yes" menu_select="yes" ajax="0">
// define ViewMenu
$fw_menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = function()
{
<inp2:m_if check="m_ParamEquals" name="menu_filters" value="yes">
// filtring menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] = new Menu('<inp2:m_phrase name="la_Text_View" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('All','filters_remove_all("<inp2:m_param name="PrefixSpecial"/>", <inp2:m_param name="ajax"/>);');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('None','filters_apply_all("<inp2:m_param name="PrefixSpecial"/>", <inp2:m_param name="ajax"/>);');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:{$PrefixSpecial}_DrawFilterMenu old_style="1" item_block="viewmenu_filter_block" spearator_block="viewmenu_filter_separator" ajax="$ajax"/>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_sorting" value="yes">
// sorting menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] = new Menu('<inp2:m_phrase name="la_Text_Sort" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_ascending" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:{$PrefixSpecial}_OrderInfo type="field" pos="1"/>","asc",null,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_IsOrder" direction="asc" pos="1" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_descending" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:{$PrefixSpecial}_OrderInfo type="field" pos="1"/>","desc",null,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_IsOrder" direction="desc" pos="1" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuSeparator();
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Default" escape="1"/>','reset_sorting("<inp2:m_param name="PrefixSpecial"/>");');
<inp2:{$PrefixSpecial}_IterateGridFields grid="$grid" mode="header" block="viewmenu_sort_block" ajax="$ajax"/>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_perpage" value="yes">
// per page menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] = new Menu('<inp2:m_phrase name="la_prompt_PerPage" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('10','set_per_page("<inp2:m_param name="PrefixSpecial"/>",10,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_PerPageEquals" value="10" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('20','set_per_page("<inp2:m_param name="PrefixSpecial"/>",20,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_PerPageEquals" value="20" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('50','set_per_page("<inp2:m_param name="PrefixSpecial"/>",50,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_PerPageEquals" value="50" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('100','set_per_page("<inp2:m_param name="PrefixSpecial"/>",100,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_PerPageEquals" value="100" >2</inp2:m_if>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('500','set_per_page("<inp2:m_param name="PrefixSpecial"/>",500,<inp2:m_param name="ajax"/>);','<inp2:m_if check="{$PrefixSpecial}_PerPageEquals" value="500" >2</inp2:m_if>');
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_select" value="yes">
// select menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] = new Menu('<inp2:m_phrase name="la_Text_Select" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_All" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].SelectAll();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Unselect" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].ClearSelection();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Invert" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].InvertSelection();');
</inp2:m_if>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = new Menu('<inp2:{$PrefixSpecial}_GetItemName/>');
<inp2:m_if check="m_ParamEquals" name="menu_filters" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_sorting" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_perpage" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_select" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] );
</inp2:m_if>
}
</inp2:m_DefineElement>
<inp2:m_include template="incs/menu_blocks"/>
<inp2:m_DefineElement name="grid_save_warning" >
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if check="m_ParamEquals" name="no_toolbar" value="no_toolbar" >nobottom<inp2:m_else/>notop</inp2:m_if>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Save_Item"/>
</td>
</tr>
</table>
<script type="text/javascript">
$edit_mode = <inp2:m_if check="m_ParamEquals" name="edit_mode" value="1">true<inp2:m_else />false</inp2:m_if>;
// window.parent.document.title += ' - MODE: ' + ($edit_mode ? 'EDIT' : 'LIVE');
</script>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid" main_prefix="" per_page="" main_special="" no_toolbar="" grid_filters="" search="on" header_block="grid_column_title" filter_block="grid_column_filter" data_block="grid_data_td" totals_block="grid_total_td" row_block="_row" ajax="0" totals="0">
<!--
grid_filters - show individual filters for each column
has_filters - draw filter section in "View" menu in toolbar
-->
<inp2:InitList pass_params="1"/> <!-- this is to avoid recalling prefix as an item in first iterate grid, by col-picker for instance -->
<inp2:{$PrefixSpecial}_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if check="m_RecallEquals" var="{$PrefixSpecial}_search_keyword" value="" inverse="inverse">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if check="m_ParamEquals" name="no_toolbar" value="no_toolbar" >nobottom<inp2:m_else/>notop</inp2:m_if>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Filter"/>
</td>
</tr>
</table>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="per_page" value="-1" inverse="1">
<inp2:m_RenderElement name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" main_special="$main_special" search="$search" no_toolbar="$no_toolbar" ajax="$ajax"/>
</inp2:m_if>
<table width="100%" cellspacing="0" cellpadding="4" class="bordered">
<inp2:m_if check="m_ParamEquals" name="grid_filters" value="1">
<tr class="pagination_bar">
<inp2:{$PrefixSpecial}_IterateGridFields grid="$grid" mode="filter" block="$filter_block" ajax="$ajax"/>
</tr>
</inp2:m_if>
<tr class="subsectiontitle">
<inp2:{$PrefixSpecial}_IterateGridFields grid="$grid" mode="header" block="$header_block" ajax="$ajax"/>
</tr>
<inp2:m_DefineElement name="_row" td_style="">
<tr class="<inp2:m_odd_even odd="table-color1" even="table-color2"/>" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:Field field="$IdField"/>" sequence="<inp2:m_get param="{$PrefixSpecial}_sequence"/>"><inp2:m_inc param="{$PrefixSpecial}_sequence" by="1"/>
<inp2:IterateGridFields grid="$grid" mode="data" block="$data_block"/>
</tr>
</inp2:m_DefineElement>
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table-color1"/>
<inp2:{$PrefixSpecial}_PrintList block="$row_block" per_page="$per_page" main_special="$main_special" />
<inp2:m_DefineElement name="grid_total_td">
<inp2:m_if check="m_Param" name="total">
<td style="<inp2:m_param name="td_style"/>">
<inp2:FieldTotal name="$field" function="$total"/>
</td>
<inp2:m_else/>
<td style="<inp2:m_param name="td_style"/>"> </td>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_if check="m_ParamEquals" name="totals" value="1">
<tr class="totals-row"/>
<inp2:IterateGridFields grid="$grid" mode="data" block="$totals_block"/>
</tr>
</inp2:m_if>
</table>
<inp2:m_if check="m_ParamEquals" name="ajax" value="0">
<inp2:m_if check="m_GetEquals" name="fw_menu_included" value="">
<script type="text/javascript" src="incs/fw_menu.js"></script>
<link rel="stylesheet" rev="stylesheet" href="incs/nlsmenu.css" type="text/css" />
<script type="text/javascript" src="js/nlsmenu.js"></script>
<script type="text/javascript" src="js/nlsmenueffect_1_2_1.js"></script>
<script type="text/javascript">
var menuMgr = new NlsMenuManager("mgr");
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
</script>
<inp2:m_set fw_menu_included="1"/>
</inp2:m_if>
<script type="text/javascript">
<inp2:m_RenderElement name="grid_js" selected_class="selected_div" tag_name="tr" pass_params="true"/>
</script>
</inp2:m_if>
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1" name="<inp2:m_param name="PrefixSpecial"/>_Sort1" value="">
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" name="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" value="asc">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_js" view_menu="1" ajax="1">
<inp2:m_if check="m_ParamEquals" name="no_init" value="no_init" inverse="inverse">
Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="selected_class"/>', ':original', edit, a_toolbar);
Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('<inp2:m_param name="tag_name"/>', /^<inp2:m_param name="PrefixSpecial"/>_([\d\w-]+)/, '<inp2:m_param name="PrefixSpecial"/>[$$ID$$][<inp2:m_param name="IdField"/>]');
Grids['<inp2:m_param name="PrefixSpecial"/>'].InitItems();
<inp2:m_if check="{$PrefixSpecial}_UseAutoRefresh">
- setTimeout('window.location.reload();', <inp2:$PrefixSpecial_AutoRefreshInterval/> * 60000);
+ function refresh_grid() {
+ // window.location.reload();
+ var $window_url = window.location.href;
+ if ($window_url.indexOf('skip_session_refresh=1') == -1) {
+ $window_url += '&skip_session_refresh=1';
+ }
+
+ window.location.href = $window_url;
+ }
+
+ setTimeout('refresh_grid()', <inp2:$PrefixSpecial_AutoRefreshInterval/> * 60000);
</inp2:m_if>
</inp2:m_if>
<inp2:m_if check="m_Param" name="view_menu">
<inp2:m_RenderElement name="nlsmenu_declaration" pass_params="true"/>
$ViewMenus = new Array('<inp2:m_param name="PrefixSpecial"/>');
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="white_grid" main_prefix="" per_page="" main_special="" no_toolbar="" search="on" render_as="" columns="2" direction="V" empty_cell_render_as="wg_empty_cell" ajax="0">
<inp2:{$PrefixSpecial}_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if check="m_RecallEquals" var="{$PrefixSpecial}_search_keyword" value="" inverse="inverse">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if check="m_ParamEquals" name="no_toolbar" value="no_toolbar" >nobottom<inp2:m_else/>notop</inp2:m_if>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Filter"/>
</td>
</tr>
</table>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="per_page" value="-1" inverse="1">
<inp2:m_RenderElement name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" main_special="$main_special" search="$search" no_toolbar="$no_toolbar" ajax="$ajax"/>
</inp2:m_if>
<br />
<inp2:m_DefineElement name="wg_empty_cell">
<td width="<inp2:m_param name="column_width"/>%"> </td>
</inp2:m_DefineElement>
<table width="100%" border="0" cellspacing="2" cellpadding="4">
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table-color1"/>
<inp2:{$PrefixSpecial}_PrintList2 pass_params="true"/>
</table>
<inp2:m_if check="m_ParamEquals" name="ajax" value="0">
<inp2:m_if check="m_GetEquals" name="fw_menu_included" value="">
<script type="text/javascript" src="incs/fw_menu.js"></script>
<link rel="stylesheet" rev="stylesheet" href="incs/nlsmenu.css" type="text/css" />
<script type="text/javascript" src="js/nlsmenu.js"></script>
<script type="text/javascript" src="js/nlsmenueffect_1_2_1.js"></script>
<script type="text/javascript">
var menuMgr = new NlsMenuManager("mgr");
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
</script>
<inp2:m_set fw_menu_included="1"/>
</inp2:m_if>
<script type="text/javascript">
<inp2:m_RenderElement name="grid_js" selected_class="table_white_selected" tag_name="td" pass_params="true"/>
</script>
</inp2:m_if>
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1" name="<inp2:m_param name="PrefixSpecial"/>_Sort1" value="">
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" name="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" value="asc">
</inp2:m_DefineElement>
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/incs/grid_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.9.2.5
\ No newline at end of property
+1.9.2.6
\ No newline at end of property
Event Timeline
Log In to Comment