Exemple #1
0
 /**
  * Shows the loaded message.
  */
 public function _show_list($handler_id, array &$data)
 {
     $qb = new org_openpsa_qbpager('org_openpsa_directmarketing_campaign_message_dba', 'campaign_messages');
     $qb->results_per_page = 10;
     $qb->add_order('metadata.created', 'DESC');
     $qb->add_constraint('campaign', '=', $this->_campaign->id);
     $ret = $qb->execute();
     $data['qbpager'] =& $qb;
     midcom_show_style("show-message-list-header");
     if (count($ret) > 0) {
         foreach ($ret as $message) {
             $this->_datamanager->autoset_storage($message);
             $data['message'] =& $message;
             $data['message_array'] = $this->_datamanager->get_content_html();
             $data['message_class'] = org_openpsa_directmarketing_viewer::get_messagetype_css_class($message->orgOpenpsaObtype);
             midcom_show_style('show-message-list-item');
         }
     }
     midcom_show_style("show-message-list-footer");
 }
Exemple #2
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_action($handler_id, array &$data)
 {
     switch ($this->_view) {
         case "area_group_members":
             // This is most likely a dynamic_load
             $qb = new org_openpsa_qbpager('midcom_db_member', 'group_members');
             $qb->add_constraint('gid', '=', $this->_request_data['group']->id);
             $qb->results_per_page = 10;
             $results = $qb->execute();
             $this->_request_data['members_qb'] =& $qb;
             if (count($results) > 0) {
                 midcom_show_style("show-group-persons-header");
                 foreach ($results as $member) {
                     $this->_request_data['member'] = $member;
                     if ($member->extra == "") {
                         $member->extra = $this->_l10n->get('<title>');
                     }
                     $this->_request_data['member_title'] = $member->extra;
                     $this->_request_data['person'] = new org_openpsa_contacts_person_dba($member->uid);
                     midcom_show_style("show-group-persons-item");
                 }
                 midcom_show_style("show-group-persons-footer");
             }
             break;
         case "area_group_subgroups":
             $qb = org_openpsa_contacts_group_dba::new_query_builder();
             $qb->add_constraint('owner', '=', $this->_request_data['group']->id);
             $results = $qb->execute();
             if (count($results) > 0) {
                 midcom_show_style("show-group-subgroups-header");
                 foreach ($results as $subgroup) {
                     $this->_request_data['subgroup'] = $subgroup;
                     midcom_show_style("show-group-subgroups-item");
                 }
                 midcom_show_style("show-group-subgroups-footer");
             }
             break;
     }
 }
