Skip to content

Commit

Permalink
Using Timeout defines
Browse files Browse the repository at this point in the history
  • Loading branch information
Stardog committed Apr 21, 2017
1 parent b882da8 commit a27a62d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 37 deletions.
4 changes: 2 additions & 2 deletions class/Factory/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function propertyTimeoutPast()
*/
public function updatePropertyTimeout()
{
Settings::set('properties', 'property_timeout', time() + 2592000);
Settings::set('properties', 'property_timeout', time() + PROPERTIES_FORWARD_TIMEOUT);
}

/**
Expand All @@ -145,7 +145,7 @@ public function flipPropertyTimeout()

public function save(Resource $property)
{
$property->timeout = time() + 2592000;
$property->forwardTimeout();
$property->updated = time();
self::saveResource($property);
return $property->id;
Expand Down
6 changes: 3 additions & 3 deletions class/Factory/Roommate.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public function put(\Canopy\Request $request, $roommate)
return $roommate;
}

public function save(Resource $roommate)
public function save(\properties\Resource\Roommate $roommate)
{
$roommate->updated = time();
$roommate->timeout = time() + 2592000;
$roommate->forwardTimeout();
self::saveResource($roommate);
return $roommate->id;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public function roommateTimeoutPast()
*/
public function updateRoommateTimeout()
{
Settings::set('properties', 'roommate_timeout', time() + 2592000);
Settings::set('properties', 'roommate_timeout', time() + PROPERTIES_FORWARD_TIMEOUT);
}

/**
Expand Down
23 changes: 11 additions & 12 deletions class/Factory/Sublease.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ public function getSubleaseByUser($user_id)
public function save(Resource $sublease)
{
$sublease->updated = time();
$sublease->timeout = time() + 2592000;
$sublease->forwardTimeout();
self::saveResource($sublease);
return $sublease->id;
}

public function post(\Canopy\Request $request, $user_id)
{
$r = new Resource;
$r->user_id = $user_id;
$sublease = new Resource;
$sublease->user_id = $user_id;
try {
$r->loadPostByType($request,
array('active', 'created', 'updated', 'user_id', 'id', 'thumbnail'));
$r->active = true;
$r->created = time();
return array('id' => $this->save($r));
$sublease->loadPostByType($request,
array('active', 'timeout', 'created', 'updated', 'user_id', 'id', 'thumbnail'));
$sublease->active = true;
$sublease->created = time();
return array('id' => $this->save($sublease));
} catch (\Exception $e) {
throw new \properties\Exception\PropertySaveFailure($e->getMessage());
}
Expand All @@ -99,13 +99,12 @@ public function view($sublease, $admin = false)
return $template->get();
}

public function put(\Canopy\Request $request, $user_id)
public function put(\Canopy\Request $request, Resource $sublease)
{
$r = $this->getSubleaseByUser($user_id);
try {
$r->loadPutByType($request,
$sublease->loadPutByType($request,
array('active', 'created', 'updated', 'user_id', 'id'));
return array('id' => $this->save($r));
return array('id' => $this->save($sublease));
} catch (\Exception $e) {
throw new \properties\Exception\PropertySaveFailure($e->getMessage());
}
Expand Down
5 changes: 5 additions & 0 deletions class/Resource/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,9 @@ public function view()
return $view;
}

public function forwardTimeout()
{
$forward = time() + PROPERTIES_FORWARD_TIMEOUT;
$this->timeout->set($forward);
}
}
6 changes: 6 additions & 0 deletions class/Resource/Roommate.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,10 @@ protected function getFocus()
return $focus[$this->focus->get()];
}

public function forwardTimeout()
{
$forward = time() + PROPERTIES_FORWARD_TIMEOUT;
$this->timeout->set($forward);
}

}
43 changes: 23 additions & 20 deletions conf/system_defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,40 @@
define('NO_LIMIT_PARKING', 99);


define('C_MONTHLY', 1);
define('C_SIX_MONTH', 2);
define('C_YEARLY', 3);
define('C_SUMMER', 4);
define('C_SEMESTER', 5);
define('C_MONTHLY', 1);
define('C_SIX_MONTH', 2);
define('C_YEARLY', 3);
define('C_SUMMER', 4);
define('C_SEMESTER', 5);
define('C_TWO_SEMESTER', 6);
define('C_TEN_MONTH', 7);
define('C_FIVE_MONTH', 8);
define('C_TEN_MONTH', 7);
define('C_FIVE_MONTH', 8);

// heating type
define('HT_HVAC', 1);
define('HT_OIL', 2);
define('HT_PROPANE', 3);
define('HT_HVAC', 1);
define('HT_OIL', 2);
define('HT_PROPANE', 3);
define('HT_ELEC_BASE', 4);
define('HT_KEROSENE', 5);
define('HT_KEROSENE', 5);
define('HT_WOODSTOVE', 6);
define('HT_GAS', 7);

// Currently coded to use square thumbs, height not used
define('PROP_THUMBNAIL_WIDTH', 100);
//define('PROP_THUMBNAIL_HEIGHT', 100);

define('TV_NONE', 0);
define('TV_CABLE', 1);
define('TV_NONE', 0);
define('TV_CABLE', 1);
define('TV_SATELLITE', 2);
define('TV_FIBER', 3);

define('NET_DIALUP', 1);
define('NET_DSL', 2);
define('NET_WIRELESS', 3);
define('NET_DIALUP', 1);
define('NET_DSL', 2);
define('NET_WIRELESS', 3);
define('NET_SATELLITE', 4);
define('NET_CABLE', 5);
define('NET_BOTH', 6);
define('NET_FIBER', 7);
define('NET_CABLE', 5);
define('NET_BOTH', 6);
define('NET_FIBER', 7);

define('PROP_TYPE_APARTMENT', 0);
define('PROP_TYPE_EFFICIENCY', 1);
Expand All @@ -58,7 +58,7 @@
define('PANEL_WIDTH', 400);
define('PANEL_HEIGHT', 300);

define('GENDER_MALE', 1);
define('GENDER_MALE', 1);
define('GENDER_FEMALE', 2);

define('JOINT_LEASE', 0);
Expand All @@ -73,3 +73,6 @@

define('PROP_MAX_IMAGE_WIDTH', 1200);
define('PROP_MAX_IMAGE_HEIGHT', 1000);

// 30 days
define('PROPERTIES_FORWARD_TIMEOUT', 2592000);

0 comments on commit a27a62d

Please sign in to comment.