Ignore:
Timestamp:
Jan 10, 2013, 12:59:07 AM (11 years ago)
Author:
julien1311
Message:

[piwecard] lots of fixes

File:
1 edited

Legend:

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

    r20013 r20032  
    88        // Class constructor
    99        function __construct() {
    10                 $this->load_config();
     10                $this->get_config();
    1111        }
    1212       
    1313        // Load general configuration from config_database
    14         function load_config() {
     14        function get_config() {
    1515                $query = 'SELECT value FROM '.CONFIG_TABLE.' WHERE param="piwecard";';
    1616                $result = pwg_query($query);
     
    2222                        }
    2323            }
    24                 $this->load_default_config();
     24                $this->get_default_config();
    2525        }
    2626       
    2727        // Initialize default values of params
    28         private function load_default_config() {
     28        private function get_default_config() {
    2929            require(ECARD_INSTALL_PATH.'default_values.inc.php');
    3030            foreach ($ecard_default_values as $key => $value) {
     
    3535
    3636        // Save  general configuration to config_database
    37         function save_config() {
     37        function set_config() {
    3838                conf_update_param('piwecard', pwg_db_real_escape_string(serialize($this->my_config)));
    3939        }
     
    5050               
    5151                if (isset($page['section']) and $page['section'] == 'ecard') {
    52                         include(ECARD_PATH . 'publish.php');
     52                        include('publish.inc.php');
    5353                }
    5454        }
     
    173173                                        $upper_ids = null;
    174174                                } else {
    175                                         foreach ($cat as $k => $v) {
    176                                                 // If the field is true or false, the variable is transformed into a
    177                                                 // boolean value.
    178                                                 if ($cat[$k] == 'true' or $cat[$k] == 'false') {
    179                                                   $cat[$k] = get_boolean($cat[$k]);
    180                                                 }
    181                                         }
    182175                                        $upper_ids = explode(',', $cat['uppercats']);
    183176                                }
    184177                        }
    185178                       
    186                         if ($this->my_config['authorizations'] == 'user_cats') {        // !Function only allowed on user image
    187                                 // Check the category name, user name et img author
    188                                 // Get all name for upper categories and current category
     179                        if ($this->my_config['authorized_cats'] == 'user') {    // !Function only allowed on user image
    189180                                if (isset($cat) and !empty($cat)) {
    190181                                        $catname[0] = $cat['name'];
     
    192183                                                $nb=1;
    193184                                                foreach ($upper_ids as $upper_cat) {
    194                                                         // Get upper cat info and store the name
    195185                                                        $cat_info = get_cat_info($upper_cat);
    196186                                                        $catname[$nb++] = $cat_info['name'];
     
    211201                       
    212202                        // Only on available cats
    213                         if (($this->my_config['authorizations'] == 'all_cats')          //Parameter : all_cats
    214                                 OR ($this->my_config['authorizations'] == 'selected_cats' AND isset($upper_ids) AND (array_intersect($upper_ids, $this->my_config['selected_cats']) != array())) //Parameter : selected_cats and recursive
    215                                 OR      ($this->my_config['authorizations'] == 'user_cats' AND (in_array($username, $catname) OR $username == $authorname)) //Parameter : user_cats
     203                        if (($this->my_config['authorized_cats'] == 'all')              //Parameter : all
     204                                OR ($this->my_config['authorized_cats'] == 'selected' AND !empty($upper_ids) AND (array_intersect($upper_ids, $this->my_config['selected_cats']) != array())) //Parameter : selected
     205                                OR      ($this->my_config['authorized_cats'] == 'user' AND (in_array($username, $catname) OR $username == $authorname)) //Parameter : user
    216206                        ) {
    217207                                // Check if user is guest.
    218                                 // In this case, force mail to default mail (in params)
     208                                // In this case, force mail to default mail (in configuration)
    219209                                if (is_a_guest()) {
    220210                                        if (!empty($this->my_config['default_guest_email']))
     
    224214                                // Template informations
    225215                                $template->assign('ecard', array(
    226                                                 'subject'                       => l10n('ecard_send_title'),
    227                                                 'message'                       => l10n('ecard_send_message'),
     216                                                'subject'                       => l10n('ecard_subject'),
     217                                                'message'                       => l10n('ecard_message'),
    228218                                                'sender_name'           => $user['username'],
    229219                                                'sender_email'          => $user['email'],
    230                                                 'recipient_name'        => l10n('ecard_send_dest_name'),
    231                                                 'recipient_email'       => l10n('ecard_send_dest_mail'),
     220                                                'recipient_name'        => l10n('ecard_recipient_name'),
     221                                                'recipient_email'       => l10n('ecard_recipient_email'),
    232222                                                'copy'                          => $this->my_config['sender_copy'] ? 'checked="checked"' : '',
    233223                                                'changemail'            => (!isset($user['email']) OR $this->my_config['sender_email_change']) ? '' : 'disabled="disabled"'
     
    248238                               
    249239                                foreach ($this->my_config['email_format'] as $email_format) {
    250                                         $template->append('ecard_send_method', array(
     240                                        $template->append('ecard_email_format', array(
    251241                                                                                                                                'id' => $email_format,
    252242                                                                                                                                'name' => l10n('ecard_mail_format_'.$email_format),
     
    258248                                // Send the card
    259249                                if (isset($_POST['ecard_submit'])) {
    260                                         $send_method = $_POST['ecard_send_method'];
    261                                        
    262                                         // If conf doesn't allow to modify the %votremail param, force it to user mail
     250                                        $email_format = $_POST['ecard_email_format'];
     251                                       
     252                                        // If conf doesn't allow to modify the %yourmail% param, force it to user mail
    263253                                        if (!$this->my_config['sender_email_change'])
    264254                                                $_POST['ecard_sender_email'] = $user['email'];
     
    321311
    322312                                        $email_subject = htmlspecialchars_decode($this->parse( $this->my_config['email_subject'], $_POST));
    323                                         $email_message = htmlspecialchars_decode($this->parse($this->my_config['email_message'][$send_method], $_POST, $image_element));
     313                                        $email_message = htmlspecialchars_decode($this->parse($this->my_config['email_message'][$email_format], $_POST, $image_element));
    324314                                        $email_arg=array(       'from' => $_POST['ecard_sender_email'],
    325315                                                                                'subject'                       => $email_subject,
     
    327317                                                                        );
    328318                                                                       
    329                                         switch($send_method) {
     319                                        switch($email_format) {
    330320                                                case 'text': // text
    331                                                         $email_arg=array(       'content_format'        => "text/plain",
    332                                                                                                 'email_format'          => "text/plain"
    333                                                                                         );
     321                                                        $email_arg = array_merge($email_arg, array(
     322                                                                                                                                                'content_format'        => "text/plain",
     323                                                                                                                                                'email_format'          => "text/plain"
     324                                                                                                                                        )
     325                                                        );
    334326                                                        break;
    335327                                                case 'html': // html
    336                                                         $email_arg=array(       'content_format' => "text/html",
    337                                                                                                 'email_format' => "text/html"
    338                                                                                         );
    339                                                         break;
     328                                                        $email_arg = array_merge($email_arg, array(
     329                                                                                                                                                'content_format'        => "text/html",
     330                                                                                                                                                'email_format'          => "text/html"
     331                                                                                                                                        )
     332                                                        );
    340333                                                default:
    341334                                                        break;
Note: See TracChangeset for help on using the changeset viewer.