/** * renders tree into menu template * @return object */ public function renderTree() { if (!$this->getConfig()->template_menu) { return; } if (!$this->tree) { return; } $template = new TemplateEngine($this->templatePath . $this->getConfig()->template_menu); $template->setCacheable(true); $cache = Cache::getInstance(); if (!$cache->isCached('submenu')) { $childs = array(); $childlist = $this->tree->getChildList($this->tree->getCurrentId()); foreach ($childlist as $item) { if (isset($item['visible']) && !$item['visible']) { continue; } $item['path'] = $this->tree->getPath($item['id']); $childs[] = $item; } $template->setVariable('submenu', $childs, false); $cache->save(serialize($childs), 'submenu'); } else { $template->setVariable('submenu', unserialize($cache->getCache('submenu')), false); } // check if template is in cache if ($template->isCached()) { return $template; } $menu = $this->tree->getRootList(); // get selected main menu item $firstNode = $this->tree->getFirstAncestorNode($this->tree->getCurrentId()); $firstId = $firstNode ? $firstNode['id'] : 0; foreach ($menu as &$item) { $item['path'] = isset($item['external']) && $item['external'] ? $item['url'] : $this->tree->getPath($item['id']); $item['selected'] = $item['id'] == $firstId; } $template->setVariable('menu', $menu, false); $auth = Authentication::getInstance(); $template->setVariable('loginName', $auth->getUserName(), false); return $template; }
private function handleDeletePost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { $key = $this->getKey(); $this->delete($key); viewManager::getInstance()->setType(NewsLetter::VIEW_PLUGIN_OVERVIEW); $plugin = $this->plugin->getObject(NewsLetter::TYPE_PLUGIN); $plugin->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleDeleteGet(); } }
private function handleTreeDeletePost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('id')) { throw new Exception('Post ontbreekt.'); } $id = $request->getValue('id'); $key = array('id' => $id); $this->delete($key); viewManager::getInstance()->setType(Calendar::VIEW_COMMENT_OVERVIEW); $this->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleTreeDeleteGet(); } }
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); } }
/** * handle navigation for sub classes / pages */ public function handleAdminSubLinks($keyName, $title, $addBreadcrumb = false) { $request = Request::getInstance(); $view = ViewManager::getInstance(); $template = new TemplateEngine(); if (!$request->exists('nl_id')) { return; } $nl_id = $request->getValue('nl_id'); $newsLetterName = $this->getName(array('id' => $nl_id)); $template->setVariable('pageTitle', $newsLetterName, false); $tree_id = $request->getValue('tree_id'); $tag = $request->getValue('tag'); $template->setVariable('tree_id', $tree_id, false); $template->setVariable('tag', $tag, false); $template->setVariable('nl_id', $nl_id, false); if (!$addBreadcrumb) { return; } $url = new Url(true); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); $url->setParameter('id', $nl_id); $url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT); $breadcrumb = array('name' => $newsLetterName, 'path' => $url->getUrl(true)); $this->addBreadcrumb($breadcrumb); }
private function handleImportPost() { $request = Request::getInstance(); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $tree_id = intval($request->getValue('tree_id')); $nl_id = intval($request->getValue('nl_id')); $tag = $request->getValue('tag'); $this->handleTreeSettings($template); try { $debug = $this->import($tree_id, $tag, $nl_id, false); $template->setVariable('debug', $debug, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleImportGet(); } }
/** * handle conf edit */ private function handleConfEditGet($retrieveFields = true) { viewManager::getInstance()->setType(ViewManager::CONF_EDIT); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setVariable('pageTitle', $this->description, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
private function handleMovePost() { $request = Request::getInstance(); try { $key = $this->getKey(); if (!$request->exists('newtag')) { throw new Exception("Destination tag cannot be empty"); } $sqlParser = clone $this->sqlParser; $sqlParser->parseCriteria($key, false); $this->parseCriteria($sqlParser, $key); $sqlParser->setFieldValue('nl_tag', $request->getValue('newtag')); $query = $sqlParser->getSql(SqlParser::MOD_UPDATE_FIELDS); $db = $this->getDb(); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } viewManager::getInstance()->setType(NewsLetter::VIEW_PLUGIN_OVERVIEW); $this->handleOverview(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleMoveGet(); } }
private function handleAdminOverviewPost() { $request = Request::getInstance(); $values = array_merge($request->getRequest(Request::POST), $request->getRequest(Request::FILES)); try { $this->install($values); viewManager::getInstance()->setType(self::VIEW_SUCCESS); $this->handleAdminOverviewGet(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleAdminOverviewGet(); } }
private function renderSiteGroup() { $template = new TemplateEngine($this->getPath() . "templates/sitegroup.tpl"); $siteGroup = $this->getSiteGroup(); $id = $siteGroup->getCurrentId(); $url = new Url(); $url->useCurrent(false); $grouplist = $siteGroup->getList(); //if($grouplist['totalItems'] < 2) return; foreach ($grouplist['data'] as &$item) { $url->setParameter(SystemSiteGroup::CURRENT_ID_KEY, $item['id']); $item['href_detail'] = $url->getUrl(true); $item['selected'] = $item['id'] == $id; } $template->setVariable('sitegroup', $grouplist, false); // add link to sitegroup to add / modify / delete websites $admin = $this->director->adminManager; $admintree = $admin->tree; $sitegroupPath = $admintree->getPath($admintree->getIdFromClassname('SiteGroup')); $template->setVariable('href_sitegroup', $sitegroupPath, false); return $template; }
private function handleImportPost() { $request = Request::getInstance(); $values = array_merge($request->getRequest(Request::POST), $request->getRequest(Request::FILES)); $grp_used = $request->getValue('grp_used'); if (!$grp_used) { $grp_used = array(); } try { require_once DIF_ROOT . "utils/CsvFile.php"; // check if import file is uploaded if (!array_key_exists('import_file', $values) && !is_array($values['import_file'])) { throw new Exception('No import file set'); } // validate file is really a uploaded file $file = $values['import_file']; if (!array_key_exists('tmp_name', $file) || !is_uploaded_file($file['tmp_name'])) { throw new Exception('wrong file.'); } $csvFile = new CsvFile(); $records = $csvFile->import($file['tmp_name']); // check fields $fields = array_intersect($csvFile->getFields(), $this->exportColumns); if (!$fields || !in_array('username', $fields)) { throw new Exception("Username is not present in import file"); } $db = $this->getDb(); // create temporary table $query = "create temporary table userimport like " . $this->sqlParser->getTable(); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } // filter and insert records $fieldNames = array_intersect($this->sqlParser->getFieldNames(), $fields); ksort($fieldNames); $query = "insert into userimport(" . join(",", array_keys($fieldNames)) . ") values "; $recordFields = array(); foreach ($fieldNames as $name) { $recordFields[$name] = $name; } $rows = array(); foreach ($records as $record) { $record = array_intersect_key($record, $recordFields); if (!$record) { next; } ksort($record); if (array_key_exists('role', $record) && $record['role']) { $record['role'] = $this->getRoleId($record['role']); } foreach ($record as &$item) { //if(!$item) $item = "NULL"; $item = addslashes($item); } $rows[] = "('" . join("','", $record) . "')"; } $query .= join(",", $rows); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } // update records $update = array(); $insert = array(); foreach ($fieldNames as $key => $value) { $insert[] = "a.{$key}"; // skip username and password if ($key == 'username' || $key == 'password') { continue; } $update[] = "a.{$key} = b.{$key}"; } $tablename = $this->sqlParser->getTable(); $query = sprintf("update %s as a inner join userimport as b on a.usr_username = b.usr_username set %s", $tablename, join(",", $update)); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } // insert records $query = sprintf("insert into %s (%s,usr_create) select %s, now() from userimport as a left join %s as b on a.usr_username = b.usr_username where b.usr_id is NULL", $tablename, join(",", array_keys($fieldNames)), join(",", $insert), $tablename); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } // update group foreach ($grp_used as $grp_id) { $query = sprintf("insert into usergroup (usr_id, grp_id) \n\t\t\t\t\t\t\t\t\t\t\t\t\tselect a.usr_id, %d \n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom %s as a \n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join userimport as b \n\t\t\t\t\t\t\t\t\t\t\t\t\ton a.usr_username = b.usr_username \n\t\t\t\t\t\t\t\t\t\t\t\t\tleft join usergroup as c \n\t\t\t\t\t\t\t\t\t\t\t\t\ton a.usr_id = c.usr_id and c.grp_id = %d \n\t\t\t\t\t\t\t\t\t\t\t\t\twhere c.usr_id is NULL", $grp_id, $this->sqlParser->getTable(), $grp_id); $res = $db->query($query); if ($db->isError($res)) { throw new Exception($res->getDebugInfo()); } } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->handleAdminOverview(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleImportGet(); } }
private function handleAdminDeletePost() { $request = Request::getInstance(); try { if (!$request->exists('id')) { throw new Exception('Gebruikersgroep ontbreekt.'); } $id = intval($request->getValue('id')); $this->delete(array('id' => $id)); viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->handleAdminOverview(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleAdminDeleteGet(); } }
public function fetch() { $includeFile = is_file($this->getSource()); $template = new TemplateEngine($this->getSource(), $includeFile); $template->setVariable($this->vars, null, false); return $template->fetch(); }
private function handleLoginGet($referer = '') { $request = Request::getInstance(); if (!$referer) { $tree = $this->director->tree; //$referer = $tree->getPath($tree->getFirstNodeId()); $referer = $request->getUrl(); } // clear login state $autentication = Authentication::getInstance(); if ($autentication->isLogin()) { $autentication->logout(); header("Location: /" . $request->getRoot()); exit; } $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setVariable('referer', $referer, false); $template->setVariable('pageTitle', 'Login', false); $template->setVariable('dbExists', $this->director->dbExists, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
private function handleTreeEditPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); if ($this->exists($key)) { $this->update($key, $values); } else { $this->insert($values); } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->referer->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleTreeEditGet(false); } }
/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // retrieve tags that are linked to this plugin $taglist = $this->plugin->getTagList(array('plugin_type' => Reservation::TYPE_LIST)); if (!$taglist) { return; } foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $template->setCacheable(false); $template->setVariable($tag, null, false); $this->template[$tag['tag']] = $template; } $this->director->theme->addJavascript('Event.observe( window, "load", function() { getReservationList();} );'); }
private function handleConfPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if ($this->exists(array())) { $this->update($this->getKey($values), $values); } else { $this->insert($values); } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->referer->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleConfGet(false); } }
/** * handle Move request */ private function handleMove() { $request = Request::getInstance(); $view = ViewManager::getInstance(); if (!$request->exists('id')) { throw new Exception(__FUNCTION__ . ' Element is missing.'); } $form_id = intval($request->getValue('id')); // check if node exists if (!$this->exists($form_id)) { throw new HttpException('404'); } $key = array('id' => $form_id); try { switch ($view->getType()) { case Form::VIEW_MV_PREC: $this->movetoPreceding($key); break; case Form::VIEW_MV_FOL: $this->movetoFollowing($key); break; } } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); } viewManager::getInstance()->setType(Form::VIEW_ELEMENT_OVERVIEW); $this->handleTreeOverviewGet(); }
private function handleTreeEditPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); if ($this->exists($key)) { $this->update($key, $values); } else { $this->insert($values); } $treeRef = new NewsTreeRef(); $treeRef->delete($key); foreach ($values['ref_tree_id'] as $ref_tree_id) { $key['ref_tree_id'] = $ref_tree_id; $treeRef->insert($key); } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->plugin->getReferer()->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); // reset date values $online = $this->sqlParser->getFieldByName('online'); $this->sqlParser->setFieldValue('online', strftime('%Y-%m-%d', strtotime($online->getValue()))); $offline = $this->sqlParser->getFieldByName('offline'); $this->sqlParser->setFieldValue('offline', strftime('%Y-%m-%d', strtotime($offline->getValue()))); $this->handleTreeEditGet(false); } }
/** * handle attachment request */ private function handleSubNavigation() { $request = Request::getInstance(); $view = ViewManager::getInstance(); $template = new TemplateEngine(); if (!$request->exists('id')) { return; } $id = $request->getValue('id'); $template->setVariable('pageTitle', $this->getName(array('id' => $id)), false); $tree_id = $request->getValue('tree_id'); $tag = $request->getValue('tag'); $template->setVariable('tree_id', $tree_id, false); $template->setVariable('tag', $tag, false); $template->setVariable('id', $id, false); }
private function handleDeletePost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('ip')) { throw new Exception('id is missing.'); } $ip = $request->getValue('ip'); $key = array('ip' => $ip); $this->delete($key); viewManager::getInstance()->setType(self::VIEW_OVERVIEW); $this->handleOverview(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleDeleteGet(); } }
/** * handle admin overview request */ private function handleAdminOverview() { $view = ViewManager::getInstance(); $log = Logger::getInstance(); $logfile = $log->getLogFile(); if ($view->isType(self::VIEW_FILE)) { $request = Request::getInstance(); $extension = ".log"; $filename = $request->getDomain() . $extension; header("Content-type: application/{$extension}"); header("Content-Length: " . filesize($logfile)); // stupid bastards of microsnob: ie does not like attachment option $browser = $request->getValue('HTTP_USER_AGENT', Request::SERVER); if (strstr($browser, 'MSIE')) { header("Content-Disposition: filename=\"{$filename}\""); } else { header("Content-Disposition: attachment; filename=\"{$filename}\""); } readfile($logfile); exit; } else { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setVariable('logfile', nl2br(file_get_contents($logfile)), false); $url = new Url(true); $url->setParameter($view->getUrlId(), self::VIEW_FILE); $template->setVariable('href_export', $url->getUrl(true), false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; } }
private function handleConfigPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { $key = $this->getKey(); if ($this->exists($key)) { $this->update($key, $values); } else { $this->insert($values); } viewManager::getInstance()->setType(ViewManager::TREE_OVERVIEW); $this->plugin->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleConfigGet(false); } }
/** * Returns protected var $oberserver. * @param string observer key * @return array */ public function getUserList($search) { try { if (!array_key_exists('tree_id', $search)) { throw new Exception('Tree node not set'); } if (!array_key_exists('tag', $search)) { throw new Exception('Template tag not set'); } if (!array_key_exists('date', $search)) { throw new Exception('Date not set'); } if (!array_key_exists('hour', $search)) { throw new Exception('Hour not set'); } $maxpage = 10; $page = array_key_exists('page', $search) ? intval($search['page']) : 0; $hour = $search['hour']; $date = $search['date'] ? $search['date'] : date('Y-m-d'); $authentication = Authentication::getInstance(); $user = $authentication->getUserId(); $usr_id = $user['id']; $canEdit = $authentication->canEdit($search['tree_id']); $canView = $authentication->canView($search['tree_id']); if (!$canEdit && !$canView) { throw new Exception('Access denied'); } $subObj = $this->getObject(self::TYPE_DEFAULT); $settingObj = $this->getObject(self::TYPE_SETTINGS); $settings = $settingObj->getSettings($search['tree_id'], $search['tag']); // get linked users $userLink = new ReservationUserLink(); $list = $userLink->getList(array('own_id' => $usr_id)); $userList = array($usr_id); foreach ($list['data'] as $item) { $userList[] = $item['usr_id']; } $vipCount = $subObj->getVipCount($search); $legitimateUserList = $canEdit ? array() : $subObj->getLegitimateUserList($userList, $settings['max_subscribe']); // check if there are any users that are allowed to make a reservation if (!$legitimateUserList && !$canEdit) { throw new Exception("Reservation count exceeded."); } // user is super user, let him be able to make reservations for his self //if(!$legitimateUserList) $legitimateUserList = array($usr_id); // COMMENTED OUT BECAUSE SUPER USER CAN MAKE RESERVATIONS FOR ALL MEMBERS $userSearch = array('id' => $legitimateUserList); //if($vipCount >= $settings['vip_slots']) $userSearch['no_grp_id'] = $settings['vip_grp_id']; // vip_grp_id is not used anymore // add search string for user if (array_key_exists('user', $search) && $search['user']) { $userSearch['search'] = $search['user']; } $userObj = $this->director->systemUser; // backup pager url $tmppagerUrl = $userObj->getPagerUrl(); $tmppagerKey = $userObj->getPagerKey(); $url = new JsUrl(); $url->setPath('javascript:userSearch'); $url->setParameter('date', "'{$date}'"); $url->setParameter('hour', $hour); $url->setParameter('user', "'{$search['user']}'"); $userObj->setPagerUrl($url); $users = $userObj->getList($userSearch, $maxpage, $page); // restore pager url $userObj->setPagerUrl($tmppagerUrl); $userObj->setPagerKey($tmppagerKey); $template = new TemplateEngine($this->getPath() . "templates/reservationuserselect.tpl"); $template->setVariable('users', $users); $template->setVariable('date', $date); $template->setVariable('hour', $hour); $template->setVariable('htdocs_path', $this->getHtdocsPath(false)); $template->setVariable('include_vip', $vipCount < $settings['vip_slots']); $template->setVariable('usersearch', array_key_exists('user', $search) ? $search['user'] : ''); return $template->fetch(); } catch (Exception $e) { return $e->getMessage(); } }
/** * handle optin confirm */ private function handleOptin() { $taglist = $this->getTagList(); if (!$taglist) { return; } $request = Request::getInstance(); $view = ViewManager::getInstance(); $objUser = $this->getObject(self::TYPE_USER); $objSettings = $this->getObject(self::TYPE_SETTINGS); try { if (!$request->exists('key')) { throw new Exception('Parameter does not exist.'); } $keyValue = $request->getValue('key'); if (!$keyValue) { throw new Exception('Parameter is empty.'); } $key = array('optin' => $keyValue); $objUser->enable($key); // retrieve settings to get redirect location $searchcriteria = array(); foreach ($taglist as $item) { $searchcriteria = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']); } $settings = $objSettings->getSettings($searchcriteria['tree_id'], $searchcriteria['tag']); $location = $settings['optin_tree_id'] ? $this->director->tree->getPath($settings['optin_tree_id']) : '/'; header("Location: {$location}"); exit; } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('newsLetterErrorMessage', $e->getMessage(), false); $this->log->info($e->getMessage()); $view->setType(ViewManager::OVERVIEW); $this->handleHttpGetRequest(); } }
/** * send email */ private function sendMail($mailto, $mailfrom, $subject, $settings, $link) { $recepients = explode(",", $mailto); $template_content = new TemplateEngine($settings['content'], false); $template_content->setVariable($settings); $template_content->setVariable('password_url', $link); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateEmail); $template->setVariable('tpl_content', $template_content); $template->setVariable('settings', $settings); $request = Request::getInstance(); $ip = $request->getValue('REMOTE_ADDR', Request::SERVER); $template->setVariable('ip', $ip); $template->setVariable('host', gethostbyaddr($ip)); $template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER)); $mail = new PHPMailer(); $mail->From = $mailfrom; $mail->FromName = $mailfrom; foreach ($recepients as $email) { $mail->AddAddress(trim($email)); } $mail->WordWrap = 80; $mail->Subject = $subject; $mail->Body = $template->fetch(); if (!$mail->Send()) { throw new Exception("Error sending message: " . $mail->ErrorInfo); } if (!$this->log->isInfoEnabled()) { return; } $this->log->info("login info sent to {$mailto}"); }
private function handleExtensionForm($theme) { $request = Request::getInstance(); try { if (!$request->exists('ext_id')) { throw new Exception('Extension ontbreekt.'); } $id = intval($request->getValue('ext_id')); $extension = $this->director->extensionManager->getExtensionFromId(array('id' => $id)); $extension->renderForm($theme); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); } }
private function handlePluginList($tag, $parameters) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $searchcriteria = isset($parameters) && array_key_exists('searchcriteria', $parameters) ? $parameters['searchcriteria'] : array(); $keys = isset($parameters) && array_key_exists('keys', $parameters) ? $parameters['keys'] : array(); $searchcriteria['id'] = $keys; $settings = $this->plugin->getSettings(); $template->setVariable('settings', $settings); $systemSite = new SystemSite(); $tree = $systemSite->getTree(); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { //TODO get url from caller plugin (newsletter) to track visits $url = new Url(); $url->setPath($request->getProtocol() . $request->getDomain() . $tree->getPath($item['tree_id'])); $url->setParameter('id', $item['id']); $url->setParameter(ViewManager::URL_KEY_DEFAULT, Calendar::VIEW_DETAIL); $item['href_detail'] = $url->getUrl(true); if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('calendar', $list); $this->template[$tag] = $template; }
private function handleConfigPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('id')) { throw new Exception('Thema ontbreekt.'); } $id = intval($request->getValue('id')); $key = array('id' => $id); $theme = $this->director->themeManager->getThemeFromId($key); $fileTpl = $theme->getTemplateFile(); $fileIni = $theme->getConfigFile(); $fileCss = $theme->getStyleSheetFile(); $tpl_content = $request->getValue('file_tpl'); $ini_content = $request->getValue('file_ini'); $css_content = $request->getValue('file_css'); if (!$tpl_content) { throw new Exception("Template file is empty."); } if (!$ini_content) { throw new Exception("Configuration file is empty."); } if (!$css_content) { throw new Exception("Stylesheet file is empty."); } if (!($hTpl = fopen($fileTpl, "w"))) { throw new Exception("Error opening {$fileTpl} for writing."); } if (!($hIni = fopen($fileIni, "w"))) { throw new Exception("Error opening {$fileIni} for writing."); } if (!($hCss = fopen($fileCss, "w"))) { throw new Exception("Error opening {$fileCss} for writing."); } fputs($hTpl, $tpl_content); fputs($hIni, $ini_content); fputs($hCss, $css_content); fclose($hTpl); fclose($hIni); fclose($hCss); // clear cache $cache = Cache::getInstance(); $cache->clear(); viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->handleAdminOverview(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleConfigGet(false); } }
private function handleRecordDeleteAllPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $record = $this->plugin->getObject(Form::TYPE_RECORD); $recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM); $record->delete($key); $recordItem->delete($key); viewManager::getInstance()->setType(ViewManager::TREE_OVERVIEW); $this->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleRecordDeleteAllGet(); } }