Exemplo n.º 1
0
 function index()
 {
     $this->load->helper('form');
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->model('user_attend_model');
     $this->load->model('blog_posts_model', 'bpm');
     $this->load->helper('reqkey');
     $reqkey = buildReqKey();
     $arr = array('talks' => $this->talks_model->getPopularTalks(), 'hot_events' => $this->event_model->getHotEvents(3), 'upcoming_events' => $this->event_model->getUpcomingEvents(3, false), 'logged' => $this->user_model->isAuth(), 'latest_blog' => $this->bpm->getLatestPost(), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     // now add the attendance data for the events
     $uid = $this->user_model->getID();
     foreach ($arr['hot_events'] as $e) {
         if ($uid) {
             $e->user_attending = $this->user_attend_model->chkAttend($uid, $e->ID);
         } else {
             $e->user_attending = false;
         }
     }
     foreach ($arr['upcoming_events'] as $e) {
         if ($uid) {
             $e->user_attending = $this->user_attend_model->chkAttend($uid, $e->ID);
         } else {
             $e->user_attending = false;
         }
     }
     $this->template->write_view('content', 'main/index', $arr, TRUE);
     $this->template->render();
 }
Exemplo n.º 2
0
 function view($id)
 {
     $this->load->helper('form');
     $this->load->library('validation');
     $this->load->library('akismet');
     $this->load->library('defensio');
     $this->load->library('spam');
     $this->load->helper('reqkey');
     $this->load->model('blog_posts_model', 'bpm');
     $this->load->model('blog_comments_model', 'bcm');
     $this->bpm->updatePostViews($id);
     $reqkey = buildReqKey();
     $fields = array('title' => 'Title', 'comment' => 'Comment', 'name' => 'Name');
     $rules = array('title' => 'required', 'comment' => 'required', 'name' => 'required');
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     if ($this->validation->run() != FALSE) {
         $arr = array('comment_type' => 'comment', 'comment_content' => $this->input->post('comment'));
         $ret = $this->akismet->send('/1.1/comment-check', $arr);
         //check with defensio
         $ec = array();
         $ec['comment'] = $this->input->post('comment');
         $def_ret = $this->defensio->check('anonymous', $ec['comment'], false, '/blog/view/' . $id);
         $is_spam = (string) $def_ret->spam;
         //check with our local filters
         $sp_ret = $this->spam->check('regex', $this->input->post('comment'));
         //passed...;
         $arr = array('title' => $this->input->post('title'), 'author_id' => (int) $this->session->userdata('ID'), 'author_name' => $this->input->post('name'), 'content' => $this->input->post('comment'), 'blog_post_id' => $id);
         //print_r($arr);
         if ($is_spam != 'true' && $sp_ret == true) {
             $this->db->insert('blog_comments', $arr);
             $subj = 'Blog comment on entry ' . $id . ' from ' . $this->config->item('site_name');
             $cont = 'Title: ' . $this->input->post('title') . "\n\n";
             $cont .= 'Content: ' . $this->input->post('comment') . "\n\n";
             $cont .= 'Post: ' . $this->config->site_url() . 'blog/view/' . $id . "\n\n";
             $cont .= 'Spam check: ' . ($ret == 'false') ? 'not spam' : 'spam caught';
             $admin_emails = $this->user_model->getSiteAdminEmail();
             foreach ($admin_emails as $user) {
                 mail($user->email, $subj, $cont, 'From: ' . $this->config->item('email_feedback'));
             }
             //redirect('blog/view/'.$id . '#comments', 'location', 302);
         }
     } else {
         //failed...
     }
     $arr = array('details' => $this->bpm->getPostDetail($id), 'is_admin' => $this->user_model->isSiteAdmin(), 'comments' => $this->bcm->getPostComments($id), 'pid' => $id, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $other_data = array('title' => 'Popular Blog Posts', 'posts' => $this->bpm->getPostDetail(), 'curr_id' => $id);
     if ($this->user_model->isAuth()) {
         $udata = $this->user_model->getUser($this->session->userdata('ID'));
         //print_r($udata);
         $arr['full_name'] = !empty($udata[0]->full_name) ? $udata[0]->full_name : $udata[0]->username;
     }
     $this->template->write('feedurl', '/feed/blog');
     $this->template->write_view('sidebar2', 'blog/_other-posts', $other_data);
     $this->template->write_view('content', 'blog/view', $arr);
     $this->template->render();
 }
Exemplo n.º 3
0
 /**
  * Displays the frontpage with the hot events, upcoming events,
  * latest blog post and more.
  *
  * @return void
  */
 function index()
 {
     $this->load->helper('form');
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->model('user_attend_model');
     $this->load->helper('reqkey');
     $reqkey = buildReqKey();
     $arr = array('talks' => $this->talks_model->getPopularTalks(), 'hot_events' => $this->event_model->getHotEvents(7), 'logged' => $this->user_model->isAuth(), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     // now add the attendance data for the hot events
     $uid = $this->user_model->getID();
     foreach ($arr['hot_events'] as $e) {
         $e->user_attending = $uid ? $this->user_attend_model->chkAttend($uid, $e->ID) : false;
     }
     $events = $this->event_model->getCurrentCfp();
     $this->template->parse_view('sidebar2', 'event/_event-cfp-sidebar', array('events' => $events));
     $this->template->write_view('content', 'main/index', $arr, true);
     $this->template->render();
 }
Exemplo n.º 4
0
 /**
  * User management page for Site admins.
  *
  * View users listing, enable/disable, etc.
  *
  * @param integer $page Number of the page to handle
  *
  * @return void
  */
 function admin($page = null)
 {
     $this->load->helper('reqkey');
     $this->load->library('validation');
     $reqkey = buildReqKey();
     $page = !$page ? 1 : $page;
     $rows_in_pg = 10;
     $offset = $page == 1 ? 1 : $page * 10;
     $all_users = $this->user_model->getAllUsers();
     $all_user_ct = count($all_users);
     $page_ct = ceil($all_user_ct / $rows_in_pg);
     $users = array_slice($all_users, $offset, $rows_in_pg);
     $fields = array('user_search' => 'Search Term');
     $rules = array('user_search' => 'required');
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     if ($this->validation->run() != false) {
         $users = $this->user_model->search($this->input->post('user_search'));
     }
     $arr = array('users' => $users, 'all_user_ct' => $all_user_ct, 'page_ct' => $page_ct, 'page' => $page, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $this->template->write_view('content', 'user/admin', $arr);
     $this->template->render();
 }
Exemplo n.º 5
0
    /**
     * Displays the details for a talk.
     *
     * @param integer     $id      the id of the talk
     * @param string|null $add_act if 'claim' tries to claim the talk
     * @param string|null $code    code to claim talk with
     *
     * @return void
     */
    function view($id, $add_act = null, $code = null)
    {
        $this->load->model('talks_model');
        $this->load->model('event_model');
        $this->load->model('invite_list_model', 'ilm');
        $this->load->model('user_attend_model');
        $this->load->model('talk_track_model', 'talkTracks');
        $this->load->model('talk_comments_model', 'tcm');
        $this->load->model('talk_speaker_model', 'talkSpeakers');
        $this->load->helper('form');
        $this->load->helper('events');
        $this->load->helper('talk');
        $this->load->helper('reqkey');
        $this->load->plugin('captcha');
        $this->load->library('defensio');
        $this->load->library('spam');
        $this->load->library('validation');
        $this->load->library('timezone');
        $this->load->library('sendemail');
        $msg = '';
        // filter it down to just the numeric characters
        if (preg_match('/[0-9]+/', $id, $m)) {
            $id = $m[0];
        } else {
            redirect('talk');
        }
        $currentUserId = $this->session->userdata('ID');
        $talk_detail = $this->talks_model->getTalks($id);
        if (empty($talk_detail)) {
            redirect('talk');
        }
        if ($talk_detail[0]->private == 'Y') {
            if (!$this->user_model->isAuth()) {
                // denied!
                redirect('event/view/' . $talk_detail[0]->eid);
            }
            // if the event for this talk is private, be sure that
            // the user is allowed
            if (!$this->ilm->isInvited($talk_detail[0]->eid, $currentUserId) && !$this->user_model->isAdminEvent($talk_detail[0]->eid)) {
                redirect('event/view/' . $talk_detail[0]->eid);
            }
        }
        $claim_status = false;
        $claim_msg = '';
        if (isset($add_act) && $add_act == 'claim') {
            // be sure they're loged in first...
            if (!$this->user_model->isAuth()) {
                //redirect to the login form
                $this->session->set_userdata('ref_url', '/talk/view/' . $id . '/claim/' . $code);
                redirect('user/login');
            } else {
                $sp = explode(',', $talk_detail[0]->speaker);
                $codes = array();
                //loop through the speakers to make the codes
                foreach ($sp as $k => $v) {
                    // we should be logged in now... lets check and
                    // see if the code is right
                    $str = buildCode($id, $talk_detail[0]->event_id, $talk_detail[0]->talk_title, trim($v));
                    $codes[] = $str;
                }
                if (in_array($code, $codes)) {
                    //TODO: linking on the display side to the right user
                    $uid = $this->session->userdata('ID');
                    $ret = $this->talks_model->linkUserRes($uid, $id, 'talk', $code);
                    if (!$ret) {
                        $claim_status = false;
                        $claim_msg = 'There was an error claiming your talk!';
                    } else {
                        $claim_status = true;
                        $claim_msg = 'Talk claimed successfully!';
                    }
                } else {
                    $claim_status = false;
                    $claim_msg = 'There was an error claiming your talk!';
                }
            }
        }
        $cl = ($r = $this->talks_model->talkClaimDetail($id)) ? $r : false;
        $rules = array('rating' => $cl && $cl[0]->userid == $currentUserId ? null : 'required');
        $fields = array('comment' => 'Comment', 'rating' => 'Rating');
        // if it's past time for the talk, they're required
        // all other times they're not required...
        if (time() >= $talk_detail[0]->date_given) {
            $rules['comment'] = 'required';
        }
        // this is for the CAPTACHA - it was disabled for authenticated users
        if (!$this->user_model->isAuth()) {
            $rules['cinput'] = 'required|callback_cinput_check';
            $fields['cinput'] = 'Captcha';
        }
        $this->validation->set_rules($rules);
        $this->validation->set_fields($fields);
        if ($this->validation->run() == false) {
            // vote processing code removed
        } else {
            $is_auth = $this->user_model->isAuth();
            $arr = array('comment_type' => 'comment', 'comment_content' => $this->input->post('your_com'));
            $priv = $this->input->post('private');
            $priv = empty($priv) ? 0 : 1;
            $anonymous = $this->input->post('anonymous');
            $anonymous = empty($anonymous) ? 0 : 1;
            if (!$is_auth) {
                $sp_ret = $this->spam->check('regex', $this->input->post('comment'));
                error_log('sp: ' . $sp_ret);
                if ($is_auth) {
                    $ec['user_id'] = $this->session->userdata('ID');
                    $ec['cname'] = $this->session->userdata('username');
                } else {
                    $ec['user_id'] = 0;
                    $ec['cname'] = $this->input->post('cname');
                }
                $ec['comment'] = $this->input->post('comment');
                $def_ret = $this->defensio->check($ec['cname'], $ec['comment'], $is_auth, '/talk/view/' . $id);
                $is_spam = (string) $def_ret->spam;
            } else {
                // They're logged in, let their comments through
                $is_spam = false;
                $sp_ret = true;
            }
            if ($is_spam != 'true' && $sp_ret == true) {
                $arr = array('talk_id' => $id, 'rating' => $this->input->post('rating'), 'comment' => $this->input->post('comment'), 'date_made' => time(), 'private' => $priv, 'active' => 1, 'user_id' => $this->user_model->isAuth() && !$anonymous ? $this->session->userdata('ID') : '0');
                $out = '';
                if ($this->input->post('edit_comment')) {
                    $cid = $this->input->post('edit_comment');
                    $uid = $this->session->userdata('ID');
                    // be sure they have the right to update the comment
                    $com_detail = $this->tcm->getCommentDetail($cid);
                    if (isset($com_detail[0]) && $com_detail[0]->user_id == $uid) {
                        $this->db->where('ID', $cid);
                        $this->db->update('talk_comments', $arr);
                        $out = 'Comment updated!';
                    } else {
                        $out = 'Error on updating comment!';
                    }
                } else {
                    $this->db->insert('talk_comments', $arr);
                    $out = 'Comment added!';
                }
                //send an email when a comment's made
                $msg = '';
                $arr['spam'] = $is_spam == 'false' ? 'spam' : 'not spam';
                foreach ($arr as $ak => $av) {
                    $msg .= '[' . $ak . '] => ' . $av . "\n";
                }
                //if its claimed, be sure to send an email to the person to tell them
                if ($cl) {
                    $this->sendemail->sendTalkComment($id, $cl[0]->email, $talk_detail, $arr);
                }
                $this->session->set_flashdata('msg', $out);
            }
            redirect('talk/view/' . $talk_detail[0]->tid . '#comments', 'location', 302);
        }
        $captcha = create_captcha();
        $this->session->set_userdata(array('cinput' => $captcha['value']));
        $reqkey = buildReqKey();
        $talk_detail = $this->talks_model->setDisplayFields($talk_detail);
        // catch this early...if it's not a valid session...
        if (empty($talk_detail)) {
            redirect('talk');
        }
        $is_talk_admin = $this->user_model->isAdminTalk($id);
        // Retrieve ALL comments, then Reformat and filter out private comments
        $all_talk_comments = $this->talks_model->getTalkComments($id, null, true);
        $talk_comments = splitCommentTypes($all_talk_comments, $is_talk_admin, $this->session->userdata('ID'));
        // also given only makes sense if there's a speaker set
        if (!empty($talk_detail[0]->speaker)) {
            $also_given = $this->talks_model->talkAlsoGiven($id, $talk_detail[0]->event_id);
            $also_given = array('talks' => $also_given, 'title' => 'Talk Also Given At...');
        }
        $user_id = $this->user_model->isAuth() ? $this->session->userdata('ID') : null;
        $speakers = $this->talkSpeakers->getSpeakerByTalkId($id);
        // check if current user is one of the approved speakers
        $is_claim_approved = false;
        foreach ($speakers as $speaker) {
            if ($speaker->speaker_id && $speaker->speaker_id == $user_id) {
                $is_claim_approved = true;
            }
        }
        $arr = array('detail' => $talk_detail[0], 'comments' => isset($talk_comments['comment']) ? $talk_comments['comment'] : array(), 'admin' => $is_talk_admin ? true : false, 'site_admin' => $this->user_model->isSiteAdmin() ? true : false, 'auth' => $this->auth, 'claimed' => $this->talks_model->talkClaimDetail($id), 'claim_status' => $claim_status, 'claim_msg' => $claim_msg, 'is_claimed' => $this->talks_model->hasUserClaimed($id) || $is_claim_approved, 'speakers' => $speakers, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey), 'user_attending' => $this->user_attend_model->chkAttend($currentUserId, $talk_detail[0]->event_id) ? true : false, 'msg' => $msg, 'track_info' => $this->talkTracks->getSessionTrackInfo($id), 'user_id' => $this->user_model->isAuth() ? $this->session->userdata('ID') : null, 'captcha' => $captcha);
        $this->template->write('feedurl', '/feed/talk/' . $id);
        if (!empty($also_given['talks'])) {
            $this->template->write_view('sidebar2', 'talk/_also_given', $also_given, true);
        }
        if (!isTalkClaimFull($arr['speakers'])) {
            $this->template->write_view('sidebar3', 'main/_sidebar-block', array('title' => 'Claiming Talks', 'content' => '<p>Claiming a talk you let us know that you were the speaker 
					for it. When you claim it (and it\'s approved by the event admins) it will 
					be linked to your account.</p><p>You\'ll also receive emails when new comments 
					are posted to 	it.</p>'));
        }
        if ($is_talk_admin) {
            $this->template->write_view('sidebar3', 'talk/modules/_talk_howto', $arr);
        }
        $this->template->write_view('content', 'talk/detail', $arr, true);
        $this->template->render();
    }
Exemplo n.º 6
0
 /**
  * Displays the details of a specific blog post.
  *
  * @param integer $id ID of the blog post to display
  *
  * @return void
  */
 function view($id)
 {
     $this->load->helper('form');
     $this->load->library('validation');
     $this->load->library('akismet');
     $this->load->library('defensio');
     $this->load->library('spam');
     $this->load->helper('reqkey');
     $this->load->model('blog_posts_model', 'blogPostsModel');
     $this->blogPostsModel->updatePostViews($id);
     $reqkey = buildReqKey();
     $arr = array('details' => $this->blogPostsModel->getPostDetail($id), 'is_admin' => $this->user_model->isSiteAdmin(), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $other_data = array('title' => 'Popular Blog Posts', 'posts' => $this->blogPostsModel->getPostDetail(), 'curr_id' => $id);
     if ($this->user_model->isAuth()) {
         $udata = $this->user_model->getUser($this->session->userdata('ID'));
         $arr['full_name'] = !empty($udata[0]->full_name) ? $udata[0]->full_name : $udata[0]->username;
     }
     $this->template->write('feedurl', '/feed/blog');
     $this->template->write_view('sidebar2', 'blog/_other-posts', $other_data);
     $this->template->write_view('content', 'blog/view', $arr);
     $this->template->render();
 }
Exemplo n.º 7
0
 /**
  * Call for Papers method
  *
  * @param null $eventId [optional] Event ID
  *
  * @return void
  */
 public function callforpapers($eventId = null)
 {
     $this->load->model('event_model', 'eventModel');
     $this->load->model('user_attend_model');
     $this->load->helper('reqkey');
     $reqkey = buildReqKey();
     $arr = array('current_cfp' => $this->eventModel->getCurrentCfp(), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     // now add the attendance data
     $uid = $this->user_model->getID();
     foreach ($arr['current_cfp'] as $e) {
         $e->user_attending = $uid ? $this->user_attend_model->chkAttend($uid, $e->ID) : false;
     }
     $this->template->write_view('content', 'event/callforpapers', $arr);
     $this->template->render();
 }
Exemplo n.º 8
0
 /**
  * Displays the details of a user.
  *
  * @param string|integer $uid Either the username or id of the user
  *
  * @return void
  */
 function view($uid)
 {
     $this->load->model('talks_model');
     $this->load->model('pending_talk_claims_model');
     $this->load->model('user_attend_model', 'uam');
     $this->load->model('user_admin_model', 'uadmin');
     $this->load->helper('reqkey');
     $this->load->helper('url');
     $this->load->library('gravatar');
     $reqkey = buildReqKey();
     // see if we have a sort type and apply it
     $p = explode('/', uri_string());
     $sort_type = isset($p[4]) ? $p[4] : null;
     $details = $this->user_model->getUserById($uid);
     // sf the user doesn't exist, redirect!
     if (!isset($details[0])) {
         redirect();
     }
     $imgStr = $this->gravatar->displayUserImage($uid, $details[0]->email, 80);
     if (empty($details[0])) {
         redirect();
     }
     // reset our UID based on what we found...
     $uid = $details[0]->ID;
     $curr_user = $this->session->userdata('ID');
     $arr = array('details' => $details, 'comments' => $this->talks_model->getUserComments($uid), 'talks' => $this->talks_model->getUserTalks($uid), 'is_admin' => $this->user_model->isSiteAdmin(), 'is_attending' => $this->uam->getUserAttending($uid), 'my_attend' => $this->uam->getUserAttending($curr_user), 'uadmin' => array('events' => $this->uadmin->getUserTypes($uid, array('event')), 'talks' => $this->talks_model->getSpeakerTalks($uid, true), 'pending_talks' => $this->pending_talk_claims_model->getTalkClaimsForUser($uid)), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey), 'sort_type' => $sort_type, 'gravatar' => $imgStr);
     if ($curr_user) {
         $arr['pending_evt'] = $this->uadmin->getUserTypes($curr_user, array('event'), true);
     } else {
         $arr['pending_evt'] = array();
     }
     $this->template->write_view('content', 'user/view', $arr);
     $this->template->render();
 }
Exemplo n.º 9
0
 /**
  * Displays the details for a talk.
  *
  * @param integer     $id      the id of the talk
  * @param string|null $add_act if 'claim' tries to claim the talk
  * @param string|null $code    code to claim talk with
  *
  * @return void
  */
 function view($id, $add_act = null, $code = null)
 {
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->model('event_comments_model');
     $this->load->model('invite_list_model', 'ilm');
     $this->load->model('user_attend_model');
     $this->load->model('talk_track_model', 'talkTracks');
     $this->load->model('talk_comments_model', 'tcm');
     $this->load->model('talk_speaker_model', 'talkSpeakers');
     $this->load->helper('form');
     $this->load->helper('events');
     $this->load->helper('talk');
     $this->load->helper('reqkey');
     $this->load->plugin('captcha');
     $this->load->library('spamcheckservice', array('api_key' => $this->config->item('akismet_key')));
     $this->load->library('spam');
     $this->load->library('validation');
     $this->load->library('timezone');
     $this->load->library('sendemail');
     $msg = '';
     // filter it down to just the numeric characters
     if (preg_match('/[0-9]+/', $id, $m)) {
         $id = $m[0];
     } else {
         redirect('talk');
     }
     $currentUserId = $this->session->userdata('ID');
     $talk_detail = $this->talks_model->getTalks($id);
     if (empty($talk_detail)) {
         redirect('talk');
     }
     if ($talk_detail[0]->private == 'Y') {
         if (!$this->user_model->isAuth()) {
             // denied!
             redirect('event/view/' . $talk_detail[0]->eid);
         }
         // if the event for this talk is private, be sure that
         // the user is allowed
         if (!$this->ilm->isInvited($talk_detail[0]->eid, $currentUserId) && !$this->user_model->isAdminEvent($talk_detail[0]->eid)) {
             redirect('event/view/' . $talk_detail[0]->eid);
         }
     }
     $claim_status = false;
     $claim_msg = '';
     if (isset($add_act) && $add_act == 'claim') {
         // be sure they're loged in first...
         if (!$this->user_model->isAuth()) {
             //redirect to the login form
             $this->session->set_userdata('ref_url', '/talk/view/' . $id . '/claim/' . $code);
             redirect('user/login');
         } else {
             $sp = explode(',', $talk_detail[0]->speaker);
             $codes = array();
             //loop through the speakers to make the codes
             foreach ($sp as $k => $v) {
                 // we should be logged in now... lets check and
                 // see if the code is right
                 $str = buildCode($id, $talk_detail[0]->event_id, $talk_detail[0]->talk_title, trim($v));
                 $codes[] = $str;
             }
             if (in_array($code, $codes)) {
                 //TODO: linking on the display side to the right user
                 $uid = $this->session->userdata('ID');
                 $ret = $this->talks_model->linkUserRes($uid, $id, 'talk', $code);
                 if (!$ret) {
                     $claim_status = false;
                     $claim_msg = 'There was an error claiming your talk!';
                 } else {
                     $claim_status = true;
                     $claim_msg = 'Talk claimed successfully!';
                 }
             } else {
                 $claim_status = false;
                 $claim_msg = 'There was an error claiming your talk!';
             }
         }
     }
     $cl = ($r = $this->talks_model->talkClaimDetail($id)) ? $r : array();
     $already_rated = false;
     if ($this->user_model->isAuth()) {
         // Find out if there is at least 1 comment that is made by our
         // user for this talk
         foreach ($this->talks_model->getUserComments($this->user_model->getId()) as $comment) {
             if ($comment->talk_id == $id) {
                 $already_rated = $comment->ID;
                 break;
             }
         }
     }
     // build array of userIds with claim to this talk
     $claim_user_ids = array();
     foreach ($cl as $claim_item) {
         $claim_user_ids[] = $claim_item->userid;
     }
     $current_comment_id = 0;
     if ($this->input->post('edit_comment')) {
         $current_comment_id = $this->input->post('edit_comment');
     }
     // comment form validation rules:
     // rating:
     //      1. rating_check to ensure between 0 and 5
     //      2. required field if not already commented
     // comment:
     //      1. duplicate_comment_check to ensure exact comment isn't posted twice
     $rating_rule = 'callback_rating_check';
     $rating_rule .= in_array($currentUserId, $claim_user_ids) || $already_rated ? '' : '|required';
     $rules = array('rating' => $rating_rule, 'comment' => "callback_duplicate_comment_check[{$id}!{$current_comment_id}]");
     $fields = array('comment' => 'Comment', 'rating' => 'Rating');
     // this is for the CAPTACHA - it was disabled for authenticated users
     if (!$this->user_model->isAuth()) {
         $rules['cinput'] = 'required|callback_cinput_check';
         $fields['cinput'] = 'Captcha';
     }
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     if ($this->validation->run() == false) {
         // vote processing code removed
     } else {
         $is_auth = $this->user_model->isAuth();
         $arr = array('comment_type' => 'comment', 'comment_content' => $this->input->post('your_com'));
         $priv = $this->input->post('private');
         $priv = empty($priv) ? 0 : 1;
         $anonymous = $this->input->post('anonymous');
         $anonymous = empty($anonymous) ? 0 : 1;
         if (!$is_auth) {
             $sp_ret = $this->spam->check('regex', $this->input->post('comment'));
             error_log('sp: ' . $sp_ret);
             if ($is_auth) {
                 $ec['user_id'] = $this->session->userdata('ID');
                 $ec['cname'] = $this->session->userdata('username');
             } else {
                 $ec['user_id'] = 0;
                 $ec['cname'] = $this->input->post('cname');
             }
             $ec['comment'] = $this->input->post('comment');
             $acceptable_comment = $this->spamcheckservice->isCommentAcceptable(array('comment' => $ec['comment']));
         } else {
             // They're logged in, let their comments through
             $acceptable_comment = true;
             $is_spam = false;
             $sp_ret = true;
         }
         if ($acceptable_comment && $sp_ret == true) {
             $arr = array('talk_id' => $id, 'rating' => $this->input->post('rating'), 'comment' => $this->input->post('comment'), 'date_made' => time(), 'private' => $priv, 'active' => 1, 'user_id' => $this->user_model->isAuth() && !$anonymous ? $this->session->userdata('ID') : '0');
             $out = '';
             if ($this->input->post('edit_comment')) {
                 $cid = $this->input->post('edit_comment');
                 $uid = $this->session->userdata('ID');
                 // be sure they have the right to update the comment
                 $com_detail = $this->tcm->getCommentDetail($cid);
                 if (isset($com_detail[0]) && $com_detail[0]->user_id == $uid) {
                     // if the user has already rated and we're not editing that comment,
                     // then the rating for this comment is zero
                     if ($already_rated && $already_rated != $cid) {
                         $arr['rating'] = 0;
                     }
                     $commentEditTime = $com_detail[0]->date_made + $this->config->item('comment_edit_time');
                     if (time() >= $commentEditTime) {
                         $out = 'This comment has passed its edit-time.' . ' You cannot edit this comment anymore.';
                     } else {
                         $this->db->where('ID', $cid);
                         // unset date made.
                         unset($arr['date_made']);
                         if ($com_detail[0]->rating == 0) {
                             $arr['rating'] = 0;
                         }
                         $this->db->update('talk_comments', $arr);
                         $out = 'Comment updated!';
                     }
                 } else {
                     $out = 'Error on updating comment!';
                 }
             } else {
                 $this->db->insert('talk_comments', $arr);
                 $out = 'Comment added!';
             }
             //send an email when a comment's made
             $msg = '';
             $arr['spam'] = $is_spam == 'false' ? 'spam' : 'not spam';
             foreach ($arr as $ak => $av) {
                 $msg .= '[' . $ak . '] => ' . $av . "\n";
             }
             //if its claimed, be sure to send an email to the person to tell them
             if ($cl) {
                 $this->sendemail->sendTalkComment($id, $cl[0]->email, $talk_detail, $arr);
             }
             $this->session->set_flashdata('msg', $out);
         }
         redirect('talk/view/' . $talk_detail[0]->tid . '#comments', 'location', 302);
     }
     $captcha = create_captcha();
     $this->session->set_userdata(array('cinput' => $captcha['value']));
     $reqkey = buildReqKey();
     $talk_detail = $this->talks_model->setDisplayFields($talk_detail);
     // catch this early...if it's not a valid session...
     if (empty($talk_detail)) {
         redirect('talk');
     }
     $is_talk_admin = $this->user_model->isAdminTalk($id);
     // Retrieve ALL comments, then Reformat and filter out private comments
     $all_talk_comments = $this->talks_model->getTalkComments($id, null, true);
     $talk_comments = splitCommentTypes($all_talk_comments, $is_talk_admin, $this->session->userdata('ID'));
     // also given only makes sense if there's a speaker set
     if (!empty($talk_detail[0]->speaker)) {
         $also_given = $this->talks_model->talkAlsoGiven($id, $talk_detail[0]->event_id);
         $also_given = array('talks' => $also_given, 'title' => 'Talk Also Given At...');
     }
     $user_id = $this->user_model->isAuth() ? $this->session->userdata('ID') : null;
     $speakers = $this->talkSpeakers->getSpeakerByTalkId($id);
     // check if current user is one of the approved speakers
     $is_claim_approved = false;
     foreach ($speakers as $speaker) {
         if ($speaker->speaker_id && $speaker->speaker_id == $user_id) {
             $is_claim_approved = true;
         }
     }
     if (isset($talk_comments['comment'])) {
         for ($i = 0; $i < count($talk_comments['comment']); $i++) {
             if ($talk_comments['comment'][$i]->user_id != 0) {
                 $talk_comments['comment'][$i]->user_comment_count = $this->event_comments_model->getUserCommentCount($talk_comments['comment'][$i]->user_id) + $this->tcm->getUserCommentCount($talk_comments['comment'][$i]->user_id);
             }
         }
     }
     $arr = array('detail' => $talk_detail[0], 'comments' => isset($talk_comments['comment']) ? $talk_comments['comment'] : array(), 'admin' => $is_talk_admin ? true : false, 'site_admin' => $this->user_model->isSiteAdmin() ? true : false, 'auth' => $this->auth, 'claimed' => $this->talks_model->talkClaimDetail($id), 'claim_status' => $claim_status, 'claim_msg' => $claim_msg, 'is_claimed' => $this->talks_model->hasUserClaimed($id) || $is_claim_approved, 'speakers' => $speakers, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey), 'user_attending' => $this->user_attend_model->chkAttend($currentUserId, $talk_detail[0]->event_id) ? true : false, 'msg' => $msg, 'track_info' => $this->talkTracks->getSessionTrackInfo($id), 'user_id' => $this->user_model->isAuth() ? $this->session->userdata('ID') : null, 'captcha' => $captcha, 'alreadyRated' => $already_rated);
     $this->template->write('feedurl', '/feed/talk/' . $id);
     if (!empty($also_given['talks'])) {
         $this->template->write_view('sidebar2', 'talk/_also_given', $also_given, true);
     }
     if (!isTalkClaimFull($arr['speakers'])) {
         $this->template->write_view('sidebar3', 'main/_sidebar-block', array('title' => 'Claiming Talks', 'content' => '<p>Is this your talk? Claim it! By doing so it
                 lets us know you are the speaker. Once your claim is
                 verified by event administration it will be linked to your
                 account.</p>'));
     }
     if ($is_talk_admin) {
         $this->template->write_view('sidebar3', 'talk/modules/_talk_howto', $arr);
     }
     $this->template->write_view('content', 'talk/detail', $arr, true);
     $this->template->render();
 }
Exemplo n.º 10
0
 /**
  * Displays a list of tracks for the given event id.
  *
  * @param integer $id The id of the event
  *
  * @return void
  */
 function tracks($id)
 {
     if (!$this->user_model->isSiteAdmin() && !$this->user_model->isAdminEvent($id)) {
         redirect();
     }
     $this->load->model('event_track_model', 'etm');
     $this->load->model('event_model');
     $this->load->helper('reqkey');
     $reqkey = buildReqKey();
     $arr = array('detail' => $this->event_model->getEventDetail($id), 'tracks' => $this->etm->getEventTracks($id), 'admin' => $this->user_model->isAdminEvent($id) ? true : false, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $this->template->write_view('content', 'event/tracks', $arr);
     $this->template->render();
 }
Exemplo n.º 11
0
 /**
  * Displays the search page and results when used.
  *
  * @return void
  */
 function index()
 {
     $this->load->helper('form');
     $this->load->library('validation');
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->helper('reqkey');
     $results = array();
     $rules = array('search_term' => 'required');
     $fields = array('search_term' => 'Search Term', 'start_mo' => 'Start Month', 'start_day' => 'Start Day', 'start_yr' => 'Start Year', 'end_mo' => 'End Month', 'end_day' => 'End Day', 'end_yr' => 'End Year');
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     //success! search the talks and events
     if ($this->validation->run() == true) {
         $query = 'q:' . urlencode($this->input->post('search_term'));
         $start = 0;
         $end = 0;
         $start_mo = $this->input->post('start_mo');
         $end_mo = $this->input->post('end_mo');
         if (!empty($start_mo)) {
             $start = sprintf('%04d-%02d-%02d', $this->input->post('start_yr'), $this->input->post('start_mo'), $this->input->post('start_day'));
             $query .= '/start:' . $start;
         }
         if (!empty($end_mo)) {
             $end = sprintf('%04d-%02d-%02d', $this->input->post('end_yr'), $this->input->post('end_mo'), $this->input->post('end_day'));
             $query .= '/end:' . $end;
         }
         redirect('search/' . $query, 'location', 302);
     }
     $results = null;
     $rsegments = $this->uri->rsegments;
     array_shift($rsegments);
     // Remove controller
     array_shift($rsegments);
     // Remove action
     if (count($rsegments) > 0) {
         $rsegments = array_slice($rsegments, 0, 3);
         $search_term = null;
         $start = null;
         $end = null;
         foreach ($rsegments as $val) {
             if (false !== ($pos = strpos($val, 'q:'))) {
                 $search_term = substr($val, 2);
                 continue;
             }
             if (false !== ($pos = strpos($val, 'start:'))) {
                 $start = substr($val, 6);
                 continue;
             }
             if (false !== ($pos = strpos($val, 'end:'))) {
                 $end = substr($val, 4);
                 continue;
             }
         }
         if (!empty($search_term)) {
             $this->validation->search_term = urldecode($search_term);
             if (null !== $start) {
                 $start = max(0, @strtotime($start));
                 $this->validation->start_mo = date('m', $start);
                 $this->validation->start_day = date('d', $start);
                 $this->validation->start_yr = date('Y', $start);
             }
             if (null !== $end) {
                 $end = max(0, @strtotime($end));
                 $this->validation->end_mo = date('m', $end);
                 $this->validation->end_day = date('d', $end);
                 $this->validation->end_yr = date('Y', $end);
             }
             //check to see if they entered a date and set that first
             $search_term = urldecode($search_term);
             $results = array('talks' => $this->talks_model->search($search_term, $start, $end), 'events' => $this->event_model->search($search_term, $start, $end), 'users' => $this->user_model->search($search_term, $start, $end));
         }
     }
     $reqkey = buildReqKey();
     $arr = array('results' => $results, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $this->template->write_view('content', 'search/main', $arr, true);
     $this->template->render();
 }
Exemplo n.º 12
0
 function view($id, $add_act = null, $code = null)
 {
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->model('invite_list_model', 'ilm');
     $this->load->model('user_attend_model');
     $this->load->model('user_admin_model', 'uam');
     $this->load->model('talk_track_model', 'ttm');
     $this->load->model('talk_comments_model', 'tcm');
     $this->load->model('talk_speaker_model', 'tsm');
     $this->load->helper('form');
     $this->load->helper('events');
     $this->load->helper('talk');
     $this->load->helper('reqkey');
     $this->load->plugin('captcha');
     $this->load->library('akismet');
     $this->load->library('defensio');
     $this->load->library('spam');
     $this->load->library('validation');
     $this->load->library('timezone');
     $this->load->library('sendemail');
     $msg = '';
     $view_private = false;
     // Filter it down to just the numeric characters
     if (preg_match('/[0-9]+/', $id, $m)) {
         $id = $m[0];
     } else {
         redirect('talk');
     }
     $currentUserId = $this->session->userdata('ID');
     $talk_detail = $this->talks_model->getTalks($id);
     if (empty($talk_detail)) {
         redirect('talk');
     }
     if ($talk_detail[0]->private == 'Y') {
         if (!$this->user_model->isAuth()) {
             /* denied! */
             redirect('event/view/' . $talk_detail[0]->eid);
         }
         // If the event for this talk is private, be sure that the user is allowed
         if (!$this->ilm->isInvited($talk_detail[0]->eid, $currentUserId) && !$this->user_model->isAdminEvent($talk_detail[0]->eid)) {
             redirect('event/view/' . $talk_detail[0]->eid);
         }
     }
     //$evt_started = $this->timezone->talkEvtStarted($id);
     $claim_status = false;
     $claim_msg = '';
     if (isset($add_act) && $add_act == 'claim') {
         //be sure they're loged in first...
         if (!$this->user_model->isAuth()) {
             //redirect to the login form
             $this->session->set_userdata('ref_url', '/talk/view/' . $id . '/claim/' . $code);
             redirect('user/login');
         } else {
             $sp = explode(',', $talk_detail[0]->speaker);
             $codes = array();
             //loop through the speakers to make the codes
             foreach ($sp as $k => $v) {
                 //we should be logged in now...lets check and see if the code is right
                 //$str='ec'.str_pad(substr($id,0,2),2,0,STR_PAD_LEFT).str_pad($talk_detail[0]->event_id,2,0,STR_PAD_LEFT);
                 //$str.=substr(md5($talk_detail[0]->talk_title.$k),5,5);
                 $str = buildCode($id, $talk_detail[0]->event_id, $talk_detail[0]->talk_title, trim($v));
                 $codes[] = $str;
             }
             if (in_array($code, $codes)) {
                 //TODO: linking on the display side to the right user
                 $uid = $this->session->userdata('ID');
                 $ret = $this->talks_model->linkUserRes($uid, $id, 'talk', $code);
                 if (!$ret) {
                     $claim_status = false;
                     $claim_msg = 'There was an error claiming your talk!';
                 } else {
                     $claim_status = true;
                     $claim_msg = 'Talk claimed successfully!';
                 }
             } else {
                 $claim_status = false;
                 $claim_msg = 'There was an error claiming your talk!';
             }
         }
     }
     $cl = ($r = $this->talks_model->isTalkClaimed($id)) ? $r : false;
     $cap_arr = array('img_path' => $_SERVER['DOCUMENT_ROOT'] . '/inc/img/captcha/', 'img_url' => '/inc/img/captcha/', 'img_width' => '130', 'img_height' => '30');
     $rules = array('rating' => $cl && $cl[0]->userid == $currentUserId ? null : 'required');
     $fields = array('comment' => 'Comment', 'rating' => 'Rating');
     // if it's past time for the talk, they're required
     // All other times they're not required...
     if (time() >= $talk_detail[0]->date_given) {
         $rules['comment'] = 'required';
     }
     // This is for the CAPTACHA - it was disabled for authenticatied users
     //if(!$this->user_model->isAuth()){
     //	$rules['cinput']	= 'required|callback_cinput_check';
     //	$fields['cinput']	= 'Captcha';
     //}
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     if ($this->validation->run() == FALSE) {
         // vote processing code removed
     } else {
         $is_auth = $this->user_model->isAuth();
         $arr = array('comment_type' => 'comment', 'comment_content' => $this->input->post('your_com'));
         $ret = $this->akismet->send('/1.1/comment-check', $arr);
         $priv = $this->input->post('private');
         $priv = empty($priv) ? 0 : 1;
         if (!$is_auth) {
             $sp_ret = $this->spam->check('regex', $this->input->post('comment'));
             error_log('sp: ' . $sp_ret);
             if ($is_auth) {
                 $ec['user_id'] = $this->session->userdata('ID');
                 $ec['cname'] = $this->session->userdata('username');
             } else {
                 $ec['user_id'] = 0;
                 $ec['cname'] = $this->input->post('cname');
             }
             $ec['comment'] = $this->input->post('comment');
             $def_ret = $this->defensio->check($ec['cname'], $ec['comment'], $is_auth, '/talk/view/' . $id);
             $is_spam = (string) $def_ret->spam;
             if (strtolower($ec['cname']) == 'dynom') {
                 $is_spam = 'false';
             }
             //hack to allow comments for now
         } else {
             // They're logged in, let their comments through
             $is_spam = false;
             $sp_ret = true;
         }
         if ($is_spam != 'true' && $sp_ret == true) {
             $arr = array('talk_id' => $id, 'rating' => $this->input->post('rating'), 'comment' => $this->input->post('comment'), 'date_made' => time(), 'private' => $priv, 'active' => 1, 'user_id' => $this->user_model->isAuth() ? $this->session->userdata('ID') : '0');
             $out = '';
             if ($this->input->post('edit_comment')) {
                 $cid = $this->input->post('edit_comment');
                 $uid = $this->session->userdata('ID');
                 // Be sure they have the right to update the comment
                 $com_detail = $this->tcm->getCommentDetail($cid);
                 if (isset($com_detail[0]) && $com_detail[0]->user_id == $uid) {
                     $this->db->where('ID', $cid);
                     $this->db->update('talk_comments', $arr);
                     $out = 'Comment updated!';
                 } else {
                     $out = 'Error on updating comment!';
                 }
             } else {
                 $this->db->insert('talk_comments', $arr);
                 $out = 'Comment added!';
             }
             //send an email when a comment's made
             $msg = '';
             $arr['spam'] = $ret == 'false' ? 'spam' : 'not spam';
             foreach ($arr as $ak => $av) {
                 $msg .= '[' . $ak . '] => ' . $av . "\n";
             }
             @mail($this->config->item('email_admin'), 'Comment on talk ' . $id, $msg, 'From: ' . $this->config->item('email_comments'));
             //if its claimed, be sure to send an email to the person to tell them
             if ($cl) {
                 $this->sendemail->sendTalkComment($id, $cl[0]->email, $talk_detail, $arr);
             }
             $this->session->set_flashdata('msg', $out);
         }
         redirect('talk/view/' . $talk_detail[0]->tid . '#comments', 'location', 302);
     }
     //$cap = create_captcha($cap_arr);
     //$this->session->set_userdata(array('cinput'=>$cap['word']));
     $reqkey = buildReqKey();
     $talk_detail = $this->talks_model->setDisplayFields($talk_detail);
     // catch this early...if it's not a valid session...
     if (empty($talk_detail)) {
         redirect('talk');
     }
     $is_talk_admin = $this->user_model->isAdminTalk($id);
     // Check to see if they can view private comments....
     $view_private = $this->user_model->canViewPrivateComments($talk_detail[0]->eid, $id) ? true : false;
     $event_claims = $this->event_model->getClaimedTalks($talk_detail[0]->eid);
     $talk_comments = splitCommentTypes($this->talks_model->getTalkComments($id, null, $view_private));
     $also_given = $this->talks_model->talkAlsoGiven($id, $talk_detail[0]->event_id);
     $also_given = array('talks' => $also_given, 'title' => 'Talk Also Given At...');
     $arr = array('detail' => $talk_detail[0], 'comments' => isset($talk_comments['comment']) ? $talk_comments['comment'] : array(), 'admin' => $is_talk_admin ? true : false, 'site_admin' => $this->user_model->isSiteAdmin() ? true : false, 'auth' => $this->auth, 'claimed' => $this->talks_model->isTalkClaimed($id), 'claims' => $event_claims, 'claim_status' => $claim_status, 'claim_msg' => $claim_msg, 'claim_details' => $this->uam->getTalkClaims($id), 'speakers' => $this->tsm->getSpeakerByTalkId($id), 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey), 'user_attending' => $this->user_attend_model->chkAttend($currentUserId, $talk_detail[0]->event_id) ? true : false, 'msg' => $msg, 'track_info' => $this->ttm->getSessionTrackInfo($id), 'user_id' => $this->user_model->isAuth() ? $this->session->userdata('ID') : null);
     $this->template->write('feedurl', '/feed/talk/' . $id);
     if (!empty($also_given['talks'])) {
         $this->template->write_view('sidebar2', 'talk/_also_given', $also_given, TRUE);
     }
     $this->template->write_view('content', 'talk/detail', $arr, TRUE);
     $this->template->render();
 }
Exemplo n.º 13
0
 /**
  * Displays the search page and results when used.
  *
  * @return void
  */
 function index()
 {
     $this->load->helper('form');
     $this->load->library('validation');
     $this->load->model('talks_model');
     $this->load->model('event_model');
     $this->load->helper('reqkey');
     $results = array();
     $rules = array('search_term' => 'required');
     $fields = array('search_term' => 'Search Term', 'start_mo' => 'Start Month', 'start_day' => 'Start Day', 'start_yr' => 'Start Year', 'end_mo' => 'End Month', 'end_day' => 'End Day', 'end_yr' => 'End Year');
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     //success! search the talks and events
     if ($this->validation->run() == true) {
         $query = 'q:' . urlencode($this->input->post('search_term'));
         // Replace urlencoded / (%2F) with something that's URL safe and not
         // likely to ever really be searched on: _|_. Apache does not allow
         // URLs with encoded /'s for security reasons. It doesn't even get
         // to mod_rewrite. Which is why searches with / got a 404 previously.
         $query = str_replace('%2F', self::SLASH_REPLACEMENT, $query);
         $start = 0;
         $end = 0;
         $start_mo = $this->input->post('start_mo');
         $end_mo = $this->input->post('end_mo');
         if (!empty($start_mo)) {
             $start = sprintf('%04d-%02d-%02d', $this->input->post('start_yr'), $this->input->post('start_mo'), $this->input->post('start_day'));
             $query .= '/start:' . $start;
         }
         if (!empty($end_mo)) {
             $end = sprintf('%04d-%02d-%02d', $this->input->post('end_yr'), $this->input->post('end_mo'), $this->input->post('end_day'));
             $query .= '/end:' . $end;
         }
         redirect('search/' . $query, 'location', 302);
     }
     $results = null;
     $rsegments = $this->uri->rsegments;
     array_shift($rsegments);
     // Remove controller
     array_shift($rsegments);
     // Remove action
     if (count($rsegments) > 0) {
         $rsegments = array_slice($rsegments, 0, 3);
         $search_term = null;
         $start = null;
         $end = null;
         foreach ($rsegments as $val) {
             if (false !== ($pos = strpos($val, 'q:'))) {
                 $search_term = substr($val, 2);
                 continue;
             }
             if (false !== ($pos = strpos($val, 'start:'))) {
                 $start = substr($val, 6);
                 continue;
             }
             if (false !== ($pos = strpos($val, 'end:'))) {
                 $end = substr($val, 4);
                 continue;
             }
         }
         if (!empty($search_term)) {
             // Put the /'s back. If there's a _|_ in the search term, assume
             // it was originally a /
             $search_term = str_replace(self::SLASH_REPLACEMENT, '%2F', $search_term);
             $this->validation->search_term = urldecode($search_term);
             if (null !== $start) {
                 $start = max(0, @strtotime($start));
                 $this->validation->start_mo = date('m', $start);
                 $this->validation->start_day = date('d', $start);
                 $this->validation->start_yr = date('Y', $start);
             }
             if (null !== $end) {
                 $end = max(0, @strtotime($end));
                 $this->validation->end_mo = date('m', $end);
                 $this->validation->end_day = date('d', $end);
                 $this->validation->end_yr = date('Y', $end);
             }
             //check to see if they entered a date and set that first
             $search_term = urldecode($search_term);
             $results = array('talks' => $this->talks_model->search($search_term, $start, $end), 'events' => $this->event_model->search($search_term, $start, $end), 'users' => $this->user_model->search($search_term, $start, $end));
         }
     }
     $reqkey = buildReqKey();
     $arr = array('results' => $results, 'reqkey' => $reqkey, 'seckey' => buildSecFile($reqkey));
     $this->template->write_view('content', 'search/main', $arr, true);
     $this->template->render();
 }