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

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

all collections are "active", display a menu when adding to a collection

File size: 2.8 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;
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
74function get_collections_preferred_orders()
75{
76  return array(
77    array(l10n('Name, A &rarr; Z'),               'name ASC',           true),
78    array(l10n('Name, Z &rarr; A'),               'name DESC',          true),
79    array(l10n('Date created, new &rarr; old'),   'date_creation DESC', true),
80    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',  true), 
81    array(l10n('Photos number, high &rarr; low'), 'nb_images DESC',     true),
82    array(l10n('Photos number, low &rarr; high'), 'nb_images ASC',      true),
83    );
84}
85
86?>
Note: See TracBrowser for help on using the repository browser.