diff options
| author | bitweaver.org <bitweaver@users.sourceforge.net> | 2005-12-09 06:59:54 +0000 |
|---|---|---|
| committer | bitweaver.org <bitweaver@users.sourceforge.net> | 2005-12-09 06:59:54 +0000 |
| commit | e686c2762faae2d487381aede0ddcc9662ebbd52 (patch) | |
| tree | 8b30cde0c76c96e8f74c462244930979f1559548 /admin | |
| download | newsletters-e686c2762faae2d487381aede0ddcc9662ebbd52.tar.gz newsletters-e686c2762faae2d487381aede0ddcc9662ebbd52.tar.bz2 newsletters-e686c2762faae2d487381aede0ddcc9662ebbd52.zip | |
IMPORT from TikiPro HEAD _p_tp_newsletters
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/admin_newsletter_subscriptions.php | 154 | ||||
| -rw-r--r-- | admin/index.php | 191 | ||||
| -rw-r--r-- | admin/schema_inc.php | 61 |
3 files changed, 406 insertions, 0 deletions
diff --git a/admin/admin_newsletter_subscriptions.php b/admin/admin_newsletter_subscriptions.php new file mode 100644 index 0000000..45ab8d3 --- /dev/null +++ b/admin/admin_newsletter_subscriptions.php @@ -0,0 +1,154 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletter_subscriptions.php,v 1.1 2005/12/09 06:59:54 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../../tiki_setup_inc.php' ); + +include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' ); + +if ($feature_newsletters != 'y') { + $smarty->assign('msg', tra("This feature is disabled").": feature_newsletters"); + + $gTikiSystem->display( 'error.tpl' ); + die; +} + +if (!isset($_REQUEST["nl_id"])) { + $smarty->assign('msg', tra("No newsletter indicated")); + + $gTikiSystem->display( 'error.tpl' ); + die; +} + +$smarty->assign('nl_id', $_REQUEST["nl_id"]); + +$smarty->assign('individual', 'n'); + +if ($userlib->object_has_one_permission($_REQUEST["nl_id"], 'newsletter')) { + $smarty->assign('individual', 'y'); + + if ($tiki_p_admin != 'y') { + $perms = $userlib->get_permissions(0, -1, 'perm_name_desc', '', 'newsletters'); + + foreach ($perms["data"] as $perm) { + $perm_name = $perm["perm_name"]; + + if ($userlib->object_has_permission($user, $_REQUEST["nl_id"], 'newsletter', $perm_name)) { + $$perm_name = 'y'; + + $smarty->assign("$perm_name", 'y'); + } else { + $$perm_name = 'n'; + + $smarty->assign("$perm_name", 'n'); + } + } + } +} + +if ($tiki_p_admin_newsletters != 'y') { + $smarty->assign('msg', tra("You dont have permission to use this feature")); + + $gTikiSystem->display( 'error.tpl' ); + die; +} + +if ($_REQUEST["nl_id"]) { + $info = $nllib->get_newsletter($_REQUEST["nl_id"]); +} else { + $info = array(); + + $info["name"] = ''; + $info["description"] = ''; + $info["allow_any_sub"] = 'n'; + $info["frequency"] = 7 * 24 * 60 * 60; +} + +$smarty->assign('nl_info', $info); + +if (isset($_REQUEST["remove"])) { + check_ticket('admin-nl-subsriptions'); + $nllib->remove_newsletter_subscription($_REQUEST["remove"], $_REQUEST["email"]); +} + +if (isset($_REQUEST["add_all"])) { + check_ticket('admin-nl-subsriptions'); + $nllib->add_all_users($_REQUEST["nl_id"]); +} + +if (isset($_REQUEST["save"])) { + check_ticket('admin-nl-subsriptions'); + $sid = $nllib->newsletter_subscribe($_REQUEST["nl_id"], $_REQUEST["email"]); +} + +if ( empty( $_REQUEST["sort_mode"] ) ) { + $sort_mode = 'subscribed_desc'; +} else { + $sort_mode = $_REQUEST["sort_mode"]; +} + +if (!isset($_REQUEST["offset"])) { + $offset = 0; +} else { + $offset = $_REQUEST["offset"]; +} + +$smarty->assign_by_ref('offset', $offset); + +if (isset($_REQUEST["find"])) { + $find = $_REQUEST["find"]; +} else { + $find = ''; +} + +$smarty->assign('find', $find); + +$smarty->assign_by_ref('sort_mode', $sort_mode); +$channels = $nllib->list_newsletter_subscriptions($_REQUEST["nl_id"], $offset, $maxRecords, $sort_mode, $find); + +$cant_pages = ceil($channels["cant"] / $maxRecords); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($offset / $maxRecords)); + +if ($channels["cant"] > ($offset + $maxRecords)) { + $smarty->assign('next_offset', $offset + $maxRecords); +} else { + $smarty->assign('next_offset', -1); +} + +// If offset is > 0 then prev_offset +if ($offset > 0) { + $smarty->assign('prev_offset', $offset - $maxRecords); +} else { + $smarty->assign('prev_offset', -1); +} + +$smarty->assign_by_ref('channels', $channels["data"]); + +// Fill array with possible number of questions per page +$freqs = array(); + +for ($i = 0; $i < 90; $i++) { + $aux["i"] = $i; + + $aux["t"] = $i * 24 * 60 * 60; + $freqs[] = $aux; +} + +$smarty->assign('freqs', $freqs); + +/* +$cat_type='newsletter'; +$cat_objid = $_REQUEST["nl_id"]; +include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' ); +*/ +ask_ticket('admin-nl-subsriptions'); +// Display the template +$gTikiSystem->display( 'tikipackage:newsletters/admin_newsletter_subscriptions.tpl'); + +?> diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..775d227 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,191 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/Attic/index.php,v 1.1 2005/12/09 06:59:54 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../../tiki_setup_inc.php' ); + +include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' ); + +if ($feature_newsletters != 'y') { + $smarty->assign('msg', tra("This feature is disabled").": feature_newsletters"); + + $gTikiSystem->display( 'error.tpl' ); + die; +} + +if (!isset($_REQUEST["nl_id"])) { + $_REQUEST["nl_id"] = 0; +} + +$smarty->assign('nl_id', $_REQUEST["nl_id"]); + +$smarty->assign('individual', 'n'); + +if ($userlib->object_has_one_permission($_REQUEST["nl_id"], 'newsletter')) { + $smarty->assign('individual', 'y'); + + if ($tiki_p_admin != 'y') { + $perms = $userlib->get_permissions(0, -1, 'perm_name_desc', '', 'newsletters'); + + foreach ($perms["data"] as $perm) { + $perm_name = $perm["perm_name"]; + + if ($userlib->object_has_permission($user, $_REQUEST["nl_id"], 'newsletter', $perm_name)) { + $$perm_name = 'y'; + + $smarty->assign("$perm_name", 'y'); + } else { + $$perm_name = 'n'; + + $smarty->assign("$perm_name", 'n'); + } + } + } +} + +if ($tiki_p_admin_newsletters != 'y') { + $smarty->assign('msg', tra("You do not have permission to use this feature")); + + $gTikiSystem->display( 'error.tpl' ); + die; +} + +if ($_REQUEST["nl_id"]) { + $info = $nllib->get_newsletter($_REQUEST["nl_id"]); +} else { + $info = array(); + + $info["name"] = ''; + $info["description"] = ''; + $info["allow_user_sub"] = 'y'; + $info["allow_any_sub"] = 'n'; + $info["unsub_msg"] = 'y'; + $info["validate_addr"] = 'y'; +} + +$smarty->assign('info', $info); + +if (isset($_REQUEST["remove"])) { + check_ticket('admin-nl'); + $nllib->remove_newsletter($_REQUEST["remove"]); +} + +if (isset($_REQUEST["save"])) { + check_ticket('admin-nl'); + if (isset($_REQUEST["allow_user_sub"]) && $_REQUEST["allow_user_sub"] == 'on') { + $_REQUEST["allow_user_sub"] = 'y'; + } else { + $_REQUEST["allow_user_sub"] = 'n'; + } + + if (isset($_REQUEST["allow_any_sub"]) && $_REQUEST["allow_any_sub"] == 'on') { + $_REQUEST["allow_any_sub"] = 'y'; + } else { + $_REQUEST["allow_any_sub"] = 'n'; + } + + if (isset($_REQUEST["unsub_msg"]) && $_REQUEST["unsub_msg"] == 'on') { + $_REQUEST["unsub_msg"] = 'y'; + } else { + $_REQUEST["unsub_msg"] = 'n'; + } + + if (isset($_REQUEST["validate_addr"]) && $_REQUEST["validate_addr"] == 'on') { + $_REQUEST["validate_addr"] = 'y'; + } else { + $_REQUEST["validate_addr"] = 'n'; + } + + $sid = $nllib->replace_newsletter($_REQUEST["nl_id"], $_REQUEST["name"], $_REQUEST["description"], $_REQUEST["allow_user_sub"], $_REQUEST["allow_any_sub"], $_REQUEST["unsub_msg"], $_REQUEST["validate_addr"]); + /* + $cat_type='newsletter'; + $cat_objid = $sid; + $cat_desc = substr($_REQUEST["description"],0,200); + $cat_name = $_REQUEST["name"]; + $cat_href= NEWSLETTERS_PKG_URL."newsletters.php?nl_id=".$cat_objid; + include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' ); + */ + $info["name"] = ''; + $info["description"] = ''; + $info["allow_user_sub"] = 'y'; + $info["allow_any_sub"] = 'n'; + $info["unsub_msg"] = 'y'; + $info["validate_addr"] = 'y'; + //$info["frequency"] = 7 * 24 * 60 * 60; + $smarty->assign('nl_id', 0); + $smarty->assign('info', $info); +} + +if ( empty( $_REQUEST["sort_mode"] ) ) { + $sort_mode = 'created_desc'; +} else { + $sort_mode = $_REQUEST["sort_mode"]; +} + +if (!isset($_REQUEST["offset"])) { + $offset = 0; +} else { + $offset = $_REQUEST["offset"]; +} + +$smarty->assign_by_ref('offset', $offset); + +if (isset($_REQUEST["find"])) { + $find = $_REQUEST["find"]; +} else { + $find = ''; +} + +$smarty->assign('find', $find); + +$smarty->assign_by_ref('sort_mode', $sort_mode); +$channels = $nllib->list_newsletters($offset, $maxRecords, $sort_mode, $find); + +$cant_pages = ceil($channels["cant"] / $maxRecords); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($offset / $maxRecords)); + +if ($channels["cant"] > ($offset + $maxRecords)) { + $smarty->assign('next_offset', $offset + $maxRecords); +} else { + $smarty->assign('next_offset', -1); +} + +// If offset is > 0 then prev_offset +if ($offset > 0) { + $smarty->assign('prev_offset', $offset - $maxRecords); +} else { + $smarty->assign('prev_offset', -1); +} + +$smarty->assign_by_ref('channels', $channels["data"]); + +// Fill array with possible number of questions per page +/* +$freqs = array(); + +for ($i = 0; $i < 90; $i++) { + $aux["i"] = $i; + + $aux["t"] = $i * 24 * 60 * 60; + $freqs[] = $aux; +} + +$smarty->assign('freqs', $freqs); +*/ +/* +$cat_type='newsletter'; +$cat_objid = $_REQUEST["nl_id"]; +include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' ); +*/ +ask_ticket('admin-nl'); + +// Display the template +$gTikiSystem->display( 'tikipackage:newsletters/admin_newsletters.tpl'); + +?> diff --git a/admin/schema_inc.php b/admin/schema_inc.php new file mode 100644 index 0000000..2e96914 --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,61 @@ +<?php + +$tables = array( + +'tiki_newsletter_subscriptions' => " + nl_id I4 PRIMARY, + email C(160) PRIMARY, + code C(32), + valid C(1), + subscribed I8 +", + +'tiki_newsletters' => " + nl_id I4 AUTO PRIMARY, + name C(200), + description X, + created I8, + last_sent I8, + editions I8, + users I8, + allow_user_sub C(1) default 'y', + allow_any_sub C(1), + unsub_msg C(1) default 'y', + validate_addr C(1) default 'y', + frequency I8 +", + +'tiki_sent_newsletters' => " + edition_id I4 AUTO PRIMARY, + nl_id I4 NOTNULL, + users I8, + sent I8, + subject C(200), + data B +" + +); + +global $gTikiInstaller; + +foreach( array_keys( $tables ) AS $tableName ) { + $gTikiInstaller->registerSchemaTable( NEWSLETTERS_PKG_DIR, $tableName, $tables[$tableName] ); +} + + +$gTikiInstaller->registerSchemaDefault( NEWSLETTERS_PKG_DIR, array( + + "INSERT INTO `".TIKI_DB_PREFIX."tiki_menu_options` (`menu_id` , `type` , `name` , `url` , `position` , `section` , `perm` , `groupname`) VALUES (42,'s','Newsletters','tiki-newsletters.php',900,'feature_newsletters','','')", + "INSERT INTO `".TIKI_DB_PREFIX."tiki_menu_options` (`menu_id` , `type` , `name` , `url` , `position` , `section` , `perm` , `groupname`) VALUES (42,'o','Send newsletters','tiki-send_newsletters.php',905,'feature_newsletters','tiki_p_admin_newsletters','')", + "INSERT INTO `".TIKI_DB_PREFIX."tiki_menu_options` (`menu_id` , `type` , `name` , `url` , `position` , `section` , `perm` , `groupname`) VALUES (42,'o','Admin newsletters','tiki-admin_newsletters.php',910,'feature_newsletters','tiki_p_admin_newsletters','')", + + "INSERT INTO `".TIKI_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('tiki_p_admin_newsletters', 'Can admin newsletters', 'editors', 'newsletters')", + "INSERT INTO `".TIKI_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('tiki_p_subscribe_newsletters', 'Can subscribe to newsletters', 'basic', 'newsletters')", + "INSERT INTO `".TIKI_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('tiki_p_subscribe_email', 'Can subscribe any email to newsletters', 'editors', 'newsletters')", + + + "INSERT INTO `".TIKI_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('', 'feature_newsletters','n')" + +) ); + +?> |
