static function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $location = new Location();
     $location->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $location->libraryId = $homeLibrary->libraryId;
     }
     $location->find();
     $locationList = array();
     while ($location->fetch()) {
         $locationList[$location->locationId] = $location->displayName;
     }
     require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php';
     $browseCategories = new BrowseCategory();
     $browseCategories->orderBy('label');
     $browseCategories->find();
     $browseCategoryList = array();
     while ($browseCategories->fetch()) {
         $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})";
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'locationId' => array('property' => 'locationId', 'type' => 'enum', 'values' => $locationList, 'label' => 'Location', 'description' => 'A link to the location which the browse category belongs to'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget.  Lower weights are displayed to the left of the screen.', 'required' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 public function add()
 {
     $location = new LocationForm();
     $form = $location->form();
     if ($this->request->isPost()) {
         $form->setFieldValues($this->request->getPost());
         if ($form->isValid()) {
             $country_name = $this->request->getPost('lace-country-name');
             //get country
             $country_iso3 = $this->request->getPost('lace-country-iso3');
             //get iso3
             $country_iso2 = $this->request->getPost('lace-country-iso2');
             //get iso2
             $post_code = $this->request->getPost('lace-postcode');
             //get post code
             $enabled = $this->request->getPost('lace-enabled');
             //get enabled
             $location = new Location();
             $location->save(['name' => $country_name, 'iso_code_3' => $country_iso3, 'iso_code_2' => $country_iso2, 'postcode_required' => isset($post_code) ? $post_code : 0, 'status' => isset($enabled) ? $enabled : 0]);
             //redirect to country
             $this->session->setRequestValue('success', 'Country Successfully Added', 1);
             $this->response->redirect($this->request->getBasePath() . '/' . $this->request->getPath(0) . '/locations');
         }
     }
     $this->setView('location/add_country');
     $this->view->title = 'Add Location';
     $this->view->form = $form;
     $this->response->setBody($this->view->render());
     $this->response->send();
 }
Beispiel #3
0
 /**
  * Upload an image via form-data.
  * Allowed only .jpg format.
  *
  * Optional parameters: (lat, lon), tag, description.
  */
 function index_post()
 {
     header('Access-Control-Allow-Origin: *');
     if (!isset($_FILES['image'])) {
         $this->response(error('Provide \'image\' parameter.', 400), 400);
         return;
     }
     $imageBytes = $_FILES['image'];
     $imageDescription = $this->post('description');
     $lat = $this->post('lat');
     $lon = $this->post('lon');
     $location = null;
     if ($lat != null && $lon != null) {
         $location = new Location();
         $location->setLat((double) $lat);
         $location->setLon((double) $lon);
     }
     $tagValue = $this->post('tag');
     $tag = null;
     if ($tagValue != null) {
         $tag = new Tag();
         $tag->setValue($tagValue);
     }
     $imageModel = new ImageModel($this->db);
     try {
         $image = $imageModel->createImage($imageBytes, $imageDescription, $tag, $location);
         $this->response($image->serialize(), 201);
     } catch (ImageAlreadyExistsException $e) {
         $this->response(error('Image already exists.', 409), 409);
     } catch (InvalidImageExtensionException $e) {
         $this->response(error('Invalid image extension. Allowed only .jpg.', 400), 400);
     }
 }
 public function isTFTP()
 {
     $Location = new Location($this->get('locationID'));
     if ($Location && $Location->isValid()) {
         return $Location->get('tftp');
     }
 }
 /**
  * @test
  */
 public function RegexpRuleResultAssignTest()
 {
     global $DB, $PF_CONFIG;
     $DB->connect();
     $rule = new Rule();
     $location = new Location();
     $input = array('name' => 'Monsols04', 'entities_id' => 0);
     $location->add($input);
     $input = array('is_active' => 1, 'name' => 'Location regexp', 'match' => 'AND', 'sub_type' => 'PluginFusioninventoryInventoryRuleLocation', 'ranking' => 1);
     $rules_id = $rule->add($input);
     // Add criteria
     $rulecriteria = new RuleCriteria();
     $input = array('rules_id' => $rules_id, 'criteria' => "name", 'pattern' => "/computer (.*)/", 'condition' => PluginFusioninventoryInventoryRuleLocation::REGEX_MATCH);
     $rulecriteria->add($input);
     // Add action
     $ruleaction = new RuleAction();
     $input = array('rules_id' => $rules_id, 'action_type' => 'assign', 'field' => 'locations_id', 'value' => 1);
     $ruleaction->add($input);
     $input = array('name' => 'computer Monsols04');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $ruleLocation = new PluginFusioninventoryInventoryRuleLocationCollection();
     $ruleLocation->getCollectionPart();
     $loc = $ruleLocation->processAllRules($input, array());
     $a_references = array('locations_id' => 1, '_ruleid' => 50);
     $this->assertEquals($a_references, $loc, 'Location result assign_result');
     $rule->delete(array('id' => $rules_id), True);
 }
 public function departureBoard(Location $location)
 {
     $url = $this->config->getRejseplanenBaseUrl() . '/departureBoard?id=' . urlencode($location->getId());
     $xml = file_get_contents($url);
     // file_put_contents('/tmp/data', $xml."\n");
     return $this->responseFactory->getDepartureBoardResponse($xml);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('locations')->truncate();
     $locationClusterCmb = new Location();
     $locationClusterCmb->code = "CLS_001";
     $locationClusterCmb->name = "Colombo";
     $locationClusterCmb->location_type_id = 1;
     $locationClusterCmb->parent_location_id = 0;
     $locationClusterCmb->save();
     $locationRegMah = new Location();
     $locationRegMah->code = "REG_001";
     $locationRegMah->name = "Maharagama";
     $locationRegMah->location_type_id = 2;
     $locationRegMah->parent_location_id = $locationClusterCmb->id;
     $locationRegMah->save();
     $locationRegG5 = new Location();
     $locationRegG5->code = "REG_002";
     $locationRegG5->name = "Gampaha";
     $locationRegG5->location_type_id = 2;
     $locationRegG5->parent_location_id = $locationClusterCmb->id;
     $locationRegG5->save();
     $locationTmpNug = new Location();
     $locationTmpNug->code = "TMP_001";
     $locationTmpNug->name = "Nugegoda";
     $locationTmpNug->location_type_id = 3;
     $locationTmpNug->parent_location_id = $locationRegMah->id;
     $locationTmpNug->save();
 }
 public function getCountryList()
 {
     /* Start here set the country list */
     App::import("Model", "Location");
     $location = new Location();
     $options = array('fields' => array('Location.county_name'));
     return $getLocationArray = $location->find('list', $options);
 }
 /**
  * @param \Sitemapper\Url $url
  */
 public function addLocation(Location $location)
 {
     $node = $this->root->appendChild($this->doc->createElement(static::URL_NODE_NAME));
     $node->appendChild($this->doc->createElement('loc', $location->getLocation()));
     if ($location->getLastModification()) {
         $node->appendChild($this->doc->createElement('lastmod', $location->getLastModification()));
     }
     return $node;
 }
Beispiel #10
0
 public function actionAdmin()
 {
     $model = new Location('search');
     $model->unsetAttributes();
     if (isset($_GET['Location'])) {
         $model->setAttributes($_GET['Location']);
     }
     $this->render('admin', array('model' => $model));
 }
Beispiel #11
0
 public function testLocationModel()
 {
     $location = new Location();
     $location->name = '';
     $location->longitude = '33.979700';
     $location->latitude = '-84.001750';
     $location->description = 'A challenging maze';
     $location->save();
 }
Beispiel #12
0
 public function testLocationByPosition()
 {
     $Location = new Location();
     $Location->setPosition(49.9, 7.77);
     $Forecast = new Forecast(new Openweathermap(), $Location);
     $object = $Forecast->object();
     if ($object->isEmpty()) {
         $this->markTestSkipped('Openweathermap: Position "49,9, 7.77" was not available.');
     }
 }
Beispiel #13
0
 public function getDistanceInMetersTo(Location $other)
 {
     $radiusOfEarth = 6371000;
     // Earth's radius in meters.
     $diffLatitude = $other->getLatitude() - $this->latitude;
     $diffLongitude = $other->getLongitude() - $this->longitude;
     $a = sin($diffLatitude / 2) * sin($diffLatitude / 2) + cos($this->latitude) * cos($other->getLatitude()) * sin($diffLongitude / 2) * sin($diffLongitude / 2);
     $c = 2 * asin(sqrt($a));
     $distance = $radiusOfEarth * $c;
     return $distance;
 }
 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $checkDtStart = new Zend_Date($this->_lastRunDt);
     $checkDtStart->subHour($config->user->numHoursEvaluationReminder->val);
     $checkDtEnd = new Zend_Date();
     $checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val);
     $event = new Event();
     $events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendee = new Event_Attendee();
     $eu = new Evaluation_User();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
             $evalAvailableDt = new Zend_Date($endDt);
             $evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val);
             if ($evalAvailableDt->getTimestamp() > time()) {
                 $taken = $eu->getCompleted($e->eventId);
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $attending = $attendee->getAttendeesForEvent($e->eventId, 'attending');
                 foreach ($attending as $a) {
                     if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) {
                         $trigger = new Ot_Trigger();
                         $trigger->setVariables($data);
                         $trigger->accountId = $a['accountId'];
                         $trigger->studentEmail = $a['emailAddress'];
                         $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                         $trigger->studentUsername = $a['username'];
                         $trigger->dispatch('Event_Evaluation_Reminder');
                     }
                 }
             }
         }
     }
 }
