Example #1
0
 public function __construct()
 {
     $this->root_topic = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ROOTTOPIC);
     $this->current_object = $this->root_topic;
     // TODO: Remove
     $this->check_style_inheritance($this->root_topic);
 }
Example #2
0
 public function send()
 {
     if (!preg_match('|^https?://|', $this->url)) {
         if ($this->url == '' || substr($this->url, 0, 1) != "/") {
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             if ($prefix == '') {
                 $prefix = midcom::get()->get_page_prefix();
             }
             $this->url = "{$prefix}{$this->url}";
             debug_add("This is a relative URL from the local site, prepending anchor prefix: {$this->url}");
         } else {
             $this->url = midcom::get()->get_host_name() . $this->url;
             debug_add("This is an absolute URL from the local host, prepending host name: {$this->url}");
         }
         $location = "Location: {$this->url}";
     } else {
         // This is an external URL
         $location = "Location: {$this->url}";
     }
     midcom::get('cache')->content->no_cache();
     midcom::get()->finish();
     debug_add("Relocating to {$location}");
     midcom::get()->header($location, $this->code);
     _midcom_stop_request();
 }
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_delete($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     $this->_group = new midcom_db_group($args[0]);
     if (array_key_exists('org_openpsa_user_deleteok', $_POST)) {
         $delete_succeeded = $this->_group->delete();
         $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
         if ($delete_succeeded) {
             // Update the index
             $indexer = midcom::get('indexer');
             $indexer->delete($this->_group->guid);
             return new midcom_response_relocate('');
         } else {
             // Failure, give a message
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), $this->_l10n->get("failed to delete group, reason") . ' ' . midcom_connection::get_error_string(), 'error');
             return new midcom_response_relocate($prefix . 'group/' . $this->_group->guid . '/');
         }
     }
     $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_group);
     $data['group'] = $this->_group;
     org_openpsa_widgets_tree::add_head_elements();
     $this->add_breadcrumb('groups/', $this->_l10n->get('groups'));
     $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('delete %s'), $this->_group->get_label()));
     $this->bind_view_to_object($this->_group);
 }
Example #4
0
 public function get_row(midcom_core_dbaobject $document)
 {
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     $entry = array();
     $entry['id'] = $document->id;
     $entry['index_title'] = $document->title;
     $entry['index_filesize'] = 0;
     $entry['filesize'] = '';
     $entry['mimetype'] = '';
     $icon = MIDCOM_STATIC_URL . '/stock-icons/mime/gnome-text-blank.png';
     $alt = '';
     $att = $document->load_attachment();
     if ($att) {
         $icon = midcom_helper_misc::get_mime_icon($att->mimetype);
         $alt = $att->name;
         $stats = $att->stat();
         $entry['index_filesize'] = $stats[7];
         $entry['filesize'] = midcom_helper_misc::filesize_to_string($stats[7]);
         $entry['mimetype'] = org_openpsa_documents_document_dba::get_file_type($att->mimetype);
     }
     $title = '<a class="tab_escape" href="' . $prefix . 'document/' . $document->guid . '/"><img src="' . $icon . '"';
     $title .= 'alt="' . $alt . '" style="border: 0px; height: 16px; vertical-align: middle" /> ' . $document->title . '</a>';
     $entry['title'] = $title;
     $entry['created'] = strftime('%Y-%m-%d %X', $document->metadata->created);
     $entry['index_author'] = '';
     $entry['author'] = '';
     if ($document->author) {
         $author = org_openpsa_contacts_person_dba::get_cached($document->author);
         $entry['index_author'] = $author->rname;
         $author_card = org_openpsa_widgets_contact::get($author->guid);
         $entry['author'] = $author_card->show_inline();
     }
     return $entry;
 }
