Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
tool_import_bmail_user.inc
1 <?php
17 require_once SQ_SYSTEM_ROOT.'/core/assets/system/tool/tool.inc';
18 
34 {
35 
36 
43  function Tool_Import_Bmail_User($assetid=0)
44  {
45  $this->Tool($assetid);
46 
47  }//end constructor
48 
49 
59  public static function paintTool(&$o, $type_code)
60  {
61  $tool_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code);
62  $o->openSection($tool_info['name']);
63 
64  $o->openField(translate('bm_tool_import_bmail_user_file_upload'));
65  file_upload($type_code.'_file_upload');
66  $o->note(translate('bm_tool_import_bmail_user_file_upload_note'));
67  $o->closeField();
68 
69  $o->openField(translate('bm_tool_import_bmail_user_file_upload_header'));
70  check_box($type_code.'_csv_header');
71  $o->note(translate('bm_tool_import_bmail_user_file_upload_header_example'));
72  $o->closeField();
73 
74  $o->openField(translate('bm_tool_import_bmail_user_create_in'));
75  asset_finder($type_code.'_create_in_assetid', 0, Array('user_group' => 'D'));
76  $o->note(translate('bm_tool_import_bmail_user_create_in_note'));
77  $o->closeField();
78 
79  $o->openField('');
80  check_box($type_code.'_new_link'); echo 'Link user with an existing email address?';
81  $o->note('The "email" attribute of a Bulkmail User is unique, so that the same user will not get multiple copies of the same mail out.<br />If an existing address is specified in the CSV file, the Bulkmail User will also be linked under the "Create Users in" folder, if this option is enabled.');
82  $o->closeField();
83 
84  $o->closeSection();
85 
86  }//end paintTool()
87 
88 
98  public static function processTool(&$o, $type_code)
99  {
100  // error: csv file not specified
101  $file_info = get_file_upload_info($type_code.'_file_upload');
102  if (empty($file_info)) {
103  trigger_localised_error('BML0011', E_USER_NOTICE);
104  return FALSE;
105  }
106 
107  // error: user group not specified
108  if (!$_REQUEST[$type_code.'_create_in_assetid']['assetid']) {
109  trigger_localised_error('BML0012', E_USER_NOTICE);
110  return FALSE;
111  }
112 
113  $vars['csv_header'] = 0;
114  if (isset($_REQUEST[$type_code.'_csv_header'])) {
115  $vars['csv_header'] = 1;
116  }
117 
118  // set HIPO running_vars
119  $vars['file_info'] = $file_info;
120  $vars['create_in_assetid'] = $_REQUEST[$type_code.'_create_in_assetid']['assetid'];
121  $vars['new_link'] = (isset($_REQUEST[$type_code.'_new_link'])) ? $_REQUEST[$type_code.'_new_link'] : FALSE;
122 
123  // run HIPO job
124  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
125  $hh->queueHipo('hipo_job_tool_import_bmail_user', $vars, '', SQ_PACKAGES_PATH.'/bulkmail/hipo_jobs');
126  $url = $hh->runQueuedJobs();
127  if (!empty($url)) $o->setRedirect($url);
128  return TRUE;
129 
130  }//end processTool()
131 
132 
133 }//end class
134 
135 
136 ?>