function onSubmit($vals) { loader_import('siteforum.Post'); loader_import('siteforum.Filters'); loader_import('siteforum.Topic'); $p = new SiteForum_Post(); if (!session_admin()) { $notice = 'no'; } else { if ($vals['notice'] == 'Make this post a notice.') { $notice = 'yes'; } else { $notice = 'no'; } } $t = new SiteForum_Topic(); $topic = $t->get($vals['topic']); if (!($res = $p->add(array('user_id' => session_username(), 'topic_id' => $vals['topic'], 'post_id' => $vals['post'], 'ts' => date('Y-m-d H:i:s'), 'subject' => $vals['subject'], 'body' => $vals['body'], 'sig' => db_shift('select sig from sitellite_user where username = ?', session_username()), 'notice' => $notice, 'sitellite_access' => $topic->sitellite_access, 'sitellite_status' => $topic->sitellite_status)))) { page_title(intl_get('Database Error')); echo '<p>' . intl_get('An error occurred. Please try again later.') . '</p>'; echo '<p>' . intl_get('Error Message') . ': ' . $p->error . '</p>'; return; } $vals['id'] = $res; if (!empty($vals['post'])) { $p->touch($vals['post']); } if ($vals['subscribe'] == 'Subscribe me to this forum thread.') { if (!$vals['post']) { $vals['post'] = $res; } db_execute('insert into siteforum_subscribe (id, post_id, user_id) values (null, ?, ?)', $vals['post'], session_username()); } $ae = appconf('admin_email'); if ($ae) { @mail($ae, intl_get('Forum Posting Notice'), template_simple('post_email.spt', $vals), 'From: ' . appconf('forum_name') . '@' . site_domain()); } $exempt = explode(',', $ae); $res = db_fetch_array('select distinct u.email, u.username from sitellite_user u, siteforum_subscribe s where s.user_id = u.username and s.post_id = ?', $vals['post']); foreach ($res as $row) { if (in_array($row->email, $exempt)) { continue; } $vals['user_id'] = $row->username; @mail($row->email, intl_get('Forum Posting Notice'), template_simple('post_email_subscriber.spt', $vals), 'From: ' . appconf('forum_name') . '@' . site_domain()); } page_title(intl_get('Message Posted')); echo template_simple('post_submitted.spt', $vals); }
function SiteforumTopicEditForm() { parent::MailForm(); $this->parseSettings('inc/app/siteforum/forms/topic/edit/settings.php'); global $cgi; page_title(intl_get('Editing Topic') . ': ' . $cgi->id); loader_import('siteforum.Topic'); $t = new SiteForum_Topic(); $topic = $t->get($cgi->id); if (!$topic) { header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; } unset($topic->sitellite_owner); unset($topic->sitellite_team); foreach (get_object_vars($topic) as $k => $v) { $this->widgets[$k]->setValue($v); } }