mentors

mentors Commit Details


Date:2014-07-12 23:02:04 (10 years 5 months ago)
Author:Right Or Wrong
Branch:develop
Commit:9f2eae2d8b4cb561dd4e7ccd2993a9601d5e7f63
Parents: 725160e25c0c8d1a7c856574e0d401206e7dffef
Message:added some email functionality

Changes:

File differences

app/controllers/EmailController.php
99
1010
1111
12
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1329
1430
1531
......
2036
2137
2238
23
39
40
41
2442
2543
2644
......
3351
3452
3553
36
37
38
3954
40
55
56
57
58
59
60
61
4162
4263
4364
44
65
4566
4667
4768
4869
49
70
5071
51
52
53
54
55
56
72
5773
58
59
60
61
74
75
6276
63
64
65
66
67
68
69
77
78
79
80
81
82
83
7084
7185
7286
7387
7488
7589
76
77
90
91
92
7893
7994
8095
......
132147
133148
134149
150
151
152
153
154
135155
136156
*/
public function index()
{
$sent_emails = SentEmail::all();
$received = ReceivedEmail::all();
$user = Auth::user()->level;
if(!$user == 'admin')
{
return View::make('users.profile')
->with('sent', $sent_emails)
->with('received', $received);
}else
{
return View::make('admin.index')
->with('sent', $sent_emails)
->with('received', $received);
}
}
*/
public function create()
{
return View::make('emails.create');
$user = Auth::user();
return View::make('emails.create')->with('user', $user);
}
{
$user_id = Auth::id();
$from_address = Auth::user()->email;
$to_address = Input::get('to_address');
$title = Input::get('title');
$message = Input::get('message');
$valid = Validator::make(array($to_address, $title, $message), SentEmail::$rules);
$rules = array(
'to' => 'required|email',
'subject' => 'required',
'message' => 'required'
);
$valid = Validator::make(array(Input::only('to', 'subject', 'message')), $rules);
if($valid->fails())
{
return Redirect::route('emails/create')
return Redirect::route('emails.create')
->withInput(Input::all())
->withErrors($valid);
}else
{
$recepient = User::where('email', '=', $to_address)->get();
$recepient = User::where('email', '=', Input::get('to'))->first();
$response = Mail::queue('emails.email', array('name'=> $recepient->first), function($message) use ($recepient)
{
$message->to($to_address, $recepient->first . ' '. $recepient->last)->subject($title);
});
if(!$response)
Mail::queue('users.welcome', array('name'=> $recepient->first), function($message) use ($recepient)
{
Session::flash('message', 'We were unable to send your email. Please try again later');
return Redirect::route('emails.create')->withInput(Input::all());
}
$message->to($recepient->email, $recepient->first . ' '. $recepient->last)->subject(\Input::get('subject'));
});
$sentEmail = new SentEmail;
$sentEmail->user_id = $user_id;
$sentEmail->from_address = $from_address;
$sentEmail->to_address = $to_address;
$sentEmail->title = $title;
$sentEmail->message = $message;
$sentEmail = SentEmail::create(array(
'user_id' => $user_id,
'from_address' => $from_address,
'to_address' => Input::get('to'),
'subject' => Input::get('subject'),
'message' => Input::get('message')
));
if($sentEmail->save())
{
return Redirect::route('user');
}else
{
Session::flash('message', 'Something bad happened.')
return Redirect::route('emails/create')
Session::flash('message', 'Something bad happened.');
return Redirect::route('emails.create')
->withInput(Input::all());
}
}
$email->delete();
}
public function sendEmail($address, $recepient, $subject)
{
return;
}
}
app/controllers/ProjectsController.php
4343
4444
4545
46
47
46
47
4848
4949
5050
public function store()
{
$rules = array(
'title' => 'required|min:5',
'link' => 'required|url',
'title' => 'required|min:5',
'link' => 'required|url',
'language' => 'required'
);
app/database/migrations/2014_07_12_172800_create_sent_emails_table.php
1717
1818
1919
20
21
22
20
21
22
2323
2424
2525
......
2929
3030
3131
32
33
34
32
33
34
3535
3636
3737
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->string('from_address', 100);
$table->string('to_address', 100);
$table->string('title', 100);
$table->string('from', 100);
$table->string('to', 100);
$table->string('subject', 100);
$table->text('message');
$table->timestamps();
});
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->string('from_address', 100);
$table->string('to_address', 100);
$table->string('title', 100);
$table->string('from', 100);
$table->string('to', 100);
$table->string('subject', 100);
$table->text('message');
$table->timestamps();
});
app/models/ReceivedEmail.php
88
99
1010
11
11
1212
1313
14
15
16
17
14
15
16
17
1818
1919
protected $dates = ['deleted_at'];
protected $fillable = array('user_id','from_address', 'to_address', 'title', 'message');
protected $fillable = array('user_id','from', 'to', 'subject', 'message');
protected static $rules = array(
'from_address' => 'required|email',
'to_address' => 'required|email',
'title' => 'required',
'message' => 'required',
'from' => 'required|email',
'to' => 'required|email',
'subject' => 'required',
'message' => 'required',
);
}
app/models/SentEmail.php
88
99
1010
11
12
13
14
15
16
17
18
11
12
1913
protected $dates = ['deleted_at'];
protected $fillable = array('user_id','from_address', 'to_address', 'title', 'message');
protected static $rules = array(
'from_address' => 'required|email',
'to_address' => 'required|email',
'title' => 'required',
'message' = 'required',
);
protected $fillable = array('user_id','from', 'to', 'subject', 'message');
}
app/routes.php
3838
3939
4040
41
4142
4243
4344
......
6465
6566
6667
67
68
6869
6970
7071
Route::get('mentors', array('as' => 'mentors', 'uses' => 'UserController@mentors'));
Route::get('mentees', array('as' => 'mentees', 'uses' => 'UserController@mentees'));
Route::resource('projects', 'ProjectsController');
Route::resource('emails', 'EmailController');
});
Route::post('admin/user/contact', array('uses' => 'AdminController@contactUser'));
Route::post('admin/user/revoke', array('uses' => 'AdminController@revokeAccess'));
Route::get('admin/users/matches', array('as' => 'matches', 'uses' => 'AdminController@showMatches'));
Route::resource('emails', 'EmailController');
});
app/views/admin/index.blade.php
2727
2828
2929
30
30
3131
3232
3333
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
<a class="navbar-brand" href="/">
{{ HTML::image("images/mentconnect.png", "editor", array("width" => "150px", "height" => "30px")) }}
</a>
</div>
app/views/emails/create.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
<title>{{ $user->first}}- Mentconnect</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/spacelab/bootstrap.min.css">
{{HTML::style('css/userprofile.css')}}
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<nav class="navbar navbar-inverse container" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
{{HTML::link('/', 'Mentconnect', array('class' => 'navbar-brand'))}}
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Welcome... {{ $user->first }}<b class="caret"></b></a>
<ul class="dropdown-menu">
<li align="center" class="well">
{{HTML::image('/'.$user->photo, 'profile', array('class' => 'img-responsive'))}}<a class="change" href="">Change Picture</a></div>
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="row well">
<div class="col-lg-3"></div>
<div id="signup-content">
{{ Form::open(array('route' => 'emails.store', 'class' => 'form-horizontal')) }}
<div class="container padded">
<div class="col-lg-6">
<div class="form-group">
<label for="first">To</label>
{{Form::email('to_address', \Input::old('to_address'), array('class' => 'form-control form-control-bordered', 'tabindex' => '1'))}} <span class="pull-right">{{$errors->first('to_address')}}</span>
</div>
<div class="form-group">
<label for="last">Subject</label>
{{ Form::text('subject', \Input::old('subject'), array('class' => 'form-control form-control-bordered', 'tabindex' => '2')) }} <span class="pull-right"> {{$errors->first('subject')}}</span>
</div>
<div class="form-group">
<label for="language">Message</label>
{{ Form::textarea('message', \Input::old('message'), array('class' => 'form-control form-control-bordered',
'tabindex' => '3')) }}<span class="pull-right"> {{$errors->first('message') }}</span>
</div>
<div class="row" id="signup-bottom-row">
{{Form::submit('Send', array('class' => 'btn btn-primary btn-large submit-button'))}}
</div>
</div>
</div>
</div>
{{ Form::close() }}
<div class="col-lg-3"></div>
</div>
</div>
</body>
</html>
app/views/users/profile.blade.php
66
77
88
9
9
1010
1111
1212
13
14
1315
1416
1517
......
4547
4648
4749
48
4950
5051
5152
5253
53
54
5455
5556
5657
......
7071
7172
7273
73
74
7475
7576
7677
......
8081
8182
8283
83
84
8485
8586
8687
......
124125
125126
126127
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
128
163129
164
130
165131
166132
167133
<!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
<title>{{ $user->first}}- Mentconnect</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/slate/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/spacelab/bootstrap.min.css">
{{HTML::style('css/userprofile.css')}}
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
</head>
<body>
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="row well">
<div class="col-md-2">
<ul class="nav nav-pills nav-stacked well">
<li class="active"><a href="#"><i class="fa fa-envelope"></i> Compose</a></li>
<li class="active "><a href="/emails/create"><i class="fa fa-envelope"></i> Compose</a></li>
<li><a href="/"><i class="fa fa-home"></i> Home</a></li>
<li><a href="/users"><i class="fa fa-user"></i> Profile</a></li>
<li><a href="#"><i class="fa fa-key"></i> Security</a></li>
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#inbox" data-toggle="tab"><i class="fa fa-envelope-o"></i> Inbox</a></li>
<li><a href="#sent" data-toggle="tab"><i class="fa fa-reply-all"></i> Sent</a></li>
<li><a href="#assignment" data-toggle="tab"><i class="fa fa-file-text-o"></i> Assignment</a></li>
<li><a href="#assignment" data-toggle="tab"><i class="fa fa-file-text-o"></i> Projects</a></li>
<li><a href="#event" data-toggle="tab"><i class="fa fa-clock-o"></i> Mentor(s)</a></li>
</ul>
<div class="btn-toolbar well well-sm" role="toolbar" style="margin:0px;">
<div class="btn-group"><input type="checkbox"></div>
<div class="btn-group col-md-3">{{$user->first}} {{ $user->last }}</div>
<div class="btn-group col-md-8"><b>Hi Check this new Bootstrap plugin</b> <div class="pull-right"><i class="glyphicon glyphicon-time"></i> 12:10 PM <button class="btn btn-primary btn-xs" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa fa-share-square-o"> Reply</i></button></div> </div>
<div class="btn-group col-md-8"><b>Hi Check this new Bootstrap plugin</b> <div class="pull-right"><i class="glyphicon glyphicon-time"></i> 12:10 PM <button class="btn btn-primary btn-xs"><i class="fa fa-share-square-o"> Reply</i></button></div> </div>
</div>
</a>
<div id="a1" class="collapse out well">This is the message body</div>
</div>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content"><br/><br/>
<form class="form-horizontal">
<fieldset>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" for="body">Body :</label>
<div class="col-md-8">
<input id="body" name="body" type="text" placeholder="Message Body" class="form-control input-md">
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-2 control-label" for="message">Message :</label>
<div class="col-md-8">
<textarea class="form-control" id="message" name="message"></textarea>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-2 control-label" for="send"></label>
<div class="col-md-8">
<button id="send" name="send" class="btn btn-primary">Send</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div><script type="text/javascript">
<script type="text/javascript">
$(function () {
$('#myTab a:last').tab('show')
$('#myTab a:first').tab('show')
})
</script>
public/js/user-profile.js
1
2
3
4
5
6
7
$(function()
{
$('#dialog').click(function(){
$('#compose').dialog();
});
});

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.08594s using 13 queries.