mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Fixes #976 - Submit news status now updates after being approved. Form-handler 'hidden fields' type now correctly rendered with the form.
This commit is contained in:
@@ -366,7 +366,7 @@ class news_admin_ui extends e_admin_ui
|
|||||||
'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'tab'=>0, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'tab'=>0, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
||||||
'news_body' => array('title' => "", 'type' => 'method', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_body' => array('title' => "", 'type' => 'method', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
'news_extended' => array('title' => "", 'type' => 'hidden', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_extended' => array('title' => "", 'type' => null, 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
|
|
||||||
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
@@ -383,6 +383,7 @@ class news_admin_ui extends e_admin_ui
|
|||||||
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'tab'=>2, 'data' => 'int' , 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'tab'=>2, 'data' => 'int' , 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||||
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'tab'=>2, 'writeParms'=>'inverse=1', 'data' => 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'inverse=1'),
|
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'tab'=>2, 'writeParms'=>'inverse=1', 'data' => 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'inverse=1'),
|
||||||
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'tab'=>2, 'noedit'=>true, 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
|
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'tab'=>2, 'noedit'=>true, 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||||
|
'submitted_id' => array('title'=>'Submitted Item', 'type' => 'hidden', 'data'=>false, 'writeParms'=>'show=1'),
|
||||||
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
|
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
|
||||||
|
|
||||||
);
|
);
|
||||||
@@ -428,8 +429,6 @@ class news_admin_ui extends e_admin_ui
|
|||||||
$tmp = explode(chr(35), $new_data['news_author']);
|
$tmp = explode(chr(35), $new_data['news_author']);
|
||||||
$new_data['news_author'] = intval($tmp[0]);
|
$new_data['news_author'] = intval($tmp[0]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $new_data;
|
return $new_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +456,13 @@ class news_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
public function afterCreate($new_data, $old_data, $id)
|
public function afterCreate($new_data, $old_data, $id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!empty($new_data['submitted_id']))
|
||||||
|
{
|
||||||
|
e107::getDb()->update('submitnews', "submitnews_auth = 1 WHERE submitnews_id = ".intval($new_data['submitted_id'])." LIMIT 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->processPings();
|
$this->processPings();
|
||||||
e107::getEvent()->trigger('newspost',$new_data);
|
e107::getEvent()->trigger('newspost',$new_data);
|
||||||
e107::getEvent()->trigger('admin_news_created',$new_data);
|
e107::getEvent()->trigger('admin_news_created',$new_data);
|
||||||
@@ -1074,7 +1080,8 @@ class news_admin_ui extends e_admin_ui
|
|||||||
$data['news_body'] = $row['submitnews_item'];
|
$data['news_body'] = $row['submitnews_item'];
|
||||||
$data['news_category'] = intval( $row['submitnews_category']);
|
$data['news_category'] = intval( $row['submitnews_category']);
|
||||||
$data['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]";
|
$data['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]";
|
||||||
|
$thumbs = array();
|
||||||
|
|
||||||
if($row['submitnews_file'])
|
if($row['submitnews_file'])
|
||||||
{
|
{
|
||||||
$files = explode(",",$row['submitnews_file']);
|
$files = explode(",",$row['submitnews_file']);
|
||||||
@@ -1082,12 +1089,16 @@ class news_admin_ui extends e_admin_ui
|
|||||||
{
|
{
|
||||||
if($bbpath = e107::getMedia()->importFile($f,'news'))
|
if($bbpath = e107::getMedia()->importFile($f,'news'))
|
||||||
{
|
{
|
||||||
$data['news_body'] .= "\n\n[img]".$bbpath."[/img]";
|
$thumbs[] = $bbpath;
|
||||||
|
// $data['news_body'] .= "\n\n[img]".$bbpath."[/img]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['news_thumbnail'] = implode(",",$thumbs);
|
||||||
|
$data['submitted_id'] = $id;
|
||||||
|
|
||||||
foreach($data as $k=>$v)
|
foreach($data as $k=>$v)
|
||||||
{
|
{
|
||||||
$this->getModel()->setData($k, $v); // Override Table data.
|
$this->getModel()->setData($k, $v); // Override Table data.
|
||||||
|
@@ -4021,9 +4021,9 @@ class e_form
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'hidden':
|
case 'hidden':
|
||||||
|
|
||||||
$value = (isset($parms['value'])) ? $parms['value'] : $value;
|
$value = (isset($parms['value'])) ? $parms['value'] : $value;
|
||||||
$ret = (vartrue($parms['show']) ? ($value ? $value : varset($parms['empty'], $value)) : '');
|
$ret = (vartrue($parms['show']) ? ($value ? $value : varset($parms['empty'], $value)) : '');
|
||||||
//echo "<br />key=".$key."<br />value=".$value;
|
|
||||||
$ret = $ret.$this->hidden($key, $value);
|
$ret = $ret.$this->hidden($key, $value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -4039,6 +4039,10 @@ class e_form
|
|||||||
$ret = vartrue($eloptions['pre']).$this->selectbox($key, $options, $value, $eloptions).vartrue($eloptions['post']);
|
$ret = vartrue($eloptions['pre']).$this->selectbox($key, $options, $value, $eloptions).vartrue($eloptions['post']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case null:
|
||||||
|
// Possibly used in db but should not be submitted in form. @see news_extended.
|
||||||
|
break;
|
||||||
|
|
||||||
default:// No LAN necessary, debug only.
|
default:// No LAN necessary, debug only.
|
||||||
$ret = (ADMIN) ? "<span class='alert alert-error'>".LAN_ERROR." Unknown 'type' : ".$attributes['type'] ."</span>" : $value;
|
$ret = (ADMIN) ? "<span class='alert alert-error'>".LAN_ERROR." Unknown 'type' : ".$attributes['type'] ."</span>" : $value;
|
||||||
break;
|
break;
|
||||||
@@ -4338,6 +4342,8 @@ class e_form
|
|||||||
$model_required = $model->getValidationRules();
|
$model_required = $model->getValidationRules();
|
||||||
$required_help = false;
|
$required_help = false;
|
||||||
$hidden_fields = array();
|
$hidden_fields = array();
|
||||||
|
|
||||||
|
|
||||||
foreach($fdata['fields'] as $key => $att)
|
foreach($fdata['fields'] as $key => $att)
|
||||||
{
|
{
|
||||||
if($tab !== false && varset($att['tab'], 0) !== $tab)
|
if($tab !== false && varset($att['tab'], 0) !== $tab)
|
||||||
@@ -4351,7 +4357,7 @@ class e_form
|
|||||||
$key = $att['field'];
|
$key = $att['field'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($key == 'checkboxes' || $key == 'options')
|
if($key == 'checkboxes' || $key == 'options' || ($att['type'] === null))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -4389,6 +4395,8 @@ class e_form
|
|||||||
|
|
||||||
if(!vartrue($writeParms['show']))
|
if(!vartrue($writeParms['show']))
|
||||||
{
|
{
|
||||||
|
$hidden_fields[] = $this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
@@ -4415,7 +4423,7 @@ class e_form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if('hidden' === $att['type'])
|
if('hidden' === $att['type'])
|
||||||
{
|
{
|
||||||
parse_str(varset($att['writeParms']), $tmp);
|
parse_str(varset($att['writeParms']), $tmp);
|
||||||
@@ -4427,12 +4435,8 @@ class e_form
|
|||||||
}
|
}
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$leftCell = $required."<span{$required_class}>".defset(vartrue($att['title']), vartrue($att['title']))."</span>".$label;
|
$leftCell = $required."<span{$required_class}>".defset(vartrue($att['title']), vartrue($att['title']))."</span>".$label;
|
||||||
$rightCell = $this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()), $model->getId())." {$help}";
|
$rightCell = $this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()), $model->getId())." {$help}";
|
||||||
@@ -4487,7 +4491,11 @@ class e_form
|
|||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</tbody>
|
</tbody>
|
||||||
</table></fieldset>";
|
</table>";
|
||||||
|
|
||||||
|
$text .= implode("\n", $hidden_fields);
|
||||||
|
|
||||||
|
$text .= "</fieldset>";
|
||||||
|
|
||||||
$text .= vartrue($fdata['fieldset_post']);
|
$text .= vartrue($fdata['fieldset_post']);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user