| | 182 | |
|---|
| | 183 | // Register file river hook (if there) |
|---|
| | 184 | if (function_exists('river_save_event')) |
|---|
| | 185 | { |
|---|
| | 186 | listen_for_event('community','publish', 'community_river_hook'); |
|---|
| | 187 | listen_for_event('community','delete', 'community_river_hook'); |
|---|
| | 188 | |
|---|
| | 189 | river_register_friendlyname_hook('community::community', 'community_get_friendly_name'); |
|---|
| | 190 | } |
|---|
| | 191 | |
|---|
| | 192 | } |
|---|
| | 193 | |
|---|
| | 194 | function community_get_friendly_name($object_type, $object_id) |
|---|
| | 195 | { |
|---|
| | 196 | global $CFG; |
|---|
| | 197 | |
|---|
| | 198 | if ($object_type == 'community::community') |
|---|
| | 199 | { |
|---|
| | 200 | $record = get_record_sql("SELECT * from {$CFG->prefix}users where ident=$object_id and user_type = 'community'"); |
|---|
| | 201 | |
|---|
| | 202 | if ($record) |
|---|
| | 203 | { |
|---|
| | 204 | $community = user_info("name", $record->ident); |
|---|
| | 205 | $url = river_get_userurl($record->ident); |
|---|
| | 206 | |
|---|
| | 207 | return sprintf(__gettext("the community <a href=\"$url\">%s</a>"), $community); |
|---|
| | 208 | } |
|---|
| | 209 | } |
|---|
| | 210 | |
|---|
| | 211 | return ""; |
|---|
| | 212 | } |
|---|
| | 213 | |
|---|
| | 214 | function community_river_hook( $object_type, $event, $object) |
|---|
| | 215 | { |
|---|
| | 216 | global $CFG; |
|---|
| | 217 | |
|---|
| | 218 | $userid = ($_SESSION['userid'] == "" ? -1 : $_SESSION['userid']); |
|---|
| | 219 | $object_id = $object->ident; |
|---|
| | 220 | $object_owner = $object->owner; |
|---|
| | 221 | $title = trim($object->name); |
|---|
| | 222 | |
|---|
| | 223 | $username = user_info("name", $userid); |
|---|
| | 224 | $weblogname = "<a href=\"" . river_get_userurl($userid) . "\">". user_info("name", $object_id) . "</a>'s"; |
|---|
| | 225 | if ($userid == $object_owner) $weblogname = __gettext("their"); |
|---|
| | 226 | |
|---|
| | 227 | if ($username == false) $username = __gettext("Anonymous user"); |
|---|
| | 228 | |
|---|
| | 229 | if ($event == "publish") |
|---|
| | 230 | 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>."); |
|---|
| | 231 | |
|---|
| | 232 | return $object; |
|---|