$name, 'URL' => get_root_url().'admin.php?page=plugin-'.basename(NBMS_PATH) ) ); return $menu; } /* Saving from profile with added data */ add_event_handler('save_profile_from_post', 'NBMS_Save_Profile'); function NBMS_Save_Profile() { global $conf, $user; include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.php'); $query = ' SELECT * FROM '.USER_MAIL_NOTIFICATION_TABLE.' WHERE user_id = \''.$user['id'].'\' '; $count = pwg_db_num_rows(pwg_query($query)); if ($count == 0) { $inserts = array(); $check_key_list = array(); // Calculate key $nbm_user['check_key'] = find_available_check_key(); // Save key array_push($check_key_list, $nbm_user['check_key']); // Insert new nbm_users array_push ( $inserts, array ( 'user_id' => $user['id'], 'check_key' => $nbm_user['check_key'], 'enabled' => $_POST['NBM_Subscription'] ) ); mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); } elseif ($count != 0 and !empty($_POST['NBM_Subscription']) && in_array($_POST['NBM_Subscription'], array('true', 'false'))) { $query = ' UPDATE '.USER_MAIL_NOTIFICATION_TABLE.' SET enabled = \''.$_POST['NBM_Subscription'].'\' WHERE user_id = \''.$user['id'].'\';'; pwg_query($query); } } /* Adding NBMS in profile page */ add_event_handler('load_profile_in_template', 'NBMS_Load_Profile'); function NBMS_Load_Profile() { global $conf, $user, $template, $lang; $query = ' SELECT enabled FROM '.USER_MAIL_NOTIFICATION_TABLE.' WHERE user_id = \''.$user['id'].'\' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); $values = $data['enabled']; if (is_null($values)) $values = 'false'; $template->assign('radio_options', array( 'true' => l10n('Yes'), 'false'=> l10n('No') ) ); $template->assign( array( 'NBMS'=>$values ) ); $template->set_prefilter('profile_content', 'NBMS_prefilter'); } /* Original template modification */ function NBMS_prefilter($content, &$smarty) { global $template, $lang; load_language('plugin.lang', NBMS_PATH); $search = '
'; $addon = '
'; $replacement = $addon.$search; return str_replace($search, $replacement, $content); } ?>