Changeset 1817 for trunk/admin/include


Ignore:
Timestamp:
Feb 14, 2007, 11:53:02 PM (17 years ago)
Author:
plg
Message:

New: history logs high quality access via action.php. A new column
#history.is_high was added. Filter was added on administration history
detail view.

Modification: function get_sql_condition_FandF was slightly refactored for
presentation improvement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r1794 r1817  
    607607    SET ';
    608608        $is_first = true;
    609         foreach ($dbfields['update'] as $num => $key)
     609        foreach ($dbfields['update'] as $key)
    610610        {
    611611          if (!$is_first)
     
    626626        $query.= '
    627627    WHERE ';
    628         foreach ($dbfields['primary'] as $num => $key)
     628
     629        $is_first = true;
     630        foreach ($dbfields['primary'] as $key)
    629631        {
    630           if ($num > 1)
     632          if (!$is_first)
    631633          {
    632634            $query.= ' AND ';
    633635          }
    634636          $query.= $key.' = \''.$data[$key].'\'';
     637          $is_first = false;
    635638        }
    636639        $query.= '
     
    19031906
    19041907/**
     1908 * Create an XML file with PhpWebGallery informations about a list of
     1909 * pictures.
     1910 *
     1911 * The goal of the export feature is to make easier the reading of
     1912 * informations related to pictures outside of PhpWebGallery.
     1913 *
     1914 * @param array image_ids
     1915 */
     1916function export_pwg_data($image_ids)
     1917{
     1918  global $conf;
     1919
     1920  if (count($image_ids) == 0)
     1921  {
     1922    return;
     1923  }
     1924
     1925  $fp = fopen($conf['export_file'], 'w');
     1926  $xml_string = '<export>'."\n";
     1927
     1928  $query = '
     1929SELECT tag_id,
     1930       image_id
     1931  FROM '.IMAGE_TAG_TABLE.'
     1932  WHERE image_id IN ('.implode(',', $image_ids).')
     1933;';
     1934  $result = pwg_query($query);
     1935  $tags_of = array();
     1936  $all_tag_ids = array();
     1937  $tag_name_of = array();
     1938
     1939  if (mysql_num_rows($result))
     1940  {
     1941      while ($row = mysql_fetch_array($result))
     1942      {
     1943        array_push($all_tag_ids, $row['tag_id']);
     1944       
     1945        if (!isset($tags_of[ $row['image_id'] ])) {
     1946          $tags_of[ $row['image_id'] ] = array();
     1947        }
     1948       
     1949        array_push(
     1950          $tags_of[ $row['image_id'] ],
     1951          $row['tag_id']
     1952          );
     1953      }
     1954
     1955      $all_tag_ids = array_unique($all_tag_ids);
     1956
     1957      $query = '
     1958SELECT id,
     1959       name
     1960  FROM '.TAGS_TABLE.'
     1961  WHERE id IN ('.implode(',', $all_tag_ids).')
     1962;';
     1963      $result = pwg_query($query);
     1964
     1965      while ($row = mysql_fetch_array($result))
     1966      {
     1967        $tag_name_of[ $row['id'] ] = $row['name'];
     1968      }
     1969  }
     1970
     1971  $query = '
     1972SELECT id,
     1973       path
     1974  FROM '.IMAGES_TABLE.'
     1975  WHERE id IN ('.implode(',', $image_ids).')
     1976;';
     1977  $result = pwg_query($query);
     1978
     1979  while ($row = mysql_fetch_array($result))
     1980  {
     1981    $xml_string.= "  <photo>\n";
     1982    $xml_string.= "    <id>".$row['id']."</id>\n";
     1983    $xml_string.= "    <path>".$row['path']."</path>\n";
     1984
     1985    foreach ($tags_of[ $row['id'] ] as $tag_id)
     1986    {
     1987      $xml_string.= "    <tag>".$tag_name_of[$tag_id]."</tag>\n";
     1988    }
     1989   
     1990    $xml_string.= "  </photo>\n";
     1991  }
     1992 
     1993  $xml_string.= '</export>';
     1994  fwrite($fp, $xml_string);
     1995  fclose($fp);
     1996}
     1997
     1998/**
    19051999 * Check configuration and add notes on problem
    19062000 *
     
    19382032  }
    19392033}
    1940 
    19412034/**
    19422035 * Refer main PhpWebGallery URLs (currently PHPWG_DOMAIN domain)
Note: See TracChangeset for help on using the changeset viewer.