Changeset 10052


Ignore:
Timestamp:
Apr 4, 2011, 10:31:16 PM (10 years ago)
Author:
LucMorizur
Message:

Function order_by_name() removed in Piwigo 2.2: add EC's own one

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r8956 r10052  
    170170    }
    171171  }
     172}
     173
     174// Compatibility to Piwigo 2.2 , where this function disappeared
     175/** returns the argument_ids array with new sequenced keys based on related
     176 * names. Sequence is not case sensitive.
     177 * Warning: By definition, this function breaks original keys
     178 */
     179function ec_order_by_name($element_ids,$name)
     180{
     181  $ordered_element_ids = array();
     182  foreach ($element_ids as $k_id => $element_id)
     183  {
     184    $key = strtolower($name[$element_id]) .'-'. $name[$element_id] .'-'. $k_id;
     185    $ordered_element_ids[$key] = $element_id;
     186  }
     187  ksort($ordered_element_ids);
     188  return $ordered_element_ids;
    172189}
    173190
     
    348365 
    349366  // groups granted to duplication
    350   $ec_lists['groups_granted_ids'] = order_by_name(
     367  $ec_lists['groups_granted_ids'] = ec_order_by_name(
    351368    array_from_query("
    352369      SELECT `arg2`
     
    362379 
    363380  // users directly granted to duplication
    364   $ec_lists['users_granted_direct_ids'] = order_by_name(
     381  $ec_lists['users_granted_direct_ids'] = ec_order_by_name(
    365382    array_from_query("
    366383      SELECT `arg2`
     
    442459  $users_granted_thks_gen_ids = array();
    443460  if ($ec_gen_granted = (($ec_lists['types_granted'] & 8) != 0)) {
    444     $users_granted_thks_gen_ids = order_by_name(
     461    $users_granted_thks_gen_ids = ec_order_by_name(
    445462      array_diff(
    446463        array_from_query("
     
    490507        $type_users
    491508       );
    492       $users_granted_thks_types_ids = order_by_name(
     509      $users_granted_thks_types_ids = ec_order_by_name(
    493510        array_diff(
    494511          array_unique($user_granted_by_type_ids),
     
    531548      $group_users
    532549     );
    533     $users_granted_thks_groups_ids = order_by_name(
     550    $users_granted_thks_groups_ids = ec_order_by_name(
    534551      array_diff(
    535552        array_unique($user_granted_by_group_ids),
     
    548565
    549566  if ($append_tpl) {
    550     $users_denied_ids = order_by_name(
     567    $users_denied_ids = ec_order_by_name(
    551568      array_diff(
    552569        array_keys($ec_lists['user_ids']),
     
    569586    $template->assign('all_groups', $ec_lists['groups']);
    570587    $template->assign('groups_granted_ids', $ec_lists['groups_granted_ids']);
    571     $template->assign('groups_denied_ids', order_by_name(
     588    $template->assign('groups_denied_ids', ec_order_by_name(
    572589      array_diff(
    573590        array_keys($ec_lists['groups']),
     
    579596    $template->assign('all_types', $types);
    580597    $template->assign('types_granted_ids', $types_granted_ids);
    581     $template->assign('types_denied_ids', order_by_name(
     598    $template->assign('types_denied_ids', ec_order_by_name(
    582599      array_diff(array_keys($types), $types_granted_ids), $types
    583600    ));
Note: See TracChangeset for help on using the changeset viewer.