v1.0.7.3
fixed email update issue
This commit is contained in:
@@ -102,7 +102,8 @@ class EmailsController extends Controller
|
|||||||
'email_address' => $request->email_address,
|
'email_address' => $request->email_address,
|
||||||
'email_name' => $request->email_name,
|
'email_name' => $request->email_name,
|
||||||
'password' => $request->password,
|
'password' => $request->password,
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
'email_address' => 'required|email|unique:emails',
|
'email_address' => 'required|email|unique:emails',
|
||||||
'email_name' => 'required',
|
'email_name' => 'required',
|
||||||
'password' => 'required',
|
'password' => 'required',
|
||||||
@@ -280,7 +281,8 @@ class EmailsController extends Controller
|
|||||||
'email_address' => $request->email_address,
|
'email_address' => $request->email_address,
|
||||||
'email_name' => $request->email_name,
|
'email_name' => $request->email_name,
|
||||||
'password' => $request->password,
|
'password' => $request->password,
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
'email_address' => 'email',
|
'email_address' => 'email',
|
||||||
'email_name' => 'required',
|
'email_name' => 'required',
|
||||||
'password' => 'required',
|
'password' => 'required',
|
||||||
@@ -304,7 +306,7 @@ class EmailsController extends Controller
|
|||||||
}
|
}
|
||||||
if ($request->fetching_status == 'on') {
|
if ($request->fetching_status == 'on') {
|
||||||
$imap_check = $this->getImapStream($request, $validate);
|
$imap_check = $this->getImapStream($request, $validate);
|
||||||
if ($imap_check == 0) {
|
if ($imap_check[0] == 0) {
|
||||||
return 'Incoming email connection failed';
|
return 'Incoming email connection failed';
|
||||||
}
|
}
|
||||||
$need_to_check_imap = 1;
|
$need_to_check_imap = 1;
|
||||||
@@ -325,22 +327,22 @@ class EmailsController extends Controller
|
|||||||
|
|
||||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||||
if ($imap_check != 0 && $smtp_check != 0) {
|
if ($imap_check != 0 && $smtp_check != 0) {
|
||||||
$this->update($id, $request);
|
$this->update($id, $request, $imap_check[1]);
|
||||||
$return = 1;
|
$return = 1;
|
||||||
}
|
}
|
||||||
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
||||||
if ($imap_check != 0 && $smtp_check == 0) {
|
if ($imap_check != 0 && $smtp_check == 0) {
|
||||||
$this->update($id, $request);
|
$this->update($id, $request, $imap_check[1]);
|
||||||
$return = 1;
|
$return = 1;
|
||||||
}
|
}
|
||||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
||||||
if ($imap_check == 0 && $smtp_check != 0) {
|
if ($imap_check == 0 && $smtp_check != 0) {
|
||||||
$this->update($id, $request);
|
$this->update($id, $request, null);
|
||||||
$return = 1;
|
$return = 1;
|
||||||
}
|
}
|
||||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
||||||
if ($imap_check == 0 && $smtp_check == 0) {
|
if ($imap_check == 0 && $smtp_check == 0) {
|
||||||
$this->update($id, $request);
|
$this->update($id, $request, null);
|
||||||
$return = 1;
|
$return = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,13 +359,16 @@ class EmailsController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function update($id, $request)
|
public function update($id, $request, $imap_check)
|
||||||
{
|
{
|
||||||
try {
|
// try {
|
||||||
|
// dd($id);
|
||||||
|
// dd($request);
|
||||||
|
// dd($imap_check);
|
||||||
// fetch the selected emails
|
// fetch the selected emails
|
||||||
$emails = Emails::whereId($id)->first();
|
$emails = Emails::whereId($id)->first();
|
||||||
// insert all the requested parameters with except
|
// insert all the requested parameters with except
|
||||||
$emails->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'sending_status'))->save();
|
$emails->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save();
|
||||||
if ($request->fetching_status == 'on') {
|
if ($request->fetching_status == 'on') {
|
||||||
$emails->fetching_status = 1;
|
$emails->fetching_status = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -379,6 +384,13 @@ class EmailsController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$emails->auto_response = 0;
|
$emails->auto_response = 0;
|
||||||
}
|
}
|
||||||
|
if ($imap_check !== null) {
|
||||||
|
$emails->fetching_encryption = $imap_check;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$emails->fetching_encryption = $request->fetching_encryption;
|
||||||
|
}
|
||||||
|
// dd($email->fetching_encryption);
|
||||||
// fetching department value
|
// fetching department value
|
||||||
$emails->department = $this->departmentValue($request->input('department'));
|
$emails->department = $this->departmentValue($request->input('department'));
|
||||||
// fetching priority value
|
// fetching priority value
|
||||||
@@ -390,11 +402,10 @@ class EmailsController extends Controller
|
|||||||
$emails->save();
|
$emails->save();
|
||||||
// returns success message for successful email update
|
// returns success message for successful email update
|
||||||
$return = 1;
|
$return = 1;
|
||||||
} catch (Exception $e) {
|
// } catch (Exception $e) {
|
||||||
// returns if try fails
|
// // returns if try fails
|
||||||
$return = $e->getMessage();
|
// $return = $e->getMessage();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user