Example #1
0
 public function onRender()
 {
     // get page
     $page = $this->getPage();
     // get tags assigned to this page
     $tags = $page->tags->getAssigned();
     $dynamicContent = array();
     // loop through tags
     for ($i = 0; $i < count($tags); $i++) {
         // get all content blocks which got a tag assigned
         $cbs = sCblockMgr()->tags->getByTag($tags[$i]['ID']);
         for ($j = 0; $j < count($cbs); $j++) {
             // instance content block object
             $cb = sCblockMgr()->getCblock($cbs[$j]['OBJECTID']);
             if ($cb) {
                 // get additional information like name and push it to the $dynamicContent
                 $info = $cb->get();
                 $cbs[$j] = array_merge($cbs[$j], $info);
                 /* optionally get the full content of each content block
                                            gets slow if performed for a large number of content blocks 
                 
                                            $cbs[$j]["CONTENT"] = $cb->getContent();*/
                 array_push($dynamicContent, $cbs[$j]);
             }
         }
     }
     // assign array
     sSmarty()->assign("dynamicContent", $dynamicContent);
 }
Example #2
0
 public function onRender($args = NULL)
 {
     $page = $this->getPage();
     $pageinfo = $page->get();
     $action = sApp()->request->parameters['ACTION'];
     // check if commenting user is authenticated
     $anonymousUserID = sUserMgr()->getAnonymousID();
     if ((int) sUserMgr()->getCurrentUserID() == $anonymousUserID) {
         $isLoggedIn = false;
     } else {
         $isLoggedIn = true;
     }
     // get comment infos
     $commentError = NULL;
     $commentObject = $page->comments;
     $commentSettings = $commentObject->getSettings();
     $commentStatus = $commentObject->getStatus($pageinfo['ID']);
     $commentPermission = $page->permissions->check(sUserMgr()->getCurrentUserID(), 'RCOMMENT', $pageinfo['ID']);
     // add comment
     if ($action == 'ADD') {
         $commentUser = sApp()->request->parameters['USER'];
         $commentEmail = sApp()->request->parameters['EMAIL'];
         $commentText = sApp()->request->parameters['TEXT'];
         $result = $commentObject->add($commentText, $pageinfo['ID'], $commentUser, $commentEmail);
         if ($result !== ERROR_NONE) {
             switch ($result) {
                 case ERROR_COMMENTS_MINIMUM_POST_INTERVAL_EXCEEDED:
                     $commentError = 'Minimum post interval was exceeded.';
                     break;
                 case ERROR_COMMENTS_BLACKLISTED_WORD:
                     $commentError = 'You have used a blacklisted word.';
                     break;
                 case ERROR_COMMENTS_AUTHENTICATION_NEEDED:
                     $commentError = 'Authentication is needed.';
                     break;
                 case ERROR_COMMENTS_COMMENTING_IS_CLOSED:
                     $commentError = 'Commenting is closed.';
                     break;
                 case ERROR_COMMENTS_NO_COMMENT_RIGHTS:
                     $commentError = 'No permissions to comment.';
                     break;
                 default:
                     $commentError = 'An unknown error has occured.';
                     break;
             }
         }
     }
     // get comments - has to be after add functionaly in order for new comments to show up
     $commentCount = $commentObject->getCommentsCount();
     $comments = $commentObject->getComments($pageinfo['ID'], NULL);
     sSmarty()->assign("isLoggedIn", $isLoggedIn);
     sSmarty()->assign("commentError", $commentError);
     sSmarty()->assign("commentCount", $commentCount);
     sSmarty()->assign("commentPermission", $commentPermission);
     sSmarty()->assign("commentSettings", $commentSettings);
     sSmarty()->assign("commentStatus", $commentStatus);
     sSmarty()->assign("comments", $comments);
 }
