Exemple #1
0
 /**
  * Build and return admin interface
  * 
  * Any module providing an admin interface is required to have this function, which
  * returns a string containing the (x)html of it's admin interface.
  * @return string
  */
 function getAdminInterface()
 {
     switch (@$_REQUEST['section']) {
         case 'lists':
             switch (@$_REQUEST['action']) {
                 case 'updateList':
                     $list = new MailList($_REQUEST['listId']);
                     $form = $list->getListUsersForm();
                     return;
                     break;
                 case 'delete':
                     $list = new MailList(@$_REQUEST['maillist_id']);
                     $list->delete();
                     break;
                 case 'addedit':
                     $list = new MailList(@$_REQUEST['maillist_id']);
                     $form = $list->getAddEditForm();
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['maillist_submit'])) {
                         return $form->display();
                     }
                     break;
             }
             $this->addJS('/modules/Mail/js/list_edit.js');
             $lists = MailList::getAllMailLists();
             $this->smarty->assign('lists', $lists);
             return $this->smarty->fetch('admin/lists.tpl');
         case 'users':
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $user = new MailUser(@$_REQUEST['mailuser_id']);
                     $form = $user->getAddEditForm();
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['mailuser_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $user = new MailUser(@$_REQUEST['mailuser_id']);
                     $user->delete();
                     break;
             }
             $users = MailUser::getAllMailUsers();
             $this->smarty->assign('users', $users);
             return $this->smarty->fetch('admin/users.tpl');
         case 'content':
         default:
             $this->addCSS('/modules/Mail/css/send.css');
             switch (@$_REQUEST['action']) {
                 case 'delete':
                     $content = new MailContent(@$_REQUEST['mailcontent_mail_id']);
                     $content->delete();
                     break;
                 case 'addedit':
                     $content = new MailContent(@$_REQUEST['mailcontent_mail_id']);
                     $form = $content->getAddEditForm();
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['mailcontent_submit'])) {
                         return $form->display();
                     } else {
                         break;
                     }
                 case 'send':
                     $lists = MailList::getAllMailLists();
                     $content = new MailContent(@$_REQUEST['mailcontent_mail_id']);
                     $this->smarty->assign('content', $content);
                     $this->smarty->assign('lists', $lists);
                     return $this->smarty->fetch('admin/send.tpl');
                     break;
                 case 'queue':
                     $list = new MailList($_REQUEST['maillist_id']);
                     $content = new MailContent($_REQUEST['mailcontent_id']);
                     $sendout = new MailSendOut();
                     $sendout->accept($content);
                     $sendout->setTimestamp(date('Y-m-d H:i:s'));
                     $sendout->setListCount($list->getListCount());
                     $sendout->save();
                     $list->queueUsers($sendout);
                     break;
                 case 'iframe_preview':
                     $content = new MailContent(@$_REQUEST['mailcontent_mail_id']);
                     $this->smarty->assign('content', $content);
                     echo $this->smarty->fetch('admin/shell.tpl');
                     die;
                     break;
             }
             $contents = MailContent::getAllMailContents();
             $this->smarty->assign('contents', $contents);
             return $this->smarty->fetch('admin/contents.tpl');
         case 'reports':
             switch (@$_REQUEST['action']) {
                 case 'view':
                     $report = new MailReport($_REQUEST['rid']);
                     $this->smarty->assign('report', $report);
                     return $this->smarty->fetch('admin/report_detail.tpl');
                     break;
                 default:
                     break;
             }
             $this->addCSS('/modules/Mail/css/report.css');
             $this->addJS('/modules/Mail/js/report.js');
             $reports = MailReport::getAllReports();
             $this->smarty->assign('reports', $reports);
             return $this->smarty->fetch('admin/reports.tpl');
             break;
     }
 }
Exemple #2
0
 public function getListUsersForm()
 {
     $form = new Form('MailList_users', 'post', '/admin/Mail');
     $form->setConstants(array('section' => 'lists'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'updateList'));
     $form->addElement('hidden', 'action');
     $form->setConstants(array('listId' => $this->getId()));
     $form->addElement('hidden', 'listId');
     $users = array();
     foreach ($this->getListUsers() as $user) {
         $users[] = $user->getId();
     }
     $allusers = array();
     foreach (MailUser::getAllMailUsers() as $user) {
         $allusers[$user->getId()] = $user->__toString();
     }
     $form->setDefaults(array('subscribers' => $users));
     $ams = $form->addElement('advmultiselect', 'subscribers', null, $allusers, array('style' => 'width: 300px;', 'onblur' => 'changeCallback(this);'));
     $ams->setLabel(array($this->getName(), 'Available', 'Subscribed to List'));
     if ($form->validate() && $form->isSubmitted()) {
         $clean = $form->getSubmitValues();
         if (isset($_REQUEST['subscribers-t'])) {
             foreach ($_REQUEST['subscribers-t'] as $from) {
                 $this->removeListUser($from);
             }
         }
         if (isset($_REQUEST['subscribers-f'])) {
             foreach ($_REQUEST['subscribers-f'] as $from) {
                 $this->addListUser($from);
             }
         }
     }
     return $form;
 }