Example #1
0
 /**
  *	@fn attribute_visits
  *	@short Action method to attribute a visit to a person.
  *	@details This method is designed to be called with AJAX, and does not render anything.
  *	It assigns a visit object to a person object.
  */
 public function attribute_visits()
 {
     $conn = Db::get_connection();
     $visit_factory = new Visit();
     $visits = $visit_factory->find_all(array('where_clause' => "`date` >= '{$conn->escape(date("Y-m-d H:i:s", Time::ago(@$_REQUEST['t'])))}' " . "AND (`ip_addr` = '{$conn->escape(@$_REQUEST['ip'])}' " . "OR `params` LIKE '%Apache'' => ''{$conn->escape(@$_REQUEST['ip'])}%')"));
     if (count($visits) > 0) {
         foreach ($visits as $visit) {
             $visit->person_id = @$_REQUEST['person_id'];
             $visit->save();
         }
     }
     Db::close_connection($conn);
     $this->render(NULL);
 }