DMail Milestone 1.0
Drupal Mail Client
dmail.signatures.inc
Go to the documentation of this file.
00001 <?php
00002 // $Id: 66f60aed47dc1bfdff109a391b4710d89345e0d5 $
00011 function dmail_user_signatures() {
00012   return drupal_get_form('mfm_dmail_signatures');
00013 }
00014 
00018 function dmail_user_signatures_add() {
00019   return drupal_get_form('mfm_dmail_signatures_add');
00020 }
00021 
00025 function mfm_dmail_signatures() {
00026   global $user;
00027   mfn_dmail_security_check();
00028   $signatures = mfn_dmail_db_signatures_select();
00029   $form['dmail']['signature']['list']['header']['#dmail_data'] = array(
00030     array('data' => t('##'), 'field' => 'id'),
00031     array('data' => t('Signature'), 'field' => 'name'),
00032     array('data' => t('Created'), 'field' => 'created'),
00033     array('data' => t('Updated'), 'field' => 'updated'),
00034   );
00035   foreach ($signatures as $signature) {
00036     $urlf = 'user/' . $user->uid . '/email/signature/' . $signature->id;
00037     $form['dmail']['signature']['list']['id'][$signature->id] = array(
00038       '#value' => l($signature->id, $urlf . '/edit'),
00039     );
00040     $form['dmail']['signature']['list']['name'][$signature->id] = array(
00041       '#value' => $signature->name,
00042     );
00043     $form['dmail']['signature']['list']['created'][$signature->id] = array(
00044       '#value' => $signature->created,
00045     );
00046     $form['dmail']['signature']['list']['updated'][$signature->id] = array(
00047       '#value' => $signature->updated,
00048     );
00049     $v = mfn_dmail_l($urlf . '/remove', t('Delete'));
00050     $form['dmail']['signature']['list']['operations'][$signature->id] = array(
00051       '#value' => $v,
00052     );
00053     $signatures_on_page[$signature->id] = '';
00054   }
00055   $form['dmail']['signature']['list']['signatures'] = array(
00056     '#type' => 'checkboxes',
00057     '#options' => $signatures_on_page,
00058   );
00059   return $form;
00060 }
00061 
00065 function theme_mfm_dmail_signatures($form) {
00066   $header = mfn_dmail_list_headers('dmail_signatures', $form);
00067   $output = NULL;
00068   $rows = array();
00069   foreach (element_children($form['dmail']['signature']['list']['id']) as $key) {
00070     $rows[] = array(
00071       drupal_render($form['dmail']['signature']['list']['signatures'][$key]),
00072       drupal_render($form['dmail']['signature']['list']['id'][$key]),
00073       drupal_render($form['dmail']['signature']['list']['name'][$key]),
00074       drupal_render($form['dmail']['signature']['list']['created'][$key]),
00075       drupal_render($form['dmail']['signature']['list']['updated'][$key]),
00076       drupal_render($form['dmail']['signature']['list']['operations'][$key]),
00077     );
00078   }
00079   if (!count($rows)) {
00080     $rows[] = array(array('data' => t('No signatures to list.'), 'colspan' => '6'));
00081   }
00082   $output .= theme('table', $header, $rows);
00083   $output .= drupal_render($form);
00084   return $output;
00085 }
00086 
00090 function mfm_dmail_signatures_add() {
00091   global $user;
00092   mfn_dmail_security_check();
00093   $form['dmail']['signature']['add']['name'] = array(
00094     '#type' => 'textfield',
00095     '#title' => t('Name'),
00096     '#description' => t('The visual representation of the signature.'),
00097     '#required' => TRUE,
00098   );
00099   $form['dmail']['signature']['add']['signature'] = array(
00100     '#type' => 'textarea',
00101     '#title' => t('Signature'),
00102     '#description' => t('The signature.'),
00103     '#required' => TRUE,
00104   );
00105   $form['dmail']['signature']['add']['submit'] = array(
00106     '#type' => 'submit',
00107     '#value' => t('Add Signature'),
00108   );
00109   $form['#redirect'] = 'user/' . $user->uid . '/email/signatures';
00110   return $form;
00111 }
00112 
00116 function mfm_dmail_signatures_add_validate(&$form, &$form_state) {
00117   $values =& $form_state['values'];
00118   $signature = mfn_dmail_db_signature_select($values['name']);
00119   if ($signature !== FALSE) {
00120     form_set_error('dmail][signature][add]', t('Duplicate name.'));
00121   }
00122 }
00123 
00127 function mfm_dmail_signatures_add_submit(&$form, &$form_state) {
00128   $values =& $form_state['values'];
00129   mfn_dmail_db_signatures_add($values);
00130 }
All Data Structures Files Functions Variables Enumerations