phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] hr/inc class.hr_ui.inc.php, 1.3 class.hr_so.inc.php,


From: skwashd
Subject: [Phpgroupware-cvs] hr/inc class.hr_ui.inc.php, 1.3 class.hr_so.inc.php, 1.3 class.hr_bo.inc.php, 1.2 class.hr_acl_so.inc.php, 1.2 class.hr_acl_bo.inc.php, 1.3
Date: Tue, 6 Dec 2005 09:14:00 +0100

Update of hr/inc

Modified Files:
     Branch: MAIN
            class.hr_ui.inc.php lines: +8 -11
            class.hr_so.inc.php lines: +75 -4
            class.hr_bo.inc.php lines: +29 -7
            class.hr_acl_so.inc.php lines: +5 -1
            class.hr_acl_bo.inc.php lines: +3 -2

Log Message:
some bug fixes and enhancements

====================================================
Index: hr/inc/class.hr_ui.inc.php
diff -u hr/inc/class.hr_ui.inc.php:1.2 hr/inc/class.hr_ui.inc.php:1.3
--- hr/inc/class.hr_ui.inc.php:1.2      Wed Nov 16 09:57:22 2005
+++ hr/inc/class.hr_ui.inc.php  Tue Dec  6 08:14:21 2005
@@ -85,9 +85,7 @@
                        {
                                if ( isset($_FILES['photo']) && 
$_FILES['photo']['size'] && is_uploaded_file($_FILES['photo']['tmp_name']) )
                                {
-                                       $this->bo->add_entry($_POST['user_id'], 
-2, '');
-                                       $content = 
file_get_contents($_FILES['photo']['tmp_name']);
-                                       
$this->bo->update_entry($_POST['user_id'], -2, $content);
+                                       
$this->bo->update_photo($_POST['user_id'], $_FILES['photo']);
                                }

                                if ( is_array($_POST['field']) && 
count($_POST['field']) )
@@ -99,14 +97,14 @@
                                }
                        }

-                       $cats = $this->bo->get_cats();
+                       $perms = $this->bo->get_permissions();
                        if ( isset($_POST['add']) && isset($_POST['cat'])  && 
$_POST['cat']
-                               && 
isset($cats[$_POST['cat']]['rights'][$GLOBALS['phpgw_info']['user']['account_id']])
-                               && 
$cats[$_POST['cat']]['rights'][$GLOBALS['phpgw_info']['user']['account_id']] | 
PHPGW_ACL_ADD )
+                               && isset($perms["C{$_POST['cat']}"]) && 
$perms["C{$_POST['cat']}"] | PHPGW_ACL_ADD )
                        {
                                $this->bo->add_entry($_POST['user_id'], 
$_POST['cat'], '');
-                               $cats = $this->bo->get_cats(); //refresh the 
cats
                        }
+
+                       $cats = $this->bo->get_cats();
                        unset($cats[-1]);//can't edit contact here!

                        $GLOBALS['phpgw']->common->phpgw_header();
@@ -150,7 +148,7 @@
                                                (
                                                        'label'         => 
$cats[$rec_id]['name'],
                                                        'id'            => 
$rec_id,
-                                                       'field_val'     => 
nl2br(htmlspecialchars($record))
+                                                       'field_val'     => 
htmlspecialchars($record)
                                                ));
                                        $this->t->parse('edit_blocks', 
'edit_block', true);
                                        unset($cats[$rec_id]);
@@ -161,8 +159,7 @@
                                $this->t->set_var('edit_blocks', '');
                        }

-                       if ( isset($cats[-2]) && 
isset($cats[-2]['rights'][$GLOBALS['phpgw_info']['user']['account_id']])
-                               && 
$cats[-2]['rights'][$GLOBALS['phpgw_info']['user']['account_id']] | 
PHPGW_ACL_ADD )
+                       if ( isset($perms['C-2']) && $perms['C-2'] | 
PHPGW_ACL_ADD )
                        {
                                $this->t->parse('update_photos', 
'update_photo');
                        }

====================================================
Index: hr/inc/class.hr_so.inc.php
diff -u hr/inc/class.hr_so.inc.php:1.2 hr/inc/class.hr_so.inc.php:1.3
--- hr/inc/class.hr_so.inc.php:1.2      Wed Nov 16 09:57:22 2005
+++ hr/inc/class.hr_so.inc.php  Tue Dec  6 08:14:21 2005
@@ -29,12 +29,23 @@
                * @var object $db reference to phpgw global database object
                */
                var $db;
+
+               /**
+               * @var object $vfs virtual file system object
+               */
+               var $vfs;

                function hr_so()
                {
                        $this->accounts =& $GLOBALS['phpgw']->accounts;
                        $this->contacts = createObject('phpgwapi.contacts');
                        $this->db =& $GLOBALS['phpgw']->db;
+                       $this->vfs = createObject('phpgwapi.vfs');
+                       $this->vfs->override_acl = 1;
+
+                       $this->vfs_base = '/hr/';
+                       $this->verify_root($this->vfs_base);
+
                }

                /**
@@ -129,13 +140,16 @@
                                return $user;
                        }

-                       $this->accounts->get_account_name($user_id, $lid, 
$fname, $lname);
+                       //$user['account'] = 
$this->accounts->get_account_data($account_id);
+                       //$user['account'] = $user['account'][$user_id];
+                       $user['account'] = $this->accounts-> 
get_account_name($user_id, $lid, $fname, $lname);
                        $user['account'] = array
                                        (
                                                'account_id'    => $user_id,
                                                'firstname'     => $fname,
                                                'lastname'      => $lname,
-                                               'fullname'      => "{$fname} 
{$lname}"
+                                               'fullname'      => "{$fname} 
{$lname}",
+                                               'person_id'     => 
$this->contacts->is_contact($user_id)
                                        );
                        unset($lid, $fname, $lname);

@@ -153,7 +167,7 @@
                                $user['contact'] = array();
                                if ( isset($user['account']['person_id']) && 
intval($user['account']['person_id']) )
                                {
-                                       $user['contact'] = 
$this->contacts->person_complete_data($user['person_id']);
+                                       $user['contact'] = 
$this->contacts->person_complete_data($user['account']['person_id']);
                                }
                        }
                        return $user;
@@ -186,6 +200,63 @@
                                        . ' AND user_id = ' . intval($user_id);

                        $this->db->query($sql, __LINE__, __FILE__);
+               }
+
+               /**
+               * Update a photo
+               */
+               function update_photo($user, $data)
+               {
+                       $name_parts = explode('.', $data['name']);
+                       $ext = $name_parts[count($name_parts)-1];
+                       unset($name_parts);
+
+                       $this->vfs->set_attributes(array
+                                               (
+                                                       'string'        => 
"{$this->vfs_base}{$user}.{$ext}",
+                                                        'relatives'     => 
array (RELATIVE_ROOT),
+                                                        'attributes'    => 
array
+                                                                       (
+                                                                               
'owner_id' => $GLOBALS['userinfo']['username'],
+                                                                               
'modifiedby_id' => $GLOBALS['userinfo']['username'],
+                                                                               
'modified' => time(),
+                                                                               
'size' => $data['size'],
+                                                                               
'mime_type' => $data['type'],
+                                                                               
'deleteable' => 'Y',
+                                                                       )
+                                               ));
+
+                       $this->vfs->cp(array
+                                       (
+                                               'from'  => $data['tmp_name'],
+                                               'to'    => 
"{$this->vfs_base}{$user}.{$ext}",
+                                               'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ROOT)
+                                       ));
+               }
+
+                function verify_root()
+               {
+                       $path_data = array
+                                       (
+                                               'string'        => 
$this->vfs_base,
+                                               'relatives'     => array 
(RELATIVE_ROOT)
+                                       );
+
+                       if ( !$this->vfs->file_exists($path_data) )
+                       {
+                               $this->vfs->override_acl = 1;
+                               if ( !$this->vfs->mkdir($path_data) )
+                               {
+                                       return false;
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+                       $this->vfs->update_real(array
+                                               (
+                                                       'string'        => 
$path_data,
+                                                       'relatives'     => 
array (RELATIVE_ROOT)
+                                               ));
+                       return true;
                }

                /**

====================================================
Index: hr/inc/class.hr_bo.inc.php
diff -u hr/inc/class.hr_bo.inc.php:1.1 hr/inc/class.hr_bo.inc.php:1.2
--- hr/inc/class.hr_bo.inc.php:1.1      Tue Nov 15 14:09:42 2005
+++ hr/inc/class.hr_bo.inc.php  Tue Dec  6 08:14:21 2005
@@ -15,12 +15,18 @@
        class hr_bo
        {
                /**
+               * @var object $acls reference to the ACL object
+               */
+               var $acls;
+
+               /**
                * @var object $so hr storage object
                */
                var $so;

                function hr_bo()
                {
+                       $this->acls = createObject('hr.hr_acl_bo');
                        $this->so = createObject('hr.hr_so');
                }

@@ -44,8 +50,7 @@
                */
                function can_edit()
                {
-                       $acls = createObject('hr.hr_acl_bo');
-                       $rights = $acls->permissions;
+                       $rights = $this->acls->permissions;
                        if ( is_array($rights) && count($rights) )
                        {
                                foreach ( $rights as $cat => $right )
@@ -64,8 +69,7 @@
                */
                function get_cats()
                {
-                       $acls = createObject('hr.hr_acl_bo');
-                       return $acls->cats;
+                       return $this->acls->cats;
                }

                /**
@@ -91,6 +95,14 @@
                }

                /**
+               * Get the ACL permissions list
+               */
+               function get_permissions()
+               {
+                       return $this->acls->permissions;
+               }
+
+               /**
                * Get all records for a user
                *
                * @param int $user_id user id
@@ -102,8 +114,7 @@
                        $cats = array();
                        $cats[] = 0;

-                       $acls = createObject('hr.hr_acl_bo');
-                       $rights = $acls->permissions;
+                       $rights = $this->acls->permissions;
                        if ( is_array($rights) && count($rights) )
                        {
                                foreach ( $rights as $cat => $right )
@@ -153,6 +164,17 @@
                function get_users($filter = '' )
                {
                        return $this->so->get_users($filter);
+               }
+
+               /**
+               * Update a photo
+               *
+               * @param int $user_id the user to update the entry for
+               * @param array image upload information
+               */
+               function update_photo($user_id, $upload_data)
+               {
+                       return $this->so->update_photo($user_id, $upload_data);
                }

                /**

====================================================
Index: hr/inc/class.hr_acl_so.inc.php
diff -u hr/inc/class.hr_acl_so.inc.php:1.1 hr/inc/class.hr_acl_so.inc.php:1.2
--- hr/inc/class.hr_acl_so.inc.php:1.1  Tue Nov 15 14:09:42 2005
+++ hr/inc/class.hr_acl_so.inc.php      Tue Dec  6 08:14:21 2005
@@ -43,6 +43,10 @@
                        $this->db->query($sql,__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
+                               if ( $this->db->f('acl_location') == 'run' )
+                               {
+                                       continue;
+                               }
                                $result[$this->db->f('acl_location')] |= 
$this->db->f('acl_rights');
                        }
                        return $result;

====================================================
Index: hr/inc/class.hr_acl_bo.inc.php
diff -u hr/inc/class.hr_acl_bo.inc.php:1.2 hr/inc/class.hr_acl_bo.inc.php:1.3
--- hr/inc/class.hr_acl_bo.inc.php:1.2  Wed Nov 16 09:57:22 2005
+++ hr/inc/class.hr_acl_bo.inc.php      Tue Dec  6 08:14:21 2005
@@ -48,6 +48,7 @@
                                $this->save_sessiondata();
                        }
                        $this->catbo = createobject('phpgwapi.categories');
+                       $this->catbo->app_name = 'hr';
                        $this->_set_cats();
                        $this->permissions = $this->get_permissions(True);
                }
@@ -119,7 +120,7 @@
                }

                //access permissions for current user
-               function get_permissions($inc_groups = False)
+               function get_permissions($inc_groups = True)
                {
                        return 
$this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'], 
$inc_groups);
                }






reply via email to

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