/**
  * Find details on claims of a talk
  *
  * @param integer $tid      Talk ID
  * @param boolean $show_all Switch to show/hide
  *
  * @return array $talks Talk claim data
  */
 public function talkClaimDetail($tid, $show_all = false)
 {
     $this->load->helper("events");
     $sql = sprintf('
         select
             u.username,
             u.email,
             ts.speaker_id uid,
             ts.talk_id rid,
             u.ID userid,
             t.talk_title,
             t.event_id,
             ts.speaker_name speaker
         from
             user u,
             talks t,
             talk_speaker ts
         where
             u.ID = ts.speaker_id and
             ts.talk_id = t.ID and
             t.ID = %s
     ', $this->db->escape($tid));
     if (!$show_all) {
         $sql .= " and (ts.status != 'pending' OR ts.status IS NULL)";
     }
     $query = $this->db->query($sql);
     $talks = $query->result();
     //echo '<pre>'; print_r($ret); echo '</pre>';
     foreach ($talks as $k => $talk) {
         $codes = array();
         $speakers = array();
         foreach (explode(',', $talk->speaker) as $ik => $iv) {
             $codes[] = buildCode($talk->rid, $talk->event_id, $talk->talk_title, trim($iv));
             $speakers[] = trim($iv);
         }
         $talks[$k]->codes = $codes;
         $talks[$k]->speakers = $speakers;
     }
     return $talks;
 }
Example #2
0
    public function isTalkClaimed($tid)
    {
        $sql = sprintf('
			select
				u.username,
				u.email,
				ua.uid,
				ua.rid,
				ua.rcode,
				u.ID userid,
				t.talk_title,
				t.event_id,
				t.speaker
			from
				user u,
				user_admin ua,
				talks t
			where
				u.ID=ua.uid and
				ua.rid=%s and
				ua.rcode!=\'pending\' and
				t.ID=ua.rid
		', $this->db->escape($tid));
        $q = $this->db->query($sql);
        $ret = $q->result();
        //echo '<pre>'; print_r($ret); echo '</pre>';
        foreach ($ret as $k => $v) {
            $codes = array();
            $speakers = array();
            foreach (explode(',', $v->speaker) as $ik => $iv) {
                $codes[] = buildCode($v->rid, $v->event_id, $v->talk_title, trim($iv));
                $speakers[] = trim($iv);
            }
            $ret[$k]->codes = $codes;
            $ret[$k]->speakers = $speakers;
        }
        return $ret;
    }
Example #3
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();
    }
Example #4
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();
 }
Example #5
0
 /**
  * ?
  *
  * @param integer $id The id of the event
  *
  * @todo fill in description, I do not know it's function
  *
  * @return void
  */
 function codes($id)
 {
     $this->load->helper('form');
     $this->load->library('validation');
     $this->load->library('events');
     $this->load->helper('url');
     $this->load->helper('events');
     if (!$this->user_model->isSiteAdmin() && !$this->user_model->isAdminEvent($id)) {
         redirect();
     }
     $rules = array();
     $fields = array();
     $codes = array();
     $full_talks = array();
     $this->load->model('event_model');
     //make our code list for the talks
     $talks = $this->event_model->getEventTalks($id);
     foreach ($talks as $k => $v) {
         $sp = explode(',', $v->speaker);
         foreach ($sp as $sk => $sv) {
             //$str='ec'.str_pad(substr($v->ID,0,2),2,0,STR_PAD_LEFT) .
             //  str_pad($v->event_id,2,0,STR_PAD_LEFT);
             //$str.=substr(md5($v->talk_title.$sk),5,5);
             $str = buildCode($v->ID, $v->event_id, $v->talk_title, trim($sv));
             $codes[] = $str;
             $obj = clone $v;
             $obj->code = $str;
             $obj->speaker = trim($sv);
             $full_talks[] = $obj;
             //$rules['email_'.$v->ID]='trim|valid_email';
             $rules['email_' . $v->ID] = 'callback_chk_email_check';
             $fields['email_' . $v->ID] = 'speaker email';
         }
     }
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     $cl = $this->event_model->getClaimedTalks($id, $talks);
     foreach ($cl as $k => $v) {
         //$cstr='ec'.str_pad(substr($v->rid,0,2),2,0,STR_PAD_LEFT) .
         //  str_pad($v->tdata['event_id'],2,0,STR_PAD_LEFT);
         //$cstr.=substr(md5($v->tdata['talk_title'].$sk),5,5);
         $sp = explode(',', $v->tdata['speaker']);
         foreach ($sp as $spk => $spv) {
             $code = buildCode($v->rid, $v->tdata['event_id'], $v->tdata['talk_title'], trim($spv));
             if ($code == $v->rcode) {
                 $cl[$k]->code = $code;
             }
         }
     }
     $arr = array('talks' => $talks, 'full_talks' => $full_talks, 'codes' => $codes, 'details' => $this->event_model->getEventDetail($id), 'claimed' => $cl);
     if ($this->validation->run() != false) {
         foreach ($talks as $k => $v) {
             $pv = $this->input->post('email_' . $v->ID);
             $chk = $this->input->post('email_chk_' . $v->ID);
             if (!empty($pv) && $chk == 1) {
                 //these are the ones we need to send the email to these
                 $this->events->sendCodeEmail($pv, $codes[$k], $arr['details'], $v->ID);
             }
         }
     } else {
         /*echo 'fail';*/
     }
     $this->template->write_view('content', 'event/codes', $arr, true);
     $this->template->render();
 }