Example #5
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_rss($handler_id, array &$data)
 {
     $qb = net_nemein_wiki_wikipage::new_query_builder();
     $qb->add_constraint('topic.component', '=', midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT));
     $qb->add_constraint('topic', 'INTREE', $this->_topic->id);
     $qb->add_order('metadata.revised', 'DESC');
     $qb->set_limit($this->_config->get('rss_count'));
     $result = $qb->execute();
     foreach ($result as $wikipage) {
         if ($wikipage->topic == $this->_topic->id) {
             $node = $data['node'];
         } else {
             $node = $data['nap']->get_node($wikipage->topic);
         }
         $item = new FeedItem();
         $item->title = $wikipage->title;
         if ($wikipage->name == 'index') {
             $item->link = "{$node[MIDCOM_NAV_FULLURL]}";
         } else {
             $item->link = "{$node[MIDCOM_NAV_FULLURL]}{$wikipage->name}/";
         }
         $item->date = $wikipage->metadata->revised;
         try {
             $author = new midcom_db_person($wikipage->metadata->revisor);
             $item->author = $author->name;
         } catch (midcom_error $e) {
             $e->log();
         }
         $parser = new net_nemein_wiki_parser($wikipage);
         $item->description = $parser->get_html();
         $data['rss_creator']->addItem($item);
     }
     $data['rss'] = $data['rss_creator']->createFeed('RSS2.0');
     echo $data['rss'];
 }
Example #6
0
 private function _populate_toolbar()
 {
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_left.png', MIDCOM_TOOLBAR_ACCESSKEY => 'v'));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "edit/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e', MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:update')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd', MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:delete')));
     foreach (array_keys($this->_request_data['schemadb']) as $name) {
         if ($name == $this->_datamanager->schema->name) {
             // The page is already of this type, skip
             continue;
         }
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "change/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n->get('change to %s'), $this->_l10n->get($this->_request_data['schemadb'][$name]->description)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_refresh.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('change_to' => $name), MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:update')));
     }
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "whatlinks/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('what links'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/jump-to.png'));
     if (midcom::get('auth')->user) {
         $user = midcom::get('auth')->user->get_storage();
         if ($this->_page->parameter('net.nemein.wiki:watch', $user->guid)) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('unsubscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('unsubscribe' => 1)));
         } else {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('subscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('subscribe' => 1)));
         }
     }
     if ($this->_page->can_do('midgard:update')) {
         midcom::get('head')->add_link_head(array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $this->_request_data['l10n_midcom']->get('edit'), 'href' => midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "edit/{$this->_page->name}/"));
     }
     if (midcom::get('componentloader')->is_installed('org.openpsa.relatedto')) {
         org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_page->guid);
     }
     $this->bind_view_to_object($this->_page, $this->_datamanager->schema->name);
 }
Example #7
0
 /**
  * Sort the reports by task and day
  */
 private function _get_sorted_reports($hours_mc)
 {
     $reports = array();
     $hours = $hours_mc->list_keys();
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     foreach ($hours as $guid => $empty) {
         $task_id = $hours_mc->get_subkey($guid, 'task');
         try {
             $task = org_openpsa_projects_task_dba::get_cached($task_id);
         } catch (midcom_error $e) {
             // Task couldn't be loaded, probably because of ACL
             continue;
         }
         $person = $hours_mc->get_subkey($guid, 'person');
         $date = $hours_mc->get_subkey($guid, 'date');
         $date_identifier = date('Y-m-d', $date);
         $row_identifier = $task->id . '-' . $person;
         if (!isset($reports[$row_identifier])) {
             $reports[$row_identifier] = array($date_identifier => 0, 'task' => "<a href=\"{$prefix}hours/task/{$task->guid}/\">" . $task->get_label() . "</a>", 'task_index' => $task->get_label());
             try {
                 $person = org_openpsa_contacts_person_dba::get_cached($person);
                 $reports[$row_identifier]['person'] = $person->name;
             } catch (midcom_error $e) {
                 $reports[$row_identifier]['person'] = $this->_l10n->get('no person');
             }
         }
         if (!isset($reports[$row_identifier][$date_identifier])) {
             $reports[$row_identifier][$date_identifier] = 0;
         }
         $reports[$row_identifier][$date_identifier] += $hours_mc->get_subkey($guid, 'hours');
     }
     return array_values($reports);
 }
Example #8
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_edit($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     // Check if we get the group
     $this->_group = new org_openpsa_contacts_group_dba($args[0]);
     $this->_group->require_do('midgard:update');
     if ($this->_group->orgOpenpsaObtype < org_openpsa_contacts_group_dba::MYCONTACTS) {
         $this->_type = 'group';
     } else {
         $this->_type = 'organization';
     }
     $data['controller'] = $this->get_controller('simple', $this->_group);
     switch ($data['controller']->process_form()) {
         case 'save':
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($data['controller']->datamanager);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             return new midcom_response_relocate($prefix . "group/" . $this->_group->guid . "/");
     }
     $root_group = org_openpsa_contacts_interface::find_root_group();
     if ($this->_group->owner && $this->_group->owner != $root_group->id) {
         $data['parent_group'] = new org_openpsa_contacts_group_dba($this->_group->owner);
     } else {
         $data['parent_group'] = false;
     }
     $data['group'] =& $this->_group;
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_group);
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('edit %s'), $this->_group->official));
     org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_group, $this);
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get($this->_type)));
 }