Beispiel #15
0
 function categorydispatchAction()
 {
     try {
         $this->_helper->viewRenderer->setNoRender();
         $locationid = $this->_getParam('qloc');
         $category = $this->_getParam('qcategory');
         //echo $location;
         //echo $category;
         if (empty($locationid) || empty($category)) {
             $this->_redirect('/');
         } else {
             $location = new Location($locationid);
             $country = $location->getCountry();
             $city = $location->getUriCity();
             $state = $location->getUriState();
             /*
             $searchRules = $location->getSearchRules();
             
             			// Some locaiton only has state.
             if (empty($searchRules->city))
             {
             	$city = $state;
             }
             
             // Some locaiton only has city.
             if (empty($searchRules->state))
             {
             	$state = $city;
             }
             */
             $this->_redirect("/" . Tag::myUrlEncode($category) . "/" . $city . "/" . $state . "/" . $country . "/" . $locationid);
             /*
             $locationArray = explode('|', $location);
             $this->_redirect("/" . Tag::myUrlEncode($category) . "/" . Tag::myUrlEncode($locationArray[0]). "/" . Tag::myUrlEncode($locationArray[1]) . "/" . Tag::myUrlEncode($locationArray[2]) .  "/");
             */
             /*
             $routerParams = array(
             	'query' => $category,
                 'city'  => $locationArray[0],
             	'country' => $locationArray[1]
             );
             */
             //echo $this->_help->url($routerParams, 'user');
             // Redirect to results page
             //$this->_redirect("/" . Tag::myUrlEncode($category) . "/" . Tag::myUrlEncode($locationArray[0]). "/" . Tag::myUrlEncode($locationArray[1]));
         }
         // Using homepage template.
         //Hotspot_Plugin_ViewSetup::setUpSiteTemplate(Hotspot_Plugin_ViewSetup::SIMPLEVIEW);
         //$this->_helper->viewRenderer->setNoRender();
         //echo 'wlecome to hotspot101';
     } catch (Exception $e) {
         echo $e;
     }
 }
