Ignore:
Timestamp:
Jan 15, 2013, 12:41:50 AM (11 years ago)
Author:
julien1311
Message:

[piwecard] several improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Piwecard/include/piwecard.class.php

    r20088 r20162  
    199199                                // Username or the current user
    200200                                $username = $user['username'];
     201                                if (!$this->config['user_cats_case_sensitive'])
     202                                        $catname = array_map('strtolower', $catname);
    201203                               
    202204                                // author of the photo
     
    212214                        if (($this->config['authorized_cats'] == 'all')         //Parameter : all
    213215                                OR ($this->config['authorized_cats'] == 'selected' AND !empty($upper_ids) AND (array_intersect($upper_ids, $this->config['selected_cats']) != array())) //Parameter : selected
    214                                 OR      ($this->config['authorized_cats'] == 'user' AND (in_array($username, $catname) OR $username == $authorname)) //Parameter : user
     216                                OR      ($this->config['authorized_cats'] == 'user' AND $this->config['user_cats_case_sensitive'] AND (in_array($username, $catname) OR $username == $authorname)) //Parameter : user AND case sensitive
     217                                OR      ($this->config['authorized_cats'] == 'user' AND !$this->config['user_cats_case_sensitive'] AND (in_array(strtolower($username), $catname) OR $username == $authorname)) //Parameter : user AND not case sensitive
    215218                        ) {
    216219                                // Check if user is guest.
     
    244247                                                );
    245248                                        }
     249                                } else {
     250                                        $template->assign('ecard_validity_hidden', $this->config['validity_default']);
    246251                                }
    247252
     
    254259                                        );
    255260                                }
     261                               
     262                                $template->set_filenames(array('ecard_template' =>  PIWECARD_ROOT.'/template/ecard.tpl'));
     263                                $template->concat('COMMENT_IMG', $template->parse('ecard_template', true));
    256264
    257265                                // Send the card
    258266                                if (isset($_POST['ecard_submit'])) {
    259267                                        $email_format = $_POST['ecard_email_format'];
     268                                       
     269                                        //Check fields
     270                                        if ($_POST['ecard_sender_name'] == ''
     271                                                OR $_POST['ecard_recipient_name'] == ''
     272                                                OR $_POST['ecard_sender_email'] == ''
     273                                                OR $_POST['ecard_recipient_email'] == ''
     274                                                OR $_POST['ecard_title'] == ''
     275                                                OR $_POST['ecard_message'] == '') {
     276                                                return;
     277                                        }
     278                                       
     279                                        if (($_POST['ecard_sender_email'] != '' AND !$piwecard->is_valid_email($_POST['ecard_sender_email']))
     280                                                OR ($_POST['ecard_recipient_email'] != '' AND !$piwecard->is_valid_email($_POST['ecard_recipient_email']))) {
     281                                                return;
     282                                        }
    260283                                       
    261284                                        // If conf doesn't allow to modify the %yourmail% param, force it to user mail
     
    322345                                        );
    323346                                        unset_make_full_url();
    324 
     347                                       
    325348                                        $email_subject = htmlspecialchars_decode($this->parse($this->config['email_subject'], $_POST, $image_element));
    326349                                        $email_message = htmlspecialchars_decode($this->parse($this->config['email_message'][$email_format], $_POST, $image_element));
     
    355378                                        pwg_mail($_POST['ecard_recipient_email'], $email_arg);
    356379                                }
    357                                
    358                                 $template->set_filenames(array('ecard_template' =>  PIWECARD_ROOT.'/template/ecard.tpl'));
    359                                 $template->concat('COMMENT_IMG', $template->parse('ecard_template', true));
    360380                        }
    361381                }
Note: See TracChangeset for help on using the changeset viewer.