function store($p_admin, $p_user_id=null) { require_once 'HTML/QuickForm.php'; $mask = $this->_getFormMask($p_admin, $p_owner); $form = new html_QuickForm('blog_comment', 'post', '', null, null, true); FormProcessor::parseArr2Form($form, $mask); if ($form->validate() && SecurityToken::isValid()) { $data = $form->getSubmitValues(); foreach ($data['BlogComment'] as $k => $v) { // clean user input if (!in_array($k, BlogComment::$m_html_allowed_fields)) { $data['BlogComment'][$k] = htmlspecialchars_array($v); } } if ($data['f_comment_id']) { foreach ($data['BlogComment'] as $k => $v) { if (is_array($v)) { foreach($v as $key => $value) { if ($value) { $string .= "$key, "; } } $v = substr($string, 0, -2); unset ($string); } $this->setProperty($k, $v); } BlogEntry::TriggerCounters(BlogComment::GetEntryId($data['comment_id'])); return true; } elseif ($this->create( $data['f_entry_id'], $p_user_id, $data['BlogComment']['user_name'], $data['BlogComment']['user_email'], $data['BlogComment']['title'], $data['BlogComment']['content'], $data['BlogComment']['fk_mood_id'])) { // admin and owner can override status setting if ($p_admin && $data['BlogComment']['admin_status']) { $this->setProperty('admin_status', $data['BlogComment']['admin_status']); } if ($p_owner && $data['BlogComment']['status']) { $this->setProperty('status', $data['BlogComment']['status']); } BlogEntry::TriggerCounters($this->getProperty('fk_entry_id')); return true; } } return false; }