Example #6
0
 function run()
 {
     $this->CI->load->library('wsvalidate');
     $this->CI->load->model('user_admin_model');
     $this->CI->load->model('user_model');
     $this->CI->load->model('talks_model');
     $this->CI->load->model('event_model');
     $rules = array('talk_id' => 'required|istalk');
     $tid = $this->xml->action->talk_id;
     $ret = $this->CI->wsvalidate->validate($rules, $this->xml->action);
     if (!$ret) {
         if ($this->CI->wsvalidate->validate_loggedin() || $this->isValidLogin($this->xml)) {
             $uid_session = $this->CI->session->userdata('ID');
             if (empty($uid_session)) {
                 //They're not logged in, coming from the web service
                 // If it is, we need to be sure they've given us the user to add the claim for
                 // can only claim talks for ourselves - use logged in user
                 $username = $this->xml->auth->user;
                 if (!isset($username)) {
                     return array('output' => 'json', 'data' => array('items' => array('msg' => 'Fail: Username required!')));
                 }
                 $this->CI->load->model('user_model');
                 $udata = $this->CI->user_model->getUser($username);
                 if (!empty($udata)) {
                     $uid = $udata[0]->ID;
                 } else {
                     return array('output' => 'json', 'data' => array('items' => array('msg' => 'Fail: User not found!')));
                 }
             } else {
                 // They're logged in, so let's go with that user
                 $uid = $this->CI->session->userdata('ID');
             }
             $ret = $this->CI->talks_model->getTalks($tid);
             $talk_det = $ret[0];
             $arr = array('uid' => $uid, 'rid' => $tid, 'rtype' => 'talk', 'rcode' => 'pending');
             // If we're a site admin, we can add without having to get approval
             // This will be coming from the API
             if (isset($this->xml->auth->user)) {
                 $is_site_admin = $this->CI->user_model->isSiteAdmin($this->xml->auth->user);
                 if ($is_site_admin) {
                     $this->CI->load->helper('events_helper');
                     $c_name = $udata[0]->full_name;
                     $arr['rcode'] = buildCode($tid, $talk_det->eid, $talk_det->talk_title, $c_name);
                 }
             }
             // Be sure we don't already have a claim pending
             $q = $this->CI->db->get_where('user_admin', $arr);
             $ret = $q->result();
             if (isset($ret[0]->ID)) {
                 return array('output' => 'json', 'data' => array('items' => array('msg' => 'Fail: Duplicate Claim!')));
             } else {
                 $to = array();
                 $admin_emails = $this->CI->user_model->getSiteAdminEmail();
                 foreach ($admin_emails as $user) {
                     $to[] = $user->email;
                 }
                 // See if there's an admin for the event
                 $evt_admin = $this->CI->event_model->getEventAdmins($talk_det->event_id);
                 if (count($evt_admin) > 0) {
                     foreach ($evt_admin as $k => $v) {
                         $to[] = $v->email;
                     }
                 }
                 //insert a row into user_admin for the user/talk ID but with a code of "pending"
                 $this->CI->db->insert('user_admin', $arr);
                 //send an email about the claim
                 $subj = 'Talk claim submitted! Go check!';
                 $msg = sprintf("\nTalk claim has been submitted for talk \"%s\"\n\nVisit the link below to approve or deny the talk. Note: you must\nbe logged in to get to the \"Claims\" page for the event!\n\n%sevent/claim/%s\n\t\t\t\t    ", $talk_det->talk_title, $this->CI->config->site_url(), $talk_det->event_id);
                 foreach ($to as $email_addr) {
                     mail($email_addr, $this->CI->config->item('site_name') . ': Talk claim submitted! Go check!', $msg, 'From: ' . $this->CI->config->item('email_feedback'));
                 }
                 //return the success message
                 return array('output' => 'json', 'data' => array('items' => array('msg' => 'Success')));
             }
         } else {
             return array('output' => 'json', 'data' => array('items' => array('msg' => 'redirect:/user/login')));
         }
     } else {
         return array('output' => 'json', 'data' => array('items' => array('msg' => 'Fail')));
     }
 }
