Changeset 1080

Show
Ignore:
Timestamp:
04/23/07 13:34:08 (1 year ago)
Author:
ben
Message:

Integrating Diego Ramirez's work to migrate the communities code into /mod/community.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/htaccess-dist

    r1077 r1080  
    9898RewriteRule ^([A-Za-z0-9]+)\/foaf\/?$ _friends/foaf.php?friends_name=$1 
    9999 
    100 RewriteRule ^([A-Za-z0-9]+)\/communities\/?$ _communities/index.php?friends_name=$1 
    101 RewriteRule ^community\/([0-9]+)\/?$ _communities/community.php?community_id=$1 
     100RewriteRule ^([A-Za-z0-9]+)\/communities\/?$ mod/community/index.php?friends_name=$1 
     101RewriteRule ^([A-Za-z0-9]+)\/communities\/owned$ mod/community/owned.php?profile_name=$1 
     102RewriteRule ^([A-Za-z0-9]+)\/communities\/new$ mod/community/new.php?profile_name=$1 
     103RewriteRule ^([A-Za-z0-9]+)\/community\/delete$ mod/community/index.php?profile_name=$1&action=community:delete 
     104RewriteRule ^([A-Za-z0-9]+)\/community\/requests$ mod/community/requests.php?profile_name=$1 
     105RewriteRule ^([A-Za-z0-9]+)\/community\/requests\/aprove\/([0-9]+)$ mod/community/requests.php?profile_name=$1&action=community:approve:request&request_id=$2 
     106RewriteRule ^([A-Za-z0-9]+)\/community\/requests\/decline\/([0-9]+)$ mod/community/requests.php?profile_name=$1&action=community:decline:request&request_id=$2 
     107RewriteRule ^([A-Za-z0-9]+)\/community\/members$ mod/community/members.php?profile_name=$1 
     108RewriteRule ^([A-Za-z0-9]+)\/community\/separate\/([0-9]+)$ mod/community/members.php?profile_name=$1&friend_id=$2&action=separate 
     109RewriteRule ^community\/([0-9]+)\/?$ mod/communities/community.php?community_id=$1 
    102110 
    103111RewriteRule ^([A-Za-z0-9]+)\/files\/?$ _files/index.php?files_name=$1 
  • devel/includes_system.php

    r1077 r1080  
    2929        include($CFG->dirroot . "units/files/main.php"); 
    3030                 
    31     // Communities 
    32         require($CFG->dirroot . "units/communities/main.php"); 
    33          
    3431    // Friends 
    3532        include($CFG->dirroot . "units/friends/main.php"); 
  • devel/mod/community/lib.php

    r1010 r1080  
    11<?php 
     2// Communities module 
     3 
     4/* 
     5A brief explanation: 
     6 
     7Communities are a specialisation of users. Each community is just another 
     8row in the users table, albeit with user_type set to 'community', which 
     9allows it to have all the features of a regular user. 
     10 
     11Friendships are stored in the same way too, but displayed as memberships. 
     12The 'owner' field of the users table stores the moderator for a community 
     13(for regular users it's set to -1). 
     14 
     15TO DO: 
     16 
     17  - Allow a moderator to restrict access to communities 
     18  - Allow moderators to delete all weblog postings and file uploads 
     19 
     20*/ 
    221 
    322function community_pagesetup() { 
    4     // register links --  
     23    // register links -- 
    524    global $profile_id; 
    625    global $PAGE; 
    726    global $CFG; 
    827    global $USER; 
     28    global $metatags; 
     29 
     30    require_once (dirname(__FILE__)."/default_template.php"); 
     31    require_once (dirname(__FILE__)."/lib/communities_config.php"); 
     32 
     33    $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/community/css.css\" type=\"text/css\" media=\"screen\" />"; 
    934 
    1035    $page_owner = $profile_id; 
    11      
     36 
    1237    $usertype = user_type($page_owner); 
    1338 
     39    $username= user_info('username', $page_owner); 
     40 
    1441    if ($usertype == "community") { 
    15              
     42 
    1643        if (defined("context") && context == "profile") { 
    1744 
    1845            if (run("permissions:check", "profile")) { 
    19                  
    20                 $PAGE->menu_sub[] = array( 'name' => 'profile:edit',  
     46 
     47                // Edit community functions 
     48                $PAGE->menu_sub[] = array( 'name' => 'profile:edit', 
    2149                                       'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$page_owner.'">' 
    22                                        . __gettext("Edit this profile") . '</a>'); 
    23                  
     50                                       . __gettext("Edit community profile") . '</a>'); 
     51 
    2452                $PAGE->menu_sub[] = array( 'name' => 'community:pic', 
    2553                                           'html' => a_href("{$CFG->wwwroot}_icons/?context=profile&amp;profile_id=$page_owner" , 
    2654                                                              __gettext("Community site picture"))); 
    27                  
     55 
    2856                $PAGE->menu_sub[] = array( 'name' => 'community:edit', 
    2957                                           'html' => a_href("{$CFG->wwwroot}_userdetails/?context=profile&amp;profile_id=$page_owner" , 
    3058                                                             __gettext("Edit community details"))); 
     59            } 
    3160 
    32             } 
    33              
    3461        } 
    35         if (defined("context") && (context == "profile" || context == "network")) { 
    36             if (run("permissions:check", "profile")) { 
    37                 $PAGE->menu_sub[] = array( 'name' => 'community:requests', 
    38                                            'html' => a_href("{$CFG->wwwroot}_communities/requests.php?profile_id=$page_owner", 
    39                                                              __gettext("View membership requests"))); 
     62 
     63        if (defined("context") && (context == "profile" || context == COMMUNITY_CONTEXT)) { 
     64          if (run("permissions:check", "profile")) { 
     65              if(context == COMMUNITY_CONTEXT){ 
     66              $PAGE->menu_sub[] = array( 'name' => 'profile:view', 
     67                                         'html' => a_href("{$CFG->wwwroot}{$username}/profile", 
     68                                         __gettext("Return to community profile"))); 
     69              } 
     70 
     71              $PAGE->menu_sub[] = array( 'name' => 'community:adminmembers', 
     72                                         'html' => a_href("{$CFG->wwwroot}{$username}/community/members", 
     73                                         __gettext("Edit members"))); 
     74 
     75              $PAGE->menu_sub[] = array( 'name' => 'community:requests', 
     76                                         'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", 
     77                                                           __gettext("View membership requests"))); 
    4078            } 
    4179        } 
    42          
    43         /*$PAGE->menu_sub[] = array( 'name' => 'community:members', 
    44                                    'html' => a_href("{$CFG->wwwroot}_communities/members.php?owner=$page_owner" , 
    45                                                       __gettext("Community Members")));*/ 
    46                                                        
    47          
    4880    } else if ($usertype == "person") { 
    49      
    50         if (defined("context") && context == "network") { 
    51      
     81 
     82        if (defined("context") && context == COMMUNITY_CONTEXT) { 
     83          if(COMMUNITY_COMPACT_VIEW){ 
    5284            $PAGE->menu_sub[] = array( 'name' => 'community', 
    53                                        'html' => a_href("{$CFG->wwwroot}_communities/?owner=$page_owner" , 
    54                                                           __gettext("Communities")));  
     85                                     'html' => a_href("{$CFG->wwwroot}{$username}/communities" , 
     86                                                        __gettext("Communities"))); 
     87 
     88            if (logged_on && $page_owner == $_SESSION['userid'] && 
     89                ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident))) { 
     90              $PAGE->menu_sub[] = array( 'name' => 'community:owned', 
     91                                     'html' => a_href("{$CFG->wwwroot}{$username}/communities/new" , 
     92                                                        __gettext("New Community"))); 
     93            } 
     94          } 
     95          else{ 
     96            $PAGE->menu_sub[] = array( 'name' => 'community', 
     97                                     'html' => a_href("{$CFG->wwwroot}{$username}/communities" , 
     98                                                        __gettext("Communities"))); 
     99 
    55100            if ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident)) { 
    56             $PAGE->menu_sub[] = array( 'name' => 'community:owned', 
    57                                        'html' => a_href("{$CFG->wwwroot}_communities/owned.php?owner=$page_owner" , 
    58                                                           __gettext("Owned Communities"))); 
     101              $PAGE->menu_sub[] = array( 'name' => 'community:owned', 
     102                                     'html' => a_href("{$CFG->wwwroot}{$username}/communities/owned" , 
     103                                                        __gettext("Owned Communities"))); 
    59104            } 
     105          } 
    60106        } 
    61          
    62107    } 
    63      
     108 
    64109    $PAGE->search_menu[] = array( 'name' => __gettext("Communities"), 
    65110                                  'user_type' => 'community'); 
     
    68113 
    69114function community_init() { 
     115        global $CFG,$function; 
     116 
     117    // Add communities to access levels 
     118        $function['init'][] = $CFG->dirroot . "mod/community/lib/communities_access_levels.php"; 
     119        $function['userdetails:init'][] = $CFG->dirroot . "mod/community/lib/userdetails_actions.php"; 
     120 
     121    // Communities actions 
     122        $function['communities:init'][] = $CFG->dirroot . "mod/community/lib/communities_config.php"; 
     123        $function['communities:init'][] = $CFG->dirroot . "mod/community/lib/communities_actions.php"; 
     124 
     125    // Communities modifications of friends actions 
     126        //$function['friends:init'][] = $CFG->dirroot . "mod/community/lib/communities_actions.php"; 
     127 
     128    // Communities bar down the right hand side 
     129        $function['display:sidebar'][] = $CFG->dirroot . "mod/community/lib/communities_owned.php"; 
     130        $function['display:sidebar'][] = $CFG->dirroot . "mod/community/lib/community_memberships.php"; 
     131 
     132    // 'Communities' aspect to the little menus beneath peoples' icons 
     133        $function['users:infobox:menu:text'][] = $CFG->dirroot . "mod/community/lib/user_info_menu_text.php"; 
     134 
     135    // Permissions for communities 
     136        $function['permissions:check'][] = $CFG->dirroot . "mod/community/lib/permissions_check.php"; 
     137 
     138    // View community memberships 
     139        $function['communities:editpage'][] = $CFG->dirroot . "mod/community/lib/communities_edit_wrapper.php"; 
     140        $function['communities:edit'][] = $CFG->dirroot . "mod/community/lib/communities_edit.php"; 
     141        $function['communities:members'][] = $CFG->dirroot . "mod/community/lib/communities_members.php"; 
     142        $function['communities:owned'][] = $CFG->dirroot . "mod/community/lib/communities_moderator_of.php"; 
     143        $function['communities:owned'][] = $CFG->dirroot . "mod/community/lib/communities_create.php"; 
     144        $function['communities:create'][] = $CFG->dirroot . "mod/community/lib/communities_create.php"; 
     145 
     146    // Membership requests 
     147        $function['communities:requests:view'][] = $CFG->dirroot . "mod/community/lib/communities_membership_requests.php"; 
     148 
     149    // Check access levels 
     150        $function['users:access_level_check'][] = $CFG->dirroot . "mod/community/lib/communities_access_level_check.php"; 
     151 
     152    // Obtain SQL "where" string for access levels 
     153        $function['users:access_level_sql_where'][] = $CFG->dirroot . "mod/community/lib/communities_access_level_sql_check.php"; 
     154 
     155    // Link to edit icons 
     156        $function['profile:edit:link'][] = $CFG->dirroot . "mod/community/lib/profile_edit_link.php"; 
     157 
     158    // Edit profile details 
     159        $function['userdetails:edit'][] = $CFG->dirroot . "mod/community/lib/userdetails_edit.php"; 
     160 
    70161    // Delete users 
    71162        listen_for_event("user","delete","community_user_delete"); 
     
    79170            $newsuser = -1; 
    80171        } 
    81              
     172 
    82173        if ($communities = get_records_sql("select * from {$CFG->prefix}users where owner = {$object->ident}")) { 
    83174            foreach($communities as $community) { 
     
    92183        } 
    93184    } 
     185//          $members = get_records("friends","friend",$page_owner); 
     186 
    94187    return $object; 
    95188}