Ignore:
Timestamp:
Jun 20, 2011, 9:05:36 AM (13 years ago)
Author:
Mattias
Message:

Small changes in comment's, removed unnescessary code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/batch_global.php

    r11423 r11439  
    1616function copyrights_batch_global()
    1717{
    18   global $template;
     18        global $template;
    1919
    20   load_language('plugin.lang', dirname(__FILE__).'/');                                  // Engels is voorlopig goed zat
     20        load_language('plugin.lang', dirname(__FILE__).'/');
    2121
    22   // Assign the template for batch management
    23   $template->set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl');
     22        // Assign the template for batch management
     23        $template->set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl');
    2424
    25   // Fetch all the copyrights and assign them to the template
    26   $query = sprintf(
    27     'SELECT `cr_id`,`name`
    28     FROM %s
    29     WHERE `visible`<>0
    30     ;',
    31     COPYRIGHTS_ADMIN);
    32   $result = pwg_query($query);
    33   $CRoptions = array();
    34   while ($row = pwg_db_fetch_assoc($result)) {
    35     $CRoptions[$row['cr_id']] = $row['name'];
    36   }
    37   $template->assign('CRoptions', $CRoptions);
     25        // Fetch all the copyrights and assign them to the template
     26        $query = sprintf(
     27                'SELECT `cr_id`,`name`
     28                FROM %s
     29                WHERE `visible`<>0
     30                ;',
     31        COPYRIGHTS_ADMIN);
     32        $result = pwg_query($query);
     33        $CRoptions = array();
     34        while ($row = pwg_db_fetch_assoc($result)) {
     35                $CRoptions[$row['cr_id']] = $row['name'];
     36        }
     37        $template->assign('CRoptions', $CRoptions);
    3838
    39  
    40   // Goed, ik weet dus echt niet waarom dit hieronder gedaan wordt...
    41   // AHA!!!! - dit is er zodat de "choose action" optie deze plugin gebruikt....
    42   $template->append('element_set_global_plugins_actions', array(
    43     'ID' => 'copyrights',       // ID of the batch manager action
    44     'NAME' => l10n('Edit copyright'), // Description of the batch manager action
    45     'CONTENT' => $template->parse('batch_global', true)
    46     )
    47   );
     39
     40        // Add info on the "choose action" dropdown in the batch manager
     41        $template->append('element_set_global_plugins_actions', array(
     42                'ID' => 'copyrights',   // ID of the batch manager action
     43                'NAME' => l10n('Edit copyright'), // Description of the batch manager action
     44                'CONTENT' => $template->parse('batch_global', true)
     45        )
     46        );
    4847}
    4948
     
    5352function copyrights_batch_global_submit($action, $collection)
    5453{
    55   if ($action == 'copyrights')
    56   {
    57           $crID = pwg_db_real_escape_string($_POST['copyrightID']);
    58    
    59     if (count($collection) > 0) {
    60       $query = sprintf(
    61         'DELETE
    62         FROM %s
    63         WHERE media_id IN (%s)
    64         ;',
    65         COPYRIGHTS_MEDIA, implode(',', $collection));
    66       pwg_query($query);
    67     }
     54        // If its our plugin that is called
     55        if ($action == 'copyrights')
     56        {
     57                $crID = pwg_db_real_escape_string($_POST['copyrightID']);
    6858
    69     $edits = array();
    70     foreach ($collection as $image_id)
    71     {
    72       array_push(
    73         $edits,
    74         array(
    75           'media_id' => $image_id,
    76           'cr_id' => $crID,
    77           )
    78         );
    79     }
     59                if (count($collection) > 0) {
     60                $query = sprintf(
     61                                'DELETE
     62                                FROM %s
     63                                WHERE media_id IN (%s)
     64                                ;',
     65                        COPYRIGHTS_MEDIA, implode(',', $collection));
     66                        pwg_query($query);
     67                }
    8068
    81     mass_inserts(
    82       COPYRIGHTS_MEDIA, // Table name
    83       array_keys($edits[0]), //Columns
    84       $edits // Data
    85     );
    86   }
     69                $edits = array();
     70                foreach ($collection as $image_id)
     71                {
     72                        array_push(
     73                                $edits,
     74                                array(
     75                                        'media_id' => $image_id,
     76                                        'cr_id' => $crID,
     77                                )
     78                        );
     79                }
     80
     81                mass_inserts(
     82                        COPYRIGHTS_MEDIA,               // Table name
     83                        array_keys($edits[0]),  //Columns
     84                        $edits                                  // Data
     85                );
     86        }
    8787}
    8888
Note: See TracChangeset for help on using the changeset viewer.