예제 #1
0
 public function deleteIssue()
 {
     if (Auth::user()->isAdmin()) {
         $issue_id = Input::get('issue_id');
         $deletedRatings = Rating::where('issue_id', '=', $issue_id)->delete();
         $deletedIssueFollows = IssueFollow::where('issue_id', '=', $issue_id)->delete();
         $issue = Issue::find($issue_id);
         $issue->delete();
     } else {
         return App::abort(404);
     }
 }
예제 #2
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), array('email' => 'required|max:50|email|unique:users', 'username' => 'required|max:20|min:3|unique:users', 'password' => 'required|min:6', 'password_again' => 'required|same:password'));
     if ($validator->fails()) {
         return Redirect::route('create') > withErrors($validator)->withInput();
     } else {
         //create user account
         $user = User::create(array('email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'code' => str_random(60), 'active' => 1));
         //normally active = 0 but until we can get email validation working it will stay 1);
         $user->save();
         $user->sex = Input::get('sex');
         $user->birth_month = Input::get('birth_month');
         $user->birth_day = Input::get('birth_day');
         $user->birth_year = Input::get('birth_year');
         $user->party = Input::get('party');
         $user->bio = Input::get('bio');
         //Upload Image
         $file = Input::file('photo');
         if (isset($file)) {
             if ($file->isValid()) {
                 $destinationPath = public_path() . '/assets/images/avatars/';
                 // The destination were you store the image.
                 $filename = $file->getClientOriginalName();
                 $file->move($destinationPath, $filename);
                 $user->pic_url = '/assets/images/avatars/' . $filename;
             }
         }
         $user->save();
         /* $filename           = $file->getClientOriginalName(); // Original file name that the end user used for it.
          			 $mime_type          = $file->getMimeType(); // Gets this example image/png
         			 $extension          = $file->getClientOriginalExtension(); // The original extension that the user used example .jpg or .png.
          			try{ $upload_success     = $file->move($destinationPath, $filename); // Now we move the file to its new home.
         			} catch (Exception $e) {return 'Caught exception image upload: '.$e->getMessage();}
                                */
         // This is were you would store the image path in a table
         $issues = Issue::all();
         foreach ($issues as $issue) {
             $issue_checkbox = Input::get($issue->id);
             if (isset($issue_checkbox)) {
                 $issues_follows = IssueFollow::create(array('issue_id' => $issue_checkbox, 'user_id' => $user->id));
                 $issues_follows->save();
             }
         }
         //Redirect to login page - added to redirect to home upon successful account
         $auth = Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'active' => 1));
         return Redirect::route('myprofile');
     }
     // else
     /*
     	if ($user){
             
     	//send email here
     		Mail::send(/*'emails.activate',*/
     /*'activate',
     		array('link' =>URL::route('activate',$code), 'username'=>$username),function($message) use ($user){
     	       return $message->to($user->email,$user->username)->subject('Activate your account');
     		});
     			
     				return Redirect::route('home')
     				->with('global','Your account has been created! We have sent you an email to activate your account');
     			
     		  
                }*/
     //if ($user)
 }
예제 #3
0
 public function updateIssuesFollowed()
 {
     //Make a list of all issues user is currently following. Then check against that list with edit form input
     //Dont create new issue follow records for old follows
     //Make sure to delete issues un-checked that were previously followed
     $issues_already_followed = Auth::user()->issues;
     $issues_already_followed_array[] = array();
     $i = 0;
     foreach ($issues_already_followed as $issue_followed) {
         $issues_already_followed_array[$i++] = $issue_followed->id;
     }
     $issues = Issue::all();
     foreach ($issues as $issue) {
         $issue_checkbox = Input::get($issue->id);
         if (in_array($issue->id, $issues_already_followed_array)) {
             if (!isset($issue_checkbox)) {
                 /*delete issue follow*/
                 $issue_follow = IssueFollow::where('issue_id', '=', $issue->id)->where('user_id', '=', Auth::user()->id);
                 $issue_follow->delete();
             }
         } else {
             if (isset($issue_checkbox)) {
                 $issue_follow = IssueFollow::create(array('issue_id' => $issue_checkbox, 'user_id' => Auth::user()->id));
                 $issue_follow->save();
             }
         }
     }
     //Redirect to login page - added to redirect to home upon successful account
     return Redirect::route('edit-myprofile', '#issues');
     //issues
 }