/** * Prepare todoitem listing query builder that takes all configured filters into account * * @access static */ static function prepare_todoitem_qb(&$data, &$config) { // Load filters $filters = fi_kilonkipinat_todos_viewer::prepare_filters($config); $qb = $data['qb']; // Add filtering constraint if (isset($filters['filter_category'])) { $qb->add_constraint('category', 'LIKE', '%|' . $filters['filter_category'] . '|%'); } // Add filtering constraint if (isset($filters['filter_person'])) { $qb->add_constraint('person', 'IN', $filters['filter_person']); } // Add filtering constraint if (isset($filters['filter_supervisor'])) { $qb->add_constraint('supervisor', 'IN', $filters['filter_supervisor']); } // Add filtering constraint if (isset($filters['filter_group'])) { $qb->add_constraint('grp', 'IN', $filters['filter_group']); } // Add filtering constraint if (isset($filters['filter_event'])) { $qb->add_constraint('event', 'IN', $filters['filter_event']); } // Add filtering constraint if (isset($filters['filter_status'])) { $qb->add_constraint('status', 'IN', $filters['filter_status']); } else { $status_list = array(FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_NEW, FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_PENDING, FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_ACKNOWLEDGED); $qb->add_constraint('status', 'IN', $status_list); } if (isset($filters['other'])) { // Handle other direct field mapping constraints foreach ($filters['other'] as $field => $filter) { $qb->add_constraint($field, '=', $filter); } } // Handle category filter if (isset($filters['category_filter'])) { $qb->add_constraint('category', 'LIKE', "%|{$filters['category_filter']}|%"); } return $filters; }
<ul class="midcom_toolbar"> <li class="enabled"> <a href="/extranet/nakit/edit_todo/<?php echo $todo->guid; ?> /"> <img alt="" src="/midcom-static/stock-icons/16x16/edit.png"> <span class="toolbar_label">Muokkaa</span> </a> </li> <?php $can_edit = false; $can_supervise = false; if ($todo->supervisor == $_MIDGARD['user']) { $can_supervise = true; } if ($todo->person == $_MIDGARD['user'] || fi_kilonkipinat_todos_viewer::isInMyGroups($todo->grp) || $todo->grp == 0 && $todo->person == 0) { $can_edit = true; } if ($can_edit) { if ($todo->status == FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_NEW || $todo->status == FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_PENDING) { ?> <li class="enabled"> <a href="#" onclick="jQuery.application.changeTodoStatus('acknowledged', '<?php echo $todo->guid; ?> '); return false;"> <img alt="" src="/midcom-static/stock-icons/16x16/edit.png"> <span class="toolbar_label">Vastaanota</span> </a> </li> <?php }
/** * 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_all($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_ALL"; $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'); $data['qb'] = $qb; $data['filters'] = fi_kilonkipinat_todos_viewer::prepare_todoitem_qb($data, $this->_config); $data['qb']->begin_group('OR'); $data['qb']->add_constraint('visibility', '=', FI_KILONKIPINAT_TODOS_TODOITEM_VISIBILITY_PUBLIC); $data['qb']->add_constraint('person', '=', $_MIDGARD['user']); $data['qb']->add_constraint('supervisor', '=', $_MIDGARD['user']); $data['qb']->end_group(); $data['qb']->add_order('status'); $data['qb']->add_order('deadline'); if ($handler_id == 'list_all_count') { $data['qb']->results_per_page = $args[0]; } elseif (isset($data['filters']['filter_limit'])) { $data['qb']->results_per_page = (int) $data['filters']['filter_limit']; } else { $data['qb']->results_per_page = $this->_config->get('index_entries'); } $data['todoitems'] = $data['qb']->execute(); $data['handler_id'] = $handler_id; $persons = array(); $root_group = new midcom_db_group($this->_config->get('root_group_to_show')); $person_ids = array(); $mc_groups = midcom_db_member::new_collector('sitegroup', $_MIDGARD['sitegroup']); $mc_groups->add_constraint('gid', '=', $root_group->id); $mc_groups->add_value_property('uid'); $mc_groups->execute(); $tmp_keys = $mc_groups->list_keys(); foreach ($tmp_keys as $guid => $tmp_key) { $person_id = $mc_groups->get_subkey($guid, 'uid'); $person_ids[$person_id] = $person_id; } $mc_persons = fi_kilonkipinat_account_person_dba::new_collector('sitegroup', $_MIDGARD['sitegroup']); $mc_persons->add_constraint('id', 'IN', $person_ids); $mc_persons->add_value_property('id'); $mc_persons->add_value_property('nickname'); $mc_persons->add_value_property('firstname'); $mc_persons->add_value_property('lastname'); $mc_persons->execute(); $tmp_persons = $mc_persons->list_keys(); foreach ($tmp_persons as $guid => $tmp_key) { $persons[] = array('id' => $mc_persons->get_subkey($guid, 'id'), 'nickname' => $mc_persons->get_subkey($guid, 'nickname'), 'firstname' => $mc_persons->get_subkey($guid, 'firstname'), 'lastname' => $mc_persons->get_subkey($guid, 'lastname')); } $data['persons'] = $persons; return true; }