Example #1
0
 /**
  * Removes the folder from indexer if applicable.
  */
 private function _delete_topic_update_index()
 {
     if ($GLOBALS['midcom_config']['indexer_backend'] === false) {
         // Indexer is not configured.
         return;
     }
     debug_add("Dropping all NAP registered objects from the index.");
     // First we collect everything we have to delete, this might take a while
     // so we keep an eye on the script timeout.
     $guids = array();
     $nap = new midcom_helper_nav();
     $node_list = array($nap->get_current_node());
     while (count($node_list) > 0) {
         set_time_limit(30);
         // Add the node being processed.
         $nodeid = array_shift($node_list);
         debug_add("Processing node {$nodeid}");
         $node = $nap->get_node($nodeid);
         $guids[] = $node[MIDCOM_NAV_GUID];
         debug_add("Processing leaves of node {$nodeid}");
         $leaves = $nap->list_leaves($nodeid, true);
         debug_add('Got ' . count($leaves) . ' leaves.');
         foreach ($leaves as $leafid) {
             $leaf = $nap->get_leaf($leafid);
             $guids[] = $leaf[MIDCOM_NAV_GUID];
         }
         debug_add('Loading subnodes');
         $node_list = array_merge($node_list, $nap->list_nodes($nodeid, true));
         debug_print_r('Remaining node queue', $node_list);
     }
     debug_add('We have to delete ' . count($guids) . ' objects from the index.');
     // Now we go over the entire index and delete the corresponding objects.
     // We load all attachments of the corresponding objects as well, to have
     // them deleted too.
     //
     // Again we keep an eye on the script timeout.
     $indexer = midcom::get('indexer');
     foreach ($guids as $guid) {
         set_time_limit(60);
         try {
             $object = midcom::get('dbfactory')->get_object_by_guid($guid);
             $atts = $object->list_attachments();
             if ($atts) {
                 foreach ($atts as $attachment) {
                     debug_add("Deleting attachment {$attachment->id} from the index.");
                     $indexer->delete($attachment->guid);
                 }
             }
         } catch (midcom_error $e) {
             $e->log();
         }
         debug_add("Deleting guid {$guid} from the index.");
         $indexer->delete($guid);
     }
 }
Example #2
0
 /**
  * Method for drawing the navigation.
  */
 public function draw()
 {
     if (!$this->root_id) {
         $this->root_id = $this->_nap->get_root_node();
     }
     if ($this->skip_levels !== 0) {
         if (!array_key_exists($this->skip_levels, $this->node_path)) {
             return;
         }
         $this->root_id = $this->node_path[$this->skip_levels];
     }
     if ($this->show_only_current) {
         $this->root_id = $this->_nap->get_current_node();
     }
     $this->_list_child_elements($this->root_id);
 }
Example #3
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_search($handler_id, array $args, array &$data)
 {
     $this->_request_data['results'] = array();
     if (array_key_exists('query', $_GET)) {
         // Figure out where we are
         $nap = new midcom_helper_nav();
         $node = $nap->get_node($nap->get_current_node());
         // Instantiate indexer
         $indexer = midcom::get('indexer');
         // Add the search parameters
         $query = $_GET['query'];
         $query .= " AND __TOPIC_URL:\"{$node[MIDCOM_NAV_FULLURL]}*\"";
         $query .= " AND __COMPONENT:org.openpsa.documents";
         // TODO: Metadata support
         // Run the search
         $this->_request_data['results'] = $indexer->query($query, null);
     }
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.documents/layout.css");
     $this->_populate_toolbar();
 }
Example #4
0
<?php

$nap = new midcom_helper_nav();
$node = $nap->get_node($nap->get_current_node());
?>
<div class="sidebar">
<div class="area org_openpsa_helper_box">
    <h3><?php 
echo $data['l10n']->get('groups');
?>
</h3>
<?php 
$data['tree']->render();
?>
</div>
</div>

<div class="main">
    <?php 
