Changeset 1095

Show
Ignore:
Timestamp:
05/11/07 16:00:59 (2 years ago)
Author:
ben
Message:

Some community fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/community/lib.php

    r1080 r1095  
    2626    global $CFG; 
    2727    global $USER; 
    28     global $metatags; 
    2928 
    3029    require_once (dirname(__FILE__)."/default_template.php"); 
    3130    require_once (dirname(__FILE__)."/lib/communities_config.php"); 
    3231 
    33     $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/community/css.css\" type=\"text/css\" media=\"screen\" />"; 
    34  
    3532    $page_owner = $profile_id; 
    3633 
     
    3835 
    3936    $username= user_info('username', $page_owner); 
     37 
     38    if (isloggedin()) { 
     39        if (defined("context") && context == COMMUNITY_CONTEXT && context!="network" && $page_owner == $_SESSION['userid']) { 
     40 
     41            $PAGE->menu[] = array( 'name' => 'community', 
     42                                   'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" class=\"selected\" >" .__gettext("Your Communities").'</a></li>'); 
     43            } else { 
     44                $PAGE->menu[] = array( 'name' => 'community', 
     45                                       'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" >" .__gettext("Your Communities").'</a></li>'); 
     46            } 
     47    } 
    4048 
    4149    if ($usertype == "community") { 
     
    7684                                         'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", 
    7785                                                           __gettext("View membership requests"))); 
     86 
     87 
     88      /*-----------------------------------* 
     89           * O2O BEGIN modified by mac 
     90          /*-----------------------------------*/ 
     91                  /** 
     92                 *it connects to invite to a person from a group by mac 
     93                 */ 
     94                 /* 
     95                  $PAGE->menu_sub[] = array( 'name' => 'community:invite', 
     96                                         'html' => a_href( "{$CFG->wwwroot}_invite/", __gettext("Invite a friend"))); 
     97                  */ 
     98 
     99      /**---- I hypertie to contact to add a group like member  by mac --**/ 
     100      /* 
     101          $PAGE->menu_sub[] = array( 'name' => 'community:addgroup', 
     102                                     'html' => a_href("{$CFG->wwwroot}_communities/addgroup.php?profile_id=$page_owner", 
     103                                                             __gettext("Invite a Community"))); 
     104      */ 
     105      /*-----------------------------------* 
     106           * O2O BEGIN modified by mac 
     107          /*-----------------------------------*/ 
    78108            } 
    79109        } 
     
    131161 
    132162    // 'Communities' aspect to the little menus beneath peoples' icons 
     163        $function['community:infobox:menu'][] = $CFG->dirroot . "mod/community/lib/communities_info_menu.php";   
    133164        $function['users:infobox:menu:text'][] = $CFG->dirroot . "mod/community/lib/user_info_menu_text.php"; 
    134165 
  • devel/mod/community/lib/communities_config.php

    r1080 r1095  
    3434 * Type: boolean 
    3535 */ 
    36 define('COMMUNITY_COMPACT_VIEW', true); 
     36define('COMMUNITY_COMPACT_VIEW', false); 
     37 
     38 /** 
     39  * Defines if its allowed to a community have members of type 'community' 
     40  * Type: boolean 
     41  */ 
     42define('COMMUNITY_ALLOW_COMMUNITY_TYPE_MEMBERS',false); 
    3743?> 
  • devel/mod/community/lib/communities_edit.php

    r1087 r1095  
    1010                               JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
    1111                               WHERE f.owner = ? AND u.user_type = ?', array($user_id,'community')); 
    12  
    13 END; 
    1412    $i = 1; 
    1513    if (!empty($result)) { 
     
    1917            $friends_name = user_name($info->ident); 
    2018            $info->icon = run("icons:get",$info->ident); 
    21             $friends_menu = run("users:infobox:menu",array($info->ident)); 
     19            $friends_menu = run("community:infobox:menu",array($info)); 
    2220            $friends_icon = user_icon_html($info->ident,COMMUNITY_ICON_SIZE); 
    2321            $link = $CFG->wwwroot.$info->username."/"; 
    24             $functions = array(); 
    25             $members = get_records("friends","friend",$info->ident); 
    26             $membercount = count($members); 
    27             $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/community/members\">".__gettext("Members")."&nbsp;(".$membercount.")</a>"; 
    28             if($info->owner == $_SESSION['userid']){ 
    29                 $_body = &$owned; 
    30                 $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/profile\">".__gettext("Administrate")."</a>"; 
    31                 $msg= "onclick=\"return confirm('". addslashes(__gettext("Are you sure you want to delete this community?")) ."')\""; 
    32                 $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/community/delete\" $msg>".__gettext("Delete")."</a>"; 
    33                 if ($user_id != $_SESSION['userid']) { 
    34                     $_body = &$member; 
    35                     $msg= "onclick=\"return confirm('". addslashes(__gettext("Are you sure you want to separate this user from the community?")) ."')\""; 
    36                     $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/community/separate/".$user_id."\" $msg>".__gettext("Separate")."</a>"; 
    37                 } 
     22            if ($info->owner == $user_id) { 
     23              $_body = & $owned; 
     24            } else { 
     25              $_body = & $member; 
    3826            } 
    39             $functions = implode("\n",array_map(create_function('$entry',"return \"<li>\$entry</li>\";"),$functions)); 
    4027            $_body[] = templates_draw(array( 
    4128                                        'context' => 'community_member', 
     
    4330                                        'icon' => $friends_icon, 
    4431                                        'link' => $link, 
    45                                         'functions' => $functions 
     32                                        'functions' => $friends_menu 
    4633                                      ) 
    4734                        ); 
     
    5340          array_walk($member,create_function('&$body,$i',$separator_function)); 
    5441          $separator="<td $colspan>$memberlabel</td></tr><tr>"; 
    55           $memberlabel = "<h2>".__gettext("Communities to which I belong")."</h2>"; 
     42          //$memberlabel = "<h2>".__gettext("Communities to which I belong")."</h2>"; 
     43          $memberlabel = "<h2>".sprintf(__gettext("Communities were %s belongs"),user_info('name',$user_id))."</h2>"; 
    5644          if(!empty($owned)){ 
    57             $body="<td $colspan><h2>".__gettext("Owned Communities")."</h2></td></tr><tr>"; 
     45            $body="<td $colspan><h2>".sprintf(__gettext("Communities owned by %s"),user_info('name',$user_id))."</h2></td></tr><tr>"; 
    5846            $body.= implode("\n",$owned); 
    5947            $separator="<td $colspan><hr>$memberlabel</td></tr><tr>"; 
     
    6957          $body = implode("\n",$member); 
    7058        } 
    71  
    7259    } else { 
    7360        if ($user_id == $_SESSION['userid']) { 
  • devel/mod/community/lib/communities_members.php

    r1087 r1095  
    22global $CFG; 
    33// Given a user ID as a parameter, will display a list of communities 
     4 
    45 
    56if (isset($parameter[0])) { 
     
    910    $community_owner = user_info('owner',$community_id); 
    1011 
    11     $result = get_records_sql('SELECT u.*, f.ident AS friendident FROM '.$CFG->prefix.'friends f 
     12    if(COMMUNITY_ALLOW_COMMUNITY_TYPE_MEMBERS){ 
     13      $result = get_records_sql('SELECT u.*, f.ident AS friendident FROM '.$CFG->prefix.'friends f 
     14                               JOIN '.$CFG->prefix.'users u ON u.ident = f.owner 
     15                               WHERE f.friend = ?',array($community_id)); 
     16       
     17    } 
     18    else{ 
     19      $result = get_records_sql('SELECT u.*, f.ident AS friendident FROM '.$CFG->prefix.'friends f 
    1220                               JOIN '.$CFG->prefix.'users u ON u.ident = f.owner 
    1321                               WHERE f.friend = ? AND u.user_type = ?',array($community_id,'person')); 
     22    } 
    1423 
    1524    $i = 1; 
     
    2231            // $friends_menu = run("users:infobox:menu",array($info->ident)); 
    2332            $functions = array(); 
    24             if($community_owner != $info->ident && 
    25                 $community_owner == $_SESSION['userid']){ 
     33            if($community_owner != $info->ident && $community_owner == $_SESSION['userid']){ 
    2634                $msg= "onclick=\"return confirm('". __gettext("Are you sure you want to separate this user from the community?") ."')\""; 
    2735                $functions[] = "<a href=\"".$CFG->wwwroot.$community_name."/community/separate/".$info->ident."\" $msg>".__gettext("Separate")."</a>"; 
    2836            } 
    29             else if ($community_owner == $info->ident)
    30                 $functions[] = "<b>(".__gettext("Owner").")</b>"; 
     37            else if($community_owner == $info->ident)
     38              $functions[] = "<b>(".__gettext("Owner").")</b>"; 
    3139            } 
    32             //@todo Add the funcionality to add admin users. 
    3340 
    3441            $functions = implode("\n",array_map(create_function('$entry',"return \"<li>\$entry</li>\";"),$functions)); 
  • devel/mod/community/lib/communities_membership_requests.php

    r1080 r1095  
    11<?php 
    22global $CFG; 
     3 
    34$body = ''; 
    45    // Lists membership requests for a community 
  • devel/mod/community/lib/communities_moderator_of.php

    r1087 r1095  
    1616            $friends_name = user_name($info->ident); 
    1717            $info->icon = run("icons:get",$info->ident); 
    18             // $friends_menu = run("users:infobox:menu",array($info->ident)); 
     18            $friends_menu = run("community:infobox:menu",array($info)); 
    1919            $friends_icon = user_icon_html($info->ident,COMMUNITY_ICON_SIZE); 
    2020            $link = $CFG->wwwroot.$info->username."/"; 
    21             $functions = array(); 
    22             $members = get_records("friends","friend",$info->ident); 
    23             $membercount = count($members); 
    24             $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/community/members\">".__gettext("Members")."&nbsp;(".$membercount.")</a>"; 
    25             if ($info->owner == $_SESSION['userid']) { 
    26                 $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/profile\">".__gettext("Administrate")."</a>"; 
    27                 $msg= "onclick=\"return confirm('". __gettext("Are you sure you want to delete this community?") ."')\""; 
    28                 $functions[] = "<a href=\"".$CFG->wwwroot.$info->username."/community/delete\" $msg>".__gettext("Delete")."</a>"; 
    29             } 
    3021 
    31             $functions = implode("\n",array_map(create_function('$entry',"return \"<li>\$entry</li>\";"),$functions)); 
    3222            $body .= templates_draw(array( 
    3323                                        'context' => 'community_member', 
     
    3525                                        'icon' => $friends_icon, 
    3626                                        'link' => $link, 
    37                                         'functions' => $functions 
     27                                        'functions' => $friends_menu 
    3828                                      ) 
    3929                        ); 
     
    5949 
    6050} 
    61  
    6251?> 
  • devel/mod/community/lib/community_memberships.php

    r1087 r1095  
    22global $CFG; 
    33global $page_owner; 
    4  
     4  
    55if ($page_owner != -1) { 
    66    if (user_type($page_owner) == "person" || user_type($page_owner) == "external") { 
  • devel/mod/community/lib/permissions_check.php

    r1094 r1095  
    4545            if (record_exists('users','ident',$owner,'owner',$USER->ident,'user_type','community')) { 
    4646                $run_result = true; 
    47             }/* 
     47            } 
    4848            if (empty($run_result)) { 
     49                /* 
    4950                if (count_records_sql('SELECT count(u.ident) FROM '.$CFG->prefix.'friends f 
    5051                                                 JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
     
    5354                    $run_result = true; 
    5455                } 
    55             }*/ 
     56                */ 
     57            } 
    5658            break; 
    5759        case    "userdetails:change": 
  • devel/mod/community/members.php

    r1080 r1095  
    1818 
    1919    // Whose friends are we looking at? 
    20         global $page_owner
     20        global $page_owner,$profile_id
    2121 
    2222    // You must be logged on to view this!