Exemple #3
0
 private function _list_group_products()
 {
     $product_qb = new org_openpsa_qbpager('org_openpsa_products_product_dba', 'org_openpsa_products_product_dba');
     $product_qb->results_per_page = $this->_config->get('products_per_page');
     if (count($this->_request_data['linked_products']) > 0) {
         $product_qb->begin_group('OR');
     }
     if ($this->_request_data['group'] && $this->_request_data['group']->orgOpenpsaObtype == org_openpsa_products_product_group_dba::TYPE_SMART) {
         // Smart group, query products by stored constraints
         $constraints = $this->_request_data['group']->list_parameters('org.openpsa.products:constraints');
         if (empty($constraints)) {
             $product_qb->add_constraint('productGroup', '=', $this->_request_data['parent_group']);
         }
         $reflector = new midgard_reflection_property('org_openpsa_products_product');
         foreach ($constraints as $constraint_string) {
             $constraint_members = explode(',', $constraint_string);
             if (count($constraint_members) != 3) {
                 throw new midcom_error("Invalid constraint '{$constraint_string}'");
             }
             // Reflection is needed here for safety
             $field_type = $reflector->get_midgard_type($constraint_members[0]);
             switch ($field_type) {
                 case 4:
                     throw new midcom_error("Invalid constraint: '{$constraint_members[0]}' is not a Midgard property");
                 case MGD_TYPE_INT:
                     $constraint_members[2] = (int) $constraint_members[2];
                     break;
                 case MGD_TYPE_FLOAT:
                     $constraint_members[2] = (double) $constraint_members[2];
                     break;
                 case MGD_TYPE_BOOLEAN:
                     $constraint_members[2] = (bool) $constraint_members[2];
                     break;
             }
             $product_qb->add_constraint($constraint_members[0], $constraint_members[1], $constraint_members[2]);
         }
     } else {
         if ($this->_request_data['handler_id'] == 'list_intree') {
             $product_qb->add_constraint('productGroup', '=', $this->_request_data['parent_category_id']);
         } else {
             if ($this->_request_data['handler_id'] == 'listall') {
                 $categories_qb = org_openpsa_products_product_group_dba::new_query_builder();
                 $categories_qb->add_constraint('up', '=', $this->_request_data['group']->id);
                 $categories = $categories_qb->execute();
                 for ($i = 0; $i < count($categories); $i++) {
                     $categories_in[$i] = $categories[$i]->id;
                 }
                 $product_qb->add_constraint('productGroup', 'IN', $categories_in);
             } else {
                 $product_qb->add_constraint('productGroup', '=', $this->_request_data['parent_group']);
             }
         }
     }
     if (count($this->_request_data['linked_products']) > 0) {
         $product_qb->add_constraint('id', 'IN', $this->_request_data['linked_products']);
         $product_qb->end_group();
     }
     // This should be a helper function, same functionality, but with different config-parameter is used in /handler/product/search.php
     foreach ($this->_config->get('products_listing_order') as $ordering) {
         $this->_add_ordering($product_qb, $ordering);
     }
     if ($this->_config->get('enable_scheduling')) {
         $product_qb->add_constraint('start', '<=', time());
         $product_qb->begin_group('OR');
         /*
          * List products that either have no defined end-of-market dates
          * or are still in market
          */
         $product_qb->add_constraint('end', '=', 0);
         $product_qb->add_constraint('end', '>=', time());
         $product_qb->end_group();
     }
     $this->_request_data['products'] = $product_qb->execute();
     $this->_request_data['products_qb'] =& $product_qb;
 }
Exemple #4
0
 private function _list_products($limit = 5, $product_group = '')
 {
     $product_qb = new org_openpsa_qbpager('org_openpsa_products_product_dba', 'latest_products');
     $this->_request_data['product_qb'] =& $product_qb;
     $product_qb->results_per_page = $limit;
     $product_qb->set_limit($limit);
     $product_qb->add_order('metadata.published', 'DESC');
     if ($product_group != '') {
         $group_qb = org_openpsa_products_product_group_dba::new_query_builder();
         $group_qb->add_constraint('code', '=', $product_group);
         $groups = $group_qb->execute();
         if (count($groups) == 0) {
             return false;
             // No matching group
         } else {
             $categories_qb = org_openpsa_products_product_group_dba::new_query_builder();
             $categories_qb->add_constraint('up', '=', $groups[0]->id);
             $categories = $categories_qb->execute();
             $categories_in = array();
             if (count($categories) == 0) {
                 /* No matching categories belonging to this group
                  * So we can search for the application using only
                  * this group id
                  */
                 $product_qb->add_constraint('productGroup', 'INTREE', $groups[0]->id);
             } else {
                 for ($i = 0; $i < count($categories); $i++) {
                     $categories_in[$i] = $categories[$i]->id;
                 }
                 $product_qb->add_constraint('productGroup', 'IN', $categories_in);
             }
         }
     }
     if ($this->_config->get('enable_scheduling')) {
         $product_qb->add_constraint('start', '<=', time());
         $product_qb->begin_group('OR');
         /*
          * List products that either have no defined end-of-market dates
          * or are still in market
          */
         $product_qb->add_constraint('end', '=', 0);
         $product_qb->add_constraint('end', '>=', time());
         $product_qb->end_group();
     }
     $this->_request_data['products'] = $product_qb->execute();
     $this->_request_data['product_group'] = $product_group;
 }