midcom::get()->dynamic_load($node[MIDCOM_NAV_RELATIVEURL] . "mycontacts");
?>
</div>
Example #5
0
 private function _get_navigation_data()
 {
     $ret = array();
     // Initialize the midcom_helper_nav or navigation access point
     $nap = new midcom_helper_nav();
     switch ((int) $this->_topic->get_parameter('midcom.helper.nav', 'navorder')) {
         case MIDCOM_NAVORDER_DEFAULT:
             $ret['nodes'] = array();
             $nodes = $nap->list_nodes($nap->get_current_node());
             foreach ($nodes as $id => $node_id) {
                 $node = $nap->get_node($node_id);
                 $node[MIDCOM_NAV_TYPE] = 'node';
                 $ret['nodes'][$id] = $node;
             }
             break;
         case MIDCOM_NAVORDER_TOPICSFIRST:
             // Sort the array to have the nodes first
             $ret = array('nodes' => array(), 'leaves' => array());
             // Fall through
         // Fall through
         case MIDCOM_NAVORDER_ARTICLESFIRST:
             // Sort the array to have the leaves first
             if (!isset($ret['leaves'])) {
                 $ret = array('leaves' => array(), 'nodes' => array());
             }
             // Get the nodes
             $nodes = $nap->list_nodes($nap->get_current_node());
             foreach ($nodes as $id => $node_id) {
                 $node = $nap->get_node($node_id);
                 $node[MIDCOM_NAV_TYPE] = 'node';
                 $ret['nodes'][$id] = $node;
             }
             // Get the leafs
             $leaves = $nap->list_leaves($nap->get_current_node());
             foreach ($leaves as $id => $leaf_id) {
                 $leaf = $nap->get_leaf($leaf_id);
                 $leaf[MIDCOM_NAV_TYPE] = 'leaf';
                 $ret['leaves'][$id] = $leaf;
             }
             break;
         case MIDCOM_NAVORDER_SCORE:
         default:
             $ret['mixed'] = array();
             // Get the navigation items
             $items = $nap->list_child_elements($nap->get_current_node());
             foreach ($items as $id => $item) {
                 if ($item[MIDCOM_NAV_TYPE] === 'node') {
                     $element = $nap->get_node($item[MIDCOM_NAV_ID]);
                 } else {
                     $element = $nap->get_leaf($item[MIDCOM_NAV_ID]);
                 }
                 // Store the type information
                 $element[MIDCOM_NAV_TYPE] = $item[MIDCOM_NAV_TYPE];
                 $ret['mixed'][] = $element;
             }
             break;
     }
     return $ret;
 }
Example #6
0
 /**
  * Handle a request.
  *
  * The URL of the component that is used to handle the request is obtained automatically.
  * If the handler hook returns false (i.e. handling failed), it will produce an error page.
  *
  * @param midcom_baseclasses_components_interface $handler The component's main handler class
  */
 public function run(midcom_baseclasses_components_interface $handler)
 {
     $result = $handler->handle();
     if (false === $result) {
         throw new midcom_error("Component " . $this->get_key(MIDCOM_CONTEXT_COMPONENT) . " failed to handle the request");
     } else {
         if (is_object($result) && $result instanceof midcom_response) {
             $result->send();
             //this will exit
         }
     }
     // Retrieve Metadata
     $nav = new midcom_helper_nav();
     if ($nav->get_current_leaf() === false) {
         $meta = $nav->get_node($nav->get_current_node());
     } else {
         $meta = $nav->get_leaf($nav->get_current_leaf());
     }
     if ($this->get_key(MIDCOM_CONTEXT_PERMALINKGUID) === null) {
         $this->set_key(MIDCOM_CONTEXT_PERMALINKGUID, $meta[MIDCOM_NAV_GUID]);
     }
     if ($this->get_key(MIDCOM_CONTEXT_PAGETITLE) == '') {
         $this->set_key(MIDCOM_CONTEXT_PAGETITLE, $meta[MIDCOM_NAV_NAME]);
     }
 }
Example #7
0
 /**
  * Day view
  *
  * @param String $handler_id    Name of the request handler
  * @param array $args           Variable arguments
  * @param array &$data          Public request data, passed by reference
  */
 public function _handler_day($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $this->_generate_date($args);
     // Instantiate calendar widget
     $this->_calendar = new org_openpsa_widgets_calendar(date('Y', $this->_selected_time), date('m', $this->_selected_time), date('d', $this->_selected_time));
     $this->_calendar->type = org_openpsa_widgets_calendar::DAY;
     // Slots are 2 hours long
     $this->_calendar->calendar_slot_length = $this->_config->get('day_slot_length') * 60;
     $this->_calendar->start_hour = $this->_config->get('day_start_time');
     $this->_calendar->end_hour = $this->_config->get('day_end_time');
     $this->_calendar->column_width = 60;
     $this->_populate_toolbar('day');
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'month/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('month view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png'));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'week/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png'));
     // Clicking a free slot should bring up 'new event' dialogue
     $nap = new midcom_helper_nav();
     $this_node = $nap->get_node($nap->get_current_node());
     if ($this->_root_event->can_do('midgard:create')) {
         $this->_calendar->reservation_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node));
     }
     $this->_calendar->free_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'));
     // Populate contacts
     $this->_populate_calendar_contacts($this->_calendar->get_day_start(), $this->_calendar->get_day_end());
     $this->_request_data['calendar'] =& $this->_calendar;
     // Set the breadcrumb
     $this->add_breadcrumb('year/' . date('Y-01-01', $this->_selected_time) . '/', strftime('%Y', $this->_selected_time));
     $this->add_breadcrumb('month/' . date('Y-m-01', $this->_selected_time) . '/', strftime('%B', $this->_selected_time));
     $this->add_breadcrumb('day/' . date('Y-m-d', $this->_selected_time) . '/', strftime('%x', $this->_selected_time));
     midcom::get('head')->set_pagetitle(strftime("%x", $this->_selected_time));
 }
Example #8
0
 private function _prepare_send(&$data)
 {
     $nap = new midcom_helper_nav();
     $node = $nap->get_node($nap->get_current_node());
     $data['compose_url'] = $node[MIDCOM_NAV_RELATIVEURL] . 'message/compose/' . $data['message_obj']->guid;
     $data['batch_url_base_full'] = $node[MIDCOM_NAV_RELATIVEURL] . 'message/send_bg/' . $data['message_obj']->guid;
     debug_add("compose_url: {$data['compose_url']}");
     debug_add("batch_url base: {$data['batch_url_base_full']}");
     $de_backup = ini_get('display_errors');
     $le_backup = ini_get('log_errors');
     ini_set('log_errors', true);
     ini_set('display_errors', false);
     ob_start();
     midcom::get()->dynamic_load($data['compose_url']);
     $composed = ob_get_contents();
     ob_end_clean();
     ini_set('display_errors', $de_backup);
     ini_set('log_errors', $le_backup);
     //We force the content-type since the compositor might have set it to something else in compositor for preview purposes
     debug_add('Forcing content type: text/html');
     midcom::get('cache')->content->content_type('text/html');
     //PONDER: Should we leave these entirely for the methods to parse from the array ?
     $data['compose_subject'] = '';
     $data['compose_from'] = '';
     if (array_key_exists('subject', $data['message_array'])) {
         $data['compose_subject'] =& $data['message_array']['subject'];
     }
     if (array_key_exists('from', $data['message_array'])) {
         $data['compose_from'] =& $data['message_array']['from'];
     }
     //Get SMS/MMS settings from component configuration
     if ($smslib_api = $this->_config->get('smslib_api')) {
         $data['message_obj']->sms_lib_api = $smslib_api;
     }
     if ($smslib_uri = $this->_config->get('smslib_uri')) {
         $data['message_obj']->sms_lib_location = $smslib_uri;
     } else {
         if ($email2sms_address = $this->_config->get('email2sms_address')) {
             $data['message_obj']->sms_lib_location = $email2sms_address;
         }
     }
     if ($smslib_client_id = $this->_config->get('smslib_client_id')) {
         $data['message_obj']->sms_lib_client_id = $smslib_client_id;
     }
     if ($smslib_user = $this->_config->get('smslib_user')) {
         $data['message_obj']->sms_lib_user = $smslib_user;
     }
     if ($smslib_password = $this->_config->get('smslib_password')) {
         $data['message_obj']->sms_lib_password = $smslib_password;
     }
     if ($mail_send_backend = $this->_config->get('mail_send_backend')) {
         $data['message_array']['mail_send_backend'] = $mail_send_backend;
     }
     if ($bouncer_address = $this->_config->get('bouncer_address')) {
         $data['message_array']['bounce_detector_address'] = $bouncer_address;
     }
     if ($link_detector_address = $this->_config->get('linkdetector_address')) {
         $data['message_array']['link_detector_address'] = $link_detector_address;
     }
     if ($token_size = $this->_config->get('token_size')) {
         $data['message_obj']->token_size = $token_size;
     }
     return $composed;
 }
Example #9
0
 /**
  * Get the URL where the topic links to
  *
  * @param array &$data   Request data
  * @return String containing redirection URL
  */
 public static function topic_links_to(&$data)
 {
     $config =& $data['config'];
     switch ($data['config']->get('redirection_type')) {
         case 'node':
             $nap = new midcom_helper_nav();
             $id = $data['config']->get('redirection_node');
             if (is_string($id)) {
                 try {
                     $topic = new midcom_db_topic($id);
                     $id = $topic->id;
                 } catch (midcom_error $e) {
                     $e->log();
                     break;
                 }
             }
             $node = $nap->get_node($id);
             // Node not found, fall through to configuration
             if (!$node) {
                 break;
             }
             return $node[MIDCOM_NAV_FULLURL];
         case 'subnode':
             $nap = new midcom_helper_nav();
             $nodes = $nap->list_nodes($nap->get_current_node());
             // Subnodes not found, fall through to configuration
             if (count($nodes) == 0) {
                 break;
             }
             // Redirect to first node
             $node = $nap->get_node($nodes[0]);
             return $node[MIDCOM_NAV_FULLURL];
         case 'permalink':
             $url = midcom::get('permalinks')->resolve_permalink($data['config']->get('redirection_guid'));
             if ($url) {
                 return $url;
             }
         case 'url':
             if ($data['config']->get('redirection_url') != '') {
                 $url = $data['config']->get('redirection_url');
                 // Support varying host prefixes
                 if (strpos($url, '__PREFIX__') !== false) {
                     $url = str_replace('__PREFIX__', midcom_connection::get_url('self'), $url);
                 }
                 return $url;
             }
             // Otherwise fall-through to config
     }
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     return "{$prefix}config/";
 }
Example #10
0
 function get_unsubscribe_url($node = false, $person = false)
 {
     if (!$node) {
         $nap = new midcom_helper_nav();
         $node = $nap->get_node($nap->get_current_node());
     }
     if (!is_object($person)) {
         $person = new org_openpsa_contacts_person_dba($this->person);
     }
     return "{$node[MIDCOM_NAV_FULLURL]}campaign/unsubscribe/{$this->guid}/";
 }