1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: class LegacyCommentObject extends XoopsSimpleObject
14: {
15: var $mUser = null;
16: var $mModule = null;
17: var $mStatus = null;
18:
19: function LegacyCommentObject()
20: {
21: static $initVars;
22: if (isset($initVars)) {
23: $this->mVars = $initVars;
24: return;
25: }
26: $this->initVar('com_id', XOBJ_DTYPE_INT, '', true);
27: $this->initVar('com_pid', XOBJ_DTYPE_INT, '0', true);
28: $this->initVar('com_rootid', XOBJ_DTYPE_INT, '0', true);
29: $this->initVar('com_modid', XOBJ_DTYPE_INT, '0', true);
30: $this->initVar('com_itemid', XOBJ_DTYPE_INT, '0', true);
31: $this->initVar('com_icon', XOBJ_DTYPE_STRING, '', true, 25);
32: $this->initVar('com_created', XOBJ_DTYPE_INT, '0', true);
33: $this->initVar('com_modified', XOBJ_DTYPE_INT, '0', true);
34: $this->initVar('com_uid', XOBJ_DTYPE_INT, '0', true);
35: $this->initVar('com_ip', XOBJ_DTYPE_STRING, '', true, 15);
36: $this->initVar('com_title', XOBJ_DTYPE_STRING, '', true, 255);
37: $this->initVar('com_text', XOBJ_DTYPE_TEXT, '', true);
38: $this->initVar('com_sig', XOBJ_DTYPE_BOOL, '0', true);
39: $this->initVar('com_status', XOBJ_DTYPE_INT, '1', true);
40: $this->initVar('com_exparams', XOBJ_DTYPE_STRING, '', true, 255);
41: $this->initVar('dohtml', XOBJ_DTYPE_BOOL, '0', true);
42: $this->initVar('dosmiley', XOBJ_DTYPE_BOOL, '1', true);
43: $this->initVar('doxcode', XOBJ_DTYPE_BOOL, '1', true);
44: $this->initVar('doimage', XOBJ_DTYPE_BOOL, '1', true);
45: $this->initVar('dobr', XOBJ_DTYPE_BOOL, '1', true);
46: $initVars=$this->mVars;
47: }
48:
49: 50: 51:
52: function loadUser()
53: {
54: $handler =& xoops_gethandler('member');
55: $this->mUser =& $handler->getUser($this->get('com_uid'));
56: }
57:
58: 59: 60:
61: function loadModule()
62: {
63: $handler =& xoops_gethandler('module');
64: $this->mModule =& $handler->get($this->get('com_modid'));
65: }
66:
67: function loadStatus()
68: {
69: $handler =& xoops_getmodulehandler('commentstatus', 'legacy');
70: $this->mStatus =& $handler->get($this->get('com_status'));
71: }
72:
73: function getVar($key)
74: {
75: if ($key == 'com_text') {
76: $ts =& MyTextSanitizer::getInstance();
77: return $ts->displayTarea($this->get($key), $this->get('dohtml'), $this->get('dosmiley'), $this->get('doxcode'), $this->get('doimage'), $this->get('dobr'));
78: }
79: else {
80: return parent::getVar($key);
81: }
82: }
83: }
84:
85: class LegacyCommentHandler extends XoopsObjectGenericHandler
86: {
87: var $mTable = "xoopscomments";
88: var $mPrimary = "com_id";
89: var $mClass = "LegacyCommentObject";
90:
91: 92: 93:
94: var $mUpdateSuccess;
95:
96: 97: 98:
99: var $mDeleteSuccess;
100:
101: function LegacyCommentHandler(&$db)
102: {
103: parent::XoopsObjectGenericHandler($db);
104:
105: $this->mUpdateSuccess =new XCube_Delegate();
106: $this->mDeleteSuccess =new XCube_Delegate();
107: }
108:
109: function insert(&$comment, $force = false)
110: {
111: if (parent::insert($comment, $force)) {
112: $this->mUpdateSuccess->call($comment);
113: return true;
114: }
115: else {
116: return false;
117: }
118: }
119:
120: 121: 122:
123: function delete(&$comment, $force = false)
124: {
125: $criteria =new Criteria('com_pid', $comment->get('com_id'));
126: $this->deleteAll($criteria);
127:
128: if (parent::delete($comment, $force)) {
129: $this->mDeleteSuccess->call($comment);
130: return true;
131: }
132: else{
133: return false;
134: }
135: }
136:
137: 138: 139: 140: 141: 142:
143: function getModuleIds()
144: {
145: $ret = array();
146:
147: $sql = "SELECT DISTINCT com_modid FROM " . $this->mTable;
148: $res = $this->db->query($sql);
149: if ($res) {
150: while ($row = $this->db->fetchArray($res)) {
151: $ret[] = $row['com_modid'];
152: }
153: }
154:
155: return $ret;
156: }
157: }
158:
159: ?>
160: