fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7333] Merge 7295:7332 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [7333] Merge 7295:7332 from trunk
Date: Tue, 31 May 2011 05:59:51 +0000

Revision: 7333
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7333
Author:   sigurdne
Date:     2011-05-31 05:59:50 +0000 (Tue, 31 May 2011)
Log Message:
-----------
Merge 7295:7332 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.soarena.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.socommon.inc.php
    
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.sogroup.inc.php
    
branches/Version-1_0-branch/activitycalendar/inc/class.soorganization.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.uicommon.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
    
branches/Version-1_0-branch/activitycalendar/inc/model/class.activity.inc.php
    branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
    branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
    branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
    branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php
    branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
    
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
    
branches/Version-1_0-branch/booking/inc/class.uiaccount_code_dimension.inc.php
    branches/Version-1_0-branch/booking/inc/class.uireports.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mssql.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mysql.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_oracle.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_sapdb.inc.php
    branches/Version-1_0-branch/phpgwapi/setup/phpgw_no.lang
    branches/Version-1_0-branch/phpgwapi/templates/bkbooking/css/frontend.css
    branches/Version-1_0-branch/phpgwapi/templates/bkbooking/head.inc.php
    branches/Version-1_0-branch/property/inc/class.uientity.inc.php
    branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
    branches/Version-1_0-branch/property/js/yahoo/location.index.js
    branches/Version-1_0-branch/property/templates/base/entity.xsl
    branches/Version-1_0-branch/property/templates/base/location.xsl
    branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php
    branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
    branches/Version-1_0-branch/rental/inc/class.uiparty.inc.php
    branches/Version-1_0-branch/rental/setup/phpgw_no.lang
    branches/Version-1_0-branch/rental/setup/setup.inc.php
    branches/Version-1_0-branch/rental/setup/tables_update.inc.php
    branches/Version-1_0-branch/rental/templates/base/contract.php

Removed Paths:
-------------
    
branches/Version-1_0-branch/phpgwapi/templates/bkbooking/images/newlayout/Thumbs.db

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7295
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php   
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php   
2011-05-31 05:59:50 UTC (rev 7333)
@@ -33,9 +33,25 @@
                (
                        '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'
                )
        );
 
+       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
@@ -203,7 +219,8 @@
        {
                // Insert a new activity
                $ts_now = strtotime('now');
-               $q ="INSERT INTO activity_activity (title, create_date) VALUES 
('tmptitle', $ts_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)) {
@@ -251,7 +268,57 @@
 
                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',
+                       'time',
+                       'last_change_date',
+                       'create_date',
+                       'contact_person_1',
+                       'contact_person_2',
+                       '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_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($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)
@@ -349,15 +416,17 @@
        
        function get_district_name($district_id)
        {
-               $result = "Ingen";
+               //$result = "Ingen";
+               $values = array();
                if($district_id != null)
                {
-                       $sql = "SELECT name FROM fm_part_of_town where 
part_of_town_id=$district_id";
+                       $sql = "SELECT 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()){
-                               $result = $this->db->f('name');
+                               $values[] = $this->db->f('name');
                        }
        }
+       $result = implode(",",$values);
                return $result;
        }
        
@@ -458,44 +527,193 @@
                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)
+               {
+                       $sql = "update bb_organization set show_in_portal=1 
where id={$org_id}";
+               $result = $this->db->query($sql, __LINE__, __FILE__);
+               }
+               return isset($result);
+       }
+       
        function get_activities()
        {
+               $activities = array();
                $sql = "SELECT * FROM activity_activity";
                $this->db->query($sql, __LINE__, __FILE__);
                while ($this->db->next_record())
                {                       
                        $activities[]= array
                        (
-                                       'id'                            => 
(int) $this->db->f('id'),
-                                       'title'                         => 
$this->db->f('title',true),
-                                       'organization_id'       => 
$this->db->f('organization_id',true),
-                                       'organization_name' => 
activitycalendar_soorganization::get_instance()->get_organization_name($this->db->f('organization_id',true)),
-                                       'group_id'                      => 
$this->db->f('group_id'),
-                                       'group_name'            => 
activitycalendar_sogroup::get_instance()->get_group_name($this->db->f('group_id')),
-                                       'district'                      => 
$this->db->f('district',true),
-                                       'district_name'         => 
activitycalendar_soactivity::get_instance()->get_district_name($this->db->f('district',
 true)),
-                                       'category'                      => 
$this->db->f('category'),
-                                       'category_name'         => 
$this->get_category_name($this->db->f('category')),
-                                       'state'                         => 
$this->db->f('state',true),
-                                       'target'                        => 
$this->db->f('target'),
-                                       'description'           => 
$this->db->f('description'),
-                                       'time'                          => 
$this->db->f('time'),
-                                       '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'),
+                               'id'                            => (int) 
$this->db->f('id'),
+                               'title'                         => 
utf8_decode($this->db->f('title',true)),
+                               'organization_id'       => 
$this->db->f('organization_id',true),
+                               'group_id'                      => 
$this->db->f('group_id'),
+                               'district'                      => 
$this->db->f('district',true),
+                               'category'                      => 
$this->db->f('category'),
+                               'state'                         => 
$this->db->f('state',true),
+                               'target'                        => 
$this->db->f('target'),
+                               'description'           => 
utf8_decode($this->db->f('description')),
+                               'arena'                         => 
$this->db->f('arena'),
+                               'time'                          => 
utf8_decode($this->db->f('time')),
+                               '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)
+               {
+                               //$activity['organization_info']        = 
$this->get_org_info($activity['organization_id']);
+                               //$activity['group_info']                       
= $this->get_group_info($activity['group_id']);
+                               $activity['district_name']              = 
utf8_decode($this->get_district_name($activity['district']));
+                               $activity['category_name']              = 
utf8_decode($this->get_category_name($activity['category']));
+                               $activity['arena_info']                 = 
$this->get_arena_info($activity['arena']);
+                               $activity['contact_person']             = 
$this->get_contact_person($activity['organization_id'],$activity['group_id'],$activity['contact_person_1']);
+               }
+//     _debug_array($activities);
                return $activities;
        }
        
+       function get_contact_person($org_id, $group_id, $cont_pers)
+       {
+               if($group_id && $cont_pers)
+               {
+                       $cont_pers = (int)$cont_pers;
+       //              $this->db->query("SELECT * FROM bb_group_contact WHERE 
id={$cont_pers}", __LINE__, __FILE__);
+                       $this->db->query("SELECT * FROM bb_group_contact WHERE 
id={$cont_pers}", __LINE__, __FILE__);
+                       while($this->db->next_record()){
+                               $result = array('name' => 
utf8_decode($this->db->f('name')),'phone' => $this->db->f('phone'),'email' => 
$this->db->f('email'));
+                       }
+               }
+               else if($org_id && $cont_pers)
+               {
+                       $cont_pers = (int)$cont_pers;
+                       $this->db->query("SELECT * FROM bb_organization_contact 
WHERE id={$cont_pers}", __LINE__, __FILE__);
+                       while($this->db->next_record()){
+                               $result = array('name' => 
utf8_decode($this->db->f('name')),'phone' => $this->db->f('phone'),'email' => 
$this->db->f('email'));
+                       }
+               }
+               return $result;
+       }
+
+       function get_organizations()
+       {
+               $organizations = array();
+               $this->db->query("SELECT * FROM bb_organization WHERE 
show_in_portal=1", __LINE__, __FILE__);
+               while($this->db->next_record())
+               {
+                       $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'              => 
$this->db->f('homepage'),
+                               'phone'                 => 
$this->db->f('phone'),
+                               'email'                 => $this->db->f('email')
+                       );
+               }
+//     _debug_array($organizations);
+               return $organizations;
+       }
+       
+       function get_org_info($org_id)
+       {
+               $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;
+       }
+       
+       function get_groups()
+       {
+               $groups = array();
+               $this->db->query("SELECT * FROM bb_group WHERE 
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')),
+                               'organization_id'       => 
$this->db->f('organization_id')
+                       );
+               }
+//     _debug_array($groups);
+               return $groups;
+       }
+       
+       function get_group_info($group_id)
+       {
+               $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;
+       }
+       
+       function get_arena_info($arena_id)
+       {
+               $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' => 
utf8_decode($this->db->f('arena_name')),
+                               'address' => 
utf8_decode($this->db->f('address'))
+                       );
+               }
+               return $result;
+       }
+       
        function get_statuscodes()
        {
-               $statuscodes[] = array('0' => 'Ingen');
-               $statuscodes[] = array('1' => 'Ny');
-               $statuscodes[] = array('2' => 'Endring');
-               $statuscodes[] = array('3' => 'Akseptert');
-               $statuscodes[] = array('4' => 'Behandlet');
-               $statuscodes[] = array('5' => 'Avvist');
+               $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;
        }
@@ -507,7 +725,7 @@
                while($this->db->next_record()){
                        $targets[] = array(
                                        'id'                            => 
(int) $this->db->f('id'),
-                                       'name'                          => 
$this->db->f('name',true),
+                                       'name'                          => 
utf8_decode($this->db->f('name',true)),
                        );
                }
                return $targets;
@@ -520,10 +738,9 @@
                while($this->db->next_record()){
                        $categories[] = array(
                                        'id'                            => 
(int) $this->db->f('id'),
-                                       'name'                          => 
$this->db->f('name',true),
+                                       'name'                          => 
utf8_decode($this->db->f('name',true)),
                        );
                }
                return $categories;
        }
-       
-}
\ No newline at end of file
+}

Modified: branches/Version-1_0-branch/activitycalendar/inc/class.soarena.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.soarena.inc.php      
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.soarena.inc.php      
2011-05-31 05:59:50 UTC (rev 7333)
@@ -25,8 +25,6 @@
        /**
         * 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
@@ -51,6 +49,7 @@
                        }
                        $order = "ORDER BY 
{$this->marshal($sort_field,'field')} $dir";
                }
+               
                if($search_for)
                {
                        $query = $this->marshal($search_for,'string');
@@ -78,6 +77,7 @@
                        $filter_clauses[] = "arena.id = {$id}";
                }
                
+               //filter on active/non-active
                if(isset($filters['active']))
                {
                        if($filters['active'] == 'active')
@@ -90,6 +90,7 @@
                        } 
                }
                
+               //filter on internal/not internal arena
                if(isset($filters['arena_type']))
                {
                        if($filters['arena_type'] == 'internal')
@@ -137,6 +138,13 @@
                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)
        {
 
@@ -151,6 +159,12 @@
                return $arena;
        }
        
+       /**
+        * Get arena name
+        *
+        * @param int $arena_id
+        * @return string arena name
+        */
        function get_arena_name($arena_id)
        {
                $result = "Ingen";
@@ -165,6 +179,11 @@
                return $result;
        }
        
