function onSubmit($vals) { loader_import('siteforum.Topic'); $t = new SiteForum_Topic(); $t->add(array('name' => $vals['name'], 'description' => $vals['description'], 'sitellite_access' => $vals['sitellite_access'], 'sitellite_status' => $vals['sitellite_status'])); header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; }
function onSubmit($vals) { loader_import('siteforum.Topic'); loader_import('siteforum.Post'); $t = new SiteForum_Topic(); $t->modify($vals['id'], array('name' => $vals['name'], 'description' => $vals['description'], 'sitellite_access' => $vals['sitellite_access'], 'sitellite_status' => $vals['sitellite_status'])); $p = new SiteForum_Post(); $p->modify(array('topic_id' => $vals['id']), array('sitellite_access' => $vals['sitellite_access'], 'sitellite_status' => $vals['sitellite_status'])); header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; }
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); }
<?php // your app begins here loader_import('siteforum.Topic'); loader_import('siteforum.Filters'); $t = new SiteForum_Topic(); $t->orderBy('name asc'); $list = $t->getTopics(); /*if (loader_import ('sitetracker.SiteTracker')) { $guests = SiteTracker::get ( array ( 'api_call' => 'num_visitors_online', 'session_lifetime' => 15, ) ); } else {*/ $guests = false; //} page_title(appconf('forum_name')); echo template_simple('topic_list.spt', array('list' => $list, 'sitesearch' => @file_exists('inc/app/sitesearch/data/sitesearch.pid'), 'users' => db_shift('select count(*) from sitellite_user'), 'active' => db_shift('select count(*) from sitellite_user where session_id is not null and expires >= ?', date('Y-m-d H:i:s', time() - 3600)), 'posts' => db_shift('select count(*) from siteforum_post'), 'today' => db_shift('select count(*) from siteforum_post where ts >= ?', date('Y-m-d 00:00:00')), 'week' => db_shift('select count(*) from siteforum_post where ts >= ?', date('Y-m-d 00:00:00', time() - 604800)), 'guests' => $guests));
function getLatest($limit = 5, $topic = false) { if (session_admin()) { $perms = session_allowed_sql(); } else { $perms = session_approved_sql(); } if ($topic) { $list = db_fetch_array('select id, topic_id, user_id, ts, subject from siteforum_post where topic_id = ? and ' . $perms . ' order by ts desc limit ' . $limit, $topic); } else { $list = db_fetch_array('select id, topic_id, user_id, ts, subject from siteforum_post where ' . $perms . ' order by ts desc limit ' . $limit); } if (!$list) { return array(); } loader_import('siteforum.Topic'); $t = new SiteForum_Topic(); foreach (array_keys($list) as $k) { $list[$k]->topic_name = $t->getTitle($list[$k]->topic_id); $list[$k]->user_public = db_shift('select public from sitellite_user where username = ?', $list[$k]->user_id); } return $list; }
<?php loader_import('siteforum.Post'); loader_import('siteforum.Topic'); loader_import('siteforum.Filters'); loader_import('saf.GUI.Pager'); global $cgi; if (empty($cgi->topic)) { header('Location: ' . site_prefix() . '/index/siteforum-app'); exit; } if (!isset($cgi->offset) || !is_numeric($cgi->offset)) { $cgi->offset = 0; } $p = new SiteForum_Post(); $p->limit(appconf('limit')); $p->offset($cgi->offset); $list = $p->getThreads($cgi->topic); $pg = new Pager($cgi->offset, appconf('limit'), $p->total); $pg->setUrl(site_prefix() . '/index/siteforum-topic-action?topic=%s', $cgi->topic); $pg->getInfo(); $t = new SiteForum_Topic(); $topic = $t->getTitle($cgi->topic); page_title($topic); template_simple_register('pager', $pg); echo template_simple('thread_list.spt', array('forum_name' => appconf('forum_name'), 'topic' => $topic, 'list' => $list, 'sitesearch' => @file_exists('inc/app/sitesearch/data/sitesearch.pid'))); if (appconf('template')) { page_template(appconf('template')); }
<?php loader_import('siteforum.Topic'); $t = new SiteForum_Topic(); $t->remove($parameters['id']); header('Location: ' . site_prefix() . '/index/siteforum-app'); exit;