Exemple #5
0
 /**
  * Search products using Midgard 1.8+ Query Builder
  */
 private function _qb_search($constraints)
 {
     $qb = new org_openpsa_qbpager('org_openpsa_products_product_dba', 'org_openpsa_products_product_dba');
     $qb->results_per_page = $this->_config->get('products_per_page');
     // Check that the object has correct schema
     $mc = new midgard_collector('midgard_parameter', 'domain', 'midcom.helper.datamanager2');
     $mc->set_key_property('parentguid');
     $mc->add_constraint('name', '=', 'schema_name');
     $mc->add_constraint('value', '=', $this->_request_data['search_schema']);
     $mc->execute();
     $keys = $mc->list_keys();
     if (!empty($keys)) {
         $qb->add_constraint('guid', 'IN', array_keys($keys));
     }
     unset($mc, $keys);
     if ($this->_request_data['search_type'] == 'OR') {
         $qb->begin_group('OR');
     }
     foreach ($constraints as $constraint) {
         $storage = $this->_request_data['schemadb_product'][$this->_request_data['search_schema']]->fields[$constraint['property']]['storage'];
         debug_print_r('constraint', $constraint);
         debug_print_r('storage', $storage);
         if (!is_array($storage) || preg_match('/^%+$/', $constraint['value'])) {
             continue;
         }
         if ($storage['location'] == 'parameter' || $storage['location'] == 'configuration') {
             $mc = new midgard_collector('midgard_parameter', 'domain', $storage['domain']);
             $mc->set_key_property('parentguid');
             $mc->add_constraint('name', '=', $constraint['property']);
             $mc->add_constraint('value', $constraint['constraint'], $constraint['value']);
             $mc->execute();
             $keys = $mc->list_keys();
             if (!empty($keys)) {
                 $qb->add_constraint('guid', 'IN', array_keys($keys));
             }
             unset($mc, $keys);
         } else {
             // Simple field storage
             if (is_numeric($constraint['value'])) {
                 // TODO: When 1.8.4 becomes more common we can reflect this instead
                 $constraint['value'] = (int) $constraint['value'];
             }
             $qb->add_constraint($storage['location'], $constraint['constraint'], $constraint['value']);
         }
     }
     if ($this->_request_data['search_type'] == 'OR') {
         $qb->end_group();
     }
     foreach ($this->_config->get('search_index_order') as $ordering) {
         $this->_add_ordering($qb, $ordering);
     }
     $ret = $qb->execute();
     /* FIXME: It this the right way to do this? */
     $this->_request_data['search_qb'] =& $qb;
     // Check schemas this way until the core issue is fixed
     foreach ($ret as $k => $product) {
         $schema = $product->get_parameter('midcom.helper.datamanager2', 'schema_name');
         debug_add("product schema '{$schema}' vs desired schema '{$this->_request_data['search_schema']}'");
         if ($schema == $this->_request_data['search_schema']) {
             continue;
         }
         unset($ret[$k]);
     }
     // array_merge reindexes the array to be continous
     return array_merge($ret);
 }
Exemple #6
0
 public function _handler_viewActivity($handler_id, $args, &$data)
 {
     $status = parent::_handler_read($handler_id, $args, $data);
     if ($_MIDGARD['user'] == $this->_person->id) {
         $this->_component_data['active_leaf'] = "own_details";
     }
     $qb_latest = new org_openpsa_qbpager('midcom_helper_activitystream_activity_dba', 'activity');
     $qb_latest->add_order('metadata.revised', 'DESC');
     $qb_latest->add_constraint('actor', '=', $this->_object->id);
     $qb_latest->set_limit($this->_config->get('activity_results_per_page'));
     $qb_latest->results_per_page = $this->_config->get('activity_results_per_page');
     $latest = $qb_latest->execute();
     $this->_request_data['qb'] = $qb_latest;
     $this->_request_data['items'] = $latest;
     return $status;
 }
