Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
m_roundcube Class Reference

This class handle roundcube's webmail hook the main panel page to add a link to the webmail. More...

Public Member Functions

 hook_admin_webmail ()
 Hook called by the homepage or the /webmail link to redirect the user to a known webmail url.
 hook_mail_delete_for_real ($mail_id, $fullmail)
 Hook called when an email is REALLY deleted (by the cron, not just in the panel)

Detailed Description

This class handle roundcube's webmail hook the main panel page to add a link to the webmail.

Definition at line 30 of file m_roundcube.php.

Member Function Documentation

hook_admin_webmail ( )

Hook called by the homepage or the /webmail link to redirect the user to a known webmail url.

the variable 'webmail_redirect' tells which webmail has the priority.

Returns
string the URL of the webmail

Definition at line 38 of file m_roundcube.php.

References $db, $domain, $host, and $i.

{
global $db;
// Search for the domain where the panel is hosted, then search for a webmail in it.
$i=2;
$domain="";
if (!empty($_SERVER["HTTP_HOST"])) {
do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
$expl=explode(".",$_SERVER["HTTP_HOST"],$i);
if (count($expl)>=2) {
list($host,$dompart)=$expl;
// We search for a 'squirrelmail' subdomain in that domain
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='roundcube';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
}
$i++;
} while (strpos($dompart,'.')!==false);
}
// not found: search for a webmail in the admin user account
$db->query("SELECT * FROM sub_domaines s WHERE s.compte=2000 AND s.type='roundcube';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
}
hook_mail_delete_for_real (   $mail_id,
  $fullmail 
)

Hook called when an email is REALLY deleted (by the cron, not just in the panel)

Parameters
mail_idinteger the ID of the mail in the AlternC database
fullmailstring the deleted mail himself in the form of john@.nosp@m.doma.nosp@m.in.tl.nosp@m.d
Returns
boolean

Definition at line 75 of file m_roundcube.php.

References $t.

{
// Include Roundcube configuration
// Delete from the roundcube configuration
// Use cleandb.sh filled by roundcube ? http://trac.roundcube.net/browser/github/bin/cleandb.sh
include_once("/etc/roundcube/debian-db.php");
switch ($dbtype) {
case "sqlite":
$rcdb = "sqlite:///$basepath/$dbname?mode=0640";
$dbh = new PDO("sqlite:/$basepath/$dbname");
break;
default:
if ($dbport != '') $dbport=":$dbport";
if ($dbserver == '') $dbserver="localhost";
$dbh= new PDO("$dbtype:host=$dbserver;dbname=$dbname;dbport=$dbport", $dbuser, $dbpass);
$rcdb = "$dbtype:$dbuser:$dbpass@$dbserver$dbport/$dbname";
break;
}
$req = $dbh->query("SELECT user_id FROM users WHERE username = '$fullmail'");
foreach ( $req->fetchAll() as $t ) {
if (empty($t['user_id'])) continue ;
$rcuser_id=$t['user_id'];
$dbh->query("DELETE from contactgroupmembers where contactgroup_id in (select contactgroup_id from contactgroups where user_id = $rcuser_id) ; ");
$dbh->query("DELETE from contactgroups where user_id = $rcuser_id ; ");
$dbh->query("DELETE from contacts where user_id = $rcuser_id ; ");
$dbh->query("DELETE from identities where user_id = $rcuser_id ; ");
$dbh->query("DELETE from users where user_id = $rcuser_id ; ");
} //foreach
}

The documentation for this class was generated from the following file: