=2) { list($host,$dompart)=$expl; // We search for a 'squirrelmail' subdomain in that domain $db->query("SELECT * FROM sub_domaines s WHERE s.domaine=? AND s.type='roundcube';",array($dompart)); 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 called when an email is REALLY deleted (by the cron, not just in the panel) * @param mail_id integer the ID of the mail in the AlternC database * @param fullmail string the deleted mail himself in the form of john@domain.tld * @return false|null */ function hook_mail_delete_for_real($mail_id, $fullmail) { // 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"); if (! isset($dbtype)) { global $msg; $msg->raise('Error', "roundcube::hook_mail_delete_for_real",_("Problem: missing var in Debian Roundcube configuration file")); return false; } 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; } $stmt = $dbh->prepare("SELECT user_id FROM users WHERE username = ?;"); $req=$stmt->execute(array($fullmail)); if ($req) { foreach ( $stmt->fetchAll() as $t ) { if (empty($t['user_id'])) continue ; $rcuser_id=$t['user_id']; $dbh->prepare("DELETE from contactgroupmembers where contactgroup_id in (select contactgroup_id from contactgroups where user_id = ?) ; ")->execute(array($rcuser_id)); $dbh->prepare("DELETE from contactgroups where user_id = ? ; ")->execute(array($rcuser_id)); $dbh->prepare("DELETE from contacts where user_id = ? ; ")->execute(array($rcuser_id)); $dbh->prepare("DELETE from identities where user_id = ? ; ")->execute(array($rcuser_id)); $dbh->prepare("DELETE from users where user_id = ? ; ")->execute(array($rcuser_id)); } //foreach } } } /* Class Roundcube */