コード例 #1
0
 public function sendDigest()
 {
     $smarty = \CODOF\Smarty\Single::get_instance(SYSPATH . 'CODOF/Forum/Notification/Digest/', true);
     $user = \CODOF\User\User::get();
     $smarty->assign('site_title', \CODOF\Util::get_opt('site_title'));
     $smarty->assign('brand_img', \CODOF\Util::get_opt('brand_img'));
     $smarty->assign('username', $user->username);
     $date = date('Y-F-j-S', time());
     list($year, $month, $day, $ordinal) = explode("-", $date);
     $dayInfo = array("year" => $year, "month" => $month, "day" => $day, "ordinal" => $ordinal);
     $smarty->assign('dayInfo', $dayInfo);
     $smarty->assign('statistics_img', 'http://i.imgur.com/7sBa4Ow.png');
     //RAW
     $smarty->assign('create_new_img', 'http://i.imgur.com/E0MhBwI.png');
     //RAW
     $notifier = new \CODOF\Forum\Notification\Notifier();
     $events = $notifier->get(TRUE, 0, 'asc');
     //get all unread notifications
     $sortedEvents = $this->sort($events);
     $smarty->assign('events', $sortedEvents);
     $smarty->assign('new_posts', $this->newPosts . " ");
     $smarty->assign('new_topics', $this->newTopics . " ");
     if (empty($events)) {
         $smarty->assign('nothing_new', true);
     } else {
         $smarty->assign('nothing_new', false);
     }
     $frequency = $user->prefers('notification_frequency');
     $html = $smarty->fetch("{$frequency}.tpl");
     $text = $smarty->fetch("{$frequency}Text.tpl");
     $this->daily = $html;
     $this->dailyText = $text;
     $mailer = new \CODOF\Forum\Notification\Mail();
     $mailer->setHTML($mailer->replace_tokens($this->dailyText));
     $mailer->to = $user->mail;
     $mailer->subject = _t('Daily digest - ') . \CODOF\Util::get_opt('site_title');
     $mailer->message = $this->daily;
     $mailer->send_mail();
 }
コード例 #2
0
 public static function load($tpl, $css_files = array(), $js_files = array())
 {
     \CODOF\Util::inc_global_views();
     //This sets all variables which will be used by the theme
     require CURR_THEME_PATH . 'theme.php';
     $page = array();
     \CODOF\Hook::call('before_site_head');
     \CODOF\Hook::call('tpl_before_' . str_replace("/", "_", $tpl));
     $asset = new \CODOF\Asset\Stream();
     $page["head"]["css"] = $asset->dumpCSS();
     //\CODOF\Theme\Js::sort_js();
     $page["head"]["js"] = $asset->dumpJS('head');
     $page["body"]["js"] = $asset->dumpJS('body');
     $page["defer"] = json_encode($asset->deferred());
     //after all modification its time for smarty to display the mod data
     $smarty = Single::get_instance();
     $site_title = \CODOF\Util::get_opt('site_title');
     $sub_title = \CODOF\Store::get('sub_title');
     $smarty->assign('site_title', $site_title);
     $smarty->assign('sub_title', $sub_title);
     $smarty->assign('home_title', \CODOF\Store::get('home_title', _t('All topics')));
     $smarty->assign('site_url', \CODOF\Util::get_opt('site_url'));
     $smarty->assign('logged_in', \CODOF\User\CurrentUser\CurrentUser::loggedIn());
     $smarty->assign('login_url', \CODOF\User\User::getLoginUrl());
     $smarty->assign('logout_url', \CODOF\User\User::getLogoutUrl());
     $smarty->assign('register_url', \CODOF\User\User::getRegisterUrl());
     $smarty->assign('profile_url', \CODOF\User\User::getProfileUrl());
     $smarty->assign('page', $page);
     $smarty->assign('CSRF_token', \CODOF\Access\CSRF::get_token());
     $smarty->assign('php_time_now', time());
     $category = new \CODOF\Forum\Category();
     $canCreateTopicInAtleastOneCategory = $category->canCreateTopicInAtleastOne();
     $smarty->assign('canCreateTopicInAtleastOneCategory', $canCreateTopicInAtleastOneCategory);
     $page = \CODOF\Store::get('rel:canonical_page', isset($_GET['u']) ? $_GET['u'] : '');
     $smarty->assign('canonical', rtrim(RURI, '/') . strip_tags($page));
     if (\CODOF\Store::has('rel:prev')) {
         $smarty->assign('rel_prev', \CODOF\Store::get('rel:prev'));
     }
     if (\CODOF\Store::has('rel:next')) {
         $smarty->assign('rel_next', \CODOF\Store::get('rel:next'));
     }
     if (\CODOF\Store::has('meta:robots')) {
         $smarty->assign('meta_robots', \CODOF\Store::get('meta:robots'));
     }
     $og = array("type" => \CODOF\Store::get('og:type', 'website'), "title" => \CODOF\Store::get('og:title', $sub_title . ' | ' . $site_title));
     if (\CODOF\Store::has('og:url')) {
         $og['url'] = \CODOF\Store::get('og:url');
     }
     if (\CODOF\Store::has('og:desc')) {
         $og['desc'] = \CODOF\Store::get('og:desc');
     } else {
         $og['desc'] = \CODOF\Util::get_opt('site_description');
     }
     if (\CODOF\Store::has('og:image')) {
         $og['image'] = \CODOF\Store::get('og:image');
     }
     $smarty->assign('og', $og);
     if (\CODOF\Store::has('article:published')) {
         $smarty->assign('article_published', \CODOF\Store::get('article:published'));
     }
     if (\CODOF\Store::has('article:modified')) {
         $smarty->assign('article_modified', \CODOF\Store::get('article:modified'));
     }
     $I = \CODOF\User\User::get();
     //current user details
     $smarty->assign('I', $I);
     $smarty->assign('can_moderate_posts', $I->can('moderate posts'));
     if (\CODOF\User\CurrentUser\CurrentUser::loggedIn()) {
         $notifier = new \CODOF\Forum\Notification\Notifier();
         $smarty->assign('unread_notifications', $notifier->getNoOfUnread());
     }
     $html = $smarty->fetch("{$tpl}.tpl");
     require_once SYSPATH . 'Ext/simplehtmldom/simple_html_dom.php';
     $dom = new \simple_html_dom();
     $dom->load($html, true, false);
     //let plugins modify html
     \CODOF\Hook::call('tpl_after_' . str_replace("/", "_", $tpl), $dom);
     \CODOF\Hook::call('after_site_head', $dom);
     echo $dom->save();
 }
