8 define(
'CH_TD_VIEWER_TYPE_VISITOR', 0);
9 define(
'CH_TD_VIEWER_TYPE_MEMBER', 1);
10 define(
'CH_TD_VIEWER_TYPE_ADMIN', 2);
12 define(
'CH_TD_STATUS_ACTIVE', 0);
13 define(
'CH_TD_STATUS_INACTIVE', 1);
14 define(
'CH_TD_STATUS_PENDING', 2);
35 $oCategories->getTagObjectConfig();
37 $this->_aForm = array(
38 'form_attrs' => array(
40 'name' =>
'text_data',
43 'enctype' =>
'multipart/form-data'
50 'uri_title' =>
'caption',
51 'submit_name' =>
'post'
57 'name' =>
'author_id',
58 'value' => $this->_iOwnerId,
66 'caption' =>
_t(
"_td_caption"),
71 'params' => array(3,64),
72 'error' =>
_t(
'_td_err_incorrect_length'),
82 'caption' =>
_t(
"_td_snippet"),
87 'params' => array(3,200),
88 'error' =>
_t(
'_td_err_incorrect_length'),
98 'caption' =>
_t(
"_td_content"),
103 'params' => array(3,65536),
104 'error' =>
_t(
'_td_err_incorrect_length'),
111 'type' =>
'datetime',
113 'caption' =>
_t(
"_td_date"),
114 'value' => date(
'Y-m-d H:i'),
117 'func' =>
'DateTime',
118 'error' =>
_t(
'_td_err_empty_value'),
121 'pass' =>
'DateTime',
127 'caption' =>
_t(
"_td_tags"),
132 'params' => array(3,64),
133 'error' =>
_t(
'_td_err_incorrect_length'),
135 'info' =>
_t(
'_sys_tags_note'),
140 'categories' => $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId,
true),
141 'allow_comment_to' => array(),
142 'allow_vote_to' => array(),
146 'value' =>
_t(
"_td_post"),
151 if(!
empty($this->_iOwnerId)) {
153 $sModuleUri = $this->_oModule->_oConfig->getUri();
155 $this->_aForm[
'inputs'][
'allow_comment_to'] = $oPrivacy->getGroupChooser($this->_iOwnerId, $sModuleUri,
'comment');
156 $this->_aForm[
'inputs'][
'allow_vote_to'] = $oPrivacy->getGroupChooser($this->_iOwnerId, $sModuleUri,
'vote');
165 if(
$oForm->isSubmittedAndValid()) {
167 $iDatePublish =
$oForm->getCleanValue(
'when');
168 if($iDatePublish > $iDateNow)
170 else if($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove())
176 'uri' =>
$oForm->generateUri(),
180 $iId =
$oForm->insert(array_merge($aDefFields, $aAddFields));
184 $oAlert =
new ChWsbAlerts($this->_oModule->_oConfig->getAlertsSystemName(),
'post',
$iId, $this->_iOwnerId);
190 $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(),
$iId);
195 $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(),
$iId);
206 if (isset($this->_aForm[
'inputs'][
'categories'])) {
208 $this->_aForm[
'inputs'][
'categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId,
true, $aValues[
'categories']);
210 if(!
empty($aValues) && is_array($aValues)) {
212 foreach($aValues
as $sKey => $sValue)
213 if(array_key_exists($sKey, $this->_aForm[
'inputs'])) {
214 if($this->_aForm[
'inputs'][$sKey][
'type'] ==
'checkbox')
215 $this->_aForm[
'inputs'][$sKey][
'checked'] = (int)$sValue == 1 ?
true :
false;
216 else if($this->_aForm[
'inputs'][$sKey][
'type'] ==
'select_box' && $this->_aForm[
'inputs'][$sKey][
'name'] ==
'Categories') {
217 $aCategories = preg_split(
'/['.$oCategories->sTagsDivider.
']/', $sValue, 0, PREG_SPLIT_NO_EMPTY );
218 $this->_aForm[
'inputs'][$sKey][
'value'] = $aCategories;
220 $this->_aForm[
'inputs'][$sKey][
'value'] = $sValue;
222 unset( $this->_aForm[
'inputs'][
'author_id']);
223 $this->_aForm[
'inputs'][
'id'] = array(
226 'value' => $aValues[
'id'],
231 $this->_aForm[
'inputs'][
'post'][
'value'] =
_t(
"_td_edit");
236 if(
$oForm->isSubmittedAndValid()) {
238 $iDatePublish =
$oForm->getCleanValue(
'when');
239 if($iDatePublish > $iDateNow)
241 else if($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove())
250 $oForm->update($aValues[
'id'], array_merge($aDefFields, $aAddFields));
254 $oAlert =
new ChWsbAlerts($this->_oModule->_oConfig->getAlertsSystemName(),
'edit', $aValues[
'id'], $this->_iOwnerId);
260 $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues[
'id']);
264 $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues[
'id']);