Changeset 1895 for trunk/admin


Ignore:
Timestamp:
Mar 12, 2007, 1:04:25 AM (18 years ago)
Author:
plg
Message:

New: send an email to group members with informations about a category
(needs improvements).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r1861 r1895  
    3131
    3232include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     33include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    3334
    3435// +-----------------------------------------------------------------------+
     
    526527  );
    527528
     529// info by email to an access granted group of category informations
     530if (isset($_POST['submitEmail']))
     531{
     532  $query = '
     533SELECT
     534    user_id,
     535    '.$conf['user_fields']['email'].' AS email
     536  FROM '.USER_GROUP_TABLE.'
     537    INNER JOIN '.USERS_TABLE.' ON '.$conf['user_fields']['id'].' = user_id
     538  WHERE '.$conf['user_fields']['email'].' IS NOT NULL
     539    AND group_id = '.$_POST['group'].'
     540;';
     541  $result = pwg_query($query);
     542
     543  while ($row = mysql_fetch_array($result))
     544  {
     545    pwg_mail(
     546      $row['email'],
     547      array(
     548        'content' => get_absolute_root_url().make_index_url(
     549          array(
     550            'category' => array(
     551              'id' => $category['id'],
     552              'name' => $category['name'],
     553              'permalink' => $category['permalink'],
     554              )
     555            )
     556          ),
     557        'subject' => $category['name']
     558        )
     559      );
     560  }
     561
     562  $query = '
     563SELECT
     564    name
     565  FROM '.GROUPS_TABLE.'
     566  WHERE id = '.$_POST['group'].'
     567;';
     568  list($group_name) = mysql_fetch_row(pwg_query($query));
     569 
     570  array_push(
     571    $page['infos'],
     572    sprintf(
     573      l10n('An information email was sent to group "%s"'),
     574      $group_name
     575      )
     576    );
     577}
     578
     579if ('private' == $category['status'])
     580{
     581  $query = '
     582SELECT
     583    group_id
     584  FROM '.GROUP_ACCESS_TABLE.'
     585  WHERE cat_id = '.$category['id'].'
     586;';
     587}
     588else
     589{
     590  $query = '
     591SELECT
     592    id AS group_id
     593  FROM '.GROUPS_TABLE.'
     594;';
     595}
     596$group_ids = array_from_query($query, 'group_id');
     597
     598if (count($group_ids) > 0)
     599{
     600  $query = '
     601SELECT
     602    id,
     603    name
     604  FROM '.GROUPS_TABLE.'
     605  WHERE id IN ('.implode(',', $group_ids).')
     606  ORDER BY name ASC
     607;';
     608  $result = pwg_query($query);
     609
     610  while ($row = mysql_fetch_array($result))
     611  {
     612    $template->assign_block_vars(
     613      'group_option',
     614      array(
     615        'VALUE' => $row['id'],
     616        'OPTION' => $row['name'],
     617        )
     618      );
     619  }
     620}
    528621
    529622//----------------------------------------------------------- sending html code
Note: See TracChangeset for help on using the changeset viewer.