Changeset 17966

Show
Ignore:
Timestamp:
10/06/08 13:59:01 (2 months ago)
Author:
adrenalin
Message:

Working on DM2 compatible org.openpsa.calendar. Changed the way
filtering works, but keeping in mind backwards compatibility.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/org.openpsa.calendar/config/config.inc

    r3853 r17966  
    1 "schemadb" => "file:/org/openpsa/calendar/config/schemadb_default.inc", 
    2 "week_slot_length" => 120, // minutes 
    3 "day_slot_length"  => 60,  // minutes 
    4 "day_start_time"   => 8,   // hour "working day" starts 
    5 "day_end_time"     => 18,  // hour "working day" ends 
    6 "calendar_popup_width"   => 500, // width of the popup in pixels 
    7 "calendar_popup_height"  => 550, // height of the popup in pixels 
    8 "show_group_subscribers" => FALSE, // whether to show members of "subscriber" groups 
     1'schemadb' => 'file:/org/openpsa/calendar/config/schemadb_default.inc', 
     2'schemadb_filters' => 'file:/org/openpsa/calendar/config/schemadb_filters.inc', 
     3 
     4'week_slot_length' => 120, // minutes 
     5'day_slot_length'  => 60,  // minutes 
     6'day_start_time'   => 8,   // hour 'working day' starts 
     7'day_end_time'     => 18,  // hour 'working day' ends 
     8'calendar_popup_width'   => 500, // width of the popup in pixels 
     9'calendar_popup_height'  => 550, // height of the popup in pixels 
     10'show_group_subscribers' => FALSE, // whether to show members of 'subscriber' groups 
    911'start_view' => 'week', // which view to start in 
    1012'wiki_title_skeleton' => 'meeting note for %s on %s by %s', //format of wiki page title created from event 
  • branches/MidCOM_2_8/org.openpsa.calendar/handler/admin.php

    r17959 r17966  
    162162        debug_pop(); 
    163163    } 
    164  
     164     
     165    /** 
     166     * Show the requested administrator view 
     167     *  
     168     * @access public 
     169     * @param String $handler_id    Name of the request handler 
     170     * @param array &$data          Public request data, passed by reference 
     171     */ 
    165172    function _show_admin($handler_id, &$data) 
    166173    { 
     
    208215        } 
    209216         
     217        switch ($this->_controller->process_form()) 
     218        { 
     219            case 'save': 
     220            case 'cancel': 
     221                $_MIDCOM->relocate("event/{$this->_event->id}/"); 
     222                // This will exit 
     223        } 
     224         
    210225        return true; 
    211226    } 
     
    241256    function _handler_delete($handler_id, $args, &$data) 
    242257    { 
     258        $this->_event->require_do('midgard:delete'); 
     259        $this->_request_data['delete_succeeded'] = false; 
     260         
     261        // Cancel pressed 
     262        if (isset($_POST['org_openpsa_calendar_delete_cancel'])) 
     263        { 
     264            $_MIDCOM->relocate("event/{$this->_event->id}/"); 
     265            // This will exit 
     266        } 
     267         
     268        // Delete confirmed, remove the event 
     269        if (isset($_POST['org_openpsa_calendar_deleteok'])) 
     270        { 
     271            $this->_request_data['delete_succeeded'] = true; 
     272            $this->_event->delete(); 
     273        } 
     274         
    243275        return true; 
    244276    } 
  • branches/MidCOM_2_8/org.openpsa.calendar/handler/create.php

    r17959 r17966  
    100100    function & dm2_create_callback (&$controller) 
    101101    { 
    102         $this->_event = new midcom_db_event(); 
     102        $this->_event = new midcom_org_openpsa_event(); 
    103103        $this->_event->up = $this->_root_event->id; 
    104104 
     
    128128    { 
    129129        // Get the root event 
    130         $this->_root_event = new midcom_db_event($this->_config->get('calendar_root_event')); 
     130        $this->_root_event = new midcom_org_openpsa_event($this->_config->get('calendar_root_event')); 
    131131         
    132132        if (   !$this->_root_event 
  • branches/MidCOM_2_8/org.openpsa.calendar/handler/filters.php

    r17959 r17966  
    1919        parent::midcom_baseclasses_components_handler(); 
    2020    } 
    21  
     21     
     22    /** 
     23     * Handle the AJAX request 
     24     */ 
    2225    function _handle_ajax() 
    2326    { 
     
    4952    } 
    5053 
     54    /** 
     55     * Handle the request for editing contact list 
     56     *  
     57     * @access public 
     58     * @param String $handler_id    Name of the request handler 
     59     * @param array $args           Variable arguments 
     60     * @param array &$data          Public request data, passed by reference 
     61     * @return boolean              Indicating success 
     62     */ 
    5163    function _handler_edit($handler_id, $args, &$data) 
    5264    { 
    5365        $_MIDCOM->auth->require_valid_user(); 
    54  
    55         $this->_request_data['user'] = $_MIDCOM->auth->user->get_storage(); 
    56  
    57         if (   array_key_exists('org_openpsa_calendar_filters_add', $_POST) 
    58             || array_key_exists('org_openpsa_calendar_filters_remove', $_POST)) 
     66         
     67        // Get the current user 
     68        $this->_person = new midcom_db_person($_MIDGARD['user']); 
     69        $this->_person->require_do('midgard:update'); 
     70         
     71        // Load the schema database 
     72        $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_filters')); 
     73         
     74        // Load the controller 
     75        $this->_controller = midcom_helper_datamanager2_controller::create('simple'); 
     76        $this->_controller->schemadb =& $this->_schemadb; 
     77        $this->_controller->set_storage($this->_person); 
     78        if (! $this->_controller->initialize()) 
    5979        { 
    60             $this->_handle_ajax(); 
     80            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for article {$this->_article->id}."); 
     81            // This will exit. 
    6182        } 
    62  
    63         // Debug helpers 
    64         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL."/org.openpsa.helpers/messages.js"); 
    65         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL."/org.openpsa.helpers/ajaxutils.js"); 
    66  
    67         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL."/org.openpsa.calendar/filters.js"); 
    68         $_MIDCOM->add_jsonload("org_openpsa_calendar_filters_makeEditable();"); 
    69  
    70         $this->_request_data['buddylist'] = array(); 
    71  
    72         $qb = org_openpsa_contacts_buddy::new_query_builder(); 
    73         $qb->add_constraint('account', '=', $this->_request_data['user']->guid); 
    74         $qb->add_constraint('blacklisted', '=', false); 
    75         $buddies = $qb->execute(); 
    76  
    77         foreach ($buddies as $buddy) 
     83         
     84        // Process the form 
     85        switch ($this->_controller->process_form()) 
    7886        { 
    79             $person = new org_openpsa_contacts_person($buddy->buddy); 
    80             if ($person) 
    81             { 
    82                 $this->_request_data['buddylist'][$person->id] = $person; 
    83             } 
     87            case 'save': 
     88            case 'cancel': 
     89                if (isset($_GET['org_openpsa_calendar_returnurl'])) 
     90                { 
     91                    $url = $_GET['org_openpsa_calendar_returnurl']; 
     92                } 
     93                else 
     94                { 
     95                    $url = ''; 
     96                } 
     97                $_MIDCOM->relocate($url); 
     98                // This will exit 
    8499        } 
    85  
    86         // Add user to the filter list if needed 
    87         if (   !array_key_exists($this->_request_data['user']->id, $this->_request_data['buddylist']) 
    88             && $_MIDCOM->auth->can_do('midgard:create', $GLOBALS['midcom_component_data']['org.openpsa.calendar']['calendar_root_event'])) 
     100         
     101        // Add the breadcrumb pieces 
     102        $tmp = array(); 
     103         
     104        if (isset($_GET['org_openpsa_calendar_returnurl'])) 
    89105        { 
    90                 $this->_request_data['buddylist'][$this->_request_data['user']->id] = $this->_request_data['user']; 
    91         } 
    92  
    93         if (array_key_exists('org_openpsa_calendar_returnurl', $_GET)) 
    94         { 
    95             $this->_view_toolbar->add_item( 
    96                 array 
    97                 ( 
    98                     MIDCOM_TOOLBAR_URL => $_GET['org_openpsa_calendar_returnurl'], 
    99                     MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('back to calendar'), 
    100                     MIDCOM_TOOLBAR_HELPTEXT => null, 
    101                     MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_left.png', 
    102                     MIDCOM_TOOLBAR_ENABLED => true, 
    103                 ) 
     106            $tmp[] = array 
     107            ( 
     108                MIDCOM_NAV_URL => $_GET['org_openpsa_calendar_returnurl'], 
     109                MIDCOM_NAV_NAME => $this->_l10n->get('calendar'), 
    104110            ); 
    105111        } 
    106  
    107         $_MIDCOM->set_pagetitle($this->_request_data['l10n']->get('choose calendars')); 
     112         
     113        $tmp[] = array 
     114        ( 
     115            MIDCOM_NAV_URL => 'filters/', 
     116            MIDCOM_NAV_NAME => $this->_l10n->get('choose calendars'), 
     117        ); 
     118        $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp); 
    108119 
    109120        return true; 
    110121    } 
    111122 
     123    /** 
     124     * Show the contact editing interface 
     125     *  
     126     * @access public 
     127     * @param String $handler_id    Name of the request handler 
     128     * @param array &$data          Public request data, passed by reference 
     129     */ 
    112130    function _show_edit($handler_id, &$data) 
    113131    { 
    114         if (count($this->_request_data['buddylist']) > 0) 
    115         { 
    116             midcom_show_style("show-filters-header"); 
    117             foreach ($this->_request_data['buddylist'] as $person) 
    118             { 
    119                 $this->_request_data['person'] =& $person; 
    120                 if ($this->_request_data['user']->parameter('org_openpsa_calendar_show', $person->guid)) 
    121                 { 
    122                     $this->_request_data['subscribed'] = true; 
    123                 } 
    124                 else 
    125                 { 
    126                     $this->_request_data['subscribed'] = false; 
    127                 } 
    128                 midcom_show_style("show-filters-item"); 
    129             } 
    130             midcom_show_style("show-filters-footer"); 
    131         } 
     132        $data['controller'] =& $this->_controller; 
     133        $data['person'] =& $this->_person; 
     134         
     135        midcom_show_style('calendar-filter-chooser'); 
    132136    } 
    133137} 
  • branches/MidCOM_2_8/org.openpsa.calendar/handler/view.php

    r17959 r17966  
    4646    } 
    4747     
     48    /** 
     49     * Populate the toolbar 
     50     *  
     51     * @access private 
     52     * @param String $today_path    Path to the today's calendar 
     53     */ 
    4854    function _populate_toolbar($today_path = null) 
    4955    { 
     
    6571                    ( 
    6672                        'rel' => 'directlink', 
    67                         'onClick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node), 
     73                        'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node), 
    6874                    ), 
    6975                ) 
     
    177183                ( 
    178184                    'rel' => 'directlink', 
    179                     'onClick' => 'javascript:openPsaShowMonthSelector();', 
     185                    'onclick' => 'javascript:openPsaShowMonthSelector();', 
    180186                ), 
    181187            ) 
     
    215221        return $datestring; 
    216222    } 
    217  
     223     
     224    /** 
     225     * Populate the calendar with resources 
     226     *  
     227     * @access private 
     228     * @param midcom_db_person $resource 
     229     * @param int $from Start time 
     230     * @param int $to End time 
     231     */ 
    218232    function _populate_calendar_resource($resource, $from, $to) 
    219233    { 
     
    292306        return $resource_array; 
    293307    } 
    294  
     308     
     309    /** 
     310     * Populate the calendar with selected contacts 
     311     * 
     312     * @access private 
     313     * @param int $from    Start time 
     314     * @param int $to      End time 
     315     */ 
    295316    function _populate_calendar_contacts($from, $to) 
    296317    { 
     
    298319 
    299320        $user = $_MIDCOM->auth->user->get_storage(); 
     321         
    300322        if (   $this->_config->get('always_show_self') 
    301323            || $user->parameter('org_openpsa_calendar_show', $user->guid)) 
     
    304326            $this->_request_data['calendar']->_resources[$user->guid] = $this->_populate_calendar_resource($user, $from, $to); 
    305327        } 
     328         
    306329        $shown_persons[$user->id] = true; 
    307330 
    308331        $subscribed_contacts = $user->list_parameters('org_openpsa_calendar_show'); 
     332         
     333        // Backwards compatibiltiy 
    309334        foreach ($subscribed_contacts as $guid => $subscribed) 
    310335        { 
     
    312337            $this->_request_data['calendar']->_resources[$person->guid] = $this->_populate_calendar_resource($person, $from, $to); 
    313338            $shown_persons[$person->id] = true; 
     339        } 
     340         
     341        // New UI for showing resources 
     342        foreach ($user->list_parameters('org.openpsa.calendar.filters') as $type => $value) 
     343        { 
     344            $selected = @unserialize($value); 
     345             
     346            // Skip empty 
     347            if (   !$selected 
     348                || empty($selected)) 
     349            { 
     350                continue; 
     351            } 
     352             
     353            // Include each type 
     354            switch ($type) 
     355            { 
     356                case 'people': 
     357                    foreach ($selected as $guid) 
     358                    { 
     359                        $person = new midcom_db_person($guid); 
     360                        $this->_request_data['calendar']->_resources[$person->guid] = $this->_populate_calendar_resource($person, $from, $to); 
     361                        $shown_persons[$person->id] = true; 
     362                    } 
     363                    break; 
     364                 
     365                case 'groups': 
     366                    foreach ($selected as $guid) 
     367                    { 
     368                        // Get the group 
     369                        $group = new midcom_db_group($guid); 
     370                         
     371                        if (   !$group 
     372                            || !$group->guid) 
     373                        { 
     374                            continue; 
     375                        } 
     376                         
     377                        // Get the members 
     378                        $mc = midcom_db_member::new_collector('gid', $group->id); 
     379                        $mc->add_value_property('uid'); 
     380                        $mc->add_order('metadata.score'); 
     381                        $mc->execute(); 
     382                         
     383                        $keys = $mc->list_keys(); 
     384                         
     385                        foreach ($keys as $membership_guid => $array) 
     386                        { 
     387                            $person = new midcom_db_person($mc->get_subkey($membership_guid, 'uid')); 
     388                            $this->_request_data['calendar']->_resources[$person->guid] = $this->_populate_calendar_resource($person, $from, $to); 
     389                            $shown_persons[$person->id] = true; 
     390                        } 
     391                    } 
     392                    break; 
     393            } 
    314394        } 
    315395 
     
    434514        $this->_request_data['calendar']->reservation_div_options = array 
    435515        ( 
    436             'onClick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
     516            'onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
    437517        ); 
    438518        if ($_MIDCOM->auth->can_do('midgard:create', $GLOBALS['midcom_component_data']['org.openpsa.calendar']['calendar_root_event'])) 
     
    440520            $this->_request_data['calendar']->free_div_options = array 
    441521            ( 
    442                 'onClick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
     522                'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
    443523            ); 
    444524        } 
     
    527607        $this->_request_data['calendar']->reservation_div_options = array 
    528608        ( 
    529             'onClick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
     609            'onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
    530610        ); 
    531611        if ($_MIDCOM->auth->can_do('midgard:create', $GLOBALS['midcom_component_data']['org.openpsa.calendar']['calendar_root_event'])) 
     
    533613            $this->_request_data['calendar']->free_div_options = array 
    534614            ( 
    535                 'onClick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
     615                'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
    536616            ); 
    537617        } 
     
    679759            $this->_request_data['calendar']->reservation_div_options = array 
    680760            ( 
    681                 'onClick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
     761                'onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node), 
    682762            ); 
    683763        } 
    684764        $this->_request_data['calendar']->free_div_options = array 
    685765        ( 
    686             'onClick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
     766            'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'), 
    687767        ); 
    688768 
  • branches/MidCOM_2_8/org.openpsa.calendar/locale/default.en.txt

    r4574 r17966  
    1010---STRING back to calendar 
    1111Back to calendar 
     12---STRINGEND 
     13 
     14---STRING calendar 
     15Calendar 
    1216---STRINGEND 
    1317 
     
    8084---STRINGEND 
    8185 
     86---STRING groups 
     87Groups 
     88---STRINGEND 
     89 
    8290---STRING location 
    8391Location 
     
    110118---STRING participants 
    111119Participants 
     120---STRINGEND 
     121 
     122---STRING people 
     123People 
    112124---STRINGEND 
    113125 
     
    156168---STRINGEND 
    157169 
     170---STRING resources 
     171Resources 
     172---STRINGEND 
     173 
  • branches/MidCOM_2_8/org.openpsa.calendar/locale/default.fi.txt

    r4574 r17966  
    1010---STRING back to calendar 
    1111Takaisin kalenteriin 
     12---STRINGEND 
     13 
     14---STRING calendar 
     15Kalenteri 
    1216---STRINGEND 
    1317 
     
    8084---STRINGEND 
    8185 
     86---STRING groups 
     87RyhmÀt 
     88---STRINGEND 
     89 
    8290---STRING location 
    8391Paikka 
     
    110118---STRING participants 
    111119Osallistujat 
     120---STRINGEND 
     121 
     122---STRING people 
     123Henkilöt 
    112124---STRINGEND 
    113125 
     
    156168---STRINGEND 
    157169 
     170---STRING resources 
     171Resurssit 
     172---STRINGEND 
     173 
  • branches/MidCOM_2_8/org.openpsa.calendar/style/show-event-delete.php

    r5048 r17966  
    1717                    <?php echo $data['l10n']->get('really delete event'); ?> 
    1818                    <input type="submit" id="org_openpsa_calendar_deleteok" name="org_openpsa_calendar_deleteok" value="<?php echo $data['l10n_midcom']->get('yes'); ?>" /> 
     19                    <input type="submit" id="org_openpsa_calendar_delete_cancel" name="org_openpsa_calendar_delete_cancel" value="<?php echo $data['l10n_midcom']->get('no'); ?>" /> 
    1920                </label> 
    2021            </fieldset>