+       /**
+        * Get registered buildings from property
+        *
+        * @return array buildings, [id => name]
+        */
        function get_buildings()
        {
                $buildings = array();
@@ -178,6 +197,12 @@
                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))
                {

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.socommon.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.socommon.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.socommon.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -314,5 +314,10 @@
                // 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

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php  
    2011-05-31 05:10:21 UTC (rev 7332)
+++ 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php  
    2011-05-31 05:59:50 UTC (rev 7333)
@@ -208,6 +208,30 @@
                return $result;
        }
        
+       function get_mailaddress_for_group_contact($contact_person_id)
+       {
+               if(isset($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;
+       }
+       
+       function get_mailaddress_for_org_contact($contact_person_id)
+       {
+               if(isset($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;
+       }
+       
 
        /**
         * Function for adding a new activity to the database. Updates the 
activity object.

Modified: branches/Version-1_0-branch/activitycalendar/inc/class.sogroup.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.sogroup.inc.php      
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.sogroup.inc.php      
2011-05-31 05:59:50 UTC (rev 7333)
@@ -180,6 +180,18 @@
                
                return $contacts;
        }
+       
+       function get_description($group_id)
+       {
+       if(isset($group_id)){
+               $q1="SELECT description FROM bb_group WHERE id={$group_id}";
+                       $this->db->query($q1, __LINE__, __FILE__);
+                       while($this->db->next_record()){
+                               $desc = $this->db->f('description');
+                       }
+       }
+               return $desc;
+       }
 
        protected function populate(int $group_id, &$group)
        {

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.soorganization.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/inc/class.soorganization.inc.php   
    2011-05-31 05:10:21 UTC (rev 7332)
+++ 
branches/Version-1_0-branch/activitycalendar/inc/class.soorganization.inc.php   
    2011-05-31 05:59:50 UTC (rev 7333)
@@ -160,6 +160,18 @@
        }
                return $contacts;
        }
+       
+       function get_description($organization_id)
+       {
+       if(isset($organization_id)){
+               $q1="SELECT description FROM bb_organization WHERE 
id={$organization_id}";
+                       $this->db->query($q1, __LINE__, __FILE__);
+                       while($this->db->next_record()){
+                               $desc = $this->db->f('description');
+                       }
+       }
+               return $desc;
+       }
 
        /**
         * Function for adding a new party to the database. Updates the party 
object.

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php 
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php 
2011-05-31 05:59:50 UTC (rev 7333)
@@ -18,7 +18,7 @@
                'add'                           => true,
                'edit'                          => true,
                'download'                      => true,
-               'download_export'       => true
+               'send_mail'                     => true
        );
        
        public function __construct()
@@ -114,10 +114,12 @@
                if(isset($g_id) && $g_id > 0)
                {
                        $persons = 
activitycalendar_sogroup::get_instance()->get_contacts($g_id);
+                       $desc = 
activitycalendar_sogroup::get_instance()->get_description($g_id);
                }
                else if(isset($o_id) && $o_id > 0)
                {
                        $persons = 
activitycalendar_soorganization::get_instance()->get_contacts($o_id);
+                       $desc = 
activitycalendar_soorganization::get_instance()->get_description($o_id);
                }
                $arenas = activitycalendar_soarena::get_instance()->get(null, 
null, null, null, null, null, null);
                $organizations = 
activitycalendar_soorganization::get_instance()->get(null, null, null, null, 
null, null, null);
@@ -127,6 +129,9 @@
                {
                        if(isset($activity)) // If an activity object is created
                        {
+                               $old_state = $activity->get_state();
+                               $new_state = phpgw::get_var('state');
+
                                // ... set all parameters
                                $activity->set_title(phpgw::get_var('title'));
                                
$activity->set_organization_id(phpgw::get_var('organization_id'));
@@ -135,11 +140,11 @@
                                $district_array = phpgw::get_var('district');
                                $activity->set_district(implode(",", 
$district_array));
                                $activity->set_office(phpgw::get_var('office'));
-                               $activity->set_state(phpgw::get_var('state'));
+                               $activity->set_state($new_state);
                                
$activity->set_category(phpgw::get_var('category'));
                                $target_array = phpgw::get_var('target');
                                $activity->set_target(implode(",", 
$target_array));
-                               
$activity->set_description(phpgw::get_var('description'));
+                               $activity->set_description($desc);
                                $activity->set_time(phpgw::get_var('time'));
                                $activity->set_contact_persons($persons);
                                
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
@@ -152,6 +157,22 @@
                                {
                                        $error = lang('messages_form_error');
                                }
+
+                               if($new_state == 3 || $new_state == 4 || 
$new_state == 5 )
+                               {
+                                       $kontor = 
activitycalendar_soactivity::get_instance()->get_office_name($activity->get_office());
+                                       $subject = "Melding fra AktivBy";
+                                       $body = lang('mail_body_state_' . 
$new_state, $kontor);
+                                       
+                                       if(isset($g_id) && $g_id > 0)
+                                       {
+                                               
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),$subject,$body);
+                                       }
+                                       else if (isset($o_id) && $o_id > 0)
+                                       {
+                                               
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),$subject,$body);
+                                       }
+                               }
                        }
                }
 
@@ -259,8 +280,109 @@
                                $value['ajax'][] = false;
                                $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'activitycalendar.uiactivities.edit', 'id' => $value['id'])));
                                $value['labels'][] = lang('edit');
+                               $value['ajax'][] = false;
+                               $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'activitycalendar.uiactivities.send_mail', 'activity_id' => 
$value['id'],'message_type' => 'update')));
+                               $value['labels'][] = lang('send_mail');
                                break;
                }
     }
+    
+    public function send_mail()
+    {
+       $activity_id = (int)phpgw::get_var('activity_id');
+       $activity = 
activitycalendar_soactivity::get_instance()->get_single($activity_id);
+       
+       $message_type = phpgw::get_var('message_type');
+       if($message_type)
+       {
+               //$subject = lang('mail_subject_update', $avtivity->get_id() . 
'-' . $activity->get_title(), $activity->get_link());
+               $subject = lang('mail_subject_update');
+               $body = lang('mail_body_update', $activity->get_id() . ', ' . 
$activity->get_title());
+       }
+       else
+       {
+               $subject = "dette er en test";
+               $body = "testmelding fra Aktivitetsoversikt";
+       }
+       
+       //var_dump($subject);
+       //var_dump($body);
+       
+       
+       if($activity->get_group_id())
+       {
+               
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
 $subject, $body);
+       }
+       else if($activity->get_organization_id())
+       {
+               
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
 $subject, $body);
+       }
+       
+    }
+    
+       function send_mailnotification_to_organization($contact_person_id, 
$subject, $body)
+       {
+               
+               //var_dump($contact_person_id . ',' . $subject . ',' . $body);
+               if (!is_object($GLOBALS['phpgw']->send))
+               {
+                       $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+               }
+
+               $config = CreateObject('phpgwapi.config','booking');
+               $config->read();
+               $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+               //$from = "address@hidden";
+
+               if (strlen(trim($body)) == 0) 
+               {
+                       return false;
+               }
+               
+               $mailtoAddress = 
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_org_contact($contact_person_id);
+               //$mailtoAddress = "address@hidden";
+
+               if (strlen($mailtoAddress) > 0) 
+               {
+                       try
+                       {
+                               //var_dump('inne i try');
+                               $GLOBALS['phpgw']->send->msg('email', 
$mailtoAddress, $subject, $body, '', '', '', $from, '', 'plain');
+                       }
+                       catch (phpmailerException $e)
+                       {
+                               //var_dump($e);
+                       }
+               }
+       }
+    
+       function send_mailnotification_to_group($contact_person_id, $subject, 
$body)
+       {
+               $send = CreateObject('phpgwapi.send');
+
+               $config = CreateObject('phpgwapi.config','booking');
+               $config->read();
+               $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+               //$from = "address@hidden";
+
+               if (strlen(trim($body)) == 0) 
+               {
+                       return false;
+               }
+               
+               $mailtoAddress = 
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_group_contact($contact_person_id);
+               //$mailtoaddress = "address@hidden";
+
+               if (strlen($mailtoAddress) > 0) 
+               {
+                       try
+                       {
+                               $send->msg('email', $mailtoAddress, $subject, 
$body, '', '', '', $from, '', 'plain');
+                       }
+                       catch (phpmailerException $e)
+                       {
+                       }
+               }
+       }
 }
 ?>

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uicommon.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uicommon.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uicommon.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -485,5 +485,10 @@
                        return array('table_name', 'fields');
                }
                
+               protected function generate_secret($length = 10)
+               {
+                       return 
substr(base64_encode(rand(1000000000,9999999999)),0, $length);
+               }
+               
        }
 ?>

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -2,6 +2,7 @@
        phpgw::import_class('activitycalendar.uicommon');
        phpgw::import_class('activitycalendar.soarena');
        phpgw::import_class('activitycalendar.soactivity');
+       phpgw::import_class('activitycalendar.soorganization');
        
        include_class('activitycalendar', 'arena', 'inc/model/');
        include_class('activitycalendar', 'activity', 'inc/model/');
@@ -17,8 +18,9 @@
                protected $errors;
                
                // File system path to import folder on server
-               protected $path;
+               protected $file;
                protected $district;
+               protected $csvdata;
                
                // Label on the import button. Changes as we step through the 
import process.
                protected $import_button_label;
@@ -66,7 +68,13 @@
                                // Get the path for user input or use a default 
path
                                $this->path = phpgw::get_var("import_path") ? 
phpgw::get_var("import_path") : '/home/notroot/FacilitExport';
                                $this->office = phpgw::get_var("district") ? 
phpgw::get_var("district") : '1';
-                               phpgwapi_cache::session_set('activitycalendar', 
'import_path', $this->path);
+                               $this->file = $_FILES['file']['tmp_name'];
+                               $this->csvdata = 
$this->getcsvdata($_FILES['file']['tmp_name']);
+                               //var_dump($this->office);
+                               //var_dump($_FILES['file']['name']);
+                               //var_dump($_FILES['file']['tmp_name']);
+                               phpgwapi_cache::session_set('activitycalendar', 
'file', $this->file);
+                               phpgwapi_cache::session_set('activitycalendar', 
'csvdata', $this->csvdata);
                                phpgwapi_cache::session_set('activitycalendar', 
'import_district', $this->office);
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendar.uiimport.index', 'importstep' => 
'true'));
                        } 
@@ -76,7 +84,8 @@
                                $start = date("G:i:s",$start_time);
                                echo "<h3>Import started at: {$start}</h3>";
                                echo "<ul>";
-                               $this->path = 
phpgwapi_cache::session_get('activitycalendar', 'import_path') . '/aktiviteter';
+                               $this->file = 
phpgwapi_cache::session_get('activitycalendar', 'file');
+                               $this->csvdata = 
phpgwapi_cache::session_get('activitycalendar', 'csvdata');
                                $this->office = 
phpgwapi_cache::session_get('activitycalendar', 'import_district');
                                //$this->path = 
'/home/notroot/FacilitExport/aktiviteter';
                                
@@ -182,19 +191,27 @@
                        $soarena = activitycalendar_soarena::get_instance();
                        $soactivity = 
activitycalendar_soactivity::get_instance();
                        
-                       $datalines = $this->getcsvdata($this->path . 
"/import_all.csv");
+                       //var_dump($_FILES['file']['name']);
+                       //var_dump($this->file);
+                       //$datalines = 
$this->getcsvdata($_FILES['file']['tmp_name']);;
+                       $datalines = $this->csvdata;
+                       //$datalines = $this->getcsvdata($this->file);
                        //$activity_district = $this->district;
-                       //var_dump($this->district);
                        
                        $this->messages[] = "Read 'import_all.csv' file in " . 
(time() - $start_time) . " seconds";
                        $this->messages[] = "'importfile.csv' contained " . 
count($datalines) . " lines";
                        
+                       //$so_arena = rental_socontract::get_instance();
+                       $db_activity = $soactivity->get_db();
+                       $db_activity->transaction_begin();
+                       
                        foreach ($datalines as $data) {
-/*                             if(count($data) <= 8)
-                               {
-                                       continue;
-                               }
-*/                             
+                               $arenaOK = true;
+                               $activityOK = true;
+                               unset($act_targets);
+                               unset($activity_persons);
+                               unset($activity_description);
+                               
                                $arena = new activitycalendar_arena();
                                //8: sted, 9:adresse
                                $arena_name = $this->decode($data[7]);
@@ -212,11 +229,12 @@
                                        } else {
                                                $this->errors[] = "Error 
importing arena: Name ({$this->decode($data[7])})";
                                                $curr_arena_id = 0;
+                                               $arenaOK = false;
                                        }
                                }
                                else
                                {
-                                       $this->errors[] = "Error importing 
arena: Name ({$this->decode($data[7])})";
+                                       $this->errors[] = "Error importing 
arena: Name not supplied";
                                        $curr_arena_id = 0;
                                }
                                
@@ -226,6 +244,22 @@
                                if($activity_org)
                                {
                                        $activity_org = 
$soactivity->get_orgid_from_orgno($activity_org);
+                                       if($activity_org)
+                                       {
+                                               
$soactivity->set_org_active($activity_org);
+                                               $activity_description = 
$this->decode($data[5]);
+                                               if($activity_description)
+                                               {
+                                                       //update description on 
organization
+                                                       
$soactivity->update_org_description($activity_org, $activity_description);
+                                                       
//var_dump(strlen($activity_description));
+                                                       
//if(strlen($activity_description) > 255)
+                                                       //{
+                                                               
//$activity_description = substr($activity_description,0,254);
+                                                       //}
+                                               }
+                                               $activity_persons = 
activitycalendar_soorganization::get_instance()->get_contacts($activity_org);
+                                       }
                                }
                                $activity_adapted = $this->decode($data[3]);
                                $activity_category = $this->decode($data[4]);
@@ -233,15 +267,6 @@
                                {
                                        $activity_category = 
$soactivity->get_category_from_name($activity_category);
                                }
-                               $activity_description = $this->decode($data[5]);
-                               if($activity_description)
-                               {
-                                       
//var_dump(strlen($activity_description));
-                                       if(strlen($activity_description) > 255)
-                                       {
-                                               $activity_description = 
substr($activity_description,0,254);
-                                       }
-                               }
                                $activity_target = $this->decode($data[6]);
                                //var_dump($activity_target);
                                if($activity_target)
@@ -253,7 +278,7 @@
                                        }
                                        $activity_target = implode(",", 
$act_targets);
                                }
