/[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.32 by wplaat, Sun Sep 20 13:31:18 2009 UTC revision 1.33 by wplaat, Tue Oct 27 18:55:46 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($path, $arg) {  function addressbook_help($section) {
38    
39    $output = '';    $output = '';
40    switch ($path) {    switch ($section) {
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($path, $arg) { Line 45  function addressbook_help($path, $arg) {
45    return $output;    return $output;
46  }  }
47    
 function addressbook_mail($key, &$message, $params)  
 {  
   $message['subject'] = $params['subject'];  
   $message['body'] = $params['body'];  
 }  
   
48  /**  /**
49   * menu hook()   * menu hook()
50   * @return array of menu items   * @return array of menu items
51   */   */
52  function addressbook_menu()  function addressbook_menu() {
53  {  
54      $items = array();
55    
56    $items[URL_FAMILY_LIST] = array(    $items[] = array('path' => URL_FAMILY_LIST,
57                     'title' => 'Addressbook family list',                     'title' => t('Addressbook family list'),
58                     'page callback' => 'family_list',                     'callback' => 'family_list',
59                     'access arguments' => array('view addressbook'),                     'access' => user_access('view addressbook'),
60                     'type' => MENU_CALLBACK,                     'type' => MENU_CALLBACK);
61                  );  
62      $items[] = array('path' => URL_FAMILY_VIEW,
63    $items[URL_FAMILY_VIEW] = array(                     'title' => t('Addressbook view family'),
64                     'title' => 'Addressbook view family',                     'callback' => 'family_view2',
65                     'page callback' => 'family_view2',                     'access' => user_access('view addressbook'),
66                     'access arguments' => array('view addressbook'),                     'type' => MENU_CALLBACK);
67                     'type' => MENU_CALLBACK,  
68                  );    $items[] = array('path' => URL_FAMILY_EDIT,
69                       'title' => t('Addressbook edit family'),
70    $items[URL_FAMILY_EDIT] = array(                     'callback' => 'family_edit',
71                     'title' => 'Addressbook edit family',                     'access' => user_access('add address'),
72                     'page callback' => 'family_edit',                     'type' => MENU_CALLBACK);
73                     'access arguments' => array('add address'),  
74                     'type' => MENU_CALLBACK,    $items[] = array('path' => URL_MEMBER_LIST,
75                  );                     'title' => t('Addressbook family list'),
76                       'callback' => 'member_list',
77    $items[URL_MEMBER_LIST] = array(                     'access' => user_access('view addressbook'),
78                     'title' => 'Addressbook family list',                     'type' => MENU_CALLBACK);
79                     'page callback' => 'member_list',  
80                     'access arguments' => array('view addressbook'),    $items[] = array('path' => URL_MEMBER_VIEW,
81                     'type' => MENU_CALLBACK,                     'title' => t('Addressbook view family member'),
82                          );                     'callback' => 'member_view',
83                       'access' => user_access('view addressbook'),
84    $items[URL_MEMBER_VIEW] = array(                     'type' => MENU_CALLBACK);
85                     'title' => 'Addressbook view family member',  
86                     'page callback' => 'member_view',    $items[] = array('path' => URL_MEMBER_EDIT,
87                     'access arguments' => array('view addressbook'),                     'title' => t('Addressbook edit family member'),
88                     'type' => MENU_CALLBACK,                     'callback' => 'member_edit',
89                          );                     'access' => user_access('add address'),
90                       'type' => MENU_CALLBACK);
91    $items[URL_MEMBER_EDIT] = array(  
92                     'title' => 'Addressbook edit family member',    $items[] = array('path' => URL_PICTURE_VIEW,
93                     'page callback' => 'member_edit',                     'title' => t('Addressbook view picture'),
94                     'access arguments' => array('add address'),                     'callback' => 'picture_view',
95                     'type' => MENU_CALLBACK,                     'access' => user_access('view addressbook'),
96                          );                     'type' => MENU_CALLBACK);
97    
98    $items[URL_PICTURE_VIEW] = array(    $items[] = array('path' => URL_PICTURE_EDIT,
99                     'title' => 'Addressbook view picture',                     'title' => t('Addressbook edit picture'),
100                     'page callback' => 'picture_view',                     'callback' => 'picture_edit',
101                     'access arguments' => array('view addressbook'),                     'access' => user_access('add address'),
102                     'type' => MENU_CALLBACK,                     'type' => MENU_CALLBACK);
103                  );  
104      $items[] = array('path' => URL_UPLOAD_CSV,
105    $items[URL_PICTURE_EDIT] = array(                     'title' => t('Addressbook CSV upload'),
106                     'title' => 'Addressbook edit picture',                     'callback' => 'upload_csv',
107                     'page callback' => 'picture_edit',                     'access' => user_access('add address'),
108                     'access arguments' => array('add address'),                     'type' => MENU_CALLBACK);
109                     'type' => MENU_CALLBACK,  
110                          );    $items[] = array('path' => URL_DOWNLOAD_CSV,
111                       'title' => t('Addressbook CSV download'),
112    $items[URL_UPLOAD_CSV] = array(                     'callback' => 'download_csv',
113                     'title' => 'Addressbook CSV upload',                     'access' => user_access('add address'),
114                     'page callback' => 'upload_csv',                     'type' => MENU_CALLBACK);
115                     'access arguments' => array('add address'),  
116                     'type' => MENU_CALLBACK,     $items[] = array('path' => URL_SEARCH,
117                  );                     'title' => t('Addressbook search'),
118                       'callback' => 'general_search',
119    $items[URL_DOWNLOAD_CSV] = array(                     'access' => user_access('view addressbook'),
120                     'title' => 'Addressbook CSV download',                     'type' => MENU_CALLBACK);
121                     'page callback' => 'download_csv',  
122                     'access arguments' => array('add address'),     $items[] = array('path' => URL_MAP_VIEW,
123                     'type' => MENU_CALLBACK,                     'title' => t('Addressbook map view'),
124                  );                     'callback' => 'map_view',
125                       'access' => user_access('view addressbook'),
126     $items[URL_SEARCH] = array(                     'type' => MENU_CALLBACK);
127                     'title' => 'Addressbook search',  
128                     'page callback' => 'general_search',     $items[] = array('path' => URL_EMAIL,
129                     'access arguments' => array('view addressbook'),                     'title' => t('Addressbook email view'),
130                     'type' => MENU_CALLBACK,                     'callback' => 'email_view',
131                  );                     'access' => user_access('add address'),
132                       'type' => MENU_CALLBACK);
133     $items[URL_MAP_VIEW] = array(  
134                     'title' => 'Addressbook map view',     $items[] = array('path' => 'admin/settings/addressbook',
135                     'page callback' => 'map_view',                     'title' => t('Addressbook'),
136                     'access arguments' => array('view addressbook'),                     'description' => t('Settings of addressbook.'),
137                     'type' => MENU_CALLBACK,                     'callback' => 'drupal_get_form',
138                  );                     'callback arguments' => array('addressbook_settings'),
139                       'access' => user_access('administer site configuration'),
140     $items[URL_EMAIL] = array(                     'type' => MENU_NORMAL_ITEM);
                    'title' => 'Addressbook email view',  
                    'page callback' => 'email_view',  
                    'access arguments' => array('add address'),  
                    'type' => MENU_CALLBACK,  
                 );  
   
    $items['admin/settings/addressbook'] = array(  
                    'title' => 'Addressbook',  
                    'description' => 'Settings of addressbook.',  
                    'page callback' => 'drupal_get_form',  
                    'page arguments' => array('addressbook_settings'),  
                    'access arguments' => array('administer site configuration'),  
                    'type' => MENU_NORMAL_ITEM,  
                 );  
141    
142    return $items;    return $items;
143  }  }
144    
145  /**  /**
146    * Valid permissions for this module.    * Valid permisions for this module
147    * @return array an array of valid permission for the module    * @return array an array of valid permission for the module
148    */    */
149  function addressbook_perm() {  function addressbook_perm() {
# Line 171  function addressbook_perm() { Line 152  function addressbook_perm() {
152  }  }
153    
154  /**  /**
155   * Module configuration settings.   * Module configuration settings
156   * @return settings HTML or deny access   * @return settings HTML or deny access
157   */   */
158  function addressbook_settings() {  function addressbook_settings() {
# Line 188  function addressbook_settings() { Line 169  function addressbook_settings() {
169       '#title' => t('Name format '),       '#title' => t('Name format '),
170       '#default_value' => variable_get('addressbook_name_format',1),       '#default_value' => variable_get('addressbook_name_format',1),
171       '#options' => array( 0 => t('middle last, first'), 1 => t('first middle last') ),       '#options' => array( 0 => t('middle last, first'), 1 => t('first middle last') ),
172       '#description' => t('Set the name format which will be used in the general addressbook list page.'));       '#description' => t('Set with name format with will be used in the general addressbook list page.'));
173    
174    $form['settings_general']['addressbook_show_sort_bar'] = array(    $form['settings_general']['addressbook_show_sort_bar'] = array(
175       '#type' => 'select',       '#type' => 'select',
176       '#title' => t('Enable sort bar'),       '#title' => t('Enable sort bar'),
177       '#default_value' => variable_get('addressbook_show_sort_bar',1),       '#default_value' => variable_get('addressbook_show_sort_bar',1),
178       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
179       '#description' => t('Enable / disable sort bar in general addressbook list page.'));       '#description' => t('Enable / Disable sort bart in general addressbook list page.'));
180    
181    $form['settings_general']['addressbook_roles'] = array(    $form['settings_general']['addressbook_roles'] = array(
182       '#type' => 'textarea',       '#type' => 'textarea',
183       '#title' => t('Roles'),       '#title' => t('Roles'),
184       '#default_value' => variable_get('addressbook_roles', ''),       '#default_value' => variable_get('addressbook_roles', ''),
185       '#rows' => 1,       '#rows' => 1,
186       '#description' => t("Enter the roles which a person can have (Seperate items with commas (,). No spaces allowed).") );       '#description' => t("Enter roles with a person can have (Seperated items with commas. No space allowed).") );
187    
188    $form['settings_general']['addressbook_country'] = array(    $form['settings_general']['addressbook_country'] = array(
189       '#type' => 'textfield',       '#type' => 'textfield',
# Line 217  function addressbook_settings() { Line 198  function addressbook_settings() {
198       '#title' => t('Show thumbnails pictures in list views'),       '#title' => t('Show thumbnails pictures in list views'),
199       '#default_value' => variable_get('addressbook_show_thumbnails',0),       '#default_value' => variable_get('addressbook_show_thumbnails',0),
200       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
201       '#description' => t('Enable / disable thumbnail pictures in family list and family member list.'));       '#description' => t('Enable / Disable thumbnails pictures in family list and family member list.'));
202    
203    $form['settings_general']['addressbook_email_manitory'] = array(    $form['settings_general']['addressbook_email_manitory'] = array(
204       '#type' => 'select',       '#type' => 'select',
205       '#title' => t('Email field manitory'),       '#title' => t('Email field manitory'),
206       '#default_value' => variable_get('addressbook_email_manitory',1),       '#default_value' => variable_get('addressbook_email_manitory',1),
207       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
208       '#description' => t('Enable / disable email field as mandatory field.'));       '#description' => t('Enable / Disable email field as manitory field.'));
209    
210    $form['settings_general']['addressbook_wiki_edit_mode'] = array(    $form['settings_general']['addressbook_wiki_edit_mode'] = array(
211       '#type' => 'select',       '#type' => 'select',
212       '#title' => t('Wiki edit mode'),       '#title' => t('Wiki edit mode'),
213       '#default_value' => variable_get('addressbook_wiki_edit_mode',0),       '#default_value' => variable_get('addressbook_wiki_edit_mode',0),
214       '#options' => array( 0 => t('Disable'), 1 => t('Enable') ),       '#options' => array( 0 => t('Disable'), 1 => t('Enable') ),
215       '#description' => t('Enable (anyone can modify existing addresses), Disable (only owner can modify created addresses).'));       '#description' => t('Enable (Every one can modify existing addresses), Disable (Only owner can modify created addresses).'));
216    
217    
218    
# Line 248  function addressbook_settings() { Line 229  function addressbook_settings() {
229       '#type' => 'textfield',       '#type' => 'textfield',
230       '#title' => t('Free www.map24.com access key'),       '#title' => t('Free www.map24.com access key'),
231       '#default_value' => variable_get('addressbook_map_key', ''),       '#default_value' => variable_get('addressbook_map_key', ''),
232       '#description' => t("Enter access key (Visit http://www.map24.com to obtain a free key)"),       '#description' => t("Enter access key (Visit http://www.map24.com to get a free key)"),
233       '#maxlength' => '50',       '#maxlength' => '50',
234       '#size' => '50');       '#size' => '50');
235    
# Line 261  function addressbook_settings() { Line 242  function addressbook_settings() {
242       '#title' => t('Birthday email notification'),       '#title' => t('Birthday email notification'),
243       '#default_value' => variable_get('addressbook_birthday_notification',0),       '#default_value' => variable_get('addressbook_birthday_notification',0),
244       '#options' => array( 0 => t('No'), 1 => t('Yes') ),       '#options' => array( 0 => t('No'), 1 => t('Yes') ),
245       '#description' => t('Enable / disable email birthday notification.'));       '#description' => t('Enable / Disable email birthday notification.'));
246    
247    $form['birthday']['addressbook_birthday_subject'] = array(    $form['birthday']['addressbook_birthday_subject'] = array(
248       '#type' => 'textfield',       '#type' => 'textfield',
249       '#title' => t('Subject of birtday e-mail'),       '#title' => t('Subject of birtday e-mail'),
250       '#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'),
251       '#maxlength' => 180,       '#maxlength' => 180,
252       '#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');       '#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');
253    
254    $form['birthday']['addressbook_birthday_body'] = array(    $form['birthday']['addressbook_birthday_body'] = array(
255       '#type' => 'textarea',       '#type' => 'textarea',
256       '#title' => t('Body of birthday e-mail'),       '#title' => t('Body of birthday e-mail'),
257       '#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"),
258       '#rows' => 15,       '#rows' => 15,
259       '#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');       '#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');
260    
261    return system_settings_form($form);    return system_settings_form($form);
262    
263  }  }
264    
265  /**  /**
266    * Find all family members which are celebrating their birthday to day and send them an email.    * Find all family member with are celebrating there birth_day to day and send a email.
267    * @return emails    * @return emails
268    */    */
269  function addressbook_cron() {  function addressbook_cron() {
# Line 290  function addressbook_cron() { Line 271  function addressbook_cron() {
271    // If birthday notification is enabled check all family members.    // If birthday notification is enabled check all family members.
272    if ( variable_get('addressbook_birthday_notification',0)==1 ) {    if ( variable_get('addressbook_birthday_notification',0)==1 ) {
273    
274      // Send the birthday notication only once in any given day (crontab may run more frequently)      // Send only one time the birthday notications per day (crontab runs every hour)
275      $current_day=date('-m-d');      $current_day=date('-m-d');
276      $current_time=date('H');      $current_time=date('H');
277    
278      if ($current_time==0) {      if ($current_time==0)
279        {
280        watchdog('cron', t('Addressbook birthday cron'));        watchdog('cron', t('Addressbook birthday cron'));
281    
282        // Fetch all members with are celebrating there birtday        // Fetch all members with are celebrating there birtday
283        $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.'"';
284        $queryResult = db_query($query);        $queryResult = db_query($query);
285        while ($data = db_fetch_object($queryResult)) {        while ($data = db_fetch_object($queryResult))
286          {
287    
288          $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);
289    
290          $email = $data->email;          $email = $data->email;
# Line 311  function addressbook_cron() { Line 295  function addressbook_cron() {
295          $user_age  = date('Y')-$year;          $user_age  = date('Y')-$year;
296    
297          // if family member have a email address send a email          // if family member have a email address send a email
298          if (($email!='') && ($user_age<100)) {          if (($email!='') && ($user_age<100))
299            {
300            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';
301    
302            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');
303            $subject=str_replace("%username", $username, $subject);            $subject = str_replace("%username", $username, $subject);
304            $subject=str_replace("%site_name", $site_name, $subject);            $subject = str_replace("%site_name", $site_name, $subject);
305    
306            $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");            $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");
307            $body=str_replace("%username", $username, $body);            $message = str_replace("%username", $username, $message);
308            $body=str_replace("%user_age", $user_age, $body);            $message = str_replace("%user_age", $user_age, $message);
309            $body=str_replace("%site_name", $site_name, $body);            $message = str_replace("%site_name", $site_name, $message);
310    
311            if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))              if ( drupal_mail( "addressbook", $email, $subject, $message, $from))
312            {              {
313              watchdog('cron', t('Sent birthday email to ').$email);               watchdog('cron', t('Sent birthday email to ').$email);
314            }            }
315            else            else
316            {            {
# Line 338  function addressbook_cron() { Line 323  function addressbook_cron() {
323  }  }
324    
325  /**  /**
326    * Find all family members which are celebrating their birthday today and make a block of it.    * Find all family member with are celebrating there birth_day to day and make a block of it.
327    * @return emails    * @return emails
328    */    */
329  function addressbook_block($op='list', $delta=0) {  function addressbook_block($op='list', $delta=0) {
# Line 491  function view_owner($uid, $readonly) { Line 476  function view_owner($uid, $readonly) {
476       $query  = 'SELECT uid, name FROM {users}';       $query  = 'SELECT uid, name FROM {users}';
477       $queryResult = db_query($query);       $queryResult = db_query($query);
478    
479       // Workaround Drupal first entry in users table is always empty. Skip this entry       // Workarround Drupal first entry in users table is always empty. Skip this entry
480       $tmp = db_fetch_object($queryResult);       $tmp = db_fetch_object($queryResult);
481    
482       $page.='<select name="owner">';       $page.='<select name="owner">';
# Line 545  function view_roles($active_roles,$wante Line 530  function view_roles($active_roles,$wante
530    
531     if ( $readonly=='0' ) {     if ( $readonly=='0' ) {
532       $page .= '<br/>';       $page .= '<br/>';
533       $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/>';       $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/>';
534       $page .= '<br/>';       $page .= '<br/>';
535     }     }
536    
# Line 705  function check_mail($adres) { Line 690  function check_mail($adres) {
690  }  }
691    
692  /*  /*
693   * Function valid number input   * Function valid number imput
694   * @returns true if valid number (only numeric string), false if not   * @returns true if valid number (only numeric string), false if not
695   */   */
696  function check_number($str) {  function check_number($str) {
# Line 1050  function family_list( $sort='', $search= Line 1035  function family_list( $sort='', $search=
1035    }    }
1036    $page .= '</table>';    $page .= '</table>';
1037    
1038     // Only administrators can access the csv upload functionality     // Only administrators can access the csv upload functionaly
1039    if (user_access('access administration pages')) {    if (user_access('access administration pages')) {
1040       //$page .= '<br/>';       //$page .= '<br/>';
1041       $page .= '<table border="0" width="100%">';       $page .= '<table border="0" width="100%">';
# Line 1139  function family_view2( $fid=0 ) { Line 1124  function family_view2( $fid=0 ) {
1124    $picture_found=0;    $picture_found=0;
1125    while ($data = db_fetch_object($queryResult))    while ($data = db_fetch_object($queryResult))
1126    {    {
1127      // Show each picture which is found      // Show each picture with is found
1128      $picture_found++;      $picture_found++;
1129      $page .= '<td valign="top">';      $page .= '<td valign="top">';
1130      $page .= '<a href="'.url(URL_PICTURE_VIEW.'/'.$data->pid).'" >';      $page .= '<a href="'.url(URL_PICTURE_VIEW.'/'.$data->pid).'" >';
# Line 1263  function family_view2( $fid=0 ) { Line 1248  function family_view2( $fid=0 ) {
1248      $page .= '</form>';      $page .= '</form>';
1249      $page .= '</td>';      $page .= '</td>';
1250    
1251      // Maximum of three pictures allowed      // Maximum three pictures allowed
1252      if ($picture_found<3)      if ($picture_found<3)
1253      {      {
1254        $page .= '<td align="left">';        $page .= '<td align="left">';
# Line 1351  function family_edit($fid=0) { Line 1336  function family_edit($fid=0) {
1336    $family_delete = isset($_POST['family_delete']) ? '1' : '0';    $family_delete = isset($_POST['family_delete']) ? '1' : '0';
1337    $go_delete = isset($_POST['go_delete']) ? '1' : '0';    $go_delete = isset($_POST['go_delete']) ? '1' : '0';
1338    
1339    $middle_name=$_POST['middle_name'];    $middle_name=htmlentities($_POST['middle_name']);
1340    $last_name=ucfirst($_POST['last_name']);    $last_name=htmlentities(ucfirst($_POST['last_name']));
1341    $street=ucfirst($_POST['street']);    $street=htmlentities(ucfirst($_POST['street']));
1342    $zipcode=$_POST['zipcode'];    $zipcode=htmlentities($_POST['zipcode']);
1343    $city=ucfirst($_POST['city']);    $city=htmlentities(ucfirst($_POST['city']));
1344    $country=$_POST['country'];    $country=htmlentities($_POST['country']);
1345    if ($country=='') $country=variable_get('addressbook_country', 'Nederland');    if ($country=='') $country=variable_get('addressbook_country', 'Nederland');
1346    $telephone=$_POST['telephone'];    $telephone=htmlentities($_POST['telephone']);
1347    $owner=$_POST['owner'];    $owner=htmlentities($_POST['owner']);
1348    
1349    // Delete are you sure form    // Delete are you sure form
1350    if (($family_delete=='1') && ($fid!='0') && ($go_delete=='0')) {    if (($family_delete=='1') && ($fid!='0') && ($go_delete=='0')) {
# Line 1582  function family_edit($fid=0) { Line 1567  function family_edit($fid=0) {
1567    $page .= '</td>';    $page .= '</td>';
1568    
1569    if ($fid!='0') {    if ($fid!='0') {
1570      // Only existing families can be deleted      // Only exiting families can be be deleted
1571      $page .= '<td valign="top">';      $page .= '<td valign="top">';
1572      $page .= '<form action="'.url(URL_FAMILY_EDIT.'/').$fid.'" method="POST">';      $page .= '<form action="'.url(URL_FAMILY_EDIT.'/').$fid.'" method="POST">';
1573      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';
# Line 1741  function member_list( $sort='' ) { Line 1726  function member_list( $sort='' ) {
1726    $page .= '<table width=100% border=1 cellpadding=3 cellspacing=3>';    $page .= '<table width=100% border=1 cellpadding=3 cellspacing=3>';
1727    
1728    // Show Banner    // Show Banner
1729     // Only administrators can access the csv upload functionality     // Only administrators can access the csv upload functionaly
1730    $page .= '<tr><td>';    $page .= '<tr><td>';
1731    if (user_access('access administration pages'))    if (user_access('access administration pages'))
1732    {    {
# Line 2063  function email_view( $sort='') Line 2048  function email_view( $sort='')
2048    
2049    if ($commit=='0')    if ($commit=='0')
2050    {    {
      $page .= '<table align="left" width="100%">';  
2051       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';
2052       $page .= '<br/>';       $page .= '<br/>';
2053       $page .= t('To:');       $page .= t('To:');
2054       $page .= '<br/>';       $page .= '<br/>';
2055       $page .= '<textarea id="email" rows=5 cols=100 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';       $page .= '<textarea id="email" cols=140 rows=5 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';
2056       $page .= '<br/>';       $page .= '<br/>';
2057       $page .= '<br/>';       $page .= '<br/>';
2058       $page .= t('Subject:');       $page .= t('Subject:');
2059       $page .= '<br/>';       $page .= '<br/>';
2060       $page .= '<input id="text" name="subject" size=100 maxlength="143" type="text" value="'.$subject.'" />';       $page .= '<input id="text" name="subject" size="143" maxlength="143" type="text" value="'.$subject.'" />';
2061       $page .= '<br/>';       $page .= '<br/>';
2062       $page .= '<br/>';       $page .= '<br/>';
2063       $page .= t('Content:');       $page .= t('Content:');
2064       $page .= '<br/>';       $page .= '<br/>';
2065       $page .= '<textarea id="body" rows=10 cols=100 maxlength="2000" name="body" >'.$body.'</textarea>';       $page .= '<textarea id="body" cols=140 rows=10 maxlength="2000" name="body" >'.$body.'</textarea>';
2066       $page .= '<br/>';       $page .= '<br/>';
2067       $page .= '<br/>';       $page .= '<br/>';
2068       $page .= '<table align="left">';       $page .= '<table align="left">';
# Line 2091  function email_view( $sort='') Line 2075  function email_view( $sort='')
2075       $page .= '</td></tr>';       $page .= '</td></tr>';
2076       $page .= '</form>';       $page .= '</form>';
2077       $page .= '</table>';       $page .= '</table>';
      $page .= '</table>';  
2078    }    }
2079    else    else
2080    {    {
2081         $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';
2082    
2083       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';
2084       $page .= '<br/>';       $page .= '<br/>';
2085    
2086       if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))       if ( drupal_mail( "addressbook", $email, $subject, $body, $from))
2087       {       {
2088          watchdog('Addressbook', t('Sent group email to ').$email);          watchdog('Addressbook', t('Sent group email to ').$email);
2089          $page .= t('Email has be sent to '.$email);          $page .= t('Email is sent!');
2090       }       }
2091       else       else
2092       {       {
2093          watchdog('Addressbook', t('Unable to email to ').$email);          watchdog('Addressbook', t('Unable to email to ').$email);
2094          $page .= t('Unable to email to '.$email);          $page .= t('Unable to email!');
2095       }       }
2096    
2097       $page .= '<br/>';       $page .= '<br/>';
2098       $page .= '<br/>';       $page .= '<br/>';
2099       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';
# Line 2155  function member_edit( $mid=0 ) { Line 2141  function member_edit( $mid=0 ) {
2141    $go_delete = isset($_POST['go_delete']) ? '1' : '0';    $go_delete = isset($_POST['go_delete']) ? '1' : '0';
2142    
2143    $uid=$user->uid;    $uid=$user->uid;
2144    $birthday_day=$_POST['birthday_day'];    $birthday_day=htmlentities( $_POST['birthday_day']);
2145    $birthday_month=$_POST['birthday_month'];    $birthday_month=htmlentities($_POST['birthday_month']);
2146    $birthday_year=$_POST['birthday_year'];    $birthday_year=htmlentities($_POST['birthday_year']);
2147    $mobile=$_POST['mobile'];    $mobile=htmlentities($_POST['mobile']);
2148    $email=$_POST['email'];    $email=htmlentities($_POST['email']);
2149    $work=$_POST['work'];    $work=htmlentities($_POST['work']);
2150    $notes=$_POST['notes'];    $notes=htmlentities($_POST['notes']);
2151    $owner=$_POST['owner'];    $owner=htmlentities($_POST['owner']);
2152    $first_name=ucfirst($_POST['first_name']);    $first_name=htmlentities(ucfirst($_POST['first_name']));
2153    $middle_name=$_POST['middle_name'];    $middle_name=htmlentities($_POST['middle_name']);
2154    $last_name=ucfirst($_POST['last_name']);    $last_name=htmlentities(ucfirst($_POST['last_name']));
2155    
2156    // Fill in some fields with default values when a new member has been created    // Fill in some field with default values when new meber is created
2157    if (($mid=='0') && ($commit=='0')) {    if (($mid=='0') && ($commit=='0')) {
2158       $query  = 'SELECT middle_name, last_name FROM {addressbook_family} WHERE fid='.$fid;       $query  = 'SELECT middle_name, last_name FROM {addressbook_family} WHERE fid='.$fid;
2159       $queryResult = db_query($query);       $queryResult = db_query($query);
# Line 2231  function member_edit( $mid=0 ) { Line 2217  function member_edit( $mid=0 ) {
2217       }       }
2218    }    }
2219    
2220    // Delete "Are you sure?" form    // Delete "are you sure" form
2221    if (($member_delete=='1') && ($mid!='0') && ($go_delete=='0')) {    if (($member_delete=='1') && ($mid!='0') && ($go_delete=='0')) {
2222      $page .= '<br/>';      $page .= '<br/>';
2223      $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 2302  function member_edit( $mid=0 ) { Line 2288  function member_edit( $mid=0 ) {
2288        $birth_day = $birthday_year.'-'.$birthday_month.'-'.$birthday_day;        $birth_day = $birthday_year.'-'.$birthday_month.'-'.$birthday_day;
2289    
2290        if (($owner==0) && !user_access('access administration pages')) {        if (($owner==0) && !user_access('access administration pages')) {
2291           // Set new owner, because items did not find owner yet!)           // Set new owner because items did not found owner yet!)
2292           $owner=$user->uid;           $owner=$user->uid;
2293        }        }
2294    
# Line 2387  function member_edit( $mid=0 ) { Line 2373  function member_edit( $mid=0 ) {
2373       $queryResult = db_query($query);       $queryResult = db_query($query);
2374       $tmp = db_fetch_object($queryResult);       $tmp = db_fetch_object($queryResult);
2375    
2376       // If no data has been found. Show anti hacking message       // If no data is found. Show anti hacking message
2377       if ($tmp==null) {       if ($tmp==null) {
2378         return hacker_warning();         return hacker_warning();
2379       }       }
# Line 2450  function member_edit( $mid=0 ) { Line 2436  function member_edit( $mid=0 ) {
2436      {      {
2437        $picture_found++;        $picture_found++;
2438    
2439        // Show each picture which has been found        // Show each picture with is found
2440        $page .= '<a href="'.url(URL_PICTURE_VIEW.'/').$data->pid.'">';        $page .= '<a href="'.url(URL_PICTURE_VIEW.'/').$data->pid.'">';
2441        $filename=url(THUMBNAILS_DIR.'/'.$data->picture);        $filename=url(THUMBNAILS_DIR.'/'.$data->picture);
2442        $filename=str_replace(array("?q="), "", $filename);        $filename=str_replace(array("?q="), "", $filename);
# Line 2531  function member_edit( $mid=0 ) { Line 2517  function member_edit( $mid=0 ) {
2517        $page .= '</td>';        $page .= '</td>';
2518      }      }
2519    
2520      // Only existing member can be deleted      // Only exiting member can be be deleted
2521      $page .= '<td valign="top">';      $page .= '<td valign="top">';
2522      $page .= '<form action="'.url(URL_MEMBER_EDIT.'/').$mid.'" method="POST">';      $page .= '<form action="'.url(URL_MEMBER_EDIT.'/').$mid.'" method="POST">';
2523      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';      $page .= '<input type="hidden" name="fid" value="'.$fid.'" />';
# Line 2540  function member_edit( $mid=0 ) { Line 2526  function member_edit( $mid=0 ) {
2526      $page .= '</td>';      $page .= '</td>';
2527    }    }
2528    
2529    // Cancel newly created member    // Cancel new created member
2530    $page .= '<td valign="top">';    $page .= '<td valign="top">';
2531    if ($_SESSION["list"]=='member') {    if ($_SESSION["list"]=='member') {
2532       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';
# Line 2593  function picture_view( $pid=0 ) { Line 2579  function picture_view( $pid=0 ) {
2579    $queryResult = db_query($query);    $queryResult = db_query($query);
2580    $tmp = db_fetch_object($queryResult);    $tmp = db_fetch_object($queryResult);
2581    
2582    // If no data has been found. Show anti hacking message    // If no data is found. Show anti hacking message
2583    if ($tmp==null) {    if ($tmp==null) {
2584      return hacker_warning();      return hacker_warning();
2585    }    }
2586    
2587    // Delete 'Are you sure?' form    // Delete are you sure form
2588    if (($picture_delete=='1') && ($pid!='0') && ($go_delete=='0')) {    if (($picture_delete=='1') && ($pid!='0') && ($go_delete=='0')) {
2589      $page .= '<br/>';      $page .= '<br/>';
2590      $page .= t('Are you sure you want to delete the picture?');      $page .= t('Are you sure you want to delete the picture?');
# Line 2635  function picture_view( $pid=0 ) { Line 2621  function picture_view( $pid=0 ) {
2621       if ($result==1)       if ($result==1)
2622       {       {
2623         // Query succesfull         // Query succesfull
2624         watchdog('user', 'Picture '.$pid.' is deleted from the addressbook');         watchdog('user', 'Picture '.$pid.' is deleted in the addressbook');
2625    
2626         $page .= '<td valign="top">';         $page .= '<td valign="top">';
2627         $page .= '<form action="'.url(URL_PICTURE_VIEW.'/'.$pid).'" method="POST">';         $page .= '<form action="'.url(URL_PICTURE_VIEW.'/'.$pid).'" method="POST">';
# Line 2659  function picture_view( $pid=0 ) { Line 2645  function picture_view( $pid=0 ) {
2645       else {       else {
2646         // Query failed         // Query failed
2647         $page .= '<br/>';         $page .= '<br/>';
2648         $page .= t('Failed to delete picture, please try again');         $page .= t('Failed to delete picture, try again');
2649         $page .= '<br/>';         $page .= '<br/>';
2650         $page .= '<br/>';         $page .= '<br/>';
2651         if ($mid!='0') {         if ($mid!='0') {
# Line 2763  function picture_edit( $mid=0 ) { Line 2749  function picture_edit( $mid=0 ) {
2749    $queryResult = db_query($query);    $queryResult = db_query($query);
2750    $tmp = db_fetch_object($queryResult);    $tmp = db_fetch_object($queryResult);
2751    
2752    // f no data has been found. Show anti hacking message    // If no data is found. Show anti hacking message
2753    if ($tmp==null) {    if ($tmp==null) {
2754      return hacker_warning();      return hacker_warning();
2755    }    }
# Line 2834  function picture_edit( $mid=0 ) { Line 2820  function picture_edit( $mid=0 ) {
2820           {           {
2821              chmod(IMAGE_DIR.'/'.$filename, 0666);              chmod(IMAGE_DIR.'/'.$filename, 0666);
2822           }           }
   
2823        }        }
2824        else        else
2825        {        {
2826          // No resize needed, move file to storage          // Not resize needed, move file to storage place
2827          copy($_FILES['uploadedfile']['tmp_name'],IMAGE_DIR.'/'.$filename);          copy($_FILES['uploadedfile']['tmp_name'],IMAGE_DIR.'/'.$filename);
2828        }        }
2829    
# Line 2886  function picture_edit( $mid=0 ) { Line 2871  function picture_edit( $mid=0 ) {
2871        {        {
2872          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)) {
2873            $page .= '<br>';            $page .= '<br>';
2874            $page .= t('Unable to create thumbnails image. Is the GD library active in the Apache PHP module?');            $page .= t('434Unable to create thumbnails image. Is Gd library active in apache php module?');
2875            $error='1';            $error='1';
2876            $page .= '<br>';            $page .= '<br>';
2877          }          }
# Line 2897  function picture_edit( $mid=0 ) { Line 2882  function picture_edit( $mid=0 ) {
2882        }        }
2883        else        else
2884        {        {
2885          // No resize needed, move file to storage          // Not resize needed, move file to storage place
2886          copy(IMAGE_DIR.'/'.$filename, THUMBNAILS_DIR.'/'.$filename);          copy(IMAGE_DIR.'/'.$filename, THUMBNAILS_DIR.'/'.$filename);
2887        }        }
2888    
# Line 2913  function picture_edit( $mid=0 ) { Line 2898  function picture_edit( $mid=0 ) {
2898          if ($result==1)          if ($result==1)
2899          {          {
2900             // Query Succesfull             // Query Succesfull
2901             watchdog('user', 'A picture has been added to address '.$id.' in addressbook');             watchdog('user', 'A picture is added to address '.$id.' in addressbook');
2902    
2903             if ($mid=='0')             if ($mid=='0')
2904             {             {
# Line 2927  function picture_edit( $mid=0 ) { Line 2912  function picture_edit( $mid=0 ) {
2912          else {          else {
2913            // Query Failed            // Query Failed
2914            $page .= '<br/>';            $page .= '<br/>';
2915            $page .= t('Failed to add picture, please try again!');            $page .= t('Failed to add picture, try again!');
2916            $page .= '<br/>';            $page .= '<br/>';
2917          }          }
2918        }        }
2919      }      }
2920      else {      else {
2921        $page .= '<br/>';        $page .= '<br/>';
2922        $page.=t('Only the jpg image format is supported for pictures');        $page.=t('Only JPG image format is supported');
2923        $page .= '<br/>';        $page .= '<br/>';
2924        $_FILES['uploadedfile']['name']='';        $_FILES['uploadedfile']['name']='';
2925      }      }
# Line 3127  function process_csv_upload() { Line 3112  function process_csv_upload() {
3112          }          }
3113        }        }
3114    
3115        // If family insert/update was successful, then continue with member insert/update.        // If family insert/update was succesful continue with member insert/update.
3116        if ( $line_error==0 )        if ( $line_error==0 )
3117        {        {
3118          // Check if member already exist          // Check if member already exist
# Line 3214  function upload_csv() { Line 3199  function upload_csv() {
3199        else {        else {
3200          // Query Failed          // Query Failed
3201          $page .= '<br/>';          $page .= '<br/>';
3202          $page .= t('Failed to save csv file, please try again!').'<br/>';          $page .= t('Failed to save csv file, try again!').'<br/>';
3203          $page .= '<br/>';          $page .= '<br/>';
3204    
3205          // Return to family view page          // Return to family view page
# Line 3264  function upload_csv() { Line 3249  function upload_csv() {
3249  }  }
3250    
3251  /**  /**
3252   * Create CSV file and start file transfer to web user.   * Creat CSV file and start file transfer to web user.
3253   */   */
3254  function download_csv() {  function download_csv() {
3255    
# Line 3393  function general_search($search="") { Line 3378  function general_search($search="") {
3378    drupal_set_title(t('Addressbook search'));    drupal_set_title(t('Addressbook search'));
3379    
3380    // Fetch search parameter out HTTP request    // Fetch search parameter out HTTP request
3381    if ($search=='') $search=$_POST['search'];    if ($search=='') $search=htmlentities($_POST['search']);
3382    // Set search value in session scope    // Set search value in session scope
3383    $_SESSION["search"]=$search;    $_SESSION["search"]=$search;
3384    
# Line 3500  function map_view() { Line 3485  function map_view() {
3485    drupal_set_title(t('Addressbook map view'));    drupal_set_title(t('Addressbook map view'));
3486    
3487    // Fetch search parameter out HTTP request    // Fetch search parameter out HTTP request
3488    $street=$_POST['street'];    $street=htmlentities($_POST['street']);
3489    $city=$_POST['city'];    $city=htmlentities($_POST['city']);
3490    $country=$_POST['country'];    $country=htmlentities($_POST['country']);
3491    $fid=$_POST['fid'];    $fid=$_POST['fid'];
3492    $mid=$_POST['mid'];    $mid=$_POST['mid'];
3493    

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

  ViewVC Help
Powered by ViewVC 1.1.3