Beispiel #16
0
 public function getTitle()
 {
     $title = parent::getTitle();
     $cat2 = $this->getCat2();
     $location = new Location($this->_posting->locId);
     $secondLing = $this->strAdd($cat2, '<span class="titleend"> (' . $location->getLocationString() . ")</span>", '');
     if (!empty($secondLing)) {
         $secondLing = '<span class="titlesecond">' . $secondLing . '</span>';
     }
     return $this->strAdd($title, $secondLing, '<br />');
 }
Beispiel #17
0
 public function getTitle()
 {
     $title = parent::getTitle();
     $title .= '<br /><span class="titlesecond">' . $this->getCat2();
     $location = new Location($this->_posting->locId);
     $suburb = $location->getSuburb();
     if (!empty($suburb)) {
         $title .= ' <span class="titleend">(' . $suburb . ')</span>';
     }
     return $title . '</span>';
 }
Beispiel #18
0
 public static function initializeLocation($accountId, $options)
 {
     // Figure out the proper domain name. We could do a lot more here...
     // Is this a real domain name? If not, use the IP address instead, by default, or initial setup is a pain
     $domain = isset($options['domain']) ? $options['domain'] : network::guessServerIP();
     $location = new Location();
     $location['account_id'] = $accountId;
     $location['name'] = isset($options['name']) ? $options['name'] : 'Main Location';
     $location['domain'] = $domain;
     $location->save();
     return $location->location_id;
 }
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 20; $i += 1) {
         $venue = new Location();
         $venue->title = $faker->company;
         $venue->address = $faker->streetAddress;
         $venue->city = $faker->city;
         $venue->state = $faker->stateAbbr;
         $venue->zip = 78201;
         $venue->save();
     }
 }
 public function run()
 {
     $codes = [75001, 75201, 78701, 73344, 75006, 78154, 75006, 75078, 75094, 75135];
     $faker = Faker::create();
     for ($i = 0; $i < 11; $i++) {
         $location = new Location();
         $location->address = $faker->streetAddress;
         $location->city = $faker->city;
         $location->state = $faker->stateAbbr;
         $location->zip = $codes[rand(0, sizeof($codes) - 1)];
         $location->save();
     }
 }
Beispiel #21
0
 public function getTitle()
 {
     $title = parent::getTitle();
     $title .= '<br /><span class="titlesecond">';
     $other = $this->strAdd($this->getCat3(), $this->getCat2(), ' - ');
     $location = new Location($this->_posting->locId);
     $suburb = $location->getSuburb();
     if (!empty($suburb)) {
         $title .= $other . ' <span class="titleend">(' . $suburb . ')</span>';
     }
     //$title .= $this->strAdd( $other , $suburb, ' : ');
     return $title;
 }