Example #3
0
 public function sendEmail($emailData)
 {
     $mail = new PHPMailer();
     if ((bool) sConfig()->getVar('CONFIG/MAILINGS/DISABLE')) {
         return true;
     }
     // Obtain userdata
     $user = new User($emailData['USER_ID']);
     $userInfo = $user->get();
     $userInfo['PROPERTIES'] = $user->properties->getValues($emailData['USER_ID']);
     // Obtain mailingdata
     $mailingMgr = new MailingMgr();
     $mailing = $mailingMgr->getMailing($emailData['MAILING_ID']);
     if ($emailData['IS_TEST']) {
         $mailingInfo = $mailing->get();
         $mailingVersion = $mailingInfo['VERSION'];
     } else {
         $mailingVersion = $mailing->getLatestApprovedVersion();
         $mailing = $mailingMgr->getMailing($emailData['MAILING_ID'], $mailingVersion);
         $mailingInfo = $mailing->get();
     }
     $templateMgr = new Templates();
     $userId = $userInfo['ID'];
     $userEmail = $userInfo['PROPERTIES']['EMAIL'];
     $userFirstName = $userInfo['PROPERTIES']['FIRSTNAME'];
     $userLastName = $userInfo['PROPERTIES']['LASTNAME'];
     $userName = trim($userFirstName . ' ' . $userLastName);
     $userCompany = $userInfo['PROPERTIES']['COMPANY'];
     $userDepartment = $userInfo['PROPERTIES']['COMPANY'];
     $templateInfo = $templateMgr->getTemplate($mailingInfo['TEMPLATEID']);
     $userInfo['PROPERTIES']['FULLNAME'] = trim($userFirstName . ' ' . $userLastName);
     sSmarty()->clear_assign('recipient');
     sSmarty()->assign('recipient', $userInfo);
     sSmarty()->clear_assign('user');
     sSmarty()->assign('user', $userInfo['PROPERTIES']);
     sApp()->output = '';
     $emailData['FROM'] = $mailingInfo['FROM_EMAIL'];
     $emailData['FROM_NAME'] = $mailingInfo['FROM_NAME'];
     $emailData['FROM_REPLYTO'] = $mailingInfo['FROM_REPLYTO'];
     $emailData['FROM_SENDER'] = $mailingInfo['FROM_SENDER'];
     $emailData['ENCODING'] = $mailingInfo['ENCODING'];
     if ($emailData['ENCODING'] == '') {
         $emailData['ENCODING'] = 'base64';
     }
     $emailData['SUBJECT'] = $this->replaceUserdataVars($mailingInfo['SUBJECT'], $emailData['USER_ID']);
     $emailData['BODY_TEXT'] = $this->replaceUserdataVars($mailingInfo['FALLBACK_TEXT'], $emailData['USER_ID']);
     // Set special smarty delimiters
     sSmarty()->left_delimiter = '[!';
     sSmarty()->right_delimiter = '!]';
     // Parse subject with smarty
     $emailData['SUBJECT'] = sSmarty()->fetch('var:' . $emailData['SUBJECT']);
     //$emailData['BODY_TEXT'] = sSmarty()->fetch('var:'.$emailData['BODY_TEXT']);
     // Reset smarty delimiters
     sSmarty()->left_delimiter = '{';
     sSmarty()->right_delimiter = '}';
     $mailingId = $emailData['MAILING_ID'];
     include getrealpath(dirname(__FILE__) . '/../../output/mailing.php');
     if ($templateInfo['FILENAME']) {
         $emailhtml = sApp()->output;
         $emailhtml = str_replace("\"/neptun/neptun.php", "\"" . $this->request->prefix . "://" . $this->request->http_host . $this->request->script_name, $emailhtml);
         $emailhtml = $this->replaceUserdataVars($emailhtml, $emailData['USER_ID']);
         $emailData['BODY_HTML'] = $emailhtml;
     } else {
         $emailData['BODY_HTML'] = NULL;
     }
     sApp()->output = '';
     $smtpServer = (string) sConfig()->getVar('CONFIG/MAILINGS/SMTP');
     if ($smtpServer) {
         $mail->IsSMTP();
         $mail->Host = $smtpServer;
     }
     if ($emailData['ENCODING']) {
         $mail->Encoding = $emailData['ENCODING'];
     }
     if ($emailData['CHARSET']) {
         $mail->CharSet = $emailData['CHARSET'];
     }
     if ($emailData['FROM']) {
         $mail->From = $emailData['FROM'];
     }
     if ($emailData['FROM_NAME']) {
         $mail->FromName = $emailData['FROM_NAME'];
     }
     if ($emailData['FROM_REPLYTO']) {
         $mail->AddReplyTo($emailData['FROM_REPLYTO']);
     }
     if ($emailData['FROM_SENDER']) {
         $mail->Sender = $emailData['FROM_SENDER'];
     }
     if ($emailData['SUBJECT']) {
         $mail->Subject = $emailData['SUBJECT'];
     }
     if ($emailData['BODY_HTML']) {
         $mail->Body = $emailData['BODY_HTML'];
         $mail->IsHTML(true);
     }
     if ($emailData['BODY_TEXT'] && !$emailData['BODY_HTML']) {
         $mail->Body = $emailData['BODY_TEXT'];
         $mail->IsHTML(false);
     }
     if ($emailData['BODY_TEXT'] && $emailData['BODY_HTML']) {
         $mail->AltBody = $emailData['BODY_TEXT'];
     }
     $forcedRecipient = (string) sConfig()->getVar('CONFIG/MAILINGS/FORCE_RECIPIENT');
     foreach ($emailData['TO'] as $emailToItem) {
         if ($forcedRecipient) {
             $mail->AddAddress($forcedRecipient, $emailToItem['EMAIL_NAME']);
         } else {
             $mail->AddAddress($emailToItem['EMAIL'], $emailToItem['EMAIL_NAME']);
         }
     }
     foreach ($emailData['CC'] as $emailCcItem) {
         $mail->AddCC($emailCcItem['EMAIL'], $emailCcItem['EMAIL_NAME']);
     }
     foreach ($emailData['BCC'] as $emailBccItem) {
         $mail->AddBCC($emailBccItem['EMAIL'], $emailBccItem['EMAIL_NAME']);
     }
     foreach ($emailData['ATTACHMENTS'] as $emailAttachmentItem) {
         $mail->AddAttachment($emailAttachmentItem['PATH'], $emailAttachmentItem['NAME']);
     }
     $result = $mail->Send();
     $mail->ClearAddresses();
     $mailingData = array('USERINFO' => $userInfo, 'DATA' => $emailData);
     $mailingMgr->callExtensionHook('onSend', $mailingId, $mailingVersion, $mailingData);
     return $result;
 }
