Esempio n. 1
0
 private function initialize_site_structure()
 {
     $nodes = array();
     foreach ($this->components as $component) {
         $nodes[$component] = midcom_helper_misc::find_node_by_component($component);
     }
     if (empty($nodes)) {
         return;
     }
     foreach ($nodes as $component => $node) {
         $parts = explode('.', $component);
         $last = array_pop($parts);
         $node_guid = 'false';
         $node_full_url = 'false';
         $node_relative_url = 'false';
         if (is_array($node)) {
             $node_guid = "'" . $node[MIDCOM_NAV_OBJECT]->guid . "'";
             $node_full_url = "'" . $node[MIDCOM_NAV_FULLURL] . "'";
             $node_relative_url = "'" . $node[MIDCOM_NAV_RELATIVEURL] . "'";
         }
         $this->set_config_value($last . '_guid', $node_guid);
         $this->set_config_value($last . '_full_url', $node_full_url);
         $this->set_config_value($last . '_relative_url', $node_relative_url);
     }
     midcom::get('auth')->request_sudo('org.openpsa.core');
     $this->snippet->update();
     midcom::get('auth')->drop_sudo();
     midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.core'), $this->_l10n->get('site structure cache created'), 'info');
 }
Esempio n. 2
0
 public function __construct($target_node, $target_object, $new_wikipage = null)
 {
     parent::__construct();
     $this->target_node = $target_node;
     $this->target = midcom::get('dbfactory')->get_object_by_guid($target_object);
     $this->wiki = midcom_helper_misc::find_node_by_component('net.nemein.wiki');
     if ($new_wikipage) {
         $this->new_wikipage = rawurlencode(str_replace('/', '-', $new_wikipage));
     }
 }
Esempio n. 3
0
 private function _populate_toolbar()
 {
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/edit/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("edit"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e'));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/create/organization/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create suborganization'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/create/group/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create subgroup'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update')));
     if (midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba') && $this->_group->can_do('midgard:create')) {
         $allow_person_create = true;
     } else {
         $allow_person_create = false;
     }
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "person/create/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create person'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person-new.png', MIDCOM_TOOLBAR_ENABLED => $allow_person_create));
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $user_url = $siteconfig->get_node_full_url('org.openpsa.user');
     if ($user_url && midcom::get('auth')->can_user_do('org.openpsa.user:access', null, 'org_openpsa_user_interface')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $user_url . "group/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('user management', 'org.openpsa.user'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png'));
     }
     $cal_node = midcom_helper_misc::find_node_by_component('org.openpsa.calendar');
     if (!empty($cal_node)) {
         //TODO: Check for privileges somehow
         $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "#", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create event'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new-event.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink', 'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($cal_node, false, $this->_group->guid))));
     }
 }
