Changeset 5978

Show
Ignore:
Timestamp:
07/09/08 21:36:58 (5 years ago)
Author:
p_lindheimer
Message:

Add a usage list to Timegroups with a call back that other modules can inform of their usage, and then add a link in timecondions to go to the current timegroup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/timeconditions/functions.inc.php

    r5957 r5978  
    256256} 
    257257 
    258  
     258function timeconditions_timegroups_usage($group_id) { 
     259 
     260  $results = sql("SELECT timeconditions_id, displayname FROM timeconditions WHERE time = '$group_id'","getAll",DB_FETCHMODE_ASSOC); 
     261  if (empty($results)) { 
     262    return array(); 
     263  } else { 
     264    foreach ($results as $result) { 
     265      $usage_arr[] = array( 
     266        "url_query" => "display=timeconditions&itemid=".$result['timeconditions_id'], 
     267        "description" => $result['displayname'], 
     268      ) 
     269    } 
     270    return $usage_arr; 
     271  } 
     272
     273 
     274function timeconditions_timegroups_list_usage($timegroup_id) { 
     275  global $active_modules; 
     276  $full_usage_arr = array(); 
     277 
     278  foreach(array_keys($active_modules) as $mod) { 
     279    $function = $mod."_timegroups_usage"; 
     280    if (function_exists($function)) { 
     281      $timegroup_usage = $function($timegroup_id); 
     282      if (!empty($timegroup_usage)) { 
     283        $full_usage_arr = array_merge($full_usage_arr, $timegroup_usage); 
     284      } 
     285    } 
     286  } 
     287  return $full_usage_arr; 
     288
    259289 
    260290/* 
     
    343373    $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/core_delete.png"/>&nbsp;'.$tlabel.'</span>'; 
    344374    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0); 
     375 
     376    $usage_list = timeconditions_timegroups_list_usage($extdisplay); 
     377    $count = 0; 
     378    foreach ($usage_list as $link) { 
     379      $label = '<span><img width="16" height="16" border="0" title="'.$link['description'].'" alt="" src="images/time_link.png"/>&nbsp;'.$link['description'].'</span>'; 
     380      $timegroup_link = $_SERVER['PHP_SELF'].'?'.$link['url_query']; 
     381      $currentcomponent->addguielem('Used By', new gui_link('link'.$count++, $label, $timegroup_link, true, false), 4); 
     382    } 
     383 
     384 
    345385    $currentcomponent->addguielem('Time Group', new gui_textbox('description', $description, 'Description', 'This will display as the name of this Time Group.', '', '', false), 3); 
    346386    $timelist = timeconditions_timegroups_get_times($extdisplay); 
  • modules/branches/2.5/timeconditions/page.timeconditions.php

    r5957 r5978  
    102102  </tr> 
    103103<?php 
     104  if (isset($thisItem['time']) && $thisItem['time'] != '') { 
     105 
     106    $grpURL = $_SERVER['PHP_SELF'].'?display=timegroups&extdisplay='.$thisItem['time']; 
     107    $tlabel = _("Goto Current Time Group"); 
     108    $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/time_edit.png"/>&nbsp;'.$tlabel.'</span>'; 
     109?> 
     110    <tr> 
     111      <td> <a href="<?php echo $grpURL ?>"><?php echo "&nbsp;".$label; ?></a></td> 
     112    <tr> 
     113<?php 
     114  } 
    104115  // implementation of module hook 
    105116  // object was initialized in config.php