Updating to the newer option page format.
[squirrelmail.git] / plugins / abook_take / functions.php
CommitLineData
70e61af6 1<?php
2
3/**
4 * functions.php
5 *
70e61af6 6 * Functions for the Address Take plugin
7 *
4b5049de 8 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
4b4abf93 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
4f51df66 10 * @version $Id$
70e61af6 11 * @package plugins
12 * @subpackage abook_take
13 */
14
867fed37 15/** */
e9e4a22b 16function valid_email ($email, $verify) {
70e61af6 17 global $Email_RegExp_Match;
18
e9e4a22b 19 if (! eregi('^' . $Email_RegExp_Match . '$', $email)) {
70e61af6 20 return false;
e9e4a22b 21 }
70e61af6 22
e9e4a22b 23 if (! $verify) {
70e61af6 24 return true;
e9e4a22b 25 }
70e61af6 26
27 return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ;
28}
29
e9e4a22b 30function abook_take_read_string($str) {
70e61af6 31 global $abook_found_email, $Email_RegExp_Match;
32
e9e4a22b 33 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits)) {
70e61af6 34 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
e9e4a22b 35 if (! isset($abook_found_email[$hits[0]])) {
9d67bd53 36 echo addHidden('email[]', $hits[0]);
70e61af6 37 $abook_found_email[$hits[0]] = 1;
38 }
39 }
40
41 return;
42}
43
e9e4a22b 44function abook_take_read_array($array) {
70e61af6 45 foreach ($array as $item)
46 abook_take_read_string($item->getAddress());
47}
48
e9e4a22b 49function abook_take_read() {
70e61af6 50 global $message;
51
1bf86d6f 52 echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') .
f265009a 53 '<div style="text-align: center;">' . "\n";
70e61af6 54
55 if (isset($message->rfc822_header->reply_to))
56 abook_take_read_array($message->rfc822_header->reply_to);
57 if (isset($message->rfc822_header->from))
58 abook_take_read_array($message->rfc822_header->from);
59 if (isset($message->rfc822_header->cc))
60 abook_take_read_array($message->rfc822_header->cc);
61 if (isset($message->rfc822_header->to))
62 abook_take_read_array($message->rfc822_header->to);
63
1bf86d6f 64 echo addSubmit(_("Take Address")) .
f265009a 65 '</div></form>';
70e61af6 66}
67
e9e4a22b 68function abook_take_pref() {
70e61af6 69 global $username, $data_dir, $abook_take_verify;
70
1bf86d6f 71 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify', false);
70e61af6 72}
73
e9e4a22b 74function abook_take_options() {
75 global $optpage_data;
76
77 $optpage_data['grps']['abook_take'] = _("Address Book Take");
78 $optionValues = array();
79 $optionValues[] = array(
80 'name' => 'abook_take_verify',
81 'caption' => _("Try to verify addresses"),
82 'type' => SMOPT_TYPE_BOOLEAN,
83 'refresh' => SMOPT_REFRESH_NONE
84 );
85 $optpage_data['vals']['abook_take'] = $optionValues;
70e61af6 86}