| | 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 | |
|---|
| | 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 | |
|---|
| | 215 | function 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 | |
|---|
| | 235 | function 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; |
|---|