Example #4
0
$mailing = $mailingMgr->getMailing($mailingId, $mailingVersion);
// Mailing Properties
$mailingInfo = $mailing->get();
$mailingProperties = $mailing->properties->get();
$mailingInfo = array_merge($mailingProperties, $mailingInfo);
// Template
$templateMgr = new Templates();
$templateInfo = $templateMgr->getTemplate($mailingInfo['TEMPLATEID']);
$templatefilename = $templateInfo['FILENAME'];
$templatefullpath = $templateMgr->getDir() . $templateInfo['PATH'] . $templatefilename;
// Content
$content = $mailing->getContent();
$mailingcnt = array('USERINFO' => $userInfo, 'FILTER' => $filter, 'CONTENTAREAS' => &$content);
$mailingMgr->callExtensionHook('onRender', $mailingId, $mailingVersion, $mailingcnt);
sSmarty()->assign('pageinfo', $mailingInfo);
sSmarty()->assign('contentareas', $content);
if (!$output_tmp) {
    $output_tmp = sSmarty()->fetch('file:' . $templatefullpath);
}
// 2nd pass
sSmarty()->left_delimiter = '[!';
sSmarty()->right_delimiter = '!]';
sApp()->output = sSmarty()->fetch('var:' . $output_tmp);
// 3rd pass (replace special urls with normal urls)
sApp()->output = replaceSpecialURLs(sApp()->output, true);
// Replace relative URLs with aboslute URLs
sApp()->output = $mailing->absolutizeURLs(sApp()->output);
// Output everthing if we are in preview mode
if ($previewMode) {
    echo sApp()->output;
}
Example #5
0
 public function onRender($args = NULL)
 {
     $action = sApp()->request->parameters["action"];
     sSmarty()->assign("action", $action);
     /* LOGIN */
     if ($action == "login") {
         $email = sApp()->request->parameters['email'];
         $password = sApp()->request->parameters['password'];
         $yg_login_referrer = sApp()->request->parameters["yg_login_referrer"];
         sUserMgr()->impersonate(sUserMgr()->getAdministratorID());
         $extproperties = $this->extensionProperties->get();
         if ($yg_login_referrer == '') {
             $yg_login_referrer = $extproperties['STANDARD_REFERRER']['URL'];
         }
         sSmarty()->assign("yg_login_referrer", $yg_login_referrer);
         $userid = sUserMgr()->validate($email, $password);
         sUserMgr()->unimpersonate();
         if ($userid === false) {
             sSmarty()->assign("yg_login_error_code", "1");
             sSmarty()->assign('action', $action);
             sSmarty()->assign("email", $email);
         } else {
             sApp()->session->setPSessionVar("username", $email);
             sApp()->session->setPSessionVar("password", $password);
             sApp()->session->refrehSessionCookie();
             sApp()->session->setPSessionVar("isvalidated", true);
             sApp()->session->setPSessionVar("keepLoggedIn", true);
             sApp()->session->cookie_time = time() + 60 * 60 * 24 * 365;
             http_redirect($yg_login_referrer);
         }
     }
     /* LOGOUT */
     if ($action == $this->extensionProperties->getValue('LOGOUT_ACTION')) {
         $extproperties = $this->extensionProperties->get();
         $logout_referrer = $extproperties['STANDARD_LOGOUT_REFERRER']['URL'];
         sApp()->session->setPSessionVar('username', '');
         sApp()->session->setPSessionVar('password', '');
         sApp()->session->setPSessionVar('isvalidated', false);
         sApp()->session->setPSessionVar('keepLoggedIn', false);
         http_redirect($logout_referrer);
     }
     /* PASSWORD RECOVERY */
     if ($action == "pwd_step1") {
         sUserMgr()->impersonate(sUserMgr()->getAdministratorID());
         $email = sApp()->request->parameters["user_email"];
         $user_info = sUserMgr()->getByLogin($email);
         if ($user_info) {
             $user = sUserMgr()->getUser($user_info['ID']);
             sUserMgr()->unimpersonate();
             $expireTS = time() + 60 * 60 * 24;
             $token = $user->generateToken($expireTS);
             $page = $this->getPage();
             $pageUrl = $page->getUrl();
             // Generate path for recovery URL
             $passwordResetUrl = sApp()->request->prefix . '://' . sApp()->request->http_host;
             $passwordResetUrl .= $pageUrl . '?action=pwd_step2&user_token=' . urlencode($token);
             echo $passwordResetUrl;
             \framework\import("org.phpmailer.phpmailer");
             $mail = new \PHPMailer();
             $mail->Encoding = '8bit';
             $mail->CharSet = 'utf-8';
             $mail->From = $this->extensionProperties->getValue("FROM_EMAIL");
             $mail->FromName = $this->extensionProperties->getValue("FROM_NAME");
             $mail->Subject = $this->extensionProperties->getValue("SUBJECT");
             $mail->Body = $this->extensionProperties->getValue("BODY_PT1");
             $mail->Body .= "\n" . $passwordResetUrl . "\n";
             $mail->Body .= $this->extensionProperties->getValue("BODY_PT2");
             $mail->AddAddress($email);
             $smtpServer = (string) sapp()->config->getVar('CONFIG/MAILINGS/SMTP');
             if ($smtpServer) {
                 $mail->IsSMTP();
                 $mail->Host = $smtpServer;
             }
             $mail->Send();
             $mail->ClearAddresses();
             sSmarty()->assign('recovery_mail_sent', true);
         } else {
             if (strlen(trim($email)) > 0) {
                 sSmarty()->assign('error_step1', true);
             }
         }
     }
     if ($action == "pwd_step2") {
         $error_step2 = false;
         $form_send = sApp()->request->parameters['form_send'];
         sSmarty()->assign('form_send', $form_send);
         $token = sApp()->request->parameters['user_token'];
         sSmarty()->assign('user_token', $token);
         $valid_token = \sUserMgr()->getUserIdByToken($token);
         if (!$valid_token) {
             $error_step2 = true;
             $error_token = true;
             sSmarty()->assign('error_step2', $error_step2);
             sSmarty()->assign('error_token', $error_token);
         }
         if ($form_send == true) {
             $user_password = sapp()->request->parameters['user_password'];
             $user_password_repeat = sapp()->request->parameters['user_password_repeat'];
             $user_id = sUserMgr()->getUserIdByToken($token);
             sUserMgr()->impersonate(sUserMgr()->getAdministratorID());
             $user = sUserMgr()->getUser($user_id);
             sUserMgr()->unimpersonate();
             $user_info = $user->get();
             if ($user_info) {
                 // Check if password is repeated correctly
                 if ($user_password != $user_password_repeat) {
                     $error_repeat = true;
                     sSmarty()->assign('error_repeat', $error_repeat);
                     $error_step2 = true;
                 }
                 // Check if password is secure enough
                 $password_ok = sUserMgr()->verifyPasswordStrength($user_password);
                 if (!$password_ok) {
                     $error_chars = true;
                     sSmarty()->assign('error_chars', $error_chars);
                     $error_step2 = true;
                 }
                 if (!$error_step2) {
                     sUserMgr()->impersonate(sUserMgr()->getAdministratorID());
                     $user = sUserMgr()->getUser($user_info['ID']);
                     $user->setPassword($user_password);
                     $user->removeToken();
                     sUserMgr()->unimpersonate();
                 } else {
                     sSmarty()->assign('error_step2', $error_step2);
                 }
             } else {
                 $error_step2 = true;
                 sSmarty()->assign('error_step2', $error_step2);
             }
         }
     }
     return true;
 }
