예제 #1
0
     // Dates management
     $dt_beg = new CMS_date();
     $dt_beg->setDebug(false);
     $dt_beg->setFormat($cms_language->getDateFormat());
     $dt_end = new CMS_date();
     $dt_end->setDebug(false);
     $dt_end->setFormat($cms_language->getDateFormat());
     if (!($dt_set_1 = $dt_beg->setLocalizedDate($pubStart, true))) {
         $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_PUBDATE_BEG)));
     }
     if (!($dt_set_2 = $dt_end->setLocalizedDate($pubEnd, true))) {
         $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_PUBDATE_END)));
     }
     //if $dt_beg && $dt_end, $dt_beg must be lower than $dt_end
     if (!$dt_beg->isNull() && !$dt_end->isNull()) {
         if (CMS_date::compare($dt_beg, $dt_end, '>')) {
             $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_PUBDATE_BEG)));
             $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_PUBDATE_END)));
             $dt_set_1 = $dt_set_2 = false;
         }
     }
     if ($dt_set_1 && $dt_set_2) {
         $item->setPublicationDates($dt_beg, $dt_end);
     }
 }
 if (!$cms_message) {
     //save the data
     if (!$item->writeToPersistence(true, $action == 'save')) {
         $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_WRITETOPERSISTENCE);
     }
     if (!$cms_message) {
예제 #2
0
//CHECKS user has admin clearance
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    CMS_grandFather::raiseError('User has no administration rights');
    echo $cms_language->getMessage(MESSAGE_PAGE_NO_SERVER_RIGHTS);
    exit;
}
$date = sensitiveIO::request('date');
$errorFile = '';
$gzip = false;
$now = new CMS_date();
$now->setNow(true);
$requestedDate = new CMS_date();
$requestedDate->setFormat($cms_language->getDateFormat());
$requestedDate->setLocalizedDate($date);
if (!$requestedDate->hasError()) {
    if (CMS_date::compare($requestedDate, $now, '==')) {
        $errorFile = PATH_MAIN_FS . '/' . CMS_grandFather::ERROR_LOG;
    } else {
        $gzip = true;
        $requestedDate->moveDate('+1 day');
        $errorFile = PATH_LOGS_FS . '/' . CMS_grandFather::ERROR_LOG . '-' . $requestedDate->getLocalizedDate('Y-m-d') . '.gz';
    }
}
if ($errorFile && file_exists($errorFile)) {
    if (connection_status() == 0) {
        //close session then clean buffer
        session_write_close();
        ob_end_clean();
        //to prevent long file from getting cut off from max_execution_time
        @set_time_limit(0);
        if ($gzip) {
예제 #3
0
 //Resource related informations
 $htmlStatus = $pubRange = '';
 $lock = $deleted = $published = $unpublished = false;
 if ($object->isPrimaryResource()) {
     $status = $item->getStatus();
     if (is_object($status)) {
         $htmlStatus = $status->getHTML(false, $cms_user, $codename, $item->getID());
         $pubRange = $status->getPublicationRange($cms_language, false);
         $lock = $item->getLock();
         $deleted = $item->getProposedLocation() == RESOURCE_LOCATION_DELETED;
     }
     $endPublication = $item->getPublicationDateEnd(false);
     $now = new CMS_date();
     $now->setNow();
     $published = $item->getPublication() == RESOURCE_PUBLICATION_PUBLIC && ($endPublication->isNull() || CMS_date::compare($endPublication, $now, '>'));
     $unpublished = $item->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && !$endPublication->isNull() && CMS_date::compare($endPublication, $now, '<=');
 }
 //Previz
 $previz = $object->getValue("previewURL") ? $item->getPrevizPageURL() : '';
 //Edit
 $edit = false;
 if (!$deleted && (!$lock || $lock == $cms_user->getUserId())) {
     $edit = array('module' => $codename, 'objectId' => $objectId, 'item' => $item->getID());
 }
 //HTML description
 $description = POLYMOD_DEBUG ? '<span class="atm-text-alert"> (ID : ' . $item->getID() . ')</span>' : '';
 if ($resultsDefinition) {
     //set execution parameters
     $parameters = array();
     $parameters['module'] = $codename;
     $parameters['objectID'] = $object->getID();
예제 #4
0
             if ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && $editions & RESOURCE_EDITION_CONTENT) {
                 $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-editions-cancelling',\n\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.setActiveTab('public');\n\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'cancel_editions'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
             }
             if ($editions & RESOURCE_EDITION_CONTENT && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME)) {
                 //validate
                 $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION_MODIFICATIONS) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-validate',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call('validations-controler.php', function(response, options, jsonResponse){\n\t\t\t\t\t\t\t\t\t\t\tif (!jsonResponse.success) {\n\t\t\t\t\t\t\t\t\t\t\t\t//get validation message\n\t\t\t\t\t\t\t\t\t\t\t\tif (response.responseXML && response.responseXML.getElementsByTagName('message').length) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar message = response.responseXML.getElementsByTagName('message').item(0).firstChild.nodeValue;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'validateById',\n\t\t\t\t\t\t\t\t\t\t\tresource:\t\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t\t'" . MOD_STANDARD_CODENAME . "',\n\t\t\t\t\t\t\t\t\t\t\tevalMessage:\t\tfalse\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
             }
             $endPublication = $cms_page->getPublicationDateEnd(false);
             $now = new CMS_date();
             $now->setNow();
             if ($cms_page->getPublication() == RESOURCE_PUBLICATION_PUBLIC && ($endPublication->isNull() || CMS_date::compare($endPublication, $now, '>'))) {
                 if (!$cms_page->isProtected()) {
                     //unpublish
                     $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unpublish',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'unpublish'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));";
                 }
             } elseif ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && !$endPublication->isNull() && CMS_date::compare($endPublication, $now, '<=')) {
                 //publish
                 $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-publish',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'publish'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
             }
             if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $cms_page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
                 //regenerate
                 $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_REGEN_DESC) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_REGENERATE) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-scripts',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'regenerate'\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
             }
             //separator
             $panelContent .= "'-'" . $pageDraft;
         }
     }
 } elseif ($cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) {
     //if user has page edition rights somewhere
     if ($cms_user->hasEditablePages()) {
         //page copy
예제 #5
0
 } else {
     $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING);
     $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update pageMetas');
 }
 $dt_beg = new CMS_date();
 $dt_beg->setDebug(false);
 $dt_beg->setFormat($cms_language->getDateFormat());
 $dateStart = $cms_page->getPublicationDateStart(false);
 $dt_end = new CMS_date();
 $dt_end->setDebug(false);
 $dt_end->setFormat($cms_language->getDateFormat());
 $dateEnd = $cms_page->getPublicationDateEnd(false);
 if ($dt_beg->setLocalizedDate($pubdatestart, false) && $dt_end->setLocalizedDate($pubdateend, true)) {
     //check if dates has changed
     if (!CMS_date::compare($dateStart, $dt_beg, '==') || !CMS_date::compare($dateEnd, $dt_end, '==')) {
         if (!$dt_end->isNull() && CMS_date::compare($dt_beg, $dt_end, '>')) {
             $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_DATES);
             $cms_page->raiseError('Error during set pubdatestart : date start is higher than date end. Values set for date start : ' . $pubdatestart . ', for date end : ' . $pubdateend);
         } else {
             $cms_page->setPublicationDates($dt_beg, $dt_end);
             if ($cms_page->writeToPersistence()) {
                 $edited = RESOURCE_EDITION_BASEDATA;
                 $logAction = CMS_log::LOG_ACTION_RESOURCE_EDIT_BASEDATA;
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
             } else {
                 $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING);
                 $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update pubdatestart, value : ' . $pubdatestart);
             }
         }
     }
 } else {
예제 #6
0
 /**
  * Adjust the publication status according to publication dates.
  *
  * @return void
  * @access public
  */
 protected function _adjustPublication()
 {
     $now = new CMS_date();
     $now->setNow(true);
     //set public if validated and into the "window" of publication and located inside userspace
     if ($this->_publication == RESOURCE_PUBLICATION_VALIDATED && CMS_date::compare($this->_publicationDateStart, $now, "<=") && (CMS_date::compare($this->_publicationDateEnd, $now, ">=") || $this->_publicationDateEnd->isNull()) && $this->_location == RESOURCE_LOCATION_USERSPACE) {
         $this->_publication = RESOURCE_PUBLICATION_PUBLIC;
         if ($this->_id) {
             $this->writeToPersistence();
         }
     }
     //set validated if public and no validation pending on basedata and out of the "window" of publication or located outside userspace
     if ($this->_publication == RESOURCE_PUBLICATION_PUBLIC && $this->_editions != RESOURCE_EDITION_BASEDATA && (CMS_date::compare($this->_publicationDateStart, $now, ">") || CMS_date::compare($this->_publicationDateEnd, $now, "<") && !$this->_publicationDateEnd->isNull())) {
         $this->_publication = RESOURCE_PUBLICATION_VALIDATED;
         if ($this->_id) {
             $this->writeToPersistence();
         }
     }
 }
 /**
  * This function is called to catch and launch all FE forms actions
  *
  * @param array $formIDs : the forms ids to check for actions
  * @param integer $pageID : the current page id
  * @param boolean $public : the data status
  * @param string $languageCode : the language code used
  * @param reference array $polymodFormsError : the forms error status to return
  * @param reference array $polymodFormsItem : reference to the forms item
  * @return boolean : true on success, false on failure
  * @access public
  * @static
  */
 static function formActions($formIDs, $pageID, $languageCode, $public, &$polymodFormsError, &$polymodFormsItems)
 {
     global $cms_language, $cms_user;
     if (!is_array($formIDs)) {
         return false;
     }
     foreach ($formIDs as $formID) {
         if (io::request('formID') && io::request('formID') == $formID) {
             if (!isset($cms_language) || $cms_language->getCode() != $languageCode) {
                 $cms_language = new CMS_language($languageCode);
             }
             //instanciate item
             $item = '';
             if (io::request('object', 'io::isPositiveInteger', '')) {
                 //check user rights on module
                 $module = CMS_poly_object_catalog::getModuleCodenameForObjectType(io::request('object'));
                 //Check user rights
                 //here assume than user should only need the view right on module, because admin right allow Automne administration access
                 if (!is_object($cms_user) || !$cms_user->hasModuleClearance($module, CLEARANCE_MODULE_VIEW)) {
                     CMS_grandFather::raiseError('No user found or user has no administration rights on module ' . $module);
                     return false;
                 }
                 //instanciate object
                 $object = CMS_poly_object_catalog::getObjectDefinition(io::request('object'));
                 if ($object && io::request('item', 'io::isPositiveInteger', '')) {
                     $search = new CMS_object_search($object, false);
                     $search->addWhereCondition('item', io::request('item'));
                     $items = $search->search();
                     if (isset($items[io::request('item')])) {
                         $item = $items[io::request('item')];
                     } else {
                         $item = new CMS_poly_object($object->getID());
                     }
                 } else {
                     $item = new CMS_poly_object($object->getID());
                 }
             }
             if (is_object($item) && !$item->hasError()) {
                 //get item fieldsObjects
                 $fieldsObjects =& $item->getFieldsObjects();
                 //checks and assignments
                 $item->setDebug(false);
                 //first, check mandatory values
                 foreach ($fieldsObjects as $fieldID => $aFieldObject) {
                     //if field is part of formular
                     if (isset($_REQUEST['polymodFields'][$fieldID])) {
                         if (!$item->checkMandatory($fieldID, $_REQUEST, '')) {
                             $polymodFormsError[$formID]['required'][$fieldID] = $fieldID;
                         }
                     }
                 }
                 //second, set values for all fields
                 foreach ($fieldsObjects as $fieldID => $aFieldObject) {
                     //if field is part of formular
                     if (isset($_REQUEST['polymodFields'][$fieldID])) {
                         //if form use a callback, call it
                         //do not use call_user_function here
                         $funcName = 'form_' . $formID . '_' . $fieldID;
                         if (!$item->setValues($fieldID, $_REQUEST, '')) {
                             $polymodFormsError[$formID]['malformed'][] = $fieldID;
                         } elseif (!isset($polymodFormsError[$formID]['required'][$fieldID]) && function_exists('form_' . $formID . '_' . $fieldID) && !$funcName($formID, $fieldID, $item)) {
                             $polymodFormsError[$formID]['malformed'][] = $fieldID;
                         }
                     }
                 }
                 //set publication dates if needed
                 if (isset($_REQUEST['polymodFields']) && $_REQUEST['polymodFields']) {
                     if ($object->isPrimaryResource()) {
                         // Dates management
                         $dt_beg = new CMS_date();
                         $dt_beg->setDebug(false);
                         $dt_beg->setFormat($cms_language->getDateFormat());
                         $dt_end = new CMS_date();
                         $dt_end->setDebug(false);
                         $dt_end->setFormat($cms_language->getDateFormat());
                         if (!($dt_set_1 = $dt_beg->setLocalizedDate(@$_REQUEST["pub_start"], true))) {
                             $polymodFormsError[$formID]['malformed'][] = 'pub_start';
                         }
                         if (!($dt_set_2 = $dt_end->setLocalizedDate(@$_REQUEST["pub_end"], true))) {
                             $polymodFormsError[$formID]['malformed'][] = 'pub_end';
                         }
                         //if $dt_beg && $dt_end, $dt_beg must be lower than $dt_end
                         if (!$dt_beg->isNull() && !$dt_end->isNull()) {
                             if (CMS_date::compare($dt_beg, $dt_end, '>')) {
                                 $polymodFormsError[$formID]['malformed'][] = 'pub_start';
                                 $polymodFormsError[$formID]['malformed'][] = 'pub_end';
                                 $dt_set_1 = $dt_set_2 = false;
                             }
                         }
                         if ($dt_set_1 && $dt_set_2) {
                             $item->setPublicationDates($dt_beg, $dt_end);
                         }
                     }
                 }
                 //Check form token
                 if (!isset($_POST["atm-token"]) || !CMS_session::checkToken(MOD_POLYMOD_CODENAME . '-' . $formID, $_POST["atm-token"])) {
                     $polymodFormsError[$formID]['error'][] = 'form-token';
                     return false;
                 } else {
                     //Token is used so expire it
                     CMS_session::expireToken(MOD_POLYMOD_CODENAME . '-' . $formID);
                 }
                 if (!$polymodFormsError[$formID]) {
                     //save the data
                     if (!$item->writeToPersistence()) {
                         $polymodFormsError[$formID]['error'][] = 'write';
                         $polymodFormsError[$formID]['filled'] = 0;
                     } else {
                         $polymodFormsError[$formID]['filled'] = 1;
                         //if form use a callback, call it
                         //do not use call_user_function here
                         $funcName = 'form_' . $formID;
                         if (function_exists('form_' . $formID) && !$funcName($formID, $item)) {
                             $polymodFormsError[$formID]['filled'] = 0;
                             $polymodFormsError[$formID]['error'][] = 'callback';
                         }
                     }
                     //if item is a primary resource, unlock it
                     if ($object->isPrimaryResource()) {
                         $item->unlock();
                     }
                 } else {
                     $polymodFormsError[$formID]['filled'] = 0;
                 }
                 //save item for later use
                 $polymodFormsItems[$formID] = $item;
             } else {
                 $polymodFormsError[$formID]['filled'] = 0;
                 $polymodFormsError[$formID]['error'][] = 'right';
                 CMS_grandFather::raiseError('No item found or user has no administration rights on item... ');
                 return false;
             }
         }
     }
     return true;
 }
예제 #8
0
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_rss_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mord='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         $this->_ID = (int) $datas['id_mord'];
         $this->_objectValues["objectID"] = (int) $datas['object_id_mord'];
         $this->_objectValues["labelID"] = (int) $datas['label_id_mord'];
         $this->_objectValues["descriptionID"] = (int) $datas['description_id_mord'];
         $this->_objectValues["link"] = $datas['link_mord'];
         $this->_objectValues["author"] = $datas['author_mord'];
         $this->_objectValues["copyright"] = $datas['copyright_mord'];
         $this->_objectValues["namespaces"] = $datas['namespaces_mord'];
         $this->_objectValues["categories"] = $datas['categories_mord'];
         $this->_objectValues["ttl"] = (int) $datas['ttl_mord'];
         $this->_objectValues["email"] = $datas['email_mord'];
         $this->_objectValues["definition"] = $datas['definition_mord'];
         $this->_objectValues["compiledDefinition"] = $datas['compiled_definition_mord'];
         $this->_objectValues["lastCompilation"] = new CMS_date();
         $this->_objectValues["lastCompilation"]->setFromDBValue($datas['last_compilation_mord']);
         $this->_objectValues["uuid"] = isset($datas['uuid_mord']) ? $datas['uuid_mord'] : '';
     } else {
         $this->_objectValues["lastCompilation"] = new CMS_date();
     }
     //check for last compilation date (recompile Feed each day)
     if ($this->_objectValues["compiledDefinition"]) {
         $lastCompilation = $this->_objectValues["lastCompilation"];
         $lastCompilation->moveDate('+1 day');
         $today = new CMS_date();
         $today->setNow();
         if (CMS_date::compare($today, $lastCompilation, '>')) {
             $this->compileDefinition();
             $this->writeToPersistence();
         }
     }
 }