示例#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;
 }
示例#2
0
 /**
  * Display a list of jobs
  *
  * @apiMethod GET
  * @apiUri    /jobs/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "name",
  * 		"allowedValues": "name, id"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return  void
  */
 public function listTask()
 {
     // get POST data
     $filters = array();
     $filters['limit'] = Request::getInt('limit', 25);
     $filters['start'] = Request::getInt('start', 0);
     $filters['search'] = Request::getVar('search', "");
     $filters['sort'] = Request::getVar('sort', "name");
     $filters['sort_dir'] = Request::getCmd('sort_Dir', "desc");
     $database = \App::get('db');
     $obj = new \Components\Jobs\Tables\Job($database);
     $jobs = $obj->get_openings($filters);
     // Create object with records property
     $response = new stdClass();
     $response->jobs = $jobs;
     // Return object
     $this->send($response);
 }