-                               unset($act_targets);
+
                                $activity_day = $this->decode($data[9]);
                                $activity_time = $this->decode($data[10]);
                                $activity_update_date = 
$this->decode($data[20]);
@@ -266,6 +291,7 @@
                                                $m = $act_update_array[1];
                                                $d = $act_update_array[0];
                                                $activity_updated_date = 
strtotime($y."-".$m."-".$d);
+                                               
//var_dump($activity_updated_date);
                                        }
                                }
                                $activity_district = $this->decode($data[21]);
@@ -289,18 +315,45 @@
                                        $activity->set_office($this->office);
                                        
$activity->set_district($activity_district);
                                        
$activity->set_last_change_date($activity_updated_date);
+                                       if($activity_persons)
+                                       {
+                                               //set contact persons
+                                               
$activity->set_contact_persons($activity_persons);
+                                       }
                                        //var_dump($activity);
                                        // All is good, store activity
-                                       if ($soactivity->store($activity)) {
+                                       if 
($soactivity->import_activity($activity)) {
                                                $this->messages[] = 
"Successfully imported activity: Title ({$this->decode($data[1])})";
                                        } else {
                                                $this->errors[] = "Error 
importing activity: Title ({$this->decode($data[1])})";
+                                               $activityOK = false;
                                        }
                                }
                        }
                        
-                       $this->messages[] = "Imported activities. (" . (time() 
- $start_time) . " seconds)";
-                       return true;
+                       if($arenaOK && $activityOK)
+                       {
+                               $this->messages[] = "Imported activities. (" . 
(time() - $start_time) . " seconds)";
+                               $db_activity->transaction_commit();
+                               return true;
+                       }
+                       else
+                       {
+                               if(!$arenaOK)
+                               {
+                                       $this->messages[] = "Import of arenas 
failed. (" . (time() - $start_time) . " seconds)";
+                               }
+                               else if(!$activityOK)
+                               {
+                                       $this->messages[] = "Import of 
activities failed. (" . (time() - $start_time) . " seconds)";
+                               }
+                               else
+                               {
+                                       $this->messages[] = "Import of 
activities/arenas failed. (" . (time() - $start_time) . " seconds)";
+                               }
+                               $db_activity->transaction_abort();
+                               return false;
+                       }
                }
                
                protected function getcsvdata($path, $skipfirstline = true)
@@ -372,8 +425,8 @@
          * Do end-of-import clean up
          */
         protected function clean_up() {
-            $socontract = rental_socontract::get_instance();
-            $socontract->clear_last_edited_table();
+            //$socontract = rental_socontract::get_instance();
+            //$socontract->clear_last_edited_table();
         }
 
         private function log_messages($step) {

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/model/class.activity.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/inc/model/class.activity.inc.php   
    2011-05-31 05:10:21 UTC (rev 7332)
+++ 
branches/Version-1_0-branch/activitycalendar/inc/model/class.activity.inc.php   
    2011-05-31 05:59:50 UTC (rev 7333)
@@ -202,11 +202,13 @@
                        {
                                $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_1());
                                $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_2());
+                               $desc = 
activitycalendar_soorganization::get_instance()->get_description($this->get_organization_id());
                        }
                        else if(isset($this->group_id) && $this->get_group_id() 
> 0)
                        {
                                $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_1());
                                $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_2());
+                               $desc = 
activitycalendar_sogroup::get_instance()->get_description($this->get_group_id());
                        }
                        else
                        {
@@ -222,7 +224,7 @@
                                'office' => 
activitycalendar_soactivity::get_instance()->get_office_name($this->get_office()),
                                'category' => 
$this->get_so()->get_category_name($this->get_category()),
                                'state' => lang('state_'.$this->get_state()),
-                               'description' => $this->get_description(),
+                               'description' => $desc,
                                'arena' => 
activitycalendar_soarena::get_instance()->get_arena_name($this->get_arena()),
                                'time' => $this->get_time(),
                                'contact_person_1' => $contact_1,

Modified: branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -371,4 +371,10 @@
 state_5        activitycalendar        no      Avvist
 activity_import        activitycalendar        no      Importer aktiviteter
 office activitycalendar        no      Kontor
-activity_helptext      activitycalendar        no      Før ny aktivitet kan 
registreres må du sjekke at organisasjon/gruppe finnes og er oppdatert, og at 
arena finnes og er oppdatert.
\ No newline at end of file
+activity_helptext      activitycalendar        no      Før ny aktivitet kan 
registreres må du sjekke at organisasjon/gruppe finnes og er oppdatert, og at 
arena finnes og er oppdatert.
+mail_subject_update    activitycalendar        no      Melding om oppdatering 
av aktivitet
+mail_body_update       activitycalendar        no      Du må oppdatere 
informasjonen som er registrert på aktivitet %1 . Bruk følgende lenke for å gå 
inn på aktiviteten: %2
+mail_body_state_3      activitycalendar        no      Ditt tips er publisert 
i kommuneportalen. Mvh %1 kulturkontor
+mail_body_state_4      activitycalendar        no      Ditt tips er behandlet 
og publisert i kommuneportalen. Mvh %1 kulturkontor
+mail_body_state_5      activitycalendar        no      Ditt tips er behandlet, 
men vil ikke bli publisert i kommuneportalen. Mvh %1 kulturkontor
+send_mail      activitycalendar        no      Send e-post
\ No newline at end of file

Modified: branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['activitycalendar']['name'] = 'activitycalendar';
-       $setup_info['activitycalendar']['version'] = '0.1.2';
+       $setup_info['activitycalendar']['version'] = '0.1.3';
        $setup_info['activitycalendar']['app_order'] = 60;
        $setup_info['activitycalendar']['enable'] = 1;
        $setup_info['activitycalendar']['app_group']    = 'office';

Modified: 
branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php   
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php   
2011-05-31 05:59:50 UTC (rev 7333)
@@ -18,6 +18,7 @@
                                'last_change_date' => array('type' => 'int', 
'precision' => 4, 'precision' => '8', 'nullable' => true),
                                'contact_person_1' => array('type' => 
'varchar','precision' => '255'),
                                'contact_person_2' => array('type' => 
'varchar','precision' => '255'),
+                               'secret' => array('type' => 'text','nullable' 
=> False),
                                'special_adaptation' => array('type' => 
'bool','nullable' => true,'default' => 'false')
                        ),
                        'pk' => array('id'),
