Index: og_teampage.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_teampage/og_teampage.module,v
retrieving revision 1.33
diff -u -F^f -r1.33 og_teampage.module
--- og_teampage.module 6 Jul 2007 12:58:05 -0000 1.33
+++ og_teampage.module 9 Jul 2007 14:51:08 -0000
@@ -55,76 +55,64 @@ function og_teampage_nodeapi(&$node, $op
$res = db_query("SELECT * FROM {og_teampage_members}
WHERE uid='0' AND gid='".$node->nid."' AND hidden='3'");
if (db_num_rows($res) > 0) {
+ $row = db_fetch_object($res);
$node->content['og_mission']['#value'] =
substr($node->content['og_mission']['#value'],0,
strlen($node->content['og_mission']['#value'])-6);
$node->content['og_mission']['#value'] =
- $node->content['og_mission']['#value'].og_teampage_teamtable($node->nid)."";
+ $node->content['og_mission']['#value'].og_teampage_teamtable($node->nid, $row->weight)."";
}
}
}
}
-function sort_members_array($a, $b) {
- if ($a[data]->weight == $b[data]->weight) return 0;
- return ($a[data]->weight > $b[data]->weight) ? 1 : -1;
-}
-
-function og_teampage_teamtable($gid) {
- $res = db_query("SELECT * FROM {og_teampage_members} WHERE uid='0' AND gid='".$gid."'");
- $test = db_fetch_object($res);
- $use_userimage = 0;
- if ($test->weight == '1') $use_userimage = 1;
-
- $table = '
';
- $table .= '
';
+function og_teampage_teamtable($gid, $use_userimage) {
$min_is_active = 1;
$min_is_admin = 0;
- $sql = "SELECT u.uid, u.name, u.picture, ou.* FROM {og_uid} ou INNER JOIN {users} u ON ou.uid = u.uid WHERE ou.nid = %b AND u.status > 0 AND is_active >= $min_is_active AND is_admin >= $min_is_admin ORDER BY u.name ASC";
+ $sql = "SELECT u.uid, u.name as user_name, u.picture as user_picture, tm.picture1 as member_picture, tm.name as member_name, tm.description as member_description FROM {og_uid} ou INNER JOIN {users} u ON ou.uid = u.uid INNER JOIN {og_teampage_members} tm ON ou.uid = tm.uid WHERE ou.nid = %b AND u.status > 0 AND is_active >= $min_is_active AND is_admin >= $min_is_admin AND tm.hidden != 1 ORDER BY tm.weight ASC";
$result = db_query($sql, $gid);
- $i=0;
- while ($account = db_fetch_object($result)) {
- $rows[$i][username] = $account->name;
- $rows[$i][uid] = $account->uid;
- $rows[$i][picture] = $account->picture;
- $res = db_query("SELECT * FROM {og_teampage_members} WHERE uid='".$account->uid."' AND gid='".$gid."'");
- if (db_num_rows($res) < 1) {
- $res = db_query("SELECT * FROM {og_teampage_members} WHERE uid='".$account->uid."' AND gid='0'");
- }
- $rows[$i][data] = db_fetch_object($res);
- $i++;
- }
+
+ $rows = array();
+
+ while ($account = db_fetch_object($result)) {
+ $rows[] = $account;
+ }
+
+ return theme('og_teampage_table', $rows, $use_userimage);
+}
+
+function theme_og_teampage_table($rows, $use_userimage) {
$trows = array();
$rowcounter = 1;
$colcounter = 0;
$colcount = variable_get('og_teampage_colcount',5);
- $colwidth = 100/variable_get('og_teampage_colcount',5);
- $colwidth = round($colwidth);
+ $colwidth = round(100/variable_get('og_teampage_colcount',5));
$colwidthstring = $colwidth.'%';
+
+ $output = '';
+ $output .= '
';
- usort($rows, sort_members_array);
- foreach($rows as $row)
- {
- if ($row[data]->hidden != '1') {
+ foreach($rows as $row) {
$colcounter++;
if ($colcounter > $colcount) {
$rowcounter++;
$colcounter = 1;
}
- $picsource = base_path().drupal_get_path('module', 'og_teampage').'/no-pic.png';
- if ($row[data]->picture1 != '')
- {
- $picsource = $row[data]->picture1;
+
+ // theme member picture
+ if ($row->member_picture != '') {
+ $picsource = $row->member_picture;
$picsource = str_replace("system/files/", "", $picsource);
$picsource = file_create_url($picsource);
- } else if (($row[picture] != '') && ($use_userimage == 1) && (file_exists($row[picture]))) $picsource = file_create_url($row[picture]);
- if ($row[data]->name != '')
- {
- $name = $row[data]->name;
- } else $name = $row[username];
-
- $description = $row[data]->description;
+ }
+ else if (($row->user_picture != '') && ($use_userimage == 1) && (file_exists($row->user_picture))) {
+ $picsource = file_create_url($row->user_picture);
+ }
+ else {
+ $picsource = base_path().drupal_get_path('module', 'og_teampage').'/no-pic.png';
+ }
+
$width = variable_get('og_teampage_imagewidth','');
$height = variable_get('og_teampage_imageheight','');
$width_attr = '';
@@ -132,42 +120,55 @@ function og_teampage_teamtable($gid) {
if ($width != '') $width_attr = 'width="'.$width.'" ';
if ($height != '') $height_attr = 'height="'.$height.'" ';
- $attr=array();
- $attr['target'] = '_blank';
- $piclink = l('
','user/'.$row[uid], $attr, NULL, NULL, FALSE, TRUE);
+ $attr = array('target' => '_blank');
+ $piclink = l('
','user/'.$row->uid, $attr, NULL, NULL, FALSE, TRUE);
+
+ // theme member name
+ if ($row->member_name != '') {
+ $name = $row->member_name;
+ }
+ else {
+ $name = $row->user_name;
+ }
$textlink = l($name,'user/'.$row[uid], $attr);
+
+ // theme member description
+ $description = $row[data]->description;
+
+ // theme member record
$member = '| '.$piclink.' |
';
$member .= '| '.$textlink.' |
';
if ($description != '') $member .= '| '.$description.' |
';
$member .= '
';
$cell = ''.$member.' | ';
- $trows[$rowcounter] .= $cell;
- }
-
- }
+ $trows[$rowcounter] .= $cell;
+ }
+
foreach ($trows as $trow) {
$trcount++;
if (($trcount < $rowcounter) || ($colcounter == $colcount)) {
- $table .= ''.$trow.'
';
+ $output .= ''.$trow.'
';
};
}
- $table .= '
';
- if ($colcounter < $colcount)
- {
- $table .= '
';
+
+ if ($colcounter < $colcount) {
+ $output .= '
';
$diff = $colcount - $colcounter;
$dummywidth = $colwidth * $diff / 2;
$dummywidth = round($dummywidth);
$dummywidthstr = $dummywidth.'%';
- $table .= '| | ';
- $table .= $trows[$rowcounter];
- $table .= ' | ';
- $table .= '
';
+ $output .= '
| ';
+ $output .= $trows[$rowcounter];
+ $output .= '
| ';
+ $output .= '
';
}
- $table .= '
';
- $table .= '
';
- return $table;
+
+ $output .= '';
+
+ return $output;
}
function og_teampage_admin_members($gid) {