Example #9
0
 /**
  * Handler for folder deletion.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success
  */
 public function _handler_delete($handler_id, array $args, array &$data)
 {
     // Symlink support requires that we use actual URL topic object here
     $urltopics = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_URLTOPICS);
     if ($urltopic = end($urltopics)) {
         $this->_topic = $urltopic;
     }
     $this->_topic->require_do('midgard:delete');
     $this->_topic->require_do('midcom.admin.folder:topic_management');
     if (array_key_exists('f_cancel', $_REQUEST)) {
         return new midcom_response_relocate('');
     }
     if (array_key_exists('f_submit', $_REQUEST)) {
         $nav = new midcom_helper_nav();
         $upper_node = $nav->get_node($nav->get_current_upper_node());
         if ($this->_process_delete_form()) {
             return new midcom_response_relocate($upper_node[MIDCOM_NAV_FULLURL]);
         }
     }
     $this->_request_data['topic'] = $this->_topic;
     // Add the view to breadcrumb trail
     $this->add_breadcrumb('__ais/folder/delete/', $this->_l10n->get('delete folder'));
     // Hide the button in toolbar
     $this->_node_toolbar->hide_item('__ais/folder/delete/');
     // Set page title
     $data['title'] = sprintf(midcom::get('i18n')->get_string('delete folder %s', 'midcom.admin.folder'), $data['topic']->extra);
     midcom::get('head')->set_pagetitle($data['title']);
     // Set the help object in the toolbar
     $help_toolbar = midcom::get('toolbars')->get_help_toolbar();
     $help_toolbar->add_help_item('delete_folder', 'midcom.admin.folder', null, null, 1);
     // Ensure we get the correct styles
     midcom::get('style')->prepend_component_styledir('midcom.admin.folder');
     // Add style sheet
     $this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.admin.folder/folder.css');
 }
Example #10
0
    /**
     * Populate the toolbar
     *
     * @param String $today_path    Path to the today's calendar
     */
    private function _populate_toolbar($path = null)
    {
        // 'New event' should always be in toolbar
        $nap = new midcom_helper_nav();
        $this_node = $nap->get_node($nap->get_current_node());
        if ($this->_root_event->can_do('midgard:create')) {
            $this->_view_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($this_node))));
        }
        if (method_exists($this->_calendar, 'get_' . $path . '_start')) {
            $previous = date('Y-m-d', call_user_func(array($this->_calendar, 'get_' . $path . '_start')) - 100);
            $next = date('Y-m-d', call_user_func(array($this->_calendar, 'get_' . $path . '_end')) + 100);
            $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $path . '/' . $previous . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('previous'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/up.png'));
            $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $path . '/' . $next . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/down.png'));
        }
        if ($this->_topic->can_do('midgard:update') && $this->_topic->can_do('midcom:component_config')) {
            $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'config/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'), MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png'));
        }
        midcom_helper_datamanager2_widget_jsdate::add_head_elements();
        midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.calendar/navigation.js");
        $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
        $default_date = date('Y-m-d', $this->_selected_time);
        midcom::get('head')->add_jscript('
var org_openpsa_calendar_default_date = "' . $default_date . '",
org_openpsa_calendar_prefix = "' . $prefix . $path . '";
        ');
        $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => '#', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('go to'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_jump-to.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink', 'id' => 'date-navigation')));
        $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$path}/" . $this->_get_datestring(time()) . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('today'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/web-calendar.png'));
        $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "filters/?org_openpsa_calendar_returnurl=" . midcom_connection::get_url('uri'), MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('choose calendars'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/preferences-desktop.png'));
    }
Example #11
0
 /**
  * Constructs a session object.
  *
  * The constructor has three semantics:
  *
  * The default constructor will create a sessioning object within the domain
  * of the current context's component. This will be sufficient for almost all
  * actual uses of the sessions.
  *
  * If passed an integer argument, it will use the context indicated by this
  * parameter as a default domain.
  *
  * Finally, if passed a string argument, this value is used as a domain. This
  * is useful for components that need sessioning while under <i>dynamic_load</i>
  * conditions or while used as a <i>library</i>.
  *
  * @param mixed $context    Either null or a context ID (uses the context's component) or an explicit domain.
  */
 public function __construct($context = null)
 {
     if (is_null($context) || is_numeric($context) || is_int($context)) {
         $this->_domain = midcom_core_context::get($context)->get_key(MIDCOM_CONTEXT_COMPONENT);
     } else {
         $this->_domain = $context;
     }
     $this->_sessioning = midcom::get("session");
 }
Example #12
0
 public function navigation()
 {
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     $libs = midcom_admin_libconfig_plugin::get_libraries();
     echo '<ul class="midgard_admin_asgard_navigation">';
     foreach ($libs as $name => $manifest) {
         $label = midcom::get('i18n')->get_string($name, $name);
         echo "            <li class=\"status\"><a href=\"{$prefix}__mfa/asgard_midcom.admin.libconfig/view/{$name}/\">{$label}</a></li>\n";
     }
     echo "</ul>";
 }
function midgard_admin_asgard_trash_type_show($object, $indent = 0, $prefix = '', $enable_undelete = true)
{
    static $persons = array();
    static $shown = array();
    static $url_prefix = '';
    if (!$url_prefix) {
        $url_prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
    }
    if (isset($shown[$object->guid])) {
        return;
    }
    if (!isset($persons[$object->metadata->revisor])) {
        $persons[$object->metadata->revisor] = midcom::get('auth')->get_user($object->metadata->revisor);
    }
    $reflector = midcom_helper_reflector_tree::get($object);
    $icon = $reflector->get_object_icon($object);
    echo "{$prefix}<tr>\n";
    $disabled = '';
    if (!$enable_undelete) {
        $disabled = ' disabled="disabled"';
    }
    $object_label = $reflector->get_object_label($object);
    if (empty($object_label)) {
        $object_label = $object->guid;
    }
    echo "{$prefix}    <td class=\"checkbox\"><input type=\"checkbox\" name=\"undelete[]\"{$disabled} value=\"{$object->guid}\" id=\"guid_{$object->guid}\" /></td>\n";
    echo "{$prefix}    <td class=\"label\" style=\"padding-left: {$indent}px\"><label for=\"guid_{$object->guid}\">{$icon}" . $object_label . "</label></td>\n";
    echo "{$prefix}    <td class=\"nowrap\">" . strftime('%x %X', strtotime($object->metadata->revised)) . "</td>\n";
    if (isset($persons[$object->metadata->revisor]->guid)) {
        echo "{$prefix}    <td><a href=\"{$url_prefix}__mfa/asgard/object/view/{$persons[$object->metadata->revisor]->guid}/\">{$persons[$object->metadata->revisor]->name}</a></td>\n";
    } else {
        echo "{$prefix}    <td>&nbsp;</td>\n";
    }
    echo "{$prefix}    <td>" . midcom_helper_misc::filesize_to_string($object->metadata->size) . "</td>\n";
    echo "{$prefix}</tr>\n";
    $child_types = midcom_helper_reflector_tree::get_child_objects($object, true);
    if (is_array($child_types) && count($child_types) > 0) {
        $child_indent = $indent + 20;
        echo "{$prefix}<tbody class=\"children\">\n";
        foreach ($child_types as $type => $children) {
            if (count($children) < 10 || isset($_GET['show_children'][$object->guid][$type])) {
                foreach ($children as $child) {
                    midgard_admin_asgard_trash_type_show($child, $child_indent, "{$prefix}    ", false);
                }
            } else {
                echo "{$prefix}    <tr>\n";
                echo "{$prefix}        <td class=\"label\" style=\"padding-left: {$child_indent}px\" colspan=\"5\"><a href=\"?show_children[{$object->guid}][{$type}]=1\">" . sprintf(midcom::get('i18n')->get_string('show %s %s children', 'midgard.admin.asgard'), count($children), midgard_admin_asgard_plugin::get_type_label($type)) . "</a></td>\n";
                echo "{$prefix}    </tr>\n";
            }
        }
        echo "{$prefix}</tbody>\n";
    }
    $shown[$object->guid] = true;
}
Example #14
0
 /**
  * If the folder already has content in it we should disable the language chooser to avoid confusion
  *
  * @return boolean
  */
 static function disable_language_select()
 {
     // We cannot use $this->_topic in a static method
     $topic = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_CONTENTTOPIC);
     $qb = midcom_db_article::new_query_builder();
     $qb->add_constraint('topic', '=', $topic->id);
     $qb->set_limit(1);
     if ($qb->count() > 0) {
         return true;
     }
     return false;
 }
Example #15
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_today($handler_id, array &$data)
 {
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $data['calendar_url'] = $siteconfig->get_node_relative_url('org.openpsa.calendar');
     $data['projects_url'] = $siteconfig->get_node_full_url('org.openpsa.projects');
     $data['projects_relative_url'] = $siteconfig->get_node_relative_url('org.openpsa.projects');
     $data['expenses_url'] = $siteconfig->get_node_full_url('org.openpsa.expenses');
     $data['wiki_url'] = $siteconfig->get_node_relative_url('net.nemein.wiki');
     $data_url = midcom::get()->get_host_name() . midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     $data['journal_url'] = $data_url . '/__mfa/org.openpsa.relatedto/journalentry/list/xml/';
     midcom_show_style('show-today');
 }
Example #16
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_pdf($handler_id, array $args, array &$data)
 {
     $this->_invoice = new org_openpsa_invoices_invoice_dba($args[0]);
     $this->_request_data['invoice_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "invoice/" . $this->_invoice->guid . "/";
     //check for manually uploaded pdf-file & if user wants to replace it
     if (array_key_exists('cancel', $_POST)) {
         return new midcom_response_relocate($this->_request_data['invoice_url']);
     } else {
         if (array_key_exists('save', $_POST)) {
             $this->_update_attachment = true;
         } else {
             $data['confirmation_message'] = 'current pdf file was manually uploaded shall it be replaced ?';
             // load schema & datamanager to get attachment
             $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
             $this->_datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$this->_datamanager->autoset_storage($this->_invoice)) {
                 throw new midcom_error("Failed to create a DM2 instance for object {$this->_invoice->guid}.");
             }
             if ($this->_invoice->sent) {
                 $data['confirmation_message'] = 'invoice has already been sent. should it be replaced?';
             } else {
                 if (!empty($this->_datamanager->types['pdf_file']->attachments)) {
                     foreach ($this->_datamanager->types['pdf_file']->attachments as $attachment) {
                         $checksum = $attachment->get_parameter('org.openpsa.invoices', 'auto_generated');
                         // check if auto generated parameter is same as md5 in current-file
                         // if not the file was manually uploaded
                         if ($checksum) {
                             $blob = new midgard_blob($attachment->__object);
                             // check if md5 sum equals the one saved in auto_generated
                             if ($checksum == md5_file($blob->get_path())) {
                                 $this->_update_attachment = true;
                             }
                         }
                     }
                 } else {
                     $this->_update_attachment = true;
                 }
             }
         }
     }
     if ($this->_update_attachment) {
         $this->_request_data['billing_data'] = $this->_invoice->get_billing_data();
         if (self::render_and_attach_pdf($this->_invoice)) {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf created'));
         } else {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf creation failed') . ': ' . midcom_connection::get_error_string(), 'error');
         }
         return new midcom_response_relocate($this->_request_data["invoice_url"]);
     }
 }
Example #17
0
 function read_structure()
 {
     // Generate a safe name for the structure
     $structure_name = midcom_helper_misc::generate_urlname_from_string(midcom::get()->get_page_prefix());
     // Prepare structure
     $structure = array();
     $structure[$structure_name] = array();
     $structure[$structure_name]['name'] = $structure_name;
     $structure[$structure_name]['title'] = $GLOBALS['midcom_config']['midcom_site_title'];
     // Read the topic data
     $root_node = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ROOTTOPIC);
     $structure[$structure_name]['root'] = $this->read_node($root_node);
     file_put_contents("{$this->root_dir}{$structure_name}.inc", $this->_draw_array($structure));
 }
Example #18
0
 public function _handler_frontpage($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $selected_time = time();
     switch ($this->_config->get('start_view')) {
         case 'day':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . 'day/' . date('Y-m-d', $selected_time) . '/');
         case 'month':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . 'month/' . date('Y-m-d', $selected_time) . '/');
         default:
         case 'week':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . 'week/' . date('Y-m-d', $selected_time) . '/');
     }
 }
Example #19
0
 public function _update_breadcrumb($handler_id)
 {
     // Get common breadcrumb for the product
     $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_object);
     // Handler-based additions
     switch ($handler_id) {
         case 'edit_product':
             $breadcrumb[] = array(MIDCOM_NAV_URL => '', MIDCOM_NAV_NAME => sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get('product')));
             break;
         case 'delete_product':
             $breadcrumb[] = array(MIDCOM_NAV_URL => '', MIDCOM_NAV_NAME => sprintf($this->_l10n_midcom->get('delete %s'), $this->_l10n->get('product')));
             break;
     }
     midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb);
 }
Example #20
0
 public function get_row(midcom_core_dbaobject $invoice)
 {
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     $entry = array();
     $number = $invoice->get_label();
     $link_html = "<a href='{$prefix}invoice/{$invoice->guid}/'>" . $number . "</a>";
     if ($number == "") {
         $number = "n/a";
     }
     $entry['id'] = $invoice->id;
     $entry['index_number'] = $number;
     $entry['number'] = $link_html;
     if (!is_a($this->_customer, 'org_openpsa_contacts_group_dba')) {
         try {
             $customer = org_openpsa_contacts_group_dba::get_cached($invoice->customer);
             $entry['customer'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$customer->guid}/\">" . $customer->get_label() . "</a>";
         } catch (midcom_error $e) {
             $entry['customer'] = '';
         }
     }
     if (!is_a($this->_customer, 'org_openpsa_contacts_person_dba')) {
         try {
             $contact = org_openpsa_contacts_person_dba::get_cached($invoice->customerContact);
             $entry['contact'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$contact->guid}/\">" . $contact->get_label() . "</a>";
         } catch (midcom_error $e) {
             $entry['contact'] = '';
         }
     }
     if (!empty($this->_request_data['deliverable'])) {
         $constraints = array('invoice' => $invoice->id, 'deliverable' => $this->_request_data['deliverable']->id);
         $item_sum = org_openpsa_invoices_invoice_item_dba::get_sum($constraints);
         $this->_request_data['totals']['deliverable'] += $item_sum;
         $entry['index_item_sum'] = $item_sum;
         $entry['item_sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($item_sum / 100 * $invoice->vat + $item_sum) . '">' . org_openpsa_helpers::format_number($item_sum) . '</span>';
     }
     $entry['index_sum'] = $invoice->sum;
     $entry['sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($invoice->sum / 100 * $invoice->vat + $invoice->sum) . '">' . org_openpsa_helpers::format_number($invoice->sum) . '</span>';
     $entry['due'] = '';
     if ($invoice->due > 0) {
         $entry['due'] = strftime('%Y-%m-%d', $invoice->due);
     }
     $colname = 'action';
     if ($this->_list_type == 'paid') {
         $colname = 'paid';
     }
     $entry[$colname] = $this->_master->render_invoice_actions($invoice);
     return $entry;
 }
Example #21
0
 /**
  * This call renders a simple form without any formatting (that is to be
  * done by the callee) that asks the user for his username and password.
  *
  * The default should be quite useable through its CSS.
  *
  * If you want to replace the form by some custom style, you can define
  * the style- or page-element <i>midcom_services_auth_frontend_form</i>. If this
  * element is present, it will be shown instead of the default style
  * included in this function. In that case you should look into the source
  * of it to see exactly what is required.
  *
  * @link http://www.midgard-project.org/midcom-permalink-c5e99db3cfbb779f1108eff19d262a7c further information about how to style these elements.
  */
 function show_authentication_form()
 {
     // Store the submitted form if the session expired, but user wants to save the data
     if (count($_POST) > 0) {
         $data =& midcom_core_context::get()->get_custom_key('request_data');
         $data['restored_form_data'] = array();
         foreach ($_POST as $key => $value) {
             if (preg_match('/(username|password|frontend_form_submit)/', $key)) {
                 continue;
             }
             $data['restored_form_data'][$key] = base64_encode(serialize($value));
         }
         midcom::get('style')->data = array_merge(midcom::get('style')->data, $data);
     }
     midcom::get('style')->show_midcom('midcom_services_auth_frontend_form');
 }
Example #22
0
 public function _on_handle($handler_id, $args)
 {
     $this->_request_data['schemadb'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     // Add machine-readable RSS link
     midcom::get('head')->add_link_head(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => sprintf($this->_l10n->get('latest updates in %s'), $this->_topic->extra), 'href' => midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . 'rss.xml'));
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/net.nemein.wiki/wiki.css");
     if (midcom::get('auth')->user) {
         $user = midcom::get('auth')->user->get_storage();
         if ($this->_topic->parameter('net.nemein.wiki:watch', $user->guid)) {
             $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/index/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('unsubscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('unsubscribe' => 1, 'target' => 'folder')));
         } else {
             $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/index/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('subscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('subscribe' => 1, 'target' => 'folder')));
         }
     }
     $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "orphans/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('orphaned pages'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/editcut.png'));
 }
Example #23
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_interview($handler_id, array $args, array &$data)
 {
     $this->_member = new org_openpsa_directmarketing_campaign_member_dba($args[0]);
     $this->_member->require_do('midgard:update');
     $data['campaign'] = new org_openpsa_directmarketing_campaign_dba($this->_member->campaign);
     $data['controller'] = $this->get_controller('simple', $this->_member);
     switch ($data['controller']->process_form()) {
         case 'save':
             // Redirect to next interviewee
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "next/{$data['campaign']->guid}/");
         case 'cancel':
             // Clear lock and return to summary
             $this->_member->orgOpenpsaObtype = org_openpsa_directmarketing_campaign_member_dba::NORMAL;
             $this->_member->update();
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "campaign/{$data['campaign']->guid}/");
     }
 }
Example #24
0
 /**
  * Tags given object with the tags in the string
  *
  * Creates missing tags and tag_links, sets tag_link navorder
  * Deletes tag links from object that are not in the list provided
  *
  * @param object &$object MidCOM DBA object
  * @param array $tags List of tags and urls, tag is key, url is value
  * @return boolean indicating success/failure
  * @todo Set the link->navorder property
  */
 public static function tag_object(&$object, $tags, $component = null)
 {
     if (is_null($component)) {
         $component = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT);
     }
     $existing_tags = net_nemein_tag_handler::get_object_tags($object);
     if (!is_array($existing_tags)) {
         // Major failure when getting existing tags
         debug_add('get_object_tags() reported critical failure, aborting', MIDCOM_LOG_ERROR);
         return false;
     }
     // Determine operations
     $add_tags = array();
     $update_tags = array();
     $remove_tags = array();
     foreach ($tags as $tagname => $url) {
         if (empty($tagname)) {
             unset($tags[$tagname]);
             continue;
         }
         if (!array_key_exists($tagname, $existing_tags)) {
             $add_tags[$tagname] = $url;
         } else {
             if (!empty($url)) {
                 $update_tags[$tagname] = $url;
             }
         }
     }
     foreach ($existing_tags as $tagname => $url) {
         if (!array_key_exists($tagname, $tags)) {
             $remove_tags[$tagname] = true;
         }
     }
     // Excute
     foreach ($remove_tags as $tagname => $bool) {
         self::_remove_tag($tagname, $object->guid);
     }
     foreach ($update_tags as $tagname => $url) {
         self::_update_tag($tagname, $url, $object->guid);
     }
     foreach ($add_tags as $tagname => $url) {
         self::_create_tag($tagname, $url, $object, $component);
     }
     return true;
 }
Example #25
0
 /**
  * Looks up a product to display.
  *
  * @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_view($handler_id, array $args, array &$data)
 {
     if (preg_match('/_raw$/', $handler_id)) {
         midcom::get()->skip_page_style = true;
     }
     $this->_productlink = new org_openpsa_products_product_link_dba($args[0]);
     $data['controller'] = null;
     $data['datamanager'] = new midcom_helper_datamanager2_datamanager($data['schemadb_productlink']);
     if (!$data['datamanager']->autoset_storage($this->_productlink)) {
         throw new midcom_error("Failed to create a DM2 instance for productlink {$this->_productlink->guid}.");
     }
     $this->_prepare_request_data();
     $this->bind_view_to_object($this->_productlink, $data['datamanager']->schema->name);
     $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_productlink);
     midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb);
     midcom::get('metadata')->set_request_metadata($this->_productlink->metadata->revised, $this->_productlink->guid);
     //        midcom::get('head')->set_pagetitle($this->_request_data['view_title']);
 }
Example #26
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_navigation($handler_id, array $args, array &$data)
 {
     $current_topic = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_CONTENTTOPIC);
     $current_component = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_CONTENTTOPIC)->component;
     $root_topic = $current_topic;
     while ($root_topic->get_parent()->component == $current_component) {
         $root_topic = $root_topic->get_parent();
     }
     $this->_request_data['root_topic'] = $root_topic;
     $this->_request_data['current_topic'] = $current_topic;
     $qb = midcom_db_topic::new_query_builder();
     $qb->add_constraint("component", "=", $current_component);
     $qb->add_constraint("up", "INTREE", $root_topic->id);
     $document_topics = $qb->execute();
     $this->_request_data['topic_array'] = $document_topics;
     //This handler is supposed to be used with dynamic_load or AJAX, so skip page style
     midcom::get()->skip_page_style = true;
 }
Example #27
0
 public function test_request_sudo()
 {
     $auth = new midcom_services_auth();
     $auth->initialize();
     $context = midcom_core_context::get();
     $context->set_key(MIDCOM_CONTEXT_COMPONENT, 'midcom.admin.folder');
     $this->assertTrue($auth->request_sudo());
     $this->assertTrue($auth->is_component_sudo());
     $auth->drop_sudo();
     $this->assertFalse($auth->is_component_sudo());
     $this->assertFalse($auth->request_sudo(''));
     $this->assertFalse($auth->is_component_sudo());
     $this->assertTrue($auth->request_sudo('some_string'));
     $auth->drop_sudo();
     $GLOBALS['midcom_config']['auth_allow_sudo'] = false;
     $this->assertFalse($auth->request_sudo());
     $GLOBALS['midcom_config']['auth_allow_sudo'] = true;
 }
Example #28
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_create($handler_id, array $args, array &$data)
 {
     $data['directory']->require_do('midgard:create');
     $this->_load_create_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Index the directory
             $indexer = new org_openpsa_documents_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             // Relocate to the new directory view
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . $this->_request_data["directory"]->name . "/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_request_data['controller'] = $this->_controller;
     $this->add_breadcrumb("", $this->_l10n->get('new directory'));
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
 }
Example #29
0
 /**
  * Helper, updates the context so that we get a complete breadcrumb line towards the current
  * location.
  */
 private function _update_breadcrumb_line()
 {
     $tmp = array();
     if ($this->_group->up != 0) {
         $group = new org_openpsa_products_product_group_dba($this->_group->up);
         while ($group) {
             $parent = $group->get_parent();
             if ($group->get_parent() != null) {
                 $tmp[] = array(MIDCOM_NAV_URL => "{$parent->code}/{$group->code}", MIDCOM_NAV_NAME => $group->title);
             } else {
                 $tmp[] = array(MIDCOM_NAV_URL => "{$group->code}/", MIDCOM_NAV_NAME => $group->title);
             }
             $group = $parent;
         }
     }
     $tmp = array_reverse($tmp);
     $tmp[] = array(MIDCOM_NAV_URL => "{$this->_group->guid}/", MIDCOM_NAV_NAME => $this->_group->title);
     $tmp[] = array(MIDCOM_NAV_URL => "edit/{$this->_group->guid}/", MIDCOM_NAV_NAME => $this->_l10n_midcom->get('edit'));
     midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $tmp);
 }
Example #30
0
 public static function render_status_control($task)
 {
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     if ($task->status < org_openpsa_projects_task_status_dba::COMPLETED) {
         $action = 'complete';
         $checked = '';
     } else {
         if ($task->status == org_openpsa_projects_task_status_dba::COMPLETED) {
             $action = 'remove_complete';
         } else {
             $action = 'reopen';
         }
         $checked = ' checked="checked"';
     }
     $html = '<form method="post" action="' . $prefix . 'workflow/' . $task->guid . '/">';
     $html .= '<input type="hidden" name="org_openpsa_projects_workflow_action[' . $action . ']" value="true" />';
     $html .= '<input type="checkbox"' . $checked . ' name="org_openpsa_projects_workflow_dummy" value="true" onchange="this.form.submit()" />';
     $html .= '</form>';
     return $html;
 }