Moderators Kyle Posted March 12, 2011 Moderators Report Share Posted March 12, 2011 Hey Guys, I'm trying to firgure out what's wrong. So I don't want any pilots to access the retired pilots public profiles and here's my code from profile.php. if(!pilot::retired()) { $this->set('message', 'Sorry! This Profile Is Not Available! '); $this->render('core_error.tpl'); return; } Can anyone help me to guide in the right direction and I'll be happy to give you 1+ rep if you helped me. Thanks! Quote Link to comment Share on other sites More sharing options...
Tom Posted March 12, 2011 Report Share Posted March 12, 2011 Assuming you're working within the view function, place the following somewhere after $userinfo is defined. if($userinfo->retired == 1) { $this->set('message', 'Sorry! This Profile Is Not Available!'); $this->render('core_error.tpl'); return; } Hopefully should work 1 Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 27, 2011 Author Moderators Report Share Posted March 27, 2011 Nope didn't work, Not sure why. Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 28, 2011 Author Moderators Report Share Posted March 28, 2011 Anyone help me please! Quote Link to comment Share on other sites More sharing options...
Tom Posted March 28, 2011 Report Share Posted March 28, 2011 Could you paste from the start of the index function? 1 Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 28, 2011 Author Moderators Report Share Posted March 28, 2011 Is this your looking for. I ripped it off my porfile.php.... class Profile extends CodonModule { public function index() { if(!Auth::LoggedIn()) { $this->set('message', 'You must be logged in to access this feature!'); $this->render('core_error.tpl'); return; } /* * This is from /profile/editprofile */ if(isset($this->post->action)) { if($this->post->action == 'saveprofile') { $this->save_profile_post Quote Link to comment Share on other sites More sharing options...
Tom Posted March 28, 2011 Report Share Posted March 28, 2011 My bad you want the view function... Assuming you haven't modified it, and I haven't modified it (taking this from EUG profile.php which I may have edited): public function view($pilotid='') { if(!is_numeric($pilotid)) { preg_match('/^([A-Za-z]*)(\d*)/', $pilotid, $matches); $code = $matches[1]; $pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET'); } $userinfo = PilotData::getPilotData($pilotid); if($userinfo->retired == '1'){ $this->set('message', 'Sorry, this profile is not available.'); $this->render('core_error.tpl'); return; } $this->title = 'Profile of '.$userinfo->firstname.' '.$userinfo->lastname; $this->set('userinfo', $userinfo); $this->set('allfields', PilotData::GetFieldData($pilotid, false)); $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid)); $this->set('pilotcode', PilotData::GetPilotCode($userinfo->code, $userinfo->pilotid)); $this->set('allawards', AwardsData::GetPilotAwards($userinfo->pilotid)); $this->render('pilot_public_profile.tpl'); $this->render('pireps_viewall.tpl'); } 1 Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 28, 2011 Author Moderators Report Share Posted March 28, 2011 Yep it does work now. Thanks for your help Tom, I had a mistake in the coding, so i now understand. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.