/[drupal]/contributions/modules/addressbook/addressbook.module
ViewVC logotype

Diff of /contributions/modules/addressbook/addressbook.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.33 by wplaat, Tue Oct 27 18:55:46 2009 UTC revision 1.34 by wplaat, Tue Oct 27 19:01:51 2009 UTC
# Line 12  Line 12 
12   * Email   : info@plaatsoft.nl   * Email   : info@plaatsoft.nl
13   */   */
14    
15  // Addressbook module URLs  // Addressbook module URLs.
16  define('URL_FAMILY_LIST',  'addressbook/family/list');  define('URL_FAMILY_LIST',  'addressbook/family/list');
17  define('URL_FAMILY_VIEW',  'addressbook/family/view');  define('URL_FAMILY_VIEW',  'addressbook/family/view');
18  define('URL_FAMILY_EDIT',  'addressbook/family/edit');  define('URL_FAMILY_EDIT',  'addressbook/family/edit');
# Line 34  define('THUMBNAILS_DIR', file_director Line 34  define('THUMBNAILS_DIR', file_director
34   * help hook()   * help hook()
35   * @return help texts   * @return help texts
36   */   */
37  function addressbook_help($section) {  function addressbook_help($path, $arg) {
38    
39    $output = '';    $output = '';
40    switch ($section) {    switch ($path) {
41      case 'admin/modules#description':      case 'admin/modules#description':
42        $output .= t('Addressbook module');        $output .= t('Addressbook module');
43        break;        break;
# Line 45  function addressbook_help($section) { Line 45  function addressbook_help($section) {
45    return $output;    return $output;
46  }  }
47    
48    function addressbook_mail($key, &$message, $params)
49    {
50      $message['subject'] = $params['subject'];
51      $message['body'] = $params['body'];
52    }
53    
54  /**  /**
55   * menu hook()   * menu hook()
56   * @return array of menu items   * @return array of menu items
57   */   */
58  function addressbook_menu() {  function addressbook_menu()
59    {
   $items = array();  
60    
61    $items[] = array('path' => URL_FAMILY_LIST,    $items[URL_FAMILY_LIST] = array(
62                     'title' => t('Addressbook family list'),                     'title' => 'Addressbook family list',
63                     'callback' => 'family_list',                     'page callback' => 'family_list',
64                     'access' => user_access('view addressbook'),                     'access arguments' => array('view addressbook'),
65                     'type' => MENU_CALLBACK);                     'type' => MENU_CALLBACK,
66                    );
67    $items[] = array('path' => URL_FAMILY_VIEW,  
68                     'title' => t('Addressbook view family'),    $items[URL_FAMILY_VIEW] = array(
69                     'callback' => 'family_view2',                     'title' => 'Addressbook view family',
70                     'access' => user_access('view addressbook'),                     'page callback' => 'family_view2',
71                     'type' => MENU_CALLBACK);                     'access arguments' => array('view addressbook'),
72                       'type' => MENU_CALLBACK,
73    $items[] = array('path' => URL_FAMILY_EDIT,                  );
74                     'title' => t('Addressbook edit family'),  
75                     'callback' => 'family_edit',    $items[URL_FAMILY_EDIT] = array(
76                     'access' => user_access('add address'),                     'title' => 'Addressbook edit family',
77                     'type' => MENU_CALLBACK);                     'page callback' => 'family_edit',
78                       'access arguments' => array('add address'),
79    $items[] = array('path' => URL_MEMBER_LIST,                     'type' => MENU_CALLBACK,
80                     'title' => t('Addressbook family list'),                  );
81                     'callback' => 'member_list',  
82                     'access' => user_access('view addressbook'),    $items[URL_MEMBER_LIST] = array(
83                     'type' => MENU_CALLBACK);                     'title' => 'Addressbook family list',
84                       'page callback' => 'member_list',
85    $items[] = array('path' => URL_MEMBER_VIEW,                     'access arguments' => array('view addressbook'),
86                     'title' => t('Addressbook view family member'),                     'type' => MENU_CALLBACK,
87                     'callback' => 'member_view',                          );
88                     'access' => user_access('view addressbook'),  
89                     'type' => MENU_CALLBACK);    $items[URL_MEMBER_VIEW] = array(
90                       'title' => 'Addressbook view family member',
91    $items[] = array('path' => URL_MEMBER_EDIT,                     'page callback' => 'member_view',
92                     'title' => t('Addressbook edit family member'),                     'access arguments' => array('view addressbook'),
93                     'callback' => 'member_edit',                     'type' => MENU_CALLBACK,
94                     'access' => user_access('add address'),                          );
95                     'type' => MENU_CALLBACK);  
96      $items[URL_MEMBER_EDIT] = array(
97    $items[] = array('path' => URL_PICTURE_VIEW,                     'title' => 'Addressbook edit family member',
98                     'title' => t('Addressbook view picture'),                     'page callback' => 'member_edit',
99                     'callback' => 'picture_view',                     'access arguments' => array('add address'),
100                     'access' => user_access('view addressbook'),                     'type' => MENU_CALLBACK,
101                     'type' => MENU_CALLBACK);                          );
102    
103    $items[] = array('path' => URL_PICTURE_EDIT,    $items[URL_PICTURE_VIEW] = array(
104                     'title' => t('Addressbook edit picture'),                     'title' => 'Addressbook view picture',
105                     'callback' => 'picture_edit',                     'page callback' => 'picture_view',
106                     'access' => user_access('add address'),                     'access arguments' => array('view addressbook'),
107                     'type' => MENU_CALLBACK);                     'type' => MENU_CALLBACK,
108                    );
109    $items[] = array('path' => URL_UPLOAD_CSV,  
110                     'title' => t('Addressbook CSV upload'),    $items[URL_PICTURE_EDIT] = array(
111                     'callback' => 'upload_csv',                     'title' => 'Addressbook edit picture',
112                     'access' => user_access('add address'),                     'page callback' => 'picture_edit',
113                     'type' => MENU_CALLBACK);                     'access arguments' => array('add address'),
114                       'type' => MENU_CALLBACK,
115    $items[] = array('path' => URL_DOWNLOAD_CSV,                          );
116                     'title' => t('Addressbook CSV download'),  
117                     'callback' => 'download_csv',    $items[URL_UPLOAD_CSV] = array(
118                     'access' => user_access('add address'),                     'title' => 'Addressbook CSV upload',
119                     'type' => MENU_CALLBACK);                     'page callback' => 'upload_csv',
120                       'access arguments' => array('add address'),
121     $items[] = array('path' => URL_SEARCH,                     'type' => MENU_CALLBACK,
122                     'title' => t('Addressbook search'),                  );
123                     'callback' => 'general_search',  
124                     'access' => user_access('view addressbook'),    $items[URL_DOWNLOAD_CSV] = array(
125                     'type' => MENU_CALLBACK);                     'title' => 'Addressbook CSV download',
126                       'page callback' => 'download_csv',
127     $items[] = array('path' => URL_MAP_VIEW,                     'access arguments' => array('add address'),
128                     'title' => t('Addressbook map view'),                     'type' => MENU_CALLBACK,
129                     'callback' => 'map_view',                  );
130                     'access' => user_access('view addressbook'),  
131                     'type' => MENU_CALLBACK);     $items[URL_SEARCH] = array(
132                       'title' => 'Addressbook search',
133     $items[] = array('path' => URL_EMAIL,                     'page callback' => 'general_search',
134                     'title' => t('Addressbook email view'),                     'access arguments' => array('view addressbook'),
135                     'callback' => 'email_view',                     'type' => MENU_CALLBACK,
136                     'access' => user_access('add address'),                  );
137                     'type' => MENU_CALLBACK);  
138       $items[URL_MAP_VIEW] = array(
139     $items[] = array('path' => 'admin/settings/addressbook',                     'title' => 'Addressbook map view',
140                     'title' => t('Addressbook'),                     'page callback' => 'map_view',
141                     'description' => t('Settings of addressbook.'),                     'access arguments' => array('view addressbook'),
142                     'callback' => 'drupal_get_form',                     'type' => MENU_CALLBACK,
143                     'callback arguments' => array('addressbook_settings'),                  );
144                     'access' => user_access('administer site configuration'),  
145                     'type' => MENU_NORMAL_ITEM);     $items[URL_EMAIL] = array(
146                       'title' => 'Addressbook email view',
147                       'page callback' => 'email_view',
148                       'access arguments' => array('add address'),
149                       'type' => MENU_CALLBACK,
150                    );
151    
152       $items['admin/settings/addressbook'] = array(
153                       'title' => 'Addressbook',
154                       'description' => 'Settings of addressbook.',
155                       'page callback' => 'drupal_get_form',
156                       'page arguments' => array('addressbook_settings'),
157                       'access arguments' => array('administer site configuration'),
158                       'type' => MENU_NORMAL_ITEM,
159                    );
160    
161    return $items;    return $items;
162  }  }
163    
164  /**  /**
165    * Valid permisions for this module    * Valid permissions for this module.
166    * @return array an array of valid permission for the module    * @return array an array of valid permission for the module
167    */    */
168  function addressbook_perm() {  function addressbook_perm() {
# Line 152  function addressbook_perm() { Line 171  function addressbook_perm() {
171  }  }
172    
173  /**  /**
174   * Module configuration settings   * Module configuration settings.
175   * @return settings HTML or deny access   * @return settings HTML or deny access
176   */   */
177  function addressbook_settings() {  function addressbook_settings() {
# Line 169  function addressbook_settings() { Line 188  function addressbook_settings() {
188       '#title' => t('Name format '),       '#title' => t('Name format '),
189       '#default_value' => variable_get('addressbook_name_format',1),       '#default_value' => variable_get('addressbook_name_format',1),
190       '#options' => array( 0 => t('middle last, first'), 1 => t('first middle last') ),       '#options' => array( 0 => t('middle last, first'), 1 => t('first middle last') ),
191       '#description' => t('Set with name format with will be used in the general addressbook list page.'));       '#description' => t('Set the name format which will be used in the general addressbook list page.'));
192    
193    $form['settings_general']['addressbook_show_sort_bar'] = array(    $form['settings_general']['addressbook_show_sort_bar'] = array(
194       '#type' => 'select',       '#type' => 'select',
195       '#title' => t('Enable sort bar'),       '#title' => t('Enable sort bar'),
196       '#default_value' => variable_get('addressbook_show_sort_bar',1),       '#default_value' => variable_get('addressbook_show_sort_bar',1),
197       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
198       '#description' => t('Enable / Disable sort bart in general addressbook list page.'));       '#description' => t('Enable / disable sort bar in general addressbook list page.'));
199    
200    $form['settings_general']['addressbook_roles'] = array(    $form['settings_general']['addressbook_roles'] = array(
201       '#type' => 'textarea',       '#type' => 'textarea',
202       '#title' => t('Roles'),       '#title' => t('Roles'),
203       '#default_value' => variable_get('addressbook_roles', ''),       '#default_value' => variable_get('addressbook_roles', ''),
204       '#rows' => 1,       '#rows' => 1,
205       '#description' => t("Enter roles with a person can have (Seperated items with commas. No space allowed).") );       '#description' => t("Enter the roles which a person can have (Seperate items with commas (,). No spaces allowed).") );
206    
207    $form['settings_general']['addressbook_country'] = array(    $form['settings_general']['addressbook_country'] = array(
208       '#type' => 'textfield',       '#type' => 'textfield',
# Line 198  function addressbook_settings() { Line 217  function addressbook_settings() {
217       '#title' => t('Show thumbnails pictures in list views'),       '#title' => t('Show thumbnails pictures in list views'),
218       '#default_value' => variable_get('addressbook_show_thumbnails',0),       '#default_value' => variable_get('addressbook_show_thumbnails',0),
219       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
220       '#description' => t('Enable / Disable thumbnails pictures in family list and family member list.'));       '#description' => t('Enable / disable thumbnail pictures in family list and family member list.'));
221    
222    $form['settings_general']['addressbook_email_manitory'] = array(    $form['settings_general']['addressbook_email_manitory'] = array(
223       '#type' => 'select',       '#type' => 'select',
224       '#title' => t('Email field manitory'),       '#title' => t('Email field manitory'),
225       '#default_value' => variable_get('addressbook_email_manitory',1),       '#default_value' => variable_get('addressbook_email_manitory',1),
226       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
227       '#description' => t('Enable / Disable email field as manitory field.'));       '#description' => t('Enable / disable email field as mandatory field.'));
228    
229    $form['settings_general']['addressbook_wiki_edit_mode'] = array(    $form['settings_general']['addressbook_wiki_edit_mode'] = array(
230       '#type' => 'select',       '#type' => 'select',
231       '#title' => t('Wiki edit mode'),       '#title' => t('Wiki edit mode'),
232       '#default_value' => variable_get('addressbook_wiki_edit_mode',0),       '#default_value' => variable_get('addressbook_wiki_edit_mode',0),
233       '#options' => array( 0 => t('Disable'), 1 => t('Enable') ),       '#options' => array( 0 => t('Disable'), 1 => t('Enable') ),
234       '#description' => t('Enable (Every one can modify existing addresses), Disable (Only owner can modify created addresses).'));       '#description' => t('Enable (anyone can modify existing addresses), Disable (only owner can modify created addresses).'));
235    
236    
237    
# Line 229  function addressbook_settings() { Line 248  function addressbook_settings() {
248       '#type' => 'textfield',       '#type' => 'textfield',
249       '#title' => t('Free www.map24.com access key'),       '#title' => t('Free www.map24.com access key'),
250       '#default_value' => variable_get('addressbook_map_key', ''),       '#default_value' => variable_get('addressbook_map_key', ''),
251       '#description' => t("Enter access key (Visit http://www.map24.com to get a free key)"),       '#description' => t("Enter access key (Visit http://www.map24.com to obtain a free key)"),
252       '#maxlength' => '50',       '#maxlength' => '50',
253       '#size' => '50');       '#size' => '50');
254    
# Line 242  function addressbook_settings() { Line 261  function addressbook_settings() {
261       '#title' => t('Birthday email notification'),       '#title' => t('Birthday email notification'),
262       '#default_value' => variable_get('addressbook_birthday_notification',0),       '#default_value' => variable_get('addressbook_birthday_notification',0),
263       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
264       '#description' => t('Enable / Disable email birthday notification.'));       '#description' => t('Enable / disable email birthday notification.'));
265    
266    $form['birthday']['addressbook_birthday_subject'] = array(    $form['birthday']['addressbook_birthday_subject'] = array(
267       '#type' => 'textfield',       '#type' => 'textfield',
268       '#title' => t('Subject of birtday e-mail'),       '#title' => t('Subject of birtday e-mail'),
269       '#default_value' => variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name'),       '#default_value' => variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name'),
270       '#maxlength' => 180,       '#maxlength' => 180,
271       '#description' => t('Customize the subject of your birthday e-mail, which is sent to members upon there birtday.') .' '. t('Available variables are:') .' %username, %site_name');       '#description' => t('Customize the subject of your birthday e-mail, which is sent to members upon their birthday.') .' '. t('Available variables are:') .' %username, %site_name');
272    
273    $form['birthday']['addressbook_birthday_body'] = array(    $form['birthday']['addressbook_birthday_body'] = array(
274       '#type' => 'textarea',       '#type' => 'textarea',
275       '#title' => t('Body of birthday e-mail'),       '#title' => t('Body of birthday e-mail'),
276       '#default_value' => variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n"),       '#default_value' => variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n"),
277       '#rows' => 15,       '#rows' => 15,
278       '#description' => t('Customize the body of the birtday e-mail, which is sent to members upon there birtday.') .' '. t('Available variables are:') .' %username, %user_age, %site_name');       '#description' => t('Customize the body of the birthday e-mail, which is sent to members upon their birthday.') .' '. t('Available variables are:') .' %username, %user_age, %site_name');
279    
280    return system_settings_form($form);    return system_settings_form($form);
281    
282  }  }
283    
284  /**  /**
285    * Find all family member with are celebrating there birth_day to day and send a email.    * Find all family members which are celebrating their birthday to day and send them an email.
286    * @return emails    * @return emails
287    */    */
288  function addressbook_cron() {  function addressbook_cron() {
# Line 271  function addressbook_cron() { Line 290  function addressbook_cron() {
290    // If birthday notification is enabled check all family members.    // If birthday notification is enabled check all family members.
291    if ( variable_get('addressbook_birthday_notification',0)==1 ) {    if ( variable_get('addressbook_birthday_notification',0)==1 ) {
292    
293      // Send only one time the birthday notications per day (crontab runs every hour)      // Send the birthday notication only once in any given day (crontab may run more frequently)
294      $current_day=date('-m-d');      $current_day=date('-m-d');
295      $current_time=date('H');      $current_time=date('H');
296    
297      if ($current_time==0)      if ($current_time==0) {
     {  
298        watchdog('cron', t('Addressbook birthday cron'));        watchdog('cron', t('Addressbook birthday cron'));
299    
300        // Fetch all members with are celebrating there birtday        // Fetch all members with are celebrating there birtday
301        $query='SELECT first_name, middle_name, last_name, email, birth_day FROM {addressbook_member} WHERE birth_day LIKE "%'.$current_day.'"';        $query='SELECT first_name, middle_name, last_name, email, birth_day FROM {addressbook_member} WHERE birth_day LIKE "%'.$current_day.'"';
302        $queryResult = db_query($query);        $queryResult = db_query($query);
303        while ($data = db_fetch_object($queryResult))        while ($data = db_fetch_object($queryResult)) {
       {  
   
304          $username=view_name($data->first_name,$data->middle_name,$data->last_name,true);          $username=view_name($data->first_name,$data->middle_name,$data->last_name,true);
305    
306          $email = $data->email;          $email = $data->email;
# Line 295  function addressbook_cron() { Line 311  function addressbook_cron() {
311          $user_age  = date('Y')-$year;          $user_age  = date('Y')-$year;
312    
313          // if family member have a email address send a email          // if family member have a email address send a email
314          if (($email!='') && ($user_age<100))          if (($email!='') && ($user_age<100)) {
         {  
315            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';
316    
317            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');
318            $subject = str_replace("%username", $username, $subject);            $subject=str_replace("%username", $username, $subject);
319            $subject = str_replace("%site_name", $site_name, $subject);            $subject=str_replace("%site_name", $site_name, $subject);
320    
321            $message=variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n");            $body=variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n");
322            $message = str_replace("%username", $username, $message);            $body=str_replace("%username", $username, $body);
323            $message = str_replace("%user_age", $user_age, $message);            $body=str_replace("%user_age", $user_age, $body);
324            $message = str_replace("%site_name", $site_name, $message);            $body=str_replace("%site_name", $site_name, $body);
325    
326              if ( drupal_mail( "addressbook", $email, $subject, $message, $from))            if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))
327              {            {
328               watchdog('cron', t('Sent birthday email to ').$email);              watchdog('cron', t('Sent birthday email to ').$email);
329            }            }
330            else            else
331            {            {
# Line 323  function addressbook_cron() { Line 338  function addressbook_cron() {
338  }  }
339    
340  /**  /**
341    * Find all family member with are celebrating there birth_day to day and make a block of it.    * Find all family members which are celebrating their birthday today and make a block of it.
342    * @return emails    * @return emails
343    */    */
344  function addressbook_block($op='list', $delta=0) {  function addressbook_block($op='list', $delta=0) {
# Line 476  function view_owner($uid, $readonly) { Line 491  function view_owner($uid, $readonly) {
491       $query  = 'SELECT uid, name FROM {users}';       $query  = 'SELECT uid, name FROM {users}';
492       $queryResult = db_query($query);       $queryResult = db_query($query);
493    
494       // Workarround Drupal first entry in users table is always empty. Skip this entry       // Workaround Drupal first entry in users table is always empty. Skip this entry
495       $tmp = db_fetch_object($queryResult);       $tmp = db_fetch_object($queryResult);
496    
497       $page.='<select name="owner">';       $page.='<select name="owner">';
# Line 530  function view_roles($active_roles,$wante Line 545  function view_roles($active_roles,$wante
545    
546     if ( $readonly=='0' ) {     if ( $readonly=='0' ) {
547       $page .= '<br/>';       $page .= '<br/>';
548       $page .= '<b>'.t('Please enter the roles you currently forfilling and please enter the roles you are now or in the near future interesed in!').'</b><br/>';       $page .= '<b>'.t('Please enter the roles you currently fulfilling and please enter the roles you are interesed in now or in the near future!').'</b><br/>';
549       $page .= '<br/>';       $page .= '<br/>';
550     }     }
551    
# Line 690  function check_mail($adres) { Line 705  function check_mail($adres) {
705  }  }
706    
707  /*  /*
708   * Function valid number imput   * Function valid number input
709   * @returns true if valid number (only numeric string), false if not   * @returns true if valid number (only numeric string), false if not
710   */   */
711  function check_number($str) {  function check_number($str) {
# Line 1035  function family_list( $sort='', $search= Line 1050  function family_list( $sort='', $search=
1050    }    }
1051    $page .= '</table>';    $page .= '</table>';
1052    
1053     // Only administrators can access the csv upload functionaly     // Only administrators can access the csv upload functionality
1054    if (user_access('access administration pages')) {    if (user_access('access administration pages')) {
1055       //$page .= '<br/>';       //$page .= '<br/>';
1056       $page .= '<table border="0" width="100%">';       $page .= '<table border="0" width="100%">';
# Line 1124  function family_view2( $fid=0 ) { Line 1139  function family_view2( $fid=0 ) {
1139    $picture_found=0;    $picture_found=0;
1140    while ($data = db_fetch_object($queryResult))    while ($data = db_fetch_object($queryResult))
1141    {    {
1142      // Show each picture with is found      // Show each picture which is found
1143      $picture_found++;      $picture_found++;
1144      $page .= '<td valign="top">';      $page .= '<td valign="top">';
1145      $page .= '<a href="'.url(URL_PICTURE_VIEW.'/'.$data->pid).'" >';      $page .= '<a href="'.url(URL_PICTURE_VIEW.'/'.$data->pid).'" >';
# Line 1248  function family_view2( $fid=0 ) { Line 1263  function family_view2( $fid=0 ) {
1263      $page .= '</form>';      $page .= '</form>';
1264      $page .= '</td>';      $page .= '</td>';
1265    
1266      // Maximum three pictures allowed      // Maximum of three pictures allowed
1267      if ($picture_found<3)      if ($picture_found<3)
1268      {      {
1269        $page .= '<td align="left">';        $page .= '<td align="left">';
# Line 1567  function family_edit($fid=0) { Line 1582  function family_edit($fid=0) {
1582    $page .= '</td>';    $page .= '</td>';
1583    
1584    if ($fid!='0') {    if ($fid!='0') {
1585      // Only exiting families can be be deleted      // Only existing families can be deleted
1586      $page .= '<td valign="top">';      $page .= '<td valign="top">';
1587      $page .= '<form action="'.url(URL_FAMILY_EDIT.'/').$fid.'" method="POST">';      $page .= '<form action="'.url(URL_FAMILY_EDIT.'/').$fid.'" method="POST">';
1588      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';
# Line 1726  function member_list( $sort='' ) { Line 1741  function member_list( $sort='' ) {
1741    $page .= '<table width=100% border=1 cellpadding=3 cellspacing=3>';    $page .= '<table width=100% border=1 cellpadding=3 cellspacing=3>';
1742    
1743    // Show Banner    // Show Banner
1744     // Only administrators can access the csv upload functionaly     // Only administrators can access the csv upload functionality
1745    $page .= '<tr><td>';    $page .= '<tr><td>';
1746    if (user_access('access administration pages'))    if (user_access('access administration pages'))
1747    {    {
# Line 2048  function email_view( $sort='') Line 2063  function email_view( $sort='')
2063    
2064    if ($commit=='0')    if ($commit=='0')
2065    {    {
2066         $page .= '<table align="left" width="100%">';
2067       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';
2068       $page .= '<br/>';       $page .= '<br/>';
2069       $page .= t('To:');       $page .= t('To:');
2070       $page .= '<br/>';       $page .= '<br/>';
2071       $page .= '<textarea id="email" cols=140 rows=5 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';       $page .= '<textarea id="email" rows=5 cols=100 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';
2072       $page .= '<br/>';       $page .= '<br/>';
2073       $page .= '<br/>';       $page .= '<br/>';
2074       $page .= t('Subject:');       $page .= t('Subject:');
2075       $page .= '<br/>';       $page .= '<br/>';
2076       $page .= '<input id="text" name="subject" size="143" maxlength="143" type="text" value="'.$subject.'" />';       $page .= '<input id="text" name="subject" size=100 maxlength="143" type="text" value="'.$subject.'" />';
2077       $page .= '<br/>';       $page .= '<br/>';
2078       $page .= '<br/>';       $page .= '<br/>';
2079       $page .= t('Content:');       $page .= t('Content:');
2080       $page .= '<br/>';       $page .= '<br/>';
2081       $page .= '<textarea id="body" cols=140 rows=10 maxlength="2000" name="body" >'.$body.'</textarea>';       $page .= '<textarea id="body" rows=10 cols=100 maxlength="2000" name="body" >'.$body.'</textarea>';
2082       $page .= '<br/>';       $page .= '<br/>';
2083       $page .= '<br/>';       $page .= '<br/>';
2084       $page .= '<table align="left">';       $page .= '<table align="left">';
# Line 2075  function email_view( $sort='') Line 2091  function email_view( $sort='')
2091       $page .= '</td></tr>';       $page .= '</td></tr>';
2092       $page .= '</form>';       $page .= '</form>';
2093       $page .= '</table>';       $page .= '</table>';
2094         $page .= '</table>';
2095    }    }
2096    else    else
2097    {    {
      $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';  
   
2098       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';
2099       $page .= '<br/>';       $page .= '<br/>';
2100    
2101       if ( drupal_mail( "addressbook", $email, $subject, $body, $from))       if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))
2102       {       {
2103          watchdog('Addressbook', t('Sent group email to ').$email);          watchdog('Addressbook', t('Sent group email to ').$email);
2104          $page .= t('Email is sent!');          $page .= t('Email has be sent to '.$email);
2105       }       }
2106       else       else
2107       {       {
2108          watchdog('Addressbook', t('Unable to email to ').$email);          watchdog('Addressbook', t('Unable to email to ').$email);
2109          $page .= t('Unable to email!');          $page .= t('Unable to email to '.$email);
2110       }       }
   
2111       $page .= '<br/>';       $page .= '<br/>';
2112       $page .= '<br/>';       $page .= '<br/>';
2113       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';
# Line 2141  function member_edit( $mid=0 ) { Line 2155  function member_edit( $mid=0 ) {
2155    $go_delete = isset($_POST['go_delete']) ? '1' : '0';    $go_delete = isset($_POST['go_delete']) ? '1' : '0';
2156    
2157    $uid=$user->uid;    $uid=$user->uid;
2158    $birthday_day=htmlentities( $_POST['birthday_day']);    $birthday_day=htmlentities($_POST['birthday_day']);
2159    $birthday_month=htmlentities($_POST['birthday_month']);    $birthday_month=htmlentities($_POST['birthday_month']);
2160    $birthday_year=htmlentities($_POST['birthday_year']);    $birthday_year=htmlentities($_POST['birthday_year']);
2161    $mobile=htmlentities($_POST['mobile']);    $mobile=htmlentities($_POST['mobile']);
# Line 2153  function member_edit( $mid=0 ) { Line 2167  function member_edit( $mid=0 ) {
2167    $middle_name=htmlentities($_POST['middle_name']);    $middle_name=htmlentities($_POST['middle_name']);
2168    $last_name=htmlentities(ucfirst($_POST['last_name']));    $last_name=htmlentities(ucfirst($_POST['last_name']));
2169    
2170    // Fill in some field with default values when new meber is created    // Fill in some fields with default values when a new member has been created
2171    if (($mid=='0') && ($commit=='0')) {    if (($mid=='0') && ($commit=='0')) {
2172       $query  = 'SELECT middle_name, last_name FROM {addressbook_family} WHERE fid='.$fid;       $query  = 'SELECT middle_name, last_name FROM {addressbook_family} WHERE fid='.$fid;
2173       $queryResult = db_query($query);       $queryResult = db_query($query);
# Line 2217  function member_edit( $mid=0 ) { Line 2231  function member_edit( $mid=0 ) {
2231       }       }
2232    }    }
2233    
2234    // Delete "are you sure" form    // Delete "Are you sure?" form
2235    if (($member_delete=='1') && ($mid!='0') && ($go_delete=='0')) {    if (($member_delete=='1') && ($mid!='0') && ($go_delete=='0')) {
2236      $page .= '<br/>';      $page .= '<br/>';
2237      $page .= t('Are you sure you want to delete this family member?');      $page .= t('Are you sure you want to delete this family member?');
# Line 2288  function member_edit( $mid=0 ) { Line 2302  function member_edit( $mid=0 ) {
2302        $birth_day = $birthday_year.'-'.$birthday_month.'-'.$birthday_day;        $birth_day = $birthday_year.'-'.$birthday_month.'-'.$birthday_day;
2303    
2304        if (($owner==0) && !user_access('access administration pages')) {        if (($owner==0) && !user_access('access administration pages')) {
2305           // Set new owner because items did not found owner yet!)           // Set new owner, because items did not find owner yet!)
2306           $owner=$user->uid;           $owner=$user->uid;
2307        }        }
2308    
# Line 2373  function member_edit( $mid=0 ) { Line 2387  function member_edit( $mid=0 ) {
2387       $queryResult = db_query($query);       $queryResult = db_query($query);
2388       $tmp = db_fetch_object($queryResult);       $tmp = db_fetch_object($queryResult);
2389    
2390       // If no data is found. Show anti hacking message       // If no data has been found. Show anti hacking message
2391       if ($tmp==null) {       if ($tmp==null) {
2392         return hacker_warning();         return hacker_warning();
2393       }       }
# Line 2436  function member_edit( $mid=0 ) { Line 2450  function member_edit( $mid=0 ) {
2450      {      {
2451        $picture_found++;        $picture_found++;
2452    
2453        // Show each picture with is found        // Show each picture which has been found
2454        $page .= '<a href="'.url(URL_PICTURE_VIEW.'/').$data->pid.'">';        $page .= '<a href="'.url(URL_PICTURE_VIEW.'/').$data->pid.'">';
2455        $filename=url(THUMBNAILS_DIR.'/'.$data->picture);        $filename=url(THUMBNAILS_DIR.'/'.$data->picture);
2456        $filename=str_replace(array("?q="), "", $filename);        $filename=str_replace(array("?q="), "", $filename);
# Line 2517  function member_edit( $mid=0 ) { Line 2531  function member_edit( $mid=0 ) {
2531        $page .= '</td>';        $page .= '</td>';
2532      }      }
2533    
2534      // Only exiting member can be be deleted      // Only existing member can be deleted
2535      $page .= '<td valign="top">';      $page .= '<td valign="top">';
2536      $page .= '<form action="'.url(URL_MEMBER_EDIT.'/').$mid.'" method="POST">';      $page .= '<form action="'.url(URL_MEMBER_EDIT.'/').$mid.'" method="POST">';
2537      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';
# Line 2526  function member_edit( $mid=0 ) { Line 2540  function member_edit( $mid=0 ) {
2540      $page .= '</td>';      $page .= '</td>';
2541    }    }
2542    
2543    // Cancel new created member    // Cancel newly created member
2544    $page .= '<td valign="top">';    $page .= '<td valign="top">';
2545    if ($_SESSION["list"]=='member') {    if ($_SESSION["list"]=='member') {
2546       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';
# Line 2579  function picture_view( $pid=0 ) { Line 2593  function picture_view( $pid=0 ) {
2593    $queryResult = db_query($query);    $queryResult = db_query($query);
2594    $tmp = db_fetch_object($queryResult);    $tmp = db_fetch_object($queryResult);
2595    
2596    // If no data is found. Show anti hacking message    // If no data has been found. Show anti hacking message
2597    if ($tmp==null) {    if ($tmp==null) {
2598      return hacker_warning();      return hacker_warning();
2599    }    }
2600    
2601    // Delete are you sure form    // Delete 'Are you sure?' form
2602    if (($picture_delete=='1') && ($pid!='0') && ($go_delete=='0')) {    if (($picture_delete=='1') && ($pid!='0') && ($go_delete=='0')) {
2603      $page .= '<br/>';      $page .= '<br/>';
2604      $page .= t('Are you sure you want to delete the picture?');      $page .= t('Are you sure you want to delete the picture?');
# Line 2621  function picture_view( $pid=0 ) { Line 2635  function picture_view( $pid=0 ) {
2635       if ($result==1)       if ($result==1)
2636       {       {
2637         // Query succesfull         // Query succesfull
2638         watchdog('user', 'Picture '.$pid.' is deleted in the addressbook');         watchdog('user', 'Picture '.$pid.' is deleted from the addressbook');
2639    
2640         $page .= '<td valign="top">';         $page .= '<td valign="top">';
2641         $page .= '<form action="'.url(URL_PICTURE_VIEW.'/'.$pid).'" method="POST">';         $page .= '<form action="'.url(URL_PICTURE_VIEW.'/'.$pid).'" method="POST">';
# Line 2645  function picture_view( $pid=0 ) { Line 2659  function picture_view( $pid=0 ) {
2659       else {       else {
2660         // Query failed         // Query failed
2661         $page .= '<br/>';         $page .= '<br/>';
2662         $page .= t('Failed to delete picture, try again');         $page .= t('Failed to delete picture, please try again');
2663         $page .= '<br/>';         $page .= '<br/>';
2664         $page .= '<br/>';         $page .= '<br/>';
2665         if ($mid!='0') {         if ($mid!='0') {
# Line 2749  function picture_edit( $mid=0 ) { Line 2763  function picture_edit( $mid=0 ) {
2763    $queryResult = db_query($query);    $queryResult = db_query($query);
2764    $tmp = db_fetch_object($queryResult);    $tmp = db_fetch_object($queryResult);
2765    
2766    // If no data is found. Show anti hacking message    // f no data has been found. Show anti hacking message
2767    if ($tmp==null) {    if ($tmp==null) {
2768      return hacker_warning();      return hacker_warning();
2769    }    }
# Line 2820  function picture_edit( $mid=0 ) { Line 2834  function picture_edit( $mid=0 ) {
2834           {           {
2835              chmod(IMAGE_DIR.'/'.$filename, 0666);              chmod(IMAGE_DIR.'/'.$filename, 0666);
2836           }           }
2837    
2838        }        }
2839        else        else
2840        {        {
2841          // Not resize needed, move file to storage place          // No resize needed, move file to storage
2842          copy($_FILES['uploadedfile']['tmp_name'],IMAGE_DIR.'/'.$filename);          copy($_FILES['uploadedfile']['tmp_name'],IMAGE_DIR.'/'.$filename);
2843        }        }
2844    
# Line 2871  function picture_edit( $mid=0 ) { Line 2886  function picture_edit( $mid=0 ) {
2886        {        {
2887          if (!image_scale(IMAGE_DIR.'/'.$filename, file_create_path(THUMBNAILS_DIR.'/'.$filename), $width, $height)) {          if (!image_scale(IMAGE_DIR.'/'.$filename, file_create_path(THUMBNAILS_DIR.'/'.$filename), $width, $height)) {
2888            $page .= '<br>';            $page .= '<br>';
2889            $page .= t('434Unable to create thumbnails image. Is Gd library active in apache php module?');            $page .= t('Unable to create thumbnails image. Is the GD library active in the Apache PHP module?');
2890            $error='1';            $error='1';
2891            $page .= '<br>';            $page .= '<br>';
2892          }          }
# Line 2882  function picture_edit( $mid=0 ) { Line 2897  function picture_edit( $mid=0 ) {
2897        }        }
2898        else        else
2899        {        {
2900          // Not resize needed, move file to storage place          // No resize needed, move file to storage
2901          copy(IMAGE_DIR.'/'.$filename, THUMBNAILS_DIR.'/'.$filename);          copy(IMAGE_DIR.'/'.$filename, THUMBNAILS_DIR.'/'.$filename);
2902        }        }
2903    
# Line 2898  function picture_edit( $mid=0 ) { Line 2913  function picture_edit( $mid=0 ) {
2913          if ($result==1)          if ($result==1)
2914          {          {
2915             // Query Succesfull             // Query Succesfull
2916             watchdog('user', 'A picture is added to address '.$id.' in addressbook');             watchdog('user', 'A picture has been added to address '.$id.' in addressbook');
2917    
2918             if ($mid=='0')             if ($mid=='0')
2919             {             {
# Line 2912  function picture_edit( $mid=0 ) { Line 2927  function picture_edit( $mid=0 ) {
2927          else {          else {
2928            // Query Failed            // Query Failed
2929            $page .= '<br/>';            $page .= '<br/>';
2930            $page .= t('Failed to add picture, try again!');            $page .= t('Failed to add picture, please try again!');
2931            $page .= '<br/>';            $page .= '<br/>';
2932          }          }
2933        }        }
2934      }      }
2935      else {      else {
2936        $page .= '<br/>';        $page .= '<br/>';
2937        $page.=t('Only JPG image format is supported');        $page.=t('Only the jpg image format is supported for pictures');
2938        $page .= '<br/>';        $page .= '<br/>';
2939        $_FILES['uploadedfile']['name']='';        $_FILES['uploadedfile']['name']='';
2940      }      }
# Line 3112  function process_csv_upload() { Line 3127  function process_csv_upload() {
3127          }          }
3128        }        }
3129    
3130        // If family insert/update was succesful continue with member insert/update.        // If family insert/update was successful, then continue with member insert/update.
3131        if ( $line_error==0 )        if ( $line_error==0 )
3132        {        {
3133          // Check if member already exist          // Check if member already exist
# Line 3199  function upload_csv() { Line 3214  function upload_csv() {
3214        else {        else {
3215          // Query Failed          // Query Failed
3216          $page .= '<br/>';          $page .= '<br/>';
3217          $page .= t('Failed to save csv file, try again!').'<br/>';          $page .= t('Failed to save csv file, please try again!').'<br/>';
3218          $page .= '<br/>';          $page .= '<br/>';
3219    
3220          // Return to family view page          // Return to family view page
# Line 3249  function upload_csv() { Line 3264  function upload_csv() {
3264  }  }
3265    
3266  /**  /**
3267   * Creat CSV file and start file transfer to web user.   * Create CSV file and start file transfer to web user.
3268   */   */
3269  function download_csv() {  function download_csv() {
3270    
# Line 3488  function map_view() { Line 3503  function map_view() {
3503    $street=htmlentities($_POST['street']);    $street=htmlentities($_POST['street']);
3504    $city=htmlentities($_POST['city']);    $city=htmlentities($_POST['city']);
3505    $country=htmlentities($_POST['country']);    $country=htmlentities($_POST['country']);
3506    $fid=$_POST['fid'];    $fid=htmlentities($_POST['fid']);
3507    $mid=$_POST['mid'];    $mid=htmlentities($_POST['mid']);
3508    
3509    drupal_set_html_head('');    drupal_set_html_head('');
3510    drupal_set_html_head('<script type=\'text/javascript\' src=\'http://api.map24.com/ajax/1.2/?init=default\'></script>');    drupal_set_html_head('<script type=\'text/javascript\' src=\'http://api.map24.com/ajax/1.2/?init=default\'></script>');

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.3