@@ -31,7 +32,7 @@
                                'internal_arena_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
                                'arena_name' => array('type' => 
'varchar','precision' => '255','nullable' => false),
                                'address' => array('type' => 
'varchar','precision' => '255','nullable' => True),
-                               'active' => array('type' => 'bool','nullable' 
=> true,'default' => True)
+                               'active' => array('type' => 'bool','nullable' 
=> true,'default' => 'true')
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: 
branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -27,4 +27,18 @@
                $GLOBALS['setup_info']['activitycalendar']['currentver'] = 
'0.1.2';
                return $GLOBALS['setup_info']['activitycalendar']['currentver'];
        }
+       
+       $test[] = '0.1.2';
+       function activitycalendar_upgrade0_1_2()
+       {
+               $def_val = substr(base64_encode(rand(1000000000,9999999999)),0, 
10);
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('activity_activity','secret',array(
+                       'type' => 'text',
+                       'default' => $def_val,
+                       'nullable' => 'False'
+               ));
+               
+               $GLOBALS['setup_info']['activitycalendar']['currentver'] = 
'0.1.3';
+               return $GLOBALS['setup_info']['activitycalendar']['currentver'];
+       }
 ?>
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -279,23 +279,12 @@
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_description() 
|| $editable) { ?>
+                                       <?php if($activity->get_description()) 
{ ?>
                                        <label for="description"><?php echo 
lang('description') ?></label>
                                        <?php  } ?>
                                </dt>
                                <dd>
-                                       <?php
-                                       if ($editable)
-                                       {
-                                       ?>
-                                               <textarea cols="100" rows="5" 
name="description" id="description"><?php echo $activity->get_description() 
?></textarea>
-                                       <?php
-                                       }
-                                       else
-                                       {
-                                               echo 
$activity->get_description();
-                                       }
-                                       ?>
+                                       <?php echo 
$activity->get_description(); ?>
                                </dd>
                                <dt>
                                        <?php if($activity->get_time() || 
$editable) { ?>

Modified: 
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php 
    2011-05-31 05:10:21 UTC (rev 7332)
+++ 
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php 
    2011-05-31 05:59:50 UTC (rev 7333)
@@ -11,9 +11,9 @@
 
 <div id="messageHolder"></div>
 
-<form action="index.php?menuaction=activitycalendar.uiimport.index" 
method="post">
+<form action="index.php?menuaction=activitycalendar.uiimport.index" 
method="post" enctype="multipart/form-data">
        <fieldset>
-               <label for="path">Path to activities file:</label> <input 
type="text" name="import_path" id="import_path" value="<?php echo $import_path 
?>" size="60"/>
+               <label for="file">Choose activities file:</label> <input 
type="file" name="file" id="file" />
                <label for="district">Location for the imported 
activities:</label>
                <select name="district" id="district">
                        <?php

Modified: 
branches/Version-1_0-branch/booking/inc/class.uiaccount_code_dimension.inc.php
===================================================================
--- 
branches/Version-1_0-branch/booking/inc/class.uiaccount_code_dimension.inc.php  
    2011-05-31 05:10:21 UTC (rev 7332)
+++ 
branches/Version-1_0-branch/booking/inc/class.uiaccount_code_dimension.inc.php  
    2011-05-31 05:59:50 UTC (rev 7333)
@@ -34,7 +34,6 @@
                                }
                                $config->save_repository();
                        }
-                       //echo '<pre>'; print_r($config->config_data); exit;
                        
                        self::render_template('account_code_dimension', 
array('config_data' =>$config->config_data));
                }

Modified: branches/Version-1_0-branch/booking/inc/class.uireports.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.uireports.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/booking/inc/class.uireports.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -146,13 +146,13 @@
                $sql = "select distinct al.id, al.from_, al.to_, EXTRACT(DOW 
FROM al.to_) as day_of_week, bu.id as building_id, bu.name as building_name, 
br.id as resource_id, br.name as resource_name
                                from bb_allocation al
                                inner join bb_allocation_resource ar on 
ar.allocation_id = al.id
-                               inner join bb_resource br on br.id = 
ar.resource_id
+                               inner join bb_resource br on br.id = 
ar.resource_id and br.active = 1
                                inner join bb_building bu on bu.id = 
br.building_id
                                left join bb_booking bb on bb.allocation_id = 
al.id
                                where bb.id is null 
                                and al.from_ >= '".$from." 00:00:00'
                                and al.to_ <= '".$to." 23:59:59' ";
-               
+
                if ($buildings)
                        $sql .= "and building_id in (".$buildings.") ";
 

Modified: 
branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mssql.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mssql.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mssql.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -109,14 +109,24 @@
 
                function TranslateDefault($sDefault)
                {
-                       switch ($sDefault)
+                       // Need Strict comparisons for true/false in case of 
datatype bolean
+                       if ($sDefault === true || $sDefault === 'true' || 
$sDefault === 'True')
                        {
-                               case 'current_date':
-                               case 'current_timestamp':
-                               return "GetDate()";
+                               $ret= 1;
                        }
-
-                       return "'" . $sDefault . "'";
+                       else if ($sDefault === false || $sDefault === 'false' 
|| $sDefault === 'False')
+                       {
+                               $ret= 0;
+                       }
+                       else if ($sDefault == 'current_date' || $sDefault == 
'current_timestamp')
+                       {
+                               $ret= 'GetDate()';
+                       }
+                       else
+                       {
+                               $ret= "'" . $sDefault . "'";                    
+                       }
+                       return $ret;
                }
 
                // Inverse of above, convert sql column types to array info

Modified: 
branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mysql.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mysql.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_mysql.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -139,21 +139,25 @@
 
                function TranslateDefault($sDefault)
                {
-                       switch ($sDefault)
+
+                       // Need Strict comparisons for true/false in case of 
datatype bolean
+                       if ($sDefault === true || $sDefault === 'true' || 
$sDefault === 'True')
                        {
-                               case 'current_date':
-                               case 'current_timestamp':
-                                       return 'now()';
-                                       break;
-                               case 'true':
-                               case 'True':
-                                       return 1;
-                                       break;
-                               case 'false':
-                               case 'False':
-                                       return 0;
+                               $ret= 1;
                        }
-                       return "'" . $sDefault . "'";
+                       else if ($sDefault === false || $sDefault === 'false' 
|| $sDefault === 'False')
+                       {
+                               $ret= 0;
+                       }
+                       else if ($sDefault == 'current_date' || $sDefault == 
'current_timestamp')
+                       {
+                               $ret= 'now()';
+                       }
+                       else
+                       {
+                               $ret= "'" . $sDefault . "'";                    
+                       }
+                       return $ret;
                }
 
                /* Inverse of above, convert sql column types to array info */

Modified: 
branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_oracle.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_oracle.inc.php   
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_oracle.inc.php   
2011-05-31 05:59:50 UTC (rev 7333)
@@ -83,14 +83,28 @@
 
                function TranslateDefault($sDefault)
                {
-                       switch ($sDefault)
+                       // Need Strict comparisons for true/false in case of 
datatype bolean
+                       if ($sDefault === true || $sDefault === 'true' || 
$sDefault === 'True')
                        {
-                               case 'current_date':
-                                       return "sysdate";
-                               case 'current_timestamp':
-                                       return "systimestamp";
+                               $ret= 1;
                        }
-                       return "'" . $sDefault . "'";
+                       else if ($sDefault === false || $sDefault === 'false' 
|| $sDefault === 'False')
+                       {
+                               $ret= 0;
+                       }
+                       else if ($sDefault == 'current_date')
+                       {
+                               $ret= 'sysdate';
+                       }
+                       else if ($sDefault == 'current_timestamp')
+                       {
+                               $ret= 'systimestamp';
+                       }               
+                       else
+                       {
+                               $ret= "'" . $sDefault . "'";                    
+                       }
+                       return $ret;
                }
 
                /* Inverse of above, convert sql column types to array info */

Modified: 
branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -112,13 +112,24 @@
 
                function TranslateDefault($sDefault)
                {
-                       switch ($sDefault)
+                       // Need Strict comparisons for true/false in case of 
datatype bolean
+                       if ($sDefault === true || $sDefault === 'true' || 
$sDefault === 'True')
                        {
-                               case 'current_date':
-                               case 'current_timestamp':
-                                       return "now()";
+                               $ret= 'True';
                        }
-                       return "'" . $sDefault . "'";
+                       else if ($sDefault === false || $sDefault === 'false' 
|| $sDefault === 'False')
+                       {
+                               $ret= 'False';
+                       }
+                       else if ($sDefault == 'current_date' || $sDefault == 
'current_timestamp')
+                       {
+                               $ret= "now()";
+                       }
+                       else
+                       {
+                               $ret= "'" . $sDefault . "'";                    
+                       }
+                       return $ret;
                }
 
                /* Inverse of above, convert sql column types to array info */

Modified: 
branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_sapdb.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_sapdb.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc_sapdb.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -146,13 +146,24 @@
                 */
                function TranslateDefault($sDefault)
                {
-                       switch ($sDefault)
+                       // Need Strict comparisons for true/false in case of 
datatype bolean
+                       if ($sDefault === true || $sDefault === 'true' || 
$sDefault === 'True')
                        {
-                               case 'current_date':
-                               case 'current_timestamp':
-                                       return 'TIMESTAMP';
+                               $ret= 1;
                        }
-                       return "'" . $sDefault . "'";
+                       else if ($sDefault === false || $sDefault === 'false' 
|| $sDefault === 'False')
+                       {
+                               $ret= 0;
+                       }
+                       else if ($sDefault == 'current_date' || $sDefault == 
'current_timestamp')
+                       {
+                               $ret= 'TIMESTAMP';
+                       }
+                       else
+                       {
+                               $ret= "'" . $sDefault . "'";                    
+                       }
+                       return $ret;
                }
 
                /**

Modified: branches/Version-1_0-branch/phpgwapi/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/phpgwapi/setup/phpgw_no.lang    2011-05-31 
05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/setup/phpgw_no.lang    2011-05-31 
05:59:50 UTC (rev 7333)
@@ -50,6 +50,7 @@
 group public   common  no      Gruppe Public
 groups common  no      Grupper
 help   common  no      Hjelp
+manual common  no      Veiledning lag og organisasjoner
 high   common  no      Høy
 home   common  no      Hjemme
 it has been more then %1 days since you changed your password  common  no      
Det er mer enn %1 dager siden du har endet ditt passord

Modified: 
branches/Version-1_0-branch/phpgwapi/templates/bkbooking/css/frontend.css
===================================================================
--- branches/Version-1_0-branch/phpgwapi/templates/bkbooking/css/frontend.css   
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/templates/bkbooking/css/frontend.css   
2011-05-31 05:59:50 UTC (rev 7333)
@@ -276,6 +276,7 @@
        border: none !important;
 }
 
+/* CSS for newlayout */
 body{
 color: #575757;
 margin:0;
@@ -327,7 +328,7 @@
 height: 108px !important;
 background: url(../images/newlayout/aktivby_logo.jpg) no-repeat !important;
 background-position: bottom center !important;
-padding: 22px 0px 0px 150px !important;
+padding: 22px 0px 0px 400px !important;
 }
 
 #header-search{