コード例 #3
0
 public function edit()
 {
     //hacking attempt
     if ($_POST['end_of_line'] != "") {
         exit;
     }
     $tid = (int) $_POST['tid'];
     $topic = new \CODOF\Forum\Topic($this->db);
     $topic_info = $topic->get_topic_info($tid);
     //i have come to edit the topic
     $tuid = $topic_info['uid'];
     $cid = $topic_info['cat_id'];
     $topic_status = (int) $topic_info['topic_status'];
     $req_cid = (int) $_POST['cat'];
     $topicNeedsToBeMoved = $cid != $req_cid;
     $has_permission = $topic->canViewTopic($tuid, $cid, $tid) && $topic->canEditTopic($tuid, $cid, $tid);
     $user = \CODOF\User\User::get();
     if ($topicNeedsToBeMoved) {
         $has_permission = $has_permission && $user->can('move topics', $req_cid);
     }
     if ($has_permission) {
         if (isset($_POST['title']) && isset($_POST['cat']) && isset($_POST['imesg']) && isset($_POST['omesg'])) {
             if ($topicNeedsToBeMoved) {
                 \DB::table(PREFIX . 'codo_notify_subscribers')->where('tid', '=', $tid)->update(array('cid' => $req_cid));
                 //above also checks whether category exists
                 \DB::table(PREFIX . 'codo_categories')->where('cat_id', $cid)->update(array('no_topics' => \DB::raw('no_topics-1'), 'no_posts' => \DB::raw('no_posts-' . $topic_info['no_posts'])));
                 \DB::table(PREFIX . 'codo_categories')->where('cat_id', $req_cid)->update(array('no_topics' => \DB::raw('no_topics+1'), 'no_posts' => \DB::raw('no_posts+' . $topic_info['no_posts'])));
                 $cid = $req_cid;
                 if ($_POST['notify'] === 'true') {
                     $categoryName = $topic->getCatNameFromId($cid);
                     $topicData = array("label" => 'Topic moved', "cid" => $req_cid, "tid" => $tid, "pid" => $topic_info['post_id'], "notification" => "%actor% moved <b>%title%</b> to %category%", "bindings" => array("title" => \CODOF\Util::start_cut($topic_info['title'], 100), "category" => $categoryName));
                     $notifier = new \CODOF\Forum\Notification\Notifier();
                     $notifier->queueNotify('ofTopic', $topicData);
                 }
             }
             $sticky = $_POST['sticky'] === "true" ? 'yes' : 'no';
             $frontpage = $_POST['frontpage'] === "true" ? 'yes' : 'no';
             $new_topic_status = $topic_status;
             if ($sticky == 'yes' && $user->can('make sticky')) {
                 if ($frontpage == 'yes') {
                     $new_topic_status = \CODOF\Forum\Forum::STICKY;
                 } else {
                     $new_topic_status = \CODOF\Forum\Forum::STICKY_ONLY_CATEGORY;
                 }
             }
             if ($sticky == 'no' && \CODOF\Forum\Forum::isSticky($topic_status)) {
                 $new_topic_status = \CODOF\Forum\Forum::APPROVED;
             }
             $topic->edit_topic($cid, $tid, $topic_info['post_id'], $_POST['title'], $_POST['imesg'], $_POST['omesg'], $new_topic_status);
         }
         if (isset($_POST['tags']) && $user->can('add tags')) {
             $tags = $_POST['tags'];
             $dbTags = $topic->getTags($tid);
             $_tags = $topic->getTagStatus($dbTags, $tags);
             $topic->insertTags($tid, $_tags['toInsert']);
             $topic->removeTags($tid, $_tags['toDelete']);
         }
         echo json_encode(array('tid' => $tid));
     } else {
         echo _t("You do not have permission to ") . _t("edit this topic");
     }
 }
コード例 #4
0
            $time = $_GET['time'];
        } else {
            $time = time();
        }
        $events = $notifier->getLatest($time);
        if (!empty($events)) {
            $lastEventTime = $events[0]['created'];
            $time = $lastEventTime;
        }
        $notifications = $notifier->getFormattedForInline($events);
        echo json_encode(array("events" => $notifications, "time" => $time));
    }
});
dispatch_get('Ajax/notifications/all', function () {
    if (Request::valid($_GET['_token'])) {
        $notifier = new \CODOF\Forum\Notification\Notifier();
        $notifications = $notifier->get();
        echo json_encode($notifier->getFormattedForInline($notifications));
    }
});
//search: from query
dispatch_get('Ajax/topics/get_topics', function () {
    if (Request::valid($_GET['token'])) {
        $topics = new Controller\Ajax\forum\topics();
        $list = $topics->get_topics($_GET['from'], isset($_GET['str']));
        echo json_encode($list);
    }
});
dispatch_get('Ajax/topics/mark_read', function () {
    if (Request::valid($_GET['token'])) {
        $tracker = new CODOF\Forum\Tracker();