Beispiel #22
0
 public static function get_all_location($connection)
 {
     $statement = $connection->prepare("SELECT * FROM location");
     $statement->execute();
     $result = $statement->get_result();
     $locations = array();
     while ($row = $result->fetch_assoc()) {
         $location = new Location();
         $location->set_name($row["location"]);
         array_push($locations, $location);
     }
     return $locations;
 }
Beispiel #23
0
function setup_edit()
{
    $l = new Location();
    $l->setFromRequest();
    $dao = getLocationDAO();
    $dao->getLocations($l, Q_MATCH);
    if ($l->numResults > 0) {
        $ret = $l->results[0];
    } else {
        $ret = $l;
    }
    return $ret;
}
 public function buildMerchants($xml)
 {
     $merchants = new Merchants();
     $merchants->setPageOffset((string) $xml->PageOffset);
     $merchants->setTotalCount((string) $xml->TotalCount);
     // merchant
     $merchantArray = array();
     foreach ($xml->Merchant as $merchant) {
         $tmpMerchant = new Merchant();
         $tmpMerchant->setId((string) $merchant->Id);
         $tmpMerchant->setName((string) $merchant->Name);
         $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl);
         $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber);
         $tmpMerchant->setCategory((string) $merchant->Category);
         $tmpLocation = new Location();
         $location = $merchant->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpAcceptance = new Acceptance();
         //$acceptance = $merchant->Acceptance;
         // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpFeatures = new Features();
         //$features =  $merchant->Features;
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpMerchant->setLocation($tmpLocation);
         array_push($merchantArray, $tmpMerchant);
     }
     $merchants->setMerchant($merchantArray);
     return $merchants;
 }
Beispiel #25
0
 public function testDelete()
 {
     $loc = new Location();
     $loc->setBuildingID(1);
     $loc->setRoom(9999);
     $loc->save();
     $this->assertTrue(Location::locationExists($loc->getBuildingId(), $loc->getRoom()) != false);
     $loc->delete();
     $this->assertTrue(!Location::locationExists($loc->getBuildingId(), $loc->getRoom()));
 }
Beispiel #26
0
 public function populateMapData($item, $spot)
 {
     if ($spot->lat != null and $spot->lng != null) {
         $loc = new Location();
         $pt = array();
         $pt[0] = $spot->lng;
         $pt[1] = $spot->lat;
         $loc->addPoint($pt);
         $loc->setData($this->populateItemTemplate($item));
         return $loc;
     } else {
         return null;
     }
 }
Beispiel #27
0
 /**
  * Save CompanyLocation
  * @param Location location
  * @returns boolean
  * @throws DaoException
  */
 public function saveCompanyLocation(Location $location)
 {
     try {
         if ($location->getLocCode() == '') {
             $idGenService = new IDGeneratorService();
             $idGenService->setEntity($location);
             $location->setLocCode($idGenService->getNextID());
         }
         $location->save();
         return true;
     } catch (Exception $e) {
         throw new DaoException($e->getMessage());
     }
 }
Beispiel #28
0
 function GetLocation($arg)
 {
     if (!is_numeric($arg)) {
         return FALSE;
     }
     $db = new Db();
     $LocationID = $db->quote($arg);
     $results = $db->select("SELECT * from Locations where LocationID = {$LocationID} limit 1");
     foreach ($results as $result) {
         $location = new Location();
         $location->hydrate($result);
     }
     return $location;
 }
 public function run()
 {
     $faker = Faker::create();
     /*foreach(range(1, 10) as $index)*/
     for ($i = 0; $i < 50; $i++) {
         $location = new Location();
         $location->title = $faker->company;
         $location->address = $faker->streetAddress;
         $location->city = $faker->city;
         $location->state = $faker->stateAbbr;
         $location->zip = $faker->postcode;
         $location->save();
     }
 }
Beispiel #30
0
 /**
  * Registers new principal and school for platform access
  * @return [type] [description]
  */
 public function register()
 {
     $this->setSEO(array("title" => "Register School"));
     $view = $this->getActionView();
     if (RequestMethods::post("action") == "register") {
         $user = new \User(array("name" => RequestMethods::post("name"), "email" => RequestMethods::post("email"), "phone" => RequestMethods::post("phone"), "username" => strtolower(implode("", explode(" ", RequestMethods::post("name")))), "password" => Markup::encrypt("password"), "admin" => 0));
         $user->save();
         $location = new Location(array("user_id" => $user->id, "address" => RequestMethods::post("address"), "city" => RequestMethods::post("city"), "latitude" => "", "longitude" => ""));
         $location->save();
         $organization = new Organization(array("user_id" => $user->id, "name" => RequestMethods::post("sname"), "location_id" => $location->id, "phone" => RequestMethods::post("sphone"), "logo" => ""));
         $organization->save();
         $view->set("success", true);
     }
 }