Changeset 1281

Show
Ignore:
Timestamp:
11/08/07 21:39:01 (1 year ago)
Author:
rho
Message:

restored previous fixes and tweaks on community mod

Sign-off-by: Rolando Espinoza La Fuente <rho@prosotpeople.com>

Files:

Legend:

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

    r1248 r1281  
    8787            } 
    8888        } 
     89         
     90        if (defined("context") && context == "profile") { 
     91 
     92            if (run("permissions:check", "profile")) { 
     93                 
     94                if (!empty($CFG->uses_YUI)) { 
     95                    $PAGE->menu_sub[] = array( 'name' => 'profile:widget:manage', 
     96                        'html' => '<a href="'.$CFG->wwwroot.'mod/widget/manage_widgets.php?owner='.$page_owner.'">' 
     97                        . __gettext("Manage widgets") . '</a>'); 
     98                } else { 
     99                    $PAGE->menu_sub[] = array( 'name' => 'profile:widget:add', 
     100                        'html' => '<a href="'.$CFG->wwwroot.'mod/profile/add.php?owner='.$page_owner.'">' 
     101                        . __gettext("Add widget") . '</a>'); 
     102                 
     103            } 
     104     
     105            } 
     106        } 
     107         
    89108    } else if ($usertype == "person") { 
    90109 
     
    182201    // Delete users 
    183202        listen_for_event("user","delete","community_user_delete"); 
     203         
     204    // Register file river hook (if there) 
     205        if (function_exists('river_save_event')) 
     206        { 
     207                listen_for_event('community','publish', 'community_river_hook'); 
     208                listen_for_event('community','delete', 'community_river_hook'); 
     209     
     210                river_register_friendlyname_hook('community::community', 'community_get_friendly_name'); 
     211        } 
     212         
     213} 
     214 
     215function community_get_friendly_name($object_type, $object_id) 
     216{ 
     217        global $CFG; 
     218 
     219        if ($object_type == 'community::community') 
     220        { 
     221                $record = get_record_sql("SELECT * from {$CFG->prefix}users where ident=$object_id and user_type = 'community'"); 
     222 
     223                if ($record) 
     224                { 
     225                        $community = user_info("name", $record->ident); 
     226                        $url = river_get_userurl($record->ident); 
     227                         
     228                        return sprintf(__gettext("the community <a href=\"$url\">%s</a>"), $community); 
     229                } 
     230        } 
     231 
     232        return ""; 
     233} 
     234 
     235function community_river_hook( $object_type, $event, $object) 
     236{ 
     237        global $CFG; 
     238 
     239        $userid = ($_SESSION['userid'] == "" ? -1 : $_SESSION['userid']); 
     240        $object_id = $object->ident; 
     241        $object_owner = $object->owner; 
     242        $title = trim($object->name); 
     243 
     244        $username = user_info("name", $userid); 
     245        $weblogname = "<a href=\"" . river_get_userurl($userid) . "\">". user_info("name", $object_id) . "</a>'s"; 
     246        if ($userid == $object_owner) $weblogname = __gettext("their"); 
     247 
     248        if ($username == false) $username = __gettext("Anonymous user"); 
     249         
     250        if ($event == "publish") 
     251                river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" .  river_get_userurl($userid) . "\">$username</a> created the community <a href=\"{$CFG->wwwroot}{$object->username}\">{$object->name}</a>."); 
     252 
     253        return $object; 
    184254} 
    185255 
  • devel/mod/community/lib/communities_actions.php

    r1248 r1281  
    4343                        $rssresult = run("profile:rss:publish", array($cid, false)); 
    4444 
     45                        // add owner as member 
     46                        $f = new StdClass; 
     47                        $f->owner = $USER->ident; 
     48                        $f->friend = $cid; 
     49                        insert_record('friends',$f); 
     50 
    4551                        plugin_hook("community","publish",$c); 
    4652                        $messages[] = __gettext("Your community was created and you were added as its first member."); 
     
    6773 
    6874        case "community:delete": 
    69             if (run("permissions:check",array("userdetails:change", $page_owner))) { 
    70                 if (user_delete($page_owner)) { 
    71                     plugin_hook("community","publish",$page_owner); 
     75            $community_id = optional_param('community_id',0,PARAM_INT); 
     76            if (run("permissions:check",array("userdetails:change", $community_id))) { 
     77                if (user_delete($community_id)) { 
     78                    // plugin_hook("community","publish",$community_id); 
    7279                    $messages[] = __gettext("The community was deleted."); 
    7380                } else { 
  • devel/mod/community/lib/communities_moderator_of.php

    r1248 r1281  
    1717            $info->icon = run("icons:get",$info->ident); 
    1818            $friends_menu = run("community:infobox:menu",array($info)); 
     19            if (run("permissions:check",array("userdetails:change", $info->ident))) { 
     20                $friends_menu .= "<a href=\"{$CFG->wwwroot}mod/community/index.php?community_id=".$info->ident."&amp;action=community:delete\" onClick=\"return confirm('".__gettext('Are you sure you want to delete this community?')."');\">Delete community</a>"; 
     21            } 
    1922            $friends_icon = user_icon_html($info->ident,COMMUNITY_ICON_SIZE); 
    2023            $link = $CFG->wwwroot.$info->username."/";