Index: trunk/kernel/include/itemdb.php
===================================================================
diff -u -r883 -r887
--- trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 883)
+++ trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 887)
@@ -152,38 +152,51 @@
return isset($this->Data[$name]) ? 1 : 0;
}
+ /**
+ * Set's value(-s) of field(-s) specified.
+ * Modifies HasChanges flag automatically.
+ *
+ * @param string/array $name
+ * @param string/array $value
+ * @access public
+ */
function Set($name, $value)
- {
- //echo "Setting Field $name: = [$value]
";
+ {
+ //echo "Setting Field $name: = [$value]
";
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( !(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( !(isset($_GET['new']) && $_GET['new']) ) {
- $this->DetectChanges($name, $value);
- }
- $this->Data[$name] = $value;
- $this->m_dirtyFieldsMap[$name] = $value;
- }
- }
- }
+ {
+ for ($i=0; $i < sizeof($name); $i++)
+ {
+ $this->_Set($name[$i],$value[$i]);
+ }
+ }
+ else
+ {
+ $this->_Set($name,$value);
+ }
+ }
+
+
+ /**
+ * Set's value(-s) of field(-s) specified.
+ * Modifies HasChanges flag automatically.
+ *
+ * @param string $name
+ * @param string $value
+ * @access private
+ */
+ function _Set($name,$value)
+ {
+ $var = 'm_'.$name;
+ if( !$this->HasField($name) || $this->Data[$name] != $value )
+ {
+ if( !(isset($_GET['new']) && $_GET['new']) ) {
+ $this->DetectChanges($name, $value);
+ }
+ $this->Data[$name] = $value;
+ $this->m_dirtyFieldsMap[$name] = $value;
+ }
+ }
function Dirty($list=NULL)
{
@@ -382,8 +395,21 @@
return $sql;
}
+ /**
+ * Set's HasChanges flag based on new field
+ * with $name with value $value.
+ *
+ * @param string $name
+ * @param string $value
+ * @access private
+ */
function DetectChanges($name, $value)
{
+ // Maris, don't try to create this method as universal
+ // as possible, remove unneeded if statements here and
+ // move them to those this class children's where they
+ // are really needed.
+
global $objSession;
//print_pre($_POST);
//echo "$name: $value
";