XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
comment.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
16{
17 public $mUser = null;
18 public $mModule = null;
19 public $mStatus = null;
20
21 public function __construct()
22 {
23 static $initVars;
24 if (isset($initVars)) {
25 $this->mVars = $initVars;
26 return;
27 }
28 $this->initVar('com_id', XOBJ_DTYPE_INT, '', true);
29 $this->initVar('com_pid', XOBJ_DTYPE_INT, '0', true);
30 $this->initVar('com_rootid', XOBJ_DTYPE_INT, '0', true);
31 $this->initVar('com_modid', XOBJ_DTYPE_INT, '0', true);
32 $this->initVar('com_itemid', XOBJ_DTYPE_INT, '0', true);
33 $this->initVar('com_icon', XOBJ_DTYPE_STRING, '', true, 25);
34 $this->initVar('com_created', XOBJ_DTYPE_INT, '0', true);
35 $this->initVar('com_modified', XOBJ_DTYPE_INT, '0', true);
36 $this->initVar('com_uid', XOBJ_DTYPE_INT, '0', true);
37 $this->initVar('com_ip', XOBJ_DTYPE_STRING, '', true, 15);
38 $this->initVar('com_title', XOBJ_DTYPE_STRING, '', true, 191);
39 $this->initVar('com_text', XOBJ_DTYPE_TEXT, '', true);
40 $this->initVar('com_sig', XOBJ_DTYPE_BOOL, '0', true);
41 $this->initVar('com_status', XOBJ_DTYPE_INT, '1', true);
42 $this->initVar('com_exparams', XOBJ_DTYPE_STRING, '', true, 191);
43 $this->initVar('dohtml', XOBJ_DTYPE_BOOL, '0', true);
44 $this->initVar('dosmiley', XOBJ_DTYPE_BOOL, '1', true);
45 $this->initVar('doxcode', XOBJ_DTYPE_BOOL, '1', true);
46 $this->initVar('doimage', XOBJ_DTYPE_BOOL, '1', true);
47 $this->initVar('dobr', XOBJ_DTYPE_BOOL, '1', true);
48 $initVars=$this->mVars;
49 }
50
54 public function loadUser()
55 {
56 $handler =& xoops_gethandler('member');
57 $this->mUser =& $handler->getUser($this->get('com_uid'));
58 }
59
63 public function loadModule()
64 {
65 $handler =& xoops_gethandler('module');
66 $this->mModule =& $handler->get($this->get('com_modid'));
67 }
68
69 public function loadStatus()
70 {
71 $handler =& xoops_getmodulehandler('commentstatus', 'legacy');
72 $this->mStatus =& $handler->get($this->get('com_status'));
73 }
74
75 public function getVar($key)
76 {
77 if ('com_text' == $key) {
79 return $ts->displayTarea($this->get($key), $this->get('dohtml'), $this->get('dosmiley'), $this->get('doxcode'), $this->get('doimage'), $this->get('dobr'));
80 } else {
81 return parent::getVar($key);
82 }
83 }
84}
85
87{
88 public $mTable = 'xoopscomments';
89 public $mPrimary = 'com_id';
90 public $mClass = 'LegacyCommentObject';
91
95 public $mUpdateSuccess;
96
100 public $mDeleteSuccess;
101
102 public function __construct(&$db)
103 {
104 parent::__construct($db);
105
106 $this->mUpdateSuccess =new XCube_Delegate();
107 $this->mDeleteSuccess =new XCube_Delegate();
108 }
109
110 public function insert(&$comment, $force = false)
111 {
112 if (parent::insert($comment, $force)) {
113 $this->mUpdateSuccess->call($comment);
114 return true;
115 } else {
116 return false;
117 }
118 }
119
126 public function delete(&$comment, $force = false)
127 {
128 $criteria =new Criteria('com_pid', $comment->get('com_id'));
129 $this->deleteAll($criteria);
130
131 if (parent::delete($comment, $force)) {
132 $this->mDeleteSuccess->call($comment);
133 return true;
134 } else {
135 return false;
136 }
137 }
138
145 public function getModuleIds()
146 {
147 $ret = [];
148
149 $sql = 'SELECT DISTINCT com_modid FROM ' . $this->mTable;
150 $res = $this->db->query($sql);
151 if ($res) {
152 while ($row = $this->db->fetchArray($res)) {
153 $ret[] = $row['com_modid'];
154 }
155 }
156
157 return $ret;
158 }
159}
[Final] Used for the simple mechanism for common delegation in XCube.
deleteAll($criteria, $force=false)
Definition handler.php:451