Ignore:
Timestamp:
Dec 9, 2009, 11:14:01 PM (14 years ago)
Author:
plg
Message:

feature 1316 added: we now have the ability to only fill the single value
properties that are currently empty in the database instead of automatically
replacing.

feature 1312: as a matter of consistency, I have changed the replace_mode
(that was only for multiple values properties) into multiple_value_mode +
single_value_mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/ws_functions.inc.php

    r4444 r4459  
    16661666  }
    16671667
    1668   // name
    1669   // category_id
    1670   // file_content
    1671   // file_sum
    1672   // thumbnail_content
    1673   // thumbnail_sum
    1674 
    16751668  $params['image_id'] = (int)$params['image_id'];
    16761669  if ($params['image_id'] <= 0)
     
    16921685
    16931686  // database registration
    1694   $update = array(
    1695     'id' => $params['image_id'],
    1696     );
     1687  $update = array();
    16971688
    16981689  $info_columns = array(
     
    17041695    );
    17051696
    1706   $perform_update = false;
    17071697  foreach ($info_columns as $key)
    17081698  {
    17091699    if (isset($params[$key]))
    17101700    {
    1711       $perform_update = true;
    1712       $update[$key] = $params[$key];
    1713     }
    1714   }
    1715 
    1716   if ($perform_update)
    1717   {
     1701      if ('fill_if_empty' == $params['single_value_mode'])
     1702      {
     1703        if (empty($image_row[$key]))
     1704        {
     1705          $update[$key] = $params[$key];
     1706        }
     1707      }
     1708      elseif ('replace' == $params['single_value_mode'])
     1709      {
     1710        $update[$key] = $params[$key];
     1711      }
     1712      else
     1713      {
     1714        new PwgError(
     1715          500,
     1716          '[ws_images_setInfo]'
     1717          .' invalid parameter single_value_mode "'.$params['single_value_mode'].'"'
     1718          .', possible values are {fill_if_empty, replace}.'
     1719          );
     1720        exit();
     1721      }
     1722    }
     1723  }
     1724
     1725  if (count(array_keys($update)) > 0)
     1726  {
     1727    $update['id'] = $params['image_id'];
     1728
    17181729    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    17191730    mass_updates(
     
    17321743      $params['image_id'],
    17331744      $params['categories'],
    1734       $params['replace_mode']
     1745      ('replace' == $params['multiple_value_mode'] ? true : false)
    17351746      );
    17361747  }
     
    17431754    $tag_ids = explode(',', $params['tag_ids']);
    17441755
    1745     if ($params['replace_mode'])
     1756    if ('replace' == $params['multiple_value_mode'])
    17461757    {
    17471758      set_tags(
     
    17501761        );
    17511762    }
    1752     else
     1763    elseif ('append' == $params['multiple_value_mode'])
    17531764    {
    17541765      add_tags(
     
    17561767        array($params['image_id'])
    17571768        );
     1769    }
     1770    else
     1771    {
     1772      new PwgError(
     1773        500,
     1774        '[ws_images_setInfo]'
     1775        .' invalid parameter multiple_value_mode "'.$params['multiple_value_mode'].'"'
     1776        .', possible values are {replace, append}.'
     1777        );
     1778      exit();
    17581779    }
    17591780  }
Note: See TracChangeset for help on using the changeset viewer.