Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
bulkmail_post_office.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset.inc';
18 require_once SQ_PACKAGES_PATH.'/bulkmail/bulkmail_constant.inc';
19 require_once SQ_FUDGE_PATH.'/general/file_system.inc';
20 require_once 'Mail.php';
21 require_once SQ_DATA_PATH.'/private/conf/tools.inc';
22 @require_once 'Mail/mime.php';
23 
24 
39 {
40 
41 
48  function __construct($assetid=0)
49  {
50  $this->_ser_attrs = TRUE;
51  parent::__construct($assetid);
52 
53  }//end constructor
54 
55 
65  function _getName($short_name=FALSE)
66  {
67  return $this->attr('name');
68 
69  }//end _getName()
70 
71 
79  function _getAllowedLinks()
80  {
81  // ensure that each job is only linked to one post office in canCreateLink and canMoveLink
82  // see the relationship between site_network and site for more info
83  return Array(
84  SQ_LINK_TYPE_1 => Array(
85  'bulkmail_job' => Array(
86  'card' => 'M',
87  'exclusive' => FALSE,
88  ),
89  ),
90  SQ_LINK_TYPE_2 => Array(
91  'bulkmail_job' => Array(
92  'card' => 'M',
93  'exclusive' => FALSE,
94  ),
95  ),
96  SQ_LINK_NOTICE => Array(
97  'bulkmail_job' => Array(
98  'card' => 'M',
99  'exclusive' => FALSE,
100  ),
101  ),
102  );
103 
104  }//end _getAllowedLinks()
105 
106 
117  function canCreateLink(&$minor, $link_type, $exclusive)
118  {
119  $result = parent::canCreateLink($minor, $link_type, $exclusive);
120  if ($result !== TRUE) return $result;
121 
122  if (($minor instanceof Bulkmail_Job) && ($link_type != SQ_LINK_NOTICE)) {
123  // bulkmail job can only link to one bulkmail post office
124  $bmail_link = $GLOBALS['SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT, 'bulkmail_post_office', FALSE, 'minor');
125  if (!empty($bmail_link)) {
126  return translate('bm_warning_one_post_office_for_job');
127  }
128  }
129 
130  return TRUE;
131 
132  }//end canCreateLink()
133 
134 
145  function canMoveLink(&$minor, &$old_major, $link_type)
146  {
147  if (($minor instanceof Bulkmail_Job) && ($old_major instanceof Bulkmail_Post_Office) && ($link_type != SQ_LINK_NOTICE)) {
148  // tolerate one existing bmail_link if we are moving jobs from one post office to another
149  $bmail_link = $GLOBALS['SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT, 'bulkmail_post_office', FALSE, 'minor');
150  if (count($bmail_link) > 1) {
151  return translate('bm_warning_one_post_office_for_job');
152  }
153  } else {
154  // if we aren't moving from a post office, the usual check applies
155  return parent::canMoveLink($minor, $old_major, $link_type);
156  }
157 
158  return TRUE;
159 
160  }//end canMoveLink()
161 
162 
171  public function attr($name)
172  {
173  $value = parent::attr($name);
174  if($name === 'server_details' ) {
175  $driver = array_get_index($value, 'driver', '');
176  if($driver === 'sendmail') {
177  if(SQ_TOOL_SENDMAIL_PATH !== '') {
178  $value['sendmail_path'] = SQ_TOOL_SENDMAIL_PATH;
179  }
180  if(SQ_TOOL_SENDMAIL_ARGS !== '') {
181  $value['sendmail_args'] = SQ_TOOL_SENDMAIL_ARGS;
182  }
183  }
184  }
185 
186  return $value;
187 
188  }//end attr()
189 
190 }//end class
191 ?>