Modified: branches/Version-1_0-branch/phpgwapi/templates/bkbooking/head.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/templates/bkbooking/head.inc.php       
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/phpgwapi/templates/bkbooking/head.inc.php       
2011-05-31 05:59:50 UTC (rev 7333)
@@ -117,10 +117,10 @@
        $app = lang($app);
        $tpl_vars = array
        (
-               'manual_text'   => lang('manual'),
-               'manual_url'    => 'logout.php',
-               'help_text'     => lang('help'),
-               'help_url'              => 'logout.php',
+#              'manual_text'   => lang('manual'),
+#              'manual_url'    => '#',
+#              'help_text'     => lang('help'),
+#              'help_url'              => '#',
                'css'                   => $GLOBALS['phpgw']->common->get_css(),
                'javascript'    => $GLOBALS['phpgw']->common->get_javascript(),
                'img_icon'      => 
$GLOBALS['phpgw']->common->find_image('phpgwapi', 'favicon.ico'),

Deleted: 
branches/Version-1_0-branch/phpgwapi/templates/bkbooking/images/newlayout/Thumbs.db
===================================================================
(Binary files differ)

Modified: branches/Version-1_0-branch/property/inc/class.uientity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -1641,10 +1641,11 @@
                                }
  */
                        }
+// ---- START INTEGRATION -------------------------
 
                        $custom_config  = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
 $this->acl_location));
-                       $_integration_config = 
isset($custom_config->config_data['integration']) ? 
$custom_config->config_data['integration'] : array();
-
+                       $_config = isset($custom_config->config_data) && 
$custom_config->config_data ? $custom_config->config_data : array();
+//_debug_array($custom_config->config_data);die();
                        // required settings:
 /*
                        integration_tab
@@ -1659,20 +1660,24 @@
                        integration_auth_hash_value
                        integration_location_data
  */
