| 1 |
<?php |
<?php |
| 2 |
// $Id: rpg.db.inc,v 1.9 2007/12/06 22:52:43 aaron Exp $ |
// $Id: rpg.db.inc,v 1.11 2008/03/08 00:31:04 aaron Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 142 |
|
|
| 143 |
// make sure each attribute will be initially saved, preserving defaults |
// make sure each attribute will be initially saved, preserving defaults |
| 144 |
foreach (rpg_object_attributes($object) as $type) { |
foreach (rpg_object_attributes($object) as $type) { |
| 145 |
if (!isset($object->data[$type['attribute']]) && $type['default_value']) { |
if (!$object->data[$type['attribute']] && $type['default_value']) { |
| 146 |
$object->data[$type['attribute']] = $type['default_value']; |
$object->data[$type['attribute']] = $type['default_value']; |
| 147 |
} |
} |
| 148 |
} |
} |
| 157 |
|
|
| 158 |
/** |
/** |
| 159 |
* TODO: update this function for the new api. |
* TODO: update this function for the new api. |
|
* TODO: this function is never actually called. how is it invoked? add a group to api? |
|
| 160 |
* this updates the object, saving its new values into the database. |
* this updates the object, saving its new values into the database. |
| 161 |
* it does NOT save attributes. that happens in _rpg_save_all_marked_objects. |
* it does NOT save attributes. that happens in _rpg_save_all_marked_objects. |
| 162 |
|
* It is called from rpg_form_object_submit |
| 163 |
* @param |
* @param |
| 164 |
* the object or rid to be saved |
* the object or rid to be saved |
| 165 |
* @return |
* @return |
| 166 |
* NULL |
* NULL |
| 167 |
*/ |
*/ |
| 168 |
function rpg_save_rpg($object) { |
function rpg_save_rpg($object) {//print_r($object); |
| 169 |
rpg_invoke_object($object, 'update'); |
global $rpg; |
| 170 |
$object = rpg_object($object);//drupal_set_message('save ' . $object->rid . ', dest:' . $object->data['dest']); |
rpg_invoke_object($object, 'update');//print_r($object); |
| 171 |
|
$rpg[$object->rid] = $object; |
| 172 |
db_query("UPDATE {rpg} SET uid=%d, created=%d, changed=%d WHERE rid=%d", $object->uid, $object->created, $object->changed, $object->rid); |
db_query("UPDATE {rpg} SET uid=%d, created=%d, changed=%d WHERE rid=%d", $object->uid, $object->created, $object->changed, $object->rid); |
| 173 |
db_query("DELETE FROM {rpg_object_types} WHERE rid=%d", $object->rid); |
db_query("DELETE FROM {rpg_object_types} WHERE rid=%d", $object->rid); |
| 174 |
foreach($object->types as $type) { |
foreach($object->types as $type) { |
| 175 |
db_query("INSERT INTO {rpg_object_types} (rid, type) VALUES (%d, '%s')", $object->rid, $type); |
db_query("INSERT INTO {rpg_object_types} (rid, type) VALUES (%d, '%s')", $object->rid, $type); |
| 176 |
} |
} |
| 177 |
|
// reset attributes according to new types |
| 178 |
|
rpg_object_attributes($object, NULL, FALSE); |
| 179 |
} |
} |
| 180 |
|
|
| 181 |
/** |
/** |