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 getFilterActivityMember($id,$member) {
         return ContactConfigOptionValues::findOne(array('conditions' => array('`option_id` = ? AND `member_id` = ? AND `contact_id` = ?', $id, $member, logged_user()->getId())));
 }
 function do_delete()
 {
     $id = $this->getId();
     ContactAddresses::instance()->delete("`contact_id` = {$id}");
     ContactImValues::instance()->delete("`contact_id` = {$id}");
     ContactEmails::instance()->delete("`contact_id` = {$id}");
     ContactTelephones::instance()->delete("`contact_id` = {$id}");
     ContactWebpages::instance()->delete("`contact_id` = {$id}");
     ContactConfigOptionValues::instance()->delete("`contact_id` = {$id}");
     ContactPasswords::instance()->delete("`contact_id` = {$id}");
     ObjectSubscriptions::instance()->delete("`contact_id` = {$id}");
     ObjectReminders::instance()->delete("`contact_id` = {$id}");
     ContactPermissionGroups::instance()->delete("`contact_id` = {$id}");
     ContactMemberPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     ContactDimensionPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     SystemPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     TabPanelPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     $this->delete();
     $ret = null;
     Hook::fire("after_user_deleted", $this, $ret);
 }
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return  ContactConfigOptionValues 
  */
 function manager()
 {
     if (!$this->manager instanceof ContactConfigOptionValues) {
         $this->manager = ContactConfigOptionValues::instance();
     }
     return $this->manager;
 }
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'ContactConfigOptionValues')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return ContactConfigOptionValues::instance()->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
 /**
  * Set value  
  *
  */
 function setContactValue($new_value, $user_id = 0){
 	$val = ContactConfigOptionValues::findById(array('option_id' => $this->getId(), 'contact_id' => $user_id));
     if(!$val){
             // if value was not found, create it
             $val = new ContactConfigOptionValue();
             $val->setOptionId($this->getId());
             $val->setContactId($user_id);
     }
     $val->setValue($new_value);
     $val->save();
     $this->updateContactValueCache($user_id,$val->getValue());
 }
 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");
     }
 }
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return  ContactConfigOptionValues 
 */
 function manager() {
   if(!($this->manager instanceof ContactConfigOptionValues )) $this->manager =  ContactConfigOptionValues::instance();
   return $this->manager;
 } // manager