Mailinglist
 All Data Structures Files Functions Variables Pages
mailinglist_exportable.class.php
Go to the documentation of this file.
1 <?php
14  public $object_type;
15  public $settings;
16  public $export_type;
17 
26  public function get_setting($name, $def=NULL) {
27  if (isset($this->settings[$name])) return $this->settings[$name];
28  return $def;
29  }
30 
31  /******************** MailinglistPolymorphicExportableInterface *************/
42  function created() {
43  $ret = module_invoke_all($this->baseName() . '_created', $this);
44  }
45 
51  function edited(/* MailinglistPolymorpicExportableInterface */ $old) {
52  $ret = module_invoke_all($this->baseName() . '_edited', $this, $old);
53  }
54 
60  function changedType(MailinglistPolymorpicExportableInterface $old) {
61  $ret = module_invoke_all($this->baseName() . '_changed_type', $this, $old);
62  }
63 
69  function delete() {
70  $ret = module_invoke_all($this->baseName() . '_delete', $this);
71  }
72 
78  function baseName() {
79  return $this->table;
80  }
81 
83 
84  /******************** ctools_export_ui interface ****************************/
95  public function edit_form(&$form, &$form_state) {
96  }
97 
102  function edit_form_validate(&$form, &$form_state) {
103  }
104 
109  function edit_form_submit(&$form, &$form_state) {
110  }
112 
117 /**** Loging Interface ******/
118 
119  const LOG_OFF = 0;
120  const LOG_SCREEN = 1;
121  const LOG_DB = 2;
122  const LOG_DB_SCREEN = 3;
123  const LOG_FILE = 4;
124  const LOG_FILE_SCREEN = 5;
125 
126  // Each level defined here need to be listed in log_screen()
127 
128  const LOG_DEBUG = WATCHDOG_DEBUG;
129  const LOG_INFO = WATCHDOG_INFO;
130  const LOG_NOTICE = WATCHDOG_NOTICE;
131  const LOG_WARNING = WATCHDOG_WARNING;
132  const LOG_ERROR = WATCHDOG_ERROR;
133  const LOG_CRITICAL = WATCHDOG_CRITICAL;
134  const LOG_ALERT = WATCHDOG_ALERT;
135  const LOG_EMERGENCY = WATCHDOG_EMERGENCY;
136 
137  public $logging_screen = self::LOG_DEBUG;
138  public $logging_db = self::LOG_INFO;
139  public $logging_file = self::LOG_DEBUG;
140 
144  public function log($str, $level = self::LOG_NOTICE, $parms = array()) {
145  // Note, Value for levels are highest, for lowest priority events
146  if ($level <= $this->logging_db) {
147  $this->log_db($str, $parms, $level);
148  }
149  if ($level <= $this->logging_file) {
150  $this->log_file($str, $parms, $level);
151  }
152  if ($level <= $this->logging_screen) {
153  $this->log_screen($str, $parms, $level);
154  }
155  }
156 
157  /*****************************************************************************
158  These methods provide implementations for the various logging options above,
159  while they can be directly called, it is not normal.
160  */
161 
167  public function log_screen($str, $parms = array(), $level = self::LOG_NOTICE) {
168  // This array needs a member for each logging level
169  static $levels = array(
170  self::LOG_DEBUG => 'status',
171  self::LOG_INFO => 'status',
172  self::LOG_NOTICE => 'status',
173  self::LOG_WARNING => 'warning',
174  self::LOG_ERROR => 'error',
175  self::LOG_CRITICAL => 'error',
176  self::LOG_ALERT => 'error',
177  self::LOG_EMERGENCY => 'error',
178  );
180  dpm(t($str, $parms), $this->object_type, $levels[$level]);
181  }
182 
183 
189  public function log_db($str, $parms = array(), $level = self::LOG_ERROR) {
190  $key = $this->object_type;
191  if(property_exists($this, 'admin_name')){
192  $key .= ' ' . $this->admin_name;
193  }
194  watchdog($this->object_type, $str, $parms, $level);
195  }
196 
203  public function log_file($str, $parms = array(), $level = self::LOG_INFO) {
204  }
205 
207 };
208 
209 
interface MailinglistPolymorphicExportInterface
edit_form_validate(&$form, &$form_state)
Implements ctools_export_ui::edit_form_validate().
get_setting($name, $def=NULL)
get_settings()
log_file($str, $parms=array(), $level=self::LOG_INFO)
log_file().
$object_type
The type of object we are.
log($str, $level=self::LOG_NOTICE, $parms=array())
log()
edit_form_submit(&$form, &$form_state)
Implements ctools_export_ui::edit_form_submit().
changedType(MailinglistPolymorpicExportableInterface $old)
changedType()
log_db($str, $parms=array(), $level=self::LOG_ERROR)
log_db().
Place for common code for classes used in export_ui classes.
log_screen($str, $parms=array(), $level=self::LOG_NOTICE)
log_screen()
edit_form(&$form, &$form_state)
Implements ctools_export_ui::edit_form() called via mailinglist_export_ui Build an edit form for our ...
$settings
Generic Array to hold misc settings so all can use same schema.