2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-12 14:30:07 +00:00
* e107 website system
*
2013-02-20 21:11:17 +00:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2009-11-12 14:30:07 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*/
2006-12-02 04:36:16 +00:00
require_once ( '../class2.php' );
2017-01-17 01:33:03 +01:00
2008-12-07 12:00:13 +00:00
if ( ! getperms ( 'O' ))
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2006-12-02 04:36:16 +00:00
exit ;
}
2017-01-17 01:33:03 +01:00
e107 :: coreLan ( 'notify' , true );
2016-11-08 10:00:33 -08:00
class plugin_notify_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array ( 'controller' => 'plugin_notify_admin_ui' ,
'path' => null ,
'ui' => 'plugin_notify_admin_form_ui' , 'uipath' => null )
);
protected $adminMenu = array (
'main/config' => array ( 'caption' => " Email " , 'perm' => '0' ),
'main/push' => array ( 'caption' => " Push (experimental) " , 'perm' => '0' )
);
protected $adminMenuAliases = array (
'main/edit' => 'main/list'
);
/**
* Navigation menu title
* @ var string
*/
protected $menuTitle = NT_LAN_1 ;
function init ()
{
if ( e_DEBUG !== true )
{
unset ( $this -> adminMenu [ 'main/push' ]);
}
}
}
class plugin_notify_admin_ui extends e_admin_ui
{
protected $pluginTitle = NT_LAN_1 ;
protected $pluginName = 'core' ;
protected $table = " " ;
protected $listQry = " " ;
protected $pid = " notify_id " ;
protected $perPage = 20 ;
protected $batchDelete = true ;
// protected $displaySettings = array();
// protected $disallowPages = array('main/create', 'main/prefs');
protected $fields = array ();
//required - default column user prefs
protected $fieldpref = array ();
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array (
/* 'pref_type' => array ( 'title' => 'type' , 'type' => 'text' , 'data' => 'string' , 'validate' => true ),
'pref_folder' => array ( 'title' => 'folder' , 'type' => 'boolean' , 'data' => 'integer' ),
'pref_name' => array ( 'title' => 'name' , 'type' => 'text' , 'data' => 'string' , 'validate' => 'regex' , 'rule' => '#^[\w]+$#i' , 'help' => 'allowed characters are a-zA-Z and underscore' ) */
);
var $notify_prefs ;
var $changeList = array ();
var $pluginConfig = array ();
function init ()
{
if ( ! empty ( $_POST [ 'update' ]))
{
if ( $this -> update ())
{
// e107::getMessage()->addSuccess(LAN_UPDATED);
}
else
{
e107 :: getMessage () -> addError ( LAN_UPDATED_FAILED );
}
}
$pref = e107 :: getPref ();
$this -> notify_prefs = e107 :: getConfig ( 'notify' ) -> getPref ();
$this -> prefCleanup ();
$this -> test ();
$recalibrate = FALSE ;
// load every e_notify.php file.
if ( $pref [ 'e_notify_list' ])
{
foreach ( $pref [ 'e_notify_list' ] as $val ) // List of available e_notify.php files.
{
// if (!isset($this->notify_prefs['plugins'][$val]))
{
$this -> notify_prefs [ 'plugins' ][ $val ] = TRUE ;
if ( is_readable ( e_PLUGIN . $val . " /e_notify.php " ))
{
require_once ( e_PLUGIN . $val . '/e_notify.php' );
if ( class_exists ( $val . " _notify " )) // new v2.x
{
$legacy = 0 ; // Newe.
$config_events = array ();
$data = e107 :: callMethod ( $val . " _notify " , 'config' );
$config_category = str_replace ( " _menu " , " " , ucfirst ( $val )) . " Events " ;
foreach ( $data as $v )
{
$func = $v [ 'function' ];
$config_events [ $func ] = $v [ 'name' ];
}
}
else
{
$legacy = 1 ; // Legacy Mode.
}
// foreach ($config_events as $event_id => $event_text)
// {
// $this -> notify_prefs['event'][$event_id] = array('class' => '255', 'email' => '', 'plugin'=> $val);
// }
$this -> pluginConfig [ $val ] = array ( 'category' => $config_category , 'events' => $config_events , 'legacy' => $legacy );
$recalibrate = true ;
}
}
}
}
// print_a($this->pluginConfig);
if ( $recalibrate )
{
// $s_prefs = $tp -> toDB($this -> notify_prefs);
// $s_prefs = $eArrayStorage -> WriteArray($s_prefs);
// $sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'");
}
}
function prefCleanup ()
{
$oldPrefs = e107 :: getEvent () -> oldCoreList ();
$curData = $this -> notify_prefs [ 'event' ];
foreach ( $curData as $k => $v )
{
if ( isset ( $oldPrefs [ $k ]))
{
$newKey = $oldPrefs [ $k ];
$this -> notify_prefs [ 'event' ][ $newKey ] = $v ;
unset ( $this -> notify_prefs [ 'event' ][ $k ]);
}
}
}
function pushPage ()
{
e107 :: getMessage () -> addInfo ( " Under Construction " );
}
function test ()
{
if ( ! empty ( $_POST [ 'test' ]))
{
$id = key ( $_POST [ 'test' ]);
$exampleData = array ( 'id' => 'Test for ' . $id , 'data' => 'example data' );
e107 :: getMessage () -> addSuccess ( 'Triggering: ' . $id );
e107 :: getEvent () -> trigger ( $id , $exampleData );
}
}
function configPage ()
{
//global $ns, $rs, $frm, $emessage;
$ns = e107 :: getRender ();
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$events = e107 :: getEvent () -> coreList ();
$tab = array ();
foreach ( $events as $k => $cat )
{
$text = " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
foreach ( $cat as $c => $ev )
{
$text .= $this -> render_event ( $c , $ev );
}
$text .= " </table> " ;
$caption = str_replace ( " _menu " , " " , ucfirst ( $k )) . " " . LAN_NOTIFY_01 ;
$tab [] = array ( 'caption' => $caption , 'text' => $text );
}
if ( ! empty ( $this -> notify_prefs [ 'plugins' ]))
{
foreach ( $this -> notify_prefs [ 'plugins' ] as $plugin_id => $plugin_settings )
{
if ( is_readable ( e_PLUGIN . $plugin_id . '/e_notify.php' ))
{
$config_category = $this -> pluginConfig [ $plugin_id ][ 'category' ];
$legacy = $this -> pluginConfig [ $plugin_id ][ 'legacy' ];
$text = " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
;
foreach ( $this -> pluginConfig [ $plugin_id ][ 'events' ] as $event_id => $event_text )
{
$text .= $this -> render_event ( $event_id , $event_text , $plugin_id , $legacy );
}
$text .= " </table> \n " ;
$tab [] = array ( 'caption' => $config_category , 'text' => $text );
}
}
}
$text2 = $frm -> open ( 'scanform' , 'post' , e_REQUEST_URL ); // <form action='".e_SELF."?results' method='post' id='scanform'>
$text2 .= $frm -> tabs ( $tab );
$text2 .= " <div class='buttons-bar center'> " . $frm -> admin_button ( 'update' , LAN_UPDATE , 'update' ) . " </div> " ;
$text2 .= $frm -> close ();
// $ns -> tablerender(NT_LAN_1, $mes->render() . $text2);
return $text2 ;
// return;
}
function render_event ( $id , $description , $include = '' , $legacy = 0 )
{
$tp = e107 :: getParser ();
$frm = e107 :: getForm ();
$uc = e107 :: getUserClass ();
$uc -> fixed_classes [ 'email' ] = 'Email Address =>' ;
$uc -> text_class_link [ 'email' ] = 'email' ;
if ( defined ( $description ))
{
$description = constant ( $description );
}
$highlight = varset ( $_GET [ 'type' ]) == $id ? " class='text-warning' " : '' ;
$text = "
< tr >
< td title = '".$id."' >< span { $highlight } > " . $description . " :</ span ></ td > " ;
if ( e_DEBUG )
{
$text .= " <td> " . $id . " </td> " ;
}
$text .= "
< td class = 'form-inline nowrap' >
" . $uc->uc_dropdown ('event['. $id .'][class]', varset( $this->notify_prefs ['event'][ $id ]['class'], e_UC_NOBODY), " nobody , main , admin , member , classes , email " , " onchange = \ " mail_field(this.value,'event_ " . $id . " '); \" " );
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] == 'email' )
{
$disp = 'display:visible' ;
$value = $tp -> toForm ( $this -> notify_prefs [ 'event' ][ $id ][ 'email' ]);
}
else
{
$disp = " display:none " ;
$value = " " ;
}
$text .= " <input type='text' style='width:200px; $disp ' class='tbox' id='event_ " . $id . " ' name='event[ " . $id . " ][email]' value= \" " . $value . " \" /> \n " ;
$text .= $frm -> hidden ( " event[ " . $id . " ][include] " , $include );
$text .= $frm -> hidden ( " event[ " . $id . " ][legacy] " , $legacy ); // function or method
if ( isset ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ]) && $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != e_UC_NOBODY )
{
$text .= $frm -> button ( 'test[' . $id . ']' , $id , 'confirm' , 'Test' );
}
$text .= " </td> " ;
$text .= "
</ tr > " ;
return $text ;
}
function update ()
{
$this -> changeList = array ();
$active = false ;
foreach ( $_POST [ 'event' ] as $key => $value )
{
if ( $this -> update_event ( $key ))
{
$active = true ;
}
}
// print_a($this->notify_prefs);
/*
$s_prefs = $tp -> toDB ( $this -> notify_prefs );
$s_prefs = $eArrayStorage -> WriteArray ( $s_prefs );
if ( $sql -> db_Update ( " core " , " e107_value=' " . $s_prefs . " ' WHERE e107_name='notify_prefs' " ) !== FALSE )
*/
e107 :: getConfig () -> set ( 'notify' , $active ) -> save ( true , true , false );
e107 :: getConfig ( 'notify' ) -> updatePref ( $this -> notify_prefs );
if ( e107 :: getConfig ( 'notify' ) -> save ( FALSE ))
{
// e107::getAdminLog()->logArrayAll('NOTIFY_01',$this->changeList);
return true ;
}
else
{
return false ;
}
}
function update_event ( $id )
{
$changed = FALSE ;
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != $_POST [ 'event' ][ $id ][ 'class' ])
{
$this -> notify_prefs [ 'event' ][ $id ][ 'class' ] = $_POST [ 'event' ][ $id ][ 'class' ];
$changed = TRUE ;
}
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'email' ] != $_POST [ 'event' ][ $id ][ 'email' ])
{
$this -> notify_prefs [ 'event' ][ $id ][ 'email' ] = $_POST [ 'event' ][ $id ][ 'email' ];
$changed = TRUE ;
}
$this -> notify_prefs [ 'event' ][ $id ][ 'include' ] = $_POST [ 'event' ][ $id ][ 'include' ];
$this -> notify_prefs [ 'event' ][ $id ][ 'legacy' ] = $_POST [ 'event' ][ $id ][ 'legacy' ];
unset ( $this -> notify_prefs [ 'event' ][ $id ][ 'plugin' ]);
unset ( $this -> notify_prefs [ 'event' ][ $id ][ 'type' ]);
if ( $changed )
{
$this -> changeList [ $id ] = $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] . ', ' . $this -> notify_prefs [ 'event' ][ $id ][ 'email' ];
}
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != 255 )
{
return TRUE ;
}
else
{
return FALSE ;
}
}
}
class plugin_notify_admin_form_ui extends e_admin_form_ui
{
}
new plugin_notify_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
function headerjs ()
{
$js = "
< script type = 'text/javascript' >
function mail_field ( val , id )
{
if ( val == 'email' )
{
document . getElementById ( id ) . style . display = '' ;
}
else
{
document . getElementById ( id ) . style . display = 'none' ;
}
}
</ script > " ;
return $js ;
}
exit ;
2009-08-28 16:11:02 +00:00
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'notify' ;
require_once ( 'auth.php' );
require_once ( e_HANDLER . 'userclass_class.php' );
2009-07-10 14:25:23 +00:00
2013-02-10 13:55:52 +01:00
$frm = e107 :: getForm ();
2013-06-18 20:21:10 -07:00
2006-12-02 04:36:16 +00:00
$nc = new notify_config ;
2013-06-18 20:21:10 -07:00
2008-04-26 14:34:17 +00:00
$uc = new user_class ;
2013-02-10 13:55:52 +01:00
$mes = e107 :: getMessage ();
2008-04-26 14:34:17 +00:00
2015-05-13 01:22:05 -07:00
if ( ! empty ( $_GET [ 'iframe' ]))
{
define ( 'e_IFRAME' , true );
}
2015-03-07 16:30:46 -08:00
2008-04-26 14:34:17 +00:00
if ( isset ( $_POST [ 'update' ]))
{
2009-07-10 14:25:23 +00:00
if ( $nc -> update ())
{
2013-02-10 13:55:52 +01:00
//$message = LAN_UPDATED;
//$style = E_MESSAGE_SUCCESS;
//$mes->addSuccess(LAN_UPDATED);
2009-07-10 14:25:23 +00:00
}
else
{
2013-02-10 13:55:52 +01:00
//$message = LAN_UPDATED_FAILED;
//$style = E_MESSAGE_FAILED;
$mes -> addError ( LAN_UPDATED_FAILED );
2009-07-10 14:25:23 +00:00
}
2013-02-10 13:55:52 +01:00
//$emessage->add($message, $style);
2009-07-10 14:25:23 +00:00
// $ns -> tablerender($message,"<div style='text-align:center'>".$message."</div>");
2006-12-02 04:36:16 +00:00
}
2013-06-18 20:21:10 -07:00
2006-12-02 04:36:16 +00:00
$nc -> config ();
2009-07-08 06:58:00 +00:00
class notify_config
2008-12-07 12:00:13 +00:00
{
2006-12-02 04:36:16 +00:00
var $notify_prefs ;
2008-12-07 12:00:13 +00:00
var $changeList = array ();
2013-06-18 20:21:10 -07:00
var $pluginConfig = array ();
2006-12-02 04:36:16 +00:00
2013-06-18 20:21:10 -07:00
function __construct ()
2008-12-07 12:00:13 +00:00
{
2015-02-13 02:30:31 -08:00
$pref = e107 :: getPref ();
2013-02-19 21:26:45 +00:00
$this -> notify_prefs = e107 :: getConfig ( 'notify' ) -> getPref ();
2015-02-13 02:30:31 -08:00
2015-03-07 16:30:46 -08:00
$this -> prefCleanup ();
$this -> test ();
2006-12-02 04:36:16 +00:00
2009-12-28 22:16:54 +00:00
$recalibrate = FALSE ;
2015-03-07 16:30:46 -08:00
2006-12-02 04:36:16 +00:00
// load every e_notify.php file.
2009-07-14 03:18:17 +00:00
if ( $pref [ 'e_notify_list' ])
2006-12-02 04:36:16 +00:00
{
2013-06-18 20:21:10 -07:00
foreach ( $pref [ 'e_notify_list' ] as $val ) // List of available e_notify.php files.
2009-07-14 03:18:17 +00:00
{
2013-06-18 20:21:10 -07:00
// if (!isset($this->notify_prefs['plugins'][$val]))
2006-12-02 04:36:16 +00:00
{
2013-06-18 20:21:10 -07:00
2009-07-14 03:18:17 +00:00
$this -> notify_prefs [ 'plugins' ][ $val ] = TRUE ;
2013-06-18 20:21:10 -07:00
2009-07-14 03:18:17 +00:00
if ( is_readable ( e_PLUGIN . $val . " /e_notify.php " ))
{
require_once ( e_PLUGIN . $val . '/e_notify.php' );
2013-06-18 20:21:10 -07:00
if ( class_exists ( $val . " _notify " )) // new v2.x
{
$legacy = 0 ; // Newe.
$config_events = array ();
$data = e107 :: callMethod ( $val . " _notify " , 'config' );
$config_category = str_replace ( " _menu " , " " , ucfirst ( $val )) . " Events " ;
foreach ( $data as $v )
{
$func = $v [ 'function' ];
$config_events [ $func ] = $v [ 'name' ];
}
}
else
{
$legacy = 1 ; // Legacy Mode.
2009-07-14 03:18:17 +00:00
}
2013-06-18 20:21:10 -07:00
// foreach ($config_events as $event_id => $event_text)
// {
// $this -> notify_prefs['event'][$event_id] = array('class' => '255', 'email' => '', 'plugin'=> $val);
// }
$this -> pluginConfig [ $val ] = array ( 'category' => $config_category , 'events' => $config_events , 'legacy' => $legacy );
2009-07-14 03:18:17 +00:00
$recalibrate = true ;
2006-12-02 04:36:16 +00:00
}
}
2009-07-14 03:18:17 +00:00
}
2006-12-02 04:36:16 +00:00
}
2013-06-18 20:21:10 -07:00
// print_a($this->pluginConfig);
2008-12-07 12:00:13 +00:00
if ( $recalibrate )
{
2015-02-13 02:30:31 -08:00
// $s_prefs = $tp -> toDB($this -> notify_prefs);
// $s_prefs = $eArrayStorage -> WriteArray($s_prefs);
2013-06-18 20:21:10 -07:00
// $sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'");
2006-12-02 04:36:16 +00:00
}
}
2015-02-13 02:30:31 -08:00
function prefCleanup ()
{
$oldPrefs = e107 :: getEvent () -> oldCoreList ();
$curData = $this -> notify_prefs [ 'event' ];
2013-06-18 20:21:10 -07:00
2015-02-13 02:30:31 -08:00
foreach ( $curData as $k => $v )
{
if ( isset ( $oldPrefs [ $k ]))
{
$newKey = $oldPrefs [ $k ];
$this -> notify_prefs [ 'event' ][ $newKey ] = $v ;
unset ( $this -> notify_prefs [ 'event' ][ $k ]);
}
}
}
2015-03-07 16:30:46 -08:00
function test ()
{
if ( ! empty ( $_POST [ 'test' ]))
{
$id = key ( $_POST [ 'test' ]);
$exampleData = array ( 'id' => 'Test for ' . $id , 'data' => 'example data' );
e107 :: getMessage () -> addSuccess ( 'Triggering: ' . $id );
e107 :: getEvent () -> trigger ( $id , $exampleData );
}
}
2015-02-13 02:30:31 -08:00
2013-06-18 20:21:10 -07:00
2009-07-10 14:25:23 +00:00
function config ()
2008-12-07 12:00:13 +00:00
{
2013-02-10 13:55:52 +01:00
//global $ns, $rs, $frm, $emessage;
$ns = e107 :: getRender ();
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
2006-12-02 04:36:16 +00:00
2015-02-13 02:30:31 -08:00
$events = e107 :: getEvent () -> coreList ();
$tab = array ();
foreach ( $events as $k => $cat )
{
$text = " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
foreach ( $cat as $c => $ev )
{
$text .= $this -> render_event ( $c , $ev );
}
$text .= " </table> " ;
2015-05-02 16:27:01 +02:00
$caption = str_replace ( " _menu " , " " , ucfirst ( $k )) . " " . LAN_NOTIFY_01 ;
2015-02-13 02:30:31 -08:00
$tab [] = array ( 'caption' => $caption , 'text' => $text );
}
if ( ! empty ( $this -> notify_prefs [ 'plugins' ]))
{
foreach ( $this -> notify_prefs [ 'plugins' ] as $plugin_id => $plugin_settings )
{
if ( is_readable ( e_PLUGIN . $plugin_id . '/e_notify.php' ))
{
$config_category = $this -> pluginConfig [ $plugin_id ][ 'category' ];
$legacy = $this -> pluginConfig [ $plugin_id ][ 'legacy' ];
$text = " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
;
foreach ( $this -> pluginConfig [ $plugin_id ][ 'events' ] as $event_id => $event_text )
{
$text .= $this -> render_event ( $event_id , $event_text , $plugin_id , $legacy );
}
$text .= " </table> \n " ;
$tab [] = array ( 'caption' => $config_category , 'text' => $text );
}
}
}
2015-05-13 01:22:05 -07:00
$text2 = $frm -> open ( 'scanform' , 'post' , e_REQUEST_URL ); // <form action='".e_SELF."?results' method='post' id='scanform'>
2015-02-13 02:30:31 -08:00
$text2 .= $frm -> tabs ( $tab );
$text2 .= " <div class='buttons-bar center'> " . $frm -> admin_button ( 'update' , LAN_UPDATE , 'update' ) . " </div> " ;
$text2 .= $frm -> close ();
$ns -> tablerender ( NT_LAN_1 , $mes -> render () . $text2 );
return ;
// <div>".NT_LAN_2.":</div>
/*
2013-02-10 13:55:52 +01:00
$text = "
2013-03-16 02:33:55 -07:00
2006-12-02 04:36:16 +00:00
< form action = '".e_SELF."?results' method = 'post' id = 'scanform' >
2013-03-16 02:33:55 -07:00
< ul class = 'nav nav-tabs' >
< li class = 'active' >< a href = '#core' data - toggle = 'tab' > Users </ a ></ li >
< li >< a href = '#news' data - toggle = 'tab' > News </ a ></ li >
< li >< a href = '#mail' data - toggle = 'tab' > Mail </ a ></ li >
< li >< a href = '#files' data - toggle = 'tab' > Files </ a ></ li > " ;
2015-02-03 12:23:03 -08:00
if ( ! empty ( $this -> notify_prefs [ 'plugins' ]))
2013-03-16 02:33:55 -07:00
{
2015-02-03 12:23:03 -08:00
foreach ( $this -> notify_prefs [ 'plugins' ] as $id => $var )
{
$text .= " <li><a href='#notify- " . $id . " ' data-toggle='tab'> " . ucfirst ( $id ) . " </a></li> " ;
}
2013-03-16 02:33:55 -07:00
}
$text .= "
</ ul >
< div class = 'tab-content' >
< div class = 'tab-pane active' id = 'core' >
2009-07-10 14:25:23 +00:00
< fieldset id = 'core-notify-config' >
2009-07-14 03:18:17 +00:00
< legend > " .NU_LAN_1. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-10 14:25:23 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
" ;
2006-12-02 04:36:16 +00:00
$text .= $this -> render_event ( 'usersup' , NU_LAN_2 );
$text .= $this -> render_event ( 'userveri' , NU_LAN_3 );
$text .= $this -> render_event ( 'login' , NU_LAN_4 );
$text .= $this -> render_event ( 'logout' , NU_LAN_5 );
2015-02-13 02:30:31 -08:00
$text .= $this -> render_event ( 'user_xup_' , NU_LAN_5 );
2006-12-02 04:36:16 +00:00
2009-07-14 03:18:17 +00:00
$text .= " </table></fieldset>
< fieldset id = 'core-notify-2' >
< legend > " .NS_LAN_1. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-14 03:18:17 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
2006-12-02 04:36:16 +00:00
$text .= $this -> render_event ( 'flood' , NS_LAN_2 );
2009-07-14 03:18:17 +00:00
$text .= " </table></fieldset>
2013-03-16 02:33:55 -07:00
</ div >
< div class = 'tab-pane' id = 'news' >
2009-07-14 03:18:17 +00:00
< fieldset id = 'core-notify-3' >
< legend > " .NN_LAN_1. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-14 03:18:17 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
2006-12-02 04:36:16 +00:00
$text .= $this -> render_event ( 'subnews' , NN_LAN_2 );
$text .= $this -> render_event ( 'newspost' , NN_LAN_3 );
$text .= $this -> render_event ( 'newsupd' , NN_LAN_4 );
$text .= $this -> render_event ( 'newsdel' , NN_LAN_5 );
2009-07-14 03:18:17 +00:00
$text .= " </table></fieldset>
2013-03-16 02:33:55 -07:00
</ div >
< div class = 'tab-pane' id = 'mail' >
2009-07-14 03:18:17 +00:00
< fieldset id = 'core-notify-4' >
2009-11-27 21:42:46 +00:00
< legend > " .NM_LAN_1. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-11-27 21:42:46 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
$text .= $this -> render_event ( 'maildone' , NM_LAN_2 );
$text .= " </table></fieldset>
2013-03-16 02:33:55 -07:00
</ div >
< div class = 'tab-pane' id = 'files' >
2009-11-27 21:42:46 +00:00
< fieldset id = 'core-notify-5' >
2009-07-14 03:18:17 +00:00
< legend > " .NF_LAN_1. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-14 03:18:17 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
2006-12-02 04:36:16 +00:00
$text .= $this -> render_event ( 'fileupload' , NF_LAN_2 );
2013-03-16 02:33:55 -07:00
$text .= " </table>
</ fieldset >
</ div > " ;
2015-02-03 12:23:03 -08:00
if ( ! empty ( $this -> notify_prefs [ 'plugins' ]))
2008-04-26 14:34:17 +00:00
{
2015-02-03 12:23:03 -08:00
foreach ( $this -> notify_prefs [ 'plugins' ] as $plugin_id => $plugin_settings )
2006-12-02 04:36:16 +00:00
{
2015-02-03 12:23:03 -08:00
if ( is_readable ( e_PLUGIN . $plugin_id . '/e_notify.php' ))
2008-04-26 14:34:17 +00:00
{
2015-02-03 12:23:03 -08:00
$config_category = $this -> pluginConfig [ $plugin_id ][ 'category' ];
$legacy = $this -> pluginConfig [ $plugin_id ][ 'legacy' ];
// require(e_PLUGIN.$plugin_id.'/e_notify.php');
$text .= " <div class='tab-pane' id='notify- " . $plugin_id . " '>
< fieldset id = 'core-notify-".str_replace(" ","_",$config_category)."' >
< legend > " . $config_category . " </ legend >
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup > " ;
;
foreach ( $this -> pluginConfig [ $plugin_id ][ 'events' ] as $event_id => $event_text )
{
$text .= $this -> render_event ( $event_id , $event_text , $plugin_id , $legacy );
}
$text .= " </table>
</ div > " ;
2006-12-02 04:36:16 +00:00
}
}
}
2009-07-14 03:18:17 +00:00
$text .= "
2013-03-16 02:33:55 -07:00
2009-07-10 14:25:23 +00:00
< div class = 'buttons-bar center' > " ;
$text .= $frm -> admin_button ( 'update' , LAN_UPDATE , 'update' );
$text .= "
</ div >
</ fieldset >
2006-12-02 04:36:16 +00:00
</ form >
2013-02-10 13:55:52 +01:00
" ;
2006-12-02 04:36:16 +00:00
2013-02-10 13:55:52 +01:00
$ns -> tablerender ( NT_LAN_1 , $mes -> render () . $text );
2015-02-13 02:30:31 -08:00
*/
2006-12-02 04:36:16 +00:00
}
2008-12-07 12:00:13 +00:00
2013-06-18 20:21:10 -07:00
function render_event ( $id , $description , $include = '' , $legacy = 0 )
2008-12-07 12:00:13 +00:00
{
2013-02-10 13:55:52 +01:00
$tp = e107 :: getParser ();
2013-06-18 20:21:10 -07:00
$frm = e107 :: getForm ();
2015-03-07 16:30:46 -08:00
$uc = e107 :: getUserClass ();
$uc -> fixed_classes [ 'email' ] = 'Email Address =>' ;
$uc -> text_class_link [ 'email' ] = 'email' ;
2015-02-13 02:30:31 -08:00
if ( defined ( $description ))
{
$description = constant ( $description );
}
2015-05-13 01:22:05 -07:00
2016-03-17 11:02:25 -07:00
2015-05-13 01:22:05 -07:00
$highlight = varset ( $_GET [ 'type' ]) == $id ? " class='text-warning' " : '' ;
2013-02-10 13:55:52 +01:00
2009-12-28 22:16:54 +00:00
$text = "
2008-04-26 14:34:17 +00:00
< tr >
2016-03-17 11:02:25 -07:00
< td title = '".$id."' >< span { $highlight } > " . $description . " :</ span ></ td > " ;
if ( e_DEBUG )
{
$text .= " <td> " . $id . " </td> " ;
}
$text .= "
2014-07-02 21:38:47 -07:00
< td class = 'form-inline nowrap' >
2015-03-07 16:30:46 -08:00
" . $uc->uc_dropdown ('event['. $id .'][class]', varset( $this->notify_prefs ['event'][ $id ]['class'], e_UC_NOBODY), " nobody , main , admin , member , classes , email " , " onchange = \ " mail_field(this.value,'event_ " . $id . " '); \" " );
2008-04-26 14:34:17 +00:00
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] == 'email' )
{
$disp = 'display:visible' ;
$value = $tp -> toForm ( $this -> notify_prefs [ 'event' ][ $id ][ 'email' ]);
}
else
{
2009-04-28 00:06:17 +00:00
$disp = " display:none " ;
2008-04-26 14:34:17 +00:00
$value = " " ;
}
2014-07-02 21:38:47 -07:00
$text .= " <input type='text' style='width:200px; $disp ' class='tbox' id='event_ " . $id . " ' name='event[ " . $id . " ][email]' value= \" " . $value . " \" /> \n " ;
2008-04-26 14:34:17 +00:00
2013-06-18 20:21:10 -07:00
$text .= $frm -> hidden ( " event[ " . $id . " ][include] " , $include );
$text .= $frm -> hidden ( " event[ " . $id . " ][legacy] " , $legacy ); // function or method
2015-05-13 01:22:05 -07:00
if ( isset ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ]) && $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != e_UC_NOBODY )
2015-03-07 16:30:46 -08:00
{
$text .= $frm -> button ( 'test[' . $id . ']' , $id , 'confirm' , 'Test' );
}
2016-03-17 11:02:25 -07:00
$text .= " </td> " ;
$text .= "
2006-12-02 04:36:16 +00:00
</ tr > " ;
return $text ;
}
2008-12-07 12:00:13 +00:00
function update ()
{
$this -> changeList = array ();
2015-03-07 16:30:46 -08:00
$active = false ;
2008-04-26 14:34:17 +00:00
foreach ( $_POST [ 'event' ] as $key => $value )
{
if ( $this -> update_event ( $key ))
{
2015-03-07 16:30:46 -08:00
$active = true ;
2006-12-02 04:36:16 +00:00
}
}
2015-03-07 16:30:46 -08:00
2013-06-18 20:21:10 -07:00
// print_a($this->notify_prefs);
2013-02-19 21:26:45 +00:00
/*
2006-12-02 04:36:16 +00:00
$s_prefs = $tp -> toDB ( $this -> notify_prefs );
$s_prefs = $eArrayStorage -> WriteArray ( $s_prefs );
2008-04-26 14:34:17 +00:00
if ( $sql -> db_Update ( " core " , " e107_value=' " . $s_prefs . " ' WHERE e107_name='notify_prefs' " ) !== FALSE )
2013-02-19 21:26:45 +00:00
*/
2015-03-07 16:30:46 -08:00
e107 :: getConfig () -> set ( 'notify' , $active ) -> save ( true , true , false );
2013-02-19 21:26:45 +00:00
e107 :: getConfig ( 'notify' ) -> updatePref ( $this -> notify_prefs );
if ( e107 :: getConfig ( 'notify' ) -> save ( FALSE ))
2008-04-26 14:34:17 +00:00
{
2014-01-10 07:36:54 -08:00
// e107::getAdminLog()->logArrayAll('NOTIFY_01',$this->changeList);
2015-03-07 16:30:46 -08:00
return true ;
2006-12-02 04:36:16 +00:00
}
2008-04-26 14:34:17 +00:00
else
{
2015-03-07 16:30:46 -08:00
return false ;
2008-04-26 14:34:17 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-12-07 12:00:13 +00:00
function update_event ( $id )
{
$changed = FALSE ;
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != $_POST [ 'event' ][ $id ][ 'class' ])
{
$this -> notify_prefs [ 'event' ][ $id ][ 'class' ] = $_POST [ 'event' ][ $id ][ 'class' ];
$changed = TRUE ;
}
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'email' ] != $_POST [ 'event' ][ $id ][ 'email' ])
{
$this -> notify_prefs [ 'event' ][ $id ][ 'email' ] = $_POST [ 'event' ][ $id ][ 'email' ];
$changed = TRUE ;
}
2013-06-18 20:21:10 -07:00
$this -> notify_prefs [ 'event' ][ $id ][ 'include' ] = $_POST [ 'event' ][ $id ][ 'include' ];
$this -> notify_prefs [ 'event' ][ $id ][ 'legacy' ] = $_POST [ 'event' ][ $id ][ 'legacy' ];
unset ( $this -> notify_prefs [ 'event' ][ $id ][ 'plugin' ]);
unset ( $this -> notify_prefs [ 'event' ][ $id ][ 'type' ]);
2008-12-07 12:00:13 +00:00
if ( $changed )
{
$this -> changeList [ $id ] = $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] . ', ' . $this -> notify_prefs [ 'event' ][ $id ][ 'email' ];
}
if ( $this -> notify_prefs [ 'event' ][ $id ][ 'class' ] != 255 )
{
2006-12-02 04:36:16 +00:00
return TRUE ;
2008-12-07 12:00:13 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
return FALSE ;
}
}
}
2016-11-08 10:00:33 -08:00
require_once ( e_ADMIN . 'footer.php' ); /*
2008-04-26 14:34:17 +00:00
function headerjs ()
{
$js = "
< script type = 'text/javascript' >
2006-12-02 04:36:16 +00:00
2008-04-26 14:34:17 +00:00
function mail_field ( val , id )
{
if ( val == 'email' )
{
document . getElementById ( id ) . style . display = '' ;
}
else
{
document . getElementById ( id ) . style . display = 'none' ;
}
}
</ script > " ;
return $js ;
2016-11-08 10:00:33 -08:00
} */
2006-12-02 04:36:16 +00:00
?>