Changeset 1817


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.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/action.php

    r1678 r1817  
    6262
    6363
    64 if ( !isset($_GET['id']) or !is_numeric($_GET['id'])
     64if (!isset($_GET['id'])
     65    or !is_numeric($_GET['id'])
    6566    or !isset($_GET['part'])
    6667    or !in_array($_GET['part'], array('t','e','i','h') ) )
     
    6970}
    7071
    71 $id = $_GET['id'];
    7272$query = '
    7373SELECT * FROM '. IMAGES_TABLE.'
    74   WHERE id='.$id.'
     74  WHERE id='.$_GET['id'].'
    7575;';
    7676
     
    8585// are not used because it's not necessary (filter <> restriction)
    8686$query='
    87 SELECT id FROM '.CATEGORIES_TABLE.'
    88   INNER JOIN '.IMAGE_CATEGORY_TABLE.'
    89   ON category_id=id
    90   WHERE image_id='.$id.'
    91 '.get_sql_condition_FandF(array('forbidden_categories' => 'category_id'), 'AND').'
     87SELECT id
     88  FROM '.CATEGORIES_TABLE.'
     89    INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON category_id = id
     90  WHERE image_id = '.$_GET['id'].'
     91'.get_sql_condition_FandF(
     92  array('forbidden_categories' => 'category_id'),
     93  '    AND'
     94  ).'
    9295  LIMIT 1
    9396;';
     
    124127}
    125128
     129if ($_GET['part'] == 'h') {
     130  $is_high = true;
     131  pwg_log($_GET['id'], $is_high);
     132}
     133
    126134$http_headers = array();
    127135
  • trunk/admin/history.php

    r1782 r1817  
    9595  }
    9696
     97  $search['fields']['pictures'] = $_POST['pictures'];
     98  $search['fields']['high'] = $_POST['high'];
     99 
    97100  // echo '<pre>'; print_r($search); echo '</pre>';
    98101 
     
    182185  }
    183186
     187  if (isset($page['search']['fields']['pictures']))
     188  {
     189    $clause = null;
     190   
     191    if ($page['search']['fields']['pictures'] == 'no')
     192    {
     193      $clause = 'image_id IS NULL';
     194    }
     195
     196    if ($page['search']['fields']['pictures'] == 'only')
     197    {
     198      $clause = 'image_id IS NOT NULL';
     199    }
     200
     201    if (isset($clause))
     202    {
     203      array_push($clauses, $clause);
     204    }
     205  }
     206
     207  if (isset($page['search']['fields']['high']))
     208  {
     209    $clause = null;
     210   
     211    if ($page['search']['fields']['high'] == 'no')
     212    {
     213      $clause = "is_high IS NULL or is_high = 'false'";
     214    }
     215
     216    if ($page['search']['fields']['high'] == 'only')
     217    {
     218      $clause = "is_high = 'true'";
     219    }
     220
     221    if (isset($clause))
     222    {
     223      array_push($clauses, $clause);
     224    }
     225  }
     226 
    184227  $clauses = prepend_append_array_items($clauses, '(', ')');
    185228
     
    199242
    200243  $query = '
    201 SELECT date, time, user_id, IP, section, category_id, tag_ids, image_id
     244SELECT
     245    date,
     246    time,
     247    user_id,
     248    IP,
     249    section,
     250    category_id,
     251    tag_ids,
     252    image_id,
     253    is_high
    202254  FROM '.HISTORY_TABLE.'
    203255  WHERE '.$where_separator.'
     
    299351        )
    300352      );
     353
     354    if (isset($line['image_id']))
     355    {
     356      if ($line['is_high'] == 'true')
     357      {
     358        $template->assign_block_vars('detail.high', array());
     359      }
     360      else
     361      {
     362        $template->assign_block_vars('detail.no_high', array());
     363      }
     364    }
    301365  }
    302366}
     
    352416  {
    353417    $tokens = explode('-', $page['search']['fields']['date-before']);
    354    
    355      (int)$tokens[0];
    356      (int)$tokens[1];
    357      (int)$tokens[2];
    358   }
     418
     419    $form['end_year']  = (int)$tokens[0];
     420    $form['end_month'] = (int)$tokens[1];
     421    $form['end_day']   = (int)$tokens[2];
     422  }
     423
     424  $form['pictures'] = $page['search']['fields']['pictures'];
     425  $form['high'] = $page['search']['fields']['high'];
    359426}
    360427else
     
    365432  $form['start_month'] = $form['end_month'] = date('n');
    366433  $form['start_day']   = $form['end_day']   = date('j');
     434  $form['pictures'] = 'yes';
     435  $form['high'] = 'yes';
    367436}
    368437
     
    380449    )
    381450  );
     451
     452foreach (array('pictures', 'high') as $block)
     453{
     454  foreach (array('yes', 'no', 'only') as $item)
     455  {
     456    $selected = '';
     457   
     458    if ($item == $form[$block])
     459    {
     460      $selected = 'selected="selected"';
     461    }
     462   
     463    $template->assign_block_vars(
     464      $block.'_option',
     465      array(
     466        'VALUE' => $item,
     467        'CONTENT' => l10n($item),
     468        'SELECTED' => $selected,
     469        )
     470      );
     471  }
     472}
    382473 
    383474// +-----------------------------------------------------------------------+
  • 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)
  • trunk/include/functions.inc.php

    r1766 r1817  
    411411}
    412412
    413 function pwg_log($image_id = null)
     413function pwg_log($image_id = null, $is_high = false)
    414414{
    415415  global $conf, $user, $page;
     
    469469    category_id,
    470470    image_id,
     471    is_high,
    471472    tag_ids
    472473  )
     
    484485    '.(isset($page['category']) ? $page['category'] : 'NULL').',
    485486    '.(isset($image_id) ? $image_id : 'NULL').',
     487    '.(isset($image_id) ? "'".boolean_to_string($is_high)."'" : 'NULL').',
    486488    '.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').'
    487489  )
  • trunk/include/functions_user.inc.php

    r1763 r1817  
    10901090
    10911091/*
    1092  * Compute sql where condition with restrict and filter data
    1093  *
    1094  * FandF: Forbidden and Filters
    1095  *
    1096  * @param $condition_fields array:
    1097  *            keys are condition to aply and
    1098  *            values are sql field to use
    1099  *            array('forbidden_categories' => 'ic.category_id')
    1100  *        $prefix_condition string:
    1101  *            this value are concatenated if sql is not empty
    1102  *        $force_one_condition:
    1103  *            if there are not condition , use this condition "1 = 1"
     1092 * Compute sql where condition with restrict and filter data. "FandF" means
     1093 * Forbidden and Filters.
     1094 *
     1095 * @param array condition_fields: read function body
     1096 * @param string prefix_condition: prefixes sql if condition is not empty
     1097 * @param boolean force_one_condition: use at least "1 = 1"
    11041098 *
    11051099 * @return string sql where/conditions
    11061100 */
    1107 function get_sql_condition_FandF($condition_fields, $prefix_condition = null, $force_one_condition = false)
     1101function get_sql_condition_FandF(
     1102  $condition_fields,
     1103  $prefix_condition = null,
     1104  $force_one_condition = false
     1105  )
    11081106{
    11091107  global $user, $filter;
     
    11161114    {
    11171115      case 'forbidden_categories':
     1116      {
    11181117        if (!empty($user['forbidden_categories']))
    11191118        {
    1120           $sql_list[] = $field_name.' NOT IN ('.$user['forbidden_categories'].')';
     1119          $sql_list[] =
     1120            $field_name.' NOT IN ('.$user['forbidden_categories'].')';
    11211121        }
    11221122        break;
    1123 
     1123      }
    11241124      case 'visible_categories':
     1125      {
    11251126        if (!empty($filter['visible_categories']))
    11261127        {
    1127           $sql_list[] = $field_name.' IN ('.$filter['visible_categories'].')';
     1128          $sql_list[] =
     1129            $field_name.' IN ('.$filter['visible_categories'].')';
    11281130        }
    11291131        break;
    1130 
     1132      }
    11311133      case 'visible_images':
     1134      {
    11321135        if (!empty($filter['visible_images']))
    11331136        {
    1134           $sql_list[] = $field_name.' IN ('.$filter['visible_images'].')';
     1137          $sql_list[] =
     1138            $field_name.' IN ('.$filter['visible_images'].')';
    11351139        }
    11361140        break;
    1137 
     1141      }
    11381142      default:
     1143      {
    11391144        die('Unknow condition');
    11401145        break;
    1141 
     1146      }
    11421147    }
    11431148  }
  • trunk/install/phpwebgallery_structure.sql

    r1791 r1817  
    127127  `image_id` mediumint(8) default NULL,
    128128  `summarized` enum('true','false') default 'false',
     129  `is_high` enum('true','false') default NULL,
    129130  PRIMARY KEY  (`id`),
    130131  KEY `history_i1` (`summarized`)
  • trunk/template/yoga/admin/history.tpl

    r1780 r1817  
    5050  </ul>
    5151
     52  <ul>
     53    <li><label></label></li>
     54    <li></li>
     55  </ul>
     56
     57  <label>
     58    {lang:Pictures}
     59    <select name="pictures">
     60      <!-- BEGIN pictures_option -->
     61      <option
     62        value="{pictures_option.VALUE}"
     63        {pictures_option.SELECTED}
     64      >
     65        {pictures_option.CONTENT}
     66      </option>
     67      <!-- END pictures_option -->
     68    </select>
     69  </label>
     70
     71  <label>
     72    {lang:High quality}
     73    <select name="high">
     74      <!-- BEGIN high_option -->
     75      <option
     76        value="{high_option.VALUE}"
     77        {high_option.SELECTED}
     78      >
     79        {high_option.CONTENT}
     80      </option>
     81      <!-- END high_option -->
     82    </select>
     83  </label>
     84
    5285  <input class="submit" type="submit" name="submit" value="{lang:submit}" {TAG_INPUT_ENABLED}/>
    5386</fieldset>
     
    69102    <th>{lang:IP}</th>
    70103    <th>{lang:image}</th>
     104    <th>{lang:high quality}</th>
    71105    <th>{lang:section}</th>
    72106    <th>{lang:category}</th>
     
    80114    <td>{detail.IP}</td>
    81115    <td>{detail.IMAGE}</td>
     116    <td>
     117  <!-- BEGIN high -->
     118      <img src="{themeconf:icon_dir}/check.png" alt="{lang:yes}">
     119  <!-- END high -->
     120  <!-- BEGIN no_high -->
     121      <img src="{themeconf:icon_dir}/uncheck.png" alt="{lang:no}">
     122  <!-- END no_high -->
     123    </td>
    82124    <td>{detail.SECTION}</td>
    83125    <td>{detail.CATEGORY}</td>
Note: See TracChangeset for help on using the changeset viewer.