예제 #1
0
 /**
  * get marker coordinates
  */
 public function getmarkersTask()
 {
     $checked = Request::getVar('checked', array(), 'request');
     $tags = trim(Request::getString('tags', '', 'request'));
     $resources = Request::get('resources', array());
     $filters = array();
     $filters['scope'] = $resources;
     // get markers object
     $GM = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
     echo $GM->getMarkers($filters);
     exit;
 }
예제 #2
0
 /**
  * populate the geosearch markers table
  *
  * @param	 object	 $job	\Components\Cron\Models\Job
  * @return	boolean
  */
 public function getLocationData(\Components\Cron\Models\Job $job)
 {
     //setup database object
     $this->database = App::get('db');
     //get the relevant tables
     require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'profile.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_geosearch' . DS . 'tables' . DS . 'geosearchmarkers.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_jobs' . DS . 'tables' . DS . 'job.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'tables' . DS . 'event.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'organization.php';
     // get current markers
     $markers = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
     $markers = $markers->getMarkers(array(), 'array');
     // user profiles
     $objProfile = new \Components\Members\Tables\Profile($this->database);
     $profiles = $objProfile->selectWhere('uidNumber', 'public=1');
     // jobs
     $objJob = new \Components\Jobs\Tables\Job($this->database);
     $jobs = $objJob->get_openings();
     // events
     $objEvents = new \Components\Events\Tables\Event($this->database);
     $events = $objEvents->getEvents('year', array('year' => date('Y'), 'category' => 0));
     // organizations
     $objOrganizations = new \Components\Members\Tables\Organization($this->database);
     $organizations = $objOrganizations->find('all');
     if (count($markers) > 0) {
         //separate by scope
         $existingMarkers = $this->_separatebyScope($markers);
         //unique entries
         foreach ($existingMarkers as $class => &$existing) {
             switch ($class) {
                 case 'markerJobIDs':
                     $identifier = 'code';
                     $all = $jobs;
                     break;
                 case 'markerMemberIDs':
                     $identifier = 'uidNumber';
                     $all = $profiles;
                     break;
                 case 'markerEventIDs':
                     $identifier = 'id';
                     $all = $events;
                     break;
                 case 'markerOrganizationIDs':
                     $identifier = 'id';
                     $all = $organizations;
                     break;
                 default:
                     $identifier = '';
                     $all = array();
                     break;
             }
             //end switch
             if ($identifier != '' && count($all) > 0) {
                 //var_dump($all);
                 $existing = $this->_distill($existing, $all, $identifier);
             }
         }
         $markerMemberIDs = $this->_scopify($existingMarkers['markerMemberIDs'], 'member');
         $markerJobIDs = $this->_scopify($existingMarkers['markerJobIDs'], 'job');
         $markerEventIDs = $this->_scopify($existingMarkers['markerEventIDs'], 'event');
         $markerOrganizationIDs = $this->_scopify($existingMarkers['markerOrganizationIDs'], 'organization');
     } elseif (count($markers) == 0) {
         $markerMemberIDs = array();
         $markerJobIDs = array();
         $markerEventIDs = array();
         $markerOrganizationIDs = array();
         foreach ($profiles as $profile) {
             $obj = array();
             $obj['scope'] = 'member';
             $obj['scope_id'] = $profile->uidNumber;
             array_push($markerMemberIDs, $obj);
         }
         foreach ($jobs as $job) {
             $obj = array();
             $obj['scope'] = 'job';
             $obj['scope_id'] = $job->code;
             array_push($markerJobIDs, $obj);
         }
         foreach ($events as $event) {
             $obj = array();
             $obj['scope'] = 'event';
             $obj['scope_id'] = $event->id;
             array_push($markerEventIDs, $obj);
         }
         foreach ($organizations as $organization) {
             $obj = array();
             $obj['scope'] = 'organization';
             $obj['scope_id'] = $organization->id;
             array_push($markerEventIDs, $obj);
         }
     }
     //merge into one array
     $newMarkers = $this->_merger($markerMemberIDs, $markerJobIDs, $markerEventIDs, $markerOrganizationIDs);
     $creations = $this->_doGeocode($newMarkers, $objProfile, $objJob, $objEvents, $objOrganizations);
     foreach ($creations as $creation) {
         $m = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
         $m->addressLatitude = $creation->location->getLatitude();
         $m->addressLongitude = $creation->location->getLongitude();
         $m->scope_id = $creation->scope_id;
         $m->scope = $creation->scope;
         $m->store(true);
     }
     return true;
 }