function parseAnnouncment()
{
    global $_PATHS, $objLang;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("announcement.tpl.htm");
    $objTpl->setVariable("BUTTON_CLOSE", $objLang->get("close", "button"));
    $objMessages = AnnounceMessage::getMessages();
    foreach ($objMessages as $objMessage) {
        $objTpl->setVariable("HEADER", $objMessage->getHeader());
        $objTpl->setVariable("BODY", $objMessage->getMessage());
        break;
    }
    return $objTpl->get();
}
 public static function getMessages($blnCheck = true)
 {
     global $objLiveUser;
     self::$__object = "AnnounceMessage";
     $strReturn = "";
     $intId = 0;
     $strSql = "SELECT *\n\t\t\t\tFROM pcms_announce_message\n\t\t\t\tWHERE id NOT IN (SELECT messageId FROM pcms_announce_user WHERE permUserId = '{$objLiveUser->getProperty('perm_user_id')}')\n\t\t\t\tORDER BY sort";
     $objMessages = self::select($strSql);
     if ($blnCheck) {
         foreach ($objMessages as $objMessage) {
             $objMessage->check();
         }
     }
     return $objMessages;
 }
Beispiel #3
0
function parseScriptHeader($intCatId, $strCommand, $intElmntId)
{
    global $_PATHS, $objLang, $objLiveUser;
    $strScript = "";
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("formheader.tpl.htm");
    switch ($intCatId) {
        case NAV_MYPUNCH_LOGIN:
            //*** Don't use the FormObject. The login screen has it's own errorcheck.
            $strScript = "jQuery(function(){ jQuery('#handle').focus(); });";
            break;
        case NAV_PCMS_ELEMENTS:
            switch ($strCommand) {
                case CMD_LIST:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    break;
                case CMD_ADD:
                case CMD_EDIT:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    //*** Form fields.
                    $strScript .= "var objForm = new ValidForm('elementForm');\n";
                    $strScript .= "objForm.addElement('frm_active', LIBFRM_STRING);\n";
                    $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
                    $strScript .= "objForm.addElement('frm_apiname', LIBFRM_WORD);\n";
                    $strScript .= "objForm.addElement('frm_template', LIBFRM_INTEGER);\n";
                    //*** Element specific fields.
                    //*** TODO!!!
                    //*** Form errors.
                    $strScript .= "var objAlerts = new Object();\n";
                    $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_active'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("elementName", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_apiname'] = '" . $objLang->get("commonTypeWord", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_template'] = '" . $objLang->get("commonRequired", "formerror") . "';\n";
                    $strScript .= "objForm.alerts = objAlerts;\n";
                    //*** Element specific errors.
                    //*** TODO!!!
                    //*** Add form to the Forms object.
                    $strScript .= "objValidForms.addForm(objForm);\n";
                    break;
            }
            break;
        case NAV_PCMS_TEMPLATES:
            switch ($strCommand) {
                case CMD_LIST:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    break;
                case CMD_ADD:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    //*** Form fields.
                    $strScript .= "var objForm = new ValidForm('templateForm');\n";
                    $strScript .= "objForm.addElement('frm_ispage', LIBFRM_STRING);\n";
                    $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
                    $strScript .= "objForm.addElement('frm_apiname', LIBFRM_WORD);\n";
                    $strScript .= "objForm.addElement('frm_description', LIBFRM_TEXT);\n";
                    //*** Form errors.
                    $strScript .= "var objAlerts = new Object();\n";
                    $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_ispage'] = '" . $objLang->get("isPage", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("templateName", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_apiname'] = '" . $objLang->get("commonTypeWord", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_description'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
                    $strScript .= "objForm.alerts = objAlerts;\n";
                    //*** Add form to the Forms object.
                    $strScript .= "objValidForms.addForm(objForm);\n";
                    break;
                case CMD_ADD_FIELD:
                case CMD_EDIT_FIELD:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    //*** Form fields.
                    $strScript .= "var objForm = new ValidForm('templateFieldForm');\n";
                    $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
                    $strScript .= "objForm.addElement('frm_apiname', LIBFRM_WORD);\n";
                    $strScript .= "objForm.addElement('frm_description', LIBFRM_TEXT);\n";
                    $strScript .= "objForm.addElement('frm_field_type', LIBFRM_STRING, true);\n";
                    //*** Form errors.
                    $strScript .= "var objAlerts = new Object();\n";
                    $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("fieldName", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_apiname'] = '" . $objLang->get("commonTypeWord", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_description'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_field_type'] = '" . $objLang->get("fieldType", "formerror") . "';\n";
                    $strScript .= "objForm.alerts = objAlerts;\n";
                    //*** Add form to the Forms object.
                    $strScript .= "objValidForms.addForm(objForm);\n";
                    break;
            }
            break;
        case NAV_PCMS_FORMS:
            switch ($strCommand) {
                case CMD_LIST:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    break;
                case CMD_ADD:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    //*** Form fields.
                    $strScript .= "var objForm = new ValidForm('formForm');\n";
                    $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
                    $strScript .= "objForm.addElement('frm_apiname', LIBFRM_WORD);\n";
                    $strScript .= "objForm.addElement('frm_description', LIBFRM_TEXT);\n";
                    //*** Form errors.
                    $strScript .= "var objAlerts = new Object();\n";
                    $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("formName", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_apiname'] = '" . $objLang->get("commonTypeWord", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_description'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
                    $strScript .= "objForm.alerts = objAlerts;\n";
                    //*** Add form to the Forms object.
                    $strScript .= "objValidForms.addForm(objForm);\n";
                    break;
                case CMD_ADD_FIELD:
                case CMD_EDIT_FIELD:
                    //*** Form objects.
                    $strScript .= "var objValidForms = new ValidForms();\n";
                    //*** Form fields.
                    $strScript .= "var objForm = new ValidForm('templateFieldForm');\n";
                    $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
                    $strScript .= "objForm.addElement('frm_apiname', LIBFRM_WORD);\n";
                    $strScript .= "objForm.addElement('frm_description', LIBFRM_TEXT);\n";
                    $strScript .= "objForm.addElement('frm_field_type', LIBFRM_STRING, true);\n";
                    //*** Form errors.
                    $strScript .= "var objAlerts = new Object();\n";
                    $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("fieldName", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_apiname'] = '" . $objLang->get("commonTypeWord", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_description'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
                    $strScript .= "objAlerts['frm_field_type'] = '" . $objLang->get("fieldType", "formerror") . "';\n";
                    $strScript .= "objForm.alerts = objAlerts;\n";
                    //*** Add form to the Forms object.
                    $strScript .= "objValidForms.addForm(objForm);\n";
                    break;
            }
            break;
        case NAV_MYPUNCH_PROFILE:
            //*** Form objects.
            $strScript .= "var objValidForms = new ValidForms();\n";
            //*** Form fields.
            $strScript .= "var objForm = new ValidForm('settingsProfileForm');\n";
            $strScript .= "objForm.addElement('frm_name', LIBFRM_STRING, true);\n";
            $strScript .= "objForm.addElement('frm_email', LIBFRM_EMAIL, true);\n";
            $strScript .= "objForm.addElement('frm_language', LIBFRM_WORD, true);\n";
            //*** Form errors.
            $strScript .= "var objAlerts = new Object();\n";
            $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
            $strScript .= "objAlerts['frm_name'] = '" . $objLang->get("profileName", "formerror") . "';\n";
            $strScript .= "objAlerts['frm_email'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
            $strScript .= "objAlerts['frm_language'] = '" . $objLang->get("commonTypeText", "formerror") . "';\n";
            $strScript .= "objForm.alerts = objAlerts;\n";
            //*** Add form to the Forms object.
            $strScript .= "objValidForms.addForm(objForm);\n";
            //*** Form fields.
            $strScript .= "var objForm = new ValidForm('settingsPasswordForm');\n";
            $strScript .= "objForm.addElement('frm_currentpass', LIBFRM_PASSWORD, true);\n";
            $strScript .= "objForm.addElement('frm_newpass', LIBFRM_PASSWORD, true);\n";
            $strScript .= "objForm.addElement('frm_verifypass', LIBFRM_PASSWORD, true);\n";
            //*** Form errors.
            $strScript .= "var objAlerts = new Object();\n";
            $strScript .= "objAlerts.mainAlert = '" . $objLang->get("main", "formerror") . "';\n";
            $strScript .= "objAlerts['frm_currentpass'] = '******';\n";
            $strScript .= "objAlerts['frm_newpass'] = '******';\n";
            $strScript .= "objAlerts['frm_verifypass'] = '******';\n";
            $strScript .= "objForm.alerts = objAlerts;\n";
            //*** Add form to the Forms object.
            $strScript .= "objValidForms.addForm(objForm);\n";
            break;
        default:
            $strScript .= "";
            break;
    }
    //*** Tree scripts.
    $strScript .= "\n";
    $intSelectedTab = 0;
    switch ($intCatId) {
        case NAV_PCMS_TEMPLATES:
            if ($strCommand == CMD_EDIT_FIELD) {
                $strScript .= Tree::treeRender("templatefields", $intElmntId);
            } else {
                $strScript .= Tree::treeRender("templates", $intElmntId);
            }
            break;
        case NAV_PCMS_ELEMENTS:
            $strScript .= Tree::treeRender("elements", $intElmntId);
            if ($strCommand == CMD_EDIT) {
                $intSelectedTab = 1;
            }
            break;
        case NAV_MYPUNCH_USERS:
            $strScript .= Tree::treeRender("users", $intElmntId);
            break;
        case NAV_PCMS_FORMS:
            $strScript .= Tree::treeRender("forms", $intElmntId);
            break;
        case NAV_PCMS_STORAGE:
            $strScript .= Tree::treeRender("storage", $intElmntId);
            break;
    }
    //*** Announcement script.
    $strScript .= "function loadAnnouncement() {";
    if (AnnounceMessage::getMessages(false)->count() > 0 && $objLiveUser->checkRight(MYPUNCH_ANNOUNCEMENTS_VIEW)) {
        $strScript .= "objLightbox = new lightbox('index.php?cid=24');";
        $strScript .= "objLightbox.activate();";
    }
    $strScript .= "}";
    executeUpdateScript($objTpl);
    $objTpl->setCurrentBlock("__global__");
    $objTpl->setVariable("SELECTED_TAB", $intSelectedTab);
    $objTpl->setVariable("SCRIPT", $strScript);
    $objTpl->parseCurrentBlock();
    return $objTpl->get();
}