Skip to content

Commit

Permalink
0.5.9 rev 3840
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Oct 14, 2014
1 parent 1fc4ef4 commit 9469c9e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 17 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.9 rev 3838
0.5.9 rev 3840
49 changes: 47 additions & 2 deletions api/libs/api.sigreq.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,55 @@ public function renderList() {
} else {
$confControl='';
}

show_window($confControl.__('Available signup requests'), $result);
$viewControl= wf_Link('?module=sigreq&calendarview=true', wf_img('skins/icon_calendar.gif', __('As calendar')), false, '');
show_window($confControl.__('Available signup requests').' '.$viewControl, $result);
}

/*
* renders available signups data in calendar view
*
* @return void
*/

public function renderCalendar() {
$curyear= curyear();
$query="SELECT * from `sigreq` WHERE `date` LIKE '".$curyear."-%' ORDER BY `date` ASC";
$all= simple_queryall($query);
$result='';
$calendarData='';
if (!empty($all)) {
foreach ($all as $io=>$each) {
$timestamp=strtotime($each['date']);
$date=date("Y, n-1, j",$timestamp);
$rawTime=date("H:i:s",$timestamp);
if ($each['state']==0) {
$coloring="className : 'undone',";
} else {
$coloring='';
}
$calendarData.="
{
title: '".$rawTime.' '.$each['street'].' '.$each['build'].'/'.$each['apt']."',
url: '?module=sigreq&showreq=".$each['id']."',
start: new Date(".$date."),
end: new Date(".$date."),
".$coloring."
},
";
}


}
$result= wf_FullCalendar($calendarData);
//check database configuration table
if (zb_CheckTableExists('sigreqconf')) {
$confControl= wf_Link('?module=sigreq&settings=true', wf_img('skins/settings.png', __('Settings')), false).' ';
} else {
$confControl='';
}
$viewControl= wf_Link('?module=sigreq', wf_img('skins/icon_table.png', __('Grid view')), false, '');
show_window($confControl.__('Available signup requests').' '.$viewControl, $result);
}
/*
* returns signup request data by selected ID
*
Expand Down
6 changes: 6 additions & 0 deletions docs/signup2/config/signup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ db = "stg"
character = "UTF8"
prefix = "billing"

;signup2 configuration database connection caching
confcache=0

;global caching timeout in seconds
cachetimeout=3600

;debug mode
debug = 0
2 changes: 1 addition & 1 deletion docs/signup2/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

$dbConnect = new MySQLDB();

$signup = new SignupService();
$signup = new SignupService($snConfig['confcache'],$snConfig['cachetimeout']);

//show form by default
if (!la_CheckPost(array('createrequest'))) {
Expand Down
58 changes: 52 additions & 6 deletions docs/signup2/modules/engine/api.signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SignupService {
protected $optionEmailDisplay = true;
protected $optionSpamTraps = true;
protected $optionCaching = false;
protected $optionConfCaching=false;
protected $optionServices = '';
protected $optionTariffs = '';
protected $optionIspName = '';
Expand All @@ -21,7 +22,7 @@ class SignupService {

//caching
const CACHE_PATH = 'cache/';
const CACHE_TIME = 3600;
protected $cachigTime = 3600;

//other properties
protected $cities = array();
Expand All @@ -33,7 +34,11 @@ class SignupService {
protected $required = array('street', 'build', 'realname', 'phone');
protected $important = '';

public function __construct() {
public function __construct($confcache=0,$cachetimeout=3600) {
if ($confcache) {
$this->optionConfCaching=true;
}
$this->cachingTime=$cachetimeout;
$this->important = ' ' . la_tag('sup') . '*' . la_tag('sup', true);
$this->loadConfig();
$this->configPreprocess();
Expand All @@ -50,13 +55,54 @@ public function __construct() {
*/

protected function loadConfig() {
if ($this->optionConfCaching) {
$cacheTime = $this->cachingTime;
$cacheTime = time() - $cacheTime;
$cacheName = self::CACHE_PATH . 'config.dat';
$updateCache = false;
if (file_exists($cacheName)) {
$updateCache = false;
if ((filemtime($cacheName) > $cacheTime)) {
$updateCache = false;
} else {
$updateCache = true;
}
} else {
$updateCache = true;
}

if (!$updateCache) {
//read data directly from cache
$result = array();
$rawData = file_get_contents($cacheName);
if (!empty($rawData)) {
$rawData= base64_decode($rawData);
$result = unserialize($rawData);

}
$this->configRaw = $result;
} else {
//updating cache
$query = "SELECT * from `sigreqconf`";
$all = simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io => $each) {
$this->configRaw[$each['key']] = $each['value'];
}
}
$cacheStoreData = serialize($this->configRaw);
$cacheStoreData = base64_encode($cacheStoreData);
file_put_contents($cacheName, $cacheStoreData);
}
} else {
$query = "SELECT * from `sigreqconf`";
$all = simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io => $each) {
$this->configRaw[$each['key']] = $each['value'];
}
}
}
}

/*
Expand Down Expand Up @@ -111,7 +157,7 @@ public function setTemplateData() {

protected function loadCities() {
if ($this->optionCaching) {
$cacheTime = self::CACHE_TIME;
$cacheTime = $this->cachingTime;
$cacheTime = time() - $cacheTime;
$cacheName = self::CACHE_PATH . 'city.dat';
$updateCache = false;
Expand All @@ -136,7 +182,7 @@ protected function loadCities() {
$this->cities = $result;
} else {
//updating cache
$query = "SELECT * from `city`";
$query = "SELECT * from `city` ORDER BY `id` ASC";
$all = simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io => $each) {
Expand All @@ -147,7 +193,7 @@ protected function loadCities() {
file_put_contents($cacheName, $cacheStoreData);
}
} else {
$query = "SELECT * from `city`";
$query = "SELECT * from `city` ORDER BY `id` ASC";
$all = simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io => $each) {
Expand Down Expand Up @@ -211,7 +257,7 @@ protected function loadHideouts() {

protected function loadStreets() {
if ($this->optionCaching) {
$cacheTime = self::CACHE_TIME;
$cacheTime = $this->cachingTime;
$cacheTime = time() - $cacheTime;
$cacheName = self::CACHE_PATH . 'street.dat';
$updateCache = false;
Expand Down
18 changes: 11 additions & 7 deletions modules/general/sigreq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
if ($alterconf['SIGREQ_ENABLED']) {
//Main sigreq management
if (!wf_CheckGet(array('settings'))) {
$signups = new SignupRequests();

$signups = new SignupRequests();
//requests management
//set request done
if (isset($_GET['reqdone'])) {
Expand All @@ -32,21 +32,25 @@
//shows selected signup request by its ID
$signups->showRequest($_GET['showreq']);
} else {
//display signup requests list
$signups->renderList();
if (!wf_CheckGet(array('calendarview'))) {
//display signup requests list
$signups->renderList();
} else {
//display signup requests calendar
$signups->renderCalendar();
}
}
} else {
//signup requests service configuration
$signupConf=new SignupConfig;
$signupConf = new SignupConfig;

//save config request
if (wf_CheckPost(array('changesettings'))) {
$signupConf->save();
rcms_redirect('?module=sigreq&settings=true');
}
show_window(__('Settings'), $signupConf->renderForm());
}

} else {
show_window(__('Error'), __('This module disabled'));
}
Expand Down

0 comments on commit 9469c9e

Please sign in to comment.