[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14558] booking: formatting code
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14558] booking: formatting code |
Date: |
Thu, 10 Dec 2015 12:56:19 +0000 |
Revision: 14558
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14558
Author: sigurdne
Date: 2015-12-10 12:56:18 +0000 (Thu, 10 Dec 2015)
Log Message:
-----------
booking: formatting code
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.account_helper.inc.php
branches/dev-syncromind/booking/inc/class.account_ui_utils.inc.php
branches/dev-syncromind/booking/inc/class.async_task.inc.php
branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
branches/dev-syncromind/booking/inc/class.async_task_update_reservation_state.inc.php
branches/dev-syncromind/booking/inc/class.boaccount_code_set.inc.php
branches/dev-syncromind/booking/inc/class.boactivity.inc.php
branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
branches/dev-syncromind/booking/inc/class.boallocation.inc.php
branches/dev-syncromind/booking/inc/class.boapplication.inc.php
branches/dev-syncromind/booking/inc/class.boasync_settings.inc.php
branches/dev-syncromind/booking/inc/class.boaudience.inc.php
branches/dev-syncromind/booking/inc/class.bobooking.inc.php
branches/dev-syncromind/booking/inc/class.bobuilding.inc.php
branches/dev-syncromind/booking/inc/class.bocommon.inc.php
branches/dev-syncromind/booking/inc/class.bocommon_authorized.inc.php
branches/dev-syncromind/booking/inc/class.bocommon_global_manager_authorized.inc.php
branches/dev-syncromind/booking/inc/class.bocompleted_reservation.inc.php
branches/dev-syncromind/booking/inc/class.bocompleted_reservation_export.inc.php
branches/dev-syncromind/booking/inc/class.bocompleted_reservation_export_file.inc.php
branches/dev-syncromind/booking/inc/class.bocontactperson.inc.php
branches/dev-syncromind/booking/inc/class.bodocument.inc.php
branches/dev-syncromind/booking/inc/class.bodocument_building.inc.php
branches/dev-syncromind/booking/inc/class.bodocument_resource.inc.php
branches/dev-syncromind/booking/inc/class.bodocument_view.inc.php
branches/dev-syncromind/booking/inc/class.bodocumentation.inc.php
branches/dev-syncromind/booking/inc/class.boevent.inc.php
branches/dev-syncromind/booking/inc/class.bogroup.inc.php
branches/dev-syncromind/booking/inc/class.bomassbooking.inc.php
branches/dev-syncromind/booking/inc/class.boorganization.inc.php
branches/dev-syncromind/booking/inc/class.bopermission.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_building.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_document_building.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_document_resource.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_massbooking.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_root.inc.php
branches/dev-syncromind/booking/inc/class.bopermission_season.inc.php
branches/dev-syncromind/booking/inc/class.boresource.inc.php
branches/dev-syncromind/booking/inc/class.boseason.inc.php
branches/dev-syncromind/booking/inc/class.bosystem_message.inc.php
branches/dev-syncromind/booking/inc/class.customer_identifier.inc.php
branches/dev-syncromind/booking/inc/class.errorstack.inc.php
branches/dev-syncromind/booking/inc/class.export_agresso.inc.php
branches/dev-syncromind/booking/inc/class.filestorage.inc.php
branches/dev-syncromind/booking/inc/class.hook_helper.inc.php
branches/dev-syncromind/booking/inc/class.menu.inc.php
branches/dev-syncromind/booking/inc/class.ofbooking.inc.php
branches/dev-syncromind/booking/inc/class.soaccount_code_set.inc.php
branches/dev-syncromind/booking/inc/class.soactivity.inc.php
branches/dev-syncromind/booking/inc/class.soagegroup.inc.php
branches/dev-syncromind/booking/inc/class.soallocation.inc.php
branches/dev-syncromind/booking/inc/class.soapplication.inc.php
branches/dev-syncromind/booking/inc/class.soaudience.inc.php
branches/dev-syncromind/booking/inc/class.sobilling_sequential_number_generator.inc.php
branches/dev-syncromind/booking/inc/class.sobooking.inc.php
branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
branches/dev-syncromind/booking/inc/class.socommon.inc.php
branches/dev-syncromind/booking/inc/class.socompleted_reservation.inc.php
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export.inc.php
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export_file.inc.php
branches/dev-syncromind/booking/inc/class.socontact_organization.inc.php
branches/dev-syncromind/booking/inc/class.socontactperson.inc.php
branches/dev-syncromind/booking/inc/class.sodocument.inc.php
branches/dev-syncromind/booking/inc/class.sodocument_building.inc.php
branches/dev-syncromind/booking/inc/class.sodocument_resource.inc.php
branches/dev-syncromind/booking/inc/class.sodocument_view.inc.php
branches/dev-syncromind/booking/inc/class.sodocumentation.inc.php
branches/dev-syncromind/booking/inc/class.soevent.inc.php
branches/dev-syncromind/booking/inc/class.sogroup.inc.php
branches/dev-syncromind/booking/inc/class.somassbooking.inc.php
branches/dev-syncromind/booking/inc/class.soorganization.inc.php
branches/dev-syncromind/booking/inc/class.sopermission.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_account_code_set.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_activity.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_agegroup.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_allocation.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_audience.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_booking.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_building.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_document_building.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_document_resource.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_event.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_group.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_massbooking.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_organization.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_building.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_building.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_resource.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_resource.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_root.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_permission_season.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_resource.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_root.inc.php
branches/dev-syncromind/booking/inc/class.sopermission_season.inc.php
branches/dev-syncromind/booking/inc/class.soresource.inc.php
branches/dev-syncromind/booking/inc/class.soseason.inc.php
branches/dev-syncromind/booking/inc/class.sosystem_message.inc.php
branches/dev-syncromind/booking/inc/class.uiaccount_code_dimension.inc.php
branches/dev-syncromind/booking/inc/class.uiaccount_code_set.inc.php
branches/dev-syncromind/booking/inc/class.uiactivity.inc.php
branches/dev-syncromind/booking/inc/class.uiagegroup.inc.php
branches/dev-syncromind/booking/inc/class.uiallocation.inc.php
branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
branches/dev-syncromind/booking/inc/class.uiapplication_settings.inc.php
branches/dev-syncromind/booking/inc/class.uiasync_settings.inc.php
branches/dev-syncromind/booking/inc/class.uiaudience.inc.php
branches/dev-syncromind/booking/inc/class.uibooking.inc.php
branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
branches/dev-syncromind/booking/inc/class.uicommon.inc.php
branches/dev-syncromind/booking/inc/class.uicompleted_reservation.inc.php
branches/dev-syncromind/booking/inc/class.uicompleted_reservation_export.inc.php
branches/dev-syncromind/booking/inc/class.uicompleted_reservation_export_file.inc.php
branches/dev-syncromind/booking/inc/class.uicontactperson.inc.php
branches/dev-syncromind/booking/inc/class.uidashboard.inc.php
branches/dev-syncromind/booking/inc/class.uidocument.inc.php
branches/dev-syncromind/booking/inc/class.uidocument_building.inc.php
branches/dev-syncromind/booking/inc/class.uidocument_resource.inc.php
branches/dev-syncromind/booking/inc/class.uidocument_view.inc.php
branches/dev-syncromind/booking/inc/class.uidocumentation.inc.php
branches/dev-syncromind/booking/inc/class.uievent.inc.php
branches/dev-syncromind/booking/inc/class.uievent_mail_settings.inc.php
branches/dev-syncromind/booking/inc/class.uigroup.inc.php
branches/dev-syncromind/booking/inc/class.uimail_settings.inc.php
branches/dev-syncromind/booking/inc/class.uimassbooking.inc.php
branches/dev-syncromind/booking/inc/class.uimetasettings.inc.php
branches/dev-syncromind/booking/inc/class.uiorganization.inc.php
branches/dev-syncromind/booking/inc/class.uipermission.inc.php
branches/dev-syncromind/booking/inc/class.uipermission_building.inc.php
branches/dev-syncromind/booking/inc/class.uipermission_massbooking.inc.php
branches/dev-syncromind/booking/inc/class.uipermission_resource.inc.php
branches/dev-syncromind/booking/inc/class.uipermission_root.inc.php
branches/dev-syncromind/booking/inc/class.uipermission_season.inc.php
branches/dev-syncromind/booking/inc/class.uireports.inc.php
branches/dev-syncromind/booking/inc/class.uiresource.inc.php
branches/dev-syncromind/booking/inc/class.uiseason.inc.php
branches/dev-syncromind/booking/inc/class.uisend_email.inc.php
branches/dev-syncromind/booking/inc/class.uisettings.inc.php
branches/dev-syncromind/booking/inc/class.uisystem_message.inc.php
branches/dev-syncromind/booking/inc/class.unauthorized_exception.inc.php
branches/dev-syncromind/booking/inc/schedule.php
Modified: branches/dev-syncromind/booking/inc/class.account_helper.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.account_helper.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.account_helper.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,9 +1,13 @@
<?php
- class booking_account_helper {
+
+ class booking_account_helper
+ {
+
const ADMIN_GROUP = 'Admins';
+
protected static $account_is_admin;
protected static $current_account_lid;
-
+
/**
* Returns the current user's account_id in the phpgw_accounts
table
*/
@@ -11,59 +15,58 @@
{
return get_account_id();
}
-
+
/**
* Returns the current user's login name
*/
- public function current_account_lid() {
+ public function current_account_lid()
+ {
return $GLOBALS['phpgw_info']['user']['account_lid'];
}
-
+
/**
* Returns the current user's full name
*/
- public function current_account_fullname() {
+ public function current_account_fullname()
+ {
return $GLOBALS['phpgw_info']['user']['fullname'];
}
-
+
public static function current_account_memberships()
{
return $GLOBALS['phpgw']->accounts->membership();
}
-
-/* public static function current_account_member_of_admins()
- {
- if (!isset(self::$account_is_admin))
- {
- self::$account_is_admin = false;
-
- $memberships =
self::current_account_memberships();
- while($memberships && list($index,$group_info)
= each($memberships))
- {
- if ($group_info->lid ==
self::ADMIN_GROUP)
- {
- self::$account_is_admin = true;
- break;
- }
- }
- }
-
- return self::$account_is_admin;
- }*/
+ /* public static function
current_account_member_of_admins()
+ {
+ if (!isset(self::$account_is_admin))
+ {
+ self::$account_is_admin = false;
+ $memberships = self::current_account_memberships();
+ while($memberships && list($index,$group_info) =
each($memberships))
+ {
+ if ($group_info->lid == self::ADMIN_GROUP)
+ {
+ self::$account_is_admin = true;
+ break;
+ }
+ }
+ }
+
+ return self::$account_is_admin;
+ } */
+
public static function current_account_member_of_admins()
{
- if (!isset(self::$account_is_admin))
+ if(!isset(self::$account_is_admin))
{
self::$account_is_admin = false;
- if ( $GLOBALS['phpgw']->acl->check('run',
phpgwapi_acl::READ, 'admin')
- || $GLOBALS['phpgw']->acl->check('admin',
phpgwapi_acl::ADD, 'booking'))
+ if($GLOBALS['phpgw']->acl->check('run',
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin',
phpgwapi_acl::ADD, 'booking'))
{
- self::$account_is_admin = true;
+ self::$account_is_admin = true;
}
+ }
- }
-
return self::$account_is_admin;
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.account_ui_utils.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.account_ui_utils.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.account_ui_utils.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,30 +1,32 @@
<?php
+
class booking_account_ui_utils
{
+
public static function yui_accounts()
{
- $query = phpgw::get_var('query');
-
- $account_info =
$GLOBALS['phpgw']->accounts->get_list('accounts', 0, 'lid', '', $query, 20);
- $x = 0;
-
+ $query = phpgw::get_var('query');
+
+ $account_info =
$GLOBALS['phpgw']->accounts->get_list('accounts', 0, 'lid', '', $query, 20);
+ $x = 0;
+
$result = array();
-
+
foreach($account_info as $account)
{
- $firstname = $account->firstname;
- $lastname = $account->lastname;
+ $firstname = $account->firstname;
+ $lastname = $account->lastname;
$lastname AND $firstname .= ' ';
- $result[] = array(
- 'name' => sprintf('%s (%s%s)',
$account->lid, $firstname, $lastname),
- 'id' => $account->id,
+ $result[] = array(
+ 'name' => sprintf('%s (%s%s)',
$account->lid, $firstname, $lastname),
+ 'id' => $account->id,
);
}
-
+
$data = array(
'ResultSet' => array(
- "totalResultsAvailable" =>
$GLOBALS['phpgw']->accounts->total,
- "Result" => $result
+ "totalResultsAvailable" =>
$GLOBALS['phpgw']->accounts->total,
+ "Result"
=> $result
)
);
return $data;
Modified: branches/dev-syncromind/booking/inc/class.async_task.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.async_task.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.async_task.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,75 +1,89 @@
<?php
phpgw::import_class('booking.async_task_update_reservation_state');
-
+
class booking_async_task
{
+
protected static $task_instances = array();
protected $asyncservice;
-
- function __construct() {
- if ( !isset($GLOBALS['phpgw']->asyncservice)
- || !is_object($GLOBALS['phpgw']->asyncservice) )
+
+ function __construct()
+ {
+ if(!isset($GLOBALS['phpgw']->asyncservice) ||
!is_object($GLOBALS['phpgw']->asyncservice))
{
$GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
}
$this->asyncservice = $GLOBALS['phpgw']->asyncservice;
}
-
- public function doRun($task_args) {
+
+ public function doRun($task_args)
+ {
$task_class = $task_args['task_class'];
- if (in_array($task_class, self::getAvailableTasks())) {
+ if(in_array($task_class, self::getAvailableTasks()))
+ {
$task = self::create($task_class);
$task->run($task_args);
}
}
-
- public static function getAvailableTasks() {
+
+ public static function getAvailableTasks()
+ {
return
array('booking.async_task_update_reservation_state',
'booking.async_task_send_reminder');
}
-
- public static function create($task_class) {
+
+ public static function create($task_class)
+ {
$task = null;
- if (!isset(self::$task_instances[$task_class])) {
- $task = CreateObject($task_class);
- self::$task_instances[$task_class] = $task;
+ if(!isset(self::$task_instances[$task_class]))
+ {
+ $task
= CreateObject($task_class);
+ self::$task_instances[$task_class] =
$task;
}
-
+
return self::$task_instances[$task_class];
}
-
- public function get_task_id() {
+
+ public function get_task_id()
+ {
return get_class($this);
}
-
- public function get_default_times() {
- /*array('min' => '1', 'hour' => '0', 'dow' => '*',
'day' => '*', 'month' => '*', 'year' => '*'), */
- return array('min' => '*', 'hour' => '*', 'dow' =>
'*', 'day' => '*', 'month' => '*', 'year' => '*');
+
+ public function get_default_times()
+ {
+ /* array('min' => '1', 'hour' => '0', 'dow' => '*',
'day' => '*', 'month' => '*', 'year' => '*'), */
+ return array('min' => '*', 'hour' => '*', 'dow' => '*',
'day' => '*', 'month' => '*',
+ 'year' => '*');
}
-
- public function is_enabled() {
+
+ public function is_enabled()
+ {
return
is_array($this->asyncservice->read($this->get_task_id()));
}
-
- public function disable() {
+
+ public function disable()
+ {
$this->asyncservice->cancel_timer($this->get_task_id());
}
-
- public function enable($times = null) {
- if ($times === null) {
+
+ public function enable($times = null)
+ {
+ if($times === null)
+ {
$times = $this->get_default_times();
}
-
+
list($task_appname, $task_class) = explode('_',
get_class($this), 2);
list($appname, $class) = explode('_', __CLASS__, 2);
-
+
$this->asyncservice->set_timer(
- $times === null ? $this->get_default_times() :
$times,
- $this->get_task_id(),
- "{$appname}.{$class}.doRun",
- array('task_class' =>
"{$task_appname}.{$task_class}")
+ $times === null ? $this->get_default_times() : $times,
$this->get_task_id(), "{$appname}.{$class}.doRun", array(
+ 'task_class' => "{$task_appname}.{$task_class}")
);
}
-
- public function run($options = array()) {}
- }
+
+ public function run($options = array())
+ {
+
+ }
+ }
\ No newline at end of file
Modified:
branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -6,9 +6,10 @@
phpgw::import_class('booking.bogroup');
phpgw::import_class('booking.bobuilding');
phpgw::import_class('booking.uicommon');
-
+
class booking_async_task_send_reminder extends booking_async_task
{
+
const interval_length = '60'; // in minutes
public function __construct()
@@ -16,10 +17,10 @@
parent::__construct();
$this->db = & $GLOBALS['phpgw']->db;
- $this->booking_bo = CreateObject('booking.bobooking');
- $this->building_bo = CreateObject('booking.bobuilding');
- $this->event_bo = CreateObject('booking.boevent');
- $this->group_bo = CreateObject('booking.bogroup');
+ $this->booking_bo =
CreateObject('booking.bobooking');
+ $this->building_bo =
CreateObject('booking.bobuilding');
+ $this->event_bo =
CreateObject('booking.boevent');
+ $this->group_bo =
CreateObject('booking.bogroup');
$this->send = CreateObject('phpgwapi.send');
}
@@ -32,39 +33,39 @@
private function send_reminder_bookings()
{
- $sql = "SELECT distinct bo.id FROM bb_booking bo
+ $sql = "SELECT distinct bo.id FROM
bb_booking bo
inner join bb_group_contact gc on gc.group_id =
bo.group_id and trim(gc.email) <> ''
- where bo.from_ > now() and bo.from_ < (now() +
INTERVAL '".self::interval_length." minutes')
+ where bo.from_ > now() and bo.from_ < (now() +
INTERVAL '" . self::interval_length . " minutes')
and bo.reminder = 1";
$this->db->query($sql);
- $bookings = $this->db->resultSet;
+ $bookings = $this->db->resultSet;
- $config = CreateObject('phpgwapi.config','booking');
+ $config =
CreateObject('phpgwapi.config', 'booking');
$config->read();
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $from =
isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
foreach($bookings as $booking)
{
- $booking =
$this->booking_bo->read_single($booking['id']);
- $building =
$this->building_bo->read_single($booking['building_id']);
+ $booking =
$this->booking_bo->read_single($booking['id']);
+ $building =
$this->building_bo->read_single($booking['building_id']);
- $body =
$this->create_body_text($booking['from_'], $booking['to_'], $building['name'],
$booking['group_name'], $booking['id'], $booking['secret'], 'booking',
$external_site_address);
+ $body =
$this->create_body_text($booking['from_'], $booking['to_'], $building['name'],
$booking['group_name'], $booking['id'], $booking['secret'], 'booking',
$external_site_address);
$subject = 'Rapporter deltakertall';
- $this->db->query("select distinct name, email
from bb_group_contact where trim(email) <> '' and group_id =
".$booking['group_id']);
+ $this->db->query("select distinct name, email
from bb_group_contact where trim(email) <> '' and group_id = " .
$booking['group_id']);
$contacts = $this->db->resultSet;
- foreach($contacts as $contact)
+ foreach($contacts as $contact)
{
try
{
$this->send->msg('email',
$contact['email'], $subject, $body, '', '', '', $from, '', 'plain');
-
+
// status set to 'sent, not
responded to'
- $sql = "update bb_booking set
reminder = 3 where id = ".$booking['id'];
+ $sql = "update bb_booking set
reminder = 3 where id = " . $booking['id'];
$this->db->query($sql);
- }
- catch (phpmailerException $e)
+ }
+ catch(phpmailerException $e)
{
// do nothing. nowhere to log
or display error messages
}
@@ -74,35 +75,35 @@
private function send_reminder_events()
{
- $sql = "SELECT id from bb_event
- where from_ > now() and from_ < (now() +
INTERVAL '".self::interval_length." minutes')
+ $sql = "SELECT id from bb_event
+ where from_ > now() and from_ < (now() +
INTERVAL '" . self::interval_length . " minutes')
and trim(contact_email) <> ''
and reminder = 1";
$this->db->query($sql);
- $events = $this->db->resultSet;
+ $events = $this->db->resultSet;
- $config = CreateObject('phpgwapi.config','booking');
+ $config =
CreateObject('phpgwapi.config', 'booking');
$config->read();
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $from =
isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
foreach($events as $event)
{
- $event =
$this->event_bo->read_single($event['id']);
- $building_info =
$this->event_bo->so->get_building_info($event['id']);
- $building =
$this->building_bo->read_single($building_info['id']);
+ $event =
$this->event_bo->read_single($event['id']);
+ $building_info =
$this->event_bo->so->get_building_info($event['id']);
+ $building =
$this->building_bo->read_single($building_info['id']);
- $body =
$this->create_body_text($event['from_'], $event['to_'], $building['name'], '',
$event['id'], $event['secret'], 'event', $external_site_address);
+ $body =
$this->create_body_text($event['from_'], $event['to_'], $building['name'], '',
$event['id'], $event['secret'], 'event', $external_site_address);
$subject = 'Rapporter deltakertall';
try
{
$this->send->msg('email',
$event['contact_email'], $subject, $body, '', '', '', $from, '', 'plain');
-
+
// status set to 'sent, not responded
to'
- $sql = "update bb_event set reminder =
3 where id = ".$event['id'];
+ $sql = "update bb_event set reminder =
3 where id = " . $event['id'];
$this->db->query($sql);
}
- catch (phpmailerException $e)
+ catch(phpmailerException $e)
{
// do nothing. nowhere to log or
display error messages
}
@@ -111,31 +112,34 @@
private function create_body_text($from, $to, $where, $who,
$id, $secret, $type, $external_site_address)
{
- $config = CreateObject('phpgwapi.config','booking');
- $config->read();
+ $config = CreateObject('phpgwapi.config', 'booking');
+ $config->read();
- $body = "Informasjon om kommende arrangement:\n";
+ $body = "Informasjon om kommende arrangement:\n";
$body .= "Hvor: %WHERE%\n";
$body .= "Når: %WHEN%\n";
- if (strlen($who) > 0)
+ if(strlen($who) > 0)
{
$body .= "Hvem: %WHO%\n";
}
- if ($config->config_data['metatag_author'] != '') {
- $body .= "\n".$config->config_data['metatag_author'];
- } else {
- $body .= "\nAktivby ";
- }
+ if($config->config_data['metatag_author'] != '')
+ {
+ $body .= "\n" .
$config->config_data['metatag_author'];
+ }
+ else
+ {
+ $body .= "\nAktivby ";
+ }
$body .= " fører statistikk på bruk av lokaler og ber
derfor om at dere \n";
$body .= "\netter arrangementet melder inn korrekt
deltakertall til oss.\n";
$body .= "Du kan gjøre dette ved å klikke på linken
nedenfor.\n\n%URL%";
- $body = str_replace('%URL%',
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.ui'.$type.'.report_numbers&id='.$id.'&secret='.$secret,
$body);
- $body = str_replace('%WHO%', $who, $body);
- $body = str_replace('%WHERE%', $where, $body);
- $body = str_replace('%WHEN%', pretty_timestamp($from).'
- '.pretty_timestamp($to), $body);
+ $body = str_replace('%URL%', $external_site_address
. '/bookingfrontend/?menuaction=bookingfrontend.ui' . $type .
'.report_numbers&id=' . $id . '&secret=' . $secret, $body);
+ $body = str_replace('%WHO%', $who, $body);
+ $body = str_replace('%WHERE%', $where, $body);
+ $body = str_replace('%WHEN%',
pretty_timestamp($from) . ' - ' . pretty_timestamp($to), $body);
return $body;
}
- }
+ }
\ No newline at end of file
Modified:
branches/dev-syncromind/booking/inc/class.async_task_update_reservation_state.inc.php
===================================================================
---
branches/dev-syncromind/booking/inc/class.async_task_update_reservation_state.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++
branches/dev-syncromind/booking/inc/class.async_task_update_reservation_state.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,34 +1,40 @@
<?php
phpgw::import_class('booking.async_task');
phpgw::import_class('booking.socompleted_reservation');
-
+
class booking_async_task_update_reservation_state extends
booking_async_task
{
- public function run($options = array()) {
+
+ public function run($options = array())
+ {
$db = & $GLOBALS['phpgw']->db;
-
- $reservation_types = array
- (
+
+ $reservation_types = array
+ (
'booking',
'event',
'allocation'
);
- $completed_so =
CreateObject('booking.socompleted_reservation');
-
- foreach ($reservation_types as $reservation_type) {
- $bo =
CreateObject('booking.bo'.$reservation_type);
-
+ $completed_so =
CreateObject('booking.socompleted_reservation');
+
+ foreach($reservation_types as $reservation_type)
+ {
+ $bo = CreateObject('booking.bo' .
$reservation_type);
+
$expired = $bo->find_expired();
- if (!is_array($expired) ||
!isset($expired['results'])) { continue; }
+ if(!is_array($expired) ||
!isset($expired['results']))
+ { continue;}
$db->transaction_begin();
-
- if (count($expired['results']) > 0) {
- foreach ($expired['results'] as
$reservation) {
+
+ if(count($expired['results']) > 0)
+ {
+ foreach($expired['results'] as
$reservation)
+ {
$completed_so->create_from($reservation_type, $reservation);
}
-
+
$bo->complete_expired($expired['results']);
}
@@ -36,8 +42,7 @@
}
}
}
-
-/*
+ /*
Begreper:
application - Søknad
allocation - tildeling
Modified: branches/dev-syncromind/booking/inc/class.boaccount_code_set.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boaccount_code_set.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boaccount_code_set.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,8 +1,9 @@
<?php
phpgw::import_class('booking.bocommon_global_manager_authorized');
-
+
class booking_boaccount_code_set extends
booking_bocommon_global_manager_authorized
{
+
function __construct()
{
parent::__construct();
@@ -12,42 +13,39 @@
protected function get_object_role_permissions(array
$forObject, $defaultPermissions)
{
return array_merge(
- array
+ array
(
- booking_sopermission::ROLE_MANAGER =>
array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'write' => true,
- ),
- 'global' => array
+ 'write' => true,
+ ),
+ 'global'
=> array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'read' => true,
- 'write' => true,
- 'create' => true,
- 'delete' => true,
- ),
- )
- ),
- $defaultPermissions
+ 'read' => true,
+ 'write' => true,
+ 'create' => true,
+ 'delete' => true,
+ ),
+ )
+ ), $defaultPermissions
);
}
-
+
protected function
get_collection_role_permissions($defaultPermissions)
{
return array_merge(
- array(
- 'global' => array
+ array(
+ 'global' => array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'create' => true,
#means that this role may create new objects of the present type
- 'delete' => true,
- ),
+ 'create' => true, #means that
this role may create new objects of the present type
+ 'delete' => true,
),
),
- $defaultPermissions
+ ), $defaultPermissions
);
}
-
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.boactivity.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boactivity.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boactivity.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,14 +1,14 @@
<?php
phpgw::import_class('booking.bocommon_global_manager_authorized');
-
-
+
function node_sort($a, $b)
{
return strcmp($a['name'], $b['name']);
}
-
+
class booking_boactivity extends
booking_bocommon_global_manager_authorized
{
+
function __construct()
{
parent::__construct();
@@ -28,18 +28,20 @@
function fetch_activities($parent_id = 0)
{
- $activities = $this->so->read(array());
- $activities = $activities['results'];
+ $activities = $this->so->read(array());
+ $activities = $activities['results'];
$children = array();
foreach($activities as $activity)
{
- if(!array_key_exists($activity['id'],
$children)) {
- $children[$activity['id']] = array();
+ if(!array_key_exists($activity['id'],
$children))
+ {
+ $children[$activity['id']] = array();
}
- if(!array_key_exists($activity['parent_id'],
$children)) {
- $children[$activity['parent_id']] =
array();
- }
+ if(!array_key_exists($activity['parent_id'],
$children))
+ {
+ $children[$activity['parent_id']] =
array();
+ }
$children[$activity['parent_id']][] = $activity;
}
$result = array();
@@ -67,15 +69,14 @@
public function get_top_level($selected = 0)
{
- $values = $this->so->get_top_level();
+ $values = $this->so->get_top_level();
if($selected)
{
- foreach ($values as $entry)
+ foreach($values as $entry)
{
$entry['selected'] = $entry['id'] ==
$selected ? 1 : 0;
}
}
return $values;
}
-
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,68 +1,76 @@
<?php
phpgw::import_class('booking.bocommon_global_manager_authorized');
-
+
class booking_boagegroup extends
booking_bocommon_global_manager_authorized
{
+
function __construct()
{
parent::__construct();
$this->so = CreateObject('booking.soagegroup');
}
-
+
function fetch_age_groups($top_level_activity = 0)
{
- $filters = array('active'=>'1');
+ $filters = array('active' => '1');
if($top_level_activity)
{
$filters['activity_id'] = $top_level_activity;
}
- return $this->so->read(array('filters'=>$filters,
'sort'=>'sort'));
+ return $this->so->read(array('filters' => $filters,
'sort' => 'sort'));
}
// Extract agegroup info from _POST into $data
public function extract_form_data(&$data)
{
- $one_group_value_found = false;
- $groups_by_ref = array();
-
+ $one_group_value_found = false;
+ $groups_by_ref = array();
+
$sexes = array('male' => 'female', 'female' => 'male');
-
- foreach($sexes as $current_sex => $opposite_sex) {
+
+ foreach($sexes as $current_sex => $opposite_sex)
+ {
foreach($_POST[$current_sex] as $group_id =>
$num)
{
- $found = false;
- $num = (int)$num;
- $num = $num > 0 ? $num : null;
-
- if ($num && $num > 0) {
+ $found = false;
+ $num = (int)$num;
+ $num = $num > 0 ? $num : null;
+
+ if($num && $num > 0)
+ {
$one_group_value_found = true;
}
-
+
foreach($data['agegroups'] as &$group)
{
if($group['agegroup_id'] ==
$group_id)
{
- $found = true;
- $group[$current_sex] =
$num;
-
$groups_by_ref[$group_id] = &$group;
+ $found
= true;
+ $group[$current_sex]
= $num;
+
$groups_by_ref[$group_id] = &$group;
break;
}
}
-
+
if(!$found)
{
- $data['agegroups'][] =
array('agegroup_id' => $group_id, $current_sex => $num, $opposite_sex => null);
- $groups_by_ref[$group_id] =
&$data['agegroups'][count($data['agegroups'])-1];
+ $data['agegroups'][]
= array('agegroup_id' => $group_id, $current_sex => $num,
+ $opposite_sex => null);
+ $groups_by_ref[$group_id]
= &$data['agegroups'][count($data['agegroups']) - 1];
}
}
}
-
- if (!$one_group_value_found) { return $data; }
-
- foreach($groups_by_ref as &$group) {
- foreach($sexes as $current_sex) {
- if (!$group[$current_sex]) {
+
+ if(!$one_group_value_found)
+ { return $data;}
+
+ foreach($groups_by_ref as &$group)
+ {
+ foreach($sexes as $current_sex)
+ {
+ if(!$group[$current_sex])
+ {
$group[$current_sex] = 0;
}
}
@@ -70,4 +78,4 @@
return $data;
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.boallocation.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boallocation.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boallocation.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,281 +1,290 @@
<?php
phpgw::import_class('booking.bocommon_authorized');
-
+
class booking_boallocation extends booking_bocommon_authorized
{
+
function __construct()
{
parent::__construct();
$this->so = CreateObject('booking.soallocation');
}
-
+
/**
* @ Send message about cancelation to users of building.
*/
function send_notification($allocation, $maildata,
$mailadresses)
{
- if
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
return;
$send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config','booking');
+ $config = CreateObject('phpgwapi.config', 'booking');
$config->read();
$from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
$external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
- if($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on')
- {
- $res_names = '';
- foreach ($allocation['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
+ if($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on')
+ {
+ $res_names = '';
+ foreach($allocation['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
}
- $info_deleted = ':<p>';
- $info_deleted = $info_deleted."".$res_names." -
";
- $info_deleted .= pretty_timestamp($allocation['from_'])." - ";
- $info_deleted .= pretty_timestamp($allocation['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
- $link .=
urlencode($allocation['from_']).'&to_[]='.urlencode($allocation['to_']).'&resource='.$allocation['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ $info_deleted = ':<p>';
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $allocation['building_id'] .
'&building_name=' . urlencode($allocation['building_name']) . '&from_[]=';
+ $link .= urlencode($allocation['from_']) .
'&to_[]=' . urlencode($allocation['to_']) . '&resource=' .
$allocation['resources'][0];
+ $info_deleted .= ' - <a href="' . $link . '">'
. lang('Apply for time') . '</a><br />';
- $subject =
$config->config_data['allocation_canceled_mail_subject'];
- $body = "<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
- $body .= $info_deleted.'</p>';
-
- } else {
- $res_names = '';
- foreach ($allocation['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' .
$allocation['organization_name'] . ' har avbestilt tid i ' .
$allocation['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ else
+ {
+ $res_names = '';
+ foreach($allocation['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
}
$info_deleted = ':<p>';
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted =
$info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$allocation['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ foreach($maildata['delete'] as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $allocation['building_id'] .
'&building_name=' . urlencode($allocation['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $allocation['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
}
- $subject =
$config->config_data['allocation_canceled_mail_subject'];
- $body = "<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
- $body .= $info_deleted.'</p>';
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' .
$allocation['organization_name'] . ' har avbestilt tid i ' .
$allocation['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
- }
+ $body .= "<p>" .
$config->config_data['application_mail_signature'] . "</p>";
- $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
-
- foreach ($mailadresses as $adr)
- {
- try
- {
- $send->msg('email', $adr, $subject, $body,
'', '', '', $from, '', 'html');
- }
- catch (phpmailerException $e)
- {
- // TODO: Inform user if something goes wrong
- }
- }
-
+ foreach($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject,
$body, '', '', '', $from, '', 'html');
+ }
+ catch(phpmailerException $e)
+ {
+ // TODO: Inform user if something goes
wrong
+ }
+ }
}
- function send_admin_notification($allocation, $maildata,
$system_message)
- {
- if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
- return;
- $send = CreateObject('phpgwapi.send');
+ function send_admin_notification($allocation, $maildata,
$system_message)
+ {
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+ return;
+ $send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config','booking');
- $config->read();
+ $config = CreateObject('phpgwapi.config', 'booking');
+ $config->read();
- $mailadresses = $config->config_data['emails'];
- $mailadresses = explode("\n",$mailadresses);
+ $mailadresses = $config->config_data['emails'];
+ $mailadresses = explode("\n", $mailadresses);
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
- $subject = $system_message['title'];
- $body = '<b>Beksjed fra '.$system_message['name'].'</b><br
/>'.$system_message['message'].'<br /><br /><b>Epost som er sendt til brukere
av Hallen:</b><br />';
+ $subject = $system_message['title'];
+ $body = '<b>Beksjed fra ' . $system_message['name']
. '</b><br />' . $system_message['message'] . '<br /><br /><b>Epost som er
sendt til brukere av Hallen:</b><br />';
- if ($config->config_data['user_can_delete_allocations'] == 'yes') {
- if($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on')
- {
- $res_names = '';
- foreach ($allocation['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
- }
- $info_deleted = ':<p>';
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($allocation['from_'])."
- ";
- $info_deleted .= pretty_timestamp($allocation['to_']);
- $link =
$external_site_address.'/?menuaction=booking.uiapplication.add&building_id=';
- $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
- $link .=
urlencode($allocation['from_']).'&to_[]='.urlencode($allocation['to_']).'&resource='.$allocation['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ if($config->config_data['user_can_delete_allocations']
== 'yes')
+ {
+ if($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on')
+ {
+ $res_names = '';
+ foreach($allocation['resources'] as
$res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
+ }
+ $info_deleted = ':<p>';
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address . '/?menuaction=booking.uiapplication.add&building_id=';
+ $link .= $allocation['building_id'] .
'&building_name=' . urlencode($allocation['building_name']) . '&from_[]=';
+ $link .=
urlencode($allocation['from_']) . '&to_[]=' . urlencode($allocation['to_']) .
'&resource=' . $allocation['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
- $body .=
"<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
- $body .= $info_deleted.'</p>';
+ $body .= "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' .
$allocation['organization_name'] . ' har avbestilt tid i ' .
$allocation['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ else
+ {
+ $res_names = '';
+ foreach($allocation['resources'] as
$res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
+ }
+ $info_deleted = ':<p>';
+ foreach($maildata['delete'] as
$valid_date)
+ {
+ $info_deleted =
$info_deleted . "" . $res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address . '/?menuaction=booking.uiapplication.add&building_id=';
+ $link .=
$allocation['building_id'] . '&building_name=' .
urlencode($allocation['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $allocation['resources'][0];
+ $info_deleted .= ' - <a href="'
. $link . '">' . lang('Apply for time') . '</a><br />';
+ }
- } else {
- $res_names = '';
- foreach ($allocation['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
- }
- $info_deleted = ':<p>';
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .=
pretty_timestamp($valid_date['from_'])." - ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/?menuaction=booking.uiapplication.add&building_id=';
- $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$allocation['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply
for time').'</a><br />';
- }
+ $body .= "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' .
$allocation['organization_name'] . ' har avbestilt tid i ' .
$allocation['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ }
+ else
+ {
+ $body .= "<p>Det er ikke sendt noen beskjed til
brukere.</p>";
+ }
+ $body .= "<p>" .
$config->config_data['application_mail_signature'] . "</p>";
- $body .=
"<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
- $body .= $info_deleted.'</p>';
- }
- } else {
- $body .= "<p>Det er ikke sendt noen beskjed til brukere.</p>";
- }
- $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
+ foreach($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject,
$body, '', '', '', $from, '', 'html');
+ }
+ catch(phpmailerException $e)
+ {
+ // TODO: Inform user if something goes
wrong
+ }
+ }
+ }
- foreach ($mailadresses as $adr)
- {
- try
- {
- $send->msg('email', $adr, $subject, $body, '', '', '',
$from, '', 'html');
- }
- catch (phpmailerException $e)
- {
- // TODO: Inform user if something goes wrong
- }
- }
-
- }
-
-
/**
* @see bocommon_authorized
*/
protected function include_subject_parent_roles(array
$for_object = null)
{
$this->season_bo = CreateObject('booking.boseason');
- $parent_roles = null;
- $parent_season = null;
-
- if (is_array($for_object)) {
- if (!isset($for_object['season_id'])) {
+ $parent_roles = null;
+ $parent_season = null;
+
+ if(is_array($for_object))
+ {
+ if(!isset($for_object['season_id']))
+ {
throw new
InvalidArgumentException('Cannot initialize object parent roles unless
season_id is provided');
}
$parent_season =
$this->season_bo->read_single($for_object['season_id']);
}
-
+
//Note that a null value for $parent_season is
acceptable. That only signifies
//that any roles specified for any season are returned
instead of roles for a specific season.
$parent_roles['season'] =
$this->season_bo->get_subject_roles($parent_season);
return $parent_roles;
}
-
-
+
/**
* @see bocommon_authorized
*/
protected function get_object_role_permissions(array
$forObject, $defaultPermissions)
{
return array_merge(
- array
+ array
(
- 'parent_role_permissions' => array
+ 'parent_role_permissions' => array
(
- 'season' => array
+ 'season' => array
(
-
booking_sopermission::ROLE_MANAGER => array(
- 'write' => true,
- 'create' =>
true,
+
booking_sopermission::ROLE_MANAGER => array(
+ 'write' => true,
+ 'create' => true,
+ ),
+
booking_sopermission::ROLE_CASE_OFFICER => array(
+ 'write' => true,
+ 'create' => true,
+ ),
+ 'parent_role_permissions'
=> array(
+ 'building' => array(
+
booking_sopermission::ROLE_MANAGER => array(
+ 'write'
=> true,
+
'create' => true,
+ ),
),
-
booking_sopermission::ROLE_CASE_OFFICER => array(
- 'write' => true,
- 'create' =>
true,
- ),
-
'parent_role_permissions' => array(
- 'building' =>
array(
-
booking_sopermission::ROLE_MANAGER => array(
-
'write' => true,
-
'create' => true,
- ),
- ),
- )
- ),
+ )
),
- 'global' => array
+ ),
+ 'global'
=> array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'write' => true,
- 'delete' => true,
- 'create' => true
- ),
+ 'write' => true,
+ 'delete' => true,
+ 'create' => true
),
),
- $defaultPermissions
+ ), $defaultPermissions
);
}
-
+
/**
* @see bocommon_authorized
*/
protected function
get_collection_role_permissions($defaultPermissions)
{
return array_merge(
- array
+ array
(
- 'parent_role_permissions' => array
+ 'parent_role_permissions' => array
(
- 'season' => array
+ 'season' => array
(
-
booking_sopermission::ROLE_MANAGER => array(
- 'create' =>
true,
+
booking_sopermission::ROLE_MANAGER => array(
+ 'create' => true,
+ ),
+
booking_sopermission::ROLE_CASE_OFFICER => array(
+ 'create' => true,
+ ),
+ 'parent_role_permissions'
=> array(
+ 'building' => array(
+
booking_sopermission::ROLE_MANAGER => array(
+
'create' => true,
+ ),
),
-
booking_sopermission::ROLE_CASE_OFFICER => array(
- 'create' =>
true,
- ),
-
'parent_role_permissions' => array(
- 'building' =>
array(
-
booking_sopermission::ROLE_MANAGER => array(
-
'create' => true,
- ),
- ),
- )
)
- ),
- 'global' => array
+ )
+ ),
+ 'global'
=> array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'create' => true
- )
- ),
+ 'create' => true
+ )
),
- $defaultPermissions
+ ), $defaultPermissions
);
}
-
- public function complete_expired(&$allocations) {
+
+ public function complete_expired(&$allocations)
+ {
$this->so->complete_expired($allocations);
}
-
- public function find_expired() {
+
+ public function find_expired()
+ {
return $this->so->find_expired();
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.boapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boapplication.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boapplication.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -3,48 +3,53 @@
class booking_boapplication extends booking_bocommon
{
+
function __construct()
{
parent::__construct();
- $this->activity_bo = CreateObject('booking.boactivity');
- $this->organization_bo = CreateObject('booking.boorganization');
- $this->so = CreateObject('booking.soapplication');
+ $this->activity_bo =
CreateObject('booking.boactivity');
+ $this->organization_bo =
CreateObject('booking.boorganization');
+ $this->so =
CreateObject('booking.soapplication');
}
- function send_notification($application, $created=false,
$assocciated=false)
+ function send_notification($application, $created = false,
$assocciated = false)
{
- if
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
return;
$send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config','booking');
+ $config =
CreateObject('phpgwapi.config', 'booking');
$config->read();
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $from =
isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
$subject =
$config->config_data['application_mail_subject'];
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.show&id='.$application['id'].'&secret='.$application['secret'];
+ $link = $external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.show&id=' .
$application['id'] . '&secret=' . $application['secret'];
- if ($created) {
- $body =
"<pre>".$config->config_data['application_mail_created']."</pre>";
- $body .= '<p><a href="'.$link.'">Link til
'.$config->config_data['application_mail_systemname'].': søknad
#'.$application['id'].'</a></p>';
-
- } elseif ($application['status'] == 'PENDING') {
- $body = "<p>Din søknad i
".$config->config_data['application_mail_systemname']." om leie/lån er
".lang($application['status']) . '</p>';
- if ($application['comment'] != '') {
- $body .= '<p>Kommentar fra
saksbehandler:<br />'.$application['comment'].'</p>';
+ if($created)
+ {
+ $body = "<pre>" .
$config->config_data['application_mail_created'] . "</pre>";
+ $body .= '<p><a href="' . $link . '">Link til '
. $config->config_data['application_mail_systemname'] . ': søknad #' .
$application['id'] . '</a></p>';
+ }
+ elseif($application['status'] == 'PENDING')
+ {
+ $body = "<p>Din søknad i " .
$config->config_data['application_mail_systemname'] . " om leie/lån er " .
lang($application['status']) . '</p>';
+ if($application['comment'] != '')
+ {
+ $body .= '<p>Kommentar fra
saksbehandler:<br />' . $application['comment'] . '</p>';
}
- $body .=
"<pre>".$config->config_data['application_mail_pending']."</pre>";
- $body .= '<p><a href="'.$link.'">Link til
'.$config->config_data['application_mail_systemname'].': søknad
#'.$application['id'].'</a></p>';
+ $body .= "<pre>" .
$config->config_data['application_mail_pending'] . "</pre>";
+ $body .= '<p><a href="' . $link . '">Link til '
. $config->config_data['application_mail_systemname'] . ': søknad #' .
$application['id'] . '</a></p>';
}
- elseif ($application['status'] == 'ACCEPTED')
+ elseif($application['status'] == 'ACCEPTED')
{
// Sigurd:
// Check if any bookings, allocations or events
are associated with this application
- $assoc_bo = new
booking_boapplication_association();
- $associations =
$assoc_bo->so->read(array('filters'=>array('application_id'=>$application['id']),'sort'=>'from_',
'dir' => 'asc'));
- $_adates = array();
+ $assoc_bo = new
booking_boapplication_association();
+ $associations =
$assoc_bo->so->read(array('filters' => array('application_id' =>
$application['id']),
+ 'sort' => 'from_', 'dir' => 'asc'));
+ $_adates = array();
foreach($associations['results'] as $assoc)
{
@@ -54,174 +59,182 @@
}
}
- $adates = implode("\n",$_adates);
+ $adates = implode("\n", $_adates);
//FIXME Sigurd 2. sept 2015: Something wrong
with this one;
// $rejected =
$this->so->get_rejected($application['id']);
- $rejected = array();
- $rdates = "";
- foreach ($rejected as $key => $date)
+ $rejected = array();
+ $rdates = "";
+ foreach($rejected as $key => $date)
{
if($key === 0)
{
- $rdates .= implode(" -
",$date)."\n";
+ $rdates .= implode(" - ",
$date) . "\n";
}
else
{
- $rdates .= "\t".implode(" -
",$date)."\n";
+ $rdates .= "\t" . implode(" -
", $date) . "\n";
}
}
- $body = "<p>Din søknad i
".$config->config_data['application_mail_systemname']." om leie/lån er
".lang($application['status']) . '</p>';
- if ($application['comment'] != '') {
- $body .= "<p>Kommentar fra
saksbehandler:<br />".$application['comment']."</p>";
+ $body = "<p>Din søknad i " .
$config->config_data['application_mail_systemname'] . " om leie/lån er " .
lang($application['status']) . '</p>';
+ if($application['comment'] != '')
+ {
+ $body .= "<p>Kommentar fra
saksbehandler:<br />" . $application['comment'] . "</p>";
}
- $body .=
'<pre>'.$config->config_data['application_mail_accepted'].'<br /><a
href="'.$link.'">Link til
'.$config->config_data['application_mail_systemname'].': søknad
#'.$application['id'].'</a></pre>';
+ $body .= '<pre>' .
$config->config_data['application_mail_accepted'] . '<br /><a href="' . $link .
'">Link til ' . $config->config_data['application_mail_systemname'] . ': søknad
#' . $application['id'] . '</a></pre>';
if($adates)
{
- $body .=
"<pre>Godkjent:\n".$adates."</pre>";
+ $body .= "<pre>Godkjent:\n" . $adates .
"</pre>";
}
if($rdates)
{
- $body .= "<pre>Avvist:
".$rdates."</pre>";
+ $body .= "<pre>Avvist: " . $rdates .
"</pre>";
}
- if (isset
($config->config_data['application_notify_on_accepted']) &&
$config->config_data['application_notify_on_accepted'] ==1)
+
if(isset($config->config_data['application_notify_on_accepted']) &&
$config->config_data['application_notify_on_accepted'] == 1)
{
$buildingemail =
$this->get_tilsyn_email($application['building_name']);
- if ($buildingemail['email1'] != '' ||
$buildingemail['email2'] != '' || $buildingemail['email3'] != '') {
- $resourcename =
implode(",",$this->get_resource_name($application['resources']));
- $bsubject =
$config->config_data['application_mail_subject'].": En søknad om leie/lån av
".$resourcename." på ".$application['building_name']." er godkjent";
- $bbody =
"<p>".$application['contact_name']." sin søknad om leie/lån av
".$resourcename." på ".$application['building_name']."</p>";
+ if($buildingemail['email1'] != '' ||
$buildingemail['email2'] != '' || $buildingemail['email3'] != '')
+ {
+ $resourcename = implode(",",
$this->get_resource_name($application['resources']));
+ $bsubject =
$config->config_data['application_mail_subject'] . ": En søknad om leie/lån av
" . $resourcename . " på " . $application['building_name'] . " er godkjent";
+ $bbody =
"<p>" . $application['contact_name'] . " sin søknad om leie/lån av " .
$resourcename . " på " . $application['building_name'] . "</p>";
// $bbody .= "<p>Den ".$adates."er
Godkjent</p>";
if($adates)
{
- $body .=
"<pre>Godkjent:\n".$adates."</pre>";
+ $body .=
"<pre>Godkjent:\n" . $adates . "</pre>";
}
- $bbody .=
"<p><b>{$config->config_data['application_equipment']}:</b><br
/>".$application['equipment']."</p>";
+ $bbody .=
"<p><b>{$config->config_data['application_equipment']}:</b><br />" .
$application['equipment'] . "</p>";
- foreach ($buildingemail as
$bemail)
+ foreach($buildingemail as
$bemail)
{
try
{
$send->msg('email', $bemail, $bsubject, $bbody, '', '', '', $from, '', 'html');
}
- catch
(phpmailerException $e)
+
catch(phpmailerException $e)
{
- // TODO: Inform user if
something goes wrong
+ // TODO: Inform
user if something goes wrong
}
-
}
}
}
- } elseif ($application['status'] == 'REJECTED') {
- $body = "<p>Din søknad i
".$config->config_data['application_mail_systemname']." om leie/lån er
".lang($application['status']) . '</p>';
- if ($application['comment'] != '') {
- $body .= '<p>Kommentar fra
saksbehandler:<br />'.$application['comment'].'</p>';
+ }
+ elseif($application['status'] == 'REJECTED')
+ {
+ $body = "<p>Din søknad i " .
$config->config_data['application_mail_systemname'] . " om leie/lån er " .
lang($application['status']) . '</p>';
+ if($application['comment'] != '')
+ {
+ $body .= '<p>Kommentar fra
saksbehandler:<br />' . $application['comment'] . '</p>';
}
- $body .=
'<pre>'.$config->config_data['application_mail_rejected'].' <a
href="'.$link.'">Link til
'.$config->config_data['application_mail_systemname'].': søknad
#'.$application['id'].'</a></pre>';
- } else {
- $subject =
$config->config_data['application_comment_mail_subject'];
- $body =
"<pre><p>".$config->config_data['application_comment_added_mail']."</p>";
- $body .= '<p>Kommentar fra saksbehandler:<br
/>'.$application['comment'].'</p></pre>';
- $body .= '<p><a href="'.$link.'">Link til
'.$config->config_data['application_mail_systemname'].': søknad
#'.$application['id'].'</a></p>';
- }
- $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
+ $body .= '<pre>' .
$config->config_data['application_mail_rejected'] . ' <a href="' . $link .
'">Link til ' . $config->config_data['application_mail_systemname'] . ': søknad
#' . $application['id'] . '</a></pre>';
+ }
+ else
+ {
+ $subject =
$config->config_data['application_comment_mail_subject'];
+ $body = "<pre><p>" .
$config->config_data['application_comment_added_mail'] . "</p>";
+ $body .= '<p>Kommentar fra saksbehandler:<br
/>' . $application['comment'] . '</p></pre>';
+ $body .= '<p><a href="' . $link . '">Link til '
. $config->config_data['application_mail_systemname'] . ': søknad #' .
$application['id'] . '</a></p>';
+ }
+ $body .= "<p>" .
$config->config_data['application_mail_signature'] . "</p>";
try
{
$send->msg('email',
$application['contact_email'], $subject, $body, '', '', '', $from, '', 'html');
}
- catch (phpmailerException $e)
+ catch(phpmailerException $e)
{
// TODO: Inform user if something goes wrong
}
}
- /**
- * @ Send message about comment on application to case officer.
- */
- function send_admin_notification($application, $message = null)
- {
- if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
- return;
- $send = CreateObject('phpgwapi.send');
+ /**
+ * @ Send message about comment on application to case officer.
+ */
+ function send_admin_notification($application, $message = null)
+ {
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+ return;
+ $send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config', 'booking');
- $config->read();
+ $config = CreateObject('phpgwapi.config', 'booking');
+ $config->read();
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
- $subject =
$config->config_data['application_comment_mail_subject_caseofficer'];
+ $subject =
$config->config_data['application_comment_mail_subject_caseofficer'];
- $mailadresses = $config->config_data['emails'];
- $mailadresses = explode("\n", $mailadresses);
+ $mailadresses = $config->config_data['emails'];
+ $mailadresses = explode("\n", $mailadresses);
- if ($GLOBALS['phpgw_info']['server']['webserver_url'] != '' &&
isset($config->config_data['external_site_address']))
- $link = $external_site_address .
$GLOBALS['phpgw_info']['server']['webserver_url'] .
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
- else
- $link = $external_site_address .
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
+ if($GLOBALS['phpgw_info']['server']['webserver_url'] !=
'' && isset($config->config_data['external_site_address']))
+ $link = $external_site_address .
$GLOBALS['phpgw_info']['server']['webserver_url'] .
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
+ else
+ $link = $external_site_address .
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
- $activity =
$this->activity_bo->read_single($application['activity_id']);
+ $activity =
$this->activity_bo->read_single($application['activity_id']);
- if (strlen($application['customer_organization_number']) == 9) {
- $orgid =
$this->organization_bo->so->get_orgid($application['customer_organization_number']);
- $organization = $this->organization_bo->read_single($orgid);
- $body = '<b>Kommentar fra ' . $organization['name'] . '</b><br
/>' . $message . '<br /><br/>';
- } else {
- $body = '<b>Kommentar fra
'.$application['contact_name'].'</b><br />'.$message.'<br /><br/>';
- }
+ if(strlen($application['customer_organization_number'])
== 9)
+ {
+ $orgid =
$this->organization_bo->so->get_orgid($application['customer_organization_number']);
+ $organization =
$this->organization_bo->read_single($orgid);
+ $body = '<b>Kommentar fra '
. $organization['name'] . '</b><br />' . $message . '<br /><br/>';
+ }
+ else
+ {
+ $body = '<b>Kommentar fra ' .
$application['contact_name'] . '</b><br />' . $message . '<br /><br/>';
+ }
- $body .= '<b>Bygg: </b>'.$application['building_name'].'<br />';
- $body .= '<b>Aktivitet: </b>'.$activity['name'].'<br /><br />';
- $body .= '<b>Kontaktperson:</b>
'.$application['contact_name'].'<br />';
- $body .= '<b>Epost:</b> '.$application['contact_email'].'<br />';
- $body .= '<b>Telefon:</b> '.$application['contact_phone'].'<br
/><br />';
- $body .= '<a href="'.$link.'">Lenke til søknad</a><br /><br />';
+ $body .= '<b>Bygg: </b>' .
$application['building_name'] . '<br />';
+ $body .= '<b>Aktivitet: </b>' . $activity['name'] .
'<br /><br />';
+ $body .= '<b>Kontaktperson:</b> ' .
$application['contact_name'] . '<br />';
+ $body .= '<b>Epost:</b> ' .
$application['contact_email'] . '<br />';
+ $body .= '<b>Telefon:</b> ' .
$application['contact_phone'] . '<br /><br />';
+ $body .= '<a href="' . $link . '">Lenke til
søknad</a><br /><br />';
- foreach ($mailadresses as $adr)
- {
- try
- {
- $send->msg('email', $adr, $subject, $body, '', '', '',
$from, '', 'html');
- }
- catch (phpmailerException $e)
- {
- // TODO: Inform user if something goes wrong
- }
- }
- }
+ foreach($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject,
$body, '', '', '', $from, '', 'html');
+ }
+ catch(phpmailerException $e)
+ {
+ // TODO: Inform user if something goes
wrong
+ }
+ }
+ }
-
- /**
- * Returns an array of application ids from applications
assocciated with buildings
- * which the given user has access to
- *
- * @param int $user_id
- */
+ /**
+ * Returns an array of application ids from applications
assocciated with buildings
+ * which the given user has access to
+ *
+ * @param int $user_id
+ */
public function accessable_applications($user_id)
{
- $applications = array();
- $this->db = & $GLOBALS['phpgw']->db;
+ $applications = array();
+ $this->db = & $GLOBALS['phpgw']->db;
# $sql = "select distinct ap.id
# from bb_application ap
# inner join bb_application_resource ar
on ar.application_id = ap.id
# inner join bb_resource re on re.id =
ar.resource_id
# inner join bb_building bu on bu.id =
re.building_id";
- $sql = "select distinct ap.id
+ $sql = "select distinct ap.id
from bb_application ap
inner join bb_application_resource ar
on ar.application_id = ap.id
inner join bb_resource re on re.id =
ar.resource_id
inner join bb_building bu on bu.id =
re.building_id
inner join bb_permission pe on
pe.object_id = bu.id and pe.object_type = 'building'
- where pe.subject_id = ".$user_id;
+ where pe.subject_id = " . $user_id;
$this->db->query($sql);
- $result = $this->db->resultSet;
+ $result = $this->db->resultSet;
foreach($result as $r)
{
@@ -231,35 +244,42 @@
return $applications;
}
- public function read_dashboard_data($for_case_officer_id =
array(null,null)) {
+ public function read_dashboard_data($for_case_officer_id =
array(null, null))
+ {
$params = $this->build_default_read_params();
- if (!isset($params['filters'])) $params['filters'] =
array();
- $where_clauses = !isset($params['filters']['where']) ?
array() : (array)$params['filters']['where'];
+ if(!isset($params['filters']))
+ $params['filters'] = array();
+ $where_clauses =
!isset($params['filters']['where']) ? array() :
(array)$params['filters']['where'];
- if (!is_null($for_case_officer_id[0])) {
- $where_clauses[] =
"(%%table%%.display_in_dashboard = 1 AND %%table%%.case_officer_id =
".intval($for_case_officer_id[1]).')';
- } else {
- $where_clauses[] = "(%%table%%.case_officer_id
= ".intval($for_case_officer_id[1]).')';
+ if(!is_null($for_case_officer_id[0]))
+ {
+ $where_clauses[] =
"(%%table%%.display_in_dashboard = 1 AND %%table%%.case_officer_id = " .
intval($for_case_officer_id[1]) . ')';
}
+ else
+ {
+ $where_clauses[] = "(%%table%%.case_officer_id
= " . intval($for_case_officer_id[1]) . ')';
+ }
- if ($building_id = phpgw::get_var('filter_building_id',
'int', 'REQUEST', 0)) {
- $where_clauses[] = "(%%table%%.id IN (SELECT
DISTINCT a.id FROM bb_application a, bb_application_resource ar, bb_resource r
WHERE ar.application_id = a.id AND ar.resource_id = r.id AND r.building_id =
".intval($building_id)."))";
+ if($building_id = phpgw::get_var('filter_building_id',
'int', 'REQUEST', 0))
+ {
+ $where_clauses[] = "(%%table%%.id IN (SELECT
DISTINCT a.id FROM bb_application a, bb_application_resource ar, bb_resource r
WHERE ar.application_id = a.id AND ar.resource_id = r.id AND r.building_id = "
. intval($building_id) . "))";
}
- if ( $status = phpgw::get_var('status') != '') {
- $params['filters']['status'] = phpgw::get_var('status');
+ if($status = phpgw::get_var('status') != '')
+ {
+ $params['filters']['status'] =
phpgw::get_var('status');
}
$params['filters']['where'] = $where_clauses;
return $this->so->read($params);
}
-
}
class booking_boapplication_association extends booking_bocommon
{
+
function __construct()
{
parent::__construct();
Modified: branches/dev-syncromind/booking/inc/class.boasync_settings.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boasync_settings.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boasync_settings.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,25 +1,25 @@
<?php
//phpgw::import_class('booking.bocommon_authorized');
phpgw::import_class('booking.async_task');
-
- class booking_boasync_settings
+
+ class booking_boasync_settings
{
+
function __construct()
{
#parent::__construct();
-
- if ( !isset($GLOBALS['phpgw']->asyncservice)
- || !is_object($GLOBALS['phpgw']->asyncservice) )
+
+ if(!isset($GLOBALS['phpgw']->asyncservice) ||
!is_object($GLOBALS['phpgw']->asyncservice))
{
$GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
}
}
-
+
protected function current_account_member_of_admins()
{
return
booking_account_helper::current_account_member_of_admins();
}
-
+
/**
* Providing no id to this method results in that authorization
* is performed for the collection. If the 'object' is provided,
@@ -33,51 +33,60 @@
*/
protected function authorize($operation, $object = null)
{
- switch ($operation) {
+ switch($operation)
+ {
case 'read':
return true;
case 'write':
- if
($this->current_account_member_of_admins()) {
+
if($this->current_account_member_of_admins())
+ {
return true;
}
default:
throw new
booking_unauthorized_exception($operation, sprintf('Operation \'%s\' was denied
on %s', $operation, get_class($this)));
}
}
-
- function read() {
+
+ function read()
+ {
$this->authorize('read');
-
+
$settings = array();
-
- foreach (booking_async_task::getAvailableTasks() as
$task_class) {
- $task = booking_async_task::create($task_class);
- $settings[str_replace('.', '_',
"{$task_class}_enabled")] = $task->is_enabled();
+
+ foreach(booking_async_task::getAvailableTasks() as
$task_class)
+ {
+ $task
=
booking_async_task::create($task_class);
+ $settings[str_replace('.', '_',
"{$task_class}_enabled")] = $task->is_enabled();
}
-
+
$settings['permission'] = $this->get_permissions();
-
+
return $settings;
}
-
- function update($settings) {
+
+ function update($settings)
+ {
$this->authorize('write', $settings);
- foreach (booking_async_task::getAvailableTasks() as
$task_class) {
+ foreach(booking_async_task::getAvailableTasks() as
$task_class)
+ {
$task = booking_async_task::create($task_class);
$task->disable();
-
- if ($settings[str_replace('.', '_',
"{$task_class}_enabled")] === true) {
+
+ if($settings[str_replace('.', '_',
"{$task_class}_enabled")] === true)
+ {
$task->enable();
}
}
}
-
- public function get_permissions() {
+
+ public function get_permissions()
+ {
$permission = array('read' => true);
- if ($this->current_account_member_of_admins()) {
+ if($this->current_account_member_of_admins())
+ {
$permission['write'] = true;
}
-
+
return $permission;
}
}
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.boaudience.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boaudience.inc.php
2015-12-10 12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.boaudience.inc.php
2015-12-10 12:56:18 UTC (rev 14558)
@@ -1,14 +1,15 @@
<?php
phpgw::import_class('booking.bocommon_global_manager_authorized');
-
+
class booking_boaudience extends
booking_bocommon_global_manager_authorized
- {
+ {
+
function __construct()
{
parent::__construct();
$this->so = CreateObject('booking.soaudience');
}
-
+
public function set_active_session()
{
$_SESSION['ActiveSession'] = "ShowAll";
@@ -21,12 +22,12 @@
function fetch_target_audience($top_level_activity = 0)
{
- $filters = array('active'=>'1');
+ $filters = array('active' => '1');
if($top_level_activity)
{
$filters['activity_id'] = $top_level_activity;
}
- return $this->so->read(array('filters'=>$filters,
'sort'=>'sort'));
+ return $this->so->read(array('filters' => $filters,
'sort' => 'sort'));
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.bobooking.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.bobooking.inc.php 2015-12-10
12:55:36 UTC (rev 14557)
+++ branches/dev-syncromind/booking/inc/class.bobooking.inc.php 2015-12-10
12:56:18 UTC (rev 14558)
@@ -1,45 +1,45 @@
<?php
phpgw::import_class('booking.bocommon_authorized');
-
+
require_once "schedule.php";
-function array_minus($a, $b)
-{
- $b = array_flip($b);
- $c = array();
- foreach($a as $x)
+ function array_minus($a, $b)
{
- if(!array_key_exists($x, $b))
- $c[] = $x;
+ $b = array_flip($b);
+ $c = array();
+ foreach($a as $x)
+ {
+ if(!array_key_exists($x, $b))
+ $c[] = $x;
+ }
+ return $c;
}
- return $c;
-}
-
class booking_bobooking extends booking_bocommon_authorized
{
+
const ROLE_ADMIN = 'organization_admin';
function __construct()
{
parent::__construct();
- $this->so = CreateObject('booking.sobooking');
+ $this->so =
CreateObject('booking.sobooking');
$this->allocation_so =
CreateObject('booking.soallocation');
- $this->resource_so = CreateObject('booking.soresource');
- $this->event_so = CreateObject('booking.soevent');
- $this->season_bo = CreateObject('booking.boseason');
+ $this->resource_so =
CreateObject('booking.soresource');
+ $this->event_so =
CreateObject('booking.soevent');
+ $this->season_bo =
CreateObject('booking.boseason');
}
/**
* @ Send message about cancelation to users of building.
*/
- function send_notification($booking, $allocation, $maildata,
$mailadresses, $valid_dates=null)
+ function send_notification($booking, $allocation, $maildata,
$mailadresses, $valid_dates = null)
{
- if
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
return;
$send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config','booking');
+ $config = CreateObject('phpgwapi.config', 'booking');
$config->read();
$from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
@@ -47,242 +47,265 @@
$external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
- if(($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] != 'on') ||
- ($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] == 'on' &&
- $maildata['allocation'] == 0))
- {
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($booking['from_']).'&to_[]='.urlencode($booking['to_']).'&resource='.$booking['resources'][0];
+ if(($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on' && $maildata['delete_allocation'] != 'on') ||
+ ($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on' && $maildata['delete_allocation'] == 'on' &&
+ $maildata['allocation'] == 0))
+ {
+ $link = $external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']) . '&from_[]=';
+ $link .= urlencode($booking['from_']) .
'&to_[]=' . urlencode($booking['to_']) . '&resource=' .
$booking['resources'][0];
- $subject =
$config->config_data['booking_canceled_mail_subject'];
+ $subject =
$config->config_data['booking_canceled_mail_subject'];
- $body = "<p>".$config->config_data['booking_canceled_mail'];
- $body .= '</p><p>'.$booking['group_name'].' har avbestilt tid
i '.$booking['building_name'].':<br />';
- $body .= $this->so->get_resource($booking['resources'][0]).'
den '.pretty_timestamp($booking['from_']);
- $body .=' til '.pretty_timestamp($booking['to_']);
- $body .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a></p>';
-
- } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
+ $body = "<p>" .
$config->config_data['booking_canceled_mail'];
+ $body .= '</p><p>' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'] . ':<br />';
+ $body .=
$this->so->get_resource($booking['resources'][0]) . ' den ' .
pretty_timestamp($booking['from_']);
+ $body .=' til ' .
pretty_timestamp($booking['to_']);
+ $body .= ' - <a href="' . $link . '">' .
lang('Apply for time') . '</a></p>';
+ }
+ elseif(($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on')
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
}
$info_deleted = ':<p>';
- foreach ($valid_dates as $valid_date) {
- $info_deleted = $info_deleted."".$res_names." -
";
- $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
- $link .=
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ foreach($valid_dates as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']);
+ $link .= '&from_[]=' .
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
}
- $subject =
$config->config_data['booking_canceled_mail_subject'];
+ $subject =
$config->config_data['booking_canceled_mail_subject'];
- $body = "<p>".$config->config_data['booking_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
-
- } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
+ $body = "<p>" .
$config->config_data['booking_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ elseif(($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on')
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
}
$info_deleted = ':<p>';
- foreach ($valid_dates as $valid_date) {
- if (!in_array($valid_date,$maildata['delete'])) {
- $info_deleted =
$info_deleted."".$res_names." - ";
- $info_deleted .=
pretty_timestamp($valid_date['from_'])." - ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply
for time').'</a><br />';
- }
+ foreach($valid_dates as $valid_date)
+ {
+ if(!in_array($valid_date,
$maildata['delete']))
+ {
+ $info_deleted =
$info_deleted . "" . $res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'] . '&building_name=' .
urlencode($booking['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="'
. $link . '">' . lang('Apply for time') . '</a><br />';
+ }
}
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted =
$info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ foreach($maildata['delete'] as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
}
-
- $subject =
$config->config_data['allocation_canceled_mail_subject'];
- $body = "<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
- } else {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names =
$res_names.$this->so->get_resource($res)." ";
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ else
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
}
$info_deleted = ':<p>';
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted =
$info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($allocation['from_'])."
- ";
- $info_deleted .= pretty_timestamp($allocation['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
- }
- $subject =
$config->config_data['allocation_canceled_mail_subject'];
- $body = "<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
- }
+ foreach($maildata['delete'] as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
+ }
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
- $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
-
- foreach ($mailadresses as $adr)
- {
- try
- {
- $send->msg('email', $adr, $subject, $body,
'', '', '', $from, '', 'html');
- }
- catch (phpmailerException $e)
- {
- // TODO: Inform user if something goes wrong
- }
- }
+ $body .= "<p>" .
$config->config_data['application_mail_signature'] . "</p>";
+
+ foreach($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject,
$body, '', '', '', $from, '', 'html');
+ }
+ catch(phpmailerException $e)
+ {
+ // TODO: Inform user if something goes
wrong
+ }
+ }
}
- function send_admin_notification($booking, $maildata, $system_message,
$allocation, $valid_dates=null)
- {
- if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
- return;
- $send = CreateObject('phpgwapi.send');
+ function send_admin_notification($booking, $maildata,
$system_message, $allocation, $valid_dates = null)
+ {
+
if(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+ return;
+ $send = CreateObject('phpgwapi.send');
- $config = CreateObject('phpgwapi.config','booking');
- $config->read();
+ $config = CreateObject('phpgwapi.config', 'booking');
+ $config->read();
- $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
- $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
- $subject = $system_message['title'];
- $body = '<b>Beskjed fra '.$system_message['name'].'</b><br
/>'.$system_message['message'].'<br /><br /><b>Epost som er sendt til brukere
av Hallen:</b><br />';
- $mailadresses = $config->config_data['emails'];
- $mailadresses = explode("\n",$mailadresses);
+ $subject = $system_message['title'];
+ $body = '<b>Beskjed fra ' .
$system_message['name'] . '</b><br />' . $system_message['message'] . '<br
/><br /><b>Epost som er sendt til brukere av Hallen:</b><br />';
+ $mailadresses = $config->config_data['emails'];
+ $mailadresses = explode("\n", $mailadresses);
- if(($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] != 'on') ||
- ($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] == 'on' &&
- $maildata['allocation'] == 0))
- {
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($booking['from_']).'&to_[]='.urlencode($booking['to_']).'&resource='.$booking['resources'][0];
+ if(($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on' && $maildata['delete_allocation'] != 'on') ||
+ ($maildata['outseason'] != 'on' &&
$maildata['recurring'] != 'on' && $maildata['delete_allocation'] == 'on' &&
+ $maildata['allocation'] == 0))
+ {
+ $link = $external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']) . '&from_[]=';
+ $link .= urlencode($booking['from_']) .
'&to_[]=' . urlencode($booking['to_']) . '&resource=' .
$booking['resources'][0];
- $body .= "<p>".$config->config_data['booking_canceled_mail'];
- $body .= '</p><p>'.$booking['group_name'].' har avbestilt tid
i '.$booking['building_name'].':<br />';
- $body .= $this->so->get_resource($booking['resources'][0]).'
den '.pretty_timestamp($booking['from_']);
- $body .=' til '.pretty_timestamp($booking['to_']);
- $body .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a></p>';
+ $body .= "<p>" .
$config->config_data['booking_canceled_mail'];
+ $body .= '</p><p>' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'] . ':<br />';
+ $body .=
$this->so->get_resource($booking['resources'][0]) . ' den ' .
pretty_timestamp($booking['from_']);
+ $body .=' til ' .
pretty_timestamp($booking['to_']);
+ $body .= ' - <a href="' . $link . '">' .
lang('Apply for time') . '</a></p>';
+ }
+ elseif(($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on')
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
+ }
+ $info_deleted = ':<p>';
+ foreach($valid_dates as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']);
+ $link .= '&from_[]=' .
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
+ }
- } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names = $res_names.$this->so->get_resource($res)." ";
- }
- $info_deleted = ':<p>';
- foreach ($valid_dates as $valid_date) {
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
- $link .=
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
- }
+ $body .= "<p>" .
$config->config_data['booking_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ elseif(($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on')
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
+ }
+ $info_deleted = ':<p>';
+ foreach($valid_dates as $valid_date)
+ {
+ if(!in_array($valid_date,
$maildata['delete']))
+ {
+ $info_deleted =
$info_deleted . "" . $res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'] . '&building_name=' .
urlencode($booking['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="'
. $link . '">' . lang('Apply for time') . '</a><br />';
+ }
+ }
+ foreach($maildata['delete'] as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']) . '&from_[]=';
+ $link .=
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
+ }
- $body .= "<p>".$config->config_data['booking_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
- } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names = $res_names.$this->so->get_resource($res)." ";
- }
- $info_deleted = ':<p>';
- foreach ($valid_dates as $valid_date) {
- if (!in_array($valid_date,$maildata['delete'])) {
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .=
pretty_timestamp($valid_date['from_'])." - ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply
for time').'</a><br />';
- }
- }
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
- $info_deleted .= pretty_timestamp($valid_date['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
- $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
- }
+ $body .= "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ else
+ {
+ $res_names = '';
+ foreach($booking['resources'] as $res)
+ {
+ $res_names = $res_names .
$this->so->get_resource($res) . " ";
+ }
+ $info_deleted = ':<p>';
+ foreach($maildata['delete'] as $valid_date)
+ {
+ $info_deleted = $info_deleted . "" .
$res_names . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['from_']) . " - ";
+ $info_deleted .=
pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address .
'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .= $booking['building_id'] .
'&building_name=' . urlencode($booking['building_name']);
+ $link .= '&from_[]=' .
urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) .
'&resource=' . $booking['resources'][0];
+ $info_deleted .= ' - <a href="' . $link
. '">' . lang('Apply for time') . '</a><br />';
+ }
+ $body .= "<p>" .
$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />' . $booking['group_name'] . '
har avbestilt tid i ' . $booking['building_name'];
+ $body .= $info_deleted . '</p>';
+ }
+ $body .= "<p>" .
$config->config_data['application_mail_signature'] . "</p>";
+ foreach($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject,
$body, '', '', '', $from, '', 'html');
+ }
+ catch(phpmailerException $e)
+ {
+ // TODO: Inform user if something goes
wrong
+ }
+ }
+ }
- $body .=
"<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
-
- } else {
- $res_names = '';
- foreach ($booking['resources'] as $res) {
- $res_names = $res_names.$this->so->get_resource($res)." ";
- }
- $info_deleted = ':<p>';
- foreach ($maildata['delete'] as $valid_date) {
- $info_deleted = $info_deleted."".$res_names." - ";
- $info_deleted .= pretty_timestamp($allocation['from_'])."
- ";
- $info_deleted .= pretty_timestamp($allocation['to_']);
- $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
- $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
- $link .=
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
- $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
- }
- $body .=
"<p>".$config->config_data['allocation_canceled_mail'];
- $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
- $body .= $info_deleted.'</p>';
- }
-
- $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
- foreach ($mailadresses as $adr)
- {
- try
- {
- $send->msg('email', $adr, $subject, $body, '', '', '',
$from, '', 'html');
- }
- catch (phpmailerException $e)
- {
- // TODO: Inform user if something goes wrong
- }
- }
- }
-
-
/**
* @see bocommon_authorized
*/
protected function include_subject_parent_roles(array
$for_object = null)
{
- $parent_roles = null;
- $parent_season = null;
+ $parent_roles = null;
+ $parent_season = null;
- if (is_array($for_object)) {
- if (!isset($for_object['season_id'])) {
+ if(is_array($for_object))
+ {
+ if(!isset($for_object['season_id']))
+ {
throw new
InvalidArgumentException('Cannot initialize object parent roles unless
season_id is provided');
}
$parent_season =
$this->season_bo->read_single($for_object['season_id']);
@@ -293,120 +316,119 @@
$parent_roles['season'] =
$this->season_bo->get_subject_roles($parent_season);
return $parent_roles;
}
-
-
/**
* @see booking_bocommon_authorized
*/
- protected function get_subject_roles($for_object = null,
$initial_roles=array())
+ protected function get_subject_roles($for_object = null,
$initial_roles = array())
{
- if ($this->current_app() == 'bookingfrontend') {
+ if($this->current_app() == 'bookingfrontend')
+ {
$bouser =
CreateObject('bookingfrontend.bouser');
-
+
$group_id = is_array($for_object) ?
$for_object['group_id'] : (!is_null($for_object) ? $for_object : null);
-
- if ($bouser->is_group_admin($group_id)) {
+
+ if($bouser->is_group_admin($group_id))
+ {
$initial_roles[] = array('role' =>
self::ROLE_ADMIN);
}
}
-
+
return parent::get_subject_roles($for_object,
$initial_roles);
}
-
+
/**
* @see bocommon_authorized
*/
protected function get_object_role_permissions(array
$forObject, $defaultPermissions)
{
- if ($this->current_app() == 'bookingfrontend') {
+ if($this->current_app() == 'bookingfrontend')
+ {
$defaultPermissions[self::ROLE_ADMIN] = array
- (
+ (
'create' => true,
- 'write' => true,
+ 'write' => true,
);
}
return array_merge(
- array
+ array
(
- 'parent_role_permissions' => array
+ 'parent_role_permissions' => array
(
- 'season' => array
+ 'season' => array
(
-
booking_sopermission::ROLE_MANAGER => array(
- 'write' => true,
- 'create' =>
true,
+
booking_sopermission::ROLE_MANAGER => array(
+ 'write' => true,
+ 'create' => true,
+ ),
+
booking_sopermission::ROLE_CASE_OFFICER => array(
+ 'write' => true,
+ 'create' => true,
+ ),
+ 'parent_role_permissions'
=> array(
+ 'building' => array(
+
booking_sopermission::ROLE_MANAGER => array(
+ 'write'
=> true,
+
'create' => true,
+ ),
),
-
booking_sopermission::ROLE_CASE_OFFICER => array(
- 'write' => true,
- 'create' =>
true,
- ),
-
'parent_role_permissions' => array(
- 'building' =>
array(
-
booking_sopermission::ROLE_MANAGER => array(
-
'write' => true,
-
'create' => true,
- ),
- ),
- )
- ),
+ )
),
- 'global' => array
+ ),
+ 'global'
=> array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'write' => true,
- 'delete' => true,
- 'create' => true
- ),
+ 'write' => true,
+ 'delete' => true,
+ 'create' => true
),
),
- $defaultPermissions
+ ), $defaultPermissions
);
}
-
+
/**
* @see bocommon_authorized
*/
protected function
get_collection_role_permissions($defaultPermissions)
{
- if ($this->current_app() == 'bookingfrontend')
+ if($this->current_app() == 'bookingfrontend')
{
-
$defaultPermissions[booking_sopermission::ROLE_DEFAULT]['create'] = true;
-
$defaultPermissions[booking_sopermission::ROLE_DEFAULT]['write'] = true;
+
$defaultPermissions[booking_sopermission::ROLE_DEFAULT]['create'] = true;
+
$defaultPermissions[booking_sopermission::ROLE_DEFAULT]['write'] = true;
return $defaultPermissions;
}
return array_merge(
- array
+ array
(
- 'parent_role_permissions' => array
+ 'parent_role_permissions' => array
(
- 'season' => array
+ 'season' => array
(
-
booking_sopermission::ROLE_MANAGER => array(
- 'create' =>
true,
+
booking_sopermission::ROLE_MANAGER => array(
+ 'create' => true,
+ ),
+
booking_sopermission::ROLE_CASE_OFFICER => array(
+ 'create' => true,
+ ),
+ 'parent_role_permissions'
=> array(
+ 'building' => array(
+
booking_sopermission::ROLE_MANAGER => array(
+
'create' => true,
+ ),
),
-
booking_sopermission::ROLE_CASE_OFFICER => array(
- 'create' =>
true,
- ),
-
'parent_role_permissions' => array(
- 'building' =>
array(
-
booking_sopermission::ROLE_MANAGER => array(
-
'create' => true,
- ),
- ),
- )
)
- ),
- 'global' => array
+ )
+ ),
+ 'global'
=> array
(
-
booking_sopermission::ROLE_MANAGER => array
+ booking_sopermission::ROLE_MANAGER =>
array
(
- 'create' => true
- )
- ),
+ 'create' => true
+ )
),
- $defaultPermissions
+ ), $defaultPermissions
);
}
@@ -419,84 +441,84 @@
*
* @return array containing values from $array for the keys in
$keys.
*/
-
// todo: remove debug kode
- function building_schedule($building_id, $date)
- {
+ function building_schedule($building_id, $date)
+ {
// echo "debug:\n";
- $from = clone $date;
- $from->setTime(0, 0, 0);
- // Make sure $from is a monday
- if($from->format('w') != 1)
- {
- $from->modify('last monday');
- }
- $to = clone $from;
- $to->modify('+7 days');
- $allocation_ids =
$this->so->allocation_ids_for_building($building_id, $from, $to);
- $allocations = $this->allocation_so->read(array('filters'=>
array('id' => $allocation_ids)));
- $allocations = $allocations['results'];
- foreach($allocations as &$allocation)
- {
- $allocation['name'] = $allocation['organization_name'];
- $allocation['shortname'] =
$allocation['organization_shortname'];
- $allocation['type'] = 'allocation';
- }
+ $from = clone $date;
+ $from->setTime(0, 0, 0);
+ // Make sure $from is a monday
+ if($from->format('w') != 1)
+ {
+ $from->modify('last monday');
+ }
+ $to = clone $from;
+ $to->modify('+7 days');
+ $allocation_ids =
$this->so->allocation_ids_for_building($building_id, $from, $to);
+ $allocations =
$this->allocation_so->read(array('filters' => array('id' => $allocation_ids)));
+ $allocations = $allocations['results'];
+ foreach($allocations as &$allocation)
+ {
+ $allocation['name'] =
$allocation['organization_name'];
+ $allocation['shortname'] =
$allocation['organization_shortname'];
+ $allocation['type'] = 'allocation';
+ }
- $booking_ids = $this->so->booking_ids_for_building($building_id,
$from, $to);
- $bookings = $this->so->read(array('filters'=> array('id' =>
$booking_ids)));
- $bookings = $bookings['results'];
- foreach($bookings as &$booking)
- {
- $booking['name'] = $booking['group_name'];
- $booking['shortname'] = $booking['group_shortname'];
- $booking['type'] = 'booking';
- unset($booking['audience']);
- unset($booking['agegroups']);
- }
+ $booking_ids =
$this->so->booking_ids_for_building($building_id, $from, $to);
+ $bookings = $this->so->read(array('filters' =>
array('id' => $booking_ids)));
+ $bookings = $bookings['results'];
+ foreach($bookings as &$booking)
+ {
+ $booking['name'] =
$booking['group_name'];
+ $booking['shortname'] =
$booking['group_shortname'];
+ $booking['type'] = 'booking';
+ unset($booking['audience']);
+ unset($booking['agegroups']);
+ }
- $allocations = $this->split_allocations($allocations, $bookings);
+ $allocations = $this->split_allocations($allocations,
$bookings);
- $event_ids = $this->so->event_ids_for_building($building_id,
$from, $to);
- $events = $this->event_so->read(array('filters'=> array('id' =>
$event_ids)));
- $events = $events['results'];
- foreach($events as &$event)
- {
+ $event_ids =
$this->so->event_ids_for_building($building_id, $from, $to);
+ $events =
$this->event_so->read(array('filters' => array('id' => $event_ids)));
+ $events = $events['results'];
+ foreach($events as &$event)
+ {
- $event['name'] = $event['description'];
- $event['type'] = 'event';
- unset($event['comments']);
- unset($event['audience']);
- unset($event['agegroups']);
- unset($event['dates']);
+ $event['name'] = $event['description'];
+ $event['type'] = 'event';
+ unset($event['comments']);
+ unset($event['audience']);
+ unset($event['agegroups']);
+ unset($event['dates']);
+ }
- }
-
- $bookings = array_merge($allocations, $bookings);
+ $bookings = array_merge($allocations, $bookings);
// echo "before rem\n";
- $bookings = $this->_remove_event_conflicts($bookings, $events);
+ $bookings =
$this->_remove_event_conflicts($bookings, $events);
// echo "after rem\n";
- $bookings = array_merge($events, $bookings);
+ $bookings = array_merge($events, $bookings);
- $resource_ids = $this->so->resource_ids_for_bookings($booking_ids);
- $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_allocations($allocation_ids));
- $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_events($event_ids));
- $resources = $this->resource_so->read(array('filters' =>
array('id' => $resource_ids, 'active' => 1)));
- $resources = $resources['results'];
+ $resource_ids =
$this->so->resource_ids_for_bookings($booking_ids);
+ $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_allocations($allocation_ids));
+ $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_events($event_ids));
+ $resources =
$this->resource_so->read(array('filters' => array('id' => $resource_ids,
+ 'active' => 1)));
+ $resources = $resources['results'];
- foreach ($resources as $key => $row) {
- $sort[$key] = $row['sort'];
- }
+ foreach($resources as $key => $row)
+ {
+ $sort[$key] = $row['sort'];
+ }
- // Sort the resources with sortkey ascending
- // Add $resources as the last parameter, to sort by the common key
- array_multisort($sort, SORT_ASC, $resources);
- $bookings = $this->_split_multi_day_bookings($bookings, $from,
$to);
- $results = build_schedule_table($bookings, $resources);
+ // Sort the resources with sortkey ascending
+ // Add $resources as the last parameter, to sort by the
common key
+ array_multisort($sort, SORT_ASC, $resources);
+ $bookings =
$this->_split_multi_day_bookings($bookings, $from, $to);
+ $results = build_schedule_table($bookings,
$resources);
// exit;
- return array('total_records'=>count($results),
'results'=>$results);
- }
+ return array('total_records' => count($results),
'results' => $results);
+ }
function building_infoscreen_schedule($building_id, $date, $res
= False)
{
@@ -507,224 +529,233 @@
{
$from->modify('last monday');
}
- $to = clone $from;
- $to->modify('+7 days');
- $to->modify('-1 minute');
+ $to = clone $from;
+ $to->modify('+7 days');
+ $to->modify('-1 minute');
- if ($res != False){
- $resources = $this->so->get_screen_resources($building_id,
$res);
- if (count($resources) > 0)
- $resources = "AND bb_resource.id IN (".implode(",",
$resources).")";
- else
- $resources = '';
- }
- $allocations = $this->so->get_screen_allocation($building_id,
$from, $to, $resources);
- $bookings = $this->so->get_screen_booking($building_id, $from,
$to, $resources);
- $events = $this->so->get_screen_event($building_id, $from, $to,
$resources);
+ if($res != False)
+ {
+ $resources =
$this->so->get_screen_resources($building_id, $res);
+ if(count($resources) > 0)
+ $resources = "AND bb_resource.id
IN (" . implode(",", $resources) . ")";
+ else
+ $resources = '';
+ }
+ $allocations =
$this->so->get_screen_allocation($building_id, $from, $to, $resources);
+ $bookings =
$this->so->get_screen_booking($building_id, $from, $to, $resources);
+ $events =
$this->so->get_screen_event($building_id, $from, $to, $resources);
- $results = array();
+ $results = array();
- foreach($allocations as &$allocation)
+ foreach($allocations as &$allocation)
{
- $allocation['name'] =
$allocation['organization_name'];
+ $allocation['name'] =
$allocation['organization_name'];
$allocation['shortname'] =
$allocation['organization_shortname'];
- $allocation['type'] = 'allocation';
+ $allocation['type'] = 'allocation';
- $datef = strtotime($allocation['from_']);
- $allocation['weekday'] = date('D',$datef);
+ $datef =
strtotime($allocation['from_']);
+ $allocation['weekday'] = date('D', $datef);
}
foreach($bookings as &$booking)
{
- $booking['name'] = $booking['group_name'];
- $booking['shortname'] =
$booking['group_shortname'];
- $booking['type'] = 'booking';
+ $booking['name'] =
$booking['group_name'];
+ $booking['shortname'] =
$booking['group_shortname'];
+ $booking['type'] = 'booking';
- $datef = strtotime($booking['from_']);
- $booking['weekday'] = date('D',$datef);
- }
+ $datef =
strtotime($booking['from_']);
+ $booking['weekday'] = date('D', $datef);
+ }
- foreach($events as &$event)
- {
- $event['name'] = substr($event['description'], 0, 34);
- $event['shortname'] = substr($event['description'], 0, 12);
- $event['type'] = 'event';
- $datef = strtotime($event['from_']);
- $event['weekday'] = date('D',$datef);
- }
+ foreach($events as &$event)
+ {
+ $event['name'] =
substr($event['description'], 0, 34);
+ $event['shortname'] =
substr($event['description'], 0, 12);
+ $event['type'] = 'event';
+ $datef =
strtotime($event['from_']);
+ $event['weekday'] = date('D', $datef);
+ }
- $allocations = $this->split_allocations2($allocations, $bookings);
- $bookings = array_merge($allocations, $bookings);
- $bookings = $this->_remove_event_conflicts2($bookings, $events);
- $bookings = array_merge($bookings, $events);
- $bookings = $this->_split_multi_day_bookings2($bookings, $from,
$to);
+ $allocations = $this->split_allocations2($allocations,
$bookings);
+ $bookings = array_merge($allocations, $bookings);
+ $bookings =
$this->_remove_event_conflicts2($bookings, $events);
+ $bookings = array_merge($bookings, $events);
+ $bookings =
$this->_split_multi_day_bookings2($bookings, $from, $to);
- foreach($bookings as &$allocation)
- {
- $datef = strtotime($allocation['from_']);
- $datet = strtotime($allocation['to_']);
- $timef = date('H:i:s',$datef);
- $timet = date('H:i:s',$datet);
- $weekday = $allocation['weekday'];
- $resname = $allocation['resource_name'];
- $ft = $timef;
- $from = explode(':',$timef);
- $to = explode(':',$timet);
- $from = $from[0]*60+$from[1];
- $to = $to[0]*60+$to[1];
- if ($to == 0)
- $to = 24*60;
- $colspan = ($to-$from)/30;
+ foreach($bookings as &$allocation)
+ {
+ $datef = strtotime($allocation['from_']);
+ $datet = strtotime($allocation['to_']);
+ $timef = date('H:i:s', $datef);
+ $timet = date('H:i:s', $datet);
+ $weekday = $allocation['weekday'];
+ $resname = $allocation['resource_name'];
+ $ft = $timef;
+ $from = explode(':', $timef);
+ $to = explode(':', $timet);
+ $from = $from[0] * 60 + $from[1];
+ $to = $to[0] * 60 + $to[1];
+ if($to == 0)
+ $to = 24 * 60;
+ $colspan = ($to - $from) / 30;
- $allocation['colspan'] = $colspan;
- $results[$weekday][$resname][$ft] = $allocation;
- }
+ $allocation['colspan']
= $colspan;
+ $results[$weekday][$resname][$ft] =
$allocation;
+ }
- foreach ($results as &$day) {
- foreach ($day as &$res) {
- ksort($res);
- }
- }
+ foreach($results as &$day)
+ {
+ foreach($day as &$res)
+ {
+ ksort($res);
+ }
+ }
- return array('total_records'=>count($results),
'results'=>$results);
+ return array('total_records' => count($results),
'results' => $results);
}
- function split_allocations2($allocations, $all_bookings)
- {
- function get_from2($a) {return $a['from_'];};
- function get_to2($a) {return $a['to_'];};
- $new_allocations = array();
- foreach($allocations as $allocation)
- {
- // $ Find all associated bookings
- $bookings = array();
+ function split_allocations2($allocations, $all_bookings)
+ {
- foreach($all_bookings as $b)
- {
- if($b['allocation_id'] == $allocation['id'])
- $bookings[] = $b;
- }
- $times = array($allocation['from_'], $allocation['to_']);
+ function get_from2($a)
+ { return $a['from_'];}
+;
- $times = array_merge(array_map("get_from2", $bookings),
$times);
- $times = array_merge(array_map("get_to2", $bookings), $times);
- $times = array_unique($times);
- sort($times);
- while(count($times) >= 2)
- {
- $from_ = $times[0];
- $to_ = $times[1];
- $resources = array($allocation['resource_id']);
- foreach($all_bookings as $b)
- {
+ function get_to2($a)
+ { return $a['to_'];}
+;
+ $new_allocations = array();
+ foreach($allocations as $allocation)
+ {
+ // $ Find all associated bookings
+ $bookings = array();
- if(($b['from_'] >= $from_ && $b['from_'] < $to_) ||
($b['to_'] > $from_ && $b['to_'] <= $to_) || ($b['from_'] <= $from_ &&
$b['to_'] >= $to_))
- $resources = array_minus($resources,
array($b['resource_id']));
- }
- if($resources)
- {
- $a = $allocation;
- $a['from_'] = $times[0];
- $a['to_'] = $times[1];
- $new_allocations[] = $a;
- }
- array_shift($times);
- }
- }
- return $new_allocations;
- }
+ foreach($all_bookings as $b)
+ {
+ if($b['allocation_id'] ==
$allocation['id'])
+ $bookings[] = $b;
+ }
+ $times = array($allocation['from_'],
$allocation['to_']);
- function _remove_event_conflicts2($bookings, &$events)
- {
- $new_bookings = array();
- foreach($bookings as $b)
- {
- $keep = true;
- foreach($events as &$e)
- {
- if((($b['from_'] >= $e['from_'] && $b['from_'] <
$e['to_']) ||
- ($b['to_'] > $e['from_'] && $b['to_'] <=
$e['to_']) ||
- ($b['from_'] <= $e['from_'] && $b['to_'] >=
$e['to_'])) && ( $b['resource_id'] == $e['resource_id']))
- {
- $keep = false;
- break;
- }
- }
- if($keep)
- {
- $new_bookings[] = $b;
- }
- }
- return $new_bookings;
- }
+ $times = array_merge(array_map("get_from2",
$bookings), $times);
+ $times = array_merge(array_map("get_to2",
$bookings), $times);
+ $times = array_unique($times);
+ sort($times);
+ while(count($times) >= 2)
+ {
+ $from_ = $times[0];
+ $to_ = $times[1];
+ $resources =
array($allocation['resource_id']);
+ foreach($all_bookings as $b)
+ {
- function _split_multi_day_bookings2($bookings, $t0, $t1)
- {
- if($t1->format('H:i') == '00:00')
- $t1->modify('-1 day');
- $new_bookings = array();
- foreach($bookings as $booking)
- {
- $from = new DateTime($booking['from_']);
- $to = new DateTime($booking['to_']);
- // Basic one-day booking
- if($from->format('Y-m-d') == $to->format('Y-m-d'))
- {
- $booking['date'] = $from->format('Y-m-d');
- $booking['weekday'] =
date_format(date_create($booking['date']), 'D');
- $booking['from_'] = $from->format('H:i');
- $booking['to_'] = $to->format('H:i');
- // We need to use 24:00 instead of 00:00 to sort correctly
- $booking['to_'] = $booking['to_'] == '00:00' ? '24:00' :
$booking['to_'];
- $new_bookings[] = $booking;
- }
- // Multi-day booking
- else
- {
- $start = clone max($from, $t0);
- $end = clone min($to, $t1);
- $date = clone $start;
- do
- {
- $new_booking = $booking;
- $new_booking['date'] = $date->format('Y-m-d');
- $new_booking['weekday'] = date_format($date, 'D');
- $new_booking['from_'] = '00:00';
- $new_booking['to_'] = '00:00';
- if($new_booking['date'] == $from->format('Y-m-d'))
- {
- $new_booking['from_'] = $from->format('H:i');
- }
- else if($new_booking['date'] == $to->format('Y-m-d'))
- {
- $new_booking['to_'] = $to->format('H:i');
- }
- // We need to use 24:00 instead of 00:00 to sort
correctly
- $new_booking['to_'] = $new_booking['to_'] == '00:00' ?
'24:00' : $new_booking['to_'];
- $new_bookings[] = $new_booking;
+ if(($b['from_'] >= $from_ &&
$b['from_'] < $to_) || ($b['to_'] > $from_ && $b['to_'] <= $to_) ||
($b['from_'] <= $from_ && $b['to_'] >= $to_))
+ $resources =
array_minus($resources, array($b['resource_id']));
+ }
+ if($resources)
+ {
+ $a
= $allocation;
+ $a['from_']
= $times[0];
+ $a['to_']
= $times[1];
+ $new_allocations[] = $a;
+ }
+ array_shift($times);
+ }
+ }
+ return $new_allocations;
+ }
- if($date->format('Y-m-d') == $end->format('Y-m-d'))
- {
- break;
- }
+ function _remove_event_conflicts2($bookings, &$events)
+ {
+ $new_bookings = array();
+ foreach($bookings as $b)
+ {
+ $keep = true;
+ foreach($events as &$e)
+ {
+ if((($b['from_'] >= $e['from_'] &&
$b['from_'] < $e['to_']) ||
+ ($b['to_'] > $e['from_'] && $b['to_']
<= $e['to_']) ||
+ ($b['from_'] <= $e['from_'] &&
$b['to_'] >= $e['to_'])) && ( $b['resource_id'] == $e['resource_id']))
+ {
+ $keep = false;
+ break;
+ }
+ }
+ if($keep)
+ {
+ $new_bookings[] = $b;
+ }
+ }
+ return $new_bookings;
+ }
- // if($date->getTimestamp() >
$end->getTimestamp()) // > php 5.3.0
- if($date->format("U") > $end->format("U"))
- {
- throw new InvalidArgumentException('start time( '
. $date->format('Y-m-d') . ' ) later than end time( ' . $end->format('Y-m-d') .
" ) for {$booking['type']}#{$booking['id']}::{$booking['name']}");
- }
+ function _split_multi_day_bookings2($bookings, $t0, $t1)
+ {
+ if($t1->format('H:i') == '00:00')
+ $t1->modify('-1 day');
+ $new_bookings = array();
+ foreach($bookings as $booking)
+ {
+ $from = new DateTime($booking['from_']);
+ $to = new
DateTime($booking['to_']);
+ // Basic one-day booking
+ if($from->format('Y-m-d') ==
$to->format('Y-m-d'))
+ {
+ $booking['date'] =
$from->format('Y-m-d');
+ $booking['weekday'] =
date_format(date_create($booking['date']), 'D');
+ $booking['from_'] =
$from->format('H:i');
+ $booking['to_'] =
$to->format('H:i');
+ // We need to use 24:00 instead of
00:00 to sort correctly
+ $booking['to_'] =
$booking['to_'] == '00:00' ? '24:00' : $booking['to_'];
+ $new_bookings[] = $booking;
+ }
+ // Multi-day booking
+ else
+ {
+ $start = clone max($from, $t0);
+ $end = clone min($to, $t1);
+ $date = clone $start;
+ do
+ {
+ $new_booking
= $booking;
+ $new_booking['date'] =
$date->format('Y-m-d');
+ $new_booking['weekday'] =
date_format($date, 'D');
+ $new_booking['from_'] =
'00:00';
+ $new_booking['to_']
= '00:00';
+ if($new_booking['date'] ==
$from->format('Y-m-d'))
+ {
+ $new_booking['from_'] =
$from->format('H:i');
+ }
+ else if($new_booking['date'] ==
$to->format('Y-m-d'))
+ {
+ $new_booking['to_'] =
$to->format('H:i');
+ }
+ // We need to use 24:00 instead
of 00:00 to sort correctly
+ $new_booking['to_'] =
$new_booking['to_'] == '00:00' ? '24:00' : $new_booking['to_'];
+ $new_bookings[] =
$new_booking;
- $date->modify('+1 day');
- }
- while(true);
- }
- }
- return $new_bookings;
- }
+ if($date->format('Y-m-d') ==
$end->format('Y-m-d'))
+ {
+ break;
+ }
+ //
if($date->getTimestamp() > $end->getTimestamp()) // > php 5.3.0
+ if($date->format("U") >
$end->format("U"))
+ {
+ throw new
InvalidArgumentException('start time( ' . $date->format('Y-m-d') . ' ) later
than end time( ' . $end->format('Y-m-d') . " ) for
{$booking['type']}#{$booking['id']}::{$booking['name']}");
+ }
+
+ $date->modify('+1 day');
+ }
+ while(true);
+ }
+ }
+ return $new_bookings;
+ }
+
function building_extraschedule($building_id, $date)
{
- $config = CreateObject('phpgwapi.config','booking');
+ $config = CreateObject('phpgwapi.config', 'booking');
$config->read();
$from = clone $date;
@@ -734,67 +765,71 @@
{
$from->modify('last monday');
}
- $to = clone $from;
+ $to = clone $from;
$to->modify('+7 days');
- $allocation_ids =
$this->so->allocation_ids_for_building($building_id, $from, $to);
-
- $orgids = explode(",", $config->config_data['extra_schedule_ids']);
-
- $allocations =
$this->allocation_so->read(array('filters'=> array('id' => $allocation_ids,
'organization_id' => $orgids), 'sort'=>'from_'));
+ $allocation_ids =
$this->so->allocation_ids_for_building($building_id, $from, $to);
+
+ $orgids = explode(",",
$config->config_data['extra_schedule_ids']);
+
+ $allocations =
$this->allocation_so->read(array('filters' => array('id' => $allocation_ids,
+ 'organization_id' => $orgids), 'sort'
=> 'from_'));
$allocations = $allocations['results'];
foreach($allocations as &$allocation)
{
- $allocation['name'] =
$allocation['organization_name'];
+ $allocation['name'] =
$allocation['organization_name'];
$allocation['shortname'] =
$allocation['organization_shortname'];
- $allocation['type'] = 'allocation';
+ $allocation['type'] = 'allocation';
}
$booking_ids =
$this->so->booking_ids_for_building($building_id, $from, $to);
- $bookings = $this->so->read(array('filters'=>
array('id' => $booking_ids), 'sort'=>'from_'));
- $bookings = $bookings['results'];
+ $bookings = $this->so->read(array('filters' =>
array('id' => $booking_ids), 'sort' => 'from_'));
+ $bookings = $bookings['results'];
foreach($bookings as &$booking)
{
- $booking['name'] = $booking['group_name'];
- $booking['shortname'] =
$booking['group_shortname'];
- $booking['type'] = 'booking';
- unset($booking['audience']);
- unset($booking['agegroups']);
+ $booking['name'] =
$booking['group_name'];
+ $booking['shortname'] =
$booking['group_shortname'];
+ $booking['type'] = 'booking';
+ unset($booking['audience']);
+ unset($booking['agegroups']);
}
$allocations = $this->split_allocations($allocations,
$bookings);
- $event_ids =
$this->so->event_ids_for_building($building_id, $from, $to);
- $events = $this->event_so->read(array('filters'=>
array('id' => $event_ids), 'sort'=>'from_'));
- $events = $events['results'];
+ $event_ids =
$this->so->event_ids_for_building($building_id, $from, $to);
+ $events =
$this->event_so->read(array('filters' => array('id' => $event_ids),
+ 'sort' => 'from_'));
+ $events = $events['results'];
foreach($events as &$event)
{
-
- $event['name'] = $event['description'];
- $event['type'] = 'event';
- unset($event['comments']);
- unset($event['audience']);
- unset($event['agegroups']);
+
+ $event['name'] = $event['description'];
+ $event['type'] = 'event';
+ unset($event['comments']);
+ unset($event['audience']);
+ unset($event['agegroups']);
}
- $bookings = array_merge($allocations, $bookings);
- $bookings = $this->_remove_event_conflicts($bookings,
$events);
+ $bookings = array_merge($allocations, $bookings);
+ $bookings =
$this->_remove_event_conflicts($bookings, $events);
- $resource_ids =
$this->so->resource_ids_for_bookings($booking_ids);
- $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_allocations($allocation_ids));
- $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_events($event_ids));
- $resources = $this->resource_so->read(array('filters'
=> array('id' => $resource_ids, 'active' => 1)));
- $resources = $resources['results'];
+ $resource_ids =
$this->so->resource_ids_for_bookings($booking_ids);
+ $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_allocations($allocation_ids));
+ $resource_ids = array_merge($resource_ids,
$this->so->resource_ids_for_events($event_ids));
+ $resources =
$this->resource_so->read(array('filters' => array('id' => $resource_ids,
+ 'active' => 1)));
+ $resources = $resources['results'];
- foreach ($resources as $key => $row) {
- $sort[$key] = $row['sort'];
+ foreach($resources as $key => $row)
+ {
+ $sort[$key] = $row['sort'];
}
// Sort the resources with sortkey ascending
// Add $resources as the last parameter, to sort by the
common key
array_multisort($sort, SORT_ASC, $resources);
- $bookings = $this->_split_multi_day_bookings($bookings,
$from, $to);
- $results = build_schedule_table($bookings, $resources);
- return array('total_records'=>count($results),
'results'=>$results);
+ $bookings =
$this->_split_multi_day_bookings($bookings, $from, $to);
+ $results = build_schedule_table($bookings,
$resources);
+ return array('total_records' => count($results),
'results' => $results);
}
/**
@@ -806,329 +841,362 @@
*
* @return array containg values from $array for the keys in
$keys.
*/
- function resource_schedule($resource_id, $date)
- {
- $from = clone $date;
- $from->setTime(0, 0, 0);
- // Make sure $from is a monday
- if($from->format('w') != 1)
- {
- $from->modify('last monday');
- }
- $to = clone $from;
- $to->modify('+7 days');
- $resource = $this->resource_so->read_single($resource_id);
- $allocation_ids =
$this->so->allocation_ids_for_resource($resource_id, $from, $to);
- $allocations = $this->allocation_so->read(array('filters'=>
array('id' => $allocation_ids)));
- $allocations = $allocations['results'];
- foreach($allocations as &$allocation)
- {
- $allocation['name'] = $allocation['organization_name'];
- $allocation['shortname'] =
$allocation['organization_shortname'];
- $allocation['type'] = 'allocation';
- }
- $booking_ids = $this->so->booking_ids_for_resource($resource_id,
$from, $to);
- $bookings = $this->so->read(array('filters'=> array('id' =>
$booking_ids)));
- $bookings = $bookings['results'];
- foreach($bookings as &$booking)
- {
- $booking['name'] = $booking['group_name'];
- $booking['shortname'] = $booking['group_shortname'];
- $booking['type'] = 'booking';
- }
- $allocations = $this->split_allocations($allocations, $bookings);
+ function resource_schedule($resource_id, $date)
+ {
+ $from = clone $date;
+ $from->setTime(0, 0, 0);
+ // Make sure $from is a monday
+ if($from->format('w') != 1)
+ {
+ $from->modify('last monday');
+ }
+ $to = clone $from;
+ $to->modify('+7 days');
+ $resource =
$this->resource_so->read_single($resource_id);
+ $allocation_ids =
$this->so->allocation_ids_for_resource($resource_id, $from, $to);
+ $allocations =
$this->allocation_so->read(array('filters' => array('id' => $allocation_ids)));
+ $allocations = $allocations['results'];
+ foreach($allocations as &$allocation)
+ {
+ $allocation['name'] =
$allocation['organization_name'];
+ $allocation['shortname'] =
$allocation['organization_shortname'];
+ $allocation['type'] = 'allocation';
+ }
+ $booking_ids =
$this->so->booking_ids_for_resource($resource_id, $from, $to);
+ $bookings = $this->so->read(array('filters' =>
array('id' => $booking_ids)));
+ $bookings = $bookings['results'];
+ foreach($bookings as &$booking)
+ {
+ $booking['name'] =
$booking['group_name'];
+ $booking['shortname'] =
$booking['group_shortname'];
+ $booking['type'] = 'booking';
+ }
+ $allocations = $this->split_allocations($allocations,
$bookings);
- $event_ids = $this->so->event_ids_for_resource($resource_id,
$from, $to);
- $events = $this->event_so->read(array('filters'=> array('id' =>
$event_ids)));
- $events = $events['results'];
- foreach($events as &$event)
- {
- $event['name'] = $event['description'];
- $event['type'] = 'event';
- }
- $bookings = array_merge($allocations, $bookings);
- $bookings = $this->_remove_event_conflicts($bookings, $events);
- $bookings = array_merge($events, $bookings);
+ $event_ids =
$this->so->event_ids_for_resource($resource_id, $from, $to);
+ $events =
$this->event_so->read(array('filters' => array('id' => $event_ids)));
+ $events = $events['results'];
+ foreach($events as &$event)
+ {
+ $event['name'] = $event['description'];
+ $event['type'] = 'event';
+ }
+ $bookings = array_merge($allocations, $bookings);
+ $bookings =
$this->_remove_event_conflicts($bookings, $events);
+ $bookings = array_merge($events, $bookings);
- $bookings = $this->_split_multi_day_bookings($bookings, $from,
$to);
- $results = build_schedule_table($bookings, array($resource));
- return array('total_records'=>count($results),
'results'=>$results);
- }
+ $bookings =
$this->_split_multi_day_bookings($bookings, $from, $to);
+ $results = build_schedule_table($bookings,
array($resource));
+ return array('total_records' => count($results),
'results' => $results);
+ }
- /**
- * Split allocations overlapped by bookings into multiple allocations
- * to avoid overlaps
- */
- function split_allocations($allocations, $all_bookings)
- {
- function get_from2($a) {return $a['from_'];};
- function get_to2($a) {return $a['to_'];};
- $new_allocations = array();
- foreach($allocations as $allocation)
- {
- // $ Find all associated bookings
- $bookings = array();
- foreach($all_bookings as $b)
- {
- if($b['allocation_id'] == $allocation['id'])
- $bookings[] = $b;
- }
- $times = array($allocation['from_'], $allocation['to_']);
- $times = array_merge(array_map("get_from2", $bookings),
$times);
- $times = array_merge(array_map("get_to2", $bookings), $times);
- $times = array_unique($times);
- sort($times);
- while(count($times) >= 2)
- {
- $from_ = $times[0];
- $to_ = $times[1];
- $resources = $allocation['resources'];
- $used = array();
- foreach($all_bookings as $b)
- {
+ /**
+ * Split allocations overlapped by bookings into multiple
allocations
+ * to avoid overlaps
+ */
+ function split_allocations($allocations, $all_bookings)
+ {
- if(($b['from_'] >= $from_ && $b['from_'] < $to_) ||
($b['to_'] > $from_ && $b['to_'] <= $to_) || ($b['from_'] <= $from_ &&
$b['to_'] >= $to_))
- $resources = array_minus($resources,
$b['resources']);
- }
- if($resources)
- {
- $a = $allocation;
- $a['from_'] = $times[0];
- $a['to_'] = $times[1];
- $new_allocations[] = $a;
- }
- array_shift($times);
- }
- }
- return $new_allocations;
- }
+ function get_from2($a)
+ { return $a['from_'];}
+;
- /**
- * Split Multi-day bookings into separate single-day bookings
- **/
- function _split_multi_day_bookings($bookings, $t0, $t1)
- {
- if($t1->format('H:i') == '00:00')
- $t1->modify('-1 day');
- $new_bookings = array();
- foreach($bookings as $booking)
- {
- $from = new DateTime($booking['from_']);
- $to = new DateTime($booking['to_']);
- // Basic one-day booking
- if($from->format('Y-m-d') == $to->format('Y-m-d'))
- {
- $booking['date'] = $from->format('Y-m-d');
- $booking['wday'] =
date_format(date_create($booking['date']), 'D');
- $booking['from_'] = $from->format('H:i');
- $booking['to_'] = $to->format('H:i');
- // We need to use 24:00 instead of 00:00 to sort correctly
- $booking['to_'] = $booking['to_'] == '00:00' ? '24:00' :
$booking['to_'];
- $new_bookings[] = $booking;
- }
- // Multi-day booking
- else
- {
- $start = clone max($from, $t0);
- $end = clone min($to, $t1);
- $date = clone $start;
- do
- {
- $new_booking = $booking;
- $new_booking['date'] = $date->format('Y-m-d');
- $new_booking['wday'] = date_format($date, 'D');
- $new_booking['from_'] = '00:00';
- $new_booking['to_'] = '00:00';
- if($new_booking['date'] == $from->format('Y-m-d'))
- {
- $new_booking['from_'] = $from->format('H:i');
- }
- else if($new_booking['date'] == $to->format('Y-m-d'))
- {
- $new_booking['to_'] = $to->format('H:i');
- }
- // We need to use 24:00 instead of 00:00 to sort
correctly
- $new_booking['to_'] = $new_booking['to_'] == '00:00' ?
'24:00' : $new_booking['to_'];
- $new_bookings[] = $new_booking;
+ function get_to2($a)
+ { return $a['to_'];}
+;
+ $new_allocations = array();
+ foreach($allocations as $allocation)
+ {
+ // $ Find all associated bookings
+ $bookings = array();
+ foreach($all_bookings as $b)
+ {
+ if($b['allocation_id'] ==
$allocation['id'])
+ $bookings[] = $b;
+ }
+ $times = array($allocation['from_'],
$allocation['to_']);
+ $times = array_merge(array_map("get_from2",
$bookings), $times);
+ $times = array_merge(array_map("get_to2",
$bookings), $times);
+ $times = array_unique($times);
+ sort($times);
+ while(count($times) >= 2)
+ {
+ $from_ = $times[0];
+ $to_ = $times[1];
+ $resources =
$allocation['resources'];
+ $used = array();
+ foreach($all_bookings as $b)
+ {
- if($date->format('Y-m-d') == $end->format('Y-m-d'))
- {
- break;
- }
+ if(($b['from_'] >= $from_ &&
$b['from_'] < $to_) || ($b['to_'] > $from_ && $b['to_'] <= $to_) ||
($b['from_'] <= $from_ && $b['to_'] >= $to_))
+ $resources =
array_minus($resources, $b['resources']);
+ }
+ if($resources)
+ {
+ $a
= $allocation;
+ $a['from_']
= $times[0];
+ $a['to_']
= $times[1];
+ $new_allocations[] = $a;
+ }
+ array_shift($times);
+ }
+ }
+ return $new_allocations;
+ }
- // if($date->getTimestamp() >
$end->getTimestamp()) // > php 5.3.0
- if($date->format("U") > $end->format("U"))
- {
- throw new InvalidArgumentException('start time( '
. $date->format('Y-m-d') . ' ) later than end time( ' . $end->format('Y-m-d') .
" ) for {$booking['type']}#{$booking['id']}::{$booking['name']}");
- }
+ /**
+ * Split Multi-day bookings into separate single-day bookings
+ * */
+ function _split_multi_day_bookings($bookings, $t0, $t1)
+ {
+ if($t1->format('H:i') == '00:00')
+ $t1->modify('-1 day');
+ $new_bookings = array();
+ foreach($bookings as $booking)
+ {
+ $from = new DateTime($booking['from_']);
+ $to = new
DateTime($booking['to_']);
+ // Basic one-day booking
+ if($from->format('Y-m-d') ==
$to->format('Y-m-d'))
+ {
+ $booking['date'] =
$from->format('Y-m-d');
+ $booking['wday'] =
date_format(date_create($booking['date']), 'D');
+ $booking['from_'] =
$from->format('H:i');
+ $booking['to_'] =
$to->format('H:i');
+ // We need to use 24:00 instead of
00:00 to sort correctly
+ $booking['to_'] =
$booking['to_'] == '00:00' ? '24:00' : $booking['to_'];
+ $new_bookings[] = $booking;
+ }
+ // Multi-day booking
+ else
+ {
+ $start = clone max($from, $t0);
+ $end = clone min($to, $t1);
+ $date = clone $start;
+ do
+ {
+ $new_booking
= $booking;
+ $new_booking['date'] =
$date->format('Y-m-d');
+ $new_booking['wday'] =
date_format($date, 'D');
+ $new_booking['from_'] =
'00:00';
+ $new_booking['to_']
= '00:00';
+ if($new_booking['date'] ==
$from->format('Y-m-d'))
+ {
+ $new_booking['from_'] =
$from->format('H:i');
+ }
+ else if($new_booking['date'] ==
$to->format('Y-m-d'))
+ {
+ $new_booking['to_'] =
$to->format('H:i');
+ }
+ // We need to use 24:00 instead
of 00:00 to sort correctly
+ $new_booking['to_'] =
$new_booking['to_'] == '00:00' ? '24:00' : $new_booking['to_'];
+ $new_bookings[] =
$new_booking;
- $date->modify('+1 day');
- }
- while(true);
- }
- }
- return $new_bookings;
- }
+ if($date->format('Y-m-d') ==
$end->format('Y-m-d'))
+ {
+ break;
+ }
- function _remove_event_conflicts($bookings, &$events)
- {
- foreach($events as &$e)
- {
- $e['conflicts'] = array();
- }
- $new_bookings = array();
- $last = array();
- foreach($bookings as $b)
- {
- if ($last) {
- foreach ($last as $l) {
+ //
if($date->getTimestamp() > $end->getTimestamp()) // > php 5.3.0
+ if($date->format("U") >
$end->format("U"))
+ {
+ throw new
InvalidArgumentException('start time( ' . $date->format('Y-m-d') . ' ) later
than end time( ' . $end->format('Y-m-d') . " ) for
{$booking['type']}#{$booking['id']}::{$booking['name']}");
+ }
+
+ $date->modify('+1 day');
+ }
+ while(true);
+ }
+ }
+ return $new_bookings;
+ }
+
+ function _remove_event_conflicts($bookings, &$events)
+ {
+ foreach($events as &$e)
+ {
+ $e['conflicts'] = array();
+ }
+ $new_bookings = array();
+ $last = array();
+ foreach($bookings as $b)
+ {
+ if($last)
+ {
+ foreach($last as $l)
+ {
// echo $l['id']."-".$l['from_']."-".$l['to_']."\n";
- $new_bookings[] = $l;
- }
- $last = array();
- }
- $keep = true;
+ $new_bookings[] = $l;
+ }
+ $last = array();
+ }
+ $keep = true;
// $i = 0;
- foreach($events as &$e)
- {
+ foreach($events as &$e)
+ {
// echo $b['id']."\tfrom: ".substr($b['from_'],11,19)." to:
".substr($b['to_'],11,19)."\n";
// echo $e['id']."\tfrom: ".substr($e['from_'],11,19)." to:
".substr($e['to_'],11,19)." ".$e['name']."\n";
- if((($b['from_'] >= $e['from_'] && $b['from_'] <
$e['to_']) ||
- ($b['to_'] > $e['from_'] && $b['to_'] <=
$e['to_']) ||
- ($b['from_'] <= $e['from_'] && $b['to_'] >=
$e['to_'])) && (array_intersect($b['resources'], $e['resources']) != array()))
- {
+ if((($b['from_'] >= $e['from_'] &&
$b['from_'] < $e['to_']) ||
+ ($b['to_'] > $e['from_'] && $b['to_']
<= $e['to_']) ||
+ ($b['from_'] <= $e['from_'] &&
$b['to_'] >= $e['to_'])) && (array_intersect($b['resources'], $e['resources'])
!= array()))
+ {
// echo "##$i\n";
- $keep = false;
- $e['conflicts'][] = $b;
+ $keep
= false;
+ $e['conflicts'][] = $b;
- $bf = $b['from_'];
- $bt = $b['to_'];
- $ef = $e['from_'];
- $et = $e['to_'];
- $tmp = $b;
+ $bf = $b['from_'];
+ $bt = $b['to_'];
+ $ef = $e['from_'];
+ $et = $e['to_'];
+ $tmp = $b;
- if ($last) {
- $ilast = $last;
- $last = array();
- foreach ($ilast as $l) {
- $lf = $l['from_'];
- $lt = $l['to_'];
- $tmp = $l;
- if ($ef <= $lf && $et >= $lt) {
+ if($last)
+ {
+ $ilast = $last;
+ $last = array();
+ foreach($ilast as $l)
+ {
+ $lf =
$l['from_'];
+ $lt =
$l['to_'];
+ $tmp = $l;
+ if($ef <= $lf
&& $et >= $lt)
+ {
// echo "B0: break ef <= bf && et >=
bt\n\n";
- $last[] = $l;
- break;
- } elseif (($ef >= $lf) && ($et > $lt)) {
+ $last[]
= $l;
+ break;
+ }
+ elseif(($ef >=
$lf) && ($et > $lt))
+ {
// echo "B1: (ef >= lf) && (et > lt)\n";
- $tmp['from_'] = $lf;
- $tmp['to_'] = $ef;
- $last[] = $tmp;
- } elseif (($ef <= $lf) && ($et < $lt)) {
+
$tmp['from_'] = $lf;
+
$tmp['to_'] = $ef;
+ $last[]
= $tmp;
+ }
+ elseif(($ef <=
$lf) && ($et < $lt))
+ {
// echo "B2: (ef <= lf) && (et < lt)\n";
- $tmp['from_'] = $et;
- $tmp['to_'] = $lt;
- $last[] = $tmp;
- } elseif (($ef > $lf) && ($et < $lt)) {
+
$tmp['from_'] = $et;
+
$tmp['to_'] = $lt;
+ $last[]
= $tmp;
+ }
+ elseif(($ef >
$lf) && ($et < $lt))
+ {
// echo "B3: (ef > lf) && (et < lt)\n";
- $tmp['from_'] = $lf;
- $tmp['to_'] = $ef;
- $last[] = $tmp;
- $tmp['from_'] = $et;
- $tmp['to_'] = $lt;
- $last[] = $tmp;
- } else {
+
$tmp['from_'] = $lf;
+
$tmp['to_'] = $ef;
+ $last[]
= $tmp;
+
$tmp['from_'] = $et;
+
$tmp['to_'] = $lt;
+ $last[]
= $tmp;
+ }
+ else
+ {
// echo "B4: else break\n\n";
- $last[] = $l;
- break;
- }
- }
- } else {
- if ($ef <= $bf && $et >= $bt) {
+ $last[]
= $l;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if($ef <= $bf && $et >=
$bt)
+ {
// echo "A0: break ef <= bf && et >= bt\n\n";
- break;
- } elseif (($ef >= $bf) && ($et > $bt)) {
+ break;
+ }
+ elseif(($ef >= $bf) &&
($et > $bt))
+ {
// echo "A1: (ef >= bf) && (et > bt)\n";
- $tmp['from_'] = $bf;
- $tmp['to_'] = $ef;
- $last[] = $tmp;
- } elseif (($ef <= $bf) && ($et < $bt)) {
+ $tmp['from_']
= $bf;
+ $tmp['to_']
= $ef;
+ $last[]
= $tmp;
+ }
+ elseif(($ef <= $bf) &&
($et < $bt))
+ {
// echo "A2: (ef <= bf) && (et < bt)\n";
- $tmp['from_'] = $et;
- $tmp['to_'] = $bt;
- $last[] = $tmp;
- } elseif (($ef > $bf) && ($et < $bt)) {
+ $tmp['from_']
= $et;
+ $tmp['to_']
= $bt;
+ $last[]
= $tmp;
+ }
+ elseif(($ef > $bf) &&
($et < $bt))
+ {
// echo "A3: (ef > bf) && (et < bt)\n";
- $tmp['from_'] = $bf;
- $tmp['to_'] = $ef;
- $last[] = $tmp;
- $tmp['from_'] = $et;
- $tmp['to_'] = $bt;
- $last[] = $tmp;
- } else {
+ $tmp['from_']
= $bf;
+ $tmp['to_']
= $ef;
+ $last[]
= $tmp;
+ $tmp['from_']
= $et;
+ $tmp['to_']
= $bt;
+ $last[]
= $tmp;
+ }
+ else
+ {
// echo "A4: else break\n\n";
- break;
- }
- }
+ break;
+ }
+ }
// print_r($last);
- }
+ }
// $i+=1;
- }
+ }
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14558] booking: formatting code,
Sigurd Nes <=