Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Groups Module - Readme
========================
Version 0.2, alpha 2004/05/27
-- lehdem correction in:
B 2) javascript
B 3) addGroup ( }s missing)
B 7) register_globals
Summary:
The Groups module allows user to assign contacts to a group or multiple groups. As a stand-alone module, its pretty useless.
However, this module can be used as a launch point to build other modules using group lists.
For example, combined with a newsletter module to create mailing lists. I also implemented this into contacts/index.php
so I have a pull down menu that only returns contacts for a certain group (see sect C, Integrate into contacts/index.php)
A) Stand Alone Module
1) Download and unpack Groups module
2) Place groups folder into dotproject /modules folder
3) Add "groups" to permissions by making the following changes to /modules/admin/vw_usr_perms.php:
Line 11:
replace:
> 'forums' => 'forum_name'
with:
> 'forums' => 'forum_name',
> 'groups'=>'group_name'
Line 30:
replace:
> fm.forum_id, fm.forum_name,
with:
> fm.forum_id, fm.forum_name,
> g.group_id, g.group_name,
Line 39 (same sql statement as above):
replace:
> LEFT JOIN forums fm ON fm.forum_id = p.permission_item and p.permission_grant_on = 'forums'
with:
> LEFT JOIN forums fm ON fm.forum_id = p.permission_item and p.permission_grant_on = 'forums'
> LEFT JOIN groups g ON g.group_id = p.permission_item and p.permission_grant_on = 'groups'
Line 111:
replace:
> tables['forums'] = 'forums';
with:
> tables['forums'] = 'forums';
> tables['groups'] = 'groups';
4) Add the following case for groups around line 93 in /modules/public/selector.php (after case 'users' & before default:):
case 'groups':
$title = 'Groups';
$select = 'group_id,group_name';
$order = 'group_name';
break;
5) Login to dotproject as Admin and Install, Activate and make Visible "Groups" module
B) Integrate into Contacts add/edit
This will allow you to add a contact to group(s) from the addedit contact form. I should've just included the revised contacts module files, but I made a bunch of other changes to contacts that aren't affiliated with the groups module.
My bad -- should've created different versions.
1) /modules/contacts/addedit.php - Insert following lines before "//setup the title block"
// Pull groups for the parent groups list
$sql="
SELECT group_id, group_name
FROM groups
ORDER BY group_name ";
$allGroups = db_loadHashList( $sql );
// Pull groups for this contact
$sql = "
SELECT g.group_id, g.group_name
FROM groups g, groups_contacts gc
WHERE gc.contact_id = $contact_id
AND g.group_id = gc.group_id
";
$contactGroups = db_loadHashList( $sql );
2) /modules/contacts/addedit.php - insert following lines in javascript function submitIt() in form.submit() else block
var fl = form.contact_groups.options.length-1;
form.hcg.value = "";
for (fl; fl > -1; fl--){
form.hcg.value = "," + form.hcg.value +","+ form.contact_groups.options[fl].value
}
3) /modules/contacts/addedit.php - insert following javascript functions
function addGroup() {
var form = document.changecontact;
var at = form.all_groups.length -1;
var td = form.contact_groups.length -1;
var groups = "x";
//build array of groups
for (td; td > -1; td--) {
groups = groups + "," + form.contact_groups.options[td].value + ","
}
//Pull selected resources and add them to list
for (at; at > -1; at--) {
if (form.all_groups.options[at].selected && groups.indexOf( "," + form.all_groups.options[at].value + "," ) == -1) {
t = form.contact_groups.length
opt = new Option( form.all_groups.options[at].text, form.all_groups.options[at].value);
form.contact_groups.options[t] = opt;
}
}
}function removeGroup() {
var form = document.changecontact;
td = form.contact_groups.length -1;
for (td; td > -1; td--) {
if (form.contact_groups.options[td].selected) {
form.contact_groups.options[td] = null;
}
}
}
4) /modules/contacts/addedit.php - Insert above "contact notes" <tr></tr> block in html (or wherever you prefer to have this in the layout)
<tr>
<td>
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td><?php echo $AppUI->_( 'All Groups' );?></td>
<td><?php echo $AppUI->_( 'This Contact\'s Groups' );?></td>
</tr>
<tr>
<td>
<?php echo arraySelect( $allGroups, 'all_groups', 'style="width:180px" size="10" style="font-size:9pt;" multiple="multiple"', null ); ?>
</td>
<td>
<?php echo arraySelect( $contactGroups, 'contact_groups', 'style="width:180px" size="10" style="font-size:9pt;" multiple="multiple"', null ); ?>
</td>
</tr>
<tr>
<td align="right"><input type="button" class="button" value=">" onClick="addGroup()" /></td>
<td align="left"><input type="button" class="button" value="<" onClick="removeGroup()" /></td>
</tr>
5) /modules/contacts/addedit.php - insert before </form>
<input type="hidden" name="hcg" />
6) /modules/contacts/contacts.class.php - insert after function check()
function updateGroups( $cslist ) {
// delete all current entries
$sql = "DELETE FROM groups_contacts WHERE contact_id = $this->contact_id";
db_exec( $sql );
// process dependencies
$tarr = explode( ",", $cslist );
foreach ($tarr as $group_id) {
if (intval( $group_id ) > 0) {
$sql = "INSERT into groups_contacts (contact_id, group_id) VALUES ($this->contact_id, $group_id)";
db_exec($sql);
}
}
}
7) /modules/contacts/contact_aed.php - insert before $AppUIredirect();
if(isset($_POST['hcg'])) {
$obj->updateGroups( $_POST['hcg'] );
}
C) Integrate into /modules/contacts/index.php
This file is included in the package. Just diff what you currently have to see the changes.