-
-
-                       $integration = '';
-                       if(isset($_integration_config['tab']) && $values['id'])
+                       $integration = array();
+                       foreach ($_config as $_config_section => 
$_config_section_data)
                        {
+                               if(isset($_config_section_data['tab']) && 
$values['id'])
+                               {
+                                       if(!isset($_config_section_data['url']))
+                                       {
+                                               
phpgwapi_cache::message_set("'url' is a required setting for integrations, 
'{$_config_section}' is disabled", 'error');
+                                               break;
+                                       }
 
-                               //get session key from remote system
+                                       //get session key from remote system
+                                       $arguments = 
array($_config_section_data['auth_hash_name'] => 
$_config_section_data['auth_hash_value']);
+                                       $query = http_build_query($arguments);
+                                       $auth_url = 
$_config_section_data['auth_url'];
+                                       $request = "{$auth_url}?{$query}";
 
-                               $arguments = 
array($_integration_config['auth_hash_name'] => 
$_integration_config['auth_hash_value']);
-                               $query = http_build_query($arguments);
-                               $auth_url = $_integration_config['auth_url'];
-                               $request = "{$auth_url}?{$query}";
-
-                               $aContext = array
+                                       $aContext = array
                                        (
                                                'http' => array
                                                (
@@ -1680,88 +1685,91 @@
                                                ),
                                        );
 
-                               
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
-                               {
-                                       $aContext['http']['proxy'] = 
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
-                               }
+                                       
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
+                                       {
+                                               $aContext['http']['proxy'] = 
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
+                                       }
 
+                                       $cxContext = 
stream_context_create($aContext);
+                                       $response = 
trim(file_get_contents($request, False, $cxContext));
 
-                               $cxContext = stream_context_create($aContext);
-                               $response = trim(file_get_contents($request, 
False, $cxContext));
+                                       $integration[]  = array('section' => 
$_config_section);
+                                       $_config_section_data['url']            
= htmlspecialchars_decode($_config_section_data['url']);
+                                       $_config_section_data['parametres']     
= htmlspecialchars_decode($_config_section_data['parametres']);
 
-                               $integration    = true;
-                               $_integration_config['url']             = 
htmlspecialchars_decode($_integration_config['url']);
-                               $_integration_config['parametres']      = 
htmlspecialchars_decode($_integration_config['parametres']);
+                                       
parse_str($_config_section_data['parametres'], $output);
 
-                               parse_str($_integration_config['parametres'], 
$output);
-
-                               foreach ($output as $_dummy => $_substitute)
-                               {
-                                       $_keys[] = $_substitute;
-
-                                       $__value = false;
-                                       if(!$__value = 
urlencode($values[trim($_substitute, '_')]))
+                                       foreach ($output as $_dummy => 
$_substitute)
                                        {
-                                               foreach ($values['attributes'] 
as $_attribute)
+                                               $_keys[] = $_substitute;
+       
+                                               $__value = false;
+                                               if(!$__value = 
urlencode($values[trim($_substitute, '_')]))
                                                {
-                                                       if(trim($_substitute, 
'_') == $_attribute['name'])
+                                                       foreach 
($values['attributes'] as $_attribute)
                                                        {
-                                                               $__value = 
urlencode($_attribute['value']);
-                                                               break;
+                                                               
if(trim($_substitute, '_') == $_attribute['name'])
+                                                               {
+                                                                       
$__value = urlencode($_attribute['value']);
+                                                                       break;
+                                                               }
                                                        }
                                                }
-                                       }
 
-                                       if($__value)
-                                       {
-                                               $_values[] = $__value;
+                                               if($__value)
+                                               {
+                                                       $_values[] = $__value;
+                                               }
                                        }
-                               }
 
-                               
//_debug_array($_integration_config['parametres']);
-                               //_debug_array($_values);
-                               unset($output);
-                               unset($__value);
-                               $_sep = '?';
-                               if (stripos($_integration_config['url'],'?'))
-                               {
-                                       $_sep = '&';
-                               }
-                               $_param = str_replace($_keys, $_values, 
$_integration_config['parametres']);
-                               unset($_keys);
-                               unset($_values);
-                               //                              
$integration_src = 
phpgw::safe_redirect("{$_integration_config['url']}{$_sep}{$_param}");
-                               $integration_src = 
"{$_integration_config['url']}{$_sep}{$_param}";
-                               if($_integration_config['action'])
-                               {
+                                       
//_debug_array($_config_section_data['parametres']);
+                                       //_debug_array($_values);
+                                       unset($output);
+                                       unset($__value);
                                        $_sep = '?';
-                                       if (stripos($integration_src,'?'))
+                                       if 
(stripos($_config_section_data['url'],'?'))
                                        {
                                                $_sep = '&';
                                        }
-                                       $integration_src .= 
"{$_sep}{$_integration_config['action']}=" . 
$_integration_config["action_{$mode}"];
-                               }
+                                       $_param = str_replace($_keys, $_values, 
$_config_section_data['parametres']);
+                                       unset($_keys);
+                                       unset($_values);
+       //                              $integration_src = 
phpgw::safe_redirect("{$_config_section_data['url']}{$_sep}{$_param}");
+                                       $integration_src = 
"{$_config_section_data['url']}{$_sep}{$_param}";
+                                       if($_config_section_data['action'])
+                                       {
+                                               $_sep = '?';
+                                               if 
(stripos($integration_src,'?'))
+                                               {
+                                                       $_sep = '&';
+                                               }
+                                               $integration_src .= 
"{$_sep}{$_config_section_data['action']}=" . 
$_config_section_data["action_{$mode}"];
+                                       }
 
-                               $arguments = 
array($_integration_config['auth_key_name'] => $response);
+                                       $arguments = 
array($_config_section_data['auth_key_name'] => $response);
 
-                               if(isset($_integration_config['location_data']) 
&& $_integration_config['location_data'])
-                               {
-                                       $_integration_config['location_data']   
= htmlspecialchars_decode($_integration_config['location_data']);
-                                       
parse_str($_integration_config['location_data'], $output);
-                                       foreach ($output as $_dummy => 
$_substitute)
+                                       
if(isset($_config_section_data['location_data']) && 
$_config_section_data['location_data'])
                                        {
-                                               $_keys[] = $_substitute;
-                                               $_values[] = 
urlencode($values['location_data'][trim($_substitute, '_')]);
+                                               
$_config_section_data['location_data']  = 
htmlspecialchars_decode($_config_section_data['location_data']);
+                                               
parse_str($_config_section_data['location_data'], $output);
+                                               foreach ($output as $_dummy => 
$_substitute)
+                                               {
+                                                       $_keys[] = $_substitute;
+                                                       $_values[] = 
urlencode($values['location_data'][trim($_substitute, '_')]);
+                                               }
+                                               $integration_src .= '&' . 
str_replace($_keys, $_values, $_config_section_data['location_data']);
                                        }
-                                       $integration_src .= '&' . 
str_replace($_keys, $_values, $_integration_config['location_data']);
+
+                                       $integration_src .= 
"&{$_config_section_data['auth_key_name']}={$response}";
+                                       //_debug_array($values);
+                                       //_debug_array($integration_src);die();
+                                       $tabs[$_config_section] = array('label' 
=> $_config_section_data['tab'], 'link' => "#{$_config_section}", 'function' => 
"document.getElementById('{$_config_section}_content').src = 
'{$integration_src}';");
                                }
+                       }
 
-                               $integration_src .= 
"&{$_integration_config['auth_key_name']}={$response}";
-                               //_debug_array($values);
-                               //_debug_array($integration_src);die();
-                               $tabs['integration']    = array('label' => 
$_integration_config['tab'], 'link' => '#integration', 'function' => 
"document.getElementById('integration_content').src = '{$integration_src}';");
+// ---- END INTEGRATION -------------------------
 
-                       }
+
                        unset($values['attributes']);
                        $link_file_data = array
                                (
@@ -1976,7 +1984,7 @@
                                        'textarearows'                          
        => 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 6,
                                        'tabs'                                  
                => phpgwapi_yui::tabview_generate($tabs, $active_tab),
                                        'integration'                           
        => $integration,
-                                       'value_integration_src'                 
=> $integration_src,
+                               //      'value_integration_src'                 
=> $integration_src,
                                        'base_java_url'                         
        =>      "{menuaction:'property.uientity.get_files',".
                                                                                
                                "id:'{$id}',".
                                                                                
                                "entity_id:'{$this->entity_id}',".

Modified: branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-05-31 05:59:50 UTC (rev 7333)
@@ -231,87 +231,96 @@
                        $datatable = array();
                        $values_combo_box = array();
 
-                       $integrationurl = '';
                        $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
                        $custom_config  = 
CreateObject('admin.soconfig',$location_id);
-                       $_integration_config = 
isset($custom_config->config_data['integration']) ? 
$custom_config->config_data['integration'] : array();
+                       $_config = isset($custom_config->config_data) && 
$custom_config->config_data ? $custom_config->config_data : array();
 
-                       if(isset($_integration_config['url']))
+                       $_integration_set = array();
+                       foreach ($_config as $_config_section => 
$_config_section_data)
                        {
-                               
if(isset($_integration_config['auth_hash_name']) && 
$_integration_config['auth_hash_name'] && 
isset($_integration_config['auth_url']) && $_integration_config['auth_url'])
+                               $integrationurl = '';
+                               if(isset($_config_section_data['url']))
                                {
-                                       //get session key from remote system
+                                       
if(isset($_config_section_data['auth_hash_name']) && 
$_config_section_data['auth_hash_name'] && 
isset($_config_section_data['auth_url']) && $_config_section_data['auth_url'])
+                                       {
+                                               //get session key from remote 
system
 
-                                       $arguments = 
array($_integration_config['auth_hash_name'] => 
$_integration_config['auth_hash_value']);
-                                       $query = http_build_query($arguments);
-                                       $auth_url = 
$_integration_config['auth_url'];
-                                       $request = "{$auth_url}?{$query}";
+                                               $arguments = 
array($_config_section_data['auth_hash_name'] => 
$_config_section_data['auth_hash_value']);
+                                               $query = 
http_build_query($arguments);
+                                               $auth_url = 
$_config_section_data['auth_url'];
+                                               $request = 
"{$auth_url}?{$query}";
 
-                                       $aContext = array
-                                               (
-                                                       'http' => array
+                                               $aContext = array
                                                        (
-                                                               
'request_fulluri' => true,
-                                                       ),
-                                               );
+                                                               'http' => array
+                                                               (
+                                                                       
'request_fulluri' => true,
+                                                               ),
+                                                       );
 
-                                       
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
-                                       {
-                                               $aContext['http']['proxy'] = 
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
+                                               
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
+                                               {
+                                                       
$aContext['http']['proxy'] = 
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
+                                               }
+
+                                               $cxContext = 
stream_context_create($aContext);
+                                               $response = 
trim(file_get_contents($request, False, $cxContext));
                                        }
 
 
-                                       $cxContext = 
stream_context_create($aContext);
-                                       $response = 
trim(file_get_contents($request, False, $cxContext));
-                               }
+                                       $_config_section_data['url']            
= htmlspecialchars_decode($_config_section_data['url']);
+                                       $_config_section_data['parametres']= 
htmlspecialchars_decode($_config_section_data['parametres']);
+                                       $integration_name = 
isset($_config_section_data['name']) && $_config_section_data['name'] ? 
$_config_section_data['name'] : lang('integration');
 
+                                       
parse_str($_config_section_data['parametres'], $output);
 
-                               $_integration_config['url']             = 
htmlspecialchars_decode($_integration_config['url']);
-                               $_integration_config['parametres']= 
htmlspecialchars_decode($_integration_config['parametres']);
-                               $integration_name = 
isset($_integration_config['name']) && $_integration_config['name'] ? 
$_integration_config['name'] : lang('integration');
+                                       foreach ($output as $_dummy => 
$_substitute)
+                                       {
+                                               $_keys[] = $_substitute;
+                                               $__substitute = 
trim($_substitute, '_');
+                                               $_values[] = 
$this->$__substitute;
+                                       }
+                                       unset($output);
 
-                               parse_str($_integration_config['parametres'], 
$output);
+                                       $_sep = '?';
+                                       if 
(stripos($_config_section_data['url'],'?'))
+                                       {
+                                               $_sep = '&';
+                                       }
+                                       $_param = str_replace($_keys, $_values, 
$_config_section_data['parametres']);
 
-                               foreach ($output as $_dummy => $_substitute)
-                               {
-                                       $_keys[] = $_substitute;
-                                       $__substitute = trim($_substitute, '_');
-                                       $_values[] = $this->$__substitute;
-                               }
-                               unset($output);
+                                       $integrationurl = 
"{$_config_section_data['url']}{$_sep}{$_param}";
+                                       $integrationurl .= 
"&{$_config_section_data['auth_key_name']}={$response}";
 
-                               $_sep = '?';
-                               if (stripos($_integration_config['url'],'?'))
-                               {
-                                       $_sep = '&';
-                               }
-                               $_param = str_replace($_keys, $_values, 
$_integration_config['parametres']);
+                                       $_config_section_data['location_data']= 
htmlspecialchars_decode($_config_section_data['location_data']);
 
-                               $integrationurl = 
"{$_integration_config['url']}{$_sep}{$_param}";
-                               $integrationurl .= 
"&{$_integration_config['auth_key_name']}={$response}";
+                                       $parameters_integration = array();
+                                       
if($_config_section_data['location_data'])
+                                       {
+                                               
parse_str($_config_section_data['location_data'], $output);
 
-                               $_integration_config['location_data']= 
htmlspecialchars_decode($_integration_config['location_data']);
-
-                               $parameters_integration = array();
-                               if($_integration_config['location_data'])
-                               {
-                                       
parse_str($_integration_config['location_data'], $output);
-
-                                       foreach ($output as $_name => 
$_substitute)
-                                       {
-                                               if($_substitute == '__loc1__') 
// This one is a link...
+                                               foreach ($output as $_name => 
$_substitute)
                                                {
-                                                       $_substitute = 
'__location_code__';
-                                               }
+                                                       if($_substitute == 
'__loc1__') // This one is a link...
+                                                       {
+                                                               $_substitute = 
'__location_code__';
+                                                       }
 
-                                               
$parameters_integration['parameter'][] = array
+                                                       
$parameters_integration['parameter'][] = array
                                                        (
                                                                'name'          
=> $_name,
                                                                'source'        
=> trim($_substitute, '_'),
                                                        );
+                                               }
                                        }
+                                       
+                                       $_integration_set[] = array
+                                       (
+                                               'name'                  => 
$integration_name,
+                                               'parameters'    => 
$parameters_integration,
+                                               'url'                   => 
$integrationurl
+                                       );
                                }
-
                        }
 
                        if( phpgw::get_var('phpgw_return_as') != 'json' )
@@ -494,18 +503,42 @@
                                        )
                                );
 
-                               if($integrationurl)
+                               $button_def[] = "oNormalButton_0";
+                               $button_def[] = "oNormalButton_1";
+                               $button_def[] = "oNormalButton_2";
+                               $code_inner[] = "{order:0, 
name:'btn_search',funct:'onSearchClick'}";
+                               $code_inner[] = "{order:1, name:'btn_new',      
funct:'onNewClick'}";
+                               $code_inner[] = "{order:2, 
name:'btn_export',funct:'onDownloadClick'}";
+                               $_js_functions = '';
+
+                               foreach ($_integration_set as $i => 
$_integration)
                                {       
+
+                                       $button_def[] = 'oNormalButton_' . ($i 
+ 3); 
+                                       $code_inner[] = "{order:" . ($i + 3)  
.", name:'btn_integration_{$i}',funct:'onIntegrationClick_{$i}'}";
+
                                        
$datatable['actions']['form'][0]['fields']['field'][] =  array
-                                               (
-                                                       'type'  => 'button',
-                                                       'id'    => 
'btn_integration',
-                                                       'value' => 
$integration_name,
-                                                       'tab_index' => 10
-                                               );
+                                       (
+                                               'type'  => 'button',
+                                               'id'    => 
"btn_integration_{$i}",
+                                               'value' => 
$_integration['name'],
+                                               'tab_index' => 10 + $i
+                                       );
+
+                                       $_js_functions .= <<<JS
+                                               this.onIntegrationClick_{$i} = 
function()
+                                               {
+                                                       
window.open(values_ds.integrationurl_{$i},'window');
+                                               }
+JS;
                                }
 
+                               $code = 'var ' . implode(',', $button_def)  . 
";\n";
+                               $code .= 'var normalButtons = [' . "\n" . 
implode(",\n",$code_inner) . "\n];";
+                               $code .= $_js_functions;
 
+                               $GLOBALS['phpgw']->js->add_code('', $code);
+
                                if(!$block_query)
                                {       
                                        
$datatable['actions']['form'][0]['fields']['field'][] =  array
@@ -756,16 +789,15 @@
                                                );
                                }
 
-
-                               if($integrationurl)
-                               {       
+                               foreach ($_integration_set as $_integration )
+                               {
                                        $datatable['rowactions']['action'][] = 
array
-                                               (
-                                                       'my_name'               
=> 'integration',
-                                                       'text'                  
=> $integration_name,
-                                                       'action'                
=> $integrationurl.'&target=_blank',
-                                                       'parameters'    => 
$parameters_integration
-                                               );
+                                       (
+                                               'my_name'               => 
'integration',
+                                               'text'                  => 
$_integration['name'],
+                                               'action'                => 
$_integration['url'].'&target=_blank',
+                                               'parameters'    => 
$_integration['parameters']
+                                       );
                                }
 
                                if($this->acl_delete)
@@ -954,7 +986,10 @@
                                        'records'                       => 
array()
                                );
 
-                       $json['integrationurl'] = $integrationurl;
+                               foreach ($_integration_set as $i => 
$_integration)
+                               {       
+                                       $json["integrationurl_{$i}"]    = 
$_integration['url'];
+                               }
 
                        // values for datatable
                        if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
@@ -1536,7 +1571,6 @@
                                        'headers'                       => 
$uicols
                                );
 
-                       $json['integrationurl'] = $integrationurl;
 
                        // values for datatable
                        if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
@@ -2214,11 +2248,140 @@
                                                }
                                        }
                                }
