当前位置: 首页>>代码示例>>PHP>>正文


PHP buildCode函数代码示例

本文整理汇总了PHP中buildCode函数的典型用法代码示例。如果您正苦于以下问题:PHP buildCode函数的具体用法?PHP buildCode怎么用?PHP buildCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了buildCode函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: talkClaimDetail

 /**
  * 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;
 }
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:48,代码来源:talks_model.php

示例2: isTalkClaimed

    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;
    }
开发者ID:jeremykendall,项目名称:joind.in,代码行数:38,代码来源:talks_model.php

示例3: view

    /**
     * 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);
//.........这里部分代码省略.........
开发者ID:rickogden,项目名称:joind.in,代码行数:101,代码来源:talk.php

示例4: view

 /**
  * 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
//.........这里部分代码省略.........
开发者ID:nbalmer,项目名称:joind.in,代码行数:101,代码来源:talk.php

示例5: codes

 /**
  * ?
  *
  * @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();
 }
开发者ID:jeremykendall,项目名称:joind.in,代码行数:74,代码来源:event.php

示例6: run

 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')));
     }
 }
开发者ID:bradley-holt,项目名称:joind.in,代码行数:81,代码来源:Claim.php

示例7: claim

 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();
 }
开发者ID:bradley-holt,项目名称:joind.in,代码行数:47,代码来源:talk.php

示例8: claim

 /**
  * 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();
 }
开发者ID:bradley-holt,项目名称:joind.in,代码行数:47,代码来源:event.php


注:本文中的buildCode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。