Esempio n. 4
0
 /**
  * Add CSS
  *
  * @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_callback($handler_id, array $args, array &$data)
 {
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css");
     //need js for chooser-widgets for list of hour - because of dynamic load loading is needed here
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/chooser/jquery.chooser_widget.js");
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/chooser/jquery.chooser_widget.css");
     if ($handler_id == 'task_view') {
         org_openpsa_widgets_contact::add_head_elements();
         $data['calendar_node'] = midcom_helper_misc::find_node_by_component('org.openpsa.calendar');
     }
 }
Esempio n. 5
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_generator($handler_id, array &$data)
 {
     midcom_show_style('sales_report-deliverable-start');
     // Quick workaround to Bergies lazy determination of whether this is user's or everyone's report...
     if ($this->_request_data['query_data']['resource'] == 'user:'******'auth')->user->guid) {
         // My report
         $data['handler_id'] = 'deliverable_report';
     } else {
         // Generic report
         $data['handler_id'] = 'sales_report';
     }
     /*** Copied from sales/handler/deliverable/report.php ***/
     midcom_show_style('sales_report-deliverable-header');
     $invoices_node = midcom_helper_misc::find_node_by_component('org.openpsa.invoices');
     $sums_per_person = array();
     $sums_all = array('price' => 0, 'cost' => 0, 'profit' => 0);
     $odd = true;
     foreach ($data['invoices'] as $deliverable_guid => $invoices) {
         if (count($invoices) == 0) {
             // No invoices sent in this project, skip
             continue;
         }
         try {
             $deliverable = org_openpsa_sales_salesproject_deliverable_dba::get_cached($deliverable_guid);
             $product = org_openpsa_products_product_dba::get_cached($deliverable->product);
             $salesproject = org_openpsa_sales_salesproject_dba::get_cached($deliverable->salesproject);
             $customer = midcom_db_group::get_cached($salesproject->customer);
         } catch (midcom_error $e) {
             continue;
         }
         if (!array_key_exists($salesproject->owner, $sums_per_person)) {
             $sums_per_person[$salesproject->owner] = array('price' => 0, 'cost' => 0, 'profit' => 0);
         }
         // Calculate the price and cost from invoices
         $invoice_price = 0;
         $data['invoice_string'] = '';
         $invoice_cycle_numbers = array();
         foreach ($invoices as $invoice) {
             $invoice_price += $invoice->sum;
             $invoice_class = $invoice->get_status();
             if ($invoices_node) {
                 $invoice_label = "<a class=\"{$invoice_class}\" href=\"{$invoices_node[MIDCOM_NAV_FULLURL]}invoice/{$invoice->guid}/\">" . $invoice->get_label() . "</a>";
             } else {
                 $invoice_label = $invoice->get_label();
             }
             if ($product->delivery == org_openpsa_products_product_dba::DELIVERY_SUBSCRIPTION) {
                 $invoice_cycle_numbers[] = (int) $invoice->parameter('org.openpsa.sales', 'cycle_number');
             }
             $data['invoice_string'] .= "<li class=\"{$invoice_class}\">{$invoice_label}</li>\n";
         }
         if ($product->delivery == org_openpsa_products_product_dba::DELIVERY_SUBSCRIPTION) {
             // This is a subscription, it should be shown only if it is the first invoice
             if (!in_array(1, $invoice_cycle_numbers)) {
                 continue;
                 // This will skip to next deliverable
             }
             $scheduler = new org_openpsa_invoices_scheduler($deliverable);
             if ($deliverable->end == 0) {
                 // Subscription doesn't have an end date, use specified amount of months for calculation
                 $cycles = $scheduler->calculate_cycles($this->_config->get('subscription_profit_months'));
                 $data['calculation_basis'] = sprintf($data['l10n']->get('%s cycles in %s months'), $cycles, $this->_config->get('subscription_profit_months'));
             } else {
                 $cycles = $scheduler->calculate_cycles();
                 $data['calculation_basis'] = sprintf($data['l10n']->get('%s cycles, %s - %s'), $cycles, strftime('%x', $deliverable->start), strftime('%x', $deliverable->end));
             }
             $price = $deliverable->price * $cycles;
             $cost = $deliverable->cost * $cycles;
         } else {
             // This is a single delivery, calculate cost as percentage as it may be invoiced in pieces
             if ($deliverable->price) {
                 $cost_percentage = 100 / $deliverable->price * $invoice_price;
                 $cost = $deliverable->cost / 100 * $cost_percentage;
             } else {
                 $cost_percentage = 100;
                 $cost = $deliverable->cost;
             }
             $price = $invoice_price;
             $data['calculation_basis'] = sprintf($data['l10n']->get('%s%% of %s'), round($cost_percentage), $deliverable->price);
         }
         // And now just count the profit
         $profit = $price - $cost;
         $data['customer'] = $customer;
         $data['salesproject'] = $salesproject;
         $data['deliverable'] = $deliverable;
         $data['price'] = $price;
         $sums_per_person[$salesproject->owner]['price'] += $price;
         $sums_all['price'] += $price;
         $data['cost'] = $cost;
         $sums_per_person[$salesproject->owner]['cost'] += $cost;
         $sums_all['cost'] += $cost;
         $data['profit'] = $profit;
         $sums_per_person[$salesproject->owner]['profit'] += $profit;
         $sums_all['profit'] += $profit;
         if ($odd) {
             $data['row_class'] = '';
             $odd = false;
         } else {
             $data['row_class'] = ' class="even"';
             $odd = true;
         }
         midcom_show_style('sales_report-deliverable-item');
     }
     $data['sums_per_person'] = $sums_per_person;
     $data['sums_all'] = $sums_all;
     midcom_show_style('sales_report-deliverable-footer');
     /*** /Copied from sales/handler/deliverable/report.php ***/
     midcom_show_style('sales_report-deliverable-end');
 }
                <td class="numeric"><?php 
echo $total;
?>
</td>
                <td>&nbsp;</td>
                <td class="numeric"><?php 
echo round($total / ($report['receipt_data']['sent'] - $report['receipt_data']['bounced']) * 100, 2);
?>
</td>
            </tr>
    </table>
    <input type="submit" class="button create_campaign" value="<?php 