+
+
+// ---- START INTEGRATION -------------------------
+
+                               $custom_config  = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property', 
$this->acl_location));
+                               $_config = isset($custom_config->config_data) 
&& $custom_config->config_data ? $custom_config->config_data : array();
+//_debug_array($custom_config->config_data);die();
+                       // required settings:
+/*
+                               integration_tab
+                               integration_url
+                               integration_parametres
+                               integration_action
+                               integration_action_view
+                               integration_action_edit
+                               integration_auth_key_name
+                               integration_auth_url
+                               integration_auth_hash_name
+                               integration_auth_hash_value
+                               integration_location_data
+ */
+                               $integration = array();
+                               foreach ($_config as $_config_section => 
$_config_section_data)
+                               {
+                                       if(isset($_config_section_data['tab']))
+                                       {
+                                               
if(!isset($_config_section_data['url']))
+                                               {
+                                                       
phpgwapi_cache::message_set("'url' is a required setting for integrations, 
'{$_config_section}' is disabled", 'error');
+                                                       break;
+                                               }
+
+                                               //get session key from remote 
system
+                                               $arguments = 
array($_config_section_data['auth_hash_name'] => 
$_config_section_data['auth_hash_value']);
+                                               $query = 
http_build_query($arguments);
+                                               $auth_url = 
$_config_section_data['auth_url'];
+                                               $request = 
"{$auth_url}?{$query}";
+
+                                               $aContext = array
+                                               (
+                                                       'http' => array
+                                                       (
+                                                               
'request_fulluri' => true,
+                                                       ),
+                                               );
+       
+                                               
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
+                                               {
+                                                       
$aContext['http']['proxy'] = 
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
+                                               }
+       
+                                               $cxContext = 
stream_context_create($aContext);
+                                               $response = 
trim(file_get_contents($request, False, $cxContext));
+
+                                               $integration[]  = 
array('section' => $_config_section);
+                                               $_config_section_data['url']    
        = htmlspecialchars_decode($_config_section_data['url']);
+                                               
$_config_section_data['parametres']     = 
htmlspecialchars_decode($_config_section_data['parametres']);
+
+                                               
parse_str($_config_section_data['parametres'], $output);
+
+                                               foreach ($output as $_dummy => 
$_substitute)
+                                               {
+                                                       $_keys[] = $_substitute;
+       
+                                                       $__value = false;
+                                                       if(!$__value = 
urlencode($values[trim($_substitute, '_')]))
+                                                       {
+                                                               foreach 
($values['attributes'] as $_attribute)
+                                                               {
+                                                                       
if(trim($_substitute, '_') == $_attribute['name'])
+                                                                       {
+                                                                               
$__value = urlencode($_attribute['value']);
+                                                                               
break;
+                                                                       }
+                                                               }
+                                                       }
+
+                                                       if($__value)
+                                                       {
+                                                               $_values[] = 
$__value;
+                                                       }
+                                               }
+
+                                               
//_debug_array($_config_section_data['parametres']);
+                                               //_debug_array($_values);
+                                               unset($output);
+                                               unset($__value);
+                                               $_sep = '?';
+                                               if 
(stripos($_config_section_data['url'],'?'))
+                                               {
+                                                       $_sep = '&';
+                                               }
+                                               $_param = str_replace($_keys, 
$_values, $_config_section_data['parametres']);
+                                               unset($_keys);
+                                               unset($_values);
+               //                              $integration_src = 
phpgw::safe_redirect("{$_config_section_data['url']}{$_sep}{$_param}");
+                                               $integration_src = 
"{$_config_section_data['url']}{$_sep}{$_param}";
+                                               
if($_config_section_data['action'])
+                                               {
+                                                       $_sep = '?';
+                                                       if 
(stripos($integration_src,'?'))
+                                                       {
+                                                               $_sep = '&';
+                                                       }
+                                                       $integration_src .= 
"{$_sep}{$_config_section_data['action']}=" . 
$_config_section_data["action_{$mode}"];
+                                               }
+
+                                               $arguments = 
array($_config_section_data['auth_key_name'] => $response);
+
+                                               
if(isset($_config_section_data['location_data']) && 
$_config_section_data['location_data'])
+                                               {
+                                                       
$_config_section_data['location_data']  = 
htmlspecialchars_decode($_config_section_data['location_data']);
+                                                       
parse_str($_config_section_data['location_data'], $output);
+                                                       foreach ($output as 
$_dummy => $_substitute)
+                                                       {
+                                                               $_keys[] = 
$_substitute;
+                                                               $_values[] = 
urlencode($values['location_data'][trim($_substitute, '_')]);
+                                                       }
+                                                       $integration_src .= '&' 
. str_replace($_keys, $_values, $_config_section_data['location_data']);
+                                               }
+
+                                               $integration_src .= 
"&{$_config_section_data['auth_key_name']}={$response}";
+                                               //_debug_array($values);
+                                               
//_debug_array($integration_src);die();
+                                               $tabs[$_config_section] = 
array('label' => $_config_section_data['tab'], 'link' => "#{$_config_section}", 
'function' => "document.getElementById('{$_config_section}_content').src = 
'{$integration_src}';");
+                                       }
+                               }
+// ---- END INTEGRATION -------------------------
                        }
 
 
                        $data = array
                        (
+                               'integration'                                   
=> $integration,
                                'roles'                                         
        => $roles,
                                'edit'                                          
        => $view ? '' : true,
                                'lang_change_type'                              
=> lang('Change type'),

Modified: branches/Version-1_0-branch/property/js/yahoo/location.index.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/location.index.js     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/property/js/yahoo/location.index.js     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -11,6 +11,8 @@
     ]
 
     // define buttons
+/*
+    // Defined i UI-class
     var oNormalButton_0, oNormalButton_1, oNormalButton_2, oNormalButton_3;
     var normalButtons = [
     {order:0, name:'btn_search',funct:"onSearchClick"},
@@ -18,7 +20,7 @@
     {order:2, name:'btn_export',funct:"onDownloadClick"},
     {order:3, name:'btn_integration',funct:"onIntegrationClick"}
     ]
-
+*/
     // define Text buttons
     var textImput = [
     {order:0, name:'query',    id:'txt_query'}
@@ -36,13 +38,14 @@
     var config_values = {
       date_search : 0 //if search has link "Data search"
     }
-
+/*
+       //defined in UI-class
        this.onIntegrationClick = function()
        {
                window.open(values_ds.integrationurl,'window');
        }
+*/
 
-
 
/****************************************************************************************/
        this.particular_setting = function()
        {

Modified: branches/Version-1_0-branch/property/templates/base/entity.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/entity.xsl      
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/property/templates/base/entity.xsl      
2011-05-31 05:59:50 UTC (rev 7333)
@@ -246,6 +246,15 @@
                                                </xsl:when>
                                        </xsl:choose>
 
+                                       <xsl:for-each select="integration">
+                                               <div id="{section}">
+                                                       <iframe id = 
"{section}_content" width="100%" height="500">
+                                                               <p>Your browser 
does not support iframes.</p>
+                                                       </iframe>
+                                               </div>
+                                       </xsl:for-each>
+
+                       <!--
                                        <xsl:choose>
                                                <xsl:when 
test="integration!=''">
                                                        <div id="integration">
@@ -253,13 +262,14 @@
                                                                        <p>Your 
browser does not support iframes.</p>
                                                                </iframe>
                                                        </div>
+
                                                        <div id="test" >
-                                                               <div class="hd" 
style="background-color:#000000;color:#FFFFFF; border:0; text-align:center"> 
Integration </div>
+                                                               <div class="hd" 
style="background-color:#000000;color:#FFFFFF; border:0; text-align:center"> 
Kart </div>
                                                                <div class="bd" 
style="text-align:center;"> </div>
                                                        </div>
                                                </xsl:when>
                                        </xsl:choose>
-
+                       -->
                                        <xsl:choose>
                                                <xsl:when test="documents != 
''">
                                                        <div id="document">

Modified: branches/Version-1_0-branch/property/templates/base/location.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/location.xsl    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/property/templates/base/location.xsl    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -558,6 +558,15 @@
                                                </xsl:when>
                                        </xsl:choose>
                                </div>
+
+                               <xsl:for-each select="integration">
+                                       <div id="{section}">
+                                               <iframe id = 
"{section}_content" width="100%" height="500">
+                                                       <p>Your browser does 
not support iframes.</p>
+                                               </iframe>
+                                       </div>
+                               </xsl:for-each>
+
                                <table cellpadding="2" cellspacing="2" 
width="80%" align="center">
                                        <tr height="50">
                                                <xsl:choose>

Modified: branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php    
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/inc/class.socomposite.inc.php    
2011-05-31 05:59:50 UTC (rev 7333)
@@ -161,7 +161,7 @@
                        {
                                $cols = "rental_composite.id AS composite_id,";
                        }
-                       $cols .= "rental_unit.id AS unit_id, 
rental_unit.location_code, rental_composite.name, 
rental_composite.has_custom_address, rental_composite.address_1, 
rental_composite.house_number, rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, ";
+                       $cols .= "rental_unit.id AS unit_id, 
rental_unit.location_code, rental_composite.name, 
rental_composite.has_custom_address, rental_composite.address_1, 
rental_composite.house_number, rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, rental_composite.description, ";
                        $cols .= "
                        CASE WHEN 
                        (
@@ -177,6 +177,7 @@
                $order = $sort_field ? "ORDER BY {$this->marshal($sort_field, 
'field')} $dir ": '';
 
            //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}");
+           
                return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
        }
        

Modified: branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php     
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php     
2011-05-31 05:59:50 UTC (rev 7333)
@@ -354,9 +354,7 @@
                 * @param $contract_id the id of the contract to show
                 */
                public function viewedit($editable, $contract_id, $contract = 
null, $location_id = null, $notification = null, string $message = null, string 
$error = null)
-               {
-                       
-                                       
+               {                               
                        $cancel_link = self::link(array('menuaction' => 
'rental.uicontract.index', 'populate_form' => 'yes'));
                        $adjustment_id = (int)phpgw::get_var('adjustment_id');
                        if($adjustment_id){
@@ -364,7 +362,6 @@
                                $cancel_text = 'contract_regulation_back';
                        }
                        
-                       
                        if (isset($contract_id) && $contract_id > 0) {
                                if($contract == null){
                                        $contract = 
rental_socontract::get_instance()->get_single($contract_id);
@@ -451,12 +448,22 @@
                        $message = null;
                        $error = null;
                        $add_default_price_items = false;
-
+                       
                        if(isset($_POST['save_contract']))
                        {
                                if(isset($contract_id) && $contract_id > 0)
                                {
                                        $contract = 
rental_socontract::get_instance()->get_single($contract_id);
+                                       
+                                       // Gets responsibility area from db 
(ex: eksternleie, internleie)
+                                       $responsibility_area = 
rental_socontract::get_instance()->get_responsibility_title($contract->get_location_id());
+                                       
+                                       // Redirect with error message if 
responsibility area is eksternleie and contract type not set
+                                       if( !is_numeric( 
phpgw::get_var('contract_type') ) && (strcmp($responsibility_area, 
"contract_type_eksternleie") == 0) ){
+                                               $error = 
lang('billing_removed_external_contract');
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message, 
'error' => $error)); 
+                                       }
+                                       
                                        
if(!$contract->has_permission(PHPGW_ACL_EDIT))
                                        {
                                                unset($contract);
@@ -465,6 +472,16 @@
                                }
                                else
                                {
+                                       // Gets responsibility area from db 
(ex: eksternleie, internleie) 
+                                       $responsibility_area = 
rental_socontract::get_instance()->get_responsibility_title($location_id);
+                                       
+                                       // Redirect with error message if 
responsibility area is eksternleie and contract type not set
+                                       if( !is_numeric( 
phpgw::get_var('contract_type') ) && (strcmp($responsibility_area, 
"contract_type_eksternleie") == 0) ){
+                                               $error = 
lang('billing_removed_external_contract');
+                                               
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uicontract.edit', 'location_id' => $location_id, 'message' => $message, 
'error' => $error));
+                                       }
+                               
                                        if(isset($location_id) && 
($this->isExecutiveOfficer() || $this->isAdministrator())){
                                                $contract = new 
rental_contract();
                                                $fields = 
rental_socontract::get_instance()->get_fields_of_responsibility();
@@ -477,7 +494,7 @@
                                $date_start =  
strtotime(phpgw::get_var('date_start_hidden'));
                                $date_end =  
strtotime(phpgw::get_var('date_end_hidden'));
                                
-                               if(isset($contract)){
+                               if(isset($contract)){ 
                                        $contract->set_contract_date(new 
rental_contract_date($date_start, $date_end));
                                        
$contract->set_security_type(phpgw::get_var('security_type'));
                                        
$contract->set_security_amount(phpgw::get_var('security_amount'));
@@ -585,7 +602,8 @@
                                                return $this->viewedit(true, 
$contract_id, $contract, $location_id,$notification, $message, $error);
                                        }
                                }
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'rental.uicontract.edit', 'id' => $contract->get_id(), 
'message' => $message, 'error' => $error));
+                               
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'rental.uicontract.edit', 'id' => $contract->get_id(), 
'message' => $message, 'error' => $error));         
                        }
                        else if(isset($_POST['add_notification']))
                        {

Modified: branches/Version-1_0-branch/rental/inc/class.uiparty.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.uiparty.inc.php        
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/inc/class.uiparty.inc.php        
2011-05-31 05:59:50 UTC (rev 7333)
@@ -22,6 +22,7 @@
                        'sync'                          => true,
                        'update_all_org_enhet_id'       => true,
                        'syncronize_party'      => true,
+                       'syncronize_party_name' => true,
                        'create_user_based_on_email' => true
        );
 
