Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * Display a list of jobs
  *
  * @apiMethod GET
  * @apiUri    /jobs/job
  * @apiParameter {
  * 		"name":          "jobcode",
  * 		"description":   "The job code associated with the opening",
  * 		"type":          "integer",
  * 		"required":      true,
  * 		"default":       ""
  * }
  *
  * @return  void
  */
 public function jobTask()
 {
     $jobCode = Request::getInt('jobcode');
     $database = \App::get('db');
     $obj = new \Components\Jobs\Tables\Job($database);
     $filters = array();
     $job = $obj->get_opening($jid = NULL, $uid = NULL, $admin = NULL, $jobcode = $jobCode);
     // Create object with records property
     $response = new stdClass();
     $response->job = $job;
     // Return object
     $this->send($response);
 }