Example #7
0
 function claim()
 {
     if (!$this->user_model->isSiteAdmin()) {
         redirect();
     }
     $this->load->model('user_admin_model', 'uam');
     $this->load->library('validation');
     $this->load->library('sendemail');
     $this->load->helper('events_helper');
     $rules = array();
     $fields = array();
     //$this->validation->set_rules($rules);
     //$this->validation->set_fields($fields);
     $claims = $this->uam->getPendingClaims();
     $approved = 0;
     $deleted = 0;
     foreach ($claims as $k => $v) {
         //print_r($v);
         //first check to see if it was approved
         $chk = $this->input->post('claim_' . $v->ua_id);
         if (!empty($chk)) {
             // Split the speakers on the commas and see if we have a match on the name
             $names = explode(',', $v->speaker);
             foreach ($names as $nk => $nv) {
                 if (trim($nv) == $v->claiming_name) {
                     // match!
                     $code = buildCode($v->talk_id, $v->eid, $v->talk_title, $v->claiming_name);
                     $this->db->where('ID', $v->ua_id);
                     $this->db->update('user_admin', array('rcode' => $code));
                 }
             }
             //send an email to the person claiming to let them know it was approved
             $this->sendemail->claimSuccess($v->email, $v->talk_title, $v->event_name);
             $approved++;
             unset($claims[$k]);
         }
         $chk = $this->input->post('del_claim_' . $v->ua_id);
         if (!empty($chk)) {
             $this->db->delete('user_admin', array('ID' => $v->ua_id));
             $deleted++;
             unset($claims[$k]);
         }
     }
     $arr = array('claims' => $claims, 'approved' => $approved, 'deleted' => $deleted);
     $this->template->write_view('content', 'talk/claim', $arr);
     $this->template->render();
 }
Example #8
0
 /**
  * Allows a user to claim an event - adds a pending row to the admin table
  * for the site admins to go in and approve
  */
 function claim($eid)
 {
     if ($this->user_model->isSiteAdmin() || $this->user_model->isAdminEvent($eid)) {
         //they're okay
     } else {
         redirect('event/view/' . $eid);
     }
     $this->load->model('user_admin_model', 'uam');
     $this->load->helper('events_helper');
     $this->load->library('sendemail');
     $ret = $this->uam->getPendingClaims('talk', $eid);
     $claim = $this->input->post('claim');
     $sub = $this->input->post('sub');
     // If we have claims to process...
     if ($claim && count($claim) > 0 && isset($sub)) {
         foreach ($claim as $k => $v) {
             // p[0] is record from $ret, p[1] is the user ID, p[2] is the session ID
             $p = explode('_', $k);
             if ($v == 'approve') {
                 $t_id = $p[2];
                 $t_title = $ret[$p[0]]->talk_title;
                 $c_name = $ret[$p[0]]->claiming_name;
                 $code = buildCode($t_id, $eid, $t_title, $c_name);
                 // Put the code in the database to claim their talk!
                 $this->db->where('ID', $ret[$p[0]]->ua_id);
                 $this->db->update('user_admin', array('rcode' => $code));
                 $email = $ret[$p[0]]->email;
                 $evt_name = $ret[$p[0]]->event_name;
                 $this->sendemail->claimSuccess($email, $t_title, $evt_name);
                 unset($ret[$p[0]]);
             } else {
                 // Remove the claim...it's not valid
                 $tdata = array('rid' => $p[2], 'rtype' => 'talk', 'rcode' => 'pending');
                 $this->db->delete('user_admin', $tdata);
                 unset($ret[$p[0]]);
             }
         }
     }
     // Data to pass out to the view
     $arr = array('claims' => $ret, 'eid' => $eid);
     $this->template->write_view('content', 'event/claim', $arr);
     $this->template->render();
 }