Example #6
0
function calcPageDir($dataCount, $defaultSortCol, $defaultSortOrder = 'ASC')
{
    $pageDirPage = (int) sRequest()->parameters['pagedir_page'];
    $pageDirPerPage = sRequest()->parameters['pagedir_perpage'];
    $pageDirOrderBy = sRequest()->parameters['pagedir_orderby'];
    $pageDirOrderDir = (int) sRequest()->parameters['pagedir_orderdir'];
    $pageDirFrom = (int) sRequest()->parameters['pagedir_from'];
    if (!$pageDirFrom) {
        $pageDirFrom = 1;
    }
    if ($pageDirPerPage == 'ALL') {
        $pageDirPerPage = -1;
    } else {
        if (!$pageDirPerPage) {
            $pageDirPerPage = (int) sConfig()->getVar('CONFIG/PAGEDIR/DEFAULT_PER_PAGE');
        } else {
            $pageDirPerPage = (int) $pageDirPerPage;
        }
    }
    $pageDirMaxPages = 1;
    if (!$pageDirPage) {
        $pageDirPage = 1;
    }
    if ($pageDirPerPage > 0) {
        $pageDirMaxPages = ceil($dataCount / $pageDirPerPage);
    }
    if ($pageDirMaxPages < 1) {
        $pageDirMaxPages = 1;
    }
    if ($pageDirPage > $pageDirMaxPages) {
        $pageDirPage = $pageDirMaxPages;
        $pageDirFrom = $pageDirPage * $pageDirPerPage - ($pageDirPerPage - 1);
    }
    if (!$pageDirOrderBy) {
        $pageDirOrderBy = $defaultSortCol;
    }
    if (!$pageDirOrderDir) {
        $pageDirOrderDir = $defaultSortOrder;
    } else {
        if ($pageDirOrderDir == 1) {
            $pageDirOrderDir = "ASC";
        } else {
            $pageDirOrderDir = "DESC";
        }
    }
    if ($pageDirPerPage > 0) {
        $pageDirLimit = $pageDirFrom - 1 . ',' . $pageDirPerPage;
    }
    sKoala()->queueScript('$K.yg_pageDirUpdate(\'' . sRequest()->parameters['win_no'] . '\', ' . $pageDirPage . ', ' . $pageDirPerPage . ', ' . $pageDirMaxPages . ', \'' . $pageDirOrderBy . '\', \'' . $pageDirOrderDir . '\', ' . $pageDirFrom . ', \'' . $pageDirLimit . '\');');
    if ($pageDirPerPage == -1) {
        $itext = sItext();
        $pageDirPerPage = $itext['TXT_PAGEDIR_SHOWALL_SHORT'] != '' ? $itext['TXT_PAGEDIR_SHOWALL_SHORT'] : '$TXT_PAGEDIR_SHOWALL_SHORT';
    }
    sSmarty()->assign('pageDirPage', $pageDirPage);
    sSmarty()->assign('pageDirPerPage', $pageDirPerPage);
    sSmarty()->assign('pageDirMaxPages', $pageDirMaxPages);
    return array('pageDirOrderBy' => $pageDirOrderBy, 'pageDirOrderDir' => $pageDirOrderDir, 'pageDirLimit' => $pageDirLimit, 'pageDirMaxPages' => $pageDirMaxPages);
}