Beispiel #1
0
 private function handleUserPost()
 {
     $request = Request::getInstance();
     $user = new NewsLetterUser($this->plugin);
     $usr_used = $request->getValue('usr_used');
     if (!$usr_used) {
         $usr_used = array();
     }
     try {
         if (!$request->exists('id')) {
             throw new Exception('User group is missing.');
         }
         $id = intval($request->getValue('id'));
         $key = array('id' => $id);
         $this->removeUser($key);
         foreach ($usr_used as $item) {
             $user->addGroup(array('id' => $item), $key);
         }
         viewManager::getInstance()->setType(NewsLetter::VIEW_GROUP_OVERVIEW);
         $this->handleOverview();
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handleUserGet(false);
     }
 }
Beispiel #2
0
 public static function getGenderTypeList()
 {
     if (isset(self::$gendertypelist)) {
         return self::$gendertypelist;
     }
     self::$gendertypelist = array();
     foreach (self::$gendertypes as $key => $value) {
         self::$gendertypelist[$key] = array('id' => $key, 'name' => $value);
     }
     return self::$gendertypelist;
 }
Beispiel #3
0
 /**
  * delete a plugin item
  *
  * @param array whith id [fieldname => value]
  * @param string name of the tag that is being deleted
  * @param integer id of the tree 
  * @return void
  */
 public function deletePlugin($values, $plugin_type)
 {
     $ref = $this->getObject($plugin_type);
     switch ($plugin_type) {
         case self::TYPE_DEFAULT:
             // delete reference ids
             require_once 'NewsLetterTreeRef.php';
             $treeref = new NewsLetterTreeRef();
             $key = array('ref_tree_id' => $values['tree_id']);
             $treeref->delete($key);
             $key = array('tree_id' => $values['tree_id'], 'tag' => $values['tag']);
             // delete settings
             require_once 'NewsLetterSettings.php';
             $obj = new NewsLetterSettings($this);
             $obj->delete($key);
             // delete users
             require_once 'NewsLetterUser.php';
             $obj = new NewsLetterUser($this);
             $obj->delete($key);
             // delete user groups
             require_once 'NewsLetterGroup.php';
             $obj = new NewsLetterGroup($this);
             $obj->delete($key);
             // delete usergroup links
             $obj->deleteUserGroup($values['tree_id'], $values['tag']);
             // delete news items
             $list = $ref->getList($key);
             foreach ($list['data'] as $item) {
                 $key = $ref->getKey($item);
                 $ref->delete($key);
             }
             break;
         default:
             $key = $ref->getKey($values);
             $ref->delete($key);
     }
 }
Beispiel #4
0
 private function handlePreviewPost()
 {
     $request = Request::getInstance();
     try {
         if (!$request->exists('nl_id')) {
             throw new Exception(__CLASS__ . "::" . __FUNCTION__ . " : nl_id parameter is missing");
         }
         $key = array('id' => $request->getValue('nl_id'));
         $sendmail = $request->exists('send');
         $email = $request->getValue('email');
         if ($sendmail && !Utils::isEmail($email)) {
             throw new Exception("Invalid email address specified");
         }
         if (!$this->exists($key)) {
             throw new HttpException('404');
         }
         $detail = $this->getDetail($key);
         $user = array('gender_description' => NewsLetterUser::getGenderTypeDesc(NewsLetterUser::GENDER_MALE), 'name' => 'Test Recipient', 'email' => $email ? $email : $this->director->getConfig()->email_address);
         $systemSite = new SystemSite();
         $tree = $systemSite->getTree();
         $url_unsubscribe = new Url();
         $url_unsubscribe->setPath($request->getProtocol() . $request->getDomain() . $tree->getPath($detail['tree_id']));
         $url_unsubscribe->setParameter(ViewManager::URL_KEY_DEFAULT, NewsLetter::VIEW_USER_UNSUBSCRIBE);
         $url_unsubscribe->setParameter(NewsLetterUser::KEY_UNSUBSCRIBE, $user['email']);
         $parameters = array('user' => $user, 'href_unsubscribe' => $url_unsubscribe->getUrl(true));
         $key = array('nl_id' => $key['id'], 'activated' => true);
         $theme = $this->getNewsLetterTheme($key, $detail);
         $this->handleThemePostProcessing($theme, $parameters);
         $content = $theme->fetchTheme();
         if ($sendmail) {
             $objAttachment = $this->plugin->getObject(NewsLetter::TYPE_ATTACHMENT);
             $attachments = $objAttachment->getAttachmentList($key);
             $this->sendMail(array($email), $this->director->getConfig()->email_address, $detail['name'], $content, $attachments);
             // reset theme settings
             $this->director->theme->handlePreProcessing($this->director);
             $view = ViewManager::getInstance();
             $view->setType(ViewManager::TREE_OVERVIEW);
             $this->handleHttpGetRequest();
         } else {
             echo $content;
             exit;
         }
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handlePreviewGet();
     }
 }