@@ -244,6 +245,85 @@
                        echo "Number of parties that have been updated 
{$count}<br />";
                }
        }
+       
+       /**
+        * Synchronization job to update company name on contract parties which 
are connected to Fellesdata.
+        * 
+        * Uses property org_enhet_id on party to link party with unit from 
Fellesdata.
+        * To be run as a scheduled job
+        */
+       function syncronize_party_name()
+       {
+               $config = CreateObject('phpgwapi.config','rental');
+               $config->read();
+
+               $use_fellesdata = $config->config_data['use_fellesdata'];       
+               if(!$use_fellesdata){
+                       return;
+               }
+               $bofelles = rental_bofellesdata::get_instance();
+               
+               $parties = rental_soparty::get_instance()->get();
+               $result_count = rental_soparty::get_instance()->get_count();
+               $updated_parties;
+               
+               $updated_parties[] = "Total number of parties: {$result_count}";
+               
+               if(($this->isExecutiveOfficer() || $this->isAdministrator()))
+               {
+                       $count = 0;
+                       $count_result_unit_number = 0;
+                       $count_identifier = 0;
+                       $count_responsibility = 0;
+
+                       foreach ($parties as $party) {
+                               $unit_found = false;
+                               $fellesdata = NULL;
+
+                               if(isset($party)) {
+                                       $sync_data = $party->get_sync_data();
+
+                                       $fellesdata = 
$bofelles->result_unit_exist($sync_data['result_unit_number'],4);
+                                       if ($fellesdata) {
+                                               $updated_parties[] = "Unit id 
found {$fellesdata['UNIT_ID']} by result unit number check. The unit name is 
{$fellesdata['UNIT_NAME']}<br />";
+                                               $count_result_unit_number++;
+                                       }
+
+                                       if ($fellesdata && 
isset($fellesdata['UNIT_ID']) && is_numeric($fellesdata['UNIT_ID'])) {
+                                               // We found a match, so store 
the new connection
+                                               
$party->set_org_enhet_id($fellesdata['UNIT_ID']);
+                                               $old_party_name = 
$party->get_company_name();
+                                               
$party->set_company_name($fellesdata['UNIT_NAME']);
+                                               $updated_parties[] = "Updated 
company name on party {$party->get_id()} with unit ID 
{$party->get_org_enhet_id} from {$old_party_name} to 
{$party->get_company_name()}";
+                                               $count++;
+                                       } else {
+                                               // No match was found. Do 
nothing
+                                               
//$party->set_org_enhet_id(NULL);
+                                       }
+                                       
rental_soparty::get_instance()->store($party);
+                               }
+                       }
+
+                       $updated_parties[] = "Number of parties found through 
result unit number {$count_result_unit_number}";
+                       $updated_parties[] = "Number of parties that have been 
updated {$count}";
+                       log_sync_messages($updated_parties);
+               }
+       }
+       
+        private function log_sync_messages($messages) {
+               
+            $msgs = array_merge(
+               array('---------------Messages-------------------'),
+               $messages
+            );
+            
+            //use PHPGW tmp-catalog to store log-file
+            $path = $GLOBALS['phpgw_info']['server']['temp_dir'];
+            
+            //Write to the log-file
+            $date_now = date('Y-m-d');
+            file_put_contents("{$path}/FD_name_sync_{$date_now}.log", 
implode(PHP_EOL, $msgs));
+        }
        
 
        /**
@@ -497,10 +577,13 @@
                {
                        $party_id = phpgw::get_var('party_id');
                        $org_unit_id = phpgw::get_var('org_unit_id');
+                       $org_unit_name = phpgw::get_var('org_unit_id');
                        if(isset($party_id) && $party_id > 0 && 
isset($org_unit_id) && $org_unit_id > 0)
                        {       
                                $party = 
rental_soparty::get_instance()->get_single($party_id);
                                $party->set_org_enhet_id($org_unit_id);
+                               $patry->set_company_name($org_unit_name);
+                               // add log-statement for synchronization
                                rental_soparty::get_instance()->store($party);
                        }
                }

Modified: branches/Version-1_0-branch/rental/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/rental/setup/phpgw_no.lang      2011-05-31 
05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/setup/phpgw_no.lang      2011-05-31 
05:59:50 UTC (rev 7333)
@@ -71,7 +71,7 @@
 billing_removed_KF_contract    rental  no      Fjernet KF-kontrakt med id
 billing_removed_contract_part_1        rental  no      Fjernet kontrakt
 billing_removed_contract_part_2        rental  no      med total pris lik 0 
kroner
-billing_removed_external_contract      rental  no      siden kontrakt med 
ansvarsområde eksternleie mangler kontrakttype
+billing_removed_external_contract      rental  no      Kontrakt med 
ansvarsområde eksternleie må ha kontrakttype
 bill   rental  no      Faktura
 bill2  rental  no      Fakturér
 btn_add        rental  no      Deleger tilgang til bruker

Modified: branches/Version-1_0-branch/rental/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/setup/setup.inc.php      2011-05-31 
05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/setup/setup.inc.php      2011-05-31 
05:59:50 UTC (rev 7333)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['rental']['name'] = 'rental';               // Module 
identifier
-       $setup_info['rental']['version'] = '0.1.0.12';  // Current module 
version
+       $setup_info['rental']['version'] = '0.1.0.13';  // Current module 
version
        $setup_info['rental']['app_order'] = 51;                // (?)
        $setup_info['rental']['tables'] = array(
                'rental_party',                                         // All 
contract participants, tenants etc.

Modified: branches/Version-1_0-branch/rental/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/setup/tables_update.inc.php      
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/setup/tables_update.inc.php      
2011-05-31 05:59:50 UTC (rev 7333)
@@ -226,4 +226,19 @@
                return $GLOBALS['setup_info']['rental']['currentver'];
        }
        
+       $test[] = '0.1.0.12';
+       function rental_upgrade0_1_0_12()
+       {
+               $asyncservice = CreateObject('phpgwapi.asyncservice');
+               $asyncservice->set_timer(
+                       array('day' => "*/1"),
+                       'rental_sync_party_name',
+                       'rental.uiparty.syncronize_party_name',
+                       null
+                       );
+               
+               $GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.13';
+               return $GLOBALS['setup_info']['rental']['currentver'];
+       }
+       
 ?>
\ No newline at end of file

Modified: branches/Version-1_0-branch/rental/templates/base/contract.php
===================================================================
--- branches/Version-1_0-branch/rental/templates/base/contract.php      
2011-05-31 05:10:21 UTC (rev 7332)
+++ branches/Version-1_0-branch/rental/templates/base/contract.php      
2011-05-31 05:59:50 UTC (rev 7333)
@@ -279,8 +279,14 @@
                                                {
                                                        ?>
                                                        <select 
name="contract_type">
-                                                               <option>Ingen 
type</option>
-                                                               <?php
+                                                               <!-- Adds 
option Ingen type if the contract is not assigned responsibility area 
eksternleie  -->
+                                                               <?php  
+                                                               
$responsibility_area = 
rental_socontract::get_instance()->get_responsibility_title($contract->get_location_id());
                       
+                                                               
+                                                               if( 
strcmp($responsibility_area, "contract_type_eksternleie") != 0 ){ 
+                                                                       echo 
"<option>Ingen type</option>";
+                                                               }
+                                                               
                                                                
foreach(rental_socontract::get_instance()->get_contract_types($contract->get_location_id())
 as $contract_type_id => $contract_type_label)
                                                                {
                                                                        echo 
"<option ".($current_contract_type_id == $contract_type_id ? 
'selected="selected"' : "")." 
value=\"{$contract_type_id}\">".lang($contract_type_label)."</option>";




reply via email to

[Prev in Thread] Current Thread [Next in Thread]