/** * Will render a specified form, the name of the form given by the first parameter; * * This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form. * We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had * an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common * settings between different forms, as we've done with the methods defined in the __CALL method above; * * For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced * two switches in this method, one that would have set the common options, and the second, would have just passed through * again, and get the already set configuration options, using them. This means that if we needed to change behavior of * some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over * having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality; * * @param string $objFormToRender The name of the form to render; * @return mixed Depends on the rendered form if it returns something or not; */ public function renderForm(S $objFormToRender, A $objFA = NULL) { // Make them defaults ... if ($objFA == NULL) { $objFA = new A(); } // Do a switch ... switch ($objFormToRender) { case 'contactForm': // Set the URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array('Status')), new A(array('Ok'))); // Set some requirements; $objPHPEMLRegExpCheck = new S(Authentication::REGEXP_PHP_CHECK_EMAIL); // Get some configuration parameters ... $objNameFrm = $objFA['form_name']; $objSubject = $objFA['field_subject']; $objEMAIL = $objFA['field_email']; $objMessage = $objFA['field_message']; $objSendFrm = $objFA['form_submit_contact']; $objErrorE = $objFA['error_must_enter_valid_email']; $objErrorM = $objFA['error_must_enter_message']; $objErrorI = $objFA['error_entered_email_not_valid']; // Do some work; if ($this->checkPOST(self::$objContactTableFEMAIL)->toBoolean() == TRUE) { // Check the EMAIL was set; if ($this->getPOST(self::$objContactTableFEMAIL)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objContactTableFEMAIL, $objErrorE); } } if ($this->checkPOST(self::$objContactTableFMessage)->toBoolean() == TRUE) { // Check the MESSAGE is not empty; if ($this->getPOST(self::$objContactTableFMessage)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objContactTableFMessage, $objErrorM); } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S($objNameFrm))->setSQLAction(new S('update'))->setTableName(self::$objContactTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objContactTableFId)->setExtraUpdateData(self::$objContactTableFReceived, new S((string) $_SERVER['REQUEST_TIME']))->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('contact_submit'))->setValue($objSendFrm)->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objContactTableFSubjectId)->setLabel($objSubject)->setContainerDiv(new B(TRUE)); // Get the subjects ... foreach ($this->getSubjects() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objContactSubjectFId])->setValue($v[self::$objContactSubjectFId])->setLabel($v[self::$objContactSubjectFTitle]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objContactTableFEMAIL)->setLabel($objEMAIL)->setRegExpType(new S('preg'))->setRegExpErrMsg($objErrorI)->setPHPRegExpCheck($objPHPEMLRegExpCheck)->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objContactTableFMessage)->setLabel($objMessage)->setRows(new S('10'))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); // Do some after work; if ($this->checkPOST(new S('contact_submit'))->toBoolean() == TRUE) { if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Set some requirements ... $objMAIL = new MAIL(); // Set From: MAIL header; $objMAIL->setFrom($this->getPOST(self::$objContactTableFEMAIL)); $objMAIL->doMAIL($this->getConfigKey(new S('contact_message_email')), $this->getSubjectInfoById($this->getPOST(self::$objContactTableFSubjectId), self::$objContactSubjectFTitle), $this->getPOST(self::$objContactTableFMessage)); } // Do a redirect, to the ok page ... if everything is OK; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { $this->setHeaderKey($objURLToGoBack, new S('Location')); } } // Break out ... break; case 'messageSend': // Set the URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do some work; if ($this->checkPOST(new S('submit_resend_message'))->toBoolean() == TRUE) { // Set some requirements ... $objTo = $this->getConfigKey(new S('contact_message_email')); $objSubjectId = $this->getMessageInfoById($_GET[ADMIN_ACTION_ID], self::$objContactTableFSubjectId); $objSubject = $this->getSubjectInfoById($objSubjectId, self::$objContactSubjectFTitle); $objFrom = $this->getMessageInfoById($_GET[ADMIN_ACTION_ID], self::$objContactTableFEMAIL); $objMessage = $this->getMessageInfoById($_GET[ADMIN_ACTION_ID], self::$objContactTableFMessage); // Set some requirements ... $objMAIL = new MAIL(); // Set From: MAIL header ... $objMAIL->setFrom($objFrom); $objMAIL->doMAIL($objTo, $objSubject, $objMessage); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_RESEND_MESSAGE))->setName($objFormToRender)->setInputType(new S('submit'))->setName(new S('submit_resend_message'))->setValue(new S(CONTACT_RESEND_MESSAGE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'messageOperations': // Set some predefines; $objURLToGoBack = URL::rewriteURL(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_EDIT_COMMENT_AND_STATUS))->setSQLAction(new S('update'))->setTableName(self::$objContactTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objContactTableFId)->setExtraUpdateData(self::$objContactTableFLastEdited, new S((string) $_SERVER['REQUEST_TIME']))->setName($objFormToRender)->setInputType(new S('submit'))->setValue(new S(CONTACT_EDIT_COMMENT_AND_STATUS))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objContactTableFResolved)->setLabel(new S(CONTACT_MESSAGE_RESOLVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(CONTACT_MESSAGE_RESOLVED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(CONTACT_MESSAGE_RESOLVED_NO))->setInputType(new S('textarea'))->setName(self::$objContactTableFComment)->setLabel(new S(CONTACT_MESSAGE_COMMENT))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); if ($this->checkPOST(self::$objContactTableFComment)->toBoolean() == TRUE) { // Do a redirect, and get the user back where he belongs; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { $this->setHeaderKey($objURLToGoBack, new S('Location')); } } break; case 'messageErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objContactTable)->doToken('%condition', new S('%objContactTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'subjectCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work; if ($this->checkPOST(self::$objContactSubjectFTitle)->toBoolean() == TRUE) { // Check that the subject title is not empty!; if ($this->getPOST(self::$objContactSubjectFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objContactSubjectFTitle, new S(CONTACT_SUBJECT_CANNOT_BE_EMPTY)); } } // Get AJAX $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_ADD_SUBJECT))->setSQLAction(new S('update'))->setTableName(self::$objContactSubjectTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objContactSubjectFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(CONTACT_ADD_SUBJECT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objContactSubjectFTitle)->setLabel(new S(CONTACT_SUBJECT))->setJSRegExpReplace(new S(self::REGEXP_JS_SUBJECT))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'subjectEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do some work; if ($this->checkPOST(self::$objContactSubjectFTitle)->toBoolean() == TRUE) { // Check that the subject title is not empty!; if ($this->getPOST(self::$objContactSubjectFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objContactSubjectFTitle, new S(CONTACT_SUBJECT_CANNOT_BE_EMPTY)); } } // Get AJAX $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_EDIT_SUBJECT))->setSQLAction(new S('update'))->setTableName(self::$objContactSubjectTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objContactSubjectFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(CONTACT_EDIT_SUBJECT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objContactSubjectFTitle)->setLabel(new S(CONTACT_SUBJECT))->setJSRegExpReplace(new S(self::REGEXP_JS_SUBJECT))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'subjectErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objSQLCondition = new S('WHERE %objContactTableFSubjectId = "%Id"'); // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objContactSubjectTable)->doToken('%condition', new S('%objContactSubjectFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'configurationEdit': // Set the URL to go back too; $objURLToGoBack = new S(); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what'))))); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_MANAGE_CONFIG))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(CONTACT_CONFIG_DO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S(CONTACT_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-contact_address'))->setValue(new S('configurationEdit-contact_address'))->setLabel(new S(CONTACT_CONFIG_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-page_content'))->setValue(new S('configurationEdit-page_content'))->setLabel(new S(CONTACT_CONFIG_PAGE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-ok_page_content'))->setValue(new S('configurationEdit-ok_page_content'))->setLabel(new S(CONTACT_CONFIG_SUCCES_PAGE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-contact_address': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do form validation; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_MANAGE_CONFIG))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(CONTACT_MANAGE_CONFIGURATION_UPDATE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('contact_message_email'))->setLabel(new S(CONTACT_DEFAULT))->setValue($this->getConfigKey(new S('contact_message_email')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do form validation; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_MANAGE_CONFIGURATION_UPDATE))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(CONTACT_MANAGE_CONFIGURATION_UPDATE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('contact_page_message_content'))->setLabel(new S(CONTACT_PAGE_CONTENT))->setValue($this->getConfigKey(new S('contact_page_message_content')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-ok_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do form validation; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(CONTACT_MANAGE_CONFIGURATION_UPDATE))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(CONTACT_MANAGE_CONFIGURATION_UPDATE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('contact_page_message_content_ok'))->setLabel(new S(CONTACT_PAGE_CONTENT_OK))->setValue($this->getConfigKey(new S('contact_page_message_content_ok')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; } }
/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case 'widgetXML': // Yo man ... woohoooooo ... foreach ($this->getPublishedArticles(new S('ORDER BY %objArticleTableFDatePublished DESC')) as $k => $v) { // Set some requirements ... $objDTE = date('Y-m-d', (int) $v[self::$objArticleTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL))); // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL); // Set the XML Sitemap kids ... $objURL->addCHILD(Frontend::XML_LOCATION, $objLOC); $objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE); $objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY); $objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY); } // BK; break; case 'widgetRSS': // Yo man ... woohoooooo ... if ($_GET[FRONTEND_FEED_URL] == __CLASS__) { // Get'em 30 ... foreach ($this->getPublishedArticles(new S('ORDER BY %objArticleTableFDatePublished DESC LIMIT 0, 30')) as $k => $v) { // Set some requirements ... $objDTE = date(DATE_RFC822, (int) $v[self::$objArticleTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL))); $objDSC = $v[self::$objArticleTableFExcerpt]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags(); $objTTL = $v[self::$objArticleTableFTitle]; // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM); // Set the RSS kids ... $objURL->addCHILD(Frontend::RSS_TITLE, $objTTL); $objURL->addCHILD(Frontend::RSS_LINK, $objLOC); $objURL->addCHILD(Frontend::RSS_GUID, $objLOC); $objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE); $objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC); } } // BK; break; } // HTML: Do a switch ... switch ($objW) { case 'widgetCategoryList': // Set the template file ... if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) { // Get the category to start from ... if (isset($objWA['start_from_category'])) { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']); } else { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, NULL); } // Set the template file ... TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); TPL::tpEnd($cId); } // BK; break; case 'widgetList': // Check some needed requirements ... if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_ARTICLE_URL) { // Set some requirements ... $objPag = isset($_GET[ARTICLES_PAGE_URL]) ? $_GET[ARTICLES_PAGE_URL] : new S((string) 1); if (isset($_GET[ARTICLES_ARTICLES_URL])) { // Check that the article exists, before doing anything stupid ... if ($this->checkArticleURLIsUnique($objURL = $_GET[ARTICLES_ARTICLES_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Update them views ... $this->_Q(_QS('doUPDATE')->doToken('%table', self::$objArticleTable)->doToken('%condition', _S('%objArticleTableFViews = %objArticleTableFViews + 1 WHERE %objArticleTableFSEO = "%Id"')->doToken('%Id', $_GET[ARTICLES_ARTICLES_URL]))); // Do me SEO, yah baby! ... (add title and category name, cause we need it) TPL::manageTTL($this->getArticleInfoByURL($objURL, self::$objArticleTableFTitle)); TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoById($this->getArticleInfoByURL($objURL, self::$objArticleTableFCategoryId), self::$objCategoryTableFName))); // Do me SEO, yah baby! ... (add keywords and description, for something extra) TPL::manageTAG(new S('keywords'), $this->getArticleInfoByURL($objURL, self::$objArticleTableFTags)); TPL::manageTAG(new S('description'), $this->getArticleInfoByURL($objURL, self::$objArticleTableFTitle)->appendString(_DCSP)->appendString($this->getArticleInfoByURL($objURL, self::$objArticleTableFExcerpt))->doToken(_QOT, _NONE)); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item.tp'); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($objURL, new S('objURL'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); } } else { if (isset($_GET[ARTICLES_CATEGORY_URL])) { // Check that the category exists, before doing anything stupid ... if ($this->checkCategoryURLIsUnique($objCat = $_GET[ARTICLES_CATEGORY_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Do me SEO, yah baby! ... (title and pagination to prev. duplicates) TPL::manageTTL(_S(ARTICLES_PAGE_URL)->appendString(_SP)->appendString($objPag)); TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFName))); // Do me SEO, yah baby! ... (add cat. descr) if ($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFDescription)->toLength()->toInt() != 0) { TPL::manageTAG(new S('description'), $this->getCategoryInfoByURL($objCat, self::$objCategoryTableFDescription)->entityDecode(ENT_QUOTES)->stripTags()->doToken(_QOT, _NONE)->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE)); } // Set some requirements ... $objCnt = $this->getPublishedArticleCountForCategoryURL($objCat); $objStk = $this->getStickyArticlesByCategoryURLAndPage($objCat, $objPag); $objArt = $this->getPublishedArticlesByCategoryURLAndPage($objCat, $objPag); $objInC = new B(TRUE); } } else { // Do me SEO, yah baby! ... TPL::manageTTL(_S(FRONTEND_ARTICLE_URL)); TPL::manageTTL(_S(ARTICLES_PAGE_URL)->appendString(_SP)->appendString($objPag)); // Set some requirements ... $objCnt = $this->getPublishedArticleCount(); $objStk = $this->getStickyArticlesByPage($objPag); $objArt = $this->getPublishedArticlesByPage($objPag); $objInC = new B(FALSE); $objCat = new S(); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($objInC, new S('objInC'), $tpF); TPL::tpSet($objCat, new S('objCat'), $tpF); TPL::tpSet($objArt, new S('objArt'), $tpF); TPL::tpSet($objStk, new S('objStk'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); // Set them paginations ... if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) { self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString())); } } } else { // Do the biggest error on the PLANET ... self::renderScreenOfDeath(new S(__CLASS__), new S(ARTICLES_NEED_PROPER_SECTION), new S(ARTICLES_NEED_PROPER_SECTION_FIX)); } // BK; break; case 'widgetComments': // Check if we have the proper URL enabled ... if (isset($_GET[ARTICLES_ARTICLES_URL])) { // Check if the comments are enabled ... if ($this->getArticleInfoByURL($_GET[ARTICLES_ARTICLES_URL], self::$objArticleTableFCanComment) == 'Y') { // Set some requirements ... $objCommentIsOk = new S(); $objShowComm = new B(TRUE); $objComments = $this->getApprovedCommentsByArticleURL($_GET[ARTICLES_ARTICLES_URL], new S('ORDER BY %objCommentsTableFDate DESC')); // Check for status ... if (isset($_GET[ARTICLES_STATUS_URL])) { if ($_GET[ARTICLES_STATUS_URL] == ARTICLES_STATUS_OK_URL) { $objCommentIsOk = new S($objWA['comment_has_been_added']); } } // Set some requirements ... $objShowFrm = new B(TRUE); // Check if we're allowed to show the comment form ... if ($this->getConfigKey(new S('article_settings_article_auth_to_comment')) == 'Y') { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { $objShowFrm = new B(TRUE); } else { $objShowFrm = new B(FALSE); } } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF); TPL::tpSet($objComments, new S('objComments'), $tpF); TPL::tpSet($objShowComm, new S('objShowComm'), $tpF); TPL::tpSet($objShowFrm, new S('objShowFrm'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpExe($tpF); // Do some work ... if ($objShowFrm->toBoolean() == TRUE) { if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment'])); } } if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name'])); } } if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email'])); } } // Make the form ... (ya, outside the box ...); $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId)->setRedirect(URL::rewriteURL(new A(array(ARTICLES_STATUS_URL)), new A(array(ARTICLES_STATUS_OK_URL))))->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFArticleId, $this->getArticleInfoByURL($_GET[ARTICLES_ARTICLES_URL], self::$objArticleTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE)); // Check if the user is authenticated ... if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Set the RUId; $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)); } else { // Set the other infos; $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE)); } // Continue ... $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setRows(new S('10'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { // Get some needed requirements .. $objURL = $_GET[ARTICLES_ARTICLES_URL]; if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Query the authentication ... $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName); } else { // Or trust the FORM ... $objUSR = $this->getPOST(self::$objCommentsTableFName); } // Go and SP ... MAIL me ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(ARTICLES_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPosted'))->doToken('%u', $objUSR)); } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); } } } // BK; break; } }
/** * Will render a specified form, the name of the form given by the first parameter; * * This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form. * We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had * an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common * settings between different forms, as we've done with the methods defined in the __CALL method above; * * For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced * two switches in this method, one that would have set the common options, and the second, would have just passed through * again, and get the already set configuration options, using them. This means that if we needed to change behavior of * some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over * having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality; * * @param string $objFormToRender The name of the form to render; * @return mixed Depends on the rendered form if it returns something or not; */ public function renderForm(S $objFormToRender, A $objFA = NULL) { // Make them defaults ... if ($objFA == NULL) { $objFA = new A(); } // Do a switch ... switch ($objFormToRender) { case 'uploadForm': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(AUDIO_STATUS_URL)), new A(array(AUDIO_STATUS_OK_URL))); // Do some work ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFTitle, new S($objFA['error_title_empty'])); } } if ($this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFArtist)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFArtist, new S($objFA['error_artist_empty'])); } } if ($this->checkPOST(self::$objAudioTableFAlbum)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFAlbum)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFAlbum, new S($objFA['error_album_empty'])); } } // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['upload_audio_file']))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAudioTableFId)->setExtraUpdateData(self::$objAudioTableFUploadedDate, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAudioTableFUploaderId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId))->setExtraUpdateData(self::$objAudioTableFApproved, new S('N'))->setUploadDirectory(new S('audio/mp3/' . date('Y/m/d', $_SERVER['REQUEST_TIME'])))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString((string) $_SERVER['REQUEST_TIME']))); } // Continue ... $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S($objFA['upload_audio_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S($objFA['audio_file_title']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S($objFA['audio_file_category']))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S($objFA['audio_file_artist']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S($objFA['audio_file_album']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S($objFA['audio_file_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S($objFA['audio_file_artwork']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S($objFA['audio_file_lyrics']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S($objFA['audio_file_description']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Go ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_FRONT_FILE_HAS_BEEN_UPLOADED), $this->getHELP(new S('uploadFormEMLMessage'))->doToken('%t', $this->getPOST(self::$objAudioTableFTitle))->doToken('%a', $this->getPOST(self::$objAudioTableFArtist))->doToken('%b', $this->getPOST(self::$objAudioTableFAlbum))->doToken('%u', $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName))); } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); break; case 'audioSearchOnFrontend': // Do the form, make it happen ... $this->setMethod(new S('POST'))->setName($objFormToRender); // Do some work ... if ($this->checkPOST(new S('search'))->toBoolean() == TRUE) { // Get the title, and check it's name ... if ($this->getPOST(new S('audio_file_title'))->toLength()->toInt() == 0) { // Well, sadly, we have an issue ... $this->setErrorOnInput(new S('audio_file_title'), new S($objFA['error_empty_search'])); } else { // Notify ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_SEARCH_HAS_BEEN_PERFORMED), $this->getHELP(new S('audioSearchOnFrontend'))->doToken('%s', $this->getPOST(new S('audio_file_title')))); // Go ... $this->setHeaderKey($objURLToGoBack = URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUDIO_SEARCH_URL)), new A(array(FRONTEND_AUDIO_URL, $this->getPOST(new S('audio_file_title'))->entityDecode(ENT_QUOTES)->stripSlashes()))), new S('Location')); } } // Continue ... $this->setInputType(new S('submit'))->setName(new S('search'))->setValue(new S($objFA['search_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('audio_file_title')); // If it's set ... add the VALUE ... if (isset($_GET[AUDIO_SEARCH_URL])) { $this->setValue($_GET[AUDIO_SEARCH_URL]); } // Continue ... $this->setLabel(new S($objFA['search_title']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioSearch': // Get some predefines; if (isset($_GET[ADMIN_ACTION_BY])) { $objSearchBy = $_GET[ADMIN_ACTION_BY]; } else { $objSearchBy = new S(); } if (isset($_GET[ADMIN_ACTION_SEARCH])) { $objSearchWas = $_GET[ADMIN_ACTION_SEARCH]; } else { $objSearchWas = new S(); } // Do some work; if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) { if ($this->getPOST(new S('search_by'))->toLength()->toInt() == 0) { if (isset($_GET[ADMIN_ACTION_SEARCH])) { // Erase search terms ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location')); } // Set an input error; $this->setErrorOnInput(new S('search_by'), new S(AUDIO_SEARCH_FIELD_IS_EMPTY)); // Unset the post ... $this->unsetPOST(); } else { // Get what to search and where ... $objWhatToSearch = $this->getPOST(new S('search_by')); $objWhereToSearch = $this->getPOST(new S('search_field')); // And go there ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location')); } } // Check the option that has been selected; $objWasSelected = new A(array(new B($objSearchBy == AUDIO_SEARCH_TITLE ? TRUE : FALSE), new B($objSearchBy == AUDIO_SEARCH_ARTIST ? TRUE : FALSE), new B($objSearchBy == AUDIO_SEARCH_ALBUM ? TRUE : FALSE))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_SEARCH_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_by'))->setvalue($objSearchWas)->setLabel(new S(AUDIO_SEARCH_BY))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(AUDIO_SEARCH_IN))->setInputType(new S('option'))->setName(new S('article_title'))->setValue(new S(AUDIO_SEARCH_TITLE))->setLabel(new S(AUDIO_SEARCH_TITLE))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('article_content'))->setValue(new S(AUDIO_SEARCH_ARTIST))->setLabel(new S(AUDIO_SEARCH_ARTIST))->setSelected($objWasSelected[1])->setInputType(new S('option'))->setName(new S('article_category'))->setValue(new S(AUDIO_SEARCH_ALBUM))->setLabel(new S(AUDIO_SEARCH_ALBUM))->setSelected($objWasSelected[2])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUDIO_SEARCH_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE)); break; case 'audioCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); $objUPDirectory = date('Y/m/d', $_SERVER['REQUEST_TIME']); // Do some work ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFTitle, new S(AUDIO_TITLE_REQUIRED)); } } if ($this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFArtist)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFArtist, new S(AUDIO_ARTIST_REQUIRED)); } } if ($this->checkPOST(self::$objAudioTableFAlbum)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFAlbum)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFAlbum, new S(AUDIO_ALBUM_REQUIRED)); } } // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_ADD_AUDIO))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAudioTableFId)->setExtraUpdateData(self::$objAudioTableFUploaderId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId))->setUploadDirectory(new S('audio/mp3/' . $objUPDirectory))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString((string) $_SERVER['REQUEST_TIME']))); } // Continue ... $this->setName($objFormToRender); if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(AUDIO_ADD_AUDIO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFApproved)->setLabel(new S(AUDIO_FILE_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_FILE_APPROVED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_FILE_APPROVED_NO))->setInputType(new S('select'))->setName(self::$objAudioTableFCanComment)->setLabel(new S(AUDIO_CAN_COMMENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S(AUDIO_FILE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_FILE_CATEGORY))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S(AUDIO_FILE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S(AUDIO_FILE_ARTWORK))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S(AUDIO_FILE_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S(AUDIO_FILE_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S(AUDIO_FILE_LYRICS))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S(AUDIO_FILE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioEdit': // God send us our info ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'audioEditInfo.tp'); TPL::tpSet($this, new S('AUD'), $tpF); TPL::tpExe($tpF); // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objUPDirectory = date('Y/m/d', (int) $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)->toString()); // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_EDIT_AUDIO))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAudioTableFId)->setUploadDirectory(new S('audio/mp3/' . $objUPDirectory))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString($this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)))); } // Continue ... $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(AUDIO_EDIT_AUDIO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFApproved)->setLabel(new S(AUDIO_FILE_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_FILE_APPROVED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_FILE_APPROVED_NO))->setInputType(new S('select'))->setName(self::$objAudioTableFCanComment)->setLabel(new S(AUDIO_CAN_COMMENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S(AUDIO_FILE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_FILE_CATEGORY))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S(AUDIO_FILE))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S(AUDIO_FILE_ARTWORK))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S(AUDIO_FILE_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S(AUDIO_FILE_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S(AUDIO_FILE_LYRICS))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S(AUDIO_FILE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objUPDirectory = date('Y/m/d/', (int) $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)->toString()); if ($this->getCommentCount(_S('WHERE %objCommentsTableFAudioFileId = "%Id"')->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->toInt() != 0) { self::$objAdministration->setErrorMessage(new S(AUDIO_HAS_COMMENTS), $objURLToGoBack); } else { // Remove them files ... $objPath = new FilePath('upd/audio/mp3/' . $objUPDirectory); // First: check to see if file is there ... $objArtF = $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFFile); // Go ... if ($objArtF->toLength()->toInt() != 0) { // Kill'em ALL ... UNLINK($objPath . $objArtF); } // Second: check to see if artwork is there ... $objArtF = $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFArtwork); // Go ... if ($objArtF->toLength()->toInt() != 0) { // Kill'em ALL ... UNLINK($objPath . '' . $objArtF); UNLINK($objPath . '128_128_' . $objArtF); UNLINK($objPath . '640_480_' . $objArtF); UNLINK($objPath . '800_600_' . $objArtF); } // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAudioTable)->doToken('%condition', new S('%objAudioTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); } // BK; break; case 'commentEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_EDIT_COMMENT))->setAJAXEnabledForm(new B(FALSE))->setRedirect($objURLToGoBack)->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objCommentsTableFId)->setName($objFormToRender)->setInputType(new S('submit'))->setValue(new S(AUDIO_EDIT_COMMENT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objCommentsTableFApproved)->setLabel(new S(AUDIO_COMMENT_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S(AUDIO_COMMENT))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'commentErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objCommentsTable)->doToken('%condition', new S('%objCommentsTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'categoryCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work; if ($this->checkPOST(new S('categories_show_all'))->toBoolean() == TRUE) { // Redirect to proper ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SHOW_ALL)), new A(array('1'))), new S('Location')); } if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); $objToCheck = MPTT::mpttAddUnique($this->getPOST(new S('add_category')), new S((string) $_SERVER['REQUEST_TIME'])); if ($objToCheck->toLength()->toInt() == 0) { $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_NAME_IS_EMPTY)); // Set the memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_ALREADY_EXISTS)); // Set the memory; $objFormHappened->switchType(); } if ($this->checkCategoryURLIsUnique(URL::getURLFromString($objToCheck))->toBoolean() == FALSE) { $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_URL_MUST_BE_UNIQUE)); } } // Get AJAX; $this->getAjaxErrors(); if ($objFormHappened->toBoolean() == FALSE) { // Remember if we should add it as a brother or child; $objAddNodeAS = NULL; switch ($this->getPOST(new S('add_category_as_what'))) { case AUDIO_CATEGORY_CHILD: $objAddNodeAS = new S((string) MPTT::FIRST_CHILD); break; case AUDIO_CATEGORY_LAST_CHILD: $objAddNodeAS = new S((string) MPTT::LAST_CHILD); break; case AUDIO_CATEGORY_BROTHER: $objAddNodeAS = new S((string) MPTT::PREVIOUS_BROTHER); break; case AUDIO_CATEGORY_NEXT_BROTHER: $objAddNodeAS = new S((string) MPTT::NEXT_BROTHER); break; } // Add the node; self::$objMPTT->mpttAddNode($objToCheck, $this->getPOST(new S('add_category_parent_or_bro')), $objAddNodeAS); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_ADD_CATEGORY))->setName($objFormToRender); if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('categories_show_all'))->setValue(new S(AUDIO_SHOW_ALL_CATEGORIES))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setName(new S('add_category_submit'))->setValue(new S(AUDIO_ADD_CATEGORY))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ,.!?;&-]'))->setContainerDiv(new B(TRUE))->setName(new S('add_category'))->setLabel(new S(AUDIO_CATEGORY_NAME_LABEL))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_as_what'))->setLabel(new S(AUDIO_AS_A))->setInputType(new S('option'))->setName(new S('as_first_child'))->setLabel(new S(AUDIO_CATEGORY_CHILD))->setInputType(new S('option'))->setName(new S('as_last_child'))->setLabel(new S(AUDIO_CATEGORY_LAST_CHILD))->setInputType(new S('option'))->setName(new S('as_previous_brother'))->setLabel(new S(AUDIO_CATEGORY_BROTHER))->setInputType(new S('option'))->setName(new S('as_next_brother'))->setLabel(new S(AUDIO_CATEGORY_NEXT_BROTHER))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_parent_or_bro'))->setLabel(new S(AUDIO_OF_CATEGORY)); // Category parent or brother of this one ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objNameOfNode])->setValue($v[self::$objMPTT->objNameOfNode])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique(clone $v[self::$objMPTT->objNameOfNode]))); } // Continue, execute the form ... $this->setFormEndAndExecute(new B(TRUE)); break; case 'categoryEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do validation and error on it if something goes wrong; if ($this->checkPOST()->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); $objToCheck = MPTT::mpttAddUnique($this->getPOST(self::$objCategoryTableFName), $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFDate)); if ($objToCheck->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(self::$objCategoryTableFName, new S(AUDIO_CATEGORY_NAME_IS_EMPTY)); // Set the memory; $objFormHappened->switchType(); } else { if ($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName) != $objToCheck) { if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) { // Check to see if the group exists; $this->setErrorOnInput(self::$objCategoryTableFName, new S(AUDIO_CATEGORY_ALREADY_EXISTS)); // Set the memory; $objFormHappened->switchType(); } } } // Get AJAX; $this->getAjaxErrors(); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objCategoryTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objCategoryTableFId)->setFieldset(new S(AUDIO_EDIT_CATEGORY)); if ($this->checkPOST(self::$objCategoryTableFName)->toBoolean() == TRUE && $objFormHappened->toBoolean() == FALSE) { // Add the URL processing ... $this->setExtraUpdateData(self::$objCategoryTableFSEO, URL::getURLFromString($this->getPOST(self::$objCategoryTableFName))); $this->setRedirect($objURLToGoBack); } // Continue ... $this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('edit_category_submit'))->setValue(new S(AUDIO_EDIT_CATEGORY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCategoryTableFName)->setLabel(new S(AUDIO_CATEGORY_NAME_LABEL))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ,.!?;&-]'))->setMPTTRemoveUnique(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objCategoryTableFDescription)->setLabel(new S(AUDIO_CATEGORY_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'categoryErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase the group node from the table; self::$objMPTT->mpttRemoveNode($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName)); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'categoryMove': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_TO, ADMIN_ACTION_TYPE))); // Get names, as they are unique; $objThatIsMoved = $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName); $objWhereToMove = $this->getCategoryInfoById($_GET[ADMIN_ACTION_TO], self::$objCategoryTableFName); // Get the node subtree, that's move, make sure the node we move to ain't a child; $objMovedNodeSubTree = self::$objMPTT->mpttGetTree($objThatIsMoved); // Memorize; $objIsChild = new B(FALSE); foreach ($objMovedNodeSubTree as $k => $v) { if ($v[self::$objMPTT->objNameOfNode] == $objWhereToMove) { $objIsChild->switchType(); } } // Check if it's a child or not; if ($objIsChild->toBoolean() == TRUE) { // Set an error message; self::$objAdministration->setErrorMessage(new S(AUDIO_CATEGORY_MOVED_TO_CHILD), $objURLToGoBack); } else { // Move nodes; self::$objMPTT->mpttMoveNode($objThatIsMoved, $objWhereToMove, $_GET[ADMIN_ACTION_TYPE]); $this->setHeaderKey($objURLToGoBack, new S('Location')); } // BK; break; case 'categoryMoveOperation': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_SUBPAGE)), new A(array(AUDIO_MANAGE_AUDIO))); // Do some work; $this->checkPOST()->toBoolean() == TRUE ? $objOLDCategoryId = $this->getPOST(new S('old_category_id')) : ($objOLDCategoryId = new S('0')); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_MOVE_ARTICLE))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateField(self::$objAudioTableFId)->setUpdateWhere($this->doModuleToken(_S('%objAudioTableFCategoryId = "%Id"')->doToken('%Id', $objOLDCategoryId)))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_MOVE_ARTICLE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('old_category_id'))->setLabel(new S(AUDIO_OLD_CATEGORY))->setContainerDiv(new B(TRUE)); // Cateories; foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Categories; $this->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_NEW_CATEGORY))->setContainerDiv(new B(TRUE)); foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit': // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what'))))); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender); // Set redirect; if ($this->checkPOST()->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } // Continue; $this->setInputType(new S('submit'))->setValue(new S(ADMIN_ACTION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S(AUDIO_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_on_top_of_upload_form_page'))->setValue(new S('configurationEdit-message_on_top_of_upload_form_page'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_ON_UPLOAD))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_upon_upload_ok'))->setValue(new S('configurationEdit-message_upon_upload_ok'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_ON_UPLOAD_OK))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_if_not_auth'))->setValue(new S('configurationEdit-message_if_not_auth'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_USER_NOT_AUTH))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-items_per_page'))->setValue(new S('configurationEdit-items_per_page'))->setLabel(new S(AUDIO_CONFIG_ITEMS_PER_PAGE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-users_should_be_auth_to_comment'))->setValue(new S('configurationEdit-users_should_be_auth_to_comment'))->setLabel(new S(AUDIO_CONFIG_USER_LOGGED_TO_COMM))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_on_top_of_upload_form_page': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_page'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_page')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_upon_upload_ok': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_page_status_ok'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_page_status_ok')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_if_not_auth': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_not_authenticated'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_not_authenticated')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-items_per_page': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('audio_settings_audio_items_per_page'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_items_per_page')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-users_should_be_auth_to_comment': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('audio_settings_audio_auth_to_comment'))->setLabel(new S(AUDIO_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S('Yes'))->setSelected($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'Y' ? new B(TRUE) : new B(FALSE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S('No'))->setSelected($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'N' ? new B(TRUE) : new B(FALSE))->setFormEndAndExecute(new B(TRUE)); break; } }
/** * Will render the 'Screen Of Death', by using tested and well working PHP functions. This method relies on the fact that, at least * the framework abstract classes are working. Non-core developers should not modify anything here as they can get their hands * dirty really quick and destroy something without even knowing it; * * @param S $errFrom Error from where did it came * @param S $errString What's the string of the error * @param S $errTip Do you have an information to show * @param S $debugErrorString Should we show the debugger * @param B $errFATAL Is this error FATAL * @return S Will return the error screen string, or just void, depends on what kind of error we caught * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $ * @since Version 1.0 * @access protected * @static * @final */ protected static function renderScreenOfDeath(S $errFrom, S $errString = NULL, S $errTip = NULL, S $debugErrorString = NULL, B $errFATAL = NULL) { // Set the execution time, discard the output stream, and set the error status to TRUE; self::setExeTime(new S(__FUNCTION__)); // Add header, if it's a CSS file, on an error!; switch (checkIfItsACSSFile() or checkIfItsAJSSFile()) { case TRUE: // Set the text/HTML, header!; self::setHeaderKey(new S('text/html'), new S('Content-type:')); break; } // Se the errorStatus to TRUE; self::setErrorStatus(); $catchedKrumoContent = _NONE; // Change behaviour, if this is a FATAL error; if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) { $errString = new S(FATAL_ERROR); $errTip = new S(FATAL_ERROR_CHECK_LOG); // Clean the output buffer; self::$objOutputBuffer = _NONE; } else { // Clean the output buffer; self::discardOutputStream(new B(TRUE)); // Execute the KRUMO PLUGIN Framework; $catchedKrumoContent = self::getKrumoContent(); } // Get the file contents; $debugContent = new FileContent(FORM_TP_DIR . _S . 'frm_error_screen.tp'); // Do an if, for the [%CODE%] part of our template; if (GESHI >= 1 && DEBUG >= 1) { // Replace [%CODE%], with GeSHi parsed code from our PHP files; // Really helpfull when trying to find hidden bugs; $debugContent->doToken('[%CODE%]', self::getDebugBacktrace(array_reverse(debug_backtrace()))); $debugContent->doToken('[%KRUMO%]', $catchedKrumoContent); } else { // Replace [%CODE%], with _NONE, hiding the output; // Well, can't help the developer here!; $debugContent->doToken('[%CODE%]', _NONE); $debugContent->doToken('[%KRUMO%]', _NONE); // Set as 'Hacking attempt'; $errString = VIEW_FILE_DIRECTLY_DENIED; $errTip = VIEW_FILE_DIRECTLY_DENIED_FIX; $debugErrorString = HACKING_ATTEMPT_BANG_YOU_DEAD; } // Start replacing information in the 'frm_error_screen.tp'; $debugContent->doToken('[%HSIMG%]', DOCUMENT_HOST . IMAGE_DIR . _WS); $debugContent->doToken('[%HSJSS%]', DOCUMENT_HOST . JAVASCRIPT_DIR . _WS); $debugContent->doToken('[%ERBGR%]', ERBGR); $debugContent->doToken('[%ERPIX%]', ERPIX); $debugContent->doToken('[%ERPXL%]', ERPXL); $debugContent->doToken('[%MEMORY%]', memory_get_usage() / 1024); $debugContent->doToken('[%PID%]', getmypid()); $debugContent->doToken('[%MICROTIME%]', self::getExeTime(new S(__CLASS__), new S(__FUNCTION__))); $debugContent->doToken('[%ERROR_FROM%]', $errFrom); $debugContent->doToken('[%ERROR_DATE%]', date(DATE_STRING, $_SERVER['REQUEST_TIME'])); $debugContent->doToken('[%ERROR_EMSG%]', $errString); $debugContent->doToken('[%ERROR_ETIP%]', $errTip); $debugContent->doToken('[%ERROR_FROM_PHP%]', $debugErrorString); // Try to MAIL ... If we got this far, we have MAIL ... if (self::checkClassExistence(new S('MAIL'))->toBoolean() == TRUE) { // Set some requirements ... if ($errString == NULL) { $errString = new S(); } if ($errTip == NULL) { $errTip = new S(); } // Make'em as new as possible ... $objEML = new MAIL(); $objEML->setFrom(new S(MAIL_FROM)); $objEML->setStringAttachment(new S($debugContent)); $objEML->doMAIL(new S(MAIL_FROM), $errString, new S($errTip . _DCSP . URL::rewriteURL() . _DCSP . $_SERVER['HTTP_USER_AGENT'] . _DCSP . $_SERVER['REMOTE_ADDR'])); } // Exit, with an error screen. We could also die, it would mean the same; if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) { // Return the content; if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9) { return gzencode($debugContent, OB_GZIP_LEVEL); } else { return $debugContent; } } else { // Or die script now; if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9) { exit(gzencode($debugContent, OB_GZIP_LEVEL)); } else { exit($debugContent); } } }
/** * Will render a specified form, the name of the form given by the first parameter; * * This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form. * have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had * an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common * settings between different forms, as we've done with the methods defined in the __CALL method above; * * For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced * two switches in this method, one that would have set the common options, and the second, would have just passed through * again, and get the already set configuration options, using them. This means that if we needed to change behavior of * some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over * having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality best; * * @param string $objFormToRender The name of the form to render; * @return mixed Depends on the rendered form if it returns something or not; */ public function renderForm(S $objFormToRender, A $objFA = NULL) { // Make them defaults ... if ($objFA == NULL) { $objFA = new A(); } // Do a switch ... switch ($objFormToRender) { case 'adminLoginScreen': // Do some URL mangling, redirect back to a pure index; URL::doCleanURLPath(); // Add a <title> tag, saying we need to log in; $this->manageTTL(new S(AUTHENTICATION_LOGIN_FORM)); // Get the personalized CSS; $this->manageCSS(new FilePath($this->getPathToSkin()->toRelativePath() . SKIN_CSS_DIR . _S . 'renderAdminLoginScreen.css'), new S(__FUNCTION__)); // Do the authentication mechanism, check the _POST; if ($this->checkPOST()->toBoolean() == TRUE) { if ($this->doLogIn($this->getPOST(self::$objAuthUsersTableFUName), $this->getPOST(self::$objAuthUsersTableFUPass))->toBoolean() == TRUE) { // OK; $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGE)), new A(array(ADMIN_DASHBOARD))), new S('Location')); } else { // Do an error, and retain the user; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_ACCESS_DENIED)); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setName($objFormToRender)->setFieldset(new S(AUTHENTICATION_LOGIN_FORM))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_LOGIN_GO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_USERNAME))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setTooltip($this->getHELP(new S('adminLoginScreenU')))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S(AUTHENTICATION_PASSWORD))->setTooltip($this->getHELP(new S('adminLoginScreenP')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'userLogIn': // Do the authentication mechanism, check the _POST; if ($this->checkPOST(new S('submit_log_in'))->toBoolean() == TRUE) { // ELSE ... go authenticate us ... if ($this->doLogIn($this->getPOST(new S('user_username')), $this->getPOST(new S('user_password')))->toBoolean() == TRUE) { // Set the proper POST ... $this->setPOST(self::$objAuthUsersTableFIp, new S($_SERVER['REMOTE_ADDR'])); // Make and auto-executing form ... $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId($this->getUserInfoByName($this->getPOST(new S('user_username')), self::$objAuthUsersTableFId))->setUpdateField(self::$objAuthUsersTableFId)->setName($objFormToRender)->setInputType(new S('text'))->setName(self::$objAuthUsersTableFIp)->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); // Ok ... do nothin' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location')); } else { // Do an error, and retain the user; $this->setErrorOnInput(new S('user_username'), new S($objFA['log_in_failed'])); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setName($objFormToRender)->setInputType(new S('submit'))->setName(new S('submit_log_in'))->setValue(new S($objFA['log_in']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('user_username'))->setLabel(new S($objFA['log_in_username']))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('user_password'))->setLabel(new S($objFA['log_in_password']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'userSignUp': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(AUTHENTICATION_STATUS_URL)), new A(array(AUTHENTICATION_STATUS_OK_URL))); // Check if both password fields have been entered correctly; if ($this->checkPOST(new S('submit_signup'))->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_mandatory'])); } else { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_exists'])); } // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S($objFA['error_email_exists'])); } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S($objFA['error_passwords_do_not_match'])); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S($objFA['error_phone_ten_chars'])); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['form_signup']))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthUsersTableFId)->setExtraUpdateData(self::$objAuthUsersTableFRegOn, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAuthUsersTableFUGId, $objFA['default_group_id'])->setExtraUpdateData(self::$objAuthUsersTableFActivated, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit_signup'))->setValue(new S($objFA['form_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S($objFA['form_username']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S($objFA['form_password']))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setLabel(new S($objFA['form_password_confirm']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S($objFA['form_regexp_invalid_email']))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S($objFA['form_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S($objFA['form_phone']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S($objFA['form_last_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S($objFA['form_first_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S($objFA['form_country'])); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S($objFA['form_city']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S($objFA['form_ym']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S($objFA['form_msn']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S($objFA['form_icq']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S($objFA['form_aol']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S($objFA['form_description']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S($objFA['form_signature']))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Make them passwords OK ... if ($this->checkPOST()->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } $this->setExtraUpdateData(self::$objAuthUsersTableFHash, new S(sha1(md5($this->getPOST(self::$objAuthUsersTableFEML))))); // Send the activation EML ... $objEML = new MAIL(); $objEML->doMAIL($this->getPOST(self::$objAuthUsersTableFEML), $objFA['form_activation_subject'], $this->getHELP(new S('activationEMLMessage'))->doToken('%u', $this->getPOST(self::$objAuthUsersTableFUName))->doToken('%a', URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUTHENTICATION_ACTION_URL, AUTHENTICATION_HASH_URL)), new A(array(FRONTEND_AUTHENTICATION_URL, AUTHENTICATION_ACTIVATE_URL, sha1(md5($this->getPOST(self::$objAuthUsersTableFEML)))))))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userProfile': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(AUTHENTICATION_STATUS_URL)), new A(array(AUTHENTICATION_STATUS_OK_URL))); // Check if both password fields have been entered correctly; if ($this->checkPOST(new S('submit_signup'))->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_mandatory'])); } else { if ($this->getPOST(self::$objAuthUsersTableFUName) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFUName)) { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_exists'])); } } if ($this->getPOST(self::$objAuthUsersTableFEML) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFEML)) { // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S($objFA['error_email_exists'])); } } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S($objFA['error_passwords_do_not_match'])); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S($objFA['error_phone_ten_chars'])); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['form_signup']))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S($this->getCurrentUserInfoById(self::$objAuthUsersTableFId)))->setUpdateField(self::$objAuthUsersTableFId)->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setExtraUpdateData(self::$objAuthUsersTableFActivated, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit_signup'))->setValue(new S($objFA['form_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S($objFA['form_username']))->setReadOnly(new B(TRUE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S($objFA['form_password']))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setValue($this->getCurrentUserInfoById(self::$objAuthUsersTableFUPass))->setLabel(new S($objFA['form_password_confirm']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S($objFA['form_regexp_invalid_email']))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S($objFA['form_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S($objFA['form_phone']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S($objFA['form_last_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S($objFA['form_first_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S($objFA['form_country'])); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S($objFA['form_city']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S($objFA['form_ym']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S($objFA['form_msn']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S($objFA['form_icq']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S($objFA['form_aol']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S($objFA['form_avatar']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S($objFA['form_description']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S($objFA['form_signature']))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Make them passwords OK ... if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { // If they differ ... if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFUPass)) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } $this->setExtraUpdateData(self::$objAuthUsersTableFHash, new S(sha1(md5($this->getPOST(self::$objAuthUsersTableFEML))))); // Send the activation EML ... $objEML = new MAIL(); $objEML->doMAIL($this->getPOST(self::$objAuthUsersTableFEML), $objFA['form_activation_subject'], $this->getHELP(new S('activationEMLMessage'))->doToken('%u', $this->getPOST(self::$objAuthUsersTableFUName))->doToken('%a', URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUTHENTICATION_ACTION_URL, AUTHENTICATION_HASH_URL)), new A(array(FRONTEND_AUTHENTICATION_URL, AUTHENTICATION_ACTIVATE_URL, sha1(md5($this->getPOST(self::$objAuthUsersTableFEML)))))))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userCreate': // Set some predefines; $objURLToGoBack = URL::rewriteURL(); // Check if both password fields have been entered correctly; if ($this->checkPOST(self::$objAuthUsersTableFUName)->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_IS_MANDATORY)); } else { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_ALREADY_EXISTS)); } // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S(AUTHENTICATION_EMAIL_ALREADY_EXISTS)); } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S(AUTHENTICATION_USER_PASSWORDS_DONT_MATCH)); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S(AUTHENTICATION_PHONE_TEN_CHARS)); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_PROFILE_ADD))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthUsersTableFId)->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setExtraUpdateData(self::$objAuthUsersTableFRegOn, new S((string) $_SERVER['REQUEST_TIME'])); if ($this->checkPOST(self::$objAuthUsersTableFUName)->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_PROFILE_ADD))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD_CONFIRM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S(AUTHENTICATION_INVALID_EMAIL))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S(AUTHENTICATION_PROFILE_PHONE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S(AUTHENTICATION_PROFILE_LAST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S(AUTHENTICATION_PROFILE_FIRST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S(AUTHENTICATION_PROFILE_COUNTRY)); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S(AUTHENTICATION_PROFILE_CITY))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFUGId)->setLabel(new S(AUTHENTICATION_PROFILE_GROUP)); // Get the groups of the user; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['id'])->setValue($v['id'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S(AUTHENTICATION_PROFILE_YM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S(AUTHENTICATION_PROFILE_MSN))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S(AUTHENTICATION_PROFILE_ICQ))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S(AUTHENTICATION_PROFILE_AOL))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S(AUTHENTICATION_PROFILE_AVATAR))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S(AUTHENTICATION_PROFILE_DESCRIPTION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S(AUTHENTICATION_PROFILE_SIGNATURE))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userEdit': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if both password fields have been entered correctly; if ($this->checkPOST()->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_IS_MANDATORY)); } // Check password mismatch; if ($this->getPOST(self::$objAuthUsersTableFUPass) == $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass) && $this->getPOST(new S('confirmation_password')) == $this->getPOST(self::$objAuthUsersTableFUPass)) { // Unset ... $this->unsetPOST(self::$objAuthUsersTableFUPass); } else { if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S(AUTHENTICATION_USER_PASSWORDS_DONT_MATCH)); } } // Check phone number has 10 chars, only if it's required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S(AUTHENTICATION_PHONE_TEN_CHARS)); } } } // Get AJAX; $this->getAjaxErrors(); // Make the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_PROFILE_EDIT))->setSQLAction(new S('update'))->setUpdateId($_GET[ADMIN_ACTION_ID])->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setTableName(self::$objAuthUsersTable)->setUpdateField(self::$objAuthUsersTableFId)->setAJAXEnabledForm(new B(FALSE))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_PROFILE_EDIT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE)); // ONLY if we're NOT the BIG MAN, we cand de-activate; if ((int) $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFId)->toString() != 1) { $this->setInputType(new S('select'))->setName(self::$objAuthUsersTableFActivated)->setContainerDiv(new B(TRUE))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED_NO)); } $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setValue($this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setValue($this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD_CONFIRM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setContainerDiv(new B(TRUE))->setRegExpType(new S('preg'))->setRegExpErrMsg(new S(AUTHENTICATION_INVALID_EMAIL))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S(AUTHENTICATION_PROFILE_PHONE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S(AUTHENTICATION_PROFILE_LAST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S(AUTHENTICATION_PROFILE_FIRST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S(AUTHENTICATION_PROFILE_COUNTRY)); // Countries ... foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue ... $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S(AUTHENTICATION_PROFILE_CITY))->setContainerDiv(new B(TRUE)); // ONLY if we're not the BIG MAN, can we change the group; if ((int) $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFId)->toString() != 1) { $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFUGId)->setLabel(new S(AUTHENTICATION_PROFILE_GROUP)); foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['id'])->setValue($v['id'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } } // Execute the form, make it happen; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S(AUTHENTICATION_PROFILE_YM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S(AUTHENTICATION_PROFILE_MSN))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S(AUTHENTICATION_PROFILE_ICQ))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S(AUTHENTICATION_PROFILE_AOL))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S(AUTHENTICATION_PROFILE_AVATAR))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S(AUTHENTICATION_PROFILE_DESCRIPTION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S(AUTHENTICATION_PROFILE_SIGNATURE))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if it's administrator user, and don't delete it; if ((int) $_GET[ADMIN_ACTION_ID]->toString() == 1) { // Do not permit the deletion of the administrator user; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_ADMINISTRATOR_USER), $objURLToGoBack); } else { // Check to see if there are any zone mappings, for the current zone; if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFUGId = "%Id" AND %objAuthZoneMTableFIUG = "N"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // Do not delete users that have specific mappings; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_MAPPED_USERS), $objURLToGoBack); } else { // Go further ... and erase the user ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthUsersTable)->doToken('%condition', new S('%objAuthUsersTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } break; case 'userSearch': // Get some predefines; if (isset($_GET[ADMIN_ACTION_SEARCH])) { $objSearchWas = $_GET[ADMIN_ACTION_SEARCH]; } else { $objSearchWas = new S(); } if (isset($_GET[ADMIN_ACTION_BY])) { $objSearchBy = $_GET[ADMIN_ACTION_BY]; } else { $objSearchBy = new S(); } // Do some work; if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) { if ($this->getPOST(new S('search_user_by'))->toLength()->toInt() == 0) { if (isset($_GET[ADMIN_ACTION_SEARCH])) { // Erase search terms ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location')); } // Set an error, notify me ... $this->setErrorOnInput(new S('search_user_by'), new S(AUTHENTICATION_SEARCH_FIELD_IS_EMPTY)); // Unset the post ... $this->unsetPOST(); } else { // Get what to search and where ... $objWhatToSearch = $this->getPOST(new S('search_user_by')); $objWhereToSearch = $this->getPOST(new S('search_user_field')); // And go there ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location')); } } $objWasSelected = new A(array(new B($objSearchBy == AUTHENTICATION_PROFILE_USERNAME ? TRUE : FALSE), new B($objSearchBy == AUTHENTICATION_PROFILE_EMAIL ? TRUE : FALSE), new B($objSearchBy == AUTHENTICATION_PROFILE_GROUP ? TRUE : FALSE))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_SEARCH_USER_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_user_by'))->setvalue($objSearchWas)->setLabel(new S(AUTHENTICATION_SEARCH_USER_BY))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_user_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(AUTHENTICATION_SEARCH_USER_IN))->setInputType(new S('option'))->setName(new S('username_search'))->setValue(new S(AUTHENTICATION_PROFILE_USERNAME))->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('email_search'))->setValue(new S(AUTHENTICATION_PROFILE_EMAIL))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setSelected($objWasSelected[1])->setInputType(new S('option'))->setName(new S('group_serach'))->setValue(new S(AUTHENTICATION_PROFILE_GROUP))->setLabel(new S(AUTHENTICATION_PROFILE_GROUP))->setSelected($objWasSelected[2])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_SEARCH_USER_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE)); break; case 'groupCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work ... if ($this->checkPOST(new S('categories_show_all'))->toBoolean() == TRUE) { // Redirect to proper ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SHOW_ALL)), new A(array('1'))), new S('Location')); } // Do some work; if ($this->checkPOST(new S('submit_add_group'))->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); if ($this->getPOST(new S('group'))->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(new S('group'), new S(GROUP_NAME_CANNOT_BE_EMPTY)); // Set to memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($this->getPOST(new S('group')))->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(new S('group'), new S(GROUP_ALREADY_EXISTS)); // Set to memory; $objFormHappened->switchType(); } } // Get AJAX; $this->getAjaxErrors(); if ($objFormHappened->toBoolean() == FALSE) { // Remember if we should add it as a brother or child; $objAddNodeAS = NULL; // Switch ... switch ($this->getPOST(new S('group_as_what'))) { case AUTHENTICATION_GROUP_CHILD: $objAddNodeAS = new S((string) MPTT::FIRST_CHILD); break; case AUTHENTICATION_GROUP_LAST_CHILD: $objAddNodeAS = new S((string) MPTT::LAST_CHILD); break; case AUTHENTICATION_GROUP_BROTHER: $objAddNodeAS = new S((string) MPTT::PREVIOUS_BROTHER); break; case AUTHENTICATION_GROUP_NEXT_BROTHER: $objAddNodeAS = new S((string) MPTT::NEXT_BROTHER); break; } // Add the node; self::$objMPTT->mpttAddNode($this->getPOST(new S('group')), $this->getPOST(new S('group_parent_or_bro')), $objAddNodeAS); // Do a redirect back; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(ADD_NEW_GROUP_OF_USERS))->setName(new S($objFormToRender))->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('categories_show_all'))->setValue(new S(AUTHENTICATION_SHOW_ALL_CATEGORIES))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setName(new S('submit_add_group'))->setValue(new S(AUTHENTICATION_ADD_GROUP))->setInputType(new S('text'))->setContainerDiv(new B(TRUE))->setName(new S('group'))->setLabel(new S(AUTHENTICATION_GROUP_NAME_LABEL))->setRegExpType(new S('ereg'))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('group_as_what'))->setLabel(new S(AUTHENTICATION_AS_A))->setInputType(new S('option'))->setName(new S('as_child'))->setLabel(new S(AUTHENTICATION_GROUP_CHILD))->setInputType(new S('option'))->setName(new S('as_child'))->setLabel(new S(AUTHENTICATION_GROUP_LAST_CHILD))->setInputType(new S('option'))->setName(new S('as_brother'))->setLabel(new S(AUTHENTICATION_GROUP_BROTHER))->setInputType(new S('option'))->setName(new S('as_brother'))->setLabel(new S(AUTHENTICATION_GROUP_NEXT_BROTHER))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('group_parent_or_bro'))->setLabel(new S(AUTHENTICATION_OF_GROUP)); // Do a foreach on the already existing groups; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['name'])->setValue($v['name'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } // Execute the form; $this->setFormEndAndExecute(new B(TRUE)); break; case 'groupEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do validation and error on it if something goes wrong; if ($this->checkPOST(self::$objAuthGroupTableFName)->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); if ($this->getPOST(self::$objAuthGroupTableFName)->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(self::$objAuthGroupTableFName, new S(GROUP_NAME_CANNOT_BE_EMPTY)); // Set to memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($this->getPOST(self::$objAuthGroupTableFName))->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(self::$objAuthGroupTableFName, new S(GROUP_ALREADY_EXISTS)); // Set to memory; $objFormHappened->switchType(); } } // Get AJAX; $this->getAjaxErrors(); } else { // Set some requirements; $objFormHappened = new B(FALSE); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objAuthGroupTable)->setUpdateField(self::$objAuthGroupTableFId)->setUpdateId($_GET[ADMIN_ACTION_ID]); if ($this->checkPOST(self::$objAuthGroupTableFName)->toBoolean() == TRUE && $objFormHappened->toBoolean() == FALSE) { // Set the URL ... $this->setExtraUpdateData(self::$objAuthGroupTableFSEO, URL::getURLFromString($this->getPOST(self::$objAuthGroupTableFName)))->setRedirect($objURLToGoBack); } // Continue ... $this->setFieldset(new S(AUTHENTICATION_EDIT_GROUP))->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_EDIT_GROUP))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(self::$objAuthGroupTableFName)->setLabel(new S(AUTHENTICATION_GROUP_NAME_LABEL))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setFormEndAndExecute(new B(TRUE)); break; case 'groupErase': // The URL to go back too; $objNodeHasKids = new B(FALSE); $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if it's administrator group; if ((int) $_GET[ADMIN_ACTION_ID]->toString() == 1) { // Show the ERRORs; self::$objAdministration->setErrorMessage(new S(CANNOT_ERASE_AUTHENTICATION_GROUP), $objURLToGoBack); } else { // Check to see if there are any zone mappings; if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFUGId = "%Id" AND %objAuthZoneMTableFIUG = "Y"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // Do not delete groups with users in them; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_MAPPED_GROUPS), $objURLToGoBack); } else { // Do erase the group node from the table; self::$objMPTT->mpttRemoveNode($this->getGroupInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthGroupTableFName)); // Redirect back; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } // BK; break; case 'groupMove': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_TO, ADMIN_ACTION_TYPE))); // Get names, as they are unique; $objThatIsMoved = $this->getGroupInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthGroupTableFName); $objWhereToMove = $this->getGroupInfoById($_GET[ADMIN_ACTION_TO], self::$objAuthGroupTableFName); // Get the node subtree, that's move, make sure the node we move to ain't a child; $objMovedNodeSubTree = self::$objMPTT->mpttGetTree($objThatIsMoved); // Memorize; $objIsChild = new B(FALSE); foreach ($objMovedNodeSubTree as $k => $v) { if ($v[self::$objMPTT->objNameOfNode] == $objWhereToMove) { $objIsChild->switchType(); } } // Check if it's a child or not; if ($objIsChild->toBoolean() == TRUE) { // Set an error message; self::$objAdministration->setErrorMessage(new S(AUTHENTICATION_GROUP_MOVED_TO_CHILD), $objURLToGoBack); } else { // Move nodes; self::$objMPTT->mpttMoveNode($objThatIsMoved, $objWhereToMove, $_GET[ADMIN_ACTION_TYPE]); $this->setHeaderKey($objURLToGoBack, new S('Location')); } break; case 'zoneCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { # Check that the zone name is not empty! if ($this->getPOST(self::$objAuthZonesTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAuthZonesTableFName, new S(AUTHENTICATION_ZONE_NAME_CANNOT_BE_EMPTY)); } // Get AJAX; $this->getAjaxErrors(); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ZONE))->setSQLAction(new S('update'))->setTableName(self::$objAuthZonesTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZonesTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_ADD_ZONE))->setInputInfoMessage($this->getHELP($objFormToRender))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFName)->setLabel(new S(AUTHENTICATION_ZONE_NAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ]'))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFPrice)->setLabel(new S(AUTHENTICATION_ZONE_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZonesTableFDesc)->setLabel(new S(AUTHENTICATION_ZONE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneEdit': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do some validation, beforehand; if ($this->checkPOST()->toBoolean() == TRUE) { if ($this->checkPOST(self::$objAuthZonesTableFName)->toBoolean() == TRUE) { // Check that the zone name is not empty! if ($this->getPOST(self::$objAuthZonesTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAuthZonesTableFName, new S(AUTHENTICATION_ZONE_NAME_CANNOT_BE_EMPTY)); } } // Get AJAX; $this->getAjaxErrors(); } // Add some restrictions ... if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFZId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // The name should not be changed, due to mapping; $objNameChangeDisabled = new B(TRUE); } else { // The name can be changed; $objNameChangeDisabled = new B(FALSE); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_EDIT_ZONE))->setSQLAction(new S('update'))->setTableName(self::$objAuthZonesTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAuthZonesTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_EDIT_ZONE))->setInputInfoMessage($this->getHELP($objFormToRender))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFName)->setLabel(new S(AUTHENTICATION_ZONE_NAME))->setContainerDiv(new B(TRUE))->setReadOnly($objNameChangeDisabled)->setJSRegExpReplace(new S('[^a-zA-Z0-9 .]'))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFPrice)->setLabel(new S(AUTHENTICATION_ZONE_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthZonesTableFDesc)->setLabel(new S(AUTHENTICATION_ZONE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check to see if there are any zone mappings, for the current zone; $objSQLCondition = new S('WHERE %s = %i'); // Erase it; $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthZonesTable)->doToken('%condition', new S('%objAuthZonesTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Redirect the user back; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'zoneMappingCreateForGroups': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZoneMTableFId)->setExtraUpdateData(self::$objAuthZoneMTableFIUG, new S('Y'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_ADD_ACL))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFUGId)->setLabel(new S(AUTHENTICATION_ACL_ENTITY)); // Get the groups; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthGroupTableFId])->setValue($v[self::$objAuthGroupTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthGroupTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFZId)->setLabel(new S(AUTHENTICATION_ZONE_NAME)); // Get the zones; foreach ($this->getZones(NULL) as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthZonesTableFId])->setValue($v[self::$objAuthZonesTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthZonesTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingCreateForUsers': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZoneMTableFId)->setExtraUpdateData(self::$objAuthZoneMTableFIUG, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(AUTHENTICATION_ADD_ACL))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFUGId)->setLabel(new S(AUTHENTICATION_ACL_ENTITY)); // Get the users; foreach ($this->getUsers() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthUsersTableFId])->setValue($v[self::$objAuthUsersTableFId])->setLabel($v[self::$objAuthUsersTableFUName]); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFZId)->setLabel(new S(AUTHENTICATION_ZONE_NAME)); // Get zones; foreach ($this->getZones(NULL) as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthZonesTableFId])->setValue($v[self::$objAuthZonesTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthZonesTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_EDIT_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAuthZoneMTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_EDIT_ACL))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Erase it; $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('%objAuthZoneMTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'configurationEdit': // Set some requirements; $objURLToGoBack = URL::rewriteURL(); // Do form validation; if ($this->checkPOST()->toBoolean() == TRUE) { // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what'))))); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S('Do'))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S('Choose'))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-register_page_content'))->setValue(new S('configurationEdit-register_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_CONTENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-register_ok_page_content'))->setValue(new S('configurationEdit-register_ok_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_SUCCESS_CONTENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-activation_page_content'))->setValue(new S('configurationEdit-activation_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_ACTIVATE_CONTENT))->setInputType(new S('option'))->setName(new S('configurationEdit-activation_not_ok_page_content'))->setValue(new S('configurationEdit-activation_not_ok_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_ACTIVATE_NOTOK))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-register_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_register_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_register_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-register_ok_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_register_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_register_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-activation_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_activation_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_activation_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-activation_not_ok_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_activation_not_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_activation_not_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; } }
/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case 'widgetXML': // Yo man ... woohoooooo ... foreach ($this->getTexts(new S('ORDER BY %objTextTableFDatePublished DESC')) as $k => $v) { // Set some requirements ... $objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO); $objDTE = date('Y-m-d', (int) $v[self::$objTextTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC))); // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL); // Set the XML Sitemap kids ... $objURL->addCHILD(Frontend::XML_LOCATION, $objLOC); $objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE); $objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY); $objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY); } // BK; break; case 'widgetRSS': // Yo man ... woohoooooo ... if ($_GET[FRONTEND_FEED_URL] == __CLASS__) { // Get'em 30 ... foreach ($this->getTexts(new S('ORDER BY %objTextTableFDatePublished DESC LIMIT 0, 30')) as $k => $v) { // Set some requirements ... $objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO); $objDTE = date(DATE_RFC822, (int) $v[self::$objTextTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC))); $objDSC = $v[self::$objTextTableFContent]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags(); $objTTL = $v[self::$objTextTableFTitle]; // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM); // Set the RSS kids ... $objURL->addCHILD(Frontend::RSS_TITLE, $objTTL); $objURL->addCHILD(Frontend::RSS_LINK, $objLOC); $objURL->addCHILD(Frontend::RSS_GUID, $objLOC); $objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE); $objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC); } } // BK; break; } // HTML: Do a switch ... switch ($objW) { case 'widgetCategoryList': // Set some requirements, if not set ... if ($objWA == NULL) { $objWA = new A(); } // Get the category to start from ... if (isset($objWA['start_from_category'])) { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']); } else { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, NULL); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); break; case 'widgetList': // Do some checking ... before anything ... if (isset($_GET[TEXTS_TEXTS_URL])) { // Check or redirect ... if ($this->checkTextExistsByURL($_GET[TEXTS_TEXTS_URL])->toBoolean() == FALSE) { // The text does not exist, than redirect to 404; $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Get the TEXT ... $objTextCNT = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFContent); $objTextTTL = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTitle); $objTextKEY = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTags); $objTextDSC = clone $objTextTTL; // Set the title, keywords, description ... TPL::manageTTL($objTextTTL); TPL::manageTAG(new S('keywords'), $objTextKEY->entityEncode(ENT_QUOTES)); TPL::manageTAG(new S('description'), $objTextDSC->entityEncode(ENT_QUOTES)); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item' . TPL_EXTENSION); TPL::tpSet($objTextTTL, new S('objTextTTL'), $tpF); TPL::tpSet($objTextCNT, new S('objTextCNT'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); } } else { // Get the CATEGORY ... if ($this->checkCategoryExistsByURL($_GET[FRONTEND_SECTION_URL])->toBoolean() == FALSE) { // The category does not exist, than redirect to 404; $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Get something from db ... $objCategoryArray = $this->getTextsByCategoryURL($_GET[FRONTEND_SECTION_URL]); // Check how many texts are defined for it ... switch ($objCategoryArray->doCount()->toInt()) { // If we have only ONE text, defined for a category, // we then recommend moving to that text ... case 1: // MOVED ... permanently ... $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::rewriteURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($objCategoryArray[0][self::$objTextTableFSEO], $_GET[FRONTEND_SECTION_URL]))), new S('Location')); break; // In case we don't have any text defined, // we recommend showing a default message. // In case we don't have any text defined, // we recommend showing a default message. case 0: break; // And finally, if we have more than one, then // we recommend showing a LIST, by default reversed ... // And finally, if we have more than one, then // we recommend showing a LIST, by default reversed ... default: // Set the title, keywords, description ... TPL::manageTTL($objCategoryNME = $this->getCategoryInfoByURL($objCategoryURL = $_GET[FRONTEND_SECTION_URL], self::$objCategoryTableFName)); TPL::manageTAG(new S('description'), $objCategoryNME); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCategoryArray->arrayReverse(), new S('objCategoryArray'), $tpF); TPL::tpSet($objCategoryURL, new S('objCategory'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); break; } } } // Break out ... break; case 'widgetComments': // Check if we have the proper URL enabled ... if (isset($_GET[TEXTS_TEXTS_URL])) { // Check if the comments are enabled ... if ($this->getTextInfoByURL($objURL = $_GET[TEXTS_TEXTS_URL], self::$objTextTableFCanComment) == 'Y') { // Set some requirements ... $objCommentIsOk = new S(); $objComments = $this->getApprovedCommentsByTextURL($_GET[TEXTS_TEXTS_URL], new S('ORDER BY %objCommentsTableFDate DESC')); // Check for status ... if (isset($_GET[TEXTS_STATUS_URL])) { if ($_GET[TEXTS_STATUS_URL] == TEXTS_STATUS_OK_URL) { $objCommentIsOk = new S($objWA['comment_has_been_added']); } } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF); TPL::tpSet($objComments, new S('objComments'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpExe($tpF); // Set some requirements ... $objShowFrm = new B(TRUE); // Check if we're allowed to show the comment form ... if ($this->getConfigKey(new S('texts_settings_authenticated_to_comment')) == 'Y') { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { $objShowFrm = new B(TRUE); } else { $objShowFrm = new B(FALSE); } } // Do some work ... if ($objShowFrm->toBoolean() == TRUE) { if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment'])); } } if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name'])); } } if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email'])); } } // Make the form ... (ya, outside the box ...); $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId); if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { $this->setRedirect(URL::rewriteURL(new A(array(TEXTS_STATUS_URL)), new A(array(TEXTS_STATUS_OK_URL)))); } $this->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFTextId, $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE)); // Check if the user is authenticated ... if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Set the RUId; $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)); } else { // Set the other infos; $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE)); } // Continue ... $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setRows(new S('10'))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Query the authentication ... $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName); } else { // Or trust the FORM ... $objUSR = $this->getPOST(self::$objCommentsTableFName); } // Go and SP ... MAIL me ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(TEXTS_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsEMLNotifyAdmin'))->doToken('%u', $objUSR)); // Go deeper and notify them users ... $objCommentsForItem = $this->getCommentsByTextURL($objURL); foreach ($objCommentsForItem as $k => $v) { $objMAIL = new MAIL(); $objMAIL->doMAIL($this->ATH->getUserInfoById($v[Texts::$objCommentsTableFRUId], Authentication::$objAuthUsersTableFEML), new S(TEXTS_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsEMLNotifyUsers'))->doToken('%u', $objUSR)->doToken('%k', URL::rewriteURL())); } } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); } } } // Break out ... break; } }
/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case AUTHENTICATION_YAHOO_BB_AUTH: require_once DOCUMENT_ROOT . _S . PLUGIN_DIR . _S . 'yahoo/ybrowserauth.class.php'; $authObj = new YBBauthREST(APPID, SECRET); $objA = PARSE_URL($_SERVER['REQUEST_URI']); if (isset($objA['query'])) { $objAuthURL = new S(); $objUserYML = new B(TRUE); parse_str($objA['query'], $objQ); $authObj->token = $objQ['token']; $objPath = 'http://address.yahooapis.com/api/ws/v1/searchContacts?format=xml'; $xmlstr = $authObj->makeAuthWSgetCall($objPath); $xml = new SimpleXMLElement($xmlstr); $i = 0; $objARM = new A(); foreach ($xml->contact as $contact) { $objARM[$i] = new S((string) $contact->yahooid); if ($objARM[$i]->toLength()->toInt() != 0) { $objARM[$i] = $objARM[$i]; $i++; } } $objEML = new MAIL(); $objEML->setFrom(new S('24up! <*****@*****.**>')); foreach ($objARM as $k => $v) { $objEML->doMAIL(new S($v . '@yahoo.com'), new S(FRONTEND_YAHOO_MAIL_SUBJECT), $this->getHELP(new S('widgetYahooInviteEMAIL'))); } } else { $objAuthURL = new S($authObj->getAuthURL('yahoo_auth_invite', true)); $objUserYML = new B(FALSE); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-yahoo-invite.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($objUserYML, new S('objUserYML'), $tpF); TPL::tpSet($objAuthURL, new S('objAuthURL'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpExe($tpF); // TEMP fix; return TRUE; break; } }