Exemple #7
0
 /**
  *
  * @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.
  */
 function _handler_moderate($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     if (!$this->_topic->can_do('net.nehmer.comments:moderation')) {
         return new midcom_response_relocate('/');
     }
     // This might exit.
     $this->_process_admintoolbar();
     $view_status = array();
     $this->_request_data['handler'] = $args[0];
     switch ($args[0]) {
         case 'reported_abuse':
             $this->_request_data['status_to_show'] = 'reported abuse';
             $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             break;
         case 'abuse':
             $this->_request_data['status_to_show'] = 'abuse';
             $view_status[] = net_nehmer_comments_comment::ABUSE;
             break;
         case 'junk':
             $this->_request_data['status_to_show'] = 'junk';
             $view_status[] = net_nehmer_comments_comment::JUNK;
             break;
         case 'latest':
             $this->_request_data['status_to_show'] = 'latest comments';
             $view_status[] = net_nehmer_comments_comment::NEW_ANONYMOUS;
             $view_status[] = net_nehmer_comments_comment::NEW_USER;
             $view_status[] = net_nehmer_comments_comment::MODERATED;
             if ($this->_config->get('show_reported_abuse_as_normal')) {
                 $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             }
             break;
         case 'latest_new':
             $this->_request_data['status_to_show'] = 'latest comments, only new';
             $view_status[] = net_nehmer_comments_comment::NEW_ANONYMOUS;
             $view_status[] = net_nehmer_comments_comment::NEW_USER;
             if ($this->_config->get('show_reported_abuse_as_normal')) {
                 $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             }
             break;
         case 'latest_approved':
             $this->_request_data['status_to_show'] = 'latest comments, only approved';
             $view_status[] = net_nehmer_comments_comment::MODERATED;
             break;
     }
     $qb = new org_openpsa_qbpager('net_nehmer_comments_comment', 'net_nehmer_comments_comments');
     $qb->results_per_page = $this->_config->get('items_to_show');
     $qb->display_pages = $this->_config->get('paging');
     $qb->add_constraint('status', 'IN', $view_status);
     $qb->add_order('metadata.revised', 'DESC');
     $this->_comments = $qb->execute();
     if ($this->_comments) {
         $this->_init_display_datamanager();
     }
     net_nehmer_comments_viewer::add_head_elements();
     $this->_prepare_request_data();
     $this->add_breadcrumb('', $this->_l10n->get($data['status_to_show']));
 }
Exemple #8
0
 /**
  * The handler for the index article.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_open($handler_id, $args, &$data)
 {
     $_MIDCOM->auth->require_valid_user();
     $this->_request_data['name'] = "fi.kilonkipinat.todos";
     $this->_component_data['active_leaf'] = "{$this->_topic->id}_LIST_OPEN";
     $this->_update_breadcrumb_line($handler_id);
     $title = 'Nakit';
     $_MIDCOM->set_pagetitle(":: {$title}");
     $qb = new org_openpsa_qbpager('fi_kilonkipinat_todos_todoitem_dba', 'fi_kilonkipinat_todos_list_my');
     $qb->add_constraint('person', '=', 0);
     $qb->add_constraint('grp', '=', 0);
     $qb->add_constraint('status', '<', FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_ACKNOWLEDGED);
     $qb->add_order('deadline', 'ASC');
     if ($handler_id == 'list_open_count') {
         $qb->results_per_page = $args[0];
     } else {
         $qb->results_per_page = $this->_config->get('index_entries');
     }
     $data['todoitems'] = $qb->execute();
     $data['qb'] = $qb;
     $data['handler_id'] = $handler_id;
     return true;
 }
Exemple #9
0
 private function _list_group_products()
 {
     $product_qb = new org_openpsa_qbpager('org_openpsa_products_product_dba', 'org_openpsa_products_product_dba');
     $product_qb->results_per_page = $this->_config->get('products_per_page');
     $product_qb->add_constraint('productGroup', '=', $this->_request_data['parent_group']);
     // This should be a helper function, same functionality, but with different config-parameter is used in /handler/product/search.php
     foreach ($this->_config->get('products_listing_order') as $ordering) {
         $this->_add_ordering($product_qb, $ordering);
     }
     if ($this->_config->get('enable_scheduling')) {
         /*
          * List products that either have no defined end-of-market dates
          * or are still in market
          */
         $product_qb->add_constraint('start', '<=', time());
         $product_qb->begin_group('OR');
         $product_qb->add_constraint('end', '=', 0);
         $product_qb->add_constraint('end', '>=', time());
         $product_qb->end_group();
     }
     $this->_request_data['products'] = $product_qb->execute();
     $this->_request_data['products_qb'] =& $product_qb;
 }