YaWK
24.1
Yet another WebKit
webmail-setFlagged.php
Go to the documentation of this file.
1
<?php
2
// include required imap classes
3
require_once
"../../system/engines/imapClient/ImapClient.php"
;
4
require_once
"../../system/engines/imapClient/ImapClientException.php"
;
5
require_once
"../../system/engines/imapClient/ImapConnect.php"
;
6
// include required yawk classes
7
require_once
'../../system/classes/db.php'
;
8
require_once
'../../system/classes/settings.php'
;
9
require_once
'../../system/classes/webmail.php'
;
10
// create db object
11
$db
= new \YAWK\db();
12
// create webmail object
13
$webmail
= new \YAWK\webmail();
14
15
// let php know we need these classes:
16
use SSilence\ImapClient\ImapClientException;
17
use SSilence\ImapClient\ImapClient as Imap;
18
19
// get all webmail setting values into an array
20
$webmailSettings
=
\YAWK\settings::getValueSettingsArray
(
$db
,
"webmail_"
);
21
// mailbox server (imap.server.tld)
22
$server
=
$webmailSettings
[
'webmail_imap_server'
];
23
// mailbox user (
[email protected]
)
24
$username
=
$webmailSettings
[
'webmail_imap_username'
];
25
// mailbox password
26
$password
=
$webmailSettings
[
'webmail_imap_password'
];
27
// encryption type (ssl, tsl, null)
28
$encryption
=
"/"
.
$webmailSettings
[
'webmail_imap_encrypt'
];
29
// port (default: 993)
30
$port
=
":"
.
$webmailSettings
[
'webmail_imap_port'
];
31
// novalidate-cert
32
$novalidate
=
$webmailSettings
[
'webmail_imap_novalidate'
];
33
// create options array
34
$options
= array(
$novalidate
);
35
36
// lets go: open imap connection, check state and toggle required
37
try
38
{
// open connection to imap server
39
$imap
=
new
Imap(
$server
.$port.$encryption,
$username
,
$password
,
$encryption
, 0, 0,
$options
);
40
// connection successful, error = false
41
$error
=
false
;
42
43
// @var $_POST['state'] string (seen|unseen) : check which state should be toggled
44
if
(isset($_POST[
'state'
]))
45
{
// if email should be toggled to state 'not flagged'
46
if
($_POST[
'state'
] ===
"setUnFlagged"
)
47
{
// remove flag from message
48
if
(
$webmail
->removeFlags(
$imap
->getImap(), $_POST[
'uid'
]) ==
true
)
49
{
// remove flag successful
50
echo
"true"
;
51
}
52
else
53
{
// remove flag failed
54
echo
"false"
;
55
}
56
}
57
else
58
{
// set message as flagged
59
if
(
$webmail
->markAsFlagged(
$imap
->getImap(), $_POST[
'uid'
]) ==
true
)
60
{
// set flag successful
61
echo
"true"
;
62
}
63
else
64
{
// set flag failed
65
echo
"false"
;
66
}
67
}
68
}
69
}
70
// open imap connection failed...
71
catch
(ImapClientException
$error
)
72
{
// no errors in production...
73
echo
"false"
;
74
echo
"<script>console.log('.$error.');</script>"
;
75
}
76
?>
YAWK\settings\getValueSettingsArray
static getValueSettingsArray($db, $property)
Returns an array containing property as key and values corresponding to this property where p like $p...
Definition:
settings.php:41
$imap
$imap
Definition:
webmail-compose.php:112
$options
$options
Definition:
webmail-setFlagged.php:34
$username
$username
Definition:
webmail-setFlagged.php:24
$db
$db
Definition:
webmail-setFlagged.php:11
$password
$password
Definition:
webmail-setFlagged.php:26
$webmail
$webmail
Definition:
webmail-setFlagged.php:13
$novalidate
$novalidate
Definition:
webmail-setFlagged.php:32
$encryption
$encryption
Definition:
webmail-setFlagged.php:28
$port
$port
Definition:
webmail-setFlagged.php:30
$server
$server
Definition:
webmail-setFlagged.php:22
$webmailSettings
$webmailSettings
Definition:
webmail-setFlagged.php:20
$error
$error
Definition:
webmail-setFlagged.php:41
yawk.io
admin
js
webmail-setFlagged.php
Generated on Tue Jan 16 2024 21:58:59 for YaWK by
doxygen 1.9.1