1: <?php
2: 3: 4: 5: 6:
7:
8: if (!defined('XOOPS_ROOT_PATH')) exit();
9:
10: class Profile_DataObject extends XoopsSimpleObject
11: {
12: public $mDef = null;
13:
14: 15: 16:
17: public function Profile_DataObject()
18: {
19: $handler = Legacy_Utils::getModuleHandler('definitions', 'profile');
20: $this->mDef = $handler->getDefinitions(false);
21:
22: $this->initVar('uid', XOBJ_DTYPE_INT, '', false);
23: foreach(array_keys($this->mDef) as $key){
24: $this->mDef[$key]->mFieldType->setInitVar($this, $this->mDef[$key]->getShow('field_name'), $this->mDef[$key]->getDefault());
25: }
26: }
27:
28: 29: 30: 31: 32: 33: 34: 35:
36: public function showField( $key, $option=2)
37: {
38: return $this->mDef[$key]->mFieldType->showField($this, $key, $option);
39: }
40:
41: 42: 43: 44: 45: 46: 47: 48:
49: public function setField( $key, $value)
50: {
51: $type = $this->mDef[$key]->get('type');
52: switch ($type) {
53: case Profile_FormType::TEXT:
54: if($this->mDef[$key]->get('options')=='html'){
55: $value = XCube_Root::getSingleton()->mTextFilter->purifyHtml($value);
56: }
57: $this->set($key, $value);
58: break;
59: case Profile_FormType::DATE:
60: $dateArr = explode('-', $value);
61: $date = mktime(0,0,0,$dateArr[1],$dateArr[2],$dateArr[0]);
62: $this->set($key, $date);
63: break;
64: default:
65: $this->set($key, $value);
66: break;
67: }
68:
69: return $value;
70: }
71: }
72:
73: class Profile_DataHandler extends XoopsObjectGenericHandler
74: {
75: var $mTable = 'profile_data';
76: var $mPrimary = 'uid';
77: var $mClass = 'Profile_DataObject';
78:
79: public function insert(&$obj, $force = false)
80: {
81: if(count($obj->mDef)===0){
82: return true;
83: }
84: parent::insert($obj, $force = false);
85: }
86:
87: }
88:
89: ?>
90: