Changeset 224
- Timestamp:
- 02/10/09 11:55:00 (19 months ago)
- Location:
- trunk/sites/all/modules/og
- Files:
-
- 6 removed
- 16 modified
- 4 copied
-
. (modified) (1 prop)
-
CVS (deleted)
-
LICENSE.txt (copied) (copied from trunk/sites/all/modules/og/LICENSE.txt)
-
README.txt (modified) (1 diff)
-
includes/CVS (deleted)
-
includes/groupcontent.inc (modified) (2 diffs)
-
includes/groupcontext.inc (modified) (2 diffs)
-
og.info (modified) (1 diff)
-
og.install (modified) (14 diffs)
-
og.module (modified) (76 diffs)
-
og_access.info (modified) (1 diff)
-
og_access.module (modified) (6 diffs)
-
og_notifications (deleted)
-
og_panels.info (modified) (1 diff)
-
og_panels.install (modified) (2 diffs)
-
og_panels.module (modified) (10 diffs)
-
og_views.inc (modified) (49 diffs)
-
og_workflow_ng.inc (modified) (5 diffs)
-
og_xmlrpc.inc (modified) (2 diffs)
-
po/CVS (deleted)
-
po/de.po (modified) (2 diffs)
-
po/general.pot (copied) (copied from trunk/sites/all/modules/og/po/general.pot)
-
po/og-module.pot (copied) (copied from trunk/sites/all/modules/og/po/og-module.pot)
-
po/og.pot (deleted)
-
po/og_views-inc.pot (copied) (copied from trunk/sites/all/modules/og/po/og_views-inc.pot)
-
tests/CVS (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sites/all/modules/og
- Property svn:mergeinfo
-
old new 1 /branches/kester/current/sites/all/modules/og:126-131,1892 /external/current/sites/all/modules/messaging/og:1303 /external/current/sites/all/modules/og:127,129,188
-
- Property svn:mergeinfo
-
trunk/sites/all/modules/og/README.txt
r152 r224 42 42 INTEGRATION 43 43 --------------------- 44 - I recommend enabling the job_queue.module. When you do, group email notifications are sent during cron runs, instead of immediately after a post is submitted. This speeds up posting a lot, for big groups. The delay also helps authors fix typos in their posts before the mail is sent. 44 45 - This module exposes an API for retrieving and managing membership via direct PHP functions [og_save_subscription()] and via XMLRPC. 45 - Enabling og_notifications provides subscription support for groups and group46 posts. The README in the og_notifications directory provides more information.47 46 48 47 UNIT TESTING -
trunk/sites/all/modules/og/includes/groupcontent.inc
r152 r224 6 6 'icon' => 'user-multiple.png', 7 7 'path' => drupal_get_path('module', 'og_panels'). '/', 8 'description' => t('The welcome message for the group. Specified on group edit form .'),8 'description' => t('The welcome message for the group. Specified on group edit form'), 9 9 'required context' => new panels_required_context(t('Group'), 'group'), 10 10 'category' => array(t('Organic groups'), -10), … … 184 184 '#type' => 'textfield', 185 185 '#title' => t('Number of members'), 186 '#description' => t('Maximum number of members that should appear on the list .'),186 '#description' => t('Maximum number of members that should appear on the list'), 187 187 '#default_value' => isset($conf['num_items']) ? $conf['num_items'] : 10, 188 188 '#size' => 5, -
trunk/sites/all/modules/og/includes/groupcontext.inc
r152 r224 1 1 <?php 2 // $Id: groupcontext.inc,v 1.1.2. 4 2008/05/26 14:03:35weitzman Exp $2 // $Id: groupcontext.inc,v 1.1.2.3 2008/03/22 21:50:52 weitzman Exp $ 3 3 /** 4 4 * @file contexts/group.inc … … 35 35 '#type' => 'checkbox', 36 36 '#default_value' => $conf['external'], 37 '#title' => t('Require this context from an external source (such as containing panel page) .'),37 '#title' => t('Require this context from an external source (such as containing panel page)'), 38 38 '#description' => t('If selected, group selection (below) will be ignored'), 39 39 ); -
trunk/sites/all/modules/og/og.info
r152 r224 3 3 package = "Organic groups" 4 4 dependencies = views views_rss 5 ; Information added by drupal.org packaging script on 2008-05-12 6 version = "5.x-7.2" 7 project = "og" 8 datestamp = "1210629035" 9 -
trunk/sites/all/modules/og/og.install
r152 r224 1 1 <?php 2 // $Id: og.install,v 1.21.2.3 2.2.8 2008/10/09 15:06:14weitzman Exp $2 // $Id: og.install,v 1.21.2.31 2008/05/05 21:27:57 weitzman Exp $ 3 3 4 4 function og_install() { … … 13 13 register int(1) NOT NULL default 0, 14 14 directory int(1) NOT NULL default 0, 15 notification int(1) NOT NULL default 0, 15 16 language varchar(12) NOT NULL default '', 16 17 private int(1) NOT NULL default 0, … … 24 25 is_admin int(1) NOT NULL DEFAULT 0, 25 26 uid int(11) NOT NULL, 26 created int(11) NULL DEFAULT 0, 27 changed int(11) NULL DEFAULT 0, 27 mail_type int(11) NULL, 28 created int(11) NULL DEFAULT 0, 29 changed int(11) NULL DEFAULT 0, 28 30 PRIMARY KEY (nid, uid) 29 31 ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); 30 32 33 db_query("CREATE TABLE {og_uid_global} ( 34 uid int(11) NOT NULL, 35 og_email int(11) NOT NULL DEFAULT 2, 36 PRIMARY KEY (uid) 37 ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); 31 38 db_query("CREATE TABLE {og_ancestry} ( 32 39 nid int(11) NOT NULL, … … 46 53 register smallint NOT NULL default 0, 47 54 directory smallint NOT NULL default 0, 55 notification smallint NOT NULL default 0, 48 56 language varchar(12) NOT NULL default '', 49 57 private smallint NOT NULL default 0, … … 57 65 is_admin smallint NOT NULL DEFAULT 0, 58 66 uid int NOT NULL, 59 created int NULL DEFAULT 0, 60 changed int NULL DEFAULT 0, 67 mail_type int NULL, 68 created int NULL DEFAULT 0, 69 changed int NULL DEFAULT 0, 61 70 PRIMARY KEY (nid, uid) 62 71 );"); 63 72 64 db_query("CREATE TABLE {og_ancestry} ( 73 db_query("CREATE TABLE {og_uid_global} ( 74 uid int NOT NULL, 75 og_email int NOT NULL DEFAULT 2, 76 PRIMARY KEY (uid) 77 );"); 78 79 db_query(" 80 CREATE TABLE {og_ancestry} ( 65 81 nid int NOT NULL, 66 82 group_nid int NOT NULL, … … 73 89 74 90 // enable standard og blocks. for custom profiles, block may not be included yet. 75 if (function_exists(' _block_rehash')) {91 if (function_exists('block_rehash')) { 76 92 _block_rehash(); 77 93 } … … 296 312 } 297 313 298 // populate the og_uid_global table. we have to choose selective here for 299 // backward compatibility. To set everyone up for 'always' notifications, run 300 // this after the update: UPDATE og_uid_global SET og_email=1 301 // og_uid_global is later moved into og_notifications. This update is only 302 // around to retain schema consistency - the population script has been removed. 314 // populate the og_uid_global table. we have to choose selective here for backward compatibility. 315 // to set everyone up for 'always' notifications, run this after the update: UPDATE og_uid_global SET og_email=1 303 316 function og_update_13() { 304 317 switch ($GLOBALS['db_type']) { … … 319 332 break; 320 333 } 321 334 335 // works for mysql and postgres 336 $sql = 'SELECT uid FROM {users} WHERE uid > 0'; 337 $result = db_query($sql); 338 while ($row = db_fetch_object($result)) { 339 $sql = "INSERT INTO {og_uid_global} (uid, og_email) VALUES (%d, %d)"; 340 db_query($sql, $row->uid, OG_NOTIFICATION_SELECTIVE); 341 } 322 342 return array(); 323 343 } … … 404 424 } 405 425 406 // Formerly contained og_uid_global code which is no longer required.407 426 function og_update_19() { 408 return array(); 427 og_populate_uid_global_table(); 428 return array('Populated og_uid_global table'); 409 429 } 410 430 … … 444 464 $ret = array(); 445 465 if (variable_get('og_enabled', FALSE) && !module_exists('og_access')) { 446 drupal_install_modules(array('og_access'));466 module_enable('og_access'); 447 467 } 448 468 // variable_del('og_enabled'); is harmless to leave around, and will help if someone reruns the update. … … 477 497 return $ret; 478 498 } 479 480 /** 481 * Force menu rebuild since subscribe/unsubscribe paths are better protected now. 482 */ 483 function og_update_5702() { 484 $ret[] = array('success' => TRUE, 'query' => 'Menu has been rebuilt.'); 485 menu_rebuild(); 486 return $ret; 487 } 488 489 /** 490 * Notifications upgrade: Set flag to indicate that this is an upgraded 491 * installation. 492 */ 493 function og_update_5703() { 494 // Remove mail / no mail options from OG group types and move preferences to 495 // og_notifications. 496 $types = og_get_types('group_post'); 497 $mail_types = array(); 498 foreach ($types as $type) { 499 $variable = 'og_content_type_usage_'. $type; 500 $usage = variable_get($variable, ''); 501 switch ($usage) { 502 case 'group_post_standard_mail': 503 $mail_types[$type] = $type; 504 case 'group_post_standard_nomail': 505 variable_set($variable, 'group_post_standard'); 506 break; 507 case 'group_post_wiki_mail': 508 $mail_types[$type] = $type; 509 case 'group_post_wiki_nomail': 510 variable_set($variable, 'group_post_wiki'); 511 break; 512 } 513 } 514 // Set variable for og_notifications. If it is never enabled, this variable 515 // is also deleted in og_uninstall. 516 variable_set('og_notifications_content_types', $mail_types); 517 518 // Vestigial variable. 519 variable_del('og_omitted_email_node_types'); 520 521 // Set update flag for og_notifications. 522 variable_set('og_notifications_update_required', 1); 523 524 return array(); 525 } 526 527 // end updates // 499 500 // end updates // 501 502 function og_enable() { 503 og_populate_uid_global_table(); 504 } 505 506 // need to populate og_uid_global for existing users on enable 507 // this is called from update 13 & 19 & og_enable. 508 // TODO: conditionally use subquery 509 function og_populate_uid_global_table() { 510 $sql = 'SELECT u.uid FROM {users} u LEFT JOIN {og_uid_global} oug ON u.uid=oug.uid WHERE u.uid > 0 AND oug.og_email IS NULL'; 511 $result = db_query($sql); 512 while ($row = db_fetch_object($result)) { 513 $sql = "INSERT INTO {og_uid_global} (uid, og_email) VALUES (%d, %d)"; 514 db_query($sql, $row->uid, OG_NOTIFICATION_SELECTIVE); 515 } 516 } 528 517 529 518 function og_uninstall() { … … 531 520 db_query('DROP TABLE {og}'); 532 521 db_query('DROP TABLE {og_uid}'); 522 db_query('DROP TABLE {og_uid_global}'); 533 523 db_query('DROP TABLE {og_ancestry}'); 534 535 // In case og_notifications has never been enabled, the vestigial536 // og_uid_global table will still be around.537 if (variable_get('og_notifications_update_required', FALSE)) {538 db_query('DROP TABLE {og_uid_global}');539 }540 524 541 525 // Delete variables … … 543 527 'og_member_pics', 'og_help', 'og_block_cnt_2', 'og_block_cnt_3', 544 528 'og_audience_checkboxes', 'og_omitted', 'og_content_type_usage', 545 'og_audience_required', 529 'og_audience_required', 'og_omitted_email_node_types', 546 530 'og_visibility_directory', 'og_visibility_registration', 547 531 'og_home_page_view', 'og_email_max', 'og_node_types', … … 552 536 'og_new_admin_body', 'og_new_admin_subject', 553 537 'og_new_node_body', 'og_new_node_subject', 554 'og_request_user_body', 'og_request_user_subject', 555 'og_notifications_update_required', 'og_notifications_content_types' 538 'og_notification', 'og_request_user_body', 'og_request_user_subject', 556 539 ); 557 540 foreach ($variables as $variable) { -
trunk/sites/all/modules/og/og.module
r190 r224 1 1 <?php 2 // $Id: og.module,v 1.298.2.1 97.2.18 2008/12/30 16:34:33weitzman Exp $2 // $Id: og.module,v 1.298.2.185 2008/05/08 19:49:26 weitzman Exp $ 3 3 4 4 // Selective groups states. chosen by the group admin … … 19 19 define('OG_DIRECTORY_CHOOSE_TRUE', 2); 20 20 define('OG_DIRECTORY_CHOOSE_FALSE', 3); 21 22 // site admin chooses in og_admin_settings() whether new registrants receive group email notifications by default 23 define('OG_NOTIFICATION_NEVER', 0); 24 define('OG_NOTIFICATION_ALWAYS', 1); 25 define('OG_NOTIFICATION_SELECTIVE', 2); 21 26 22 27 function og_help($section) { … … 36 41 if ($may_cache) { 37 42 // anon users should be able to get to the join page 38 $items[] = array('path' => 'og/subscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_ menu_check_node_view', 'access' => TRUE, 'callback arguments' => array('og_subscribe'), 'title' => t('Join group'));43 $items[] = array('path' => 'og/subscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_subscribe', 'access' => TRUE, 'title' => t('Join group')); 39 44 40 45 $items[] = array('path' => 'og/opml', 'type' => MENU_CALLBACK, 'callback' => 'og_opml', 'access' => $access, 'title' => t('OPML')); 41 $items[] = array('path' => 'og/unsubscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_ menu_check_node_view', 'callback arguments' => array('og_unsubscribe'), 'access' => $access, 'title' => t('Leave group'));46 $items[] = array('path' => 'og/unsubscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_unsubscribe', 'access' => $access, 'title' => t('Leave group')); 42 47 $items[] = array('path' => 'og/approve', 'type' => MENU_CALLBACK, 'callback' => 'og_approve', 'access' => $access, 'title' => t('Approve membership request')); 43 48 $items[] = array('path' => 'og/deny', 'type' => MENU_CALLBACK, 'callback' => 'og_deny', 'access' => $access, 'title' => t('Deny membership request')); … … 61 66 'path' => 'admin/og', 62 67 'title' => t('Organic groups'), 63 'description' => t('Administer the suite of organic groups modules.'),68 'description' => t('Administer the suite of Organic groups modules.'), 64 69 'position' => 'right', 65 70 'weight' => -5, … … 73 78 74 79 // we get a NOTICE if doing this from within og_theme() so I do it here for now. 75 if ($group_node = og_get_group_context()) { 76 if ($user->uid || variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) { 77 $_SESSION['og_last'] = $group_node->nid; 78 } 79 } 80 $_SESSION['og_last'] = og_get_group_context(); 80 81 81 82 //membership page and its 'add members' tab … … 91 92 $items[] = array('path' => "og/users/$gid/add_user", 'callback' => 'drupal_get_form', 'title' => t('Add members'), 'callback arguments' => array('og_add_users', $gid), 'type' => MENU_LOCAL_TASK, 'weight' => 5, 'access' => og_is_node_admin($node)); 92 93 } 93 94 // Broadcast tab on group node.94 95 // email tab on group node 95 96 if (arg(0) == 'node' && is_numeric(arg(1))) { 96 97 $node = node_load(arg(1)); 97 98 if (og_is_group_type($node->type)) { 98 $items[] = array( 99 'path' => 'node/'. arg(1) .'/broadcast', 100 'title' => t('Broadcast'), 101 'callback' => 'drupal_get_form', 102 'callback arguments' => array('og_broadcast_form', arg(1)), 103 'access' => og_broadcast_access($node), 104 'type' => MENU_LOCAL_TASK, 105 'weight' => 7 106 ); 99 $items[] = array('path' => 'node/'. arg(1). '/email', 'title' => t('E-mail'), 'callback' => 'drupal_get_form', 'callback arguments' => array('og_email_form', arg(1)), 'access' => og_is_node_admin($node), 'type' => MENU_LOCAL_TASK, 'weight' => 7); 107 100 } 108 101 } … … 126 119 drupal_access_denied(); 127 120 } 128 }129 130 // check for node access 'view' and then pass along to the real menu callback131 // arguments must be in this order: function, $gid, <extra params required by function>132 function og_menu_check_node_view() {133 global $user;134 135 $args = func_get_args();136 $function = array_shift($args);137 $gid = $args[0];138 $node = node_load((int)$gid);139 if (node_access('view', $node)) {140 return call_user_func_array($function, $args);141 }142 else {143 drupal_access_denied();144 }145 146 121 } 147 122 … … 281 256 // node is in multiple groups. preference goes to the group we showed on the prior page view (if any), 282 257 // then to a group the current user is a member of 283 if (in_array($_SESSION['og_last'] , $node->og_groups)) {284 $group_node = node_load($_SESSION['og_last'] );258 if (in_array($_SESSION['og_last']->nid, $node->og_groups)) { 259 $group_node = node_load($_SESSION['og_last']->nid); 285 260 $custom_theme = $group_node->og_theme; 286 261 } … … 305 280 306 281 /** 307 * Admins may broadcast messages to all their members.282 * Admins may broadcast email to all their members 308 283 * 309 284 * @param $gid 310 285 * the nid of a group. 311 286 */ 312 function og_ broadcast_form($gid) {287 function og_email_form($gid) { 313 288 $node = node_load($gid); 314 drupal_set_title(t('Send messageto %group', array('%group' => $node->title)));289 drupal_set_title(t('Send email to %group', array('%group' => $node->title))); 315 290 316 291 $result = db_query(og_list_users_sql(1), $gid); 317 292 $txt = format_plural(db_num_rows($result), 'the sole member', 'all @count members'); 318 293 if (!$_POST) { 319 drupal_set_message(t('Your message will be sent to !count in this group.', array('!count' => l($txt, "og/users/$gid"))));320 } 321 322 $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#size' => 70, '#maxlength' => 250, '#description' => t("Enter a subject for your message."), '#required' => true);323 $form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#rows' => 5, '#cols' => 90, '#description' => t('Enter the body of your message.'), '#required' => true);324 $form['send'] = array('#type' => 'submit', '#value' => t('Send message'));294 drupal_set_message(t('Your email will be sent to !count in this group. Please use this feature sparingly.', array('!count' => l($txt, "og/users/$gid")))); 295 } 296 297 $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#size' => 70, '#maxlength' => 250, '#description' => t("Enter a subject for your email."), '#required' => true); 298 $form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#rows' => 5, '#cols' => 90, '#description' => t('Enter a body for your email.'), '#required' => true); 299 $form['send'] = array('#type' => 'submit', '#value' => t('Send email')); 325 300 $form['gid'] = array('#type' => 'value', '#value' => $gid); 326 301 return $form; 327 302 } 328 303 329 function og_broadcast_form_submit($form_id, $form_values) { 330 global $user; 331 332 $sql = og_list_users_sql(1); 333 $result = db_query($sql, $form_values['gid']); 334 $recipients = array(); 335 while ($row = db_fetch_object($result)) { 336 $recipients[] = $row->uid; 337 } 338 304 function og_email_form_submit($form_id, $form_values) { 339 305 $node = node_load($form_values[gid]); 306 340 307 $variables = array( 341 308 '@group' => $node->title, … … 345 312 '!url_unsubscribe' => url("og/unsubscribe/$node->nid", NULL, NULL, TRUE) 346 313 ); 347 $message = array( 348 'from' => $user, 349 'subject' => $form_values['subject'], 350 'body' => _og_user_mail_text('og_admin_email_body', $variables) 351 ); 352 353 // Send notifications to each member; Sending an array of recipients implies 354 // that this is a bulk message. 355 module_invoke_all('og', 'user broadcast', $gid, $recipients, $message); 356 drupal_set_message(format_plural(count($recipients), '1 message queued for delivery.', '@count messages queued for delivery.')); 357 314 315 global $user; 316 $from = $user->mail; 317 $sql = og_list_users_sql(1); 318 $result = db_query($sql, $form_values['gid']); 319 while ($row = db_fetch_object($result)) { 320 $emails[] = $row->mail; 321 } 322 foreach ($emails as $mail) { 323 drupal_mail('og_mail', trim($mail), $form_values['subject'], _og_user_mail_text('og_admin_email_body', $variables), $from); 324 } 325 drupal_set_message(format_plural(count($emails), '1 email sent.', '@count emails sent')); 358 326 drupal_goto("node/{$form_values[gid]}"); 359 327 } … … 362 330 global $user; 363 331 332 // warn users who can't receive mail anyway 333 if ($txt = user_validate_mail($user->mail)) { 334 drupal_set_message($txt, 'error'); 335 return ''; 336 } 337 364 338 $group = node_load($gid); 365 339 $bc[] = array('path' => "og", 'title' => t('Groups')); … … 388 362 } 389 363 364 switch ($user->og_email) { 365 // og_email can be NULL when you enable og on an existing site. 366 case NULL: 367 case OG_NOTIFICATION_SELECTIVE: 368 $form['mail_type'] = array('#type' => 'radios', '#title' => t('Email notification'), '#default_value' => $user->og_groups[$group->nid]['mail_type'], '#options' => array(1 => t('enabled'), 0 => t('disabled')), '#description' => t('Do you want to receive an email each time a message is posted to this group?')); 369 $submit = TRUE; 370 break; 371 case OG_NOTIFICATION_ALWAYS: 372 $form['mail_type'] = array('#type' => 'item', '#title' => t('Email notification'), '#value' => t('Your <a href="!prof">personal profile</a> is configured to: <em>Always receive email notifications</em>.', array('!prof' => url("user/$user->uid/edit")))); 373 break; 374 case OG_NOTIFICATION_NEVER: 375 $form['mail_type'] = array('#type' => 'item', '#title' => t('Email notification'), '#value' => t('Your <a href="!prof">personal profile</a> is configured to: <em>Never receive email notifications</em>.', array('!prof' => url("user/$user->uid/edit")))); 376 break; 377 } 378 if ($submit) { 379 $form['op'] = array('#type' => 'submit', '#value' => t('Submit')); 380 } 390 381 $form['gid'] = array('#type' => 'value', '#value' => $group->nid); 391 382 return $form; … … 406 397 * @param $uid user ID of user 407 398 * @param $args an array with details of this membership. Possible array keys are: 408 is_active, is_admin, created399 is_active, is_admin, mail_type, created 409 400 */ 410 401 function og_save_subscription($gid, $uid, $args = array()) { … … 412 403 $cnt = db_result(db_query($sql, $gid, $uid)); 413 404 $time = time(); 414 415 // Allow other modules to pass their data inside the $args.416 $og_allowed_args = array('is_active', 'is_admin', 'created');417 $return_args = $args;418 foreach ($args as $key => $value) {419 if (!in_array($key, $og_allowed_args)) {420 unset($args[$key]);421 }422 }423 405 if ($cnt == 0) { 424 406 // this pattern borrowed from user_save() … … 429 411 $fields[] = db_escape_string($key); 430 412 $values[] = $value; 431 $s[] = "'%s'"; 413 $s[] = "'%s'"; 432 414 } 433 415 db_query('INSERT INTO {og_uid} ('. implode(', ', $fields). ') VALUES (%d, %d, %d, %d, '. implode(', ', $s). ')', $values); 434 module_invoke_all('og', 'user insert', $gid, $uid, $ return_args);416 module_invoke_all('og', 'user insert', $gid, $uid, $args); 435 417 } 436 418 else { … … 441 423 $cond = implode(', ', $cond); 442 424 db_query("UPDATE {og_uid} SET $cond WHERE nid = %d AND uid = %d", $gid, $uid); 443 module_invoke_all('og', 'user update', $gid, $uid, $ return_args);444 } 445 } 446 447 function og_delete_subscription($gid, $uid , $args = array()){425 module_invoke_all('og', 'user update', $gid, $uid, $args); 426 } 427 } 428 429 function og_delete_subscription($gid, $uid){ 448 430 $sql = "DELETE FROM {og_uid} WHERE nid = %d AND uid = %d"; 449 431 db_query($sql, $gid, $uid); 450 // Allow other modules to pass their data inside the $args. 451 module_invoke_all('og', 'user delete', $gid, $uid, $args); 432 module_invoke_all('og', 'user delete', $gid, $uid, array()); 452 433 } 453 434 … … 461 442 } 462 443 if (in_array($gid, array_keys($account->og_groups))) { 463 drupal_set_message(t("!name already approved to group %group .", array('!name' => theme('username', $account), '%group' => $node->title)), 'error');444 drupal_set_message(t("!name already approved to group %group", array('!name' => theme('username', $account), '%group' => $node->title)), 'error'); 464 445 return ''; 465 446 } … … 469 450 470 451 $variables = array( 471 '@title' => $node->title, 472 '!group_url'=> url("node/$node->nid", NULL, NULL, TRUE) 473 ); 474 $message = array( 475 'subject' => _og_user_mail_text('og_approve_user_subject', $variables), 476 'body' => _og_user_mail_text('og_approve_user_body', $variables) 477 ); 478 479 module_invoke_all('og', 'user approve', $gid, $uid, $message); 452 '@title' => $node->title, 453 '!group_url'=> url("node/$node->nid", NULL, NULL, TRUE) 454 ); 455 456 $from = variable_get('site_mail', ini_get('sendmail_from')); 457 $account = user_load(array('uid' => $uid)); 458 drupal_mail('og_approve', $account->mail, _og_user_mail_text('og_approve_user_subject', $variables), _og_user_mail_text('og_approve_user_body', $variables), $from); 480 459 drupal_goto("node/$gid"); 481 460 } … … 494 473 $variables = array( 495 474 '@title' => $node->title, 496 '!group_url' => url("node/$node->nid", NULL, NULL, TRUE)475 '!group_url' => url("node/$node->nid", NULL, NULL, TRUE) 497 476 ); 498 $message = array( 499 'subject' => _og_user_mail_text('og_deny_user_subject', $variables), 500 'body' => _og_user_mail_text('og_deny_user_body', $variables) 501 ); 502 503 module_invoke_all('og', 'user deny', $gid, $uid, $message); 477 478 $from = variable_get('site_mail', ini_get('sendmail_from')); 479 $account = user_load(array('uid' => $uid)); 480 drupal_mail('og_deny', $account->mail, _og_user_mail_text('og_deny_user_subject', $variables), _og_user_mail_text('og_deny_user_body', $variables), $from); 504 481 drupal_goto("node/$gid"); 505 482 } … … 542 519 543 520 og_save_subscription($node->nid, $account->uid, array('is_admin' => 1)); 544 drupal_set_message(t('%name was promoted to %ga .', array('%name' => $account->name, '%ga' => t('group administrator'))));521 drupal_set_message(t('%name was promoted to %ga', array('%name' => $account->name, '%ga' => t('group administrator')))); 545 522 546 523 $variables = array( … … 549 526 '@username' => $account->name 550 527 ); 551 $message = array( 552 'subject' => _og_user_mail_text('og_new_admin_subject', $variables), 553 'body' => _og_user_mail_text('og_new_admin_body', $variables) 554 ); 555 556 module_invoke_all('og', 'admin create', $node->nid, $account->uid, $message); 528 529 $from = variable_get('site_mail', ini_get('sendmail_from')); 530 drupal_mail('og_new_admin', $account->mail, _og_user_mail_text('og_new_admin_subject', $variables), _og_user_mail_text('og_new_admin_body', $variables), $from); 557 531 return "og/users/$node->nid"; 558 532 } … … 590 564 $gid = $form_values['gid']; 591 565 og_save_subscription($gid, $account->uid, array('is_admin' => 0)); 592 drupal_set_message(t('%name is no longer a %ga .', array('%name' => $account->name, '%ga' => t('group administrator'))));566 drupal_set_message(t('%name is no longer a %ga', array('%name' => $account->name, '%ga' => t('group administrator')))); 593 567 return "og/users/$gid"; 594 568 } … … 625 599 $emails = explode(',', $mails); 626 600 if (count($emails) > $max) { 627 form_set_error('mails', t( 'You may not specify more than %max email addresses or usernames.', array('%max' => $max)));601 form_set_error('mails', t("You may not specify more than %max email addresses or usernames.", array('%max' => $max))); 628 602 } 629 603 elseif (in_array($user->mail, $emails)) { 630 form_set_error('mails', t( 'You may not invite yourself - @self', array('@self' => $user->mail)));604 form_set_error('mails', t("You may not invite yourself - @self", array('@self' => $user->mail))); 631 605 } 632 606 else { … … 652 626 } 653 627 if (count($bad)) { 654 form_set_error('mails', t(' Invalid email address or username:') .' '. implode(' ', $bad));628 form_set_error('mails', t('invalid email address or username: '). implode(' ', $bad)); 655 629 } 656 630 else { … … 696 670 } 697 671 $node = node_load($gid); 698 if ($node->og_selective >= OG_INVITE_ONLY || $node->status == 0 || !og_is_group_type($node->type)) {672 if ($node->og_selective >= OG_INVITE_ONLY || $node->status == 0) { 699 673 drupal_access_denied(); 700 674 exit(); … … 744 718 745 719 /** 746 * Create a new membership for a given user to given group . Edits to membership should720 * Create a new membership for a given user to given group and send proper email. Edits to membership should 747 721 * go through og_save_subscription(). No access control since this is an API function. 748 722 * … … 755 729 case OG_MODERATED: 756 730 og_save_subscription($gid, $account->uid, array('is_active' => 0)); 757 758 731 $sql = og_list_users_sql(1, 1); 759 732 $res = db_query($sql, $node->nid); 760 $admins = array();761 733 while ($row = db_fetch_object($res)) { 762 $admins[] = $row->uid; 763 } 764 765 if (!empty($admins)) { 766 // Prepend user's request text with standard cruft. Should be a 767 // variable but that's a bit annoying. 768 if ($request) { 769 $request = t("\n\nPersonal message from @name:\n------------------\n\n@request", array('@name' => $account->name, '@request' => $request)); 734 if ($row->mail) { 735 $admins[] = $row->mail; 770 736 } 737 } 738 if ($admins) { 771 739 $variables = array( 772 740 '@group' => $node->title, … … 775 743 '!group_url' => url("og/users/$node->nid", NULL, NULL, TRUE) 776 744 ); 777 $message = array( 778 'subject' => _og_user_mail_text('og_request_user_subject', $variables), 779 'body' => _og_user_mail_text('og_request_user_body', $variables) . $request 780 ); 781 782 // Send notifications to each admin; Sending an array of recipients 783 // implies that this is a bulk message. 784 module_invoke_all('og', 'user request', $gid, $admins, $message); 785 } 786 745 746 $from = variable_get('site_mail', ini_get('sendmail_from')); 747 // prepend user's request text with standard cruft. should be a mail variable but thats a bit annoying 748 if ($request) { 749 $request = t("\n\nPersonal message from @name:\n------------------\n\n@request", array('@name' => $account->name, '@request' => $request)); 750 } 751 drupal_mail('og_subscription_request', implode(', ', $admins), _og_user_mail_text('og_request_user_subject', $variables), _og_user_mail_text('og_request_user_body', $variables). $request, $from); 752 } 787 753 $return_value = array('type' => 'approval', 788 754 'message' => t('Membership request to the %group group awaits approval by an administrator.', array('%group' => $node->title))); … … 792 758 og_save_subscription($gid, $account->uid, array('is_active' => 1)); 793 759 $return_value = array('type' => 'subscribed', 794 'message' => t('You are now a member of the %group .', array('%group' => $node->title)));760 'message' => t('You are now a member of the %group', array('%group' => $node->title))); 795 761 break; 796 762 case OG_CLOSED: … … 814 780 } 815 781 $node = node_load($gid); 816 $account = user_load(array('uid' => $uid)); 817 if (!in_array($gid, array_keys(og_get_subscriptions($account->uid, 0))) || ($uid != $user->uid && !og_is_node_admin($node))) { 818 // Ubsubscribee must be a member or awaiting approval 819 // Only admins can remove another member. 782 if ($uid != $user->uid && !og_is_node_admin($node)) { 783 // only admins can remove another member 820 784 drupal_access_denied(); 821 785 exit(); 822 786 } 823 if ( !og_is_group_type($node->type) ||($node->og_selective == OG_CLOSED && !og_is_node_admin($node)) || $node->uid == $uid){787 if (($node->og_selective == OG_CLOSED && !og_is_node_admin($node)) || $node->uid == $uid){ 824 788 // Regular users may not leave from a closed group 825 789 // Group manager may never leave (TODO: fix), such a link should never be generated … … 916 880 } 917 881 else { 918 $bad[] = check_plain($name);882 $bad[] = $name; 919 883 $err = TRUE; 920 884 } 921 885 } 922 886 if ($err) { 923 form_set_error('og_names', t('Unrecognized %names: ', array('%names' => format_plural(count($bad), 'name', 'names'))) .' '. implode(', ', $bad));887 form_set_error('og_names', t('Unrecognized %names: ', array('%names' => format_plural(count($bad), 'name', 'names'))). implode(', ', $bad)); 924 888 } 925 889 } … … 937 901 og_save_subscription($form_values['gid'], $account->uid, array('is_active' => 1)); 938 902 } 939 drupal_set_message(format_plural(count($accounts), '1 user added to the group .', '@count users added to the group.'));903 drupal_set_message(format_plural(count($accounts), '1 user added to the group', '@count users added to the group')); 940 904 } 941 905 … … 948 912 // prepend the group manager 949 913 $i=0; 950 $rows[$i][] = array('data' => theme('username', $node). ' <em>'. t(' Manager'). '</em>', 'colspan' => 3);914 $rows[$i][] = array('data' => theme('username', $node). ' <em>'. t('manager'). '</em>', 'colspan' => 3); 951 915 $i++; 952 916 … … 957 921 if ($account->uid != $node->uid) { 958 922 $username = theme('username', $account); 959 if (!$account->is_active) { $username .= ' <em>'. t('(approval needed)'). '</em>'; }960 elseif ($account->is_admin) { $username .= ' <em>'. t('Administrator'). '</em>'; }923 if (!$account->is_active) { $username .= ' <em>'.t('(approval needed)'). '</em>'; } 924 elseif ($account->is_admin) { $username .= ' <em>'.t('administrator'). '</em>'; } 961 925 $rows[$i][] = $username; 962 926 if ($access) { 963 927 if ($account->is_active) { 964 $rows[$i][] = l(t(' Remove'), "og/unsubscribe/$gid/$account->uid", array(), "destination=og/users/$gid");928 $rows[$i][] = l(t('remove'), "og/unsubscribe/$gid/$account->uid", array(), "destination=og/users/$gid"); 965 929 if ($account->is_admin) { 966 $rows[$i][] = l(t(' Admin: Remove'), "og/delete_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']);930 $rows[$i][] = l(t('admin: remove'), "og/delete_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']); 967 931 } 968 932 else { 969 $rows[$i][] = l(t(' Admin: Create'), "og/create_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']);933 $rows[$i][] = l(t('admin: create'), "og/create_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']); 970 934 } 971 935 } 972 936 else { 973 $rows[$i][] = l(t(' Approve'), "og/approve/$gid/$account->uid", array(), "destination=og/users/$gid");974 $rows[$i][] = l(t(' Deny'), "og/deny/$gid/$account->uid", array(), "destination=og/users/$gid");937 $rows[$i][] = l(t('approve'), "og/approve/$gid/$account->uid", array(), "destination=og/users/$gid"); 938 $rows[$i][] = l(t('deny'), "og/deny/$gid/$account->uid", array(), "destination=og/users/$gid"); 975 939 } 976 940 } … … 992 956 function og_list_users_faces_page($gid, $column_count = 5, $row_count = 10, $pager_id = 0) { 993 957 $max_per_page = $row_count * $column_count; 994 $sql = og_list_users_sql( 1, 0, 'ou.is_admin DESC, u.picture DESC, u.name ASC');958 $sql = og_list_users_sql(0, 0, 'ou.is_admin DESC, u.picture DESC, u.name ASC'); 995 959 /* list group admins first, members with pics second, regular members last. Alphabetize within each of these categories */ 996 960 $result = pager_query($sql, $max_per_page, $pager_id, NULL, $gid); … … 1032 996 $content .= '</table>'; 1033 997 1034 if ($ total) {998 if ($content) { 1035 999 return $content; 1036 1000 } … … 1109 1073 unset($node->content['body']); 1110 1074 $node->content['og_mission'] = array( 1111 '#value' => $node->body, // node_prepare() already ran check_markup()1075 '#value' => check_markup($node->body, $node->format, FALSE), 1112 1076 '#node' => $node, 1113 1077 '#weight' => -3, … … 1137 1101 og_home_empty($node); 1138 1102 } 1139 drupal_set_title( check_plain(views_get_title($view, 'page')));1103 drupal_set_title(filter_xss_admin(views_get_title($view, 'page'))); 1140 1104 } 1141 1105 } … … 1306 1270 1307 1271 function og_load_group(&$node) { 1308 $sql = 'SELECT selective AS og_selective, description AS og_description, theme AS og_theme, register AS og_register, directory AS og_directory, language AS og_language, private AS og_private FROM {og} WHERE nid = %d';1272 $sql = 'SELECT selective AS og_selective, description AS og_description, theme AS og_theme, register AS og_register, directory AS og_directory, notification AS og_notification, language AS og_language, private AS og_private FROM {og} WHERE nid = %d'; 1309 1273 $result = db_query($sql, $node->nid); 1310 1274 $node = (object) array_merge((array)$node, (array)db_fetch_array($result)); … … 1313 1277 1314 1278 function og_insert_group($node) { 1315 $sql = "INSERT INTO {og} (nid, theme, selective, description, register, directory, language, private) VALUES (%d, '%s', %d, '%s', %d, %d, '%s', %d)";1316 db_query($sql, $node->nid, $node->og_theme, $node->og_selective, $node->og_description, $node->og_register, $node->og_directory, $node->og_ language, $node->og_private);1279 $sql = "INSERT INTO {og} (nid, theme, selective, description, register, directory, notification, language, private) VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s', %d)"; 1280 db_query($sql, $node->nid, $node->og_theme, $node->og_selective, $node->og_description, $node->og_register, $node->og_directory, $node->og_notification, $node->og_language, $node->og_private); 1317 1281 } 1318 1282 1319 1283 function og_update_group($node) { 1320 $sql = "UPDATE {og} SET theme = '%s', selective = %d, register = %d, description = '%s', directory = %d, language = '%s', private = %d WHERE nid = %d";1321 db_query($sql, $node->og_theme, $node->og_selective, $node->og_register, $node->og_description, $node->og_directory, $node->og_ language, $node->og_private, $node->nid);1284 $sql = "UPDATE {og} SET theme = '%s', selective = %d, register = %d, description = '%s', directory = %d, notification = %d, language = '%s', private = %d WHERE nid = %d"; 1285 db_query($sql, $node->og_theme, $node->og_selective, $node->og_register, $node->og_description, $node->og_directory, $node->og_notification, $node->og_language, $node->og_private, $node->nid); 1322 1286 if (!db_affected_rows()) { 1323 1287 og_insert_group($node); … … 1362 1326 break; 1363 1327 case 'validate': 1364 // Ensure that a group is selected if groups are required. needed when author has no groups. In other cases, fapi does the validation 1365 if (og_is_group_post_type($node->type) && variable_get('og_audience_required', FALSE) && !user_access('administer nodes')) { 1366 if (!isset($node->og_groups)) { 1367 form_set_error('title', t('You must !join before posting on this web site.', array('!join' => l(t('join a group'), 'og')))); 1328 if (og_is_group_type($node->type)) { 1329 // Email address is required for contacting the Manager 1330 $account = user_load(array('uid' => $node->uid)); 1331 if ($account->uid > 0 && empty($account->mail)) { 1332 form_set_error('name', t('The group manager, %name, must have an email address in his <a href="!profile">profile</a>.', array('%name' => $account->name, '!profile' => url("user/$node->uid/edit")))); 1368 1333 } 1334 1335 // Must be authored in the default input format or else admins might not get their admin perms 1336 // If Body field is omitted, there may not yet be a $node->format 1337 if (isset($node->format) && $node->format != filter_resolve_format(FILTER_FORMAT_DEFAULT)) { 1338 form_set_error('body', t("You must use the default input format when authoring a group node.")); 1339 } 1340 } 1341 else { 1342 // Ensure that a group is selected if groups are required. needed when author has no groups. In other cases, fapi does the validation 1343 if (og_is_group_post_type($node->type) && variable_get('og_audience_required', FALSE) && !user_access('administer nodes')) { 1344 if (!isset($node->og_groups)) { 1345 form_set_error('title', t('You must !join before posting on this web site.', array('!join' => l(t('join a group'), 'og')))); 1346 } 1347 } 1348 1369 1349 } 1370 1350 break; … … 1403 1383 '!invite_url' => url("og/invite/$node->nid", NULL, NULL, TRUE) 1404 1384 ); 1405 $message = array( 1406 'subject' => _og_user_mail_text('og_new_admin_subject', $variables), 1407 'body' => _og_user_mail_text('og_new_admin_body', $variables) 1408 ); 1409 1410 // Alert the user that they are now the admin of the group. 1411 module_invoke_all('og', 'admin new', $gid, $account->uid, $message); 1385 1386 // alert the user that they are now the admin of the group 1387 $from = variable_get('site_mail', ini_get('sendmail_from')); 1388 drupal_mail('og_new_admin', $account->mail, _og_user_mail_text('og_new_admin_subject', $variables), _og_user_mail_text('og_new_admin_body', $variables), $from); 1412 1389 } 1413 1390 else { 1414 1391 og_save_ancestry($node); 1392 } 1393 1394 $skip_notification = FALSE; 1395 // Any module that returns TRUE from its hook_og_notify($node) will prevent sending notifications. 1396 // og2list and og_subscriptions use this to send own notifications. 1397 foreach(module_implements('og_notify') as $module) { 1398 if (module_invoke($module,'og_notify',$node)) { 1399 $skip_notification = TRUE; 1400 break; 1401 } 1402 } 1403 if (!$skip_notification && $node->status && og_is_mail_type($node->type) && $node->og_groups) { 1404 if (module_exists('job_queue')) { 1405 $description = t('OG: notify group members about node %nid - !link', array('%nid' => $node->nid, '!link' => l($node->title, "node/$node->nid"))); 1406 job_queue_add('og_mail', $description, array('node', $node->nid)); 1407 } 1408 else { 1409 og_mail('node', $node); 1410 } 1415 1411 } 1416 1412 break; … … 1439 1435 $ret[] = array('key' => 'group', 1440 1436 'value' => check_plain($title), 1441 'attributes' => array( 1442 'domain' => url("node/$gid", NULL, NULL, TRUE), 1443 'xmlns' => 'http://drupal.org/project/og', 1444 ), 1445 ); 1437 'attributes' => array('domain' => url("node/$gid", NULL, NULL, TRUE))); 1446 1438 } 1447 1439 // to get these modifications to work on 4.7, one needs to patch as per http://drupal.org/node/41703 … … 1508 1500 1509 1501 if ($form_id == 'views_edit_view') { 1510 $form['page-info']['url']['#description'] .= '<p>'. t("To display a View as a tab on your Organic Groups group home pages, set the url to 'node/\$group/custom' (where <em>custom</em> is whatever you wish). Then open Page >> Menu and check <em>Provide Menu</em> and <em>Provide Menu as Tab</em>; also make the first argument in the View be the <em>OG: Group nid(s)</em> argument. The <em>\$group</em> path element is a placeholder for the group nid and it ensures that the tab <strong>only</strong> appears on OG group nodes.") .'</p>';1502 $form['page-info']['url']['#description'] .= t("<p>To display a View as a tab on your Organic Groups group home pages, set the url to 'node/\$group/custom' (where <em>custom</em> is whatever you wish). Then open Page >> Menu and check <em>Provide Menu</em> and <em>Provide Menu as Tab</em>; also make the first argument in the View be the <em>OG: Group nid(s)</em> argument. The <em>\$group</em> path element is a placeholder for the group nid and it ensures that the tab <strong>only</strong> appears on OG group nodes.</p>"); 1511 1503 } 1512 1504 … … 1569 1561 function og_node_delete_group_form(&$form) { 1570 1562 $options[] = t('Do nothing.'); 1571 $options[] = t( "Delete all group posts which don't also belong to another group.");1563 $options[] = t('Delete all group posts which don\'t also belong to another group.'); 1572 1564 if (user_access('administer nodes')) { 1573 1565 $options[] = t('Move all group posts to the group listed below.'); … … 1578 1570 unset($options[$form['nid']['#value']]); 1579 1571 $form['target'] = array('#type' => 'select', '#title' => t('Target group'), '#default_value' => 0, '#options' => $options, '#weight' => 0, '#description' => t('If you chose <b>Move all group posts</b> above, specify a destination group.')); 1580 }1581 // register a submit handler1582 $form['#submit']['og_node_delete_confirm_submit'] = array();1572 // register a submit handler 1573 $form['#submit']['og_node_delete_confirm_submit'] = array(); 1574 } 1583 1575 $form['actions']['submit']['#value'] = t('Delete group'); 1584 1576 } … … 1604 1596 } 1605 1597 1606 // Submit handler for node delete form. handles deletes to group nodes.1598 // submit handler for node delete form. handles deletes to group nodes 1607 1599 function og_node_delete_confirm_submit($form_id, $form_values) { 1608 1600 $deleted_group_nid = $form_values['nid']; … … 1614 1606 unset($node->og_groups[$deleted_group_nid]); 1615 1607 if ($move_children) { 1616 // There is an array_unique() in og_save_ancestry() which guards against duplicates so don't worry here.1617 $node->og_groups[ $target_group_nid] = $target_group_nid;1608 // there is an array_unique() in og_save_ancestry which giards against duplicates so don't worry here. 1609 $node->og_groups[] = $target_group_nid; 1618 1610 } 1619 1611 if ($delete_orphans && count($node->og_groups) == 0) { … … 1746 1738 } 1747 1739 1748 // Show read only item if we are non-admin, and in simple mode (i.e. non-checkboxes) and at least one group is in querystring1740 // show read only item if we are non-admin, and in simple mode (i.e. non-checkboxes) and at least one group is in querystring 1749 1741 $simple = !user_access('administer organic groups') && !variable_get('og_audience_checkboxes', TRUE) && count($gids); 1750 1742 … … 1783 1775 if (count($groups)) { 1784 1776 foreach ($groups as $gid) { 1785 $titles[] = check_plain($options[$gid]);1777 $titles[] = $options[$gid]; 1786 1778 $item_value = implode(', ', $titles); 1787 1779 } … … 1817 1809 } 1818 1810 1811 function og_comment($comment, $op) { 1812 switch ($op) { 1813 case 'publish': 1814 $comment = (array) $comment; 1815 // fall through 1816 case 'insert': 1817 $skip_notification = FALSE; 1818 // Any module that returns true from its hook_og_notify($node) will prevent sending notifications. 1819 // og2list uses this to send its own notifications instead for mailing list content. 1820 $node = node_load($comment['nid']); 1821 1822 foreach(module_implements('og_notify') as $module) { 1823 if (module_invoke($module, 'og_notify', $node)) { 1824 $skip_notification = TRUE; 1825 break; 1826 } 1827 } 1828 // remove the perm check after 5.3 is released. 1829 if ($comment['status'] == COMMENT_PUBLISHED && !$skip_notification && og_is_mail_type($node->type) && isset($node->og_groups) && !empty($node->og_groups)) { 1830 if (module_exists('job_queue')) { 1831 $description = t('OG: notify group members about comment %id on !link', array('%id' => $comment['cid'], '!link' => l($node->title, "node/$node->nid", NULL, NULL, 'comment-'. $comment['cid']))); 1832 job_queue_add('og_mail', $description, array('comment', $comment['cid'])); 1833 } 1834 else { 1835 og_mail('comment', (object)$comment); 1836 } 1837 } 1838 break; 1839 } 1840 } 1841 1842 1843 /** 1844 * Send this node/comment via email to all email members. Called from og_nodeapi() and og_comment(). 1845 * Sometimes called from during cron if job_queue.module is enabled (recommended). 1846 * TODO: this function is a bit messy. rethink. 1847 * 1848 * @param $type 1849 * the object type: node or comment 1850 * @param $id 1851 * a node or comment object. if a non object is supplied, a load() operation is performed. 1852 * @return 1853 * none 1854 */ 1855 function og_mail($type, $obj) { 1856 if ($type == 'comment') { 1857 if (!is_object($obj)) { 1858 $obj = _comment_load($obj); 1859 } 1860 // registered user 1861 if ($obj->uid) { 1862 $account = user_load(array('uid' => $obj->uid)); 1863 $obj->name = $account->name; 1864 } 1865 else { 1866 $obj->name = variable_get('anonymous', 'Anonymous'); 1867 } 1868 $rendered = check_markup($obj->comment, $obj->format, FALSE); 1869 1870 $obj->body = $rendered; 1871 $obj->teaser = $rendered; 1872 $originalurl = url("node/$obj->nid", NULL, "comment-$obj->cid", TRUE); 1873 $replyurl = url("comment/reply/$obj->nid/$obj->cid", NULL, NULL, TRUE); 1874 $node = node_load($obj->nid); 1875 $obj->og_groups = $node->og_groups; 1876 $obj->title = $node->title; 1877 $obj->msgid = $obj->nid. '-'. $obj->cid. og_msgid_server(); 1878 $reply = $obj->nid. '-'; 1879 if ($obj->pid) { 1880 $reply .= $obj->pid; 1881 } 1882 else { 1883 $reply .= '0'; 1884 } 1885 $obj->in_reply_to .= $reply. og_msgid_server(); 1886 $type_friendly = 'comment'; 1887 } 1888 else { 1889 if (!is_object($obj)) { 1890 $obj = node_load($obj); 1891 } 1892 $account = user_load(array('uid' => $obj->uid)); 1893 $obj->name = $account->name; 1894 $obj->subject = $obj->title; 1895 // These calls to og_node_view() setup the node body and teaser, apply the 1896 // appropriate input filters, and handle CCK fields, event fields, etc. 1897 $obj->body = og_node_view($obj, FALSE); 1898 $obj->teaser = og_node_view($obj, TRUE); 1899 $obj->msgid = $obj->nid. '-0'. og_msgid_server(); 1900 $originalurl = url("node/$obj->nid", NULL, NULL, TRUE); 1901 $replyurl = url("comment/reply/$obj->nid", NULL, 'comment-form', TRUE); 1902 $type_friendly = node_get_types('name', $obj); 1903 } 1904 1905 // set email from variables 1906 $variables = array( 1907 '@user_mail' => $account->mail ? $account->mail : variable_get("site_mail", ini_get("sendmail_from")), 1908 '@user_name' => mime_header_encode($obj->name), 1909 '@site_mail' => variable_get("site_mail", ini_get("sendmail_from")), 1910 '@site_name' => mime_header_encode(variable_get("site_name", 'Drupal')), 1911 ); 1912 $from_mail = strtr(variable_get("og_email_notification_pattern", '@user_name <@site_mail>'), $variables); 1913 1914 $headers = array('X-Mailer' => 'Drupal - og_mail', 'Precedence' => 'list', 'Message-Id' => "<$obj->msgid>"); 1915 if ($obj->in_reply_to) { 1916 $headers['In-Reply-To'] = "<$obj->in_reply_to>"; 1917 } 1918 1919 // set email body variables 1920 $variables = array( 1921 '@site' => variable_get('site_name', 'drupal'), 1922 '!read_more' => $obj->readmore ? t('Read more') : t('View original'), 1923 '!content_url' => $originalurl, 1924 '!reply_url' => $replyurl, 1925 '@title' => trim($obj->title), 1926 '@subject' => trim($obj->subject), 1927 '@node_full' => trim(og_mail_output($obj->body)), 1928 '@node_teaser' => trim(og_mail_output($obj->teaser)), 1929 '@username' => $obj->name 1930 ); 1931 1932 // Send email to selective subscribers and global subscribers. 1933 // We use if() here in case node/comment no longer has any groups (i.e. this function can be called from cron). 1934 if (is_array($obj->og_groups) && !empty($obj->og_groups)) { 1935 $groups = implode(', ', $obj->og_groups); 1936 // tricky query here. mysql returns NULL in the case of NULL != 0 so i rework this for 2 positive statements about og_email field 1937 // ORDER BY favors newer groups to help them get ramped up. Thus, they are perceived as active. 1938 $sql = "SELECT u.mail, ou.nid AS gid, n.title AS group_name, n.uid AS group_uid, u.name AS group_owner, oug.og_email 1939 FROM {og_uid} ou INNER JOIN {users} u ON ou.uid=u.uid 1940 INNER JOIN {og_uid_global} oug ON ou.uid=oug.uid 1941 INNER JOIN {node} n ON ou.nid=n.nid 1942 WHERE ou.nid IN ($groups) AND ( 1943 (oug.og_email = %d AND ou.mail_type=1) OR 1944 (oug.og_email = %d) 1945 ) AND u.status = 1 AND u.mail != '' AND ou.is_active = 1 1946 ORDER by u.mail DESC, n.created DESC 1947 "; 1948 $result = db_query($sql, OG_NOTIFICATION_SELECTIVE, OG_NOTIFICATION_ALWAYS); 1949 $last_mail = ''; 1950 while ($row = db_fetch_object($result)) { 1951 // only notify each user once. we used to do this with GROUP BY but got very hard to assure that all the selected fields came from same record. 1952 if ($row->mail == $last_mail) { 1953 continue; 1954 } 1955 $last_mail = $row->mail; 1956 1957 // TODO: add node_access('view') call here in case node is moderated or other. 1958 // Hopefully D6 will avert need to impersonate. 1959 // Append these group specific variables. 1960 $variables['@group'] = $row->group_name; 1961 $variables['!group_url'] = url("og/manage/$row->gid", NULL, NULL, TRUE); 1962 $variables['@type'] = $type_friendly; 1963 1964 $unsubscribe = url("og/manage/$row->gid", NULL, NULL, TRUE); 1965 $ownerurl = url("user/$row->group_uid", NULL, NULL, TRUE); 1966 $group_home = url("node/$row->gid", NULL, NULL, TRUE); 1967 $groupheaders = $headers + array( 1968 'List-Id' => mime_header_encode($row->group_name). " <$group_home>", 1969 'List-Unsubscribe' => "<$unsubscribe>", 1970 'List-Owner' => mime_header_encode($row->group_owner). " <$ownerurl>", 1971 "List-Archive" => "<$group_home>" 1972 ); 1973 drupal_mail('og_mail', $row->mail, _og_user_mail_text('og_new_node_subject', $variables), _og_user_mail_text('og_new_node_body', $variables), $from_mail, $groupheaders); 1974 } 1975 } 1976 } 1977 1819 1978 /** 1820 1979 * Similar to node_view() but without calling theme('node'). 1821 1980 * 1822 1981 * This is needed to get the proper body or teaser for nodes (e.g. Event, 1823 * Location, CCK node types) and to clean up the body for use in notifications. 1982 * Location, CCK node types) and to clean up the body for use in email 1983 * notifications. 1824 1984 * 1825 1985 * @param $node … … 1853 2013 } 1854 2014 1855 /** 1856 * Define all OG message strings. 2015 // 2 functions ripped from mail.inc in project.module package 2016 function og_mail_urls($url = 0) { 2017 static $urls = array(); 2018 if ($url) { 2019 $urls[] = strpos($url, '://') ? $url : url($url, NULL, NULL, 1); 2020 return count($urls); 2021 } 2022 return $urls; 2023 } 2024 2025 // takes filtered HTML as input and transforms for email 2026 // modified from project.module 2027 function og_mail_output($body, $html = TRUE) { 2028 static $i = 0; 2029 2030 if ($html) { 2031 $pattern = '@<a +([^ >]+ )*?href *= *"([^>"]+?)"[^>]*>([^<]+?)</a>@ei'; 2032 $body = preg_replace($pattern, "'\\3 ['. og_mail_urls('\\2') .']'", $body); 2033 $urls = og_mail_urls(); 2034 if (count($urls)) { 2035 $body .= "\n"; 2036 for ($max = count($urls); $i < $max; $i++) { 2037 $body .= '['. ($i + 1) .'] '. $urls[$i] ."\n"; 2038 } 2039 } 2040 2041 $body = preg_replace('!</?blockquote>!i', '"', $body); 2042 $body = preg_replace('!</?(em|i)>!i', '/', $body); 2043 $body = preg_replace('!</?(b|strong)>!i', '*', $body); 2044 $body = preg_replace("@<br />(?!\n)@i", "\n", $body); 2045 $body = preg_replace("@</p.*>(?!\n\n)@i", "\n\n", $body); 2046 $body = preg_replace("@</h1>(?!\n\n)@i", " #\n", $body); 2047 $body = preg_replace("@</h2>(?!\n\n)@i", " ##\n", $body); 2048 $body = preg_replace("@</h3>(?!\n\n)@i", " ###\n", $body); 2049 $body = preg_replace("@</h4>(?!\n\n)@i", " ####\n", $body); 2050 $body = preg_replace("@</(li|dd)>\n?@i", "\n", $body); 2051 $body = preg_replace("@<h1.*>@i", "\n\n# ", $body); 2052 $body = preg_replace("@<h2.*>@i", "\n\n## ", $body); 2053 $body = preg_replace("@<h3.*>@i", "\n\n### ", $body); 2054 $body = preg_replace("@<h4.*>@i", "\n\n#### ", $body); 2055 $body = preg_replace("@<li.*>@i", "* ", $body); 2056 $body = strip_tags($body); 2057 $body = decode_entities($body); 2058 $body = wordwrap($body, 72); 2059 } 2060 else { 2061 $body = decode_entities($body); 2062 } 2063 return $body; 2064 } 2065 2066 /** 2067 * Define all OG emails 1857 2068 * Modelled after Drupal's user.module 1858 2069 */ … … 1868 2079 return t("@group: '@title' at @site", $variables); 1869 2080 case 'og_new_node_body': 1870 return t("@type '@subject' by @username\n\n@node_teaser\n\n!read_more: !content_url\nPost reply: !reply_url\n\n--\nYou are subscribed from the group '@group' at @site.\nTo manage your subscription, visit !group_url .", $variables);2081 return t("@type '@subject' by @username\n\n@node_teaser\n\n!read_more: !content_url\nPost reply: !reply_url\n\n--\nYou are subscribed from the group '@group' at @site.\nTo manage your subscription, visit !group_url", $variables); 1871 2082 case 'og_admin_email_body': 1872 return t("@body\n\n--\nThis message was sent by an administrator in the '@group' group at @site. To visit this group, browse to !url_group. To unsubscribe from this group, visit !url_unsubscribe .", $variables);2083 return t("@body\n\n--\nThis message was sent by an administrator in the '@group' group at @site. To visit this group, browse to !url_group. To unsubscribe from this group, visit !url_unsubscribe", $variables); 1873 2084 case 'og_approve_user_subject': 1874 2085 return t("Membership request approved for '@title'", $variables); 1875 2086 case 'og_approve_user_body': 1876 return t("You may now post messages in this group located at !group_url .", $variables);2087 return t("You may now post messages in this group located at !group_url", $variables); 1877 2088 case 'og_deny_user_subject': 1878 return t("Membership request denied for '@title' .", $variables);2089 return t("Membership request denied for '@title'", $variables); 1879 2090 case 'og_deny_user_body': 1880 2091 return t("Sorry, your membership request was denied.", $variables); 1881 2092 case 'og_invite_user_subject': 1882 return t("Invitation to join the group '@group' at @site .", $variables);2093 return t("Invitation to join the group '@group' at @site", $variables); 1883 2094 case 'og_invite_user_body': 1884 2095 return t("Hi. I'm a member of '@group' and I welcome you to join this group as well. Please see the link and message below.\n\n@group\n@description\nJoin: !group_url\n@body", $variables); 1885 2096 case 'og_request_user_subject': 1886 return t("Membership request for '@group' from '@username' .", $variables);2097 return t("Membership request for '@group' from '@username'", $variables); 1887 2098 case 'og_request_user_body': 1888 2099 return t("To instantly approve this request, visit !approve_url.\nYou may deny this request or manage members at !group_url.", $variables); 1889 2100 case 'og_new_admin_subject': 1890 return t("You are now an administrator for the group '@group' .", $variables);2101 return t("You are now an administrator for the group '@group'", $variables); 1891 2102 case 'og_new_admin_body': 1892 2103 return t("@username, you are now an administrator for the group '@group'.\n\nYou can administer this group by logging in here:\n !group_url", $variables); … … 1911 2122 */ 1912 2123 function og_is_node_admin($node) { 1913 global $user; 1914 return og_is_group_type($node->type) && (user_access('administer nodes') || !empty($user->og_groups[$node->nid]['is_admin'])); 2124 return node_access('update', $node); 1915 2125 } 1916 2126 … … 1951 2161 } 1952 2162 return $form; 2163 case 'form': 2164 if ($category == 'account' && !empty($account->og_groups)) { 2165 $form['og_settings'] = array( 2166 '#type' => 'fieldset', 2167 '#title' => t('Organic groups settings'), 2168 '#collapsible' => TRUE, 2169 '#weight' => 4); 2170 $options = array(OG_NOTIFICATION_NEVER => t('Never send email notifications. Useful when tracking activity via RSS feed instead.'), 2171 OG_NOTIFICATION_ALWAYS => t('Always send email notifications'), 2172 OG_NOTIFICATION_SELECTIVE => t('Selectively send email notification based on the checkbox for each of my group\'s <em>My Membership</em> page'), 2173 ); 2174 2175 $form['og_settings']['og_email'] = array('#type' => 'radios', 2176 '#title' => t('Email notifications'), 2177 '#options' => $options, 2178 '#default_value' => isset($account->og_email) ? $account->og_email : variable_get('og_notification', 2), 2179 '#description' => t('When posts are submitted into your groups, you may be notified via email.'), 2180 ); 2181 return $form; 2182 } 2183 break; 1953 2184 case 'insert': 1954 2185 if (is_array($edit['og_register'])) { … … 1961 2192 } 1962 2193 2194 $sql = 'INSERT INTO {og_uid_global} (uid, og_email) VALUES (%d, %d)'; 2195 db_query($sql, $account->uid, variable_get('og_notification', OG_NOTIFICATION_ALWAYS)); 2196 $account->og_email = NULL; 2197 break; 2198 case 'update': 2199 if (isset($edit['og_email'])) { 2200 $sql = 'UPDATE {og_uid_global} SET og_email=%d WHERE uid=%d'; 2201 db_query($sql, $edit['og_email'], $account->uid); 2202 $account->og_email = NULL; 2203 } 1963 2204 break; 1964 2205 case 'delete': 2206 // user delete doesn't exist, but it should and will one day. 2207 $sql = 'DELETE FROM {og_uid_global} WHERE uid=%d'; 2208 db_query($sql, $account->uid); 2209 1965 2210 $sql = 'DELETE FROM {og_uid} WHERE uid=%d'; 1966 2211 db_query($sql, $account->uid); … … 1968 2213 case 'load': 1969 2214 $account->og_groups = og_get_subscriptions($account->uid); 2215 2216 $result = db_query("SELECT og_email FROM {og_uid_global} WHERE uid = %d", $account->uid); 2217 if (db_num_rows($result)) { 2218 $account->og_email = db_result($result); 2219 } 1970 2220 break; 1971 2221 case 'view': … … 2001 2251 */ 2002 2252 function og_node_type($op, $info) { 2253 $values = variable_get($variable, array()); 2003 2254 switch ($op) { 2004 2255 case 'delete': … … 2016 2267 'group' => t('Group node'), 2017 2268 'omitted' => t('May not be posted into a group.'), 2018 'group_post_standard' => t('Standard group post (typically only author may edit).') 2269 'group_post_standard_mail' => t('Standard group post (typically only author may edit). Sends email notifications.'), 2270 'group_post_standard_nomail' => t('Standard group post (typically only author may edit). No email notification.'), 2019 2271 ); 2020 2272 2021 2273 if (module_exists('og_access')) { 2022 $usages['group_post_wiki'] = t('Wiki group post (any group member may edit).'); 2274 $usages['group_post_wiki_mail'] = t('Wiki group post (any group member may edit). Sends email notifications.'); 2275 $usages['group_post_wiki_nomail'] = t('Wiki group post (any group member may edit). No email notification.'); 2023 2276 } 2024 2277 … … 2043 2296 } 2044 2297 2298 // returns TRUE if node type should generate email notifications when posted to a group. 2299 function og_is_mail_type($type) { 2300 $usage = variable_get('og_content_type_usage_'. $type, 'omitted'); 2301 return strpos($usage, 'mail') && !strpos($usage, 'nomail') ? TRUE : FALSE; 2302 } 2303 2045 2304 // returns TRUE if node type lets all subscribers edit the node. 2046 2305 function og_is_wiki_type($type) { … … 2077 2336 header("HTTP/1.1 301 Moved Permanently"); 2078 2337 header('Location: '. url("node/$gid/feed", NULL, NULL, TRUE)); 2079 }2080 2081 /**2082 * Check a user's membership in a group. Site admins always return TRUE.2083 */2084 function og_is_group_member($gid, $user) {2085 $groups = array_keys($user->og_groups);2086 return user_access('administer nodes') || in_array($gid, $groups) ? TRUE : FALSE;2087 2338 } 2088 2339 … … 2171 2422 // only members can see this block 2172 2423 if (in_array($groupnode->nid, array_keys($user->og_groups))) { 2173 $content = t('This group offers a !groupfeed and a !subscription.', array('!groupfeed' => l(t('RSS feed'), "node/$groupnode->nid/feed"), '!subscription' => l(t('subscription option'), 'og/manage/'. $groupnode->nid)));2424 $content = t('This group offers a !groupfeed and an !email.', array('!groupfeed' => l(t('RSS feed'), "node/$groupnode->nid/feed"), '!email' => l(t('email subscription'), 'og/manage/'. $groupnode->nid))); 2174 2425 if (module_exists('views') && module_exists('views_rss')) { 2175 2426 // NOTE: See og.css for styling specific to these lists 2176 $content .= ' '. t('Or subscribe to these personalized, sitewide feeds:');2427 $content .= t(' Or subscribe to these personalized, sitewide feeds:'); 2177 2428 $inline = array('class' => 'links inline'); 2178 $l1[] = array('title' => t(' Feed'), 'href' => 'group/myunread/feed');2179 $l1[] = array('title' => t(' Page'), 'href' => 'group/myunread');2180 $links['my_unread'] = t(' My unread:') .' '. theme('links', $l1, $inline);2429 $l1[] = array('title' => t('feed'), 'href' => 'group/myunread/feed'); 2430 $l1[] = array('title' => t('page'), 'href' => 'group/myunread'); 2431 $links['my_unread'] = t('my unread: '). theme('links', $l1, $inline); 2181 2432 2182 $l2[] = array('title' => t(' Feed'), 'href' => 'group/mytracker/feed');2183 $l2[] = array('title' => t(' Page'), 'href' => 'group/mytracker');2184 $links['my_group'] = t(' My group:') .' '. theme('links', $l2, $inline);2433 $l2[] = array('title' => t('feed'), 'href' => 'group/mytracker/feed'); 2434 $l2[] = array('title' => t('page'), 'href' => 'group/mytracker'); 2435 $links['my_group'] = t('my group: '). theme('links', $l2, $inline); 2185 2436 2186 $l3[] = array('title' => t(' Feed'), 'href' => 'group/tracker/feed');2187 $l3[] = array('title' => t(' Page'), 'href' => 'group/tracker');2188 $links['all_posts'] = t('All posts:') .' '. theme('links', $l3, $inline);2437 $l3[] = array('title' => t('feed'), 'href' => 'group/tracker/feed'); 2438 $l3[] = array('title' => t('page'), 'href' => 'group/tracker'); 2439 $links['all_posts'] = array('data' => t('all posts: '). theme('links', $l3, $inline)); 2189 2440 $content .= theme('item_list', $links); 2190 2441 } … … 2260 2511 * An HTML list. 2261 2512 **/ 2262 function og_block_subscribers_list($gid, $max = 10, $is_admin = array('members', 'admin s'), $show_more = TRUE, $show_picture = NULL) {2513 function og_block_subscribers_list($gid, $max = 10, $is_admin = array('members', 'admin'), $show_more = TRUE, $show_picture = NULL) { 2263 2514 $placeholders = array_fill(0, count(array_filter($is_admin)), '%d'); 2264 2515 $placeholders = implode(', ', $placeholders); … … 2334 2585 } 2335 2586 $links['subscribers'] = $txt; 2336 $links['manager'] = t('Manager: ') .' '. theme('username', $node);2587 $links['manager'] = t('Manager: '). theme('username', $node); 2337 2588 $subscribe = isset($subscription) ? l(t('My membership'), "og/manage/$node->nid") : og_subscribe_link($node); 2338 2589 if(isset($subscribe)) { … … 2445 2696 return $form; 2446 2697 } 2447 2448 2698 function og_admin_settings() { 2449 2699 drupal_set_title(t('Organic groups configuration')); … … 2472 2722 $form['og_settings']['group_details'] = array('#type' => 'fieldset', '#title' => t('Group details'), '#collapsible' => TRUE, '#collapsed' => TRUE); 2473 2723 // groups directory visibility 2474 $options = array(t( "New groups don't appear in the groups directory. Administrators control the directory exclusively."),2724 $options = array(t('New groups don\'t appear in the groups directory. Administrators control the directory exclusively.'), 2475 2725 t('New groups always appear in the groups directory.'), 2476 2726 t('Group creator chooses whether her group appears in the directory. Defaults to %in.', array('%in' => t('in directory'))), … … 2480 2730 2481 2731 // groups registration visibility 2482 $options = array(t( "New groups don't appear on the registration form. Administrators control the form exclusively."),2732 $options = array(t('New groups don\'t appear on the registration form. Administrators control the form exclusively.'), 2483 2733 t('New groups always appear on the registration form.'), 2484 2734 t('Group creator chooses whether her group appears on the registration form. Defaults to %in.', array('%in' => t('on form'))), … … 2487 2737 $form['og_settings']['group_details']['og_visibility_registration'] = array('#type' => 'radios', '#title' => t('Registration form control'), '#default_value' => variable_get('og_visibility_registration', OG_REGISTRATION_CHOOSE_FALSE), '#description' =>t('OG admins always see the checkbox for adding a group to the %dir. Note that changing this setting has no effect on existing posts. Re-save those posts to acquire this new setting.', array('%dir' => t('registration form'))), '#options' => $options); 2488 2738 2739 // email notifications default 2740 $options = array(OG_NOTIFICATION_SELECTIVE => t('New members are not subscribed to group email notifications by default. A member may choose to enable this from her profile page or her My membership page.'), 2741 OG_NOTIFICATION_ALWAYS => t('New members are subscribed to group email notifications by default. A member may choose to disable this from her profile page.'), 2742 ); 2743 $form['og_settings']['group_details']['og_notification'] = array('#type' => 'radios', '#title' => t('Group email notifications'), '#default_value' => variable_get('og_notification', OG_NOTIFICATION_ALWAYS), '#description' =>t('Should new members automatically be notified via email when new content is posted to their group? Note that changing this setting has no effect on existing members.'), '#options' => $options); 2744 2489 2745 // audience checkboxes 2490 2746 $form['og_settings']['group_details']['og_audience_checkboxes'] = array('#type' => 'checkbox', '#title' => t('Audience checkboxes'), '#default_value' => variable_get('og_audience_checkboxes', TRUE), '#description' => t('Show each group that the user is a member of as a checkbox in the Audience section. This enables the member to place her post into multiple groups. If unchecked, simplify the user interface by omitting the checkboxes and assuming user wants to post into the current group. This simplification only applies to new nodes, and not to edits of existing nodes. Group administrators always see checkboxes.')); … … 2502 2758 $form['og_settings']['group_details']['og_member_pics'] = array('#type' => 'checkbox', '#title' => t('Member pictures'), '#default_value' => variable_get('og_member_pics', TRUE), '#description' => t('Should member pictures be shown on the members page, the group members block, and group details block? You must also enable pictures in !user.', array('!user' => l(t('User configuration'), 'admin/user/settings')))); 2503 2759 2504 // Messages fieldset. 2505 $form['og_settings']['notifications'] = array( 2506 '#type' => 'fieldset', 2507 '#title' => t('Messaging & Notifications'), 2508 '#collapsible' => TRUE, 2509 '#collapsed' => TRUE 2510 ); 2511 $form['og_settings']['notifications']['og_email_notification_pattern'] = array( 2760 $form['og_settings']['email'] = array('#type' => 'fieldset', '#title' => t('Email settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); 2761 2762 $form['og_settings']['email']['og_email_notification_pattern'] = array( 2512 2763 '#type' => 'textfield', 2513 2764 '#title' => t('Format of From: field'), … … 2515 2766 '#description' => t('Specify the format of the "From:" field on outgoing notifications. Available variables: @user_mail, @user_name, @site_mail, @site_name. Note that the @user_mail token reveals the author\'s email address. If the admin email examples above appear blank, you need to set your site email in the Site Configuration panel.'), 2516 2767 ); 2517 $form['og_settings']['notifications']['og_new_node_subject'] = array( 2518 '#type' => 'textfield', 2519 '#title' => t('New content subject'), 2520 '#description' => t('Subject of notification message for new content. Available variables: @group, !group_url, @type, @site, !content_url, !reply_url, @title, @subject, @node_full, @node_teaser, @username. %subject contains the comment title in the case of a comment but the node title in the case of a new post. @title is always the node title.'), 2521 '#default_value' => _og_user_mail_text('og_new_node_subject') 2522 ); 2523 $form['og_settings']['notifications']['og_new_node_body'] = array( 2524 '#type' => 'textarea', 2525 '#title' => t('New content body'), 2526 '#rows' => 10, 2527 '#description' => t('Body of the notification for new content. Available variables: @group, !group_url, @type, @site, !content_url, !reply_url, @title, @subject, @node_full, @node_teaser, @username. @subject contains the comment title in the case of a comment but the node title in the case of a new post. %title is always the node title.'), 2528 '#default_value' => _og_user_mail_text('og_new_node_body') 2529 ); 2530 $form['og_settings']['notifications']['og_admin_email_body'] = array( 2531 '#type' => 'textarea', 2532 '#title' => t('Group admin notification body'), 2533 '#rows' => 10, 2534 '#description' => t('The body of the message sent to users from the group admin. Available variables: @group, @body, @site, !url_group, !url_unsubscribe'), 2535 '#default_value' => _og_user_mail_text('og_admin_email_body') 2536 ); 2537 $form['og_settings']['notifications']['og_approve_user_subject'] = array( 2538 '#type' => 'textfield', 2539 '#title' => t('User approved notification subject'), 2540 '#description' => t('The subject of the message sent to new approved members. Available variables: !group_url, @title'), 2541 '#default_value' => _og_user_mail_text('og_approve_user_subject') 2542 ); 2543 $form['og_settings']['notifications']['og_approve_user_body'] = array( 2544 '#type' => 'textarea', 2545 '#title' => t('User approved notification body'), 2546 '#rows' => 10, 2547 '#description' => t('The body of the message sent to new approved members. Available variables: !group_url, @title'), 2548 '#default_value' => _og_user_mail_text('og_approve_user_body') 2549 ); 2550 $form['og_settings']['notifications']['og_deny_user_subject'] = array( 2551 '#type' => 'textfield', 2552 '#title' => t('User denied notification subject'), 2553 '#description' => t('The subject of the message sent to denied users. Available variables: !group_url, @title'), 2554 '#default_value' => _og_user_mail_text('og_deny_user_subject') 2555 ); 2556 $form['og_settings']['notifications']['og_deny_user_body'] = array( 2557 '#type' => 'textarea', 2558 '#title' => t('User denied notification body'), 2559 '#rows' => 10, 2560 '#description' => t('The body of the message sent to denied users. Available variables: !group_url, @title'), 2561 '#default_value' => _og_user_mail_text('og_deny_user_body') 2562 ); 2563 $form['og_settings']['notifications']['og_invite_user_subject'] = array( 2564 '#type' => 'textfield', 2565 '#title' => t('Invite user notification subject'), 2566 '#description' => t('The subject of the message sent to users invited to join a group. Available variables: @group, @site, @description, !group_url, @body'), 2567 '#default_value' => _og_user_mail_text('og_invite_user_subject') 2568 ); 2569 $form['og_settings']['notifications']['og_invite_user_body'] = array( 2570 '#type' => 'textarea', 2571 '#title' => t('Invite user notification body'), 2572 '#rows' => 10, 2573 '#description' => t('The body of the message sent to users invited to join a group. Available variables: @group, @site, @description, !group_url, @body'), 2574 '#default_value' => _og_user_mail_text('og_invite_user_body') 2575 ); 2576 $form['og_settings']['notifications']['og_request_user_subject'] = array( 2577 '#type' => 'textfield', 2578 '#title' => t('Request user notification subject'), 2579 '#description' => t("The subject of the message sent to a user's request to join a group. Available variables: @group, @username, !approve_url, !group_url"), 2580 '#default_value' => _og_user_mail_text('og_request_user_subject') 2581 ); 2582 $form['og_settings']['notifications']['og_request_user_body'] = array( 2583 '#type' => 'textarea', 2584 '#title' => t('Request user notification body'), 2585 '#rows' => 10, 2586 '#description' => t("The body of the message sent to a user's request to join a group. Available variables: @group, @username, !approve_url, !group_url"), 2587 '#default_value' => _og_user_mail_text('og_request_user_body') 2588 ); 2589 $form['og_settings']['notifications']['og_new_admin_subject'] = array( 2590 '#type' => 'textfield', 2591 '#title' => t('New admin user notification subject'), 2592 '#description' => t('The subject of the message sent to a new admin for a group. Available variables: @group, @username, !group_url'), 2593 '#default_value' => _og_user_mail_text('og_new_admin_subject') 2594 ); 2595 $form['og_settings']['notifications']['og_new_admin_body'] = array( 2596 '#type' => 'textarea', 2597 '#title' => t('New admin user notification body'), 2598 '#rows' => 10, 2599 '#description' => t('The body of the message sent to a new admin for a group. Available variables: @group, @username, !group_url, !invite_url'), 2600 '#default_value' => _og_user_mail_text('og_new_admin_body') 2601 ); 2768 $form['og_settings']['email']['og_new_node_subject'] = array('#type' => 'textfield', '#title' => t('New content subject'), '#description' => 'Subject of email for new content. Available variables: @group, !group_url, @type, @site, !content_url, !reply_url, @title, @subject, @node_full, @node_teaser, @username. %subject contains the comment title in the case of a comment but the node title in the case of a new post. @title is always the node title.', '#default_value' => _og_user_mail_text('og_new_node_subject')); 2769 $form['og_settings']['email']['og_new_node_body'] = array('#type' => 'textarea', '#title' => t('New content body'), '#rows' => 10, '#description' => 'Body of email for new content. Available variables: @group, !group_url, @type, @site, !content_url, !reply_url, @title, @subject, @node_full, @node_teaser, @username. @subject contains the comment title in the case of a comment but the node title in the case of a new post. %title is always the node title.', '#default_value' => _og_user_mail_text('og_new_node_body')); 2770 $form['og_settings']['email']['og_admin_email_body'] = array('#type' => 'textarea', '#title' => t('Group admin email body'), '#rows' => 10, '#description' => 'The body of the email sent to users from the group admin. Available variables: @group, @body, @site, !url_group, !url_unsubscribe', '#default_value' => _og_user_mail_text('og_admin_email_body')); 2771 $form['og_settings']['email']['og_approve_user_subject'] = array('#type' => 'textfield', '#title' => t('User approved email subject'), '#description' => 'The subject of the email sent to new approved members. Available variables: !group_url, @title', '#default_value' => _og_user_mail_text('og_approve_user_subject')); 2772 $form['og_settings']['email']['og_approve_user_body'] = array('#type' => 'textarea', '#title' => t('User approved email body'), '#rows' => 10, '#description' => 'The body of the email sent to new approved members. Available variables: !group_url, @title', '#default_value' => _og_user_mail_text('og_approve_user_body')); 2773 $form['og_settings']['email']['og_deny_user_subject'] = array('#type' => 'textfield', '#title' => t('User denied email subject'), '#description' => 'The subject of the email sent to denied users. Available variables: !group_url, @title', '#default_value' => _og_user_mail_text('og_deny_user_subject')); 2774 $form['og_settings']['email']['og_deny_user_body'] = array('#type' => 'textarea', '#title' => t('User denied email body'), '#rows' => 10, '#description' => 'The body of the email sent to denied users. Available variables: !group_url, @title', '#default_value' => _og_user_mail_text('og_deny_user_body')); 2775 $form['og_settings']['email']['og_invite_user_subject'] = array('#type' => 'textfield', '#title' => t('Invite user email subject'), '#description' => 'The subject of the email sent to users invited to join a group. Available variables: @group, @site, @description, !group_url, @body', '#default_value' => _og_user_mail_text('og_invite_user_subject')); 2776 $form['og_settings']['email']['og_invite_user_body'] = array('#type' => 'textarea', '#title' => t('Invite user email body'), '#rows' => 10, '#description' => 'The body of the email sent to users invited to join a group. Available variables: @group, @site, @description, !group_url, @body', '#default_value' => _og_user_mail_text('og_invite_user_body')); 2777 $form['og_settings']['email']['og_request_user_subject'] = array('#type' => 'textfield', '#title' => t('Request user email subject'), '#description' => 'The subject of the email sent to a user\'s request to join a group. Available variables: @group, @username, !approve_url, !group_url', '#default_value' => _og_user_mail_text('og_request_user_subject')); 2778 $form['og_settings']['email']['og_request_user_body'] = array('#type' => 'textarea', '#title' => t('Request user email body'), '#rows' => 10, '#description' => 'The body of the email sent to a user\'s request to join a group. Available variables: @group, @username, !approve_url, !group_url', '#default_value' => _og_user_mail_text('og_request_user_body')); 2779 $form['og_settings']['email']['og_new_admin_subject'] = array('#type' => 'textfield', '#title' => t('New admin user email subject'), '#description' => 'The subject of the email sent to a new admin for a group. Available variables: @group, @username, !group_url', '#default_value' => _og_user_mail_text('og_new_admin_subject')); 2780 $form['og_settings']['email']['og_new_admin_body'] = array('#type' => 'textarea', '#title' => t('New admin user email body'), '#rows' => 10, '#description' => 'The body of the email sent to a new admin for a group. Available variables: @group, @username, !group_url, !invite_url', '#default_value' => _og_user_mail_text('og_new_admin_body')); 2602 2781 2603 2782 return system_settings_form($form); … … 2649 2828 'og_xmlrpc_subscribe_user', 2650 2829 array('struct', 'string', 'string', 'int', 'int'), 2651 t('Add a user to a group .')),2830 t('Add a user to a group')), 2652 2831 array( 2653 2832 'og.getAllSubscribers', … … 2709 2888 switch ($type) { 2710 2889 case 'node': 2711 // Set some defaults.2712 $values['ogname'] = '';2713 $values['ogname-raw'] = '';2714 $values['og-id'] = '';2715 $values['og-type'] = '';2716 $values['og-type-name'] = '';2717 2718 2890 if (is_array($object->og_groups)) { 2719 2891 $gids = array_filter($object->og_groups); … … 2728 2900 break; 2729 2901 } 2730 } 2731 return $values; 2732 } 2733 2734 return; 2902 return $values; 2903 } 2904 break; 2905 } 2906 2907 // No group info found. Return defaults. 2908 $values['ogname'] = ''; 2909 $values['ogname-raw'] = ''; 2910 $values['og-id'] = ''; 2911 $values['og-type-name'] = ''; 2912 $values['og-type'] = ''; 2913 return $values; 2735 2914 } 2736 2915 … … 2747 2926 $query['where'] = 'oga.group_nid = '. $args['og_nid']; 2748 2927 return $query; 2928 } 2929 } 2930 2931 // A hook from replies.module. Return TRUE if og is handling the notification to a given recipient on a given reply 2932 function og_replies_mine($comment, $recipient) { 2933 $node = node_load($comment->nid); 2934 // check each group that this node is in 2935 foreach ((array)$node->og_groups as $gid) { 2936 // check if recipient is an active member 2937 if (isset($recipient->og_groups[$gid]) && $recipient->og_groups[$gid]['is_active']) { 2938 // check if user is already getting this group notification 2939 if ($recipient->og_email || $recipient->og_groups[$gid]['mail_type']) { 2940 return TRUE; 2941 } 2942 } 2749 2943 } 2750 2944 } … … 2765 2959 } 2766 2960 2961 if (!module_exists('job_queue')) { 2962 $requirements['og_modules'] = array( 2963 'title' => $t('Organic groups modules'), 2964 'value' => $t('Organic groups works best when !job_queue.module is enabled. See the Integration section of the !readme.', array('!job_queue' => l('job_queue.module', 'http://drupal.org/project/job_queue'), '!readme' => og_readme())), 2965 'severity' => REQUIREMENT_INFO 2966 ); 2967 } 2968 2767 2969 if (!module_exists('og_access')) { 2768 2970 $requirements['og_access'] = array( … … 2799 3001 return FALSE; 2800 3002 } 2801 2802 /**2803 * Access callback: og_notifications (or similar) is required for the broadcast2804 * tab. Override menu item to amend.2805 */2806 function og_broadcast_access($node) {2807 return og_is_node_admin($node) && module_exists('og_notifications');2808 } -
trunk/sites/all/modules/og/og_access.info
r152 r224 3 3 package = "Organic groups" 4 4 dependencies = og 5 ; Information added by drupal.org packaging script on 2008-05-12 6 version = "5.x-7.2" 7 project = "og" 8 datestamp = "1210629035" 9 -
trunk/sites/all/modules/og/og_access.module
r152 r224 1 1 <?php 2 // $Id: og_access.module,v 1.1.2.1 1 2008/05/26 14:03:35weitzman Exp $2 // $Id: og_access.module,v 1.1.2.10 2008/05/08 19:49:26 weitzman Exp $ 3 3 4 4 // visibility states for private groups. site admin chooses in og_access_settings() … … 18 18 $items[] = array( 19 19 'path' => 'admin/og/og_access', 20 'title' => t('Organic groups access configuration'),20 'title' => t('Organic Groups Access configuration'), 21 21 'description' => t('Choose whether new groups should be private or public'), 22 22 'callback' => 'drupal_get_form', … … 31 31 drupal_add_js(drupal_get_path('module', 'og_access'). '/og_access.js'); // load the form javascript to handle private groups / node visibility conflicts in the og access settings form. 32 32 33 $options = array(t('Visible only within the targeted groups .'), t('Visible within the targeted groups and on other pages.'), t('Visibility chosen by author/editor using a checkbox on the posting form.') .' '. t('Checkbox defaults to @pub.', array('@pub' => t('Public'))), t('Visibility chosen by author/editor using a checkbox on the posting form. '). t('Checkbox defaults to @pri.', array('@pri' => t('Private'))));34 $form['og_visibility'] = array('#type' => 'radios', '#title' => t('Visibility of posts'), '#default_value' => variable_get('og_visibility', 0), '#description' =>t('Determine how broadly available a given post should be when it is affiliated with a group. OG admins always see the checkbox for making a post @pub. Note that changing this setting has no effect on existing posts. Re-save those posts to acquire this new setting. If the setting you want is disabled here, check the settings under <em>Private Groups</em> setting below.You cannot set node visibility to always be public if private groups are set to always on and vice versa.', array('@pub' => t('Public'))), '#options' => $options);33 $options = array(t('Visible only within the targeted groups'), t('Visible within the targeted groups and on other pages'), t('Visibility chosen by author/editor using a checkbox on the posting form. '). t('Checkbox defaults to @pub.', array('@pub' => t('Public'))), t('Visibility chosen by author/editor using a checkbox on the posting form. '). t('Checkbox defaults to @pri.', array('@pri' => t('Private')))); 34 $form['og_visibility'] = array('#type' => 'radios', '#title' => t('Visibility of posts'), '#default_value' => variable_get('og_visibility', 0), '#description' =>t('Determine how broadly available a given post should be when it is affiliated with a group. OG admins always see the checkbox for making a post @pub. Note that changing this setting has no effect on existing posts. Re-save those posts to acquire this new setting. If the setting you want is disabled here, check the settings under <em>Private Groups</em> setting below. You cannot set node visibility to always be public if private groups are set to always on and vice versa.', array('@pub' => t('Public'))), '#options' => $options); 35 35 36 36 // private groups control … … 45 45 '#options' => $options, 46 46 '#default_value' => variable_get('og_private_groups', OG_PRIVATE_GROUPS_CHOOSE_FALSE), 47 '#description' => '<p>'. t("A private group's group home page cannot be seen by non-members, and new posts created in the group will default to being private. This setting controls what private groups options can be used when creating a new group or editing an existing group. If you select one of the <em>group administrator chooses</em> options then it will be up to group admins whether their new groups are private or not, with the default you specify here.") .'<p><p>'. t('Note that the privacy of all <em>content</em> in the group is determined as each node is created or edited, according to the <em>Node authoring form / Visibility of Posts</em> setting on this page. Note also that changing this setting only affects the default for new groups being created, not the privacy of any existing groups! To change those you must edit the groups and their individual content nodes directly. If the setting you want is disabled here, check <em>Visibility of Posts</em> above. You cannot choose to only have private groups if node visibility is set to be always public, and vice versa.') .'</p>',47 '#description' =>t("<p>A private group's group home page cannot be seen by non-members, and new posts created in the group will default to being private. This setting controls what private groups options can be used when creating a new group or editing an existing group. If you select one of the <em>group administrator chooses</em> options then it will be up to group admins whether their new groups are private or not, with the default you specify here.<p><p>Note that the privacy of all <em>content</em> in the group is determined as each node is created or edited, according to the <em>Node authoring form / Visibility of Posts</em> setting on this page. Note also that changing this setting only affects the default for new groups being created, not the privacy of any existing groups! To change those you must edit the groups and their individual content nodes directly. If the setting you want is disabled here, check <em>Visibility of Posts</em> above. You cannot choose to only have private groups if node visibility is set to be always public, and vice versa.</p>"), 48 48 ); 49 49 return system_settings_form($form); … … 82 82 $form['og_private'] = array ( 83 83 '#type' => 'checkbox', 84 '#title' => t(' Private group'),84 '#title' => t('private group'), 85 85 '#default_value' => $node->nid ? $node->og_private : $default, 86 '#description' => t('Should this group be visible only to its members? Disabled if the group is set to <em>List in Directory</em> or <em>Membership requests: open</em>.'));86 '#description' => t('Should this group be visible only to its members? Disabled if the group is set to <em>List in Directory</em> or <em>Membership requests: open</em>')); 87 87 break; 88 88 } … … 258 258 function og_access_node_access_explain($row) { 259 259 if ($row->realm == 'og_public') { 260 return t('All users may view this node.' );260 return t('All users may view this node.', array('@op' => $op)); 261 261 } 262 262 elseif ($row->realm == 'og_subscriber') { 263 263 $node = node_load((int)$row->gid); 264 return t('Members of !group_n may view this node.', array(' !group_n' => l($node->title, "node/$row->gid")));265 } 266 } 264 return t('Members of !group_n may view this node.', array('@op' => $op, '!group_n' => l($node->title, "node/$row->gid"))); 265 } 266 } -
trunk/sites/all/modules/og/og_panels.info
r152 r224 4 4 package = "Organic groups" 5 5 dependencies = og panels panels_views 6 ; Information added by drupal.org packaging script on 2008-05-12 7 version = "5.x-7.2" 8 project = "og" 9 datestamp = "1210629035" 10 -
trunk/sites/all/modules/og/og_panels.install
r152 r224 1 1 <?php 2 // $Id: og_panels.install,v 1.1.2.4 .2.1 2008/10/31 12:16:14weitzman Exp $2 // $Id: og_panels.install,v 1.1.2.4 2008/03/17 15:04:28 weitzman Exp $ 3 3 4 4 function og_panels_install() { … … 27 27 default_page integer NULL, 28 28 show_blocks integer NULL, 29 weight smallintNOT NULL DEFAULT 0,29 weight integer(4) NOT NULL DEFAULT 0, 30 30 PRIMARY KEY (did) 31 31 );"); -
trunk/sites/all/modules/og/og_panels.module
r152 r224 1 1 <?php 2 // $Id: og_panels.module,v 1.1.2.3 2.2.1 2008/10/31 12:12:27weitzman Exp $2 // $Id: og_panels.module,v 1.1.2.30 2008/04/20 17:51:10 weitzman Exp $ 3 3 4 4 function og_panels_help($section) { … … 7 7 return t('After enabling this module, visit the new Pages tab on any group. There, group admins may create as many pages as desired for their group. The pages may contain any layout that the site offers and admins may arrange many different types of content as desired. Site admins can restrict the types of content that may be added on the <a href="!settings">og_panels settings</a> page. You might want to make some Views available using <a href="!apv">admin/panels/views</a>. Group admins may designate one page as their group home page.', array('!settings' => url('admin/og/og_panels'), '!apv' => url('admin/panels/views'))); 8 8 case (arg(0) == 'node' && arg(2) == 'og_panels' && !arg(3)): 9 return '<p>'. t('Create custom pages for your group. Use custom pages to organize your content in a pretty and informative manner. Your group can group to be a whole website within a web site. Each custom page becomes a tab when viewing your group. One of your custom pages should be designated as your <em>group home page</em>. That page will then display when visitors first arrive at your group.') .'</p><p>'. t('Start by clicking the <a href="!url">Add new page</a> tab. Then you will choose a custom layout for your page. Then you will want to <em>edit content</em> for your custom page.', array('!url' => url('node/'. arg(1). '/og_panels/form'))) .'</p>'; 9 return t( 10 '<p>Create custom pages for your group. Use custom pages to organize your content in a pretty and informative manner. Your group can group to be a whole website within a web site. Each custom page becomes a tab when viewing your group. One of your custom pages should be designated as your <em>group home page</em>. That page will then display when visitors first arrive at your group.</p> 11 <p>Start by clicking the <a href="!url">Add new page</a> tab. Then you will choose a custom layout for your page. Then you will want to <em>edit content</em> for your custom page.</p>', array('!url' => url('node/'. arg(1). '/og_panels/form'))); 10 12 } 11 13 } … … 15 17 $items[] = array( 16 18 'path' => 'admin/og/og_panels', 17 'title' => t('Organic groups panels'),18 'description' => t('Configure the content that is available to group admins when creating group pages.'),19 'title' => 'Organic groups panels', 20 'description' => 'Configure the content that is available to group admins when creating group pages.', 19 21 'callback' => 'og_panels_admin_content', 20 22 'access' => user_access('administer organic groups'), … … 150 152 function og_panels_delete_confirm_submit($form_id, $form_values) { 151 153 og_panels_delete($form_values['did']); 152 drupal_set_message(t('%title has been deleted .', array('%title' => $form_values['page_title'])));154 drupal_set_message(t('%title has been deleted', array('%title' => $form_values['page_title']))); 153 155 } 154 156 … … 182 184 $item['page_title'] = array('#value' => l($display->page_title, "node/$nid/$display->path")); 183 185 $item['weight'] = array('#type' => 'weight', '#default_value' => $display->weight); 184 $item['edit content'] = array('#value' => l(t(' Edit content'), "node/$nid/og_panels/$display->did/panel_content", array(), drupal_get_destination()));185 $item['change layout'] = array('#value' => l(t(' Change layout'), "node/$nid/og_panels/$display->did/panel_layout"));186 $item['edit layout settings'] = array('#value' => l(t(' Edit layout settings'), "node/$nid/og_panels/$display->did/panel_settings"));187 $item['edit page'] = array('#value' => l(t(' Edit page'), "node/$nid/og_panels/form/$display->did", array(), drupal_get_destination()));188 $item['delete page'] = array('#value' => l(t(' Delete page'), "node/$nid/og_panels/$display->did/delete", array(), drupal_get_destination()));186 $item['edit content'] = array('#value' => l(t('edit content'), "node/$nid/og_panels/$display->did/panel_content", array(), drupal_get_destination())); 187 $item['change layout'] = array('#value' => l(t('change layout'), "node/$nid/og_panels/$display->did/panel_layout")); 188 $item['edit layout settings'] = array('#value' => l(t('edit layout settings'), "node/$nid/og_panels/$display->did/panel_settings")); 189 $item['edit page'] = array('#value' => l(t('edit page'), "node/$nid/og_panels/form/$display->did", array(), drupal_get_destination())); 190 $item['delete page'] = array('#value' => l(t('delete page'), "node/$nid/og_panels/$display->did/delete", array(), drupal_get_destination())); 189 191 190 192 $form['displays'][$display->did] = $item; … … 205 207 $form['submit'] = array( 206 208 '#type' => 'submit', 207 '#value' => t('Save settings'),209 '#value' => t('Save Settings'), 208 210 ); 209 211 … … 271 273 drupal_set_breadcrumb($bc); 272 274 // Mark node as read and show feed icon for any group panel page (how to do this better?) 273 drupal_add_feed(url("node/$ group_node->nid/feed"), t('@name at @site', array('@name' => $group_node->title, '@site' => variable_get('site_name', 'drupal'))));274 node_tag_new($ group_node->nid);275 drupal_add_feed(url("node/$nid/feed"), t('@name at @site', array('@name' => $node->title, '@site' => variable_get('site_name', 'drupal')))); 276 node_tag_new($node->nid); 275 277 276 278 … … 579 581 580 582 $items['og_subscribers'] = array( 581 'title' => t('OG members'),583 'title' => t('OG Members'), 582 584 'content_types' => 'og_panels_ct_list_subscribers', 583 585 'single' => TRUE, // only provides a single content type … … 602 604 if (og_is_picture()) { 603 605 $items['og_faces'] = array( 604 'title' => t('OG faces'),606 'title' => t('OG Faces'), 605 607 'content_types' => 'og_panels_ct_list_faces', 606 608 'single' => TRUE, // only provides a single content type … … 634 636 switch ($delta) { 635 637 case 2: 636 // Provide alternate versions of thesecontent items638 // Provide alternate versions as content items 637 639 unset($info); 638 640 break; 639 default:641 case 'default': 640 642 $info['icon'] = 'user-multiple.png'; 641 643 $info['required context'] = new panels_required_context(t('Group'), 'group'); -
trunk/sites/all/modules/og/og_views.inc
r152 r224 1 1 <?php 2 // $Id: og_views.inc,v 1.12.2.5 5.2.4 2008/10/06 07:56:45 karthikExp $2 // $Id: og_views.inc,v 1.12.2.54 2008/05/08 19:49:26 weitzman Exp $ 3 3 /** 4 4 * Implementation of the hook_views_tables() … … 32 32 ), 33 33 'count' => array( 34 'name' => t('OG: Group: Members count'),34 'name' => t('OG: Group: Members Count'), 35 35 'handler' => 'og_handler_field_count', 36 36 'help' => t('Number of members for a group. Excludes memberships which are pending approval.'), … … 39 39 ), 40 40 'post_count' => array( 41 'name' => t('OG: Group: Post count'),41 'name' => t('OG: Group: Post Count'), 42 42 'handler' => 'og_handler_post_count', 43 43 'sortable' => FALSE, … … 53 53 ), 54 54 'post_count_new' => array( 55 'name' => t('OG: Group: Post count *new*'),55 'name' => t('OG: Group: Post Count *New*'), 56 56 'handler' => 'og_handler_post_count_new', 57 57 'sortable' => FALSE, … … 61 61 '#type' => 'select', 62 62 '#options' => array( 63 'normal' => t('Normal'),64 'withmark' => t('With new mark')63 'normal' => 'Normal', 64 'withmark' => 'With new mark' 65 65 ), 66 66 ), … … 71 71 'private' => array( 72 72 'name' => t('OG: Group: Private'), 73 'handler' => 'og_handler_field_private',74 'sortable' => TRUE,75 'help' => t('Displays whether a group is private or public with respect to groups.'),76 73 ), 77 74 'subscribe' => array( … … 82 79 'notafield' => TRUE, 83 80 'help' => t('Displays a links for joining a group when a user is not already a member.'), 81 ), 82 'notification' => array( 83 'name' => t('OG: Group: Notification'), 84 'handler' => 'og_handler_field_yesempty', 85 'help' => t('Displays <em>yes</em> if group automatically sends email notifications to members'), 84 86 ), 85 87 'language' => array( … … 224 226 ), 225 227 'fields' => array( 228 'mail_type' => array( 229 'name' => t('OG: Subscription email'), 230 'handler' => 'og_handler_field_yesempty', 231 'sortable' => false, 232 'help' => t('Does member receive email notifications for a group.'), 233 ), 226 234 'managelink' => array( 227 235 'name' => t('OG: Manage membership link'), … … 239 247 'currentuidsimple' => array( 240 248 'field' => 'uid', 241 'name' => t( "OG: Group in user's groups"),249 'name' => t('OG: Group in User\'s Groups'), 242 250 'operator' => 'views_handler_operator_eqneq', 243 251 'list' => 'views_handler_filter_usercurrent', … … 324 332 ), 325 333 'help' => t('Filter for the one or more organic groups. Groups should be specified by name, or part of a name. Use the <em>Option</em> field to specify how to match the supplied name.'), 326 ), 327 'og_uid' => array( 328 'name' => t('OG: User is subscribed to group'), 329 'handler' => 'og_views_handler_argument_uid', 330 'help' => t("Filter for groups that user is subscribed to. User is specified by user ID (integer). This argument exposes a user's group subscriptions to other users. Depending on your site, this may be a violation of their privacy. Use it thoughfully."), 331 ), 334 ) 332 335 ); 333 336 return $args; … … 360 363 case 'title': 361 364 return db_result(db_query_range('SELECT title FROM {node} WHERE nid = %d', $query, 0, 1));; 362 }363 }364 365 /**366 * Custom argument for filtering by groups that a user is subscribed to367 */368 function og_views_handler_argument_uid($op, &$query, $a1, $a2 = null) {369 switch ($op) {370 case 'filter':371 $query->ensure_table('og_uid');372 $query->add_where("og_uid.uid = %d", $a2);373 break;374 case 'title':375 // This returns the title for this node in the title, breadcrumb, etc.376 return db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $a2));377 365 } 378 366 } … … 437 425 $view = new stdClass(); 438 426 $view->name = 'og_mytracker'; 439 $view->description = t('Shows all activity in subscribed groups.');427 $view->description = 'Shows all activity in subscribed groups.'; 440 428 $view->access = array ( 441 429 0 => '2', … … 443 431 $view->view_args_php = ''; 444 432 $view->page = TRUE; 445 $view->page_title = t('Recent posts in my groups');433 $view->page_title = 'Recent posts in my groups'; 446 434 $view->page_header = ''; 447 435 $view->page_header_format = '1'; 448 436 $view->page_footer = ''; 449 437 $view->page_footer_format = '1'; 450 $view->page_empty = t('There are no posts in your subscribed groups.');438 $view->page_empty = 'There are no posts in your subscribed groups.'; 451 439 $view->page_empty_format = '1'; 452 440 $view->page_type = 'table'; … … 455 443 $view->nodes_per_page = '25'; 456 444 $view->menu = TRUE; 457 $view->menu_title = t('My recent');445 $view->menu_title = 'My recent'; 458 446 $view->menu_tab = TRUE; 459 447 $view->menu_tab_weight = '0'; … … 490 478 'tablename' => 'node', 491 479 'field' => 'title', 492 'label' => t('Title'),480 'label' => 'Title', 493 481 'handler' => 'views_handler_field_nodelink_with_mark', 494 482 'sortable' => '1', … … 498 486 'tablename' => 'users', 499 487 'field' => 'name', 500 'label' => t('Author'),488 'label' => 'Author', 501 489 'sortable' => '1', 502 490 ), … … 504 492 'tablename' => 'node_comment_statistics', 505 493 'field' => 'comment_count', 506 'label' => t('Replies'),494 'label' => 'Replies', 507 495 'handler' => 'views_handler_comments_with_new', 508 496 'sortable' => '1', … … 511 499 'tablename' => 'node_comment_statistics', 512 500 'field' => 'last_comment_timestamp', 513 'label' => t('Last post'),501 'label' => 'Last Post', 514 502 'handler' => 'views_handler_field_since', 515 503 'sortable' => '1', … … 541 529 $view = new stdClass(); 542 530 $view->name = 'og_unread'; 543 $view->description = t('Shows unread posts in subscribed groups.');531 $view->description = 'Shows unread posts in subscribed groups.'; 544 532 $view->access = array ( 545 533 0 => '2', … … 547 535 $view->view_args_php = ''; 548 536 $view->page = TRUE; 549 $view->page_title = t('Unread posts in my groups');537 $view->page_title = 'Unread posts in my groups'; 550 538 $view->page_header = ''; 551 539 $view->page_header_format = '1'; 552 540 $view->page_footer = ''; 553 541 $view->page_footer_format = '1'; 554 $view->page_empty = t('There are no new posts in your subscribed groups.');542 $view->page_empty = 'There are no new posts in your subscribed groups.'; 555 543 $view->page_empty_format = '1'; 556 544 $view->page_type = 'table'; … … 559 547 $view->nodes_per_page = '25'; 560 548 $view->menu = TRUE; 561 $view->menu_title = t('My unread');549 $view->menu_title = 'My unread'; 562 550 $view->menu_tab = TRUE; 563 551 $view->menu_tab_weight = '-5'; … … 583 571 'tablename' => 'og_node_data', 584 572 'field' => 'title', 585 'label' => t('Group'),573 'label' => 'Group', 586 574 ), 587 575 array ( 588 576 'tablename' => 'node', 589 577 'field' => 'type', 590 'label' => t('Type'),578 'label' => 'Type', 591 579 'sortable' => '1', 592 580 ), … … 594 582 'tablename' => 'node', 595 583 'field' => 'title', 596 'label' => t('Title'),584 'label' => 'Title', 597 585 'handler' => 'views_handler_field_nodelink_with_mark', 598 586 'sortable' => '1', … … 602 590 'tablename' => 'users', 603 591 'field' => 'name', 604 'label' => t('Author'),592 'label' => 'Author', 605 593 'sortable' => '1', 606 594 ), … … 608 596 'tablename' => 'node_comment_statistics', 609 597 'field' => 'comment_count', 610 'label' => t('Replies'),598 'label' => 'Replies', 611 599 'handler' => 'views_handler_comments_with_new', 612 600 'sortable' => '1', … … 615 603 'tablename' => 'node_comment_statistics', 616 604 'field' => 'last_comment_timestamp', 617 'label' => t('Last post'),605 'label' => 'Last Post', 618 606 'handler' => 'views_handler_field_since', 619 607 'sortable' => '1', … … 656 644 $view = new stdClass(); 657 645 $view->name = 'og_ghp_ron'; 658 $view->description = t('OG: Group home page - River of news. Default');646 $view->description = 'OG: Group home page - River of news. Default'; 659 647 $view->page = TRUE; 660 648 $view->page_type = 'teaser'; … … 711 699 $view = new stdClass(); 712 700 $view->name = 'og_my'; 713 $view->description = t("List user's subscribed groups and provide link to manage subscription");701 $view->description = 'List user\'s subscribed groups and provide link to manage subscription'; 714 702 $view->access = array ( 715 703 0 => '2', … … 717 705 $view->view_args_php = ''; 718 706 $view->page = TRUE; 719 $view->page_title = t('My groups');720 $view->page_header = t('You might be interested in an <a href="!url" rel="nofollow">OPML feed containing feeds from all your subscribed groups</a>.', array('!url' => url('og/opml')));707 $view->page_title = 'My groups'; 708 $view->page_header = strtr('You may edit all your email subscriptions using this convenient page. Also, you might be interested in an <a href="!url" rel="nofollow">OPML feed containing feeds from all your subscribed groups</a>.', array('!url' => url('og/opml'))); 721 709 $view->page_header_format = '1'; 722 710 $view->page_footer = '<?php … … 727 715 ?>'; 728 716 $view->page_footer_format = '2'; 729 $view->page_empty = t('No subscribed groups');717 $view->page_empty = 'No subscribed groups'; 730 718 $view->page_empty_format = '1'; 731 719 $view->page_type = 'table'; … … 764 752 'tablename' => 'node', 765 753 'field' => 'title', 766 'label' => t('Group'),754 'label' => 'Group', 767 755 'handler' => 'views_handler_field_nodelink', 768 756 'options' => 'link', … … 771 759 'tablename' => 'users', 772 760 'field' => 'name', 773 'label' => t('Manager'),761 'label' => 'Manager', 774 762 ), 775 763 array ( 776 764 'tablename' => 'og', 777 765 'field' => 'count', 778 'label' => t('Members'), 766 'label' => 'Members', 767 ), 768 array ( 769 'tablename' => 'og_uid', 770 'field' => 'mail_type', 771 'label' => 'Email', 779 772 ), 780 773 array ( 781 774 'tablename' => 'og_uid', 782 775 'field' => 'managelink', 783 'label' => t('Manage'),776 'label' => 'Manage', 784 777 ), 785 778 ); … … 821 814 $view->view_args_php = ''; 822 815 $view->page = TRUE; 823 $view->page_title = t('Groups directory');816 $view->page_title = 'Groups directory'; 824 817 $view->page_header = ''; 825 818 $view->page_header_format = '2'; 826 819 $view->page_footer = ''; 827 820 $view->page_footer_format = '1'; 828 $view->page_empty = t('No groups');821 $view->page_empty = 'No groups'; 829 822 $view->page_empty_format = '1'; 830 823 $view->page_type = 'table'; … … 833 826 $view->nodes_per_page = '90'; 834 827 $view->menu = TRUE; 835 $view->menu_title = t('Groups');828 $view->menu_title = 'Groups'; 836 829 $view->menu_tab = TRUE; 837 830 $view->menu_tab_weight = '-5'; … … 857 850 'tablename' => 'node', 858 851 'field' => 'title', 859 'label' => t('Group'),852 'label' => 'Group', 860 853 'handler' => 'views_handler_field_nodelink', 861 854 'sortable' => '1', … … 865 858 'tablename' => 'users', 866 859 'field' => 'name', 867 'label' => t('Manager'),860 'label' => 'Manager', 868 861 ), 869 862 array ( 870 863 'tablename' => 'og', 871 864 'field' => 'count', 872 'label' => t('Members'),865 'label' => 'Members', 873 866 ), 874 867 array ( 875 868 'tablename' => 'og', 876 869 'field' => 'description', 877 'label' => t('Description'),870 'label' => 'Description', 878 871 ), 879 872 array ( 880 873 'tablename' => 'og', 881 874 'field' => 'subscribe', 882 'label' => t('Join'),875 'label' => 'Join', 883 876 ), 884 877 ); … … 917 910 'tablename' => 'node', 918 911 'field' => 'title', 919 'label' => t('Search for a group by name'),912 'label' => 'Search for a group by name', 920 913 'optional' => '1', 921 914 'is_default' => '0', … … 931 924 $view = new stdClass(); 932 925 $view->name = 'og_tracker'; 933 $view->description = t('Shows active posts across the whole site');926 $view->description = 'Shows active posts across the whole site'; 934 927 $view->access = array ( 935 928 ); 936 929 $view->view_args_php = ''; 937 930 $view->page = TRUE; 938 $view->page_title = t('Recent posts across whole site');931 $view->page_title = 'Recent posts across whole site'; 939 932 $view->page_header = ''; 940 933 $view->page_header_format = '1'; … … 948 941 $view->nodes_per_page = '25'; 949 942 $view->menu = TRUE; 950 $view->menu_title = t('Recent posts');943 $view->menu_title = 'Recent posts'; 951 944 $view->menu_tab = TRUE; 952 945 $view->menu_tab_weight = '5'; … … 968 961 'type' => 'uid', 969 962 'argdefault' => '2', 970 'title' => t('Recent posts for %1'),963 'title' => 'Recent posts for %1', 971 964 'options' => '', 972 965 'wildcard' => '', … … 991 984 'tablename' => 'node', 992 985 'field' => 'title', 993 'label' => t('Title'),986 'label' => 'Title', 994 987 'handler' => 'views_handler_field_nodelink_with_mark', 995 988 'options' => 'link', … … 998 991 'tablename' => 'users', 999 992 'field' => 'name', 1000 'label' => t('Author'),993 'label' => 'Author', 1001 994 ), 1002 995 array ( 1003 996 'tablename' => 'node_comment_statistics', 1004 997 'field' => 'comment_count', 1005 'label' => t('Replies'),998 'label' => 'Replies', 1006 999 'handler' => 'views_handler_comments_with_new', 1007 1000 ), … … 1009 1002 'tablename' => 'og_node_data', 1010 1003 'field' => 'title', 1011 'label' => t('Groups'),1004 'label' => 'Groups', 1012 1005 ), 1013 1006 array ( 1014 1007 'tablename' => 'node_comment_statistics', 1015 1008 'field' => 'last_comment_timestamp', 1016 'label' => t('Last post'),1009 'label' => 'Last Post', 1017 1010 'handler' => 'views_handler_field_since', 1018 1011 ), … … 1036 1029 $view = new stdClass(); 1037 1030 $view->name = 'og_search'; 1038 $view->description = t('Search within a particular group');1031 $view->description = 'Search within a particular group'; 1039 1032 $view->access = array ( 1040 1033 ); 1041 1034 $view->view_args_php = ''; 1042 1035 $view->page = TRUE; 1043 $view->page_title = t('Search');1036 $view->page_title = 'Search'; 1044 1037 $view->page_header = ''; 1045 1038 $view->page_header_format = '1'; 1046 1039 $view->page_footer = ''; 1047 1040 $view->page_footer_format = '1'; 1048 $view->page_empty = t('No posts found.');1041 $view->page_empty = 'No posts found.'; 1049 1042 $view->page_empty_format = '1'; 1050 1043 $view->page_type = 'teaser'; … … 1064 1057 'type' => 'gid', 1065 1058 'argdefault' => '1', 1066 'title' => t('Search results for %1'),1059 'title' => 'Search results for %1', 1067 1060 'options' => '', 1068 1061 'wildcard' => '', … … 1092 1085 'tablename' => 'temp_search_results', 1093 1086 'field' => 'word', 1094 'label' => t('Enter keyword'),1087 'label' => 'Enter keyword', 1095 1088 'optional' => '1', 1096 1089 'is_default' => '0', … … 1105 1098 $view = new stdClass(); 1106 1099 $view->name = 'og_comments_recent'; 1107 $view->description = t('Display recent comments block in a group');1100 $view->description = 'Display recent comments block in a group'; 1108 1101 $view->access = array ( 1109 1102 ); 1110 1103 $view->view_args_php = ''; 1111 1104 $view->block = TRUE; 1112 $view->block_title = t('Recent comments');1105 $view->block_title = 'Recent comments'; 1113 1106 $view->block_header = ''; 1114 1107 $view->block_header_format = '1'; … … 1178 1171 $view = new stdClass(); 1179 1172 $view->name = 'og_recent_type_term'; 1180 $view->description = t('Recent posts for current term filtered by node type and/or taxonomy term');1173 $view->description = 'Recent posts for current term filtered by node type and/or taxonomy term'; 1181 1174 $view->access = array ( 1182 1175 ); … … 1269 1262 return in_array($data->nid, array_keys($user->og_groups)) ? l($cnt, "og/users/$data->nid") : $cnt; 1270 1263 } 1271 1272 function og_handler_field_private($fieldinfo, $fielddata, $value, $data) {1273 return $value ? t('Private') : t('Public');1274 }1275 1276 1264 1277 1265 function og_handler_field_language($fieldinfo, $fielddata, $value, $data) { -
trunk/sites/all/modules/og/og_workflow_ng.inc
r152 r224 1 1 <?php 2 // $Id: og_workflow_ng.inc,v 1.1.2. 4 2008/07/31 20:08:16weitzman Exp $2 // $Id: og_workflow_ng.inc,v 1.1.2.2 2008/04/14 14:02:14 weitzman Exp $ 3 3 4 4 /** 5 5 * @file 6 * workflow_ng integration for og module .6 * workflow_ng integration for og module 7 7 */ 8 8 9 9 /** 10 * Implementation of hook_event_info() .10 * Implementation of hook_event_info() 11 11 */ 12 12 function og_event_info() { … … 17 17 '#arguments' => og_workflow_ng_events_hook_og_arguments(), 18 18 ), 19 'og_user_approved' => array(20 '#label' => t('User approved to group by admin'),21 '#module' => t('OG'),22 '#description' => t('A pending member is approved by a group administrator.'),23 '#arguments' => og_workflow_ng_events_hook_og_arguments(),24 ),25 19 'og_user_delete' => array( 26 20 '#label' => t('User leaves group'), 27 21 '#module' => t('OG'), 28 22 '#arguments' => og_workflow_ng_events_hook_og_arguments(), 29 ),30 );23 ), 24 ); 31 25 } 32 26 33 27 /** 34 * Describes the arguments available for the og hook .28 * Describes the arguments available for the og hook 35 29 * 36 30 * We pass uid and gid to workflow-ng so that the argument handlers can load the full entities. … … 47 41 48 42 /** 49 * handler to get user .43 * handler to get user 50 44 */ 51 45 function og_workflow_ng_events_argument_og_user($uid, $gid) { … … 54 48 55 49 /** 56 * handler to get node .50 * handler to get node 57 51 */ 58 52 function og_workflow_ng_events_argument_og_node($uid, $gid) { … … 61 55 62 56 /** 63 * Implementation of hook_og() .57 * Implementation of hook_og() 64 58 */ 65 function og_og($op, $gid, $uid, $args) {66 if (in_array($op, array('user insert', 'user delete'))) { 59 function og_og($op, $gid, $uid, $args){ 60 if (in_array($op, array('user insert', 'user delete'))) { 67 61 $op = str_replace(' ', '_', $op); 68 62 workflow_ng_invoke_event('og_'. $op, $uid, $gid); 69 63 } 70 // Pending member was approved.71 elseif ($op = 'user update' && $args['is_active']) {72 workflow_ng_invoke_event('og_user_approved', $uid, $gid);73 }74 64 } 75 76 77 /**78 * Implementation of hook_action_info().79 */80 function og_action_info() {81 return array(82 'og_workflow_ng_action_subscribe_user' => array(83 '#label' => t('Subscribe user to group'),84 '#arguments' => array(85 'user' => array('#entity' => 'user', '#label' => t('User who will be subscribed')),86 'group' => array('#entity' => 'node', '#label' => t('Group that user will be subscribed to')),87 ),88 '#description' => t('Subscribe a user to a group.'),89 '#module' => 'OG',90 ),91 'og_workflow_ng_action_remove_user' => array(92 '#label' => t('Unsubscribe user from group'),93 '#arguments' => array(94 'user' => array('#entity' => 'user', '#label' => t('User who will be unsubscribed')),95 'group' => array('#entity' => 'node', '#label' => t('Group that user will be unsubscribed from')),96 ),97 '#description' => t('Unsubscribe a user from a group.'),98 '#module' => 'OG',99 ),100 );101 }102 103 /**104 * Action: Subscribe user to group.105 */106
