Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Jul 7, 5:51 AM

in-portal

Index: trunk/kernel/include/itemdb.php
===================================================================
--- trunk/kernel/include/itemdb.php (revision 871)
+++ trunk/kernel/include/itemdb.php (revision 872)
@@ -1,591 +1,591 @@
<?php
define('FT_OPTION', 1); // option formatter
class clsItemDB
{
var $Formatters = Array(); // by Alex
var $m_dirtyFieldsMap = array();
var $Data = array();
var $adodbConnection;
var $tablename;
var $BasePermission;
var $id_field;
var $NoResourceId;
var $debuglevel;
var $SelectSQL = 'SELECT * FROM %s WHERE %s';
function clsItemDB()
{
$this->adodbConnection = &GetADODBConnection();
$this->tablename="";
$this->NoResourceId=0;
$this->debuglevel=0;
}
// ============================================================================================
function GetFormatter($field)
{
return $this->HasFormatter($field) ? $this->Formatters[$field] : false;
}
function SetFormatter($field, $type, $params)
{
// by Alex
// all params after 2nd are formmater type specific
$this->Formatters[$field]['type'] = $type;
switch($type)
{
case FT_OPTION:
$this->Formatters[$field]['options'] = $params;
break;
}
}
/*
function FormatFields()
{
// format item in list data before printing
foreach($this->Formatters as $field => $formatter)
$this->Data[$field] = $this->FormatField($field);
}
*/
function FormatField($field)
{
// formats single field if it has formatter
if( $this->HasFormatter($field) )
{
$fmt = $this->Formatters[$field];
switch($fmt['type'])
{
case FT_OPTION:
return $fmt['options'][ $this->Data[$field] ];
break;
}
}
else
return $this->Get($field);
}
function HasFormatter($field)
{
// checks if formatter is set for field
return isset($this->Formatters[$field]) ? 1 : 0;
}
// ============================================================================================
function UnsetIdField()
{
$f = $this->IdField();
unset($this->Data[$f]);
unset($this->m_dirtyFieldsMap[$f]);
}
function UnsetField($field)
{
unset($this->Data[$field]);
unset($this->m_dirtyFieldsMap[$field]);
}
function IdField()
{
if(!strlen($this->id_field))
{
return $this->tablename."Id";
}
else
return $this->id_field;
}
function UniqueId()
{
return $this->Get($this->IdField());
}
function SetUniqueId($value)
{
$var = $this->IdField();
$this->Set($var, $value);
}
function SetModified($UserId=NULL)
{
global $objSession;
$keys = array_keys($this->Data);
if(in_array("Modified",$keys))
{
$this->Set("Modified",adodb_date("U"));
}
if(in_array("ModifiedById",$keys))
{
if(!$UserId)
$UserId = $objSession->Get("PortalUserId");
$this->Set("ModifiedById",$UserId);
}
}
function PrintVars()
{
echo '<pre>'.print_r($this->Data, true).'</pre>';
}
// =================================================================
function GetFormatted($name)
{
// get formatted field value
return $this->FormatField($name);
}
function Get($name)
{
// get un-formatted field value
//if( !isset($this->Data[$name]) ) print_pre( debug_backtrace() );
return $this->HasField($name) ? $this->Data[$name] : '';
}
// =================================================================
function HasField($name)
{
// checks if field exists in item
return isset($this->Data[$name]) ? 1 : 0;
}
function Set($name, $value)
{
//echo "Setting Field <b>$name</b>: = [$value]<br>";
if( is_array($name) )
{
for ($i=0; $i < sizeof($name); $i++)
{
$var = "m_" . $name[$i];
if( !$this->HasField($name[$i]) || ($this->Data[$name[$i]] != $value[$i]))
{
- if ($_GET['new'] != 1) {
+ if( !(isset($_GET['new']) && $_GET['new']) ) {
$this->DetectChanges($name[$i], $value[$value]);
}
$this->Data[$name[$i]] = $value[$i];
$this->m_dirtyFieldsMap[$name[$i]] = $value[$i];
}
}
}
else
{
$var = "m_" . $name;
if( !$this->HasField($name) || $this->Data[$name] != $value )
{
- if ($_GET['new'] != 1) {
+ if( !(isset($_GET['new']) && $_GET['new']) ) {
$this->DetectChanges($name, $value);
}
$this->Data[$name] = $value;
$this->m_dirtyFieldsMap[$name] = $value;
}
}
}
function Dirty($list=NULL)
{
if($list==NULL)
{
foreach($this->Data as $field => $value)
{
$this->m_dirtyFieldsMap[$field] = $value;
}
}
else
{
foreach($list as $field)
{
$this->m_dirtyFieldsMap[$field] = $this->Data[$field];
}
}
}
function Clean($list=NULL)
{
if($list == NULL)
{
unset($this->m_dirtyFieldsMap);
$this->m_dirtyFieldsMap=array();
}
else
{
foreach($list as $value)
{
$varname = "m_" . $value;
unset($this->m_dirtyFieldsMap[$value]);
}
}
}
function SetDebugLevel($value)
{
$this->debuglevel = $value;
}
function SetFromArray($data, $dirty = false)
{
if(is_array($data))
{
$this->Data = $data;
if($dirty) $this->m_dirtyFieldsMap = $data;
}
}
function GetData()
{
return $this->Data;
}
function SetData($data, $dirty = false)
{
$this->SetFromArray($data, $dirty);
}
function Delete()
{
global $Errors;
if($this->Get($this->IdField())==0)
{
$Errors->AddError("error.AppError",NULL,'Internal error: Delete requires set id',"",get_class($this),"Delete");
return false;
}
$sql = sprintf('DELETE FROM %s WHERE %s = %s', $this->tablename, $this->IdField(),
$this->UniqueId());
if($this->debuglevel>0)
echo $sql."<br>";
if ($this->adodbConnection->Execute($sql) === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Delete");
return false;
}
return true;
}
function Update($UpdatedBy=NULL)
{
global $Errors, $objSession;
if(count($this->m_dirtyFieldsMap) == 0)
return true;
$this->SetModified($UpdatedBy);
$sql = "UPDATE ".$this->tablename ." SET ";
$first = 1;
foreach ($this->m_dirtyFieldsMap as $key => $value)
{
if(!is_numeric($key) && $key != $this->IdField() && $key!='ResourceId')
{
if($first)
{
if(isset($GLOBALS['_CopyFromEditTable']))
$sql = sprintf("%s %s=%s",$sql,$key,$this->adodbConnection->qstr(($value)));
else
$sql = sprintf("%s %s=%s",$sql,$key,$this->adodbConnection->qstr(stripslashes($value)));
$first = 0;
}
else
{
if(isset($GLOBALS['_CopyFromEditTable']))
$sql = sprintf("%s, %s=%s",$sql,$key,$this->adodbConnection->qstr(($value)));
else
$sql = sprintf("%s, %s=%s",$sql,$key,$this->adodbConnection->qstr(stripslashes($value)));
}
}
}
$sql = sprintf("%s WHERE %s = '%s'",$sql, $this->IdField(), $this->UniqueId());
if($this->debuglevel>0)
echo $sql."<br>";
if ($this->adodbConnection->Execute($sql) === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Update");
return false;
}
if ($objSession->GetVariable("HasChanges") == 2) {
$objSession->SetVariable("HasChanges", 1);
}
/* if ($this->adodbConnection->Affected_Rows() > 0) {
$objSession->SetVariable("HasChanges", 1);
}*/
return true;
}
function ReplaceID($new_id)
{
// replace item's id, because Update method
// is too dummy to do this autommatically
// USED in temporary table editing stuff
$db =& $this->adodbConnection;
$sql = "UPDATE %1\$s SET `%2\$s` = %3\$s WHERE `%2\$s` = %4\$s";
$sql = sprintf($sql, $this->tablename, $this->IdField(), $new_id, (int)$this->UniqueId() );
if($this->debuglevel > 0) echo $sql.'<br>';
$db->Execute($sql);
}
function CreateSQL()
{
global $Errors;
$sql = "INSERT IGNORE INTO ".$this->tablename." (";
$first = 1;
foreach ($this->Data as $key => $value)
{
if($first)
{
$sql = sprintf("%s %s",$sql,$key);
$first = 0;
}
else
{
$sql = sprintf("%s, %s",$sql,$key);
}
}
$sql = sprintf('%s ) VALUES (',$sql);
$first = 1;
foreach ($this->Data as $key => $value)
{
if( is_array($value) )
{
global $debugger;
$debugger->dumpVars($value);
$debugger->appendTrace();
trigger_error('Value of array type not allowed in method <b>CreateSQL</b> of <b>clsItemDB</b> class', E_USER_ERROR);
}
if($first)
{
if(isset($GLOBALS['_CopyFromEditTable']))
$sql = sprintf("%s %s",$sql,$this->adodbConnection->qstr(($value)));
else
$sql = sprintf("%s %s",$sql,$this->adodbConnection->qstr(stripslashes($value)));
$first = 0;
}
else
{
if(isset($GLOBALS['_CopyFromEditTable']))
$sql = sprintf("%s, %s",$sql,$this->adodbConnection->qstr(($value)));
else
$sql = sprintf("%s, %s",$sql,$this->adodbConnection->qstr(stripslashes($value)));
}
}
$sql = sprintf('%s)',$sql);
return $sql;
}
function DetectChanges($name, $value)
{
global $objSession;
//print_pre($_POST);
//echo "$name: $value<br>";
if ($this->Data[$name] != $value && !strstr($name, 'Modif') && !strstr($name, 'Created')) {
//echo "$name Modified tt ".$this->Data[$name]." tt $value<br>";
if (!strstr($name, 'Hot') && !strstr($name, 'Pop') && !strstr($name, "Id") && !strstr($name, "ItemType")) {
if ($objSession->GetVariable("HasChanges") != 1) {
$objSession->SetVariable("HasChanges", 2);
}
}
}
}
function Create()
{
global $Errors, $objSession;
if($this->debuglevel) echo "Creating Item: ".get_class($this)."<br>";
if($this->NoResourceId!=1 && (int)$this->Get("ResourceId")==0)
{
$this->Set("ResourceId", GetNextResourceId());
}
$sql = $this->CreateSql();
if($this->debuglevel>0)
echo $sql."<br>\n";
if ($this->adodbConnection->Execute($sql) === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Create");
return false;
}
$this->SetUniqueId($this->adodbConnection->Insert_ID());
if ($objSession->GetVariable("HasChanges") == 2) {
$objSession->SetVariable("HasChanges", 1);
}
/*if ($this->adodbConnection->Affected_Rows() > 0) {
$objSession->SetVariable("HasChanges", 1);
} */
return true;
}
function Increment($field)
{
global $Errors;
$sql = "Update ".$this->tablename." set $field=$field+1 where ".$this->IdField()."=" . $this->UniqueId();
if($this->debuglevel>0)
echo $sql."<br>";
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Increment");
return false;
}
$this->Set($field,$this->Get($field)+1);
}
function Decrement($field)
{
global $Errors;
$sql = "Update ".$this->tablename." set $field=$field-1 where ".$this->IdField()."=" . $this->UniqueId();
if($this->debuglevel>0)
echo $sql;
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Decrement");
return false;
}
$this->Set($field,$this->Get($field)-1);
}
function GetFieldList($UseLoadedData=FALSE)
{
if(count($this->Data) && $UseLoadedData==TRUE)
{
$res = array_keys($this->Data);
}
else
{
$res = $this->adodbConnection->MetaColumnNames($this->tablename);
}
return $res;
}
function UsingTempTable()
{
global $objSession;
$temp = $objSession->GetEditTable($this->tablename);
$p = GetTablePrefix()."ses";
$t = substr($temp,0,strlen($p));
$ThisTable = substr($this->tablename,0,strlen($p));
if($t==$ThisTable)
{
return TRUE;
}
else
return FALSE;
}
function LoadFromDatabase($Id, $IdField = null) // custom IdField by Alex
{
global $objSession,$Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
// --------- multiple ids allowed: begin -----------------
$id_field = isset($IdField) ? $IdField : $this->IdField();
if( !is_array($id_field) ) $id_field = Array($id_field);
if( !is_array($Id) ) $Id = Array($Id);
$i = 0; $id_count = count($id_field);
$conditions = Array();
while($i < $id_count)
{
$conditions[] = "(`".$id_field[$i]."` = '".$Id[$i]."')";
$i++;
}
$sql = sprintf($this->SelectSQL, $this->tablename, implode(' AND ', $conditions) );
// --------- multiple ids allowed: end --------------------
if($this->debuglevel) echo "Load SQL: $sql<br>";
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
if($this->debuglevel) print_pre($data);
if(is_array($data))
$this->SetFromArray($data);
$this->Clean();
return TRUE;
}
function FieldExists($field)
{
$res = array_key_exists($field,$this->Data);
return $res;
}
function ValueExists($Field,$Value)
{
$sql = "SELECT $Field FROM ".$this->tablename." WHERE $Field='$Value'";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
return TRUE;
}
else
return FALSE;
}
function FieldMax($Field)
{
$sql = "SELECT Max($Field) as m FROM ".$this->tablename;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$ret = $rs->fields["m"];
}
else
$ret = 0;
}
function FieldMin($Field)
{
$sql = "SELECT Min($Field) as m FROM ".$this->tablename;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$ret = $rs->fields["m"];
}
else
$ret = 0;
}
function TableExists($table = null)
{
// checks if table specified in item exists in db
$db =& $this->adodbConnection;
$sql = "SHOW TABLES LIKE '%s'";
if($table == null) $table = $this->tablename;
$rs = $db->Execute( sprintf($sql, $table) );
if( $rs->RecordCount() == 1 ) // table exists in normal case
return 1;
else // check if table exists in lowercase
$rs = $db->Execute( sprintf($sql, strtolower($table) ) );
return ($rs->RecordCount() == 1) ? 1 : 0;
}
}
?>
Property changes on: trunk/kernel/include/itemdb.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.17
\ No newline at end of property
+1.18
\ No newline at end of property
Index: trunk/kernel/include/debugger.php
===================================================================
--- trunk/kernel/include/debugger.php (revision 871)
+++ trunk/kernel/include/debugger.php (revision 872)
@@ -1,490 +1,490 @@
<?php
if(!defined('DBG_USE_HIGHLIGHT')) define('DBG_USE_HIGHLIGHT',1);
if(!defined('DBG_USE_SHUTDOWN_FUNC')) define('DBG_USE_SHUTDOWN_FUNC',1);
- if(!defined('DBG_HANDLE_ERRORS')) define('DBG_HANDLE_ERRORS',1);
+ if(!defined('DBG_HANDLE_ERRORS')) define('DBG_HANDLE_ERRORS', isset($_REQUEST['debug_host']) ? 0 : 1);
class Debugger
{
/**
* Debugger data for building report
*
* @var Array
*/
var $Data = Array();
var $ProfilerData = Array();
var $RecursionStack = Array(); // prevent recursion when processing debug_backtrace() function results
function dumpVars()
{
$dumpVars = func_get_args();
foreach($dumpVars as $varValue)
{
$this->Data[] = Array('value' => $varValue, 'debug_type' => 'var_dump');
}
}
function prepareHTML($dataIndex)
{
$Data =& $this->Data[$dataIndex];
if($Data['debug_type'] == 'html') return $Data['html'];
switch($Data['debug_type'])
{
case 'error':
$fileLink = $this->getFileLink($Data['file'],$Data['line']);
$ret = '<b class="debug_error">'.$this->getErrorNameByCode($Data['no']).'</b>: '.$Data['str'];
$ret .= ' in <b>'.$fileLink.'</b> on line <b>'.$Data['line'].'</b>';
return $ret;
break;
case 'var_dump':
$ret = highlight_string('<?php '.print_r($Data['value'], true).'?>', true);
$ret = preg_replace('/&lt;\?php (.*)\?&gt;/s','$1',$ret);
return addslashes($ret);
break;
case 'trace':
$trace =& $Data['trace'];
$i = 0; $traceCount = count($trace);
$ret = '';
while($i < $traceCount)
{
$traceRec =& $trace[$i];
$argsID = 'trace_args_'.$dataIndex.'_'.$i;
$ret .= '<a href="javascript:toggleTraceArgs(\''.$argsID.'\');" title="Show/Hide Function Arguments"><b>Function</b></a>: '.$this->getFileLink($traceRec['file'],$traceRec['line'],$traceRec['class'].$traceRec['type'].$traceRec['function']).'';
$ret .= ' in <b>'.basename($traceRec['file']).'</b> on line <b>'.$traceRec['line'].'</b><br>';
// ensure parameter value is not longer then 200 symbols
$this->processTraceArguments($traceRec['args']);
$args = $this->highlightString(print_r($traceRec['args'], true));
$ret .= '<div id="'.$argsID.'" style="display: none;">'.$args.'</div>';
$i++;
}
return $ret;
break;
case 'profiler':
$profileKey = $Data['profile_key'];
$Data =& $this->ProfilerData[$profileKey];
$runtime = ($Data['ends'] - $Data['begins']); // in seconds
return '<b>Name</b>: '.$Data['description'].'<br><b>Runtime</b>: '.$runtime.'s';
break;
default:
return 'incorrect debug data';
break;
}
}
function processTraceArguments(&$traceArgs)
{
foreach ($traceArgs as $argID => $argValue)
{
if( is_array($argValue) || is_object($argValue) )
{
if(is_object($argValue) && !in_array(get_class($argValue),$this->RecursionStack) )
{
// object & not in stack - ok
array_push($this->RecursionStack, get_class($argValue));
settype($argValue,'array');
$this->processTraceArguments($argValue);
array_pop($this->RecursionStack);
}
elseif(is_object($argValue) && in_array(get_class($argValue),$this->RecursionStack) )
{
// object & in stack - recursion
$traceArgs[$argID] = '**** RECURSION ***';
}
else
{
// normal array here
$this->processTraceArguments($argValue);
}
}
else
{
$traceArgs[$argID] = $this->cutStringForHTML($traceArgs[$argID]);
}
}
}
function cutStringForHTML($string)
{
if( strlen($string) > 200 ) $string = substr($string,0,50).' ...';
return $string;
}
/**
* Format SQL Query using predefined formatting
* and highlighting techniques
*
* @param string $sql
* @return string
*/
function formatSQL($sql)
{
$sql = preg_replace('/(\n|\t| )+/is',' ',$sql);
$sql = preg_replace('/(SELECT|UPDATE|REPLACE|INSERT|DELETE|VALUES|FROM|LEFT JOIN|WHERE|HAVING|GROUP BY|ORDER BY) /is', "\n\t$1 ",$sql);
return $this->highlightString($sql);
}
function highlightString($string)
{
if( defined('DBG_USE_HIGHLIGHT')&&DBG_USE_HIGHLIGHT )
{
$string = highlight_string('<?php '.$string.'?>', true);
return preg_replace('/&lt;\?(.*)php (.*)\?&gt;/s','$2',$string);
}
else
{
return $string;
}
}
function getFileLink($file, $lineno = 1, $title = '')
{
if(!$title) $title = $file;
return '<a href="javascript:editFile(\''.$this->getLocalFile($file).'\','.$lineno.');" title="'.$file.'">'.$title.'</a>';
}
function getLocalFile($remoteFile)
{
return str_replace(DOC_ROOT, WINDOWS_ROOT, $remoteFile);
}
function appendTrace()
{
$trace = debug_backtrace();
array_shift($trace);
$this->Data[] = Array('trace' => $trace, 'debug_type' => 'trace');
}
function appendHTML($html)
{
$this->Data[] = Array('html' => $html,'debug_type' => 'html');
}
function profileStart($key, $description)
{
$timeStamp = $this->getMoment();
$this->ProfilerData[$key] = Array('begins' => $timeStamp, 'ends' => 5000, 'debuggerRowID' => count($this->Data), 'description' => $description);
$this->Data[] = array('profile_key' => $key, 'debug_type' => 'profiler');
}
function profileFinish($key)
{
$this->ProfilerData[$key]['ends'] = $this->getMoment();
}
function getMoment()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function generateID()
{
list($usec, $sec) = explode(" ",microtime());
$id_part_1 = substr($usec, 4, 4);
$id_part_2 = mt_rand(1,9);
$id_part_3 = substr($sec, 6, 4);
$digit_one = substr($id_part_1, 0, 1);
if ($digit_one == 0) {
$digit_one = mt_rand(1,9);
$id_part_1 = ereg_replace("^0","",$id_part_1);
$id_part_1=$digit_one.$id_part_1;
}
return $id_part_1.$id_part_2.$id_part_3;
}
function getErrorNameByCode($errorCode)
{
switch($errorCode)
{
case E_USER_ERROR:
return 'Fatal Error';
break;
case E_WARNING:
case E_USER_WARNING:
return 'Warning';
break;
case E_NOTICE:
case E_USER_NOTICE:
return 'Notice';
break;
default:
return '';
break;
}
}
/**
* Generates report
*
*/
function printReport()
{
$i = 0; $lineCount = count($this->Data);
?>
<style type="text/css">
.flat_table TD {
border: 1px solid buttonface;
border-width: 1 1 0 0;
}
.debug_layer_table {
border: 1px solid red;
border-width: 0 0 1 1;
width: 480px;
}
.debug_text, .debug_row_even TD, .debug_row_odd TD {
color: #000000;
font-family: Verdana;
font-size: 11px;
word-wrap: break-word;
}
.debug_cell {
border: 1px solid red;
border-width: 1 1 0 0;
word-wrap: break-word;
}
.debug_row_even {
background-color: #CCCCFF;
}
.debug_row_odd {
background-color: #FFFFCC;
}
.debug_layer_container {
left: 2px;
top: 1px;
width: 500px;
z-index: +1000;
position: absolute;
overflow: auto;
border: 2px solid;
padding: 3px;
border-top-color: threedlightshadow;
border-left-color: threedlightshadow;
border-right-color: threeddarkshadow;
border-bottom-color: threeddarkshadow;
background-color: buttonface;
}
.debug_layer {
padding: 0px;
width: 480px;
}
.debug_error {
color: #FF0000;
}
</style>
<div id="debug_layer" class="debug_layer_container" style="display: none;">
<div class="debug_layer">
<table width="100%" cellpadding="0" cellspacing="1" border="0" class="debug_layer_table">
<?php
while ($i < $lineCount)
{
echo '<tr class="debug_row_'.(($i % 2) ? 'odd' : 'even').'"><td class="debug_cell">'.$this->prepareHTML($i).'</td></tr>';
$i++;
}
?>
</table>
</div>
</div>
<script language="javascript">
function getEventKeyCode($e)
{
var $KeyCode = 0;
if($e.keyCode) $KeyCode = $e.keyCode;
else if($e.which) $KeyCode = $e.which;
return $KeyCode;
}
function keyProcessor($e)
{
if(!$e) $e = window.event;
var $KeyCode = getEventKeyCode($e);
//alert(showProps($e));
if($KeyCode == 123 || $KeyCode == 68 && $e.shiftKey) // F12 (for Maxthon) or Ctrl+F2 (for Other Browsers)
{
toggleDebugLayer();
$e.cancelBubble = true;
if($e.stopPropagation) $e.stopPropagation();
}
}
function toggleDebugLayer()
{
var $DebugLayer = document.getElementById('debug_layer');
if( typeof($DebugLayer) != 'undefined' )
{
resizeDebugLayer(null);
$DebugLayer.style.display = ($DebugLayer.style.display == 'none') ? 'block' : 'none';
}
}
function prepareSizes($Prefix)
{
var $ret = '';
$ret = eval('document.body.'+$Prefix+'Top')+'; ';
$ret += eval('document.body.'+$Prefix+'Left')+'; ';
$ret += eval('document.body.'+$Prefix+'Height')+'; ';
$ret += eval('document.body.'+$Prefix+'Width')+'; ';
return $ret;
}
function resizeDebugLayer($e)
{
if(!$e) $e = window.event;
var $DebugLayer = document.getElementById('debug_layer');
var $TopMargin = 1;
if( typeof($DebugLayer) != 'undefined' )
{
$DebugLayer.style.top = parseInt(document.body.offsetTop + document.body.scrollTop) + $TopMargin;
$DebugLayer.style.height = document.body.clientHeight - $TopMargin - 5;
}
window.parent.status = 'OFFSET: '+prepareSizes('offset')+' | SCROLL: '+prepareSizes('scroll')+' | CLIENT: '+prepareSizes('client');
window.parent.status += 'DL Info: '+$DebugLayer.style.top+'; S.AH: '+screen.availHeight;
return true;
}
function SetClipboard($data)
{
if (window.clipboardData)
{
window.clipboardData.setData('Text', $data);
}
else if (window.netscape)
{
//netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var $copytext=$data;
str.data=$copytext;
trans.setTransferData("text/unicode",str,$copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
}
function showProps($Obj, $Name)
{
var $ret = '';
for($Prop in $Obj)
{
$ret += $Name+'.'+$Prop+' = '+$Obj[$Prop]+"\n";
}
return $ret;
}
function editFile($fileName,$lineNo)
{
var $editorPath = '<?php echo defined('WINDOWS_EDITOR') ? addslashes(WINDOWS_EDITOR) : '' ?>';
if($editorPath)
{
var $obj = new ActiveXObject("LaunchinIE.Launch");
$editorPath = $editorPath.replace('%F',$fileName);
$editorPath = $editorPath.replace('%L',$lineNo);
$obj.LaunchApplication($editorPath);
}
else
{
alert('Editor path not defined!');
}
}
function toggleTraceArgs($ArgsLayerID)
{
var $ArgsLayer = document.getElementById($ArgsLayerID);
$ArgsLayer.style.display = ($ArgsLayer.style.display == 'none') ? 'block' : 'none';
}
document.onkeydown = keyProcessor;
window.onresize = resizeDebugLayer;
window.onscroll = resizeDebugLayer;
window.focus();
if( typeof($isFatalError) != 'undefined' && $isFatalError == 1 )
{
toggleDebugLayer();
document.getElementById('debug_layer').scrollTop = 10000000;
}
</script>
<?php
}
/**
* User-defined error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param array $errcontext
*/
function saveError($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
//echo '<b>error</b> ['.$errno.'] = ['.$errstr.']<br>';
$errorType = $this->getErrorNameByCode($errno);
if(!$errorType)
{
trigger_error('Unknown error type ['.$errno.']', E_USER_ERROR);
return false;
}
$this->Data[] = Array('no' => $errno, 'str' => $errstr, 'file' => $errfile, 'line' => $errline, 'context' => $errcontext, 'debug_type' => 'error');
if( substr($errorType,0,5) == 'Fatal')
{
echo '<script language="javascript">var $isFatalError = 1;</script>';
exit;
}
}
function saveToFile($msg)
{
$fp = fopen($_SERVER['DOCUMENT_ROOT'].'/vb_debug.txt', 'a');
fwrite($fp,$msg."\n");
fclose($fp);
}
}
function ConstOn($const_name)
{
return defined($const_name)&&constant($const_name);
}
$debugger = new Debugger();
$debugger->appendHTML('<a href="javascript:toggleDebugLayer();">Hide Debugger</a>');
if(ConstOn('DBG_HANDLE_ERRORS')) set_error_handler( array(&$debugger,'saveError') );
if(ConstOn('DBG_USE_SHUTDOWN_FUNC')) register_shutdown_function( array(&$debugger,'printReport') );
?>
\ No newline at end of file
Property changes on: trunk/kernel/include/debugger.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.11
\ No newline at end of property
+1.12
\ No newline at end of property
Index: trunk/admin/config/module_email.php
===================================================================
--- trunk/admin/config/module_email.php (revision 871)
+++ trunk/admin/config/module_email.php (revision 872)
@@ -1,772 +1,395 @@
<?php
##############################################################
-
##In-portal ##
-
##############################################################
-
## In-portal ##
-
## Intechnic Corporation ##
-
## All Rights Reserved, 1998-2002 ##
-
## ##
-
## No portion of this code may be copied, reproduced or ##
-
## otherwise redistributed without proper written ##
-
## consent of Intechnic Corporation. Violation will ##
-
## result in revocation of the license and support ##
-
## privileges along maximum prosecution allowed by law. ##
-
##############################################################
-
if(!strlen($pathtoroot))
-
{
-
$path=dirname(realpath(__FILE__));
-
if(strlen($path))
-
{
-
/* determine the OS type for path parsing */
-
$pos = strpos($path,":");
-
if ($pos === false)
-
{
-
$gOS_TYPE="unix";
-
$pathchar = "/";
-
}
-
else
-
{
-
$gOS_TYPE="win";
-
$pathchar="\\";
-
}
-
$p = $path.$pathchar;
-
/*Start looking for the root flag file */
-
while(!strlen($pathtoroot) && strlen($p))
-
{
-
$sub = substr($p,strlen($pathchar)*-1);
-
if($sub==$pathchar)
-
{
-
$filename = $p."root.flg";
-
}
-
else
-
$filename = $p.$pathchar."root.flg";
-
if(file_exists($filename))
-
{
-
$pathtoroot = $p;
-
}
-
else
-
{
-
$parent = realpath($p.$pathchar."..".$pathchar);
-
if($parent!=$p)
-
{
-
$p = $parent;
-
}
-
else
-
$p = "";
-
}
-
}
-
if(!strlen($pathtoroot))
-
$pathtoroot = ".".$pathchar;
-
}
-
else
-
{
-
$pathtoroot = ".".$pathchar;
-
}
-
}
-
-
$sub = substr($pathtoroot,strlen($pathchar)*-1);
-
if($sub!=$pathchar)
-
{
-
$pathtoroot = $pathtoroot.$pathchar;
-
}
-
//echo $pathtoroot;
-
-
-
require_once($pathtoroot."kernel/startup.php");
-
-
if (!admin_login())
-
{
-
if(!headers_sent())
-
setcookie("sid"," ",time()-3600);
-
$objSession->Logout();
-
header("Location: ".$adminURL."/login.php");
-
die();
-
//require_once($pathtoroot."admin/login.php");
-
}
-
-
//admin only util
-
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
-
$admin = $objConfig->Get("AdminDirectory");
-
if(!strlen($admin))
-
$admin = "admin";
-
-
$localURL=$rootURL."kernel/";
-
$adminURL = $rootURL.$admin;
-
$imagesURL = $adminURL."/images";
-
-
require_once ($pathtoroot.$admin."/include/elements.php");
-
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
-
require_once($pathtoroot.$admin."/toolbar.php");
-
require_once($pathtoroot.$admin."/listview/listview.php");
-
-
$m = GetModuleArray();
-
foreach($m as $key=>$value)
-
{
-
$path = $pathtoroot. $value."admin/include/parser.php";
-
if(file_exists($path))
-
{
-
include_once($path);
-
}
-
}
-
-
unset($objEditItems);
-
-
//$objEditItems = new clsPhraseList();
-
//$objEditItems->SourceTable = $objSession->GetEditTable("Language");
-
-
/* -------------------------------------- Section configuration ------------------------------------------- */
-
$section = $_GET["section"];
-
$sec = $objSections->GetSection($section);
-
-
$module = $_GET["module"];
-
$envar = "env=" . BuildEnv()."&module=$module&section=$section";
-
-
//$title = prompt_language("la_Text_Configuration")." - '".$module."' - ".prompt_language("la_tab_EmailEvents");
-
-
$SortFieldVar = "Event_LV_SortField";
-
$SortOrderVar = "Event_LV_SortOrder";
-
$DefaultSortField = "Description";
-
$PerPageVar = "Perpage_Event";
-
$CurrentPageVar = "Page_Event";
-
$CurrentFilterVar = "EmailEvent_View";
-
-
$ListForm = "language";
-
$CheckClass = "EmailChecks";
-
-
-
//echo $envar."<br>\n";
-
/* ------------------------------------- Configure the toolbar ------------------------------------------- */
-
$objListToolBar = new clsToolBar();
-
$objListToolBar->Set("section",$section);
-
$objListToolBar->Set("load_menu_func","");
-
$objListToolBar->Set("CheckClass","EmailChecks");
-
$objListToolBar->Set("CheckClass",$CheckClass);
-
$objListToolBar->Set("CheckForm",$ListForm);
-
-
$listImages = array();
-
-
/*
-
$objListToolBar->Add("email_edit", "la_ToolTip_Edit","#","if (EmailChecks.itemChecked()) swap('email_edit','toolbar/tool_edit_f2.gif');",
-
"if (EmailChecks.itemChecked()) swap('email_edit', 'toolbar/tool_edit.gif');",
-
"EmailChecks.check_submit('email_edit', '');",
-
"tool_edit.gif");
-
$listImages[] = "EmailChecks.addImage('email_edit','$imagesURL/toolbar/tool_edit.gif','$imagesURL/toolbar/tool_edit_f3.gif',1); ";
-
*/
-
-
$EditVar = "env=".BuildEnv();
-
-
$objListToolBar->Add("email_user", "la_ToolTip_Email_UserSelect","#","if (EmailChecks.itemChecked()) swap('email_user','toolbar/tool_usertogroup_f2.gif');",
-
"if (EmailChecks.itemChecked()) swap('email_user', 'toolbar/tool_usertogroup.gif');",
-
"OpenUserSelector('EventId',$CheckClass,'".$EditVar."&Selector=radio&destform=userpopup&destfield=FromUserId&IdField=PortalUserId&dosubmit=1');",
-
"tool_usertogroup.gif",TRUE,TRUE);
-
-
$listImages[] = "EmailChecks.addImage('email_user','$imagesURL/toolbar/tool_usertogroup.gif','$imagesURL/toolbar/tool_usertogroup_f3.gif',1); ";
-
-
$objListToolBar->Add("email_enable", "la_ToolTip_Email_Enable","#","if (EmailChecks.itemChecked()) swap('email_enable','toolbar/tool_approve_f2.gif');",
-
"if (EmailChecks.itemChecked()) swap('email_enable', 'toolbar/tool_approve.gif');",
-
"EmailChecks.check_submit('module_email', 'm_emailevent_enable');",
-
"tool_approve.gif",FALSE,TRUE);
-
-
$listImages[] = "EmailChecks.addImage('email_enable','$imagesURL/toolbar/tool_approve.gif','$imagesURL/toolbar/tool_approve_f3.gif',1); ";
-
-
$objListToolBar->Add("email_disable", "la_ToolTip_Email_Disable","#","if (EmailChecks.itemChecked()) swap('email_disable','toolbar/tool_deny_f2.gif');",
-
"if (EmailChecks.itemChecked()) swap('email_disable', 'toolbar/tool_deny.gif');",
-
"EmailChecks.check_submit('module_email', 'm_emailevent_disable');",
-
"tool_deny.gif",FALSE,TRUE);
-
-
$listImages[] = "EmailChecks.addImage('email_disable','$imagesURL/toolbar/tool_deny.gif','$imagesURL/toolbar/tool_deny_f3.gif',1); ";
-
-
$objListToolBar->Add("email_front", "la_ToolTip_Email_FrontOnly","#","if (EmailChecks.itemChecked()) swap('email_front','toolbar/tool_frontend_mail_f2.gif');",
-
"if (EmailChecks.itemChecked()) swap('email_front', 'toolbar/tool_frontend_mail.gif');",
-
"EmailChecks.check_submit('module_email', 'm_emailevent_frontonly');",
-
"tool_frontend_mail.gif",FALSE,TRUE);
-
-
$listImages[] = "EmailChecks.addImage('email_front','$imagesURL/toolbar/tool_frontend_mail.gif','$imagesURL/toolbar/tool_frontend_mail_f3.gif',1); ";
-
-
-
$objListToolBar->Add("divider");
-
-
$objListToolBar->Add("viewmenubutton", "la_ToolTip_View","#","swap('viewmenubutton','toolbar/tool_view_f2.gif'); ",
-
"swap('viewmenubutton', 'toolbar/tool_view.gif');",
-
"ShowViewMenu();","tool_view.gif");
-
-
-
$objListToolBar->AddToInitScript($listImages);
-
$objListToolBar->AddToInitScript("fwLoadMenus();");
-
-
$objEvents = new clsEventList();
-
//$objEvents->SourceTable = $objSession->GetEditTable("Events");
-
-
$order = trim($objConfig->Get("Event_LV_SortField")." ".$objConfig->Get("Event_LV_SortOrder"));
-
-
$SearchWords = $objSession->GetVariable("EmailEventSearchWord");
-
$where = "(Module='$module')";
-
if(strlen($SearchWords))
-
$where .= ' AND '.$objEvents->AdminSearchWhereClause($SearchWords);
-
-
/* ----------------------------------------- Set the View Filter ---------------------------------------- */
-
$ViewNormal=1;
-
$Bit_Disabled=2;
-
$Bit_Enabled=1;
-
$Bit_FrontOnly=4;
-
$Bit_All = 7;
-
$FilterLabels[0] = admin_language("la_Text_Enabled");
-
$FilterLabels[1] = admin_language("la_Text_Disabled");
-
$FilterLabels[2] = admin_language("la_Text_FrontOnly");
-
-
/* determine current view menu settings */
-
$MsgView = $objConfig->Get("EmailEvent_View");
-
-
$ViewNormal=0;
-
-
if(!is_numeric($MsgView))
-
{
-
$MsgView = $Bit_All; //Set all bits ON
-
$MsgFilter = "";
-
}
-
unset($Status);
-
$Status = array();
-
-
if($MsgView & $Bit_Disabled)
-
$Status[] = 0;
-
-
if($MsgView & $Bit_Enabled)
-
$Status[] = 1;
-
-
if($MsgView & $Bit_FrontOnly)
-
$Status[] = 2;
-
-
if(count($Status)>0)
-
{
-
$MsgFilter = "Enabled IN (".implode(",",$Status).")";
-
}
-
else
-
$MsgFilter = "Enabled = -1";
-
-
$UserTable = GetTablePrefix()."PortalUser";
-
$EventTable = GetTablePrefix()."Events";
-
$MessageTable = GetTablePrefix()."EmailMessage";
-
-
$sql = "SELECT e.Description as Description, e.Module as Module, e.EventId as EventId, ";
-
$sql .="ELT(e.Enabled+1,'".admin_language("la_Text_Disabled")." ','".admin_language("la_Text_Enabled")."','".admin_language("la_Text_FrontOnly")." ') as EmailStatus, ";
-
$sql .="ELT(e.Type+1,'".admin_language("la_Text_User")." ','".admin_language("la_Text_Admin")." ') as EventType, ";
-
$sql .="u.Login as FromUser FROM $EventTable as e LEFT JOIN $UserTable as u ON (e.FromUserId=u.PortalUserId) WHERE $where ";
-
if(strlen($MsgFilter))
-
$sql .= "AND $MsgFilter ";
-
-
if(strlen(trim($objConfig->Get($SortFieldVar))))
-
{
-
$order = " ORDER BY ".$objConfig->Get($SortFieldVar)." ".$objConfig->Get($SortOrderVar);
-
}
-
else
-
$order = "";
-
-
if($objConfig->Get($CurrentPageVar)>0)
-
{
-
$objEvents->Page = $objConfig->Get($CurrentPageVar);
-
}
-
-
if($objConfig->Get($PerPageVar)>0)
-
{
-
$objListView->PerPage = $objConfig->Get($PerPageVar);
-
}
-
-
$sql .= $order." ";
-
-
if($objSession->HasSystemPermission("DEBUG.LIST"))
-
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
-
-
$objListView = new clsListView($objListToolBar);
-
$objListView->CurrentPageVar = $CurrentPageVar;
-
$objListView->PerPageVar = $PerPageVar;
-
-
$objEvents->Query_Item($sql, $objListView->GetLimitSQL() );
-
//$itemcount = TableCount($objEvents->SourceTable, $where, 0);
-
$itemcount = QueryCount($sql);
-
-
$objListView->SetListItems($objEvents);
-
$objListView->IdField = "EventId";
-
-
$order = $objConfig->Get($PerPageVar);
-
-
$objListView->ColumnHeaders->Add("Description",admin_language("la_prompt_Description"),1,0,$order,"width=\"50%\"",$SortFieldVar,$SortOrderVar,"Description");
-
//$objListView->ColumnHeaders->Add("Module",admin_language("la_prompt_Module"),1,0,$order,"width=\"10%\"","Email_LV_SortField","Email_LV_SortOrder","Module");
-
$objListView->ColumnHeaders->Add("EventType",admin_language("la_prompt_Type"),1,0,$order,"width=\"10%\"",$SortFieldVar,$SortOrderVar,"EventType");
-
$objListView->ColumnHeaders->Add("EmailStatus",admin_language("la_prompt_Status"),1,0,$order,"width=\"10%\"",$SortFieldVar,$SortOrderVar,"EmailStatus");
-
$objListView->ColumnHeaders->Add("FromUser",admin_language("la_prompt_FromUser"),1,0,$order,"width=\"15%\"",$SortFieldVar,$SortOrderVar,"FromUser");
-
-
$objListView->ColumnHeaders->SetSort($objConfig->Get($SortFieldVar), $objConfig->Get($SortOrderVar));
-
-
$objListView->PrintToolBar = FALSE;
-
$objListView->checkboxes = TRUE;
-
$objListView->CheckboxName = "itemlist[]";
-
$objListView->SearchBar = TRUE;
-
$objListView->SearchKeywords = $SearchWords;
-
$objListView->SearchAction="m_emailevent_search";
-
-
$objListView->TotalItemCount = $itemcount;
-
-
$objListView->ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSortField,
-
$CurrentFilterVar,$MsgView,$Bit_All);
-
-
foreach($FilterLabels as $Bit=>$Label)
-
{
-
$objListView->AddViewMenuFilter($Label,$Bit);
-
}
-
-
for($i=0;$i<count($objEvents->Items);$i++)
-
{
-
$e =& $objEvents->GetItemRefByIndex($i);
-
$e->Set("Description",prompt_language($e->Get("Description")));
-
}
-
$filter = false; // always initialize variables before use
-
if($objSession->GetVariable("EmailEventSearchWord") != '') {
$filter = true;
}
else {
if ($MsgView != $Bit_All) {
$filter = true;
}
}
-
$h = "\n\n<SCRIPT Language=\"JavaScript1.2\">\n".$objListView->GetViewMenu($imagesURL)."\n</SCRIPT>\n";
-
int_header($objListToolBar,NULL, $title,NULL,$h);
-
if ($filter) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
<tr>
<td valign="top">
<?php int_hint_red(admin_language("la_Warning_Filter")); ?>
</td>
</tr>
</table>
<?php } ?>
-
<form name="language" ID="language" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar;?>" method=POST>
-
<table cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
-
<tbody>
-
<?php
-
print $objListView->PrintList();
-
?>
-
<input type="hidden" NAME="section" VALUE="<?php echo $section; ?>">
-
<input type="hidden" name="Action" value="m_email_edit">
-
<input type="hidden" name="LangEditStatus" VALUE="0">
-
</FORM>
-
<FORM>
-
<TR <?php int_table_color(); ?> >
-
<td colspan="3">
-
</td>
-
</tr>
-
</FORM>
-
</TABLE>
-
-
<!-- CODE FOR VIEW MENU -->
-
<form ID="viewmenu" method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" name="viewmenu">
-
<input type="hidden" name="fieldname" value="">
-
<input type="hidden" name="varvalue" value="">
-
<input type="hidden" name="varvalue2" value="">
-
<input type="hidden" name="Action" value="">
-
</form>
-
<FORM ID="ListSearchForm" NAME="ListSearchForm" method="POST" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">
-
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="">
-
<INPUT TYPE="HIDDEN" NAME="list_search">
-
</FORM>
-
-
<FORM NAME="popup" METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" ID="popup">
-
<INPUT TYPE="HIDDEN" NAME="MessageId" value="">
-
<INPUT TYPE="HIDDEN" NAME="LanguageId" value="">
-
<INPUT TYPE="HIDDEN" NAME="Enabled" value="">
-
<INPUT TYPE="HIDDEN" NAME="Template" value="">
-
<INPUT TYPE="HIDDEN" NAME="MessageType" value="">
-
<INPUT TYPE="HIDDEN" NAME="Subscribed" value="">
-
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="m_emailevent_edit">
-
</FORM>
-
-
<FORM NAME="userpopup" METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" ID="userpopup">
-
<INPUT TYPE="HIDDEN" NAME="EventId" value="">
-
<INPUT TYPE="HIDDEN" NAME="FromUserId" value="">
-
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="m_emailevent_user">
-
</FORM>
-
-
<script src="<?php echo $adminURL; ?>/listview/listview.js"></script>
-
<script>
-
initSelectiorContainers();
-
<?php echo $objListToolBar->Get("CheckClass").".setImages();"; ?>
-
</script>
-
<?php int_footer(); ?>
-
Property changes on: trunk/admin/config/module_email.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/admin/config/addlang_email.php
===================================================================
--- trunk/admin/config/addlang_email.php (revision 871)
+++ trunk/admin/config/addlang_email.php (revision 872)
@@ -1,428 +1,440 @@
<?php
##############################################################
##In-portal ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
if(!strlen($pathtoroot))
{
$path=dirname(realpath(__FILE__));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
unset($objEditItems);
$objEditItems = new clsPhraseList();
$objEditItems->SourceTable = $objSession->GetEditTable("Language");
$objEditItems->EnablePaging = FALSE;
//Multiedit init
$en = (int)$_GET["en"];
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
$c = $objEditItems->GetItemByIndex($en);
$name = $c->Get("PackName");
$LangId = $c->Get("LanguageId");
if($itemcount>1)
{
if ($en+1 == $itemcount)
$en_next = -1;
else
$en_next = $en+1;
if ($en == 0)
$en_prev = -1;
else
$en_prev = $en-1;
}
$action = "m_phrase_edit";
/* -------------------------------------- Section configuration ------------------------------------------- */
$envar = "env=" . BuildEnv() . "&en=$en";
$section = 'in-portal:lang_email';
$sec = $objSections->GetSection($section);
$SortFieldVar = "LangEmail_LV_SortField";
$SortOrderVar = "LangEmail_LV_SortOrder";
$DefaultSortField = "Description";
$PerPageVar = "Perpage_LangEmail";
$CurrentPageVar = "Page_LangEmail";
$CurrentFilterVar = "LangEmailEvent_View";
$ListForm = "language";
$CheckClass = "EmailChecks";
/* ------------------------------------- Configure the toolbar ------------------------------------------- */
$objListToolBar = new clsToolBar();
$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","do_edit_save('language','LangEditStatus','".$admin."/config/config_lang.php',1);",$imagesURL."/toolbar/tool_select.gif");
$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('language','LangEditStatus','".$admin."/config/config_lang.php',2);",$imagesURL."/toolbar/tool_cancel.gif");
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass",$CheckClass);
$objListToolBar->Set("CheckForm",$ListForm);
if ( isset($en_prev) || isset($en_next) )
{
$objListToolBar->Add("divider");
if($en_prev>-1)
{
$MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
$MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
$onClick= $sec->Get("onclick");
$var="?env=".BuildEnv()."&en=$en_prev";
$link=$_SERVER["PHP_SELF"].$var;
$objListToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Theme"),$link,$MouseOver,$MouseOut,"","tool_prev.gif");
}
else
{
$MouseOver="";
$MouseOut="";
$onClick="";
$link="#";
$objListToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Theme"),"#","","","","tool_prev_f3.gif");
}
if($en_next>-1)
{
$MouseOver="swap('moveright','toolbar/tool_next_f2.gif');";
$MouseOut="swap('moveright', 'toolbar/tool_next.gif');";
$onClick=$sec->Get("onclick");
$var="?env=".BuildEnv()."&en=$en_next";
$link=$_SERVER["PHP_SELF"].$var;
$objListToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Theme"),$link,$MouseOver,$MouseOut,"","tool_next.gif");
}
else
{
$objListToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Theme"),$link,$MouseOver,$MouseOut,"","tool_next_f3.gif");
}
}
$objListToolBar->Add("divider");
$listImages = array();
//$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick
$EditEnv = $envar."&Lang=".$c->Get("LanguageId");
$objListToolBar->Add("email_edit", "la_ToolTip_Edit","#","if (EmailChecks.itemChecked()) swap('email_edit','toolbar/tool_edit_f2.gif');",
"if (EmailChecks.itemChecked()) swap('email_edit', 'toolbar/tool_edit.gif');",
"if (EmailChecks.itemChecked()) EmailChecks.check_submit('email_edit', '');",
"tool_edit.gif",TRUE,TRUE);
$listImages[] = "EmailChecks.addImage('email_edit','$imagesURL/toolbar/tool_edit.gif','$imagesURL/toolbar/tool_edit_f3.gif',1); ";
/*
$objListToolBar->Add("email_user", "la_ToolTip_Email_UserSelect","#","if (EmailChecks.itemChecked()) swap('email_user','toolbar/tool_usertogroup_f2.gif');",
"if (EmailChecks.itemChecked()) swap('email_user', 'toolbar/tool_usertogroup.gif');",
"OpenUserSelector('$envar&Selector=radio&destform=userpopup&destfield=FromUserId&IdField=PortalUserId',$LangId);",
"tool_usertogroup.gif");
$listImages[] = "EmailChecks.addImage('email_user','$imagesURL/toolbar/tool_usertogroup.gif','$imagesURL/toolbar/tool_usertogroup_f3.gif',1); ";
*/
$objListToolBar->Add("divider");
$objListToolBar->Add("viewmenubutton", "la_ToolTip_View","#","swap('viewmenubutton','toolbar/tool_view_f2.gif'); ",
"swap('viewmenubutton', 'toolbar/tool_view.gif');",
"ShowViewMenu();","tool_view.gif");
$objListToolBar->AddToInitScript($listImages);
$objListToolBar->AddToInitScript("fwLoadMenus();");
/* ----------------------------------------- Set the View Filter ---------------------------------------- */
$ViewNormal=1;
$Bit_Disabled=2;
$Bit_Enabled=1;
$Bit_FrontOnly=4;
$Bit_All = 7;
$FilterLabels = array();
$FilterLabels[0] = admin_language("la_Text_Enabled");
$FilterLabels[1] = admin_language("la_Text_Disabled");
$FilterLabels[2] = admin_language("la_Text_FrontOnly");
/* determine current view menu settings */
$MsgView = $objConfig->Get($CurrentFilterVar);
if(!is_numeric($MsgView))
{
$MsgView = $Bit_All; //Set all bits ON
$MsgFilter = "";
}
if($MsgView & $Bit_Disabled)
$Status[] = 0;
if($MsgView & $Bit_Enabled)
$Status[] = 1;
if($MsgView & $Bit_FrontOnly)
$Status[] = 2;
if(count($Status)>0)
{
$MsgFilter = "Enabled IN (".implode(",",$Status).")";
}
else
$MsgFilter = "Enabled = -1";
/* ------------------------------------ Build the SQL statement to populate the list ---------------------------*/
$objEvents = new clsEventList();
$order = trim($objConfig->Get($SortFieldVar)." ".$objConfig->Get($SortOrderVar));
$SearchWords = $objSession->GetVariable("LangEmailEventSearchWord");
if(strlen($SearchWords))
{
- $where = $objEvents->AdminSearchWhereClause($SearchWords);
+ // remove u.Login from search fields in this case
+ $i = 0; $field_count = count($objEvents->AdminSearchFields);
+ while($i < $field_count)
+ {
+ if( $objEvents->AdminSearchFields[$i] == 'u.Login' )
+ {
+ array_splice($objEvents->AdminSearchFields,$i);
+ break;
+ }
+ $i++;
+ }
+ $where = $objEvents->AdminSearchWhereClause($SearchWords);
}
else
- $where = "";
-
+{
+ $where = "";
+}
$UserTable = GetTablePrefix()."PortalUser";
$EventTable = GetTablePrefix()."Events";
$MessageTable = GetTablePrefix()."EmailMessage";
$sql = "SELECT e.Description as Description, e.Module as Module, e.EventId as EventId, ";
$sql .="ELT(e.Enabled+1,'".admin_language("la_Text_Disabled")." ','".admin_language("la_Text_Enabled")." ', '".admin_language("la_Text_FrontOnly")." ') as EventStatus, ";
$sql .="ELT(e.Type+1,'".admin_language("la_Text_User")." ','".admin_language("la_Text_Admin")." ') as EventType, ";
$sql .="u.Login as FromUser FROM $EventTable as e LEFT JOIN $UserTable as u ON (e.FromUserId=u.PortalUserId) ";
$FullWhere = "";
if(strlen($where))
{
$FullWhere = "WHERE $where ";
}
if(strlen($MsgFilter))
{
if(!strlen($FullWhere))
{
$FullWhere = "WHERE $MsgFilter ";
}
else
$FullWhere .= " AND ($MsgFilter) ";
}
$sql .= $FullWhere;
if(strlen($objConfig->Get($SortFieldVar)))
$sql .= "ORDER BY ".$order." ";
if(isset($_GET["lpn"]))
$objSession->SetVariable($CurrentPageVar,$_GET["lpn"]);
$sql .= GetLimitSQL($objSession->GetVariable($CurrentPageVar),$objConfig->Get($PerPageVar));
//echo $sql;
$objEvents->Query_Item($sql);
$itemcount = TableCount($objEvents->SourceTable, $where,0);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
/* ---------------------------------------- Configure the list view ---------------------------------------- */
$objListView = new clsListView($objListToolBar,$objEvents);
$objListView->IdField = "EventId";
$order = $objConfig->Get("LangEmail_LV_SortField");
$objListView->ColumnHeaders->Add("Description",admin_language("la_prompt_Description"),1,0,$order,"width=\"50%\"","LangEmail_LV_SortField","LangEmail_LV_SortOrder","Description");
$objListView->ColumnHeaders->Add("Module",admin_language("la_prompt_Module"),1,0,$order,"width=\"15%\"","LangEmail_LV_SortField","LangEmail_LV_SortOrder","Module");
$objListView->ColumnHeaders->Add("EventType",admin_language("la_prompt_Type"),1,0,$order,"width=\"10%\"","LangEmail_LV_SortField","LangEmail_LV_SortOrder","EventType");
$objListView->ColumnHeaders->Add("EventStatus",admin_language("la_prompt_Status"),1,0,$order,"width=\"10%\"","LangEmail_LV_SortField","LangEmail_LV_SortOrder","EventStatus");
//$objListView->ColumnHeaders->Add("FromUser",admin_language("la_prompt_FromUser"),1,0,$order,"width=\"15%\"","Email_LV_SortField","Email_LV_SortOrder","FromUser");
$objListView->ColumnHeaders->SetSort($objConfig->Get($SortFieldVar), $objConfig->Get($SortOrderVar));
$objListView->PrintToolBar = FALSE;
$objListView->checkboxes = TRUE;
$objListView->CurrentPageVar = $CurrentPageVar;
$objListView->PerPageVar = $PerPageVar;
$objListView->CheckboxName = "itemlist[]";
$objListView->SearchBar = TRUE;
$objListView->SearchKeywords = $SearchWords;
$objListView->SearchAction="m_langemailevent_search";
$objListView->TotalItemCount = $itemcount;
$objListView->ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSortField,
$CurrentFilterVar,$MsgView,$Bit_All);
foreach($FilterLabels as $Bit=>$Label)
{
$objListView->AddViewMenuFilter($Label,$Bit);
}
for($i=0;$i<count($objEvents->Items);$i++)
{
$e =& $objEvents->GetItemRefByIndex($i);
$e->Set("Description",prompt_language($e->Get("Description")));
}
$filter = false; // always initialize variables before use
if($objSession->GetVariable("LangEmailEventSearchWord") != '') {
$filter = true;
}
else {
if ($MsgView != $Bit_All) {
$filter = true;
}
}
$title = $title = GetTitle("la_Text_Pack", "la_tab_EmailEvents", $c->Get('LanguageId'), $c->Get('LocalName'));///prompt_language("la_Text_Configuration")." - '".$name."' ".prompt_language("la_Text_Pack")." - ".prompt_language("la_tab_EmailEvents");
$h = "\n\n<SCRIPT Language=\"JavaScript1.2\">\n".$objListView->GetViewMenu($imagesURL)."\n</SCRIPT>\n";
int_header($objListToolBar,NULL, $title,NULL,$h);
if ($objSession->GetVariable("HasChanges") == 1) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
<tr>
<td valign="top">
<?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
</td>
</tr>
</table>
<?php } ?>
<?php if ($filter) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
<tr>
<td valign="top">
<?php int_hint_red(admin_language("la_Warning_Filter")); ?>
</td>
</tr>
</table>
<?php } ?>
<form name="language" ID="language" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar;?>" method=POST>
<table cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<tbody>
<?php
print $objListView->PrintList();
?>
<input type="hidden" NAME="section" VALUE="<?php echo $section; ?>">
<input type="hidden" name="Action" value="m_email_edit">
<input type="hidden" name="LangEditStatus" VALUE="0">
</FORM>
<FORM>
<TR <?php int_table_color(); ?> >
<td colspan="3">
</td>
</tr>
</FORM>
</TABLE>
<!-- CODE FOR VIEW MENU -->
<form ID="viewmenu" method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" name="viewmenu">
<input type="hidden" name="fieldname" value="">
<input type="hidden" name="varvalue" value="">
<input type="hidden" name="varvalue2" value="">
<input type="hidden" name="Action" value="">
</form>
<FORM ID="ListSearchForm" NAME="ListSearchForm" method="POST" action="<?php echo $_SERVER["PHP_SELF"]."?env=".BuildEnv(); ?>">
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="">
<INPUT TYPE="HIDDEN" NAME="list_search">
</FORM>
<FORM NAME="popup" METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" ID="popup">
<INPUT TYPE="HIDDEN" NAME="MessageId" value="">
<INPUT TYPE="HIDDEN" NAME="LanguageId" value="">
<INPUT TYPE="HIDDEN" NAME="Enabled" value="">
<INPUT TYPE="HIDDEN" NAME="Template" value="">
<INPUT TYPE="HIDDEN" NAME="MessageType" value="">
<INPUT TYPE="HIDDEN" NAME="Subscribed" value="">
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="m_emailevent_edit">
</FORM>
<FORM NAME="userpopup" METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" ID="userpopup">
<INPUT TYPE="HIDDEN" NAME="MessageId" value="">
<INPUT TYPE="HIDDEN" NAME="LanguageId" value="<?php echo $c->Get("LanguageId"); ?>">
<INPUT TYPE="HIDDEN" NAME="FromUserId" value="">
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="m_emailevent_user">
</FORM>
<script src="<?php echo $adminURL; ?>/listview/listview.js"></script>
<script>
initSelectiorContainers();
<?php echo $objListToolBar->Get("CheckClass").".setImages();"; ?>
</script>
<?php int_footer(); ?>
Property changes on: trunk/admin/config/addlang_email.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property

Event Timeline