[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13190] formatting code
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13190] formatting code |
Date: |
Wed, 13 May 2015 12:55:22 +0000 |
Revision: 13190
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13190
Author: sigurdne
Date: 2015-05-13 12:55:21 +0000 (Wed, 13 May 2015)
Log Message:
-----------
formatting code
Modified Paths:
--------------
branches/dev-syncromind/activitycalendar/inc/class.menu.inc.php
branches/dev-syncromind/activitycalendar/inc/class.soactivity.inc.php
branches/dev-syncromind/activitycalendar/inc/class.soarena.inc.php
branches/dev-syncromind/activitycalendar/inc/class.socommon.inc.php
branches/dev-syncromind/activitycalendar/inc/class.socontactperson.inc.php
branches/dev-syncromind/activitycalendar/inc/class.sogroup.inc.php
branches/dev-syncromind/activitycalendar/inc/class.soorganization.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uiactivities.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uiarena.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uicommon.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uidashboard.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uiimport.inc.php
branches/dev-syncromind/activitycalendar/inc/class.uiorganization.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.activity.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.arena.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.building.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.category.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.contact_person.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.group.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.model.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.organization.inc.php
branches/dev-syncromind/activitycalendar/inc/model/class.target.inc.php
branches/dev-syncromind/activitycalendar/index.php
branches/dev-syncromind/activitycalendar/setup/tables_update.inc.php
branches/dev-syncromind/activitycalendar/templates/base/activity.php
branches/dev-syncromind/activitycalendar/templates/base/activity_import.php
branches/dev-syncromind/activitycalendar/templates/base/activity_list.php
branches/dev-syncromind/activitycalendar/templates/base/activity_list_partial.php
branches/dev-syncromind/activitycalendar/templates/base/arena.php
branches/dev-syncromind/activitycalendar/templates/base/arena_list.php
branches/dev-syncromind/activitycalendar/templates/base/arena_list_partial.php
branches/dev-syncromind/activitycalendar/templates/base/common.php
branches/dev-syncromind/activitycalendar/templates/base/dashboard.php
branches/dev-syncromind/activitycalendar/templates/base/group.php
branches/dev-syncromind/activitycalendar/templates/base/organization.php
branches/dev-syncromind/activitycalendar/templates/base/organization_list.php
branches/dev-syncromind/activitycalendar/templates/base/organization_list_changed.php
branches/dev-syncromind/activitycalendar/templates/base/organization_list_partial.php
Modified: branches/dev-syncromind/activitycalendar/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendar/inc/class.menu.inc.php
2015-05-13 06:02:39 UTC (rev 13189)
+++ branches/dev-syncromind/activitycalendar/inc/class.menu.inc.php
2015-05-13 12:55:21 UTC (rev 13190)
@@ -1,64 +1,66 @@
<?php
+
class activitycalendar_menu
{
+
function get_menu()
{
- $incoming_app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'activitycalendar';
- $menus = array();
+ $incoming_app
= $GLOBALS['phpgw_info']['flags']['currentapp'];
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'activitycalendar';
+ $menus
= array();
$menus['navbar'] = array
- (
+ (
'activitycalendar' => array
- (
- 'text' => lang('Activitycalendar'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'activitycalendar.uidashboard.index') ),
- 'image' => array('property', 'location'),
- 'order' => 10,
- 'group' => 'office'
+ (
+ 'text' => lang('Activitycalendar'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uidashboard.index')),
+ 'image' => array('property',
'location'),
+ 'order' => 10,
+ 'group' => 'office'
)
);
- $menus['navigation'] = array
- (
- 'dashboard' => array
+ $menus['navigation'] = array
(
- 'text' => lang('dashboard'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'activitycalendar.uidashboard.index') ),
- 'image' => array('property', 'location_tenant'),
+ 'dashboard' => array
+ (
+ 'text' => lang('dashboard'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uidashboard.index')),
+ 'image' => array('property',
'location_tenant'),
),
- 'activities' => array
- (
- 'text' => lang('Activities'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'activitycalendar.uiactivities.index') ),
- 'image' => array('property', 'location_tenant'),
+ 'activities' => array
+ (
+ 'text' => lang('Activities'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uiactivities.index')),
+ 'image' => array('property',
'location_tenant'),
),
- 'arena' => array
- (
- 'text' => lang('Arena'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'activitycalendar.uiarena.index') ),
- 'image' => array('property',
'location_1'),
+ 'arena' => array
+ (
+ 'text' => lang('Arena'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uiarena.index')),
+ 'image' => array('property',
'location_1'),
),
- 'organizationList' => array
- (
- 'text' => lang('OrganizationList'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'activitycalendar.uiorganization.index') ),
- 'image' => array('property', 'location_tenant'),
- 'children' => array(
-
'changed_organizations' => array
- (
- 'text'
=> lang('changed_org_group'),
- 'url'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uiorganization.changed_organizations') ),
- 'image'
=> array('property', 'location_tenant')
- )
- )
- )
+ 'organizationList' => array
+ (
+ 'text' =>
lang('OrganizationList'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uiorganization.index')),
+ 'image' => array('property',
'location_tenant'),
+ 'children' => array(
+ 'changed_organizations' => array
+ (
+ 'text' =>
lang('changed_org_group'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'activitycalendar.uiorganization.changed_organizations')),
+ 'image' =>
array('property', 'location_tenant')
+ )
+ )
+ )
);
-
+
$menus['folders'] =
phpgwapi_menu::get_categories('bergen');
$GLOBALS['phpgw_info']['flags']['currentapp'] =
$incoming_app;
return $menus;
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendar/inc/class.soactivity.inc.php
2015-05-13 06:02:39 UTC (rev 13189)
+++ branches/dev-syncromind/activitycalendar/inc/class.soactivity.inc.php
2015-05-13 12:55:21 UTC (rev 13190)
@@ -1,1550 +1,1575 @@
<?php
-phpgw::import_class('activitycalendar.socommon');
-phpgw::import_class('activitycalendar.soorganization');
-phpgw::import_class('activitycalendar.sogroup');
+ phpgw::import_class('activitycalendar.socommon');
+ phpgw::import_class('activitycalendar.soorganization');
+ phpgw::import_class('activitycalendar.sogroup');
//phpgw::import_class('activitycalendar.socontactperson');
-include_class('activitycalendar', 'activity', 'inc/model/');
-include_class('activitycalendar', 'target', 'inc/model/');
-include_class('activitycalendar', 'category', 'inc/model/');
+ include_class('activitycalendar', 'activity', 'inc/model/');
+ include_class('activitycalendar', 'target', 'inc/model/');
+ include_class('activitycalendar', 'category', 'inc/model/');
-class activitycalendar_soactivity extends activitycalendar_socommon
-{
- protected static $so;
- protected $soap = false;
+ class activitycalendar_soactivity extends activitycalendar_socommon
+ {
- public $soap_functions = array
- (
+ protected static $so;
+ protected $soap = false;
+ public $soap_functions = array
+ (
'get_activities' => array
+ (
+ 'in' => array('array'),
+ 'out' => array('array')
+ )
+ );
+ public $xmlrpc_methods = array
(
- 'in' => array('array'),
- 'out' => array('array')
+ array
+ (
+ 'name' => 'get_activities',
+ 'decription' => 'Get list of activities'
+ ),
+ array
+ (
+ 'name' => 'get_targetgroups',
+ 'decription' => 'Get list of targetgroups'
+ ),
+ array
+ (
+ 'name' => 'get_statuscodes',
+ 'decription' => 'Get list of statuscodes'
+ ),
+ array
+ (
+ 'name' => 'get_category_list',
+ 'decription' => 'Get list of categories'
+ ),
+ array
+ (
+ 'name' => 'get_organizations',
+ 'decription' => 'Get list of organizations'
+ ),
+ array
+ (
+ 'name' => 'get_groups',
+ 'decription' => 'Get list of groups'
+ ),
+ array
+ (
+ 'name' => 'debug_xmlrpc',
+ 'decription' => 'Return incoming params'
)
);
-
- public $xmlrpc_methods = array
- (
- array
- (
- 'name' => 'get_activities',
- 'decription' => 'Get list of activities'
- ),
- array
- (
- 'name' => 'get_targetgroups',
- 'decription' => 'Get list of targetgroups'
- ),
- array
- (
- 'name' => 'get_statuscodes',
- 'decription' => 'Get list of statuscodes'
- ),
- array
- (
- 'name' => 'get_category_list',
- 'decription' => 'Get list of categories'
- ),
- array
- (
- 'name' => 'get_organizations',
- 'decription' => 'Get list of organizations'
- ),
- array
- (
- 'name' => 'get_groups',
- 'decription' => 'Get list of groups'
- ),
- array
- (
- 'name' => 'debug_xmlrpc',
- 'decription' => 'Return incoming params'
- )
- );
-
- var $public_functions = array
- (
- 'get_activities' => true,
- 'get_organizations' => true,
- 'get_groups' => true,
+ var $public_functions = array
+ (
+ 'get_activities' => true,
+ 'get_organizations' => true,
+ 'get_groups' => true,
);
- /**
- * Get a static reference to the storage object associated with this
model object
- *
- * @return rental_soparty the storage object
- */
- public static function get_instance()
- {
- if (self::$so == null) {
- self::$so = CreateObject('activitycalendar.soactivity');
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return rental_soparty the storage object
+ */
+ public static function get_instance()
+ {
+ if(self::$so == null)
+ {
+ self::$so =
CreateObject('activitycalendar.soactivity');
+ }
+ return self::$so;
}
- return self::$so;
- }
- /**
- * Generate SQL query
- *
- * @todo Add support for filter "party_type", meaning what type of
contracts
- * the party is involved in.
- *
- * @param string $sort_field
- * @param boolean $ascending
- * @param string $search_for
- * @param string $search_type
- * @param array $filters
- * @param boolean $return_count
- * @return string SQL
- */
- protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $clauses = array('1=1');
-
- //Add columns to this array to include them in the query
- $columns = array();
-
- if($sort_field != null) {
- $dir = $ascending ? 'ASC' : 'DESC';
- //$order = "ORDER BY id $dir";
- $order = "ORDER BY $sort_field $dir";
- }
- /*else
+ /**
+ * Generate SQL query
+ *
+ * @todo Add support for filter "party_type", meaning what type
of contracts
+ * the party is involved in.
+ *
+ * @param string $sort_field
+ * @param boolean $ascending
+ * @param string $search_for
+ * @param string $search_type
+ * @param array $filters
+ * @param boolean $return_count
+ * @return string SQL
+ */
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
{
- $dir = $ascending ? 'ASC' : 'DESC';
- $order = "ORDER BY id $dir";
- }*/
- //var_dump($search_type);
- //var_dump($search_for);
- if($search_for)
- {
- $query = $this->marshal($search_for,'string');
- $like_pattern = "'%".$search_for."%'";
- $like_clauses = array();
- switch($search_type){
- case "name":
- $like_clauses[] = "party.first_name
$this->like $like_pattern";
- $like_clauses[] = "party.last_name
$this->like $like_pattern";
- $like_clauses[] = "party.company_name
$this->like $like_pattern";
- break;
- case "address":
- $like_clauses[] = "party.address_1
$this->like $like_pattern";
- $like_clauses[] = "party.address_2
$this->like $like_pattern";
- $like_clauses[] = "party.postal_code
$this->like $like_pattern";
- $like_clauses[] = "party.place
$this->like $like_pattern";
- break;
- case "identifier":
- $like_clauses[] = "party.identifier
$this->like $like_pattern";
- break;
- case "reskontro":
- $like_clauses[] = "party.reskontro
$this->like $like_pattern";
- break;
- case "result_unit_number":
- $like_clauses[] =
"party.result_unit_number $this->like $like_pattern";
- break;
- case "all":
- default:
- $like_clauses[] = "activity.title
$this->like $like_pattern";
- break;
- }
+ $clauses = array('1=1');
+ //Add columns to this array to include them in the query
+ $columns = array();
- if(count($like_clauses))
+ if($sort_field != null)
{
- $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ $dir = $ascending ? 'ASC' : 'DESC';
+ //$order = "ORDER BY id $dir";
+ $order = "ORDER BY $sort_field $dir";
}
- }
+ /* else
+ {
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = "ORDER BY id $dir";
+ } */
+ //var_dump($search_type);
+ //var_dump($search_for);
+ if($search_for)
+ {
+ $query =
$this->marshal($search_for, 'string');
+ $like_pattern = "'%" . $search_for . "%'";
+ $like_clauses = array();
+ switch($search_type)
+ {
+ case "name":
+ $like_clauses[] =
"party.first_name $this->like $like_pattern";
+ $like_clauses[] =
"party.last_name $this->like $like_pattern";
+ $like_clauses[] =
"party.company_name $this->like $like_pattern";
+ break;
+ case "address":
+ $like_clauses[] =
"party.address_1 $this->like $like_pattern";
+ $like_clauses[] =
"party.address_2 $this->like $like_pattern";
+ $like_clauses[] =
"party.postal_code $this->like $like_pattern";
+ $like_clauses[] = "party.place
$this->like $like_pattern";
+ break;
+ case "identifier":
+ $like_clauses[] =
"party.identifier $this->like $like_pattern";
+ break;
+ case "reskontro":
+ $like_clauses[] =
"party.reskontro $this->like $like_pattern";
+ break;
+ case "result_unit_number":
+ $like_clauses[] =
"party.result_unit_number $this->like $like_pattern";
+ break;
+ case "all":
+ default:
+ $like_clauses[] =
"activity.title $this->like $like_pattern";
+ break;
+ }
- $filter_clauses = array();
- if(isset($filters[$this->get_id_field_name()])){
- $id =
$this->marshal($filters[$this->get_id_field_name()],'int');
- $filter_clauses[] = "activity.id = {$id}";
- }
- if(isset($filters['new_activities']))
- {
- if(!isset($filters['activity_state']) ||
(isset($filters['activity_state']) && $filters['activity_state'] == 'all')){
- $filter_clauses[] = "(activity.state=1 OR
activity.state=2)";
- }
- if(isset($filters['activity_state']) &&
$filters['activity_state'] != 'all'){
- $activity_state =
$this->marshal($filters['activity_state'],'int');
- $filter_clauses[] = "activity.state =
{$activity_state}";
- }
- if(isset($filters['activity_org']) &&
$filters['activity_org'] != '0'){
- $activity_org =
$this->marshal($filters['activity_org'],'int');
- $filter_clauses[] = "activity.organization_id =
{$activity_org}";
- }
- if(isset($filters['activity_category']) &&
$filters['activity_category'] != 'all'){
- $activity_category =
$this->marshal($filters['activity_category'],'int');
- $filter_clauses[] = "activity.category =
{$activity_category}";
- }
- if(isset($filters['activity_district'])){
- if($filters['activity_district'] != 'all')
+ if(count($like_clauses))
{
- $activity_district =
$this->marshal($filters['activity_district'],'int');
- $filter_clauses[] = "activity.office =
'{$activity_district}'";
+ $clauses[] = '(' . join(' OR ',
$like_clauses) . ')';
}
}
- else
+
+ $filter_clauses = array();
+
+ if(isset($filters[$this->get_id_field_name()]))
{
- $activity_district =
$this->get_office_from_user($filters['user_id']);
- if($activity_district && $activity_district !=
'')
+ $id =
$this->marshal($filters[$this->get_id_field_name()], 'int');
+ $filter_clauses[] = "activity.id =
{$id}";
+ }
+ if(isset($filters['new_activities']))
+ {
+ if(!isset($filters['activity_state']) ||
(isset($filters['activity_state']) && $filters['activity_state'] == 'all'))
{
- if($activity_district == 1)
- $activity_district_corr = 2;
- else if ($activity_district == 2)
- $activity_district_corr = 1;
- else
- $activity_district_corr =
(int)$activity_district;
+ $filter_clauses[] = "(activity.state=1
OR activity.state=2)";
+ }
+ if(isset($filters['activity_state']) &&
$filters['activity_state'] != 'all')
+ {
+ $activity_state =
$this->marshal($filters['activity_state'], 'int');
+ $filter_clauses[] =
"activity.state = {$activity_state}";
+ }
+ if(isset($filters['activity_org']) &&
$filters['activity_org'] != '0')
+ {
+ $activity_org =
$this->marshal($filters['activity_org'], 'int');
+ $filter_clauses[] =
"activity.organization_id = {$activity_org}";
+ }
+ if(isset($filters['activity_category']) &&
$filters['activity_category'] != 'all')
+ {
+ $activity_category =
$this->marshal($filters['activity_category'], 'int');
+ $filter_clauses[] =
"activity.category = {$activity_category}";
+ }
+ if(isset($filters['activity_district']))
+ {
+ if($filters['activity_district'] !=
'all')
+ {
+ $activity_district =
$this->marshal($filters['activity_district'], 'int');
+ $filter_clauses[] =
"activity.office = '{$activity_district}'";
+ }
+ }
+ else
+ {
+ $activity_district =
$this->get_office_from_user($filters['user_id']);
+ if($activity_district &&
$activity_district != '')
+ {
+ if($activity_district == 1)
+ $activity_district_corr
= 2;
+ else if($activity_district == 2)
+ $activity_district_corr
= 1;
+ else
+ $activity_district_corr
= (int)$activity_district;
- $filter_clauses[] = "activity.office =
'{$activity_district_corr}'";
+ $filter_clauses[] =
"activity.office = '{$activity_district_corr}'";
+ }
}
- }
- if(isset($filters['updated_date_hidden']) &&
$filters['updated_date_hidden'] != "")
- {
- $ts_query =
strtotime($filters['updated_date_hidden']); // target timestamp specified by
user
- $filter_clauses[] = "activity.last_change_date
< {$ts_query}";
- }
- }
- else
- {
- if(isset($filters['activity_state']) &&
$filters['activity_state'] != 'all'){
- $activity_state =
$this->marshal($filters['activity_state'],'int');
- $filter_clauses[] = "activity.state =
{$activity_state}";
- }
- if(isset($filters['activity_org']) &&
$filters['activity_org'] != '0'){
- $activity_org =
$this->marshal($filters['activity_org'],'int');
- $filter_clauses[] = "activity.organization_id =
{$activity_org}";
- }
- if(isset($filters['activity_category']) &&
$filters['activity_category'] != 'all'){
- $activity_category =
$this->marshal($filters['activity_category'],'int');
- $filter_clauses[] = "activity.category =
{$activity_category}";
- }
- if(isset($filters['activity_district'])){
- if($filters['activity_district'] != 'all')
+ if(isset($filters['updated_date_hidden']) &&
$filters['updated_date_hidden'] != "")
{
- $activity_district =
$this->marshal($filters['activity_district'],'int');
- $filter_clauses[] = "activity.office =
'{$activity_district}'";
+ $ts_query =
strtotime($filters['updated_date_hidden']); // target timestamp specified by
user
+ $filter_clauses[] =
"activity.last_change_date < {$ts_query}";
}
}
else
{
- $activity_district =
$this->get_office_from_user($filters['user_id']);
- if($activity_district && $activity_district !=
'')
+ if(isset($filters['activity_state']) &&
$filters['activity_state'] != 'all')
{
- if($activity_district == 1)
- $activity_district = 2;
- else if ($activity_district == 2)
- $activity_district = 1;
+ $activity_state =
$this->marshal($filters['activity_state'], 'int');
+ $filter_clauses[] =
"activity.state = {$activity_state}";
+ }
+ if(isset($filters['activity_org']) &&
$filters['activity_org'] != '0')
+ {
+ $activity_org =
$this->marshal($filters['activity_org'], 'int');
+ $filter_clauses[] =
"activity.organization_id = {$activity_org}";
+ }
+ if(isset($filters['activity_category']) &&
$filters['activity_category'] != 'all')
+ {
+ $activity_category =
$this->marshal($filters['activity_category'], 'int');
+ $filter_clauses[] =
"activity.category = {$activity_category}";
+ }
+ if(isset($filters['activity_district']))
+ {
+ if($filters['activity_district'] !=
'all')
+ {
+ $activity_district =
$this->marshal($filters['activity_district'], 'int');
+ $filter_clauses[] =
"activity.office = '{$activity_district}'";
+ }
+ }
+ else
+ {
+ $activity_district =
$this->get_office_from_user($filters['user_id']);
+ if($activity_district &&
$activity_district != '')
+ {
+ if($activity_district == 1)
+ $activity_district
= 2;
+ else if($activity_district == 2)
+ $activity_district
= 1;
- $filter_clauses[] = "activity.office =
'{$activity_district}'";
+ $filter_clauses[] =
"activity.office = '{$activity_district}'";
+ }
}
+ if(isset($filters['updated_date_hidden']) &&
$filters['updated_date_hidden'] != "")
+ {
+ $ts_query =
strtotime($filters['updated_date_hidden']); // target timestamp specified by
user
+ $filter_clauses[] =
"activity.last_change_date < {$ts_query}";
+ }
}
- if(isset($filters['updated_date_hidden']) &&
$filters['updated_date_hidden'] != "")
+
+ if(count($filter_clauses))
{
- $ts_query =
strtotime($filters['updated_date_hidden']); // target timestamp specified by
user
- $filter_clauses[] = "activity.last_change_date
< {$ts_query}";
+ $clauses[] = join(' AND ', $filter_clauses);
}
- }
- if(count($filter_clauses))
- {
- $clauses[] = join(' AND ', $filter_clauses);
- }
+ $condition = join(' AND ', $clauses);
- $condition = join(' AND ', $clauses);
+ if($return_count) // We should only return a count
+ {
+ $cols = 'COUNT(DISTINCT(activity.id)) AS count';
+ }
+ else
+ {
+ $columns[] = 'activity.id';
+ $columns[] = 'activity.title';
+ $columns[] = 'activity.organization_id';
+ $columns[] = 'activity.group_id';
+ $columns[] = 'activity.district';
+ $columns[] = 'activity.office';
+ $columns[] = 'activity.state';
+ $columns[] = 'activity.category';
+ $columns[] = 'activity.target';
+ $columns[] = 'activity.description';
+ $columns[] = 'activity.arena';
+ $columns[] = 'activity.internal_arena';
+ $columns[] = 'activity.time';
+ $columns[] = 'activity.create_date';
+ $columns[] = 'activity.last_change_date';
+ $columns[] = 'activity.contact_person_1';
+ $columns[] = 'activity.contact_person_2';
+ $columns[] =
'activity.contact_person_2_address';
+ $columns[] =
'activity.contact_person_2_zip';
+ $columns[] =
'activity.special_adaptation';
+ $columns[] = 'activity.secret';
+ $columns[] = 'activity.frontend';
+ $columns[] = 'activity.new_org';
+ $columns[] = 'activity.new_group';
- if($return_count) // We should only return a count
- {
- $cols = 'COUNT(DISTINCT(activity.id)) AS count';
+ $cols = implode(',', $columns);
+ }
+
+ $tables = "activity_activity activity";
+
+ //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
+ //{$this->left_join} rental_contract contract ON
(contract.id = c_p.contract_id)";
+ //var_dump("SELECT {$cols} FROM {$tables} WHERE
{$condition} {$order}");
+ return "SELECT {$cols} FROM {$tables} WHERE
{$condition} {$order}";
}
- else
+
+ /**
+ * Function for adding a new activity to the database. Updates
the activity object.
+ *
+ * @param activitycalendar_activity $activity the party to be
added
+ * @return bool true if successful, false otherwise
+ */
+ function add(&$activity)
{
- $columns[] = 'activity.id';
- $columns[] = 'activity.title';
- $columns[] = 'activity.organization_id';
- $columns[] = 'activity.group_id';
- $columns[] = 'activity.district';
- $columns[] = 'activity.office';
- $columns[] = 'activity.state';
- $columns[] = 'activity.category';
- $columns[] = 'activity.target';
- $columns[] = 'activity.description';
- $columns[] = 'activity.arena';
- $columns[] = 'activity.internal_arena';
- $columns[] = 'activity.time';
- $columns[] = 'activity.create_date';
- $columns[] = 'activity.last_change_date';
- $columns[] = 'activity.contact_person_1';
- $columns[] = 'activity.contact_person_2';
- $columns[] = 'activity.contact_person_2_address';
- $columns[] = 'activity.contact_person_2_zip';
- $columns[] = 'activity.special_adaptation';
- $columns[] = 'activity.secret';
- $columns[] = 'activity.frontend';
- $columns[] = 'activity.new_org';
- $columns[] = 'activity.new_group';
+ // Insert a new activity
+ $ts_now = strtotime('now');
+ $secret = $this->generate_secret();
+ $q = "INSERT INTO activity_activity
(title, create_date,secret) VALUES ('tmptitle', $ts_now, '{$secret}')";
+ $result = $this->db->query($q, __LINE__, __FILE__);
- $cols = implode(',',$columns);
+ if(isset($result))
+ {
+ // Set the new party ID
+
$activity->set_id($this->db->get_last_insert_id('activity_activity', 'id'));
+ // Forward this request to the update method
+ return $this->update($activity);
+ }
+ else
+ {
+ return false;
+ }
}
- $tables = "activity_activity activity";
+ /**
+ * Update the database values for an existing activity object.
+ *
+ * @param $activity the activity to be updated
+ * @return boolean true if successful, false otherwise
+ */
+ function update($activity)
+ {
+ $id = intval($activity->get_id());
+ $ts_now = strtotime('now');
- //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
- //{$this->left_join} rental_contract contract ON (contract.id =
c_p.contract_id)";
+ $values = array(
+ 'title = ' .
$this->marshal($activity->get_title(), 'string'),
+ 'organization_id = ' .
$this->marshal($activity->get_organization_id(), 'int'),
+ 'group_id = ' .
$this->marshal($activity->get_group_id(), 'int'),
+ 'district = ' .
$this->marshal($activity->get_district(), 'string'),
+ 'office = ' .
$this->marshal($activity->get_office(), 'int'),
+ 'category = ' .
$this->marshal($activity->get_category(), 'int'),
+ 'state = ' .
$this->marshal($activity->get_state(), 'int'),
+ 'target = ' .
$this->marshal($activity->get_target(), 'string'),
+ 'description = ' .
$this->marshal($activity->get_description(), 'string'),
+ 'arena = ' .
$this->marshal($activity->get_arena(), 'int'),
+ 'internal_arena = ' .
$this->marshal($activity->get_internal_arena(), 'int'),
+ 'time = ' .
$this->marshal($activity->get_time(), 'string'),
+ 'last_change_date = ' . $this->marshal($ts_now,
'int'),
+ 'contact_person_1 = ' .
$this->marshal($activity->get_contact_person_1(), 'int'),
+ 'contact_person_2 = ' .
$this->marshal($activity->get_contact_person_2(), 'int'),
+ 'contact_person_2_address = ' .
$this->marshal($activity->get_contact_person_2_address(), 'string'),
+ 'contact_person_2_zip = ' .
$this->marshal($activity->get_contact_person_2_zip(), 'string'),
+ 'special_adaptation = ' .
($activity->get_special_adaptation() ? "true" : "false"),
+ 'frontend = ' . ($activity->get_frontend() ?
"true" : "false"),
+ 'new_org = ' . ($activity->get_new_org() ?
"true" : "false"),
+ 'new_group = ' . ($activity->get_new_group() ?
"true" : "false")
+ );
- //var_dump("SELECT {$cols} FROM {$tables} WHERE {$condition}
{$order}");
- return "SELECT {$cols} FROM {$tables} WHERE {$condition}
{$order}";
- }
+ //var_dump('UPDATE activity_activity SET ' . join(',',
$values) . " WHERE id=$id");
+ $result = $this->db->query('UPDATE activity_activity
SET ' . join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
+ return isset($result);
+ }
-
- /**
- * Function for adding a new activity to the database. Updates the
activity object.
- *
- * @param activitycalendar_activity $activity the party to be added
- * @return bool true if successful, false otherwise
- */
- function add(&$activity)
- {
- // Insert a new activity
- $ts_now = strtotime('now');
- $secret = $this->generate_secret();
- $q ="INSERT INTO activity_activity (title, create_date,secret)
VALUES ('tmptitle', $ts_now, '{$secret}')";
- $result = $this->db->query($q, __LINE__,__FILE__);
-
- if(isset($result)) {
- // Set the new party ID
-
$activity->set_id($this->db->get_last_insert_id('activity_activity', 'id'));
- // Forward this request to the update method
- return $this->update($activity);
- }
- else
+ function import_activity($activity)
{
- return false;
- }
- }
+ $id = intval($activity->get_id());
+ $ts_now = strtotime('now');
- /**
- * Update the database values for an existing activity object.
- *
- * @param $activity the activity to be updated
- * @return boolean true if successful, false otherwise
- */
- function update($activity)
- {
- $id = intval($activity->get_id());
- $ts_now = strtotime('now');
+ $columns = array(
+ 'title',
+ 'organization_id',
+ 'group_id',
+ 'district',
+ 'office',
+ 'category',
+ 'state',
+ 'target',
+ 'description',
+ 'arena',
+ 'internal_arena',
+ 'time',
+ 'last_change_date',
+ 'create_date',
+ 'contact_person_1',
+ 'contact_person_2',
+ 'contact_person_2_address',
+ 'contact_person_2_zip',
+ 'secret',
+ 'special_adaptation'
+ );
- $values = array(
- 'title = ' . $this->marshal($activity->get_title(),
'string'),
- 'organization_id = '.
$this->marshal($activity->get_organization_id(), 'int'),
- 'group_id = ' .
$this->marshal($activity->get_group_id(), 'int'),
- 'district = ' .
$this->marshal($activity->get_district(), 'string'),
- 'office = ' .
$this->marshal($activity->get_office(), 'int'),
- 'category = ' .
$this->marshal($activity->get_category(), 'int'),
- 'state = ' .
$this->marshal($activity->get_state(), 'int'),
- 'target = ' . $this->marshal($activity->get_target(),
'string'),
- 'description = ' .
$this->marshal($activity->get_description(), 'string'),
- 'arena = ' .
$this->marshal($activity->get_arena(), 'int'),
- 'internal_arena = ' .
$this->marshal($activity->get_internal_arena(), 'int'),
- 'time = ' . $this->marshal($activity->get_time(),
'string'),
- 'last_change_date = ' . $this->marshal($ts_now,
'int'),
- 'contact_person_1 = ' .
$this->marshal($activity->get_contact_person_1(), 'int'),
- 'contact_person_2 = ' .
$this->marshal($activity->get_contact_person_2(), 'int'),
- 'contact_person_2_address = ' .
$this->marshal($activity->get_contact_person_2_address(), 'string'),
- 'contact_person_2_zip = ' .
$this->marshal($activity->get_contact_person_2_zip(), 'string'),
- 'special_adaptation = '
.($activity->get_special_adaptation() ? "true" : "false"),
- 'frontend = '
.($activity->get_frontend() ? "true" : "false"),
- 'new_org = '
.($activity->get_new_org() ? "true" : "false"),
- 'new_group = '
.($activity->get_new_group() ? "true" : "false")
- );
+ $values = array(
+ $this->marshal($activity->get_title(),
'string'),
+
$this->marshal($activity->get_organization_id(), 'int'),
+ $this->marshal($activity->get_group_id(),
'int'),
+ $this->marshal($activity->get_district(),
'string'),
+ $this->marshal($activity->get_office(), 'int'),
+ $this->marshal($activity->get_category(),
'int'),
+ $this->marshal($activity->get_state(), 'int'),
+ $this->marshal($activity->get_target(),
'string'),
+ $this->marshal($activity->get_description(),
'string'),
+ $this->marshal($activity->get_arena(), 'int'),
+ $this->marshal($activity->get_internal_arena(),
'int'),
+ $this->marshal($activity->get_time(), 'string'),
+
$this->marshal($activity->get_last_change_date(), 'int'),
+ $this->marshal($ts_now, 'int'),
+
$this->marshal($activity->get_contact_person_1(), 'int'),
+
$this->marshal($activity->get_contact_person_2(), 'int'),
+
$this->marshal($activity->get_contact_person_2_address(), 'string'),
+
$this->marshal($activity->get_contact_person_2_zip(), 'string'),
+ $this->marshal($this->generate_secret(),
'string'),
+ ($activity->get_special_adaptation() ? "true" :
"false")
+ );
- //var_dump('UPDATE activity_activity SET ' . join(',', $values)
. " WHERE id=$id");
- $result = $this->db->query('UPDATE activity_activity SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
+ $result = $this->db->query('INSERT INTO
activity_activity (' . join(',', $columns) . ') VALUES (' . join(',', $values)
. ')', __LINE__, __FILE__);
- return isset($result);
- }
+ return isset($result);
+ }
- function import_activity($activity)
- {
- $id = intval($activity->get_id());
- $ts_now = strtotime('now');
-
- $columns = array(
- 'title',
- 'organization_id',
- 'group_id',
- 'district',
- 'office',
- 'category',
- 'state',
- 'target',
- 'description',
- 'arena',
- 'internal_arena',
- 'time',
- 'last_change_date',
- 'create_date',
- 'contact_person_1',
- 'contact_person_2',
- 'contact_person_2_address',
- 'contact_person_2_zip',
- 'secret',
- 'special_adaptation'
- );
-
- $values = array(
- $this->marshal($activity->get_title(), 'string'),
- $this->marshal($activity->get_organization_id(), 'int'),
- $this->marshal($activity->get_group_id(), 'int'),
- $this->marshal($activity->get_district(), 'string'),
- $this->marshal($activity->get_office(), 'int'),
- $this->marshal($activity->get_category(), 'int'),
- $this->marshal($activity->get_state(), 'int'),
- $this->marshal($activity->get_target(), 'string'),
- $this->marshal($activity->get_description(), 'string'),
- $this->marshal($activity->get_arena(), 'int'),
- $this->marshal($activity->get_internal_arena(), 'int'),
- $this->marshal($activity->get_time(), 'string'),
- $this->marshal($activity->get_last_change_date(),
'int'),
- $this->marshal($ts_now, 'int'),
- $this->marshal($activity->get_contact_person_1(),
'int'),
- $this->marshal($activity->get_contact_person_2(),
'int'),
-
$this->marshal($activity->get_contact_person_2_address(), 'string'),
- $this->marshal($activity->get_contact_person_2_zip(),
'string'),
- $this->marshal($this->generate_secret(),'string'),
- ($activity->get_special_adaptation() ? "true" : "false")
- );
-
- $result = $this->db->query('INSERT INTO activity_activity (' .
join(',', $columns) . ') VALUES (' . join(',', $values) . ')',
__LINE__,__FILE__);
-
- return isset($result);
- }
-
- public function get_id_field_name($extended_info = false)
- {
- if(!$extended_info)
+ public function get_id_field_name($extended_info = false)
{
- $ret = 'id';
+ if(!$extended_info)
+ {
+ $ret = 'id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' => 'activity', // alias
+ 'field' => 'id',
+ 'translated' => 'id'
+ );
+ }
+ return $ret;
}
- else
+
+ protected function populate(int $activity_id, &$activity)
{
- $ret = array
- (
- 'table' => 'activity', // alias
- 'field' => 'id',
- 'translated' => 'id'
- );
- }
- return $ret;
- }
- protected function populate(int $activity_id, &$activity)
- {
+ if($activity == null)
+ {
+ $activity = new
activitycalendar_activity((int)$activity_id);
- if($activity == null) {
- $activity = new activitycalendar_activity((int)
$activity_id);
+
$activity->set_title($this->unmarshal($this->db->f('title'), 'string'));
+
$activity->set_organization_id($this->unmarshal($this->db->f('organization_id'),
'int'));
+
$activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
+
$activity->set_district($this->unmarshal($this->db->f('district'), 'string'));
+
$activity->set_office($this->unmarshal($this->db->f('office'), 'int'));
+
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
+
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
+
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
+
$activity->set_description($this->unmarshal($this->db->f('description'),
'string'));
+
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
+
$activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'),
'string'));
+
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
+
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
'int'));
+
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
'bool')));
+
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
+
$activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'),
'string'));
+
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
'string'));
+
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
+
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
+
$activity->set_new_group($this->unmarshal($this->db->f('new_group', 'bool')));
-
$activity->set_title($this->unmarshal($this->db->f('title'), 'string'));
-
$activity->set_organization_id($this->unmarshal($this->db->f('organization_id'),
'int'));
-
$activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
-
$activity->set_district($this->unmarshal($this->db->f('district'), 'string'));
-
$activity->set_office($this->unmarshal($this->db->f('office'), 'int'));
-
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
-
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
-
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
-
$activity->set_description($this->unmarshal($this->db->f('description'),
'string'));
-
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
-
$activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'),
'string'));
-
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
-
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
'int'));
-
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
'bool')));
-
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
-
$activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'),
'string'));
-
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
'string'));
-
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
-
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
-
$activity->set_new_group($this->unmarshal($this->db->f('new_group', 'bool')));
-
- if($activity->get_group_id() &&
$activity->get_group_id() > 0)
- {
- if($activity->get_new_group())
+ if($activity->get_group_id() &&
$activity->get_group_id() > 0)
{
- $contacts =
activitycalendar_sogroup::get_instance()->get_contacts_local($activity->get_group_id());
-
$activity->set_contact_persons($contacts);
- //$org_tmp =
activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id());
-
//$activity->set_organization_id($org_tmp);
+ if($activity->get_new_group())
+ {
+ $contacts =
activitycalendar_sogroup::get_instance()->get_contacts_local($activity->get_group_id());
+
$activity->set_contact_persons($contacts);
+ //$org_tmp =
activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id());
+
//$activity->set_organization_id($org_tmp);
+ }
+ else
+ {
+ $contacts =
activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id());
+
$activity->set_contact_persons($contacts);
+ $org_tmp =
activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id());
+
$activity->set_organization_id($org_tmp);
+ }
}
- else
+ else if($activity->get_organization_id() &&
$activity->get_organization_id() > 0)
{
- $contacts =
activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id());
-
$activity->set_contact_persons($contacts);
- $org_tmp =
activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id());
-
$activity->set_organization_id($org_tmp);
+ if($activity->get_new_org())
+ {
+ $contacts =
activitycalendar_soorganization::get_instance()->get_contacts_local($activity->get_organization_id());
+
$activity->set_contact_persons($contacts);
+ }
+ else
+ {
+ $contacts =
activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id());
+
$activity->set_contact_persons($contacts);
+ }
}
}
- else if($activity->get_organization_id() &&
$activity->get_organization_id() > 0)
+
+ return $activity;
+ }
+
+ function get_category_name($category_id)
+ {
+ $result = "Ingen";
+ if($category_id != null)
{
- if($activity->get_new_org())
+ $sql = "SELECT name FROM bb_activity where
id=$category_id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
{
- $contacts =
activitycalendar_soorganization::get_instance()->get_contacts_local($activity->get_organization_id());
-
$activity->set_contact_persons($contacts);
+ $result = $this->db->f('name');
}
- else
- {
- $contacts =
activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id());
-
$activity->set_contact_persons($contacts);
- }
}
-
+ return $result;
}
- return $activity;
- }
-
- function get_category_name($category_id)
- {
- $result = "Ingen";
- if($category_id != null)
+ function get_categories()
{
- $sql = "SELECT name FROM bb_activity where
id=$category_id";
+ $categories = array();
+ $sql = "SELECT * FROM bb_activity where
active=1 and parent_id=1";
$this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('name');
+ while($this->db->next_record())
+ {
+ $category = new
activitycalendar_category($this->db->f('id'));
+
$category->set_parent_id($this->db->f('parent_id'));
+ $category->set_name($this->db->f('name'));
+ $categories[] = $category;
}
- }
- return $result;
- }
-
- function get_categories()
- {
- $categories = array();
- $sql = "SELECT * FROM bb_activity where active=1 and
parent_id=1";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $category = new
activitycalendar_category($this->db->f('id'));
- $category->set_parent_id($this->db->f('parent_id'));
- $category->set_name($this->db->f('name'));
- $categories[] = $category;
+ return $categories;
}
- return $categories;
- }
- function select_district_list()
- {
- $this->db->query("SELECT id, descr FROM fm_district where id
>'0' AND NOT descr LIKE '%vrige%' ORDER BY id ", __LINE__, __FILE__);
-
- $i = 0;
- while ($this->db->next_record())
+ function select_district_list()
{
- $district[$i]['id'] = $this->db->f('id');
- $district[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
+ $this->db->query("SELECT id, descr FROM fm_district
where id >'0' AND NOT descr LIKE '%vrige%' ORDER BY id ", __LINE__, __FILE__);
- return $district;
- }
+ $i = 0;
+ while($this->db->next_record())
+ {
+ $district[$i]['id'] =
$this->db->f('id');
+ $district[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
- function get_district_from_name($name)
- {
- $this->db->query("SELECT part_of_town_id FROM fm_part_of_town
where name like UPPER('%{$name}%') ", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('part_of_town_id');
+ return $district;
}
- return $result;
- }
- function get_district_from_id($d_id)
- {
- $this->db->query("SELECT name FROM fm_part_of_town where
part_of_town_id={$d_id} ", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('name');
+ function get_district_from_name($name)
+ {
+ $this->db->query("SELECT part_of_town_id FROM
fm_part_of_town where name like UPPER('%{$name}%') ", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('part_of_town_id');
+ }
+ return $result;
}
- return $result;
- }
-
- function get_district_name($district_id)
- {
- //$result = "Ingen";
- $values = array();
- if($district_id != null)
+ function get_district_from_id($d_id)
{
- $sql = "SELECT district_id, name FROM fm_part_of_town
where part_of_town_id in ($district_id)";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $name = $this->db->f('name');
- $values[] = $name;
- //$result .= $name . ',';
+ $this->db->query("SELECT name FROM fm_part_of_town
where part_of_town_id={$d_id} ", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name');
}
- $result = implode(", ",$values);
return $result;
- }
- return "";
- }
+ }
- function get_districts()
- {
- $this->db->query("SELECT part_of_town_id, name FROM
fm_part_of_town district_id ", __LINE__, __FILE__);
-
- $i = 0;
- while ($this->db->next_record())
+ function get_district_name($district_id)
{
- $name = $this->db->f('name');
- if($name != 'ØVRIGE')
+ //$result = "Ingen";
+ $values = array();
+ if($district_id != null)
{
- $district[$i]['part_of_town_id'] =
$this->db->f('part_of_town_id');
- $district[$i]['name'] =
stripslashes($this->db->f('name'));
- $i++;
+ $sql = "SELECT district_id, name FROM
fm_part_of_town where part_of_town_id in ($district_id)";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $name = $this->db->f('name');
+ $values[] = $name;
+ //$result .= $name . ',';
+ }
+ $result = implode(", ", $values);
+ return $result;
}
+ return "";
}
- return $district;
- }
+ function get_districts()
+ {
+ $this->db->query("SELECT part_of_town_id, name FROM
fm_part_of_town district_id ", __LINE__, __FILE__);
+ $i = 0;
+ while($this->db->next_record())
+ {
+ $name = $this->db->f('name');
+ if($name != 'ØVRIGE')
+ {
+ $district[$i]['part_of_town_id'] =
$this->db->f('part_of_town_id');
+ $district[$i]['name']
= stripslashes($this->db->f('name'));
+ $i++;
+ }
+ }
- function get_office_from_user($user_id)
- {
- if(user_id)
+ return $district;
+ }
+
+ function get_office_from_user($user_id)
{
- $user_id = (int)$user_id;
- $q1="SELECT office FROM bb_office_user WHERE
account_id={$user_id}";
- //var_dump($q1);
- $this->db->query($q1, __LINE__, __FILE__);
- while($this->db->next_record()){
- $office_id = $this->db->f('office');
+ if(user_id)
+ {
+ $user_id = (int)$user_id;
+ $q1 = "SELECT office FROM
bb_office_user WHERE account_id={$user_id}";
+ //var_dump($q1);
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $office_id = $this->db->f('office');
+ }
}
+ return $office_id;
}
- return $office_id;
- }
- function get_office_name($district_id)
- {
- $result = "Ingen";
- if($district_id != null)
+ function get_office_name($district_id)
{
- $sql = "SELECT descr FROM fm_district where
id=$district_id";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('descr');
+ $result = "Ingen";
+ if($district_id != null)
+ {
+ $sql = "SELECT descr FROM fm_district where
id=$district_id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('descr');
+ }
}
- }
- return $result;
- }
-
- function get_office_description($office_id)
- {
- $result = "";
- if($office_id != null)
- {
- $sql = "SELECT description FROM bb_office where id=$office_id";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('description');
+ return $result;
}
- }
- return $result;
- }
- function get_target_name($target_id)
- {
- $result = "Ingen";
- if($target_id != null)
+ function get_office_description($office_id)
{
- $sql = "SELECT name FROM bb_agegroup where
id=$target_id";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('name');
+ $result = "";
+ if($office_id != null)
+ {
+ $sql = "SELECT description FROM bb_office where
id=$office_id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('description');
+ }
}
- }
- return $result;
- }
+ return $result;
+ }
- function get_targets()
- {
- $targets = array();
- $sql = "SELECT * FROM bb_agegroup where active=1 ORDER BY sort";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $name = $this->db->f('name');
- if($name != 'Tilskuere')
+ function get_target_name($target_id)
+ {
+ $result = "Ingen";
+ if($target_id != null)
{
- $target = new
activitycalendar_target($this->db->f('id'));
-
$target->set_description($this->db->f('description'));
- $target->set_name($this->db->f('name'));
- $targets[] = $target;
+ $sql = "SELECT name FROM bb_agegroup where
id=$target_id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name');
+ }
}
+ return $result;
}
- return $targets;
- }
- function get_category_from_name($name)
- {
- if($name != null)
- {
- $sql = "select id from bb_activity where name like
'%{$name}%'";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('id');
+ function get_targets()
+ {
+ $targets = array();
+ $sql = "SELECT * FROM bb_agegroup where active=1
ORDER BY sort";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $name = $this->db->f('name');
+ if($name != 'Tilskuere')
+ {
+ $target = new
activitycalendar_target($this->db->f('id'));
+
$target->set_description($this->db->f('description'));
+ $target->set_name($this->db->f('name'));
+ $targets[] = $target;
+ }
}
- }
- return $result;
- }
+ return $targets;
+ }
- function get_target_from_sort_id($id)
- {
- if($id != null && is_numeric($id))
- {
- $sql = "select id from bb_agegroup where sort={$id} and
active=1";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('id');
+ function get_category_from_name($name)
+ {
+ if($name != null)
+ {
+ $sql = "select id from bb_activity where name
like '%{$name}%'";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('id');
+ }
}
- }
- return $result;
- }
+ return $result;
+ }
- function get_orgid_from_orgno($orgno)
- {
- if($orgno != null)
- {
- $sql = "select id from bb_organization where
organization_number='{$orgno}'";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('id');
+ function get_target_from_sort_id($id)
+ {
+ if($id != null && is_numeric($id))
+ {
+ $sql = "select id from bb_agegroup where
sort={$id} and active=1";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('id');
+ }
}
- }
- return $result;
- }
+ return $result;
+ }
- function update_org_description($org_id, $description)
- {
- if($org_id != null)
- {
- $sql = "update bb_organization set
description='{$description}' where id={$org_id}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- }
- return isset($result);
- }
-
- function set_org_active($org_id)
- {
- if($org_id != null)
+ function get_orgid_from_orgno($orgno)
{
- $sql = "update bb_organization set show_in_portal=1
where id={$org_id}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
+ if($orgno != null)
+ {
+ $sql = "select id from bb_organization where
organization_number='{$orgno}'";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('id');
+ }
+ }
+ return $result;
}
- return isset($result);
- }
- function get_activities($parameters = array())
- {
- $soap = isset($parameters['soap']) && $parameters['soap'] ?
true : false;
- $this->soap = $soap;
- //fromdate -> innparam for uthenting av delta - timestamp
- $whereclause_date = "";
- if($parameters['fromdate'])
+ function update_org_description($org_id, $description)
{
- $from_date = (int)$parameters['fromdate'];
- $whereclause_date = "AND last_change_date >
{$from_date}";
+ if($org_id != null)
+ {
+ $sql = "update bb_organization set
description='{$description}' where id={$org_id}";
+ $result = $this->db->query($sql, __LINE__,
__FILE__);
+ }
+ return isset($result);
}
- $activities = array();
- $sql = "SELECT * FROM activity_activity where state in (2,3,5)
{$whereclause_date}";
- $this->db->query($sql, __LINE__, __FILE__);
- while ($this->db->next_record())
+
+ function set_org_active($org_id)
{
- $gr = $this->db->f('group_id');
- $activities[]= array
- (
- 'id' => (int)
$this->db->f('id'),
- 'title' => $soap ?
$this->db->f('title',true) : utf8_decode($this->db->f('title',true)),
- 'organization_id' =>
$this->db->f('organization_id'),
- 'group_id' =>
$this->db->f('group_id'),
- 'district' =>
$this->db->f('district'),
- 'category' =>
$this->db->f('category'),
- 'state' =>
$this->db->f('state'),
- 'target' =>
$this->db->f('target'),
- 'arena' =>
$this->db->f('arena'),
- 'internal_arena' =>
$this->db->f('internal_arena'),
- 'time' => $soap ?
$this->db->f('time',true) : utf8_decode($this->db->f('time',true)),
- 'contact_person_1' =>
$this->db->f('contact_person_1'),
- 'contact_person_2' =>
$this->db->f('contact_person_2'),
- 'special_adaptation'=>
$this->db->f('special_adaptation'),
- );
+ if($org_id != null)
+ {
+ $sql = "update bb_organization set
show_in_portal=1 where id={$org_id}";
+ $result = $this->db->query($sql, __LINE__,
__FILE__);
+ }
+ return isset($result);
}
- foreach ($activities as &$activity)
+ function get_activities($parameters = array())
{
+ $soap =
isset($parameters['soap']) && $parameters['soap'] ? true : false;
+ $this->soap = $soap;
+ //fromdate -> innparam for uthenting av delta -
timestamp
+ $whereclause_date = "";
+ if($parameters['fromdate'])
+ {
+ $from_date =
(int)$parameters['fromdate'];
+ $whereclause_date = "AND
last_change_date > {$from_date}";
+ }
+ $activities = array();
+ $sql = "SELECT * FROM activity_activity
where state in (2,3,5) {$whereclause_date}";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $gr =
$this->db->f('group_id');
+ $activities[] = array
+ (
+ 'id' =>
(int)$this->db->f('id'),
+ 'title' =>
$soap ? $this->db->f('title', true) : utf8_decode($this->db->f('title', true)),
+ 'organization_id' =>
$this->db->f('organization_id'),
+ 'group_id' =>
$this->db->f('group_id'),
+ 'district' =>
$this->db->f('district'),
+ 'category' =>
$this->db->f('category'),
+ 'state' =>
$this->db->f('state'),
+ 'target' =>
$this->db->f('target'),
+ 'arena' =>
$this->db->f('arena'),
+ 'internal_arena' =>
$this->db->f('internal_arena'),
+ 'time' =>
$soap ? $this->db->f('time', true) : utf8_decode($this->db->f('time', true)),
+ 'contact_person_1' =>
$this->db->f('contact_person_1'),
+ 'contact_person_2' =>
$this->db->f('contact_person_2'),
+ 'special_adaptation' =>
$this->db->f('special_adaptation'),
+ );
+ }
+
+ foreach($activities as &$activity)
+ {
if($activity['group_id'] &&
!$activity['group_id'] == '' && !$activity['group_id'] == 0)
{
- $activity['group_info']
= $this->get_group_info($activity['group_id']);
- $activity['organization_info'] =
$this->get_org_info($activity['group_info']['organization_id']);
+ $activity['group_info']
= $this->get_group_info($activity['group_id']);
+ $activity['organization_info'] =
$this->get_org_info($activity['group_info']['organization_id']);
}
else
{
- $activity['organization_info'] =
$this->get_org_info($activity['organization_id']);
- $activity['group_info']
= $this->get_group_info($activity['group_id']);
+ $activity['organization_info'] =
$this->get_org_info($activity['organization_id']);
+ $activity['group_info']
= $this->get_group_info($activity['group_id']);
}
- $activity['district_name'] = $soap
? $this->get_district_name($activity['district']) :
utf8_decode($this->get_district_name($activity['district']));
- $activity['category_name'] = $soap
? $this->get_category_name($activity['category']) :
utf8_decode($this->get_category_name($activity['category']));
- $activity['description'] =
$this->get_activity_description($activity['organization_id'],$activity['group_id']);
- $activity['arena_info'] =
$this->get_all_arena_info($activity['arena'], $activity['internal_arena']);
- $activity['internal_arena_info']=
$this->get_internal_arena_info($activity['internal_arena']);
- $activity['contact_person'] =
$this->get_contact_person($activity['organization_id'],$activity['group_id'],$activity['contact_person_1']);
+ $activity['district_name'] =
$soap ? $this->get_district_name($activity['district']) :
utf8_decode($this->get_district_name($activity['district']));
+ $activity['category_name'] =
$soap ? $this->get_category_name($activity['category']) :
utf8_decode($this->get_category_name($activity['category']));
+ $activity['description'] =
$this->get_activity_description($activity['organization_id'],
$activity['group_id']);
+ $activity['arena_info'] =
$this->get_all_arena_info($activity['arena'], $activity['internal_arena']);
+ $activity['internal_arena_info'] =
$this->get_internal_arena_info($activity['internal_arena']);
+ $activity['contact_person'] =
$this->get_contact_person($activity['organization_id'], $activity['group_id'],
$activity['contact_person_1']);
+ }
+//_debug_array($activities);
+ return $activities;
}
-//_debug_array($activities);
- return $activities;
- }
- function get_contact_person($org_id, $group_id, $cont_pers)
- {
- if($group_id)
+ function get_contact_person($org_id, $group_id, $cont_pers)
{
- $group_id = (int)$group_id;
- // $this->db->query("SELECT * FROM bb_group_contact WHERE
id={$cont_pers}", __LINE__, __FILE__);
- $this->db->query("SELECT * FROM bb_group_contact WHERE
group_id={$group_id} LIMIT 1", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = array('name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),'phone' =>
$this->db->f('phone'),'email' => $this->db->f('email'));
+ if($group_id)
+ {
+ $group_id = (int)$group_id;
+ // $this->db->query("SELECT * FROM
bb_group_contact WHERE id={$cont_pers}", __LINE__, __FILE__);
+ $this->db->query("SELECT * FROM
bb_group_contact WHERE group_id={$group_id} LIMIT 1", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = array('name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
+ 'phone' =>
$this->db->f('phone'), 'email' => $this->db->f('email'));
+ }
}
+ else if($org_id)
+ {
+ $org_id = (int)$org_id;
+ $this->db->query("SELECT * FROM
bb_organization_contact WHERE organization_id={$org_id} LIMIT 1", __LINE__,
__FILE__);
+ while($this->db->next_record())
+ {
+ $result = array('name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
+ 'phone' =>
$this->db->f('phone'), 'email' => $this->db->f('email'));
+ }
+ }
+ return $result;
}
- else if($org_id)
+
+ function get_activity_description($org_id, $group_id)
{
- $org_id = (int)$org_id;
- $this->db->query("SELECT * FROM bb_organization_contact
WHERE organization_id={$org_id} LIMIT 1", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = array('name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),'phone' =>
$this->db->f('phone'),'email' => $this->db->f('email'));
+ if($group_id)
+ {
+ $group_id = (int)$group_id;
+ $this->db->query("SELECT * FROM bb_group WHERE
id={$group_id}", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->soap ?
$this->db->f('description') : utf8_decode($this->db->f('description'));
+ }
}
+ else if($org_id)
+ {
+ $org_id = (int)$org_id;
+ $this->db->query("SELECT * FROM bb_organization
WHERE id={$org_id}", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->soap ?
$this->db->f('description') : utf8_decode($this->db->f('description'));
+ }
+ }
+ return $result;
}
- return $result;
- }
- function get_activity_description($org_id, $group_id)
- {
- if($group_id)
+ function get_organizations()
{
- $group_id = (int)$group_id;
- $this->db->query("SELECT * FROM bb_group WHERE
id={$group_id}", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->soap ?
$this->db->f('description') : utf8_decode($this->db->f('description'));
+ $organizations = array();
+ $this->db->query("SELECT * FROM bb_organization WHERE
show_in_portal=1", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $homepage = $this->db->f('homepage');
+ if(trim($homepage) != '' &&
!preg_match("/^http|https:\/\//", trim($homepage)))
+ {
+ $homepage = 'http://' . $homepage;
+ }
+ $organizations[] = array
+ (
+ 'id' =>
(int)$this->db->f('id'),
+ 'name' =>
utf8_decode($this->db->f('name')),
+ 'shortname' =>
utf8_decode($this->db->f('shortname')),
+ 'description' =>
utf8_decode($this->db->f('description')),
+ 'homepage' => $homepage,
+ 'phone' =>
$this->db->f('phone'),
+ 'email' =>
$this->db->f('email')
+ );
}
+// _debug_array($organizations);
+ return $organizations;
}
- else if($org_id)
+
+ function get_org_info($org_id)
{
- $org_id = (int)$org_id;
- $this->db->query("SELECT * FROM bb_organization WHERE
id={$org_id}", __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->soap ?
$this->db->f('description') : utf8_decode($this->db->f('description'));
+ $result = array();
+ if($org_id)
+ {
+ $org_id = (int)$org_id;
+ $this->db->query("SELECT * FROM bb_organization
WHERE id={$org_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'name' =>
utf8_decode($this->db->f('name')),
+ 'shortname' =>
utf8_decode($this->db->f('shortname')),
+ 'description' =>
utf8_decode($this->db->f('description')),
+ 'homepage' =>
$this->db->f('homepage'),
+ 'phone' =>
$this->db->f('phone'),
+ 'email' =>
$this->db->f('email')
+ );
}
+ return $result;
}
- return $result;
- }
+ function get_groups()
+ {
+ $groups = array();
+ $join = " {$this->left_join} bb_organization ON
(bb_group.organization_id = bb_organization.id)";
+ $this->db->query("SELECT bb_group.*,
bb_organization.homepage FROM bb_group {$join} WHERE
bb_group.show_in_portal=1", __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $groups[] = array
+ (
+ 'id' =>
(int)$this->db->f('id'),
+ 'name' =>
utf8_decode($this->db->f('name')),
+ 'shortname' =>
utf8_decode($this->db->f('shortname')),
+ 'description' =>
utf8_decode($this->db->f('description')),
+ 'homepage' =>
utf8_decode($this->db->f('homepage')),
+ 'organization_id' =>
$this->db->f('organization_id')
+ );
+ }
+// _debug_array($groups);
+ return $groups;
+ }
+ /*
+ * Return incoming
+ */
- function get_organizations()
- {
- $organizations = array();
- $this->db->query("SELECT * FROM bb_organization WHERE
show_in_portal=1", __LINE__, __FILE__);
- while($this->db->next_record())
+ function debug_xmlrpc($data = array())
{
- $homepage = $this->db->f('homepage');
- if ( trim($homepage) != '' &&
!preg_match("/^http|https:\/\//", trim($homepage)) )
+ if($data['fromdate'])
{
- $homepage = 'http://'.$homepage;
+ return $data['fromdate'];
}
- $organizations[] = array
- (
- 'id' => (int)
$this->db->f('id'),
- 'name' =>
utf8_decode($this->db->f('name')),
- 'shortname' =>
utf8_decode($this->db->f('shortname')),
- 'description' =>
utf8_decode($this->db->f('description')),
- 'homepage' => $homepage,
- 'phone' =>
$this->db->f('phone'),
- 'email' => $this->db->f('email')
- );
+ else
+ {
+ return $data;
+ }
}
-// _debug_array($organizations);
- return $organizations;
- }
- function get_org_info($org_id)
- {
- $result = array();
- if($org_id)
+ function get_group_info($group_id)
{
- $org_id = (int)$org_id;
- $this->db->query("SELECT * FROM bb_organization WHERE
id={$org_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'name' =>
utf8_decode($this->db->f('name')),
- 'shortname' =>
utf8_decode($this->db->f('shortname')),
- 'description' =>
utf8_decode($this->db->f('description')),
- 'homepage' =>
$this->db->f('homepage'),
- 'phone' =>
$this->db->f('phone'),
- 'email' => $this->db->f('email')
- );
+ $result = array();
+ if($group_id)
+ {
+ $group_id = (int)$group_id;
+ $this->db->query("SELECT * FROM bb_group WHERE
id={$group_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'name' =>
utf8_decode($this->db->f('name')),
+ 'shortname' =>
utf8_decode($this->db->f('shortname')),
+ 'description' =>
utf8_decode($this->db->f('description')),
+ 'organization_id' =>
$this->db->f('organization_id')
+ );
+ }
+ return $result;
}
- return $result;
- }
- function get_groups()
- {
- $groups = array();
- $join = " {$this->left_join} bb_organization ON
(bb_group.organization_id = bb_organization.id)";
- $this->db->query("SELECT bb_group.*, bb_organization.homepage
FROM bb_group {$join} WHERE bb_group.show_in_portal=1", __LINE__, __FILE__);
- while($this->db->next_record())
+ function get_all_arena_info($arena_id, $int_arena_id)
{
- $groups[] = array
- (
- 'id' => (int)
$this->db->f('id'),
- 'name' =>
utf8_decode($this->db->f('name')),
- 'shortname' =>
utf8_decode($this->db->f('shortname')),
- 'description' =>
utf8_decode($this->db->f('description')),
- 'homepage' =>
utf8_decode($this->db->f('homepage')),
- 'organization_id' =>
$this->db->f('organization_id')
- );
+ $result = array();
+ if($arena_id && is_numeric($arena_id))
+ {
+ $arena_id = (int)$arena_id;
+ $this->db->query("SELECT * FROM activity_arena
WHERE id={$arena_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'arena_name' => $this->soap ?
$this->db->f('arena_name') : utf8_decode($this->db->f('arena_name')),
+ 'address' => $this->soap ?
$this->db->f('address') : utf8_decode($this->db->f('address'))
+ );
+ }
+ else if($int_arena_id && is_numeric($int_arena_id))
+ {
+ $int_arena_id = (int)$int_arena_id;
+ $this->db->query("SELECT id, name, street FROM
bb_building WHERE id={$int_arena_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'arena_name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
+ 'address' => $this->soap ?
$this->db->f('street') : utf8_decode($this->db->f('street'))
+ );
+ }
+ return $result;
}
-// _debug_array($groups);
- return $groups;
- }
-
- /*
- * Return incoming
- */
- function debug_xmlrpc($data = array())
- {
- if($data['fromdate'])
+ function get_arena_info($arena_id)
{
- return $data['fromdate'];
+ $result = array();
+ if($arena_id)
+ {
+ $arena_id = (int)$arena_id;
+ $this->db->query("SELECT * FROM activity_arena
WHERE id={$arena_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'arena_name' => $this->soap ?
$this->db->f('arena_name') : utf8_decode($this->db->f('arena_name')),
+ 'address' => $this->soap ?
$this->db->f('address') : utf8_decode($this->db->f('address'))
+ );
+ }
+ return $result;
}
- else
+
+ function get_internal_arena_info($arena_id)
{
- return $data;
+ $result = array();
+ if($arena_id)
+ {
+ $arena_id = (int)$arena_id;
+ $this->db->query("SELECT id, name, street FROM
bb_building WHERE id={$arena_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ $result = array
+ (
+ 'arena_name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
+ 'address' => $this->soap ?
$this->db->f('street') : utf8_decode($this->db->f('street'))
+ );
+ }
+ return $result;
}
- }
-
- function get_group_info($group_id)
- {
- $result = array();
- if($group_id)
+ function get_statuscodes()
{
- $group_id = (int)$group_id;
- $this->db->query("SELECT * FROM bb_group WHERE
id={$group_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'name' =>
utf8_decode($this->db->f('name')),
- 'shortname' =>
utf8_decode($this->db->f('shortname')),
- 'description' =>
utf8_decode($this->db->f('description')),
- 'organization_id' =>
$this->db->f('organization_id')
- );
+ $statuscodes[] = array('id' => '0', 'name' =>
utf8_decode('Ingen'));
+ $statuscodes[] = array('id' => '1', 'name' =>
utf8_decode('Ny'));
+ $statuscodes[] = array('id' => '2', 'name' =>
utf8_decode('Endring'));
+ $statuscodes[] = array('id' => '3', 'name' =>
utf8_decode('Akseptert'));
+ $statuscodes[] = array('id' => '4', 'name' =>
utf8_decode('Behandlet'));
+ $statuscodes[] = array('id' => '5', 'name' =>
utf8_decode('Avvist'));
+ return $statuscodes;
}
- return $result;
- }
- function get_all_arena_info($arena_id, $int_arena_id)
- {
- $result = array();
- if($arena_id && is_numeric($arena_id))
+ function get_targetgroups()
{
- $arena_id = (int)$arena_id;
- $this->db->query("SELECT * FROM activity_arena WHERE
id={$arena_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'arena_name' => $this->soap ?
$this->db->f('arena_name') : utf8_decode($this->db->f('arena_name')),
- 'address' => $this->soap ?
$this->db->f('address') : utf8_decode($this->db->f('address'))
- );
+ $sql = "SELECT * FROM bb_agegroup where active=1 AND
NOT name like 'Tilskuer%' ORDER BY sort";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $targets[] = array(
+ 'id' => (int)$this->db->f('id'),
+ 'name' =>
utf8_decode($this->db->f('name', true)),
+ 'sort' => (int)$this->db->f('sort'),
+ );
+ }
+ return $targets;
}
- else if($int_arena_id && is_numeric($int_arena_id))
+
+ function get_category_list()
{
- $int_arena_id = (int)$int_arena_id;
- $this->db->query("SELECT id, name, street FROM
bb_building WHERE id={$int_arena_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'arena_name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
- 'address' => $this->soap ?
$this->db->f('street') : utf8_decode($this->db->f('street'))
- );
+ $sql = "SELECT * FROM bb_activity where active=1 and
parent_id=1";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $categories[] = array(
+ 'id' => (int)$this->db->f('id'),
+ 'name' =>
utf8_decode($this->db->f('name', true)),
+ );
+ }
+ return $categories;
}
- return $result;
- }
- function get_arena_info($arena_id)
- {
- $result = array();
- if($arena_id)
+ function update_organization($org_info)
{
- $arena_id = (int)$arena_id;
- $this->db->query("SELECT * FROM activity_arena WHERE
id={$arena_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'arena_name' => $this->soap ?
$this->db->f('arena_name') : utf8_decode($this->db->f('arena_name')),
- 'address' => $this->soap ?
$this->db->f('address') : utf8_decode($this->db->f('address'))
+ $name = $org_info['name'];
+ $orgid = (int)$org_info['orgid'];
+ $homepage = $org_info['homepage'];
+ if(!$homepage)
+ {
+ $homepage = '';
+ }
+ $phone = $org_info['phone'];
+ if(!$phone)
+ {
+ $phone = '';
+ }
+ $email = $org_info['email'];
+ if(!$email)
+ {
+ $email = '';
+ }
+ $description = $org_info['description'];
+ if(!$description)
+ {
+ $description = '';
+ }
+ $street = $org_info['street'];
+ if(!$street)
+ {
+ $street = '';
+ }
+ $zip = $org_info['zip'];
+ if($zip && strlen($zip) > 5)
+ {
+ $zip_code = substr($zip, 0, 4);
+ $city = substr($zip, 5);
+ }
+ else
+ {
+ $zip_code = '';
+ $city = '';
+ }
+ $district = $org_info['district'];
+ if(!$district)
+ {
+ $district = '';
+ }
+ $activity_id = $org_info['activity_id'];
+ $show_in_portal = 1;
+
+ $values = array(
+ 'name = ' . $this->marshal($name, 'string'),
+ 'homepage = ' . $this->marshal($homepage,
'string'),
+ 'phone = ' . $this->marshal($phone, 'string'),
+ 'email = ' . $this->marshal($email, 'string'),
+ 'description = ' . $this->marshal($description,
'string'),
+ 'street = ' . $this->marshal($street, 'string'),
+ 'zip_code = ' . $this->marshal($zip_code,
'string'),
+ 'city = ' . $this->marshal($city, 'string'),
+ 'district = ' . $this->marshal($district),
+ 'activity_id = ' . $this->marshal($activity_id,
'int'),
+ 'show_in_portal = 1'
);
+
+ $result = $this->db->query('UPDATE bb_organization SET
' . join(',', $values) . " WHERE id=$orgid", __LINE__, __FILE__);
}
- return $result;
- }
- function get_internal_arena_info($arena_id)
- {
- $result = array();
- if($arena_id)
+ function add_organization($org_info)
{
- $arena_id = (int)$arena_id;
- $this->db->query("SELECT id, name, street FROM
bb_building WHERE id={$arena_id}", __LINE__, __FILE__);
- $this->db->next_record();
- $result = array
- (
- 'arena_name' => $this->soap ?
$this->db->f('name') : utf8_decode($this->db->f('name')),
- 'address' => $this->soap ?
$this->db->f('street') : utf8_decode($this->db->f('street'))
- );
- }
- return $result;
- }
+ $name = $org_info['name'];
+ $orgnr = $org_info['orgnr'];
+ $homepage = $org_info['homepage'];
+ $phone = $org_info['phone'];
+ $email = $org_info['email'];
+ $description = $org_info['description'];
+ $street = $org_info['street'];
+ $zip = $org_info['zip'];
+ if($zip && strlen($zip) > 5)
+ {
+ $zip_code = substr($zip, 0, 4);
+ $city = substr($zip, 5);
+ }
+ else
+ {
+ $zip_code = '';
+ $city = '';
+ }
+ $district = $org_info['district'];
+ $activity_id = $org_info['activity_id'];
+ $show_in_portal = 1;
- function get_statuscodes()
- {
- $statuscodes[] = array('id' => '0', 'name' =>
utf8_decode('Ingen'));
- $statuscodes[] = array('id' => '1', 'name' =>
utf8_decode('Ny'));
- $statuscodes[] = array('id' => '2', 'name' =>
utf8_decode('Endring'));
- $statuscodes[] = array('id' => '3', 'name' =>
utf8_decode('Akseptert'));
- $statuscodes[] = array('id' => '4', 'name' =>
utf8_decode('Behandlet'));
- $statuscodes[] = array('id' => '5', 'name' =>
utf8_decode('Avvist'));
+ $columns[] = 'name';
+ $columns[] = 'homepage';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'description';
+ $columns[] = 'street';
+ $columns[] = 'zip_code';
+ $columns[] = 'city';
+ $columns[] = 'district';
+ $columns[] = 'organization_number';
+ $columns[] = 'activity_id';
+ $columns[] = 'show_in_portal';
+ $cols = implode(',', $columns);
- return $statuscodes;
- }
+ $values[] = "'{$name}'";
+ $values[] = "'{$homepage}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$email}'";
+ $values[] = "'{$description}'";
+ $values[] = "'{$street}'";
+ $values[] = "'{$zip_code}'";
+ $values[] = "'{$city}'";
+ $values[] = "'{$district}'";
+ $values[] = "'{$orgnr}'";
+ $values[] = $this->marshal($activity_id, 'int');
+ $values[] = $show_in_portal;
+ $vals = implode(',', $values);
- function get_targetgroups()
- {
- $sql = "SELECT * FROM bb_agegroup where active=1 AND NOT name
like 'Tilskuer%' ORDER BY sort";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $targets[] = array(
- 'id' =>
(int) $this->db->f('id'),
- 'name' =>
utf8_decode($this->db->f('name',true)),
- 'sort' =>
(int) $this->db->f('sort'),
- );
+ $sql = "INSERT INTO bb_organization ({$cols})
VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return
$this->db->get_last_insert_id('bb_organization', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
- return $targets;
- }
- function get_category_list()
- {
- $sql = "SELECT * FROM bb_activity where active=1 and
parent_id=1";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- $categories[] = array(
- 'id' =>
(int) $this->db->f('id'),
- 'name' =>
utf8_decode($this->db->f('name',true)),
- );
- }
- return $categories;
- }
- function update_organization($org_info)
- {
- $name = $org_info['name'];
- $orgid = (int)$org_info['orgid'];
- $homepage = $org_info['homepage'];
- if(!$homepage)
+ function add_organization_local($org_info)
{
- $homepage = '';
- }
- $phone = $org_info['phone'];
- if(!$phone)
- {
- $phone = '';
- }
- $email = $org_info['email'];
- if(!$email)
- {
- $email = '';
- }
- $description = $org_info['description'];
- if(!$description)
- {
- $description = '';
- }
- $street = $org_info['street'];
- if(!$street)
- {
- $street = '';
- }
- $zip = $org_info['zip'];
- if($zip && strlen($zip) > 5)
- {
- $zip_code = substr($zip,0,4);
- $city = substr($zip, 5);
- }
- else
- {
- $zip_code = '';
- $city = '';
- }
- $district = $org_info['district'];
- if(!$district)
- {
- $district = '';
- }
- $activity_id = $org_info['activity_id'];
- $show_in_portal = 1;
+ $name = $org_info['name'];
+ $orgnr = $org_info['orgnr'];
+ $homepage = $org_info['homepage'];
+ $phone = $org_info['phone'];
+ $email = $org_info['email'];
+ $description = $org_info['description'];
+ $street = $org_info['street'];
+ $streetnumber = $org_info['streetnumber'];
+ $zip_code = $org_info['zip'];
+ $city = $org_info['postaddress'];
+ $district = $org_info['district'];
+ $status = $org_info['status'];
+ $original_org_id = $org_info['original_org_id'];
+ if(!isset($original_org_id) || $original_org_id == '')
+ {
+ $original_org_id = 0;
+ }
- $values = array(
- 'name = ' . $this->marshal($name, 'string'),
- 'homepage = ' . $this->marshal($homepage, 'string'),
- 'phone = ' . $this->marshal($phone, 'string'),
- 'email = ' . $this->marshal($email, 'string'),
- 'description = ' . $this->marshal($description,
'string'),
- 'street = ' . $this->marshal($street, 'string'),
- 'zip_code = ' . $this->marshal($zip_code, 'string'),
- 'city = ' . $this->marshal($city, 'string'),
- 'district = ' . $this->marshal($district),
- 'activity_id = ' . $this->marshal($activity_id, 'int'),
- 'show_in_portal = 1'
- );
+ $columns[] = 'name';
+ $columns[] = 'homepage';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'description';
+ $columns[] = 'address';
+ $columns[] = 'addressnumber';
+ $columns[] = 'zip_code';
+ $columns[] = 'city';
+ $columns[] = 'orgno';
+ $columns[] = 'district';
+ $columns[] = 'change_type';
+ $columns[] = 'original_org_id';
+ $cols = implode(',', $columns);
- $result = $this->db->query('UPDATE bb_organization SET ' .
join(',', $values) . " WHERE id=$orgid", __LINE__,__FILE__);
- }
- function add_organization($org_info)
- {
- $name = $org_info['name'];
- $orgnr = $org_info['orgnr'];
- $homepage = $org_info['homepage'];
- $phone = $org_info['phone'];
- $email = $org_info['email'];
- $description = $org_info['description'];
- $street = $org_info['street'];
- $zip = $org_info['zip'];
- if($zip && strlen($zip) > 5)
- {
- $zip_code = substr($zip,0,4);
- $city = substr($zip, 5);
+ $values[] = "'{$name}'";
+ $values[] = "'{$homepage}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$email}'";
+ $values[] = "'{$description}'";
+ $values[] = "'{$street}'";
+ $values[] = "'{$streetnumber}'";
+ $values[] = "'{$zip_code}'";
+ $values[] = "'{$city}'";
+ $values[] = "'{$orgnr}'";
+ $values[] = "'{$district}'";
+ $values[] = "'{$status}'";
+ $values[] = $original_org_id;
+ $vals = implode(',', $values);
+
+ //var_dump("INSERT INTO activity_organization ({$cols})
VALUES ({$vals})");
+ $sql = "INSERT INTO activity_organization ({$cols})
VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return
$this->db->get_last_insert_id('activity_organization', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
- else
+
+ function add_group($group_info)
{
- $zip_code = '';
- $city = '';
- }
- $district = $org_info['district'];
- $activity_id = $org_info['activity_id'];
- $show_in_portal = 1;
+ $name = $group_info['name'];
+ $orgid =
$group_info['organization_id'];
+ $description = $group_info['description'];
+ $activity_id = $group_info['activity_id'];
+ $show_in_portal = 1;
- $columns[] = 'name';
- $columns[] = 'homepage';
- $columns[] = 'phone';
- $columns[] = 'email';
- $columns[] = 'description';
- $columns[] = 'street';
- $columns[] = 'zip_code';
- $columns[] = 'city';
- $columns[] = 'district';
- $columns[] = 'organization_number';
- $columns[] = 'activity_id';
- $columns[] = 'show_in_portal';
- $cols = implode(',',$columns);
+ $columns[] = 'name';
+ $columns[] = 'description';
+ $columns[] = 'organization_id';
+ $columns[] = 'activity_id';
+ $columns[] = 'show_in_portal';
+ $cols = implode(',', $columns);
- $values[] = "'{$name}'";
- $values[] = "'{$homepage}'";
- $values[] = "'{$phone}'";
- $values[] = "'{$email}'";
- $values[] = "'{$description}'";
- $values[] = "'{$street}'";
- $values[] = "'{$zip_code}'";
- $values[] = "'{$city}'";
- $values[] = "'{$district}'";
- $values[] = "'{$orgnr}'";
- $values[] = $this->marshal($activity_id, 'int');
- $values[] = $show_in_portal;
- $vals = implode(',',$values);
+ $values[] = "'{$name}'";
+ $values[] = "'{$description}'";
+ $values[] = "'{$orgid}'";
+ $values[] = $this->marshal($activity_id, 'int');
+ $values[] = $show_in_portal;
+ $vals = implode(',', $values);
- $sql = "INSERT INTO bb_organization ({$cols}) VALUES ({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if(isset($result))
- {
- return $this->db->get_last_insert_id('bb_organization',
'id');
+ $sql = "INSERT INTO bb_group ({$cols}) VALUES
({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return
$this->db->get_last_insert_id('bb_group', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
- else
- {
- return 0;
- }
- }
- function add_organization_local($org_info)
- {
- $name = $org_info['name'];
- $orgnr = $org_info['orgnr'];
- $homepage = $org_info['homepage'];
- $phone = $org_info['phone'];
- $email = $org_info['email'];
- $description = $org_info['description'];
- $street = $org_info['street'];
- $streetnumber = $org_info['streetnumber'];
- $zip_code = $org_info['zip'];
- $city = $org_info['postaddress'];
- $district = $org_info['district'];
- $status = $org_info['status'];
- $original_org_id = $org_info['original_org_id'];
- if(!isset($original_org_id) || $original_org_id == '')
+ function add_group_local($group_info)
{
- $original_org_id = 0;
- }
+ $name = $group_info['name'];
+ $orgid = $group_info['organization_id'];
+ $description = $group_info['description'];
+ $status = $group_info['status'];
- $columns[] = 'name';
- $columns[] = 'homepage';
- $columns[] = 'phone';
- $columns[] = 'email';
- $columns[] = 'description';
- $columns[] = 'address';
- $columns[] = 'addressnumber';
- $columns[] = 'zip_code';
- $columns[] = 'city';
- $columns[] = 'orgno';
- $columns[] = 'district';
- $columns[] = 'change_type';
- $columns[] = 'original_org_id';
- $cols = implode(',',$columns);
+ $columns[] = 'name';
+ $columns[] = 'description';
+ $columns[] = 'organization_id';
+ $columns[] = 'change_type';
+ $cols = implode(',', $columns);
- $values[] = "'{$name}'";
- $values[] = "'{$homepage}'";
- $values[] = "'{$phone}'";
- $values[] = "'{$email}'";
- $values[] = "'{$description}'";
- $values[] = "'{$street}'";
- $values[] = "'{$streetnumber}'";
- $values[] = "'{$zip_code}'";
- $values[] = "'{$city}'";
- $values[] = "'{$orgnr}'";
- $values[] = "'{$district}'";
- $values[] = "'{$status}'";
- $values[] = $original_org_id;
- $vals = implode(',',$values);
+ $values[] = "'{$name}'";
+ $values[] = "'{$description}'";
+ $values[] = "'{$orgid}'";
+ $values[] = "'{$status}'";
+ $vals = implode(',', $values);
- //var_dump("INSERT INTO activity_organization ({$cols}) VALUES
({$vals})");
- $sql = "INSERT INTO activity_organization ({$cols}) VALUES
({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if(isset($result))
- {
- return
$this->db->get_last_insert_id('activity_organization', 'id');
+ $sql = "INSERT INTO activity_group ({$cols}) VALUES
({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return
$this->db->get_last_insert_id('activity_group', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
- else
+
+ function delete_contact_persons($org_id)
{
- return 0;
+ if($org_id)
+ {
+ $org = (int)$org_id;
+ $sql = "DELETE FROM bb_organization_contact
WHERE organization_id={$org}";
+ $result = $this->db->query($sql, __LINE__,
__FILE__);
+ return isset($result);
+ }
+ /* else if($group_id)
+ {
+ $group = (int)$group_id;
+ $sql = "DELETE FROM bb_group_contact WHERE
group_id={$group}";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ return isset($result);
+ } */
}
- }
- function add_group($group_info)
- {
- $name = $group_info['name'];
- $orgid = $group_info['organization_id'];
- $description = $group_info['description'];
- $activity_id = $group_info['activity_id'];
- $show_in_portal = 1;
+ function add_contact_person_org($contact)
+ {
+ $name = $contact['name'];
+ $phone = $contact['phone'];
+ $mail = $contact['mail'];
+ $org_id = $contact['org_id'];
+ $ssn = '';
- $columns[] = 'name';
- $columns[] = 'description';
- $columns[] = 'organization_id';
- $columns[] = 'activity_id';
- $columns[] = 'show_in_portal';
- $cols = implode(',',$columns);
+ $columns[] = 'name';
+ $columns[] = 'ssn';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'organization_id';
+ $cols = implode(',', $columns);
- $values[] = "'{$name}'";
- $values[] = "'{$description}'";
- $values[] = "'{$orgid}'";
- $values[] = $this->marshal($activity_id, 'int');
- $values[] = $show_in_portal;
- $vals = implode(',',$values);
+ $values[] = "'{$name}'";
+ $values[] = "'{$ssn}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$mail}'";
+ $values[] = $org_id;
+ $vals = implode(',', $values);
- $sql = "INSERT INTO bb_group ({$cols}) VALUES ({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if(isset($result))
- {
- return $this->db->get_last_insert_id('bb_group', 'id');
+ $sql = "INSERT INTO bb_organization_contact
({$cols}) VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ return isset($result);
}
- else
+
+ function update_contact_person_org($contact)
{
- return 0;
+
}
- }
- function add_group_local($group_info)
- {
- $name = $group_info['name'];
- $orgid = $group_info['organization_id'];
- $description = $group_info['description'];
- $status = $group_info['status'];
+ function add_contact_person_group($contact)
+ {
+ $name = $contact['name'];
+ $phone = $contact['phone'];
+ $mail = $contact['mail'];
+ $org_id = $contact['group_id'];
- $columns[] = 'name';
- $columns[] = 'description';
- $columns[] = 'organization_id';
- $columns[] = 'change_type';
- $cols = implode(',',$columns);
+ $columns[] = 'name';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'group_id';
+ $cols = implode(',', $columns);
- $values[] = "'{$name}'";
- $values[] = "'{$description}'";
- $values[] = "'{$orgid}'";
- $values[] = "'{$status}'";
- $vals = implode(',',$values);
+ $values[] = "'{$name}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$mail}'";
+ $values[] = $org_id;
+ $vals = implode(',', $values);
- $sql = "INSERT INTO activity_group ({$cols}) VALUES ({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if(isset($result))
- {
- return $this->db->get_last_insert_id('activity_group',
'id');
+ $sql = "INSERT INTO bb_group_contact ({$cols})
VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ return isset($result);
}
- else
+
+ function update_contact_person_group($contact)
{
- return 0;
+
}
- }
- function delete_contact_persons($org_id)
- {
- if($org_id)
+ function add_contact_person_local($contact)
{
- $org = (int)$org_id;
- $sql = "DELETE FROM bb_organization_contact WHERE
organization_id={$org}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- return isset($result);
- }
-/* else if($group_id)
- {
- $group = (int)$group_id;
- $sql = "DELETE FROM bb_group_contact WHERE
group_id={$group}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- return isset($result);
- }*/
- }
+ $name = $contact['name'];
+ $phone = $contact['phone'];
+ $mail = $contact['mail'];
+ $org_id = $contact['org_id'];
+ $group_id = $contact['group_id'];
- function add_contact_person_org($contact)
- {
- $name = $contact['name'];
- $phone = $contact['phone'];
- $mail = $contact['mail'];
- $org_id = $contact['org_id'];
- $ssn = '';
+ $columns[] = 'name';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'organization_id';
+ $columns[] = 'group_id';
+ $columns[] = 'address';
+ $columns[] = 'zipcode';
+ $columns[] = 'city';
+ $cols = implode(',', $columns);
- $columns[] = 'name';
- $columns[] = 'ssn';
- $columns[] = 'phone';
- $columns[] = 'email';
- $columns[] = 'organization_id';
- $cols = implode(',',$columns);
+ $values[] = "'{$name}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$mail}'";
+ $values[] = $org_id;
+ $values[] = $group_id;
+ $values[] = "''";
+ $values[] = "''";
+ $values[] = "''";
+ $vals = implode(',', $values);
- $values[] = "'{$name}'";
- $values[] = "'{$ssn}'";
- $values[] = "'{$phone}'";
- $values[] = "'{$mail}'";
- $values[] = $org_id;
- $vals = implode(',',$values);
+ //var_dump("INSERT INTO activity_contact_person
({$cols}) VALUES ({$vals})");
+ $sql = "INSERT INTO activity_contact_person
({$cols}) VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ return isset($result);
+ }
- $sql = "INSERT INTO bb_organization_contact ({$cols}) VALUES
({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- return isset($result);
- }
+ function get_activities_for_update($org_id, $group = false)
+ {
+ $activity_ids = array();
+ if($group)
+ {
+ $sql = "SELECT id FROM activity_activity WHERE
new_group AND group_id={$org_id}";
+ }
+ else
+ {
+ $sql = "SELECT id FROM activity_activity WHERE
new_org AND organization_id={$org_id}";
+ }
- function update_contact_person_org($contact)
- {
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $activity_ids[] = $this->db->f('id');
+ }
- }
+ return $activity_ids;
+ }
- function add_contact_person_group($contact)
- {
- $name = $contact['name'];
- $phone = $contact['phone'];
- $mail = $contact['mail'];
- $org_id = $contact['group_id'];
+ function get_connected_activities($org_id)
+ {
+ $activities = array();
+ $sql = "SELECT * FROM activity_activity
WHERE organization_id={$org_id}";
- $columns[] = 'name';
- $columns[] = 'phone';
- $columns[] = 'email';
- $columns[] = 'group_id';
- $cols = implode(',',$columns);
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $activity = new
activitycalendar_activity((int)$this->db->f('id'));
- $values[] = "'{$name}'";
- $values[] = "'{$phone}'";
- $values[] = "'{$mail}'";
- $values[] = $org_id;
- $vals = implode(',',$values);
+
$activity->set_title($this->unmarshal($this->db->f('title'), 'string'));
+
$activity->set_organization_id($this->unmarshal($this->db->f('organization_id'),
'int'));
+
$activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
+
$activity->set_district($this->unmarshal($this->db->f('district'), 'int'));
+
$activity->set_office($this->unmarshal($this->db->f('office'), 'int'));
+
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
+
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
+
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
+
$activity->set_description($this->unmarshal($this->db->f('description'),
'string'));
+
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
+
$activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'),
'string'));
+
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
+
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
'int'));
+
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
'bool')));
+
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
+
$activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'),
'string'));
+
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
'string'));
+
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
+
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
- $sql = "INSERT INTO bb_group_contact ({$cols}) VALUES
({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- return isset($result);
- }
+ $activities[] = $activity;
+ }
- function update_contact_person_group($contact)
- {
+ return $activities;
+ }
- }
+ function update_organization_connection($activity_id,
$organization_id)
+ {
+ $id = intval($activity_id);
+ $org_id = intval($organization_id);
- function add_contact_person_local($contact)
- {
- $name = $contact['name'];
- $phone = $contact['phone'];
- $mail = $contact['mail'];
- $org_id = $contact['org_id'];
- $group_id = $contact['group_id'];
+ $result = $this->db->query("UPDATE activity_activity
SET organization_id={$org_id} WHERE id={$id}", __LINE__, __FILE__);
- $columns[] = 'name';
- $columns[] = 'phone';
- $columns[] = 'email';
- $columns[] = 'organization_id';
- $columns[] = 'group_id';
- $columns[] = 'address';
- $columns[] = 'zipcode';
- $columns[] = 'city';
- $cols = implode(',',$columns);
+ return isset($result);
+ }
- $values[] = "'{$name}'";
- $values[] = "'{$phone}'";
- $values[] = "'{$mail}'";
- $values[] = $org_id;
- $values[] = $group_id;
- $values[] = "''";
- $values[] = "''";
- $values[] = "''";
- $vals = implode(',',$values);
+ function get_activities_without_groups()
+ {
+ $activities = array();
+ $sql_activities = "select a.*, o.description as
org_desc from activity_activity a, bb_organization o where (a.group_id is null
or a.group_id = 0) and o.id = a.organization_id";
+ $this->db->query($sql_activities, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $activity_id =
$this->db->f('id');
+ $activity_title =
$this->db->f('title');
+ $activity_organization =
$this->db->f('organization_id');
+ $description =
$this->db->f('org_desc');
- //var_dump("INSERT INTO activity_contact_person ({$cols})
VALUES ({$vals})");
- $sql = "INSERT INTO activity_contact_person ({$cols}) VALUES
({$vals})";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- return isset($result);
- }
-
- function get_activities_for_update($org_id, $group = false)
- {
- $activity_ids = array();
- if($group)
- {
- $sql = "SELECT id FROM activity_activity WHERE
new_group AND group_id={$org_id}";
+ $activities[] = array(
+ 'id' =>
$activity_id,
+ 'title' =>
$activity_title,
+ 'organization' =>
$activity_organization,
+ 'description' => $description
+ );
+ }
+ return $activities;
}
- else
- {
- $sql = "SELECT id FROM activity_activity WHERE new_org
AND organization_id={$org_id}";
- }
+ /*
+ * Function to be run once.
+ * Generates new groups based on activity where group is not
registered.
+ * Adds new group to booking
+ */
- $this->db->query($sql, __LINE__, __FILE__);
- while ($this->db->next_record())
+ function generate_groups()
{
- $activity_ids[] = $this->db->f('id');
+ //TODO
}
- return $activity_ids;
- }
-
- function get_connected_activities($org_id)
- {
- $activities = array();
- $sql = "SELECT * FROM activity_activity WHERE
organization_id={$org_id}";
-
- $this->db->query($sql, __LINE__, __FILE__);
- while ($this->db->next_record())
+ function remove_old_activities($activity_id)
{
- $activity = new activitycalendar_activity((int)
$this->db->f('id'));
+ //$sql = "delete from activity_activity where id in
(1293,1294,1297,1299)"; //1293,1294,1297,1299
+ $sql = "delete from activity_activity where
id={$activity_id}";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
-
$activity->set_title($this->unmarshal($this->db->f('title'), 'string'));
-
$activity->set_organization_id($this->unmarshal($this->db->f('organization_id'),
'int'));
-
$activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
-
$activity->set_district($this->unmarshal($this->db->f('district'), 'int'));
-
$activity->set_office($this->unmarshal($this->db->f('office'), 'int'));
-
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
-
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
-
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
-
$activity->set_description($this->unmarshal($this->db->f('description'),
'string'));
-
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
-
$activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'),
'string'));
-
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
-
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
'int'));
-
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
'bool')));
-
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
-
$activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'),
'string'));
-
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
'string'));
-
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
-
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
-
- $activities[] = $activity;
+ return isset($result);
}
- return $activities;
- }
+ function save_with_no_changes($activity)
+ {
+ $id = intval($activity->get_id());
+ $ts_now = strtotime('now');
- function update_organization_connection($activity_id, $organization_id)
- {
- $id = intval($activity_id);
- $org_id = intval($organization_id);
+ $values = "last_change_date = " .
$this->marshal($ts_now, 'int');
- $result = $this->db->query("UPDATE activity_activity SET
organization_id={$org_id} WHERE id={$id}", __LINE__,__FILE__);
+ $result = $this->db->query("UPDATE activity_activity
SET {$values} WHERE id={$id}", __LINE__, __FILE__);
- return isset($result);
- }
+ return isset($result);
+ }
- function get_activities_without_groups()
- {
- $activities = array();
- $sql_activities = "select a.*, o.description as org_desc from
activity_activity a, bb_organization o where (a.group_id is null or a.group_id
= 0) and o.id = a.organization_id";
- $this->db->query($sql_activities, __LINE__, __FILE__);
- while($this->db->next_record())
- {
- $activity_id = $this->db->f('id');
- $activity_title = $this->db->f('title');
- $activity_organization = $this->db->f('organization_id');
- $description = $this->db->f('org_desc');
+ function update_activity_group($activity_id, $group_id)
+ {
+ $id = intval($activity_id);
+ $g_id = intval($group_id);
- $activities[] = array(
- 'id'=>$activity_id,
- 'title'=>$activity_title,
- 'organization'=>$activity_organization,
- 'description'=>$description
- );
- }
- return $activities;
- }
+ $values = "group_id = " . $g_id;
+ //var_dump("UPDATE activity_activity SET {$values}
WHERE id={$id}");
+ //die;
- /*
- * Function to be run once.
- * Generates new groups based on activity where group is not
registered.
- * Adds new group to booking
- */
- function generate_groups()
- {
- //TODO
- }
+ $result = $this->db->query("UPDATE activity_activity
SET {$values} WHERE id={$id}", __LINE__, __FILE__);
-
- function remove_old_activities($activity_id)
- {
- //$sql = "delete from activity_activity where id in
(1293,1294,1297,1299)"; //1293,1294,1297,1299
- $sql = "delete from
activity_activity where id={$activity_id}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
-
- return isset($result);
- }
-
- function save_with_no_changes($activity)
- {
- $id = intval($activity->get_id());
- $ts_now = strtotime('now');
-
- $values = "last_change_date = " . $this->marshal($ts_now, 'int');
-
- $result = $this->db->query("UPDATE activity_activity SET {$values}
WHERE id={$id}", __LINE__,__FILE__);
-
- return isset($result);
- }
-
- function update_activity_group($activity_id, $group_id)
- {
- $id = intval($activity_id);
- $g_id = intval($group_id);
-
- $values = "group_id = " . $g_id;
- //var_dump("UPDATE activity_activity SET {$values} WHERE
id={$id}");
- //die;
-
- $result = $this->db->query("UPDATE activity_activity SET {$values}
WHERE id={$id}", __LINE__,__FILE__);
-
- return isset($result);
- }
-}
+ return isset($result);
+ }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/activitycalendar/inc/class.soarena.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendar/inc/class.soarena.inc.php
2015-05-13 06:02:39 UTC (rev 13189)
+++ branches/dev-syncromind/activitycalendar/inc/class.soarena.inc.php
2015-05-13 12:55:21 UTC (rev 13190)
@@ -1,332 +1,345 @@
<?php
+ phpgw::import_class('activitycalendar.socommon');
-phpgw::import_class('activitycalendar.socommon');
+ include_class('activitycalendar', 'arena', 'inc/model/');
+ include_class('activitycalendar', 'building', 'inc/model/');
-include_class('activitycalendar', 'arena', 'inc/model/');
-include_class('activitycalendar', 'building', 'inc/model/');
-
-class activitycalendar_soarena extends activitycalendar_socommon
-{
- protected static $so;
-
- /**
- * Get a static reference to the storage object associated with this
model object
- *
- * @return activitycalendar_soparty the storage object
- */
- public static function get_instance()
+ class activitycalendar_soarena extends activitycalendar_socommon
{
- if (self::$so == null) {
- self::$so = CreateObject('activitycalendar.soarena');
- }
- return self::$so;
- }
-
- /**
- * Generate SQL query
- *
- *
- * @param string $sort_field
- * @param boolean $ascending
- * @param string $search_for
- * @param string $search_type
- * @param array $filters
- * @param boolean $return_count
- * @return string SQL
- */
- protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $clauses = array('1=1');
- //Add columns to this array to include them in the query
- $columns = array();
+ protected static $so;
- if($sort_field != null) {
- $dir = $ascending ? 'ASC' : 'DESC';
- if($sort_field == 'arena_id')
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return activitycalendar_soparty the storage object
+ */
+ public static function get_instance()
+ {
+ if(self::$so == null)
{
- $sort_field='id';
+ self::$so =
CreateObject('activitycalendar.soarena');
}
- $order = "ORDER BY
{$this->marshal($sort_field,'field')} $dir";
+ return self::$so;
}
- else if(!$return_count)
+
+ /**
+ * Generate SQL query
+ *
+ *
+ * @param string $sort_field
+ * @param boolean $ascending
+ * @param string $search_for
+ * @param string $search_type
+ * @param array $filters
+ * @param boolean $return_count
+ * @return string SQL
+ */
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
{
- $dir = $ascending ? 'ASC' : 'DESC';
- $order = "ORDER BY arena.arena_name $dir";
- }
-
- if($search_for)
- {
- $query = $this->marshal($search_for,'string');
- $like_pattern = "'%".$search_for."%'";
- $like_clauses = array();
- switch($search_type){
- case "all":
- default:
- $like_clauses[] = "arena.arena_name
$this->like $like_pattern";
- $like_clauses[] = "arena.address
$this->like $like_pattern";
- break;
+ $clauses = array('1=1');
+
+ //Add columns to this array to include them in the query
+ $columns = array();
+
+ if($sort_field != null)
+ {
+ $dir = $ascending ? 'ASC' : 'DESC';
+ if($sort_field == 'arena_id')
+ {
+ $sort_field = 'id';
+ }
+ $order = "ORDER BY {$this->marshal($sort_field,
'field')} $dir";
}
+ else if(!$return_count)
+ {
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = "ORDER BY arena.arena_name $dir";
+ }
+ if($search_for)
+ {
+ $query =
$this->marshal($search_for, 'string');
+ $like_pattern = "'%" . $search_for . "%'";
+ $like_clauses = array();
+ switch($search_type)
+ {
+ case "all":
+ default:
+ $like_clauses[] =
"arena.arena_name $this->like $like_pattern";
+ $like_clauses[] =
"arena.address $this->like $like_pattern";
+ break;
+ }
- if(count($like_clauses))
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ',
$like_clauses) . ')';
+ }
+ }
+
+ $filter_clauses = array();
+
+ if(isset($filters[$this->get_id_field_name()]))
{
- $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ $id =
$this->marshal($filters[$this->get_id_field_name()], 'int');
+ $filter_clauses[] = "arena.id = {$id}";
}
- }
- $filter_clauses = array();
-
- if(isset($filters[$this->get_id_field_name()])){
- $id =
$this->marshal($filters[$this->get_id_field_name()],'int');
- $filter_clauses[] = "arena.id = {$id}";
- }
-
- //filter on active/non-active
- if(isset($filters['active']))
- {
- if($filters['active'] == 'active')
+ //filter on active/non-active
+ if(isset($filters['active']))
{
- $filter_clauses[] = "arena.active = TRUE";
- }
- else if($filters['active'] == 'inactive')
+ if($filters['active'] == 'active')
+ {
+ $filter_clauses[] = "arena.active =
TRUE";
+ }
+ else if($filters['active'] == 'inactive')
+ {
+ $filter_clauses[] = "NOT arena.active";
+ }
+ }
+
+ //filter on internal/not internal arena
+ if(isset($filters['arena_type']))
{
- $filter_clauses[] = "NOT arena.active";
- }
- }
-
- //filter on internal/not internal arena
- if(isset($filters['arena_type']))
- {
- if($filters['arena_type'] == 'internal')
+ if($filters['arena_type'] == 'internal')
+ {
+ $filter_clauses[] = "NOT
arena.internal_arena_id IS NULL";
+ }
+ else if($filters['arena_type'] ==
'not_internal')
+ {
+ $filter_clauses[] =
"arena.internal_arena_id IS NULL";
+ }
+ }
+
+ if(count($filter_clauses))
{
- $filter_clauses[] = "NOT
arena.internal_arena_id IS NULL";
+ $clauses[] = join(' AND ', $filter_clauses);
}
- else if($filters['arena_type'] == 'not_internal')
+
+ $condition = join(' AND ', $clauses);
+ //var_dump($filters);
+ //var_dump($filter_clauses);
+ //var_dump($condition);
+
+ if($return_count) // We should only return a count
{
- $filter_clauses[] = "arena.internal_arena_id IS
NULL";
+ $cols = 'COUNT(DISTINCT(arena.id)) AS count';
}
- }
-
- if(count($filter_clauses))
- {
- $clauses[] = join(' AND ', $filter_clauses);
- }
+ else
+ {
+ $columns[] = 'arena.id';
+ $columns[] = 'arena.arena_name';
+ $columns[] = 'arena.address';
+ $columns[] = 'arena.addressnumber';
+ $columns[] = 'arena.zip_code';
+ $columns[] = 'arena.city';
+ $columns[] = 'arena.internal_arena_id';
+ $columns[] = 'arena.active';
- $condition = join(' AND ', $clauses);
- //var_dump($filters);
- //var_dump($filter_clauses);
- //var_dump($condition);
+ $cols = implode(',', $columns);
+ }
- if($return_count) // We should only return a count
- {
- $cols = 'COUNT(DISTINCT(arena.id)) AS count';
+ $tables = "activity_arena arena";
+
+ //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
+ //{$this->left_join} rental_contract contract ON
(contract.id = c_p.contract_id)";
+
+ $joins = $join_contracts;
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins}
WHERE {$condition} {$order}");
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
}
- else
+
+ /**
+ * Populates an arena-object
+ *
+ * @param int $arena_id
+ * @param activitycalendar_arena $arena
+ * @return activitycalendar_arena $arena
+ */
+ protected function populate(int $arena_id, &$arena)
{
- $columns[] = 'arena.id';
- $columns[] = 'arena.arena_name';
- $columns[] = 'arena.address';
- $columns[] = 'arena.addressnumber';
- $columns[] = 'arena.zip_code';
- $columns[] = 'arena.city';
- $columns[] = 'arena.internal_arena_id';
- $columns[] = 'arena.active';
-
- $cols = implode(',',$columns);
- }
- $tables = "activity_arena arena";
+ if($arena == null)
+ {
+ $arena = new
activitycalendar_arena((int)$arena_id);
- //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
- //{$this->left_join} rental_contract contract ON (contract.id =
c_p.contract_id)";
+
$arena->set_arena_name($this->unmarshal($this->db->f('arena_name'), 'string'));
+
$arena->set_address($this->unmarshal($this->db->f('address'), 'string'));
+
$arena->set_addressnumber($this->unmarshal($this->db->f('addressnumber'),
'string'));
+
$arena->set_zip_code($this->unmarshal($this->db->f('zip_code'), 'string'));
+
$arena->set_city($this->unmarshal($this->db->f('city'), 'string'));
+
$arena->set_internal_arena_id($this->unmarshal($this->db->f('internal_arena_id'),
'int'));
+
$arena->set_active($this->unmarshal($this->db->f('active'), 'bool'));
+ }
+ return $arena;
+ }
- $joins = $join_contracts;
- //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}");
- return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
- }
-
- /**
- * Populates an arena-object
- *
- * @param int $arena_id
- * @param activitycalendar_arena $arena
- * @return activitycalendar_arena $arena
- */
- protected function populate(int $arena_id, &$arena)
- {
+ /**
+ * Get arena name
+ *
+ * @param int $arena_id
+ * @return string arena name
+ */
+ function get_arena_name($arena_id)
+ {
+ $result = "Ingen";
+ if(isset($arena_id) && $arena_id != '')
+ {
+ $q1 = "SELECT arena_name FROM activity_arena
WHERE id={$arena_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('arena_name');
+ }
+ }
- if($arena == null) {
- $arena = new activitycalendar_arena((int) $arena_id);
+ return $result;
+ }
-
$arena->set_arena_name($this->unmarshal($this->db->f('arena_name'), 'string'));
-
$arena->set_address($this->unmarshal($this->db->f('address'), 'string'));
-
$arena->set_addressnumber($this->unmarshal($this->db->f('addressnumber'),
'string'));
-
$arena->set_zip_code($this->unmarshal($this->db->f('zip_code'), 'string'));
- $arena->set_city($this->unmarshal($this->db->f('city'),
'string'));
-
$arena->set_internal_arena_id($this->unmarshal($this->db->f('internal_arena_id'),
'int'));
-
$arena->set_active($this->unmarshal($this->db->f('active'), 'bool'));
+ /**
+ * Get registered buildings from property
+ *
+ * @return array buildings, [id => name]
+ */
+ function get_buildings()
+ {
+ $buildings = array();
+ $q_buildings = "SELECT id, name FROM bb_building WHERE
active=1 ORDER BY name ASC";
+ //var_dump($q_buildings);
+ $this->db->query($q_buildings, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $id =
$this->db->f('id');
+ $buildings[$id] = $this->db->f('name');
+ }
+ return $buildings;
}
- return $arena;
- }
-
- /**
- * Get arena name
- *
- * @param int $arena_id
- * @return string arena name
- */
- function get_arena_name($arena_id)
- {
- $result = "Ingen";
- if(isset($arena_id) && $arena_id != ''){
- $q1="SELECT arena_name FROM activity_arena WHERE
id={$arena_id}";
- $this->db->query($q1, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('arena_name');
+
+ /**
+ * Get building name from property
+ *
+ * @param int $building_id
+ * @return string building name
+ */
+ function get_building_name($building_id)
+ {
+ if(isset($building_id))
+ {
+ $building_id = (int)$building_id;
+ $q1 = "SELECT name FROM
bb_building WHERE id={$building_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name');
+ }
}
- }
-
- return $result;
- }
-
- /**
- * Get registered buildings from property
- *
- * @return array buildings, [id => name]
- */
- function get_buildings()
- {
- $buildings = array();
- $q_buildings="SELECT id, name FROM bb_building WHERE active=1 ORDER BY
name ASC";
- //var_dump($q_buildings);
- $this->db->query($q_buildings, __LINE__, __FILE__);
- while($this->db->next_record()){
- $id = $this->db->f('id');
- $buildings[$id] = $this->db->f('name');
+ return $result;
}
- return $buildings;
- }
-
- /**
- * Get building name from property
- *
- * @param int $building_id
- * @return string building name
- */
- function get_building_name($building_id){
- if(isset($building_id))
+
+ /**
+ * Function for adding a new arena to the database. Updates the
arena object.
+ *
+ * @param activitycalendar_arena $arena the party to be added
+ * @return bool true if successful, false otherwise
+ */
+ function add(&$arena)
{
- $building_id = (int)$building_id;
- $q1="SELECT name FROM bb_building WHERE
id={$building_id}";
- $this->db->query($q1, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('name');
+ // Insert a new arena
+ $q = "INSERT INTO activity_arena
(arena_name) VALUES ('test')";
+ $result = $this->db->query($q);
+
+ if(isset($result))
+ {
+ // Set the new party ID
+
$arena->set_id($this->db->get_last_insert_id('activity_arena', 'id'));
+ // Forward this request to the update method
+ return $this->update($arena);
}
+ else
+ {
+ return false;
+ }
}
- return $result;
- }
-
-
- /**
- * Function for adding a new arena to the database. Updates the arena
object.
- *
- * @param activitycalendar_arena $arena the party to be added
- * @return bool true if successful, false otherwise
- */
- function add(&$arena)
- {
- // Insert a new arena
- $q ="INSERT INTO activity_arena (arena_name) VALUES ('test')";
- $result = $this->db->query($q);
- if(isset($result)) {
- // Set the new party ID
-
$arena->set_id($this->db->get_last_insert_id('activity_arena', 'id'));
- // Forward this request to the update method
- return $this->update($arena);
- }
- else
+ /**
+ * Update the database values for an existing arena object.
+ *
+ * @param $arena the arena to be updated
+ * @return boolean true if successful, false otherwise
+ */
+ function update($arena)
{
- return false;
+ $id = intval($arena->get_id());
+
+ $values = array(
+ 'arena_name = ' .
$this->marshal($arena->get_arena_name(), 'string'),
+ 'address = ' .
$this->marshal($arena->get_address(), 'string'),
+ 'addressnumber = ' .
$this->marshal($arena->get_addressnumber(), 'string'),
+ 'zip_code = ' .
$this->marshal($arena->get_zip_code(), 'string'),
+ 'city = ' . $this->marshal($arena->get_city(),
'string'),
+ 'internal_arena_id = ' .
$this->marshal($arena->get_internal_arena_id(), 'int'),
+ 'active = ' .
$this->marshal(($arena->is_active() ? 'true' : 'false'), 'bool'),
+ );
+
+ $result = $this->db->query('UPDATE activity_arena SET '
. join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
+
+ return isset($result);
}
- }
- /**
- * Update the database values for an existing arena object.
- *
- * @param $arena the arena to be updated
- * @return boolean true if successful, false otherwise
- */
- function update($arena)
- {
- $id = intval($arena->get_id());
-
- $values = array(
- 'arena_name = ' .
$this->marshal($arena->get_arena_name(), 'string'),
- 'address = ' .
$this->marshal($arena->get_address(), 'string'),
- 'addressnumber = ' .
$this->marshal($arena->get_addressnumber(), 'string'),
- 'zip_code = ' . $this->marshal($arena->get_zip_code(),
'string'),
- 'city = ' . $this->marshal($arena->get_city(), 'string'),
- 'internal_arena_id = ' .
$this->marshal($arena->get_internal_arena_id(), 'int'),
- 'active = ' . $this->marshal(($arena->is_active() ?
'true' : 'false'), 'bool'),
- );
-
- $result = $this->db->query('UPDATE activity_arena SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
-
- return isset($result);
- }
-
- public function get_id_field_name($extended_info = false)
- {
- if(!$extended_info)
+ public function get_id_field_name($extended_info = false)
{
- $ret = 'id';
+ if(!$extended_info)
+ {
+ $ret = 'id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' => 'arena', // alias
+ 'field' => 'id',
+ 'translated' => 'id'
+ );
+ }
+ return $ret;
}
- else
+
+ public function get_address($search)
{
- $ret = array
- (
- 'table' => 'arena', // alias
- 'field' => 'id',
- 'translated' => 'id'
- );
+ $result_arr = array();
+ $curr_index = 0;
+ if($search)
+ {
+ $sql = "select * from fm_streetaddress where
UPPER(descr) like UPPER('{$search}%')";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ //$result_arr = $this->db->f('name');
+ if($curr_index == 0)
+ {
+ $result_arr[] = "<option
value='0'>Velg gateadresse</option>";
+ }
+ $result_arr[] = "<option value='" .
$this->db->f('descr') . "'>" . $this->db->f('descr') . "</option>";
+ $curr_index++;
+ }
+ }
+ $result = implode(' ', $result_arr);
+ return $result;
}
- return $ret;
- }
-
- public function get_address($search)
- {
- $result_arr = array();
- $curr_index=0;
- if($search)
+
+ public function get_arena_id_by_name($arena_name)
{
- $sql = "select * from fm_streetaddress where
UPPER(descr) like UPPER('{$search}%')";
- $this->db->query($sql, __LINE__, __FILE__);
- while($this->db->next_record()){
- //$result_arr = $this->db->f('name');
- if($curr_index == 0){
- $result_arr[] = "<option value='0'>Velg
gateadresse</option>";
+ $result = 0;
+ if(isset($arena_name) && $arena_name != '')
+ {
+ $q1 = "SELECT id FROM activity_arena WHERE
UPPER(arena_name) = UPPER('{$arena_name}')";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('id');
}
- $result_arr[] = "<option value='" .
$this->db->f('descr') . "'>" . $this->db->f('descr') . "</option>";
- $curr_index++;
}
+ return $result;
}
- $result = implode(' ' , $result_arr);
- return $result;
- }
-
- public function get_arena_id_by_name($arena_name)
- {
- $result = 0;
- if(isset($arena_name) && $arena_name != ''){
- $q1="SELECT id FROM activity_arena WHERE UPPER(arena_name) =
UPPER('{$arena_name}')";
- $this->db->query($q1, __LINE__, __FILE__);
- while($this->db->next_record()){
- $result = $this->db->f('id');
- }
- }
- return $result;
- }
-}
-?>
\ No newline at end of file
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/activitycalendar/inc/class.socommon.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendar/inc/class.socommon.inc.php
2015-05-13 06:02:39 UTC (rev 13189)
+++ branches/dev-syncromind/activitycalendar/inc/class.socommon.inc.php
2015-05-13 12:55:21 UTC (rev 13190)
@@ -1,323 +1,326 @@
<?php
-abstract class activitycalendar_socommon
-{
- protected $db;
- protected $like;
- protected $join;
- protected $left_join;
-
- public function __construct()
+
+ abstract class activitycalendar_socommon
{
- $this->db = clone $GLOBALS['phpgw']->db;
- $this->like = & $this->db->like;
- $this->join = & $this->db->join;
- $this->left_join = & $this->db->left_join;
- }
-
- /**
- * Marshal values according to type
- * @param $value the value
- * @param $type the type of value
- * @return database value
- */
- protected function marshal($value, $type)
- {
- if($value === null)
+
+ protected $db;
+ protected $like;
+ protected $join;
+ protected $left_join;
+
+ public function __construct()
{
- return 'NULL';
+ $this->db = clone $GLOBALS['phpgw']->db;
+ $this->like = & $this->db->like;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
}
- else if($type == 'int')
+
+ /**
+ * Marshal values according to type
+ * @param $value the value
+ * @param $type the type of value
+ * @return database value
+ */
+ protected function marshal($value, $type)
{
- if($value == '')
+ if($value === null)
{
return 'NULL';
}
- return intval($value);
+ else if($type == 'int')
+ {
+ if($value == '')
+ {
+ return 'NULL';
+ }
+ return intval($value);
+ }
+ else if($type == 'float')
+ {
+ return str_replace(',', '.', $value);
+ }
+ else if($type == 'field')
+ {
+ return $this->db->db_addslashes($value);
+ }
+ return "'" . $this->db->db_addslashes($value) . "'";
}
- else if($type == 'float')
+
+ /**
+ * Unmarchal database values according to type
+ * @param $value the field value
+ * @param $type a string dictating value type
+ * @return the php value
+ */
+ protected function unmarshal($value, $type)
{
- return str_replace(',', '.', $value);
+ if($type == 'bool')
+ {
+ return (boolean)$value;
+ }
+ elseif($value === null || $value == 'NULL')
+ {
+ return null;
+ }
+ elseif($type == 'int')
+ {
+ return intval($value);
+ }
+ elseif($type == 'float')
+ {
+ return floatval($value);
+ }
+ return $value;
}
- else if($type == 'field')
+
+ /**
+ * Get the count of the specified query. Query must return a
signel column
+ * called count.
+ *
+ * @param $sql the sql query
+ * @return the count value
+ */
+ protected function get_query_count($sql)
{
- return $this->db->db_addslashes($value);
+ $result = $this->db->query($sql);
+ if($result && $this->db->next_record())
+ {
+ return $this->unmarshal($this->db->f('count',
true), 'int');
+ }
}
- return "'" . $this->db->db_addslashes($value) . "'";
- }
- /**
- * Unmarchal database values according to type
- * @param $value the field value
- * @param $type a string dictating value type
- * @return the php value
- */
- protected function unmarshal($value, $type)
- {
- if($type == 'bool')
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public abstract static function get_instance();
+
+ /**
+ * Convenience method for getting one single object. Calls
get() with the
+ * specified id as a filter.
+ *
+ * @param $id int with id of object to return.
+ * @return object with the specified id, null if not found.
+ */
+ public function get_single(int $id)
{
- return (boolean)$value;
- }
- elseif($value === null || $value == 'NULL')
- {
+ $objects = $this->get(null, null, null, null, null,
null, array($this->get_id_field_name() => $id));
+ if(count($objects) > 0)
+ {
+ $keys = array_keys($objects);
+ return $objects[$keys[0]];
+ }
return null;
}
- elseif($type == 'int')
+
+ /**
+ * Method for retrieving the db-object (security "forgotten")
+ */
+ public function get_db()
{
- return intval($value);
+ return $this->db;
}
- elseif($type == 'float')
- {
- return floatval($value);
- }
- return $value;
- }
- /**
- * Get the count of the specified query. Query must return a signel
column
- * called count.
- *
- * @param $sql the sql query
- * @return the count value
- */
- protected function get_query_count($sql)
- {
- $result = $this->db->query($sql);
- if($result && $this->db->next_record())
+ /**
+ * Method for retreiving objects.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to
return.
+ * @param $sort_field string representing the object field to
sort on.
+ * @param $ascending boolean true for ascending sort on sort
field, false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return array of objects. May return an empty
+ * array, never null. The array keys are the respective index
numbers.
+ */
+ public function get(int $start_index, int $num_of_objects,
string $sort_field, boolean $ascending, string $search_for, string
$search_type, array $filters)
{
- return $this->unmarshal($this->db->f('count', true),
'int');
- }
- }
-
- /**
- * Implementing classes must return an instance of itself.
- *
- * @return the class instance.
- */
- public abstract static function get_instance();
+ $results = array(); // Array
to store result objects
+ $map = array(); //
Array to hold number of records per target object
+ $check_map = array(); // Array
to hold the actual number of record read per target object
+ $object_ids = array(); // All of
the object ids encountered
+ $added_object_ids = array();// All of the added
objects ids
+ // Retrieve information about the table name and the
name and alias of id column
+ // $break_on_limit - flag indicating whether to
break the loop when the number of records
+ // for all
the result objects are traversed
+ $id_field_name_info = $this->get_id_field_name(true);
+ if(is_array($id_field_name_info))
+ {
+ $break_on_limit = true;
+ $id_field_name =
$id_field_name_info['translated'];
+ }
+ else
+ {
+ $break_on_limit = false;
+ $id_field_name = $id_field_name_info;
+ }
- /**
- * Convenience method for getting one single object. Calls get() with
the
- * specified id as a filter.
- *
- * @param $id int with id of object to return.
- * @return object with the specified id, null if not found.
- */
- public function get_single(int $id)
- {
- $objects = $this->get(null, null, null, null, null, null,
array($this->get_id_field_name() => $id));
- if(count($objects) > 0)
- {
- $keys = array_keys($objects);
- return $objects[$keys[0]];
- }
- return null;
- }
-
- /**
- * Method for retrieving the db-object (security "forgotten")
- */
- public function get_db(){
- return $this->db;
- }
+ // Special case: Sort on id field. Always changed to
the id field name.
+ // $break_when_num_of_objects_reached - flag indicating
to break the loop when the number of
+ // results are reached and we are sure
that the records are ordered by the id
+ if($sort_field == null || $sort_field == 'id' ||
$sort_field == '')
+ {
+ $sort_field
= $id_field_name;
+ $break_when_num_of_objects_reached = true;
+ }
+ else
+ {
+ $break_when_num_of_objects_reached = false;
+ }
- /**
- * Method for retreiving objects.
- *
- * @param $start_index int with index of first object.
- * @param $num_of_objects int with max number of objects to return.
- * @param $sort_field string representing the object field to sort on.
- * @param $ascending boolean true for ascending sort on sort field,
false
- * for descending.
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @return array of objects. May return an empty
- * array, never null. The array keys are the respective index numbers.
- */
- public function get(int $start_index, int $num_of_objects, string
$sort_field, boolean $ascending, string $search_for, string $search_type, array
$filters)
- {
- $results = array(); // Array to store
result objects
- $map = array(); // Array to hold number
of records per target object
- $check_map = array(); // Array to hold the actual
number of record read per target object
- $object_ids = array(); // All of the object ids
encountered
- $added_object_ids = array();// All of the added objects ids
-
- // Retrieve information about the table name and the name and
alias of id column
- // $break_on_limit - flag indicating whether to break the
loop when the number of records
- // for all the
result objects are traversed
- $id_field_name_info = $this->get_id_field_name(true);
- if(is_array($id_field_name_info))
- {
- $break_on_limit = true;
- $id_field_name = $id_field_name_info['translated'];
- }
- else
- {
- $break_on_limit = false;
- $id_field_name = $id_field_name_info;
- }
+ // Only allow positive start index
+ if($start_index < 0)
+ {
+ $start_index = 0;
+ }
- // Special case: Sort on id field. Always changed to the id
field name.
- // $break_when_num_of_objects_reached - flag indicating to
break the loop when the number of
- // results are reached and we are sure that the
records are ordered by the id
- if($sort_field == null || $sort_field == 'id' || $sort_field ==
'')
- {
- $sort_field = $id_field_name;
- $break_when_num_of_objects_reached = true;
- }
- else
- {
- $break_when_num_of_objects_reached = false;
- }
-
- // Only allow positive start index
- if($start_index < 0)
- {
- $start_index = 0;
- }
-
- // test-input for break on ordered queries
- $db2 = clone($this->db);
+ // test-input for break on ordered queries
+ $db2 = clone($this->db);
- $sql = $this->get_query($sort_field, $ascending, $search_for,
$search_type, $filters, false);
- $sql_parts = explode('1=1',$sql); // Split the query to insert
extra condition on test for break
- $this->db->query($sql,__LINE__, __FILE__, false, true);
+ $sql = $this->get_query($sort_field,
$ascending, $search_for, $search_type, $filters, false);
+ $sql_parts = explode('1=1', $sql); // Split the
query to insert extra condition on test for break
+ $this->db->query($sql, __LINE__, __FILE__, false, true);
- while ($this->db->next_record()) // Runs through all of the
results
- {
- $should_populate_object = false; // Default value - we
won't populate object
- $result_id =
$this->unmarshal($this->db->f($id_field_name), 'int'); // The id of object
- if(in_array($result_id, $added_object_ids)) // Object
with this id already added
+ while($this->db->next_record()) // Runs through all of
the results
{
- $should_populate_object = true; // We should
populate this object as we already have it in our result array
- }
- else // Object isn't already added to array
- {
- if(!in_array($result_id, $object_ids)) //
Haven't already added this id
+ $should_populate_object = false; // Default
value - we won't populate object
+ $result_id =
$this->unmarshal($this->db->f($id_field_name), 'int'); // The id of object
+ if(in_array($result_id, $added_object_ids)) //
Object with this id already added
{
- $object_ids[] = $result_id; // We have
to add the new id
+ $should_populate_object = true; // We
should populate this object as we already have it in our result array
}
- // We have to check if we should populate this
object
- if(count($object_ids) > $start_index) // We're
at index above start index
+ else // Object isn't already added to array
{
- if($num_of_objects == null ||
count($results) < $num_of_objects) // We haven't found all the objects we're
looking for
+ if(!in_array($result_id, $object_ids))
// Haven't already added this id
{
- $should_populate_object = true;
// We should populate this object
- $added_object_ids[] =
$result_id; // We keep the id
+ $object_ids[] = $result_id; //
We have to add the new id
}
+ // We have to check if we should
populate this object
+ if(count($object_ids) > $start_index)
// We're at index above start index
+ {
+ if($num_of_objects == null ||
count($results) < $num_of_objects) // We haven't found all the objects we're
looking for
+ {
+ $should_populate_object
= true; // We should populate this object
+ $added_object_ids[]
= $result_id; // We keep the id
+ }
+ }
}
- }
- if($should_populate_object)
- {
- $result = &$results[$result_id];
- $results[$result_id] =
$this->populate($result_id,$result);
- $last_result_id = $result_id;
- $map[$result_id] = (int)$map[$result_id] +1;
- }
-
- //Stop looping when array not sorted on other then id
and wanted number of results is reached
- if(count($results) == $num_of_objects &&
$last_result_id != $result_id && $break_when_num_of_objects_reached)
- {
- break;
- }
- // else stop looping when wanted number of results is
reached all records for result objects are read
- else if($break_on_limit && (count($results) ==
$num_of_objects) && $last_result_id != $result_id)
- {
- $id_ok = 0;
- foreach ($map as $_result_id => $_count)
+ if($should_populate_object)
{
- if(!isset($check_map[$_result_id]))
+ $result =
&$results[$result_id];
+ $results[$result_id] =
$this->populate($result_id, $result);
+ $last_result_id = $result_id;
+ $map[$result_id] =
(int)$map[$result_id] + 1;
+ }
+
+ //Stop looping when array not sorted on other
then id and wanted number of results is reached
+ if(count($results) == $num_of_objects &&
$last_result_id != $result_id && $break_when_num_of_objects_reached)
+ {
+ break;
+ }
+ // else stop looping when wanted number of
results is reached all records for result objects are read
+ else if($break_on_limit && (count($results) ==
$num_of_objects) && $last_result_id != $result_id)
+ {
+ $id_ok = 0;
+ foreach($map as $_result_id => $_count)
{
- // Query the number of records
for the specific object in question
- $sql2 = "{$sql_parts[0]} 1=1
AND {$id_field_name_info['table']}.{$id_field_name_info['field']} =
{$_result_id} {$sql_parts[1]}";
- $db2->query($sql2,__LINE__,
__FILE__);
- $db2->next_record();
- $check_map[$_result_id] =
$db2->num_rows();
+
if(!isset($check_map[$_result_id]))
+ {
+ // Query the number of
records for the specific object in question
+ $sql2
= "{$sql_parts[0]} 1=1 AND
{$id_field_name_info['table']}.{$id_field_name_info['field']} = {$_result_id}
{$sql_parts[1]}";
+ $db2->query($sql2,
__LINE__, __FILE__);
+ $db2->next_record();
+ $check_map[$_result_id]
= $db2->num_rows();
+ }
+ if($check_map[$_result_id] ==
$_count)
+ {
+ $id_ok++;
+ }
}
- if( $check_map[$_result_id] ==
$_count )
+ if($id_ok == $num_of_objects)
{
- $id_ok++;
+ break;
}
}
- if($id_ok == $num_of_objects)
- {
- break;
- }
}
+ return $results;
}
- return $results;
- }
-
- /**
- * Returns count of matching objects.
- *
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @return int with object count.
- */
- public function get_count(string $search_for, string $search_type,
array $filters)
- {
- return $this->get_query_count($this->get_query(null, null,
$search_for, $search_type, $filters, true));
- }
-
- /**
- * Implementing classes must return the name of the field used in the
query
- * returned from get_query().
- *
- * @return string with name of id field.
- */
- protected abstract function get_id_field_name();
-
- /**
- * Returns SQL for retrieving matching objects or object count.
- *
- * @param $start_index int with index of first object.
- * @param $num_of_objects int with max number of objects to return.
- * @param $sort_field string representing the object field to sort on.
- * @param $ascending boolean true for ascending sort on sort field,
false
- * for descending.
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @param $return_count boolean telling to return only the count of the
- * matching objects, or the objects themself.
- * @return string with SQL.
- */
- protected abstract function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count);
-
- protected abstract function populate(int $object_id, &$object);
-
- protected abstract function add(&$object);
-
- protected abstract function update($object);
-
- /**
- * Store the object in the database. If the object has no ID it is
assumed to be new and
- * inserted for the first time. The object is then updated with the new
insert id.
- */
- public function store(&$object)
- {
- if ($object->validates()) {
- if ($object->get_id() > 0) {
- // We can assume this composite came from the
database since it has an ID. Update the existing row
- return $this->update($object);
- }
- else
+
+ /**
+ * Returns count of matching objects.
+ *
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return int with object count.
+ */
+ public function get_count(string $search_for, string
$search_type, array $filters)
+ {
+ return $this->get_query_count($this->get_query(null,
null, $search_for, $search_type, $filters, true));
+ }
+
+ /**
+ * Implementing classes must return the name of the field used
in the query
+ * returned from get_query().
+ *
+ * @return string with name of id field.
+ */
+ protected abstract function get_id_field_name();
+
+ /**
+ * Returns SQL for retrieving matching objects or object count.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to
return.
+ * @param $sort_field string representing the object field to
sort on.
+ * @param $ascending boolean true for ascending sort on sort
field, false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @param $return_count boolean telling to return only the
count of the
+ * matching objects, or the objects themself.
+ * @return string with SQL.
+ */
+ protected abstract function get_query(string $sort_field,
boolean $ascending, string $search_for, string $search_type, array $filters,
boolean $return_count);
+
+ protected abstract function populate(int $object_id, &$object);
+
+ protected abstract function add(&$object);
+
+ protected abstract function update($object);
+
+ /**
+ * Store the object in the database. If the object has no ID
it is assumed to be new and
+ * inserted for the first time. The object is then updated
with the new insert id.
+ */
+ public function store(&$object)
+ {
+ if($object->validates())
{
- // This object does not have an ID, so will be
saved as a new DB row
- return $this->add($object);
+ if($object->get_id() > 0)
+ {
+ // We can assume this composite came
from the database since it has an ID. Update the existing row
+ return $this->update($object);
+ }
+ else
+ {
+ // This object does not have an ID, so
will be saved as a new DB row
+ return $this->add($object);
+ }
}
+
+ // The object did not validate
+ return false;
}
- // The object did not validate
- return false;
- }
-
- protected function generate_secret($length = 10)
- {
- return substr(base64_encode(rand(1000000000,9999999999)),0,
$length);
- }
-}
-?>
\ No newline at end of file
+ protected function generate_secret($length = 10)
+ {
+ return substr(base64_encode(rand(1000000000,
9999999999)), 0, $length);
+ }
+ }
\ No newline at end of file
Modified:
branches/dev-syncromind/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendar/inc/class.socontactperson.inc.php
2015-05-13 06:02:39 UTC (rev 13189)
+++ branches/dev-syncromind/activitycalendar/inc/class.socontactperson.inc.php
2015-05-13 12:55:21 UTC (rev 13190)
@@ -1,441 +1,455 @@
<?php
-phpgw::import_class('activitycalendar.socommon');
+ phpgw::import_class('activitycalendar.socommon');
-include_class('activitycalendar', 'contact_person', 'inc/model/');
+ include_class('activitycalendar', 'contact_person', 'inc/model/');
-class activitycalendar_socontactperson extends activitycalendar_socommon
-{
- protected static $so;
-
- /**
- * Get a static reference to the storage object associated with this
model object
- *
- * @return rental_soparty the storage object
- */
- public static function get_instance()
+ class activitycalendar_socontactperson extends activitycalendar_socommon
{
- if (self::$so == null) {
- self::$so =
CreateObject('activitycalendar.socontactperson');
- }
- return self::$so;
- }
-
- /**
- * Generate SQL query
- *
- * @todo Add support for filter "party_type", meaning what type of
contracts
- * the party is involved in.
- *
- * @param string $sort_field
- * @param boolean $ascending
- * @param string $search_for
- * @param string $search_type
- * @param array $filters
- * @param boolean $return_count
- * @return string SQL
- */
- protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $clauses = array('1=1');
- $table = "";
- //Add columns to this array to include them in the query
- $columns = array();
+ protected static $so;
-/* if($sort_field != null) {
- $dir = $ascending ? 'ASC' : 'DESC';
- $order = "ORDER BY id $dir";
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return rental_soparty the storage object
+ */
+ public static function get_instance()
+ {
+ if(self::$so == null)
+ {
+ self::$so =
CreateObject('activitycalendar.socontactperson');
+ }
+ return self::$so;
}
- */
- if($search_for)
+
+ /**
+ * Generate SQL query
+ *
+ * @todo Add support for filter "party_type", meaning what type
of contracts
+ * the party is involved in.
+ *
+ * @param string $sort_field
+ * @param boolean $ascending
+ * @param string $search_for
+ * @param string $search_type
+ * @param array $filters
+ * @param boolean $return_count
+ * @return string SQL
+ */
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
{
- $query = $this->marshal($search_for,'string');
- $like_pattern = "'%".$search_for."%'";
- $like_clauses = array();
- switch($search_type){
- case "name":
- $like_clauses[] = "party.first_name
$this->like $like_pattern";
- $like_clauses[] = "party.last_name
$this->like $like_pattern";
- $like_clauses[] = "party.company_name
$this->like $like_pattern";
- break;
- case "address":
- $like_clauses[] = "party.address_1
$this->like $like_pattern";
- $like_clauses[] = "party.address_2
$this->like $like_pattern";
- $like_clauses[] = "party.postal_code
$this->like $like_pattern";
- $like_clauses[] = "party.place
$this->like $like_pattern";
- break;
- case "identifier":
- $like_clauses[] = "party.identifier
$this->like $like_pattern";
- break;
- case "reskontro":
- $like_clauses[] = "party.reskontro
$this->like $like_pattern";
- break;
- case "result_unit_number":
- $like_clauses[] =
"party.result_unit_number $this->like $like_pattern";
- break;
- case "all":
- $like_clauses[] = "party.first_name
$this->like $like_pattern";
- $like_clauses[] = "party.last_name
$this->like $like_pattern";
- $like_clauses[] = "party.company_name
$this->like $like_pattern";
- $like_clauses[] = "party.address_1
$this->like $like_pattern";
- $like_clauses[] = "party.address_2
$this->like $like_pattern";
- $like_clauses[] = "party.postal_code
$this->like $like_pattern";
- $like_clauses[] = "party.place
$this->like $like_pattern";
- $like_clauses[] = "party.identifier
$this->like $like_pattern";
- $like_clauses[] = "party.comment
$this->like $like_pattern";
- $like_clauses[] = "party.reskontro
$this->like $like_pattern";
- break;
+ $clauses = array('1=1');
+ $table = "";
+
+ //Add columns to this array to include them in the query
+ $columns = array();
+
+ /* if($sort_field != null) {
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = "ORDER BY id $dir";
+ }
+ */
+ if($search_for)
+ {
+ $query =
$this->marshal($search_for, 'string');
+ $like_pattern = "'%" . $search_for . "%'";
+ $like_clauses = array();
+ switch($search_type)
+ {
+ case "name":
+ $like_clauses[] =
"party.first_name $this->like $like_pattern";
+ $like_clauses[] =
"party.last_name $this->like $like_pattern";
+ $like_clauses[] =
"party.company_name $this->like $like_pattern";
+ break;
+ case "address":
+ $like_clauses[] =
"party.address_1 $this->like $like_pattern";
+ $like_clauses[] =
"party.address_2 $this->like $like_pattern";
+ $like_clauses[] =
"party.postal_code $this->like $like_pattern";
+ $like_clauses[] = "party.place
$this->like $like_pattern";
+ break;
+ case "identifier":
+ $like_clauses[] =
"party.identifier $this->like $like_pattern";
+ break;
+ case "reskontro":
+ $like_clauses[] =
"party.reskontro $this->like $like_pattern";
+ break;
+ case "result_unit_number":
+ $like_clauses[] =
"party.result_unit_number $this->like $like_pattern";
+ break;
+ case "all":
+ $like_clauses[] =
"party.first_name $this->like $like_pattern";
+ $like_clauses[] =
"party.last_name $this->like $like_pattern";
+ $like_clauses[] =
"party.company_name $this->like $like_pattern";
+ $like_clauses[] =
"party.address_1 $this->like $like_pattern";
+ $like_clauses[] =
"party.address_2 $this->like $like_pattern";
+ $like_clauses[] =
"party.postal_code $this->like $like_pattern";
+ $like_clauses[] = "party.place
$this->like $like_pattern";
+ $like_clauses[] =
"party.identifier $this->like $like_pattern";
+ $like_clauses[] =
"party.comment $this->like $like_pattern";
+ $like_clauses[] =
"party.reskontro $this->like $like_pattern";
+ break;
+ }
+
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ',
$like_clauses) . ')';
+ }
}
+ $filter_clauses = array();
+ $contact_person_id =
$this->marshal($filters['id'], 'int');
+ if(isset($filters['org_id']))
+ {
+ $org_id = $this->marshal($filters['org_id'],
'int');
+ if(isset($org_id) && $org_id > 0)
+ {
+ $filter_clauses[] =
"organization_contact.organization_id = {$org_id}";
+ $filter_clauses[] =
"organization_contact.id = {$contact_person_id}";
+ $table =
"bb_organization_contact organization_contact";
+ }
+ }
+ if(isset($filters['organization_id']))
+ {
+ $org_id =
$this->marshal($filters['organization_id'], 'int');
+ if(isset($org_id) && $org_id > 0)
+ {
+ $filter_clauses[] =
"organization_contact.organization_id = {$org_id}";
+ $table =
"bb_organization_contact organization_contact";
+ }
+ }
+ else if(isset($filters['group_id']))
+ {
+ $group_id =
$this->marshal($filters['group_id'], 'int');
+ if(isset($group_id) && $group_id > 0)
+ {
+ $filter_clauses[] =
"group_contact.group_id = {$group_id}";
+ $filter_clauses[] =
"group_contact.id = {$contact_person_id}";
+ $table =
"bb_group_contact group_contact";
+ }
+ }
+ /*
+ // All parties with contracts of type X
+ if(isset($filters['party_type']))
+ {
+ $party_type =
$this->marshal($filters['party_type'],'int');
+ if(isset($party_type) && $party_type > 0)
+ {
+ $filter_clauses[] = "contract.location_id =
{$party_type}";
+ }
+ }
+ */
- if(count($like_clauses))
+ if(count($filter_clauses))
{
- $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ $clauses[] = join(' AND ', $filter_clauses);
}
+
+ $condition = join(' AND ', $clauses);
+
+ if($table == "bb_organization_contact
organization_contact")
+ {
+ if($return_count) // We should only return a
count
+ {
+ $cols =
'COUNT(DISTINCT(organization_contact.id)) AS count';
+ }
+ else
+ {
+ $columns[] =
'organization_contact.id';
+ $columns[] =
'organization_contact.name';
+ $columns[] =
'organization_contact.ssn';
+ $columns[] =
'organization_contact.phone';
+ $columns[] =
'organization_contact.email';
+ $columns[] =
'organization_contact.organization_id';
+
+ $cols = implode(',', $columns);
+ }
+ }
+ else
+ {
+ if($return_count) // We should only return a
count
+ {
+ $cols =
'COUNT(DISTINCT(group_contact.id)) AS count';
+ }
+ else
+ {
+ $columns[] = 'group_contact.id';
+ $columns[] = 'group_contact.name';
+ $columns[] =
'group_contact.phone';
+ $columns[] =
'group_contact.email';
+ $columns[] =
'group_contact.group_id';
+
+ $cols = implode(',', $columns);
+ }
+ }
+
+ $tables = $table;
+
+ //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
+ //{$this->left_join} rental_contract contract ON
(contract.id = c_p.contract_id)";
+ //var_dump("SELECT {$cols} FROM {$tables} WHERE
{$condition} {$order}");
+ return "SELECT {$cols} FROM {$tables} WHERE
{$condition} {$order}";
}
-
- $filter_clauses = array();
- $contact_person_id = $this->marshal($filters['id'],'int');
- if(isset($filters['org_id']))
+
+ function get_group_contact_name($id)
{
- $org_id = $this->marshal($filters['org_id'],'int');
- if(isset($org_id) && $org_id > 0)
+ $result = "Ingen";
+ if(isset($id) && $id != '')
{
- $filter_clauses[] =
"organization_contact.organization_id = {$org_id}";
- $filter_clauses[] = "organization_contact.id =
{$contact_person_id}";
- $table = "bb_organization_contact
organization_contact";
-
+ $q1 = "SELECT name, phone, email FROM
bb_group_contact WHERE id={$id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name') .
"<br/>" . $this->db->f('phone') . "<br/>" . $this->db->f('email');
+ }
}
+ return $result;
}
- if(isset($filters['organization_id']))
+
+ function get_group_contact_name_local($id)
{
- $org_id =
$this->marshal($filters['organization_id'],'int');
- if(isset($org_id) && $org_id > 0)
+ $result = "Ingen";
+ if(isset($id) && $id != '')
{
- $filter_clauses[] =
"organization_contact.organization_id = {$org_id}";
- $table = "bb_organization_contact
organization_contact";
-
+ $q1 = "SELECT name, phone, email FROM
activity_contact_person WHERE id={$id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name') .
"<br/>" . $this->db->f('phone') . "<br/>" . $this->db->f('email');
+ }
}
+ return $result;
}
- else if(isset($filters['group_id']))
+
+ function get_org_contact_name($id)
{
- $group_id = $this->marshal($filters['group_id'],'int');
- if(isset($group_id) && $group_id > 0)
+ $result = "Ingen";
+ if(isset($id) && $id != '')
{
- $filter_clauses[] = "group_contact.group_id =
{$group_id}";
- $filter_clauses[] = "group_contact.id =
{$contact_person_id}";
- $table = "bb_group_contact group_contact";
+ $q1 = "SELECT name, phone, email FROM
bb_organization_contact WHERE id={$id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name') .
"<br/>" . $this->db->f('phone') . "<br/>" . $this->db->f('email');
+ }
}
+ return $result;
}
-/*
- // All parties with contracts of type X
- if(isset($filters['party_type']))
+
+ function get_org_contact_name_local($id)
{
- $party_type =
$this->marshal($filters['party_type'],'int');
- if(isset($party_type) && $party_type > 0)
+ $result = "Ingen";
+ if(isset($id) && $id != '')
{
- $filter_clauses[] = "contract.location_id =
{$party_type}";
+ $q1 = "SELECT name, phone, email FROM
activity_contact_person WHERE id={$id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('name') .
"<br/>" . $this->db->f('phone') . "<br/>" . $this->db->f('email');
+ }
}
+ return $result;
}
-*/
-
- if(count($filter_clauses))
+
+ function get_mailaddress_for_group_contact($contact_person_id)
{
- $clauses[] = join(' AND ', $filter_clauses);
+ if($contact_person_id)
+ {
+ $q1 = "SELECT email FROM bb_group_contact WHERE
id={$contact_person_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('email');
+ }
+ }
+ return $result;
}
- $condition = join(' AND ', $clauses);
-
- if($table == "bb_organization_contact organization_contact")
+ function get_mailaddress_for_org_contact($contact_person_id)
{
- if($return_count) // We should only return a count
+ if($contact_person_id)
{
- $cols =
'COUNT(DISTINCT(organization_contact.id)) AS count';
+ $q1 = "SELECT email FROM
bb_organization_contact WHERE id={$contact_person_id}";
+ $this->db->query($q1, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $result = $this->db->f('email');
+ }
}
- else
- {
- $columns[] = 'organization_contact.id';
- $columns[] = 'organization_contact.name';
- $columns[] = 'organization_contact.ssn';
- $columns[] = 'organization_contact.phone';
- $columns[] = 'organization_contact.email';
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13190] formatting code,
Sigurd Nes <=