hamiltonc
committed
on 24 Jun 05
add drop scripts for admin portlet, modify clone proc to simply create a community, there's nothing to clone yet in expenses
/tcl/dotlrn-expense-tracking-procs.tcl (+175)
  1 ad_library {
  2    
  3     Procs to set up the dotLRN expense tracking applet
  4    
  5     @author Hamilton Chua (hamilton.chua@gmail.com)
  6     @version $Id$
  7
  8 }
  9
  10 namespace eval dotlrn_expense_tracking {
  11
  12     ad_proc -public get_pretty_name {
  13     } {
  14         get the pretty name
  15     } {
  16         return "Expense Tracking"
  17     }
  18
  19     ad_proc -public applet_key {} {
  20         return "dotlrn_expense_tracking"
  21     }
  22
  23     ad_proc -public my_package_key {
  24     } {
  25         What's my package key?
  26     } {
  27         return "dotlrn-expense-tracking"
  28     }
  29
  30     ad_proc -public package_key {
  31     } {
  32         What package is associated with this applet?
  33     } {
  34         return "expense-tracking"
  35     }
  36
  37     ad_proc -public add_applet {
  38     } {
  39         Add the expense tracking applet to dotlrn - one time init - must be repeatable!
  40     } {
  41         dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key]
  42     }
  43
  44     ad_proc -public remove_applet {
  45         community_id
  46         package_id
  47     } {
  48         remove the applet
  49     } {
  50         ad_return_complaint 1 "[applet_key] remove_applet not implimented!"
  51     }
  52
  53     ad_proc -public add_applet_to_community {
  54         community_id
  55     } {
  56         Add the expense tracking applet to a specifc community
  57     } {
  58         set portal_id [dotlrn_community::get_portal_id \
  59                            -community_id $community_id
  60         ]
  61
  62         # create the package instance (all in one, I've mounted it)
  63         set package_id [dotlrn::instantiate_and_mount \
  64                             $community_id \
  65                             [package_key]
  66         ]
  67         # return the package_id
  68         return $package_id
  69     }
  70
  71     ad_proc -public remove_applet_from_community {
  72         community_id
  73     } {
  74         Drops the expense tracking applet from the given community
  75     } {
  76         ad_return_complaint 1 "[applet_key] remove_applet_from_community not implimented!"
  77     }
  78
  79     ad_proc -public add_user {
  80         user_id
  81     } {
  82         For one time user-specfic init
  83     } {
  84         # noop
  85     }
  86
  87     ad_proc -public remove_user {
  88         user_id
  89     } {
  90         Remove the user from dotlrn.
  91     } {
  92         # noop
  93     }
  94
  95     ad_proc -public add_user_to_community {
  96         community_id
  97         user_id
  98     } {
  99         Called when a user is added to a specific dotlrn community
  100     } {
  101         # noop
  102     }
  103
  104     ad_proc -public remove_user_from_community {
  105         community_id
  106         user_id
  107     } {
  108         Remove a user from a community
  109     } {
  110         # noop
  111     }
  112
  113     ad_proc -public add_portlet {
  114         portal_id
  115     } {
  116         A helper proc to add the underlying portlet to the given portal.
  117
  118         @portal_id
  119     } {
  120         # noop
  121     }
  122
  123     ad_proc -public add_portlet_helper {
  124         portal_id
  125         args
  126     } {
  127         This does the call to add the portlet to the given portal.
  128         Params for the portlet are set by the calllers.
  129
  130         @param portal_id
  131         @param args An ns_set
  132     } {
  133         #noop
  134     }
  135
  136     ad_proc -public remove_portlet {
  137         portal_id
  138         args
  139     } {
  140         A helper proc to remove the underlying portlet from the given portal.
  141
  142         @param portal_id
  143         @param args An ns_set
  144     } {
  145         #noop
  146     }
  147
  148     ad_proc -public clone {
  149         old_community_id
  150         new_community_id
  151     } {
  152         Clone this applet's content from the old community to the new one
  153     } {
  154         ns_log notice "Cloning: [applet_key]"
  155         set new_package_id [add_applet_to_community $new_community_id]
  156         set old_package_id [dotlrn_community::get_applet_package_id \
  157             -community_id $old_community_id \
  158             -applet_key [applet_key]
  159         ]
  160
  161         db_exec_plsql call_expense_tracking_clone {}
  162         return $new_package_id
  163     }
  164
  165     ad_proc -public change_event_handler {
  166         community_id
  167         event
  168         old_value
  169         new_value
  170     } {
  171         listens for the following events:
  172     } {
  173     }  
  174
  175 }