- Timestamp:
- Feb 26, 2010, 11:38:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php
r516 r518 158 158 global $xoops_db; 159 159 160 // table sync161 160 $table = get_wp_prefix() . 'group_role'; 162 $xoops_group = get_xoops_prefix() . 'groups'; 163 $xoops_group_permission = get_xoops_prefix() . 'group_permission'; 161 162 $sql= "SELECT * FROM $table"; 163 $this->groupe_role = $xoops_db->get_results($sql); 164 } 165 166 function GroupeRoleCheck() { 167 global $xoops_db; 164 168 165 169 $module_id = get_xpress_modid(); 166 170 167 $ sql= "SELECT * FROM $table";168 $ before_groupes = $xoops_db->get_results($sql);169 170 $sql = "DELETE FROM $table";171 $xoops_db->query($sql); 172 173 $sql = "SELECT * FROM $xoops_group_permission WHERE gperm_itemid = $module_id";171 $group_role_table = get_wp_prefix() . 'group_role'; 172 $xoops_group_table = get_xoops_prefix() . 'groups'; 173 $xoops_group_permission_table = get_xoops_prefix() . 'group_permission'; 174 175 176 177 $sql = "SELECT * FROM $xoops_group_permission_table WHERE gperm_itemid = $module_id"; 174 178 $gperms = $xoops_db->get_results($sql); 175 179 176 $sql = "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";180 $sql = "SELECT * FROM $xoops_group_table WHERE group_type <> 'Anonymous'"; 177 181 $groupes = $xoops_db->get_results($sql); 178 $insert_sql = ''; 182 183 // list of groups registered with XOOPS 184 $xoops_groupid_list = ''; 179 185 foreach ($groupes as $groupe) { 180 $parmsql = "SELECT * FROM $xoops_group_permission WHERE gperm_itemid = $module_id AND gperm_groupid = $groupe->groupid"; 181 $gperms = $xoops_db->get_results($parmsql); 182 $parmission = ''; 186 if (!empty($xoops_groupid_list)) $xoops_groupid_list .= ','; 187 $xoops_groupid_list .= $groupe->groupid; 188 } 189 190 // delete the group deleted by the XOOPS group from a group role database 191 if (!empty($xoops_groupid_list)){ 192 $del_sql = "DELETE FROM $group_role_table WHERE groupid NOT IN ($xoops_groupid_list)"; 193 $xoops_db->query($del_sql); 194 } 195 196 $sql = "SELECT * FROM $group_role_table"; 197 $groupes_role = $xoops_db->get_results($sql); 198 199 foreach ($groupes as $groupe) { 200 //get group parmission 201 $group_type = ''; 183 202 foreach ($gperms as $gperm) { 203 if ($gperm->gperm_groupid == $groupe->groupid){ 204 $group_type = $gperm->gperm_name; 205 if ($group_type == 'module_admin') break; 206 } 207 } 208 if (empty($group_type)) $group_type = 'module_inhibit'; 209 210 $found = false; 211 foreach ($groupes_role as $groupe_role) { 212 if ($groupe_role->groupid == $groupe->groupid){ 213 $role = $groupe_role->role; 214 if ($group_type == 'module_admin') $role = 'administrator'; 215 if ($group_type == 'module_inhibit') $role = ''; 216 $edit_sql = "UPDATE $group_role_table SET group_type='$group_type',role='$role' WHERE groupid = $groupe->groupid"; 217 $found = true; 218 break; 219 } 220 } 221 if(!$found){ 222 $role = ''; 223 if ($group_type == 'module_admin') $role = 'administrator'; 224 225 $edit_sql = "INSERT INTO $group_role_table "; 226 $edit_sql .= "(groupid , name , description , group_type , role , login_all) "; 227 $edit_sql .= "VALUES ("; 228 $edit_sql .= $groupe->groupid . ', '; 229 $edit_sql .= "'" . $groupe->name . "' , "; 230 $edit_sql .= "'" . $groupe->description . "' , "; 231 $edit_sql .= "'" . $parmission . "' , "; 232 $edit_sql .= "'" . $role . "' , '"; 233 $edit_sql .= $login_all . "')"; 234 } 235 $xoops_db->query($edit_sql); 236 } 237 $this->GroupeRoleRead(); 238 } 239 240 function get_groupe_perm_for_modules($module_id ,$group_id) 241 { 242 $parmsql = "SELECT * FROM $xoops_group_permission WHERE gperm_itemid = $module_id AND gperm_groupid = $group_id"; 243 $gperms = $xoops_db->get_results($parmsql); 244 $parmission = ''; 245 foreach ($gperms as $gperm) { 184 246 $parmission = $gperm->gperm_name; 185 247 if ($parmission == 'module_admin') break; 186 } 187 188 if (!empty($parmission)){ 189 $role = ''; 190 foreach ($before_groupes as $before_groupe) { 191 if ($groupe->groupid == $before_groupe->groupid) { 192 $role = $before_groupe->role; 193 $login_all = $before_groupe->login_all; 194 } 195 } 196 if ($parmission == 'module_admin') $role = 'administrator'; 197 198 $insert_sql = "INSERT INTO $table "; 199 $insert_sql .= "(groupid , name , description , group_type , role , login_all) "; 200 $insert_sql .= "VALUES ("; 201 $insert_sql .= $groupe->groupid . ', '; 202 $insert_sql .= "'" . $groupe->name . "' , "; 203 $insert_sql .= "'" . $groupe->description . "' , "; 204 $insert_sql .= "'" . $parmission . "' , "; 205 $insert_sql .= "'" . $role . "' , '"; 206 $insert_sql .= $login_all . "')"; 207 $xoops_db->query($insert_sql); 208 } 209 } 210 211 $sql= "SELECT * FROM $table"; 212 213 $this->groupe_role = $xoops_db->get_results($sql); 214 $sql= "SELECT * FROM $table"; 248 } 249 return $parmission; 215 250 } 216 251 … … 474 509 $form .= '<tr><td>' . __('XOOPS Groupe', 'xpressme') . '</td><td>' . __('WordPress Role', 'xpressme') . '</td><td>' . __('Role is set at each login', 'xpressme') . "</td></tr>\n"; 475 510 foreach ($this->groupe_role as $groupe) { 511 if ($groupe->group_type == 'module_inhibit'){ 512 $form .= "<tr>"; 513 $form .= "<td> $groupe->name </td>"; 514 $form .= "<td>" . __('module cannot be read', 'xpressme') . "</td>"; 515 $form .= "</tr>\n"; 516 continue; 517 } 476 518 $form .= "<tr>"; 477 519 $form .= "<td> $groupe->name </td>";
Note: See TracChangeset
for help on using the changeset viewer.