function quick_config_filter_activity(){ $this->setLayout('empty'); $submited_values = array_var($_POST, 'filter'); $members = array_var($_GET, 'members'); tpl_assign('members', array_var($_GET, 'members')); $member_name = lang('view'); $obj_member = Members::findById($members); if($obj_member){ $type_obj = ObjectTypes::findById($obj_member->getObjectTypeId()); if($obj_member){ $member_name = lang($type_obj->getName()); } } tpl_assign('dim_name', $member_name); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); if(!$filters){ $filters = ContactConfigOptions::getFilterActivity(); $filter_value = $filters->getDefaultValue(); tpl_assign('id', $filters->getId()); }else{ $filter_value = $filters->getValue(); tpl_assign('id', ''); } $filters_def = explode(",",$filter_value); // if($filters_def[0] == 1){ // tpl_assign('checked_dimension_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_dimension_no', 'checked="checked"'); // } if($filters_def[1] == 1){ tpl_assign('timeslot', 'checked="checked"'); }else{ tpl_assign('timeslot', ''); } tpl_assign('show', $filters_def[2]); // if($filters_def[3] == 1){ // tpl_assign('checked_view_downloads_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_view_downloads_no', 'checked="checked"'); // } if(is_array($submited_values)) { $members = array_var($submited_values,"members"); $new_value = array_var($submited_values,"dimension",0) . "," . array_var($submited_values,"timeslot",0) . "," . array_var($submited_values,"show",10). "," . array_var($submited_values,"view_downloads",0); $filters_default = ContactConfigOptions::getFilterActivity(); if(array_var($submited_values,"apply_everywhere") == 1){ $filters_default->setDefaultValue($new_value); $filters_default->save(); $filters = ContactConfigOptionValues::getFilterActivityDelete($filters_default->getId()); }else{ $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_'.logged_user()->getId().'_'.$filters_default->getName()."_".$members); } if(!$filters){ $filter_opt = new ContactConfigOptionValue(); $filter_opt->setOptionId($filters_default->getId()); $filter_opt->setContactId(logged_user()->getId()); $filter_opt->setValue($new_value); $filter_opt->setMemberId($members); $filter_opt->save(); }else{ $filters->setValue($new_value); $filters->save(); } evt_add("user preference changed", array('name' => $filters_default->getName()."_".$members, 'value' => $new_value)); } ajx_current("reload"); } }
function quick_config_filter_activity() { $this->setLayout('empty'); $submited_values = array_var($_POST, 'filter'); $members = array_var($_GET, 'members'); tpl_assign('members', array_var($_GET, 'members')); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(), $members); if (!$filters) { $filters = ContactConfigOptions::getFilterActivity(); $filter_value = $filters->getDefaultValue(); tpl_assign('id', $filters->getId()); } else { $filter_value = $filters->getValue(); } $filters_def = explode(",", $filter_value); if ($filters_def[0] == 1) { tpl_assign('checked_dimension_yes', 'checked="checked"'); } else { tpl_assign('checked_dimension_no', 'checked="checked"'); } if ($filters_def[1] == 1) { tpl_assign('checked_timeslot_yes', 'checked="checked"'); } else { tpl_assign('checked_timeslot_no', 'checked="checked"'); } tpl_assign('show', $filters_def[2]); if ($filters_def[3] == 1) { tpl_assign('checked_view_downloads_yes', 'checked="checked"'); } else { tpl_assign('checked_view_downloads_no', 'checked="checked"'); } if (is_array($submited_values)) { $members = array_var($submited_values, "members"); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(), $members); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_' . logged_user()->getId() . '_' . $filters_default->getName() . "_" . $members); } $new_value = array_var($submited_values, "dimension") . "," . array_var($submited_values, "timeslot") . "," . array_var($submited_values, "show") . "," . array_var($submited_values, "view_downloads"); if (!$filters) { $filter_opt = new ContactConfigOptionValue(); $filter_opt->setOptionId($filters_default->getId()); $filter_opt->setContactId(logged_user()->getId()); $filter_opt->setValue($new_value); $filter_opt->setMemberId($members); $filter_opt->save(); } else { $filters->setValue($new_value); $filters->save(); } evt_add("user preference changed", array('name' => $filters_default->getName() . "_" . $members, 'value' => $new_value)); redirect_to("index.php?c=dashboard&a=main_dashboard"); } }