source: extensions/UserCollections/include/functions.inc.php @ 20384

Last change on this file since 20384 was 20093, checked in by mistic100, 11 years ago

add order and caddie buttons, columns header in CSV file, move some code to template

File size: 2.3 KB
Line 
1<?php
2defined('USER_COLLEC_PATH') or die('Hacking attempt!');
3
4function get_current_collection_id($create=true)
5{
6  global $user;
7 
8  // active in db
9  $query = '
10SELECT id
11  FROM '.COLLECTIONS_TABLE.'
12  WHERE
13    active = 1
14    AND user_id = '.$user['id'].'
15;';
16  $result = pwg_query($query);
17 
18  if (pwg_db_num_rows($result))
19  {
20    list($col_id) = pwg_db_fetch_row($result);
21    return $col_id;
22  }
23 
24  // new one
25  if ($create)
26  {
27    $UserCollection = new UserCollection('new', array(), 'temp', 1);
28    return $UserCollection->getParam('id');
29  }
30 
31  return false;
32}
33
34function uc_check_email_validity($mail_address)
35{
36  if (function_exists('email_check_format'))
37  {
38    return email_check_format($mail_address); // Piwigo 2.5
39  }
40  else if (version_compare(PHP_VERSION, '5.2.0') >= 0)
41  {
42    return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
43  }
44  else
45  {
46    $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
47    $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
48    $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
49
50    return (bool)preg_match($regex, $mail_address);
51  }
52}
53
54function get_collection_preferred_image_orders()
55{
56  global $conf, $page;
57   
58  return trigger_event('get_category_preferred_image_orders', array(
59    array(l10n('Date added to collection, new &rarr; old'), 'add_date DESC', true),
60    array(l10n('Date added to collection, old &rarr; new'), 'add_date ASC',  true),
61    array(l10n('Photo title, A &rarr; Z'),        'name ASC',             true),
62    array(l10n('Photo title, Z &rarr; A'),        'name DESC',            true),
63    array(l10n('Date created, new &rarr; old'),   'date_creation DESC',   true),
64    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',    true), 
65    array(l10n('Date posted, new &rarr; old'),    'date_available DESC',  true),
66    array(l10n('Date posted, old &rarr; new'),    'date_available ASC',   true),
67    array(l10n('Rating score, high &rarr; low'),  'rating_score DESC',    $conf['rate']),
68    array(l10n('Rating score, low &rarr; high'),  'rating_score ASC',     $conf['rate']),
69    array(l10n('Visits, high &rarr; low'),        'hit DESC',             true),
70    array(l10n('Visits, low &rarr; high'),        'hit ASC',              true),
71    ));
72}
73
74?>
Note: See TracBrowser for help on using the repository browser.