echo $l10n->get('create campaign from link');
?>
"/>
</form>
<?php 
$reports_node = midcom_helper_misc::find_node_by_component('org.openpsa.reports');
if (!empty($reports_node)) {
    $reports_prefix = $reports_node[MIDCOM_NAV_FULLURL];
    $filename = 'org_openpsa_directmarketing_' . date('Ymd_Hi');
    ?>
<form method="post" action="&(reports_prefix);csv/&(filename);.csv" onSubmit="return table2csv('org_openpsa_directmarketing_messagelinks&(form_suffix);');">
    <input type="hidden" id="csvdata" name="org_openpsa_reports_csv" value="" />
    <input class="button" type="submit" value="<?php 
    echo midcom::get('i18n')->get_string('download as CSV', 'org.openpsa.core');
    ?>
" />
</form>
    <?php 
}
Esempio n. 7
0
 public function _on_watched_dba_create($post)
 {
     // TODO: Move this logic to a separate class
     // Re-fetch the post
     $post = new net_nemein_discussion_post_dba($post->id);
     // Figure out which topic the post is in
     $thread = new net_nemein_discussion_thread_dba($post->thread);
     try {
         $node = new midcom_db_topic($thread->node);
     } catch (midcom_error $e) {
         return false;
     }
     // Find out if some campaign watches the topic
     $campaigns = array();
     $qb = new midgard_query_builder('midgard_parameter');
     $qb->add_constraint('domain', '=', 'org.openpsa.directmarketing');
     $qb->add_constraint('name', '=', 'watch_discussion');
     $qb->add_constraint('value', '=', $node->guid);
     $campaign_params = @$qb->execute();
     if (is_array($campaign_params) && count($campaign_params) > 0) {
         foreach ($campaign_params as $parameter) {
             try {
                 $campaign = new org_openpsa_directmarketing_campaign_dba($parameter->parentguid);
             } catch (midcom_error $e) {
                 continue;
             }
             $campaigns[] = $campaign;
         }
     }
     if (count($campaigns) < 1) {
         return;
     }
     // Find an o.o.directmarketing node for message composition
     $directmarketing_node = midcom_helper_misc::find_node_by_component('org.openpsa.directmarketing');
     if (!$directmarketing_node) {
         return;
     }
     foreach ($campaigns as $campaign) {
         // Create message
         $message = new org_openpsa_directmarketing_campaign_message_dba();
         $message->campaign = $campaign->id;
         // FIXME: Support HTML mails and other notifications too
         $message->orgOpenpsaObtype = org_openpsa_directmarketing_campaign_message_dba::EMAIL_TEXT;
         $message->title = $post->subject;
         $stat = $message->create();
         if ($stat) {
             // Populate the Post data here
             $message = new org_openpsa_directmarketing_campaign_message_dba($message->id);
             // FIXME: We're making awfully lot of assumptions here
             $message->parameter('midcom.helper.datamanager', 'data_post', $post->guid);
             $message->parameter('midcom.helper.datamanager', 'data_subject', "[{$campaign->title}] {$post->subject}");
             $message->parameter('midcom.helper.datamanager', 'data_content', $post->content);
             $message->parameter('midcom.helper.datamanager', 'data_from', "{$post->sendername} <{$post->senderemail}>");
             debug_add("Message created from forum post #{$post->id} \"{$post->subject}\"");
             // TODO: Now we should actually send the message
             $sending_url = $directmarketing_node[MIDCOM_NAV_RELATIVEURL] . "message/{$message->guid}/send/";
             debug_add("START SEND TO URL {$sending_url}");
             midcom::get('auth')->request_sudo();
             ob_start();
             midcom::get()->dynamic_load($sending_url);
             $output = ob_get_contents();
             ob_end_clean();
             midcom::get('auth')->drop_sudo();
             debug_add("END SEND");
         } else {
             debug_add("Failed to create campaign message from post, reason " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         }
     }
 }
Esempio n. 8
0
 /**
  * Try to find a comments node (cache results)
  */
 private function _seek_comments()
 {
     if ($this->_config->get('comments_topic')) {
         // We have a specified photostream here
         try {
             $comments_topic = new midcom_db_topic($this->_config->get('comments_topic'));
         } catch (midcom_error $e) {
             return false;
         }
         // We got a topic. Make it a NAP node
         $nap = new midcom_helper_nav();
         $comments_node = $nap->get_node($comments_topic->id);
         return $comments_node;
     }
     // No comments topic specified, autoprobe
     $comments_node = midcom_helper_misc::find_node_by_component('net.nehmer.comments');
     // Cache the data
     if (midcom::get('auth')->request_sudo('net.nehmer.blog')) {
         $this->_topic->parameter('net.nehmer.blog', 'comments_topic', $comments_node[MIDCOM_NAV_GUID]);
         midcom::get('auth')->drop_sudo();
     }
     return $comments_node;
 }
Esempio n. 9
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_review($handler_id, array &$data)
 {
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $data['calendar_node'] = midcom_helper_misc::find_node_by_component('org.openpsa.calendar');
     $data['projects_url'] = $siteconfig->get_node_full_url('org.openpsa.projects');
     $date = new DateTime(date('Y-m-d', $data['week_start']));
     $offset = $date->format('N') - 1;
     $date->modify('-' . $offset . ' days');
     $week_hours_invoiceable = 0;
     $week_hours_total = 0;
     midcom_show_style('weekreview-header');
     for ($i = 0; $i < 7; $i++) {
         $day = $date->format('Y-m-d');
         $data['day_start'] = (int) $date->format('U');
         $date->setTime(23, 59, 59);
         $data['day_end'] = (int) $date->format('U');
         //Roll over to the next day
         $date->modify('+1 second');
         if (!array_key_exists($day, $data['review_data'])) {
             // Nothing for today
             continue;
         }
         midcom_show_style('weekreview-day-header');
         $day_hours_invoiceable = 0;
         $day_hours_total = 0;
         // Arrange entries per time
         ksort($data['review_data'][$day]);
         $data['class'] = 'even';
         foreach ($data['review_data'][$day] as $time => $guids) {
             foreach ($guids as $object) {
                 if ($data['class'] == 'even') {
                     $data['class'] = 'odd';
                 } else {
                     $data['class'] = 'even';
                 }
                 $data['time'] = $time;
                 $data['object'] = $object;
                 switch (get_class($object)) {
                     case 'org_openpsa_calendar_event_dba':
                         midcom_show_style('weekreview-day-item-event');
                         break;
                     case 'org_openpsa_projects_hour_report_dba':
                         midcom_show_style('weekreview-day-item-hour-report');
                         if ($object->invoiceable) {
                             $day_hours_invoiceable += $object->hours;
                         }
                         $day_hours_total += $object->hours;
                         break;
                     case 'org_openpsa_projects_task_status_dba':
                         midcom_show_style('weekreview-day-item-task-status');
                         break;
                     case 'org_routamc_positioning_log_dba':
                         midcom_show_style('weekreview-day-item-position');
                         break;
                 }
             }
         }
         $data['day_hours_invoiceable'] = $day_hours_invoiceable;
         $week_hours_invoiceable += $day_hours_invoiceable;
         $data['day_hours_total'] = $day_hours_total;
         $week_hours_total += $day_hours_total;
         midcom_show_style('weekreview-day-footer');
     }
     $data['week_hours_invoiceable'] = $week_hours_invoiceable;
     $data['week_hours_total'] = $week_hours_total;
     midcom_show_style('weekreview-footer');
 }
Esempio n. 10
0
<?php

$nap = new midcom_helper_nav();
$node = $nap->get_node($nap->get_current_node());
?>
<div class="sidebar">
    <?php 
midcom::get()->dynamic_load($node[MIDCOM_NAV_RELATIVEURL] . "person/memberships/{$data['person']->guid}/");
// Try to find campaigns component
$campaigns_node = midcom_helper_misc::find_node_by_component('org.openpsa.directmarketing');
if ($campaigns_node) {
    midcom::get()->dynamic_load($campaigns_node[MIDCOM_NAV_RELATIVEURL] . "campaign/list/{$data['person']->guid}/");
}
?>
</div>

<div class="main">
<?php 
$data['datamanager']->display_view(true);
//add tabs
$tabs = array();
$siteconfig = org_openpsa_core_siteconfig::get_instance();
$invoices_url = $siteconfig->get_node_relative_url('org.openpsa.invoices');
$sales_url = $siteconfig->get_node_relative_url('org.openpsa.sales');
//TODO: Check for privileges somehow
$invoices_url = $siteconfig->get_node_relative_url('org.openpsa.invoices');
if ($invoices_url) {
    $qb = org_openpsa_invoices_invoice_dba::new_query_builder();
    $qb->add_constraint('customerContact', '=', $data['person']->id);
    $qb->set_limit(1);
    if ($qb->count() > 0) {
<?php

echo $data['message_array']['content'];
$blog_node = midcom_helper_misc::find_node_by_component('net.nehmer.blog');
if ($blog_node) {
    midcom::get()->dynamic_load("{$blog_node[MIDCOM_NAV_RELATIVEURL]}latest/{$data['message_array']['newsitems']}");
}