diff --git a/dba/base-data.sql b/dba/base-data.sql index 9323ec84..82c1aba4 100644 --- a/dba/base-data.sql +++ b/dba/base-data.sql @@ -17,20 +17,17 @@ INSERT INTO role_member (user_no, role_no) VALUES(1, 1); -- Set the insert sequence to the next number, with a minimum of 1000 SELECT setval('usr_user_no_seq', (SELECT 1000 UNION SELECT user_no FROM usr ORDER BY 1 DESC LIMIT 1) ); -INSERT INTO relationship_type ( rt_id, rt_name, rt_isgroup, confers ) - VALUES( 1, 'Administers Group', TRUE, 'A' ); +INSERT INTO relationship_type ( rt_id, rt_name, confers ) + VALUES( 1, 'Administers', 'A' ); -INSERT INTO relationship_type ( rt_id, rt_name, rt_isgroup, confers ) - VALUES( 2, 'is Assistant to', FALSE, 'RW' ); +INSERT INTO relationship_type ( rt_id, rt_name, confers ) + VALUES( 2, 'is Assistant to', 'RW' ); -INSERT INTO relationship_type ( rt_id, rt_name, rt_isgroup, confers ) - VALUES( 3, 'Is a member of group', TRUE, 'R' ); +INSERT INTO relationship_type ( rt_id, rt_name, confers ) + VALUES( 3, 'Can read from', 'R' ); -INSERT INTO relationship_type ( rt_id, rt_name, rt_isgroup, confers ) - VALUES( 4, 'Administers Resource', FALSE, 'A' ); - -INSERT INTO relationship_type ( rt_id, rt_name, rt_isgroup, confers ) - VALUES( 5, 'Can see free/busy time of', FALSE, 'F' ); +INSERT INTO relationship_type ( rt_id, rt_name, confers ) + VALUES( 4, 'Can see free/busy time of', 'F' ); -- Set the insert sequence to the next number, with a minimum of 1000 diff --git a/dba/caldav_functions.sql b/dba/caldav_functions.sql index 2b819e72..ef5b0163 100644 --- a/dba/caldav_functions.sql +++ b/dba/caldav_functions.sql @@ -236,7 +236,7 @@ BEGIN -- dbg := ''S-''; SELECT rt1.confers INTO out_confers FROM relationship r1 JOIN relationship_type rt1 USING ( rt_id ) - WHERE NOT rt1.rt_togroup AND r1.from_user = in_from AND r1.to_user = in_to; + WHERE r1.from_user = in_from AND r1.to_user = in_to; IF FOUND THEN RETURN dbg || out_confers; END IF; @@ -244,7 +244,7 @@ BEGIN SELECT rt1.confers, rt2.confers INTO out_confers, tmp_confers FROM relationship r1 JOIN relationship_type rt1 ON ( r1.rt_id = rt1.rt_id ) LEFT OUTER JOIN relationship r2 ON ( r1.to_user = r2.from_user ) JOIN relationship_type rt2 ON ( r2.rt_id = rt2.rt_id ) - WHERE rt1.rt_togroup AND NOT rt2.rt_togroup AND r1.from_user = in_from AND r2.to_user = in_to; + WHERE r1.from_user = in_from AND r2.to_user = in_to; IF FOUND THEN -- RAISE NOTICE ''Permissions to group % from group %'', out_confers, tmp_confers; @@ -271,8 +271,8 @@ BEGIN SELECT rt1.confers INTO out_confers, tmp_confers FROM relationship r1 JOIN relationship_type rt1 ON ( r1.rt_id = rt1.rt_id ) LEFT OUTER JOIN relationship r2 ON ( rt1.rt_id = r2.rt_id ) - WHERE rt1.rt_togroup AND r1.from_user = in_from AND r2.from_user = in_to AND r1.from_user != r2.from_user AND r1.to_user = r2.to_user - AND NOT EXISTS( SELECT 1 FROM relationship r3 WHERE r3.from_user = r1.to_user ) ; + WHERE r1.from_user = in_from AND r2.from_user = in_to AND r1.from_user != r2.from_user AND r1.to_user = r2.to_user + AND NOT EXISTS( SELECT 1 FROM relationship r3 WHERE r3.from_user = r1.to_user ) ; IF FOUND THEN -- dbg := ''H-''; diff --git a/dba/patches/1.1.7.sql b/dba/patches/1.1.7.sql index 886cd2ac..b2c20b2d 100644 --- a/dba/patches/1.1.7.sql +++ b/dba/patches/1.1.7.sql @@ -6,8 +6,7 @@ SELECT check_db_revision(1,1,6); ALTER TABLE relationship_type DROP COLUMN rt_inverse; ALTER TABLE relationship_type DROP COLUMN prefix_match; -ALTER TABLE relationship_type ALTER COLUMN rt_isgroup RENAME TO rt_togroup; -ALTER TABLE relationship_type ADD COLUMN rt_fromgroup BOOLEAN; +ALTER TABLE relationship_type DROP COLUMN rt_isgroup; SELECT new_db_revision(1,1,7, 'July' ); COMMIT; diff --git a/htdocs/relationship_types.php b/htdocs/relationship_types.php index 1f444cf8..3c6bd3f4 100644 --- a/htdocs/relationship_types.php +++ b/htdocs/relationship_types.php @@ -57,8 +57,6 @@ require_once("interactive-page.php"); $browser->AddColumn( 'rt_id', 'Id' ); $browser->AddColumn( 'rt_name', translate('Name') ); - $browser->AddColumn( 'rt_fromgroup', translate('From Group?'), '', '', "CASE WHEN rt_fromgroup THEN 'Yes' ELSE 'No' END" ); - $browser->AddColumn( 'rt_togroup', translate('To Group?'), '', '', "CASE WHEN rt_togroup THEN 'Yes' ELSE 'No' END" ); $browser->AddColumn( 'confers', translate('Rights') ); $browser->AddColumn( 'action', translate("Action"), "", "", "'base_url/relationship_types.php?action=delete&rt_id=' || rt_id || '\">".translate("Delete")."'" ); @@ -77,12 +75,6 @@ require_once("interactive-page.php"); array("title" => translate("Enter the name for this resource type"), "size" => "20") ); - $rt_fromgroup_field = new EntryField( "checkbox", "rt_fromgroup", - array("title" => translate("Is the source of this relationship a group of access rights?")) ); - - $rt_fromgroup_field = new EntryField( "checkbox", "rt_togroup", - array("title" => translate("Is the target of this relationship a group of access rights?")) ); - $confers_field = new EntryField( "text", "confers", array("title" => translate("Is this access read ('R') or Read and Write ('RW')?"), "size" => "5") ); @@ -91,8 +83,6 @@ require_once("interactive-page.php"); 'rt_id' => 'new', 'rt_name' => $rt_name_field->Render(), 'rt_link' => $rt_name_field->Render(), - 'rt_fromgroup' => $rt_fromgroup_field->Render(), - 'rt_togroup' => $rt_togroup_field->Render(), 'confers' => $confers_field->Render(), 'action' => '' ) ); diff --git a/inc/RSCDSSession.php b/inc/RSCDSSession.php index 0d240b6b..9bf7707b 100644 --- a/inc/RSCDSSession.php +++ b/inc/RSCDSSession.php @@ -143,12 +143,12 @@ class RSCDSSession extends Session */ function GetRelationships () { $this->relationships = array(); - $sql = 'SELECT relationship.rt_id, rt_name, rt_fromgroup, rt_togroup, confers FROM relationship JOIN relationship_type USING (rt_id) WHERE from_user = '.$this->user_no; + $sql = 'SELECT relationship.rt_id, rt_name, confers FROM relationship JOIN relationship_type USING (rt_id) WHERE from_user = '.$this->user_no; $qry = new PgQuery( $sql ); if ( $qry->Exec('RSCDSSession') && $qry->rows > 0 ) { while( $relationship = $qry->Fetch() ) { $this->relationships[$relationship->rt_id] = $relationship; - dbg_error_log( "RSCDSSession", "Relationships: %d - %s - %d - %s - %s -", $relationship->rt_id, $relationship->rt_name, $relationship->rt_fromgroup, $relationship->rt_togroup, $relationship->confers ); + dbg_error_log( "RSCDSSession", "Relationships: %d - %s - %d - %s - %s -", $relationship->rt_id, $relationship->rt_name, $relationship->confers ); } } } @@ -158,15 +158,15 @@ class RSCDSSession extends Session * Checks that this user is logged in, and presents a login screen if they aren't. * * The function can optionally confirm whether they are a member of one of a list - * of groups, and deny access if they are not a member of any of them. + * of roles, and deny access if they are not a member of any of them. * - * @param string $groups The list of groups that the user must be a member of one of to be allowed to proceed. - * @return boolean Whether or not the user is logged in and is a member of one of the required groups. + * @param string $roles The list of roles that the user must be a member of one of to be allowed to proceed. + * @return boolean Whether or not the user is logged in and is a member of one of the required roles. */ - function LoginRequired( $groups = "" ) { + function LoginRequired( $roles = "" ) { global $c, $session, $main_menu, $sub_menu, $tab_menu; - if ( $this->logged_in && $groups == "" ) return; + if ( $this->logged_in && $roles == "" ) return; if ( ! $this->logged_in ) { $c->messages[] = i18n("You must log in to use this system."); include_once("page-header.php"); @@ -187,8 +187,8 @@ class RSCDSSession extends Session } } else { - $valid_groups = split(",", $groups); - foreach( $valid_groups AS $k => $v ) { + $valid_roles = split(",", $roles); + foreach( $valid_roles AS $k => $v ) { if ( $this->AllowedTo($v) ) return; } $c->messages[] = i18n("You are not authorised to use this function."); diff --git a/inc/RSCDSUser.php b/inc/RSCDSUser.php index acef3b9a..c94c445c 100644 --- a/inc/RSCDSUser.php +++ b/inc/RSCDSUser.php @@ -139,11 +139,10 @@ EOSQL; "_null" => $nullvalue, "_sql" => $sql ) ); - $group_target = ( isset($this->roles['Group']) ? 'WHERE NOT rt_fromgroup' : '' ); $relationship_type_selection = $ef->DataEntryField( "", "lookup", "relate_as", array("title" => translate("Select the type of relationship from this user"), "_null" => translate("--- select a relationship type ---"), - "_sql" => "SELECT rt_id, rt_name FROM relationship_type $group_target " ) ); + "_sql" => "SELECT rt_id, rt_name FROM relationship_type " ) ); $browser->AddRow( array( 'rt_name' => $relationship_type_selection, /* Since 'fullname' is formatted to display this value */ @@ -174,7 +173,6 @@ EOSQL; $browser->AddHidden( 'user_link', "'base_url/user.php?user_no=' || user_no || '\">' || fullname || ''" ); $browser->AddColumn( 'fullname', translate('Linked From'), 'left', '##user_link##' ); $browser->AddColumn( 'rt_name', translate('Relationship') ); - $browser->AddColumn( 'to_group', translate('Group?'), 'centre', '', "CASE WHEN rt_togroup THEN 'Yes' ELSE 'No' END" ); $browser->AddHidden( 'confers' ); $browser->AddColumn( 'email', translate('EMail') ); diff --git a/inc/other_translated_strings.php b/inc/other_translated_strings.php index d5141eeb..e44152ad 100644 --- a/inc/other_translated_strings.php +++ b/inc/other_translated_strings.php @@ -30,10 +30,10 @@ i18n("Id "); i18n("Id"); // The standard relationship names -i18n("Administers Group"); -i18n("Administers Resource"); -i18n("Is Assisted by"); -i18n("Is a member of group"); +i18n('Administers'); +i18n('is Assistant to'); +i18n('Can read from'); +i18n('Can see free/busy time of'); i18n("forget me not ");