/**
  * Synchronizes an object with the database
  * @param $object object to be synchronized. It should already be persistent (had its id assigned)
  */
 function update($object)
 {
     // Set updated and updatedBy
     $isoDateFormat = new IsoDateFormat();
     $session = new Session();
     $date = Date::getTodayDate();
     $user = $session->getSessionUser();
     $object->setUpdated($isoDateFormat->toDatetimeString($date));
     $object->setUpdatedBy($user->getId());
     $persistence = $this->newPersistenceObject();
     $persistence->setProperty("ID", $object->getId());
     $persistence->setProperty("classID", $object->getClassID());
     $persistence->setProperty("created", $object->getCreated());
     $persistence->setProperty("createdBy", $object->getCreatedBy());
     $persistence->setProperty("endPublishing", $object->getEndPublishing());
     $persistence->setProperty("fullTextIndex", $object->getFullTextIndex());
     $persistence->setProperty("hits", $object->getHits());
     $persistence->setProperty("isPublished", $object->getIsPublished());
     $persistence->setProperty("startPublishing", $object->getStartPublishing());
     $persistence->setProperty("updated", $object->getUpdated());
     $persistence->setProperty("updatedBy", $object->getUpdatedBy());
     $persistence->update();
 }
Example #2
0
 /**
  * Executes the test
  */
 function execute()
 {
     $standardDateFormat = new StandardDateFormat();
     $usaDateFormat = new UsaDateFormat();
     $isoDateFormat = new IsoDateFormat();
     // Test parsing
     assert($standardDateFormat->parseDate("13/01/2005") != null);
     assert($standardDateFormat->parseDatetime("13/01/2005 23:20:30") != null);
     assert($usaDateFormat->parseDate("12/15/2005") != null);
     assert($usaDateFormat->parseDatetime("01/05/2005 10:20:30 PM") != null);
     assert($isoDateFormat->parseDate("2005-11-25") != null);
     assert($isoDateFormat->parseDatetime("2004-01-25 22:10:33") != null);
     // Test date object
     $date = $standardDateFormat->parseDatetime("15/01/2004 10:20:11");
     assert($date->getYear() == 2004);
     assert($date->getMonth() == 01);
     assert($date->getDay() == 15);
     assert($date->getHour() == 10);
     assert($date->getMinute() == 20);
     assert($date->getSecond() == 11);
     // Reparse date object
     echo "toDatetimeString: " . $standardDateFormat->toDatetimeString($date);
 }
Example #3
0
<?php include $this->loadTemplate('header.tpl.php') ?>
<?php include $this->loadTemplate('menu.tpl.php') ?>
<?php include $this->loadTemplate('toolbar.tpl.php') ?>
<?php include $this->loadTemplate('startmain.tpl.php') ?>

<?php $isoDateFormat = new IsoDateFormat(); ?>

<form method="POST" name="form" id="form">
	<input type="hidden" name="method" id="method" value="showView" />
	<input type="hidden" name="folderId" id="folderId" value="<?php echo $this->folder->getId()?>" />
	<input type="hidden" name="childFolderIdHidden" id="childFolderIdHidden" value="" />
	<input type="hidden" name="childObjectFolderIdHidden" id="childObjectFolderIdHidden" value="" />
	<input type="hidden" name="selectedFoldersHidden" id="selectedFoldersHidden" value="" />
	

	<table class="adminform" border="0" width="100%">
		<tr>
			<td valign="top" width="100%">
				<table width="100%">
					<tr>
						<td><?php echo $this->pathView?></td>
						<td align="right">
							<div align="right">
							
								<select name="folderSelect" id="folderSelect">
									<?php foreach(array_keys($this->specialArray) as $key) {?>
										<option value="<?php echo $key?>"><?php echo $this->specialArray[$key]?></option>
									<?}?>
									<?php foreach(array_keys($this->classesArray) as $key) {?>
										<option value="<?php echo $key?>"><?php echo $this->classesArray[$key]?></option>
									<?}?>
 /**
  * Shows a view that allows the user to update an object
  * @param $object Object - object to update
  * @param $setPostInContext boolean - if true, $object won't be used to fill the fields. Instead, data received by post will be used for that purpose.
  */
 function showUpdateView($setPostInContext = false)
 {
     $object = $this->object;
     // Has the required permissions ?
     if ($object->canDoAction(null, Action::EDIT_OBJECTS_ACTION()) == false) {
         $controllerMessage = new ControllerMessage($this->text["notenoughpermissions"], ControllerMessage::getErrorType());
         array_push($this->controllerMessageArray, $controllerMessage);
         $this->showView(false);
         return;
     }
     // Title of the page
     $pageTitle = str_replace("className", $this->class->getTitle(), $this->text["updateobject"]);
     // Attributes
     $frontLanguageArray = $this->constructFrontLanguageArray($object);
     // Folders
     $allowedFolderArray = $this->getFolderArray($this->class, $object);
     $this->tpl->assign("objectId", $object->getId());
     // Add items to toolbar
     $this->setUpdateToolbar();
     if ($setPostInContext) {
         $this->setPostInContext($frontLanguageArray);
     } else {
         $dateFormat = DateFormatFactory::getDateFormat();
         $isoDateFormat = new IsoDateFormat();
         $isPublished = $object->getIsPublished();
         if ($isPublished) {
             $this->tpl->assign("publishCheckbox", "-1");
         }
         $publishFromDate = $isoDateFormat->parseDatetime($object->getStartPublishing());
         if ($publishFromDate != null) {
             $this->tpl->assign("publishFromText", $dateFormat->toDateString($publishFromDate));
         }
         $publishToDate = $isoDateFormat->parseDatetime($object->getEndPublishing());
         if ($publishToDate != null) {
             $this->tpl->assign("publishToText", $dateFormat->toDateString($publishToDate));
         }
         $this->tpl->assign("hits", $object->getHits());
         $createdOnDate = $isoDateFormat->parseDatetime($object->getCreated());
         $user = $object->getCreatedByUser();
         $this->tpl->assign("createdOn", $dateFormat->toDatetimeString($createdOnDate));
         $this->tpl->assign("createdBy", $user->getName());
         $updatedOnDate = $isoDateFormat->parseDatetime($object->getUpdated());
         $user = $object->getUpdatedByUser();
         $updatedBy = "-";
         $updatedOn = "-";
         if ($updatedOnDate != null) {
             $updatedOn = $dateFormat->toDatetimeString($updatedOnDate);
         }
         if ($user != null) {
             $updatedBy = $user->getName();
         }
         $this->tpl->assign("updatedOn", $updatedOn);
         $this->tpl->assign("updatedBy", $updatedBy);
     }
     $this->displayAdd($pageTitle, $frontLanguageArray, $allowedFolderArray);
 }