private function getModel($contentIds, $count) { $dbo = JFactory::getDBO(); $nullDate = $dbo->getNullDate(); $date = JFactory::getDate(); $now = JDate::getInstance()->toSql($date); $query = $dbo->getQuery(true); $query->select('a . id'); $query->select('a . title'); $query->select('a . alias'); $query->select('a . access'); $query->select('CASE WHEN CHAR_LENGTH(a . alias) THEN CONCAT_WS(":", a . id, a . alias) ELSE a . id END as slug'); $query->select('CASE WHEN CHAR_LENGTH(cc . alias) THEN CONCAT_WS(":", cc . id, cc . alias) ELSE cc . id END as catslug'); $query->from('#__content AS a'); $query->innerJoin('#__categories AS cc ON cc.id = a.catid'); $query->where('a.id in(' . @implode(',', $contentIds) . ')'); $query->where('a.state = 1'); $query->where('( a.publish_up = ' . $dbo->Quote($nullDate) . ' OR a.publish_up <= ' . $dbo->Quote($now) . ' )'); $query->where('( a.publish_down = ' . $dbo->Quote($nullDate) . ' OR a.publish_down >= ' . $dbo->Quote($now) . ' )'); $query->where('cc.published = 1'); $dbo->setQuery($query, 0, $count); //$queryDump = $query->dump(); $rows = $dbo->loadObjectList(); return $rows; }
private function authenticate($username, $password = null, $valid = 86400) { // Get a database object $db = JFactory::getDbo(); // Look for any tokens for this user $db->setQuery($db->getQuery(true)->select('*')->from('#__rvs_user_tokens')->where('uid=' . $db->q($result->id))); $obj = $db->loadObject(); // If there is already a valid token, just return that, otherwise try to create one if ($obj->valid > JDate::getInstance()->toUnix()) { return $obj->token; } else { $db->setQuery($db->getQuery(true)->select('id, password')->from('#__users')->where('username='******':', $result->password); $crypt = $parts[0]; $salt = @$parts[1]; $testcrypt = JUserHelper::getCryptedPassword($password, $salt); if ($crypt == $testcrypt) { // Authentication successful, create a token and populate the table $obj = new stdClass(); $obj->uid = $result->id; $obj->token = md5(rand() . $salt); $obj->valid = JDate::getInstance()->toUnix() + $valid; $db->setQuery($db->getQuery(true)->select('uid')->from('#__rvs_user_tokens')->where('uid=' . $db->q($obj->uid))); if ($db->loadResult()) { $db->updateObject('#__rvs_user_tokens', $obj, 'uid'); } else { $db->insertObject('#__rvs_user_tokens', $obj, 'uid'); } return $obj->token; } } return null; }
function onAfterRoute() { $input = $this->_app->input; $option = $input->get('option', false); $is_testemail = $input->get('plg_testemail', false); if($option != 'com_config' || !$is_testemail){ return true; } $from = $input->get('from_email', false, 'string'); $sender = $input->get('from_name', false); $date = JDate::getInstance()->toSql(); $subject = JText::_('PLG_SYSTEM_TESTEMAIL_EMAIL_SUBJECT'); $body = JText::sprintf('PLG_SYSTEM_TESTEMAIL_EMAIL_BODY', $date); $result = array(); $message = JText::_('PLG_SYSTEM_TESTEMAIL_MESSAGE_SUCCESS'); $state = 'message'; $mailer = self::createMailer(); if ($mailer->sendMail($from, $sender, $from, $subject, $body) !== true) { $this->_error(); } $this->_success(); }
/** * Plugin that manipulate uploaded images * * @param string $context The context of the content being passed to the plugin. * @param object &$object_file The file object. * * @return object The file object. */ public function onContentBeforeSave($context, &$object_file) { // Are we in the right context? if ($context != 'com_media.file') { return; } // Get the current date $date = JDate::getInstance('now'); // Respect the timezone $config = JFactory::getConfig(); $date->setTimezone(new DateTimeZone($config->get('offset'))); // Set current year, month, day $year = $date->year; $month = $date->month; $day = $date->day; // Set the images subfolder, defaults to images/uploads $folder = $this->params->get('folder'); $folder = isset($folder) ? $folder . '/' : ''; $basePath = JPATH_ROOT . '/images/' . $folder; // Make some directories checks if (!is_dir(rtrim($basePath, "/"))) { mkdir(rtrim($basePath, "/")); } if (!is_dir($basePath . $year)) { mkdir($basePath . $year); } if (!is_dir($basePath . $year . '/' . $month)) { mkdir($basePath . $year . '/' . $month); } if (!is_dir($basePath . $year . '/' . $month . '/' . $day)) { mkdir($basePath . $year . '/' . $month . '/' . $day); } // Update the object to the new path $object_file->filepath = $basePath . $year . '/' . $month . '/' . $day . '/' . $object_file->name; return $object_file; }
private function getTimestamp($ts) { $app = JFactory::getApplication(); $tsDate = date("Y-m-d H:i:s", $ts); $offsetDate = JDate::getInstance($tsDate, JFactory::getConfig()->get('offset')); $updates = array('newestTS' => $ts, 'ts' => $ts, 'offset' => $offsetDate, 'pois' => null, 'categories' => null, 'steps' => null, 'votes' => null, 'comments' => null); $app->input->set('ts', $ts); //$updates['pois'] = self::pois(false); //$updates['categories'] = self::categories(false); //$updates['steps'] = self::steps(false); //$updates['votes'] = self::votes(false); //$updates['comments'] = self::comments(false); return $updates; }
/** * Unify the api dates * * @param $date * * @return JDate */ protected function unifyDate($date) { $timeZone = isset($date->timezone) ? $date->timezone : null; if (isset($date->dateTime)) { return JDate::getInstance($date->dateTime, $timeZone); } return JDate::getInstance($date->date, $timeZone); }
/** * Saves an issue entity. * * @param JInput $input Holds the data to be saved. * * @return int ID of the inserted / saved object. * * @throws Exception */ public function save($input) { $query = $this->db->getQuery(true); $user = JFactory::getUser(); // Validate form data. $values = array("title" => $input->getString('title'), "text" => $input->getString('text'), "version" => $input->getString('version'), "project_id" => $input->getInt('project_id'), "classification" => $input->getInt('classification')); $values = $this->validate($values); if (!$values) { return false; } // Validate attachments. $params = $this->getParams(); $enableAttachments = $params->get('issue_enable_attachments', 1); if ($enableAttachments) { $modelAttachments = new MonitorModelAttachments(); $files = $input->files->get('file', null, 'raw'); if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) { return false; } } $id = $input->getInt('id'); if ($id != 0) { $query->update('#__monitor_issues')->where('id = ' . $id); } else { $values["author_id"] = $user->id; $query->insert('#__monitor_issues'); } $values["created"] = JDate::getInstance()->toSql(); $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); $this->db->execute(); if ($id == 0) { $id = $this->db->insertid(); } if ($enableAttachments) { // Upload attachments $modelAttachments->upload($files, $id); } return $id; }
static function getCountdown($params) { // Explicitly disable caching for this module $params->set('cache', 0); // look for events import plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('onCountdownGetEventsQueue', array('mod_smartcountdown', $params)); if (in_array(false, $result, true)) { return false; } // get combined events queue from all plugins $groups = self::unionQueues($result); if ($groups === false || $params->get('session_time_count', 0) || $params->get('submit_form', '')) { // all elements of the result array === true: means that no plugin // is enabled. This is not an error, just get internal countdown // Also if counter mode is set to "relative to session start" or // "submit form on countdown zero" is not empty, we ignore all plugin data return self::getInternal($params); } // we have event queue here, let's proceed $show_countdown = $params->get('show_countdown', -1); // auto $now_ts = JDate::getInstance()->getTimestamp(); /** * Queue format: 2-dimensional array * 1-st dimension - events indexed by start time * 2-nd dimension - events indexed by end time */ /* * Re-process all events provided by events import plugins. * *** current versions of plugins can be significantly simplified *** * For new plugins - no need to calculate diff_js and up_limit in plugin * code, as these values will be overwritten here. At the moment it is just * a performance issue */ $past_slice = null; $start_times = array_keys($groups); foreach ($start_times as $i => $time) { // we have to filter out all past groups except the most recent one if ($time < $now_ts) { if (isset($past_slice)) { // we can safely use $i - 1 index, as $past_slice will never be // set on the first iteration s_tyles // unset previous group unset($groups[$start_times[$i - 1]]); } // set flag: at least one past event found $past_slice = $time; } $next_start = @$start_times[$i + 1]; if (isset($next_start)) { $events_hop = $next_start - $time; } else { $events_hop = PHP_INT_MAX - $time; } foreach ($groups[$time] as $end => &$event) { $duration = $end - $time; if ($show_countdown == 0) { // do not show countdown - conrinue count up until the next event start $event['up_limit'] = $events_hop; } else { if ($show_countdown == -2) { // do not show count up - start countdown right after previous event start $event['up_limit'] = 0; } else { if ($show_countdown == -1) { // auto - use event duration $event['up_limit'] = $events_hop == 0 || $events_hop > $duration ? $duration : $events_hop; } else { if ($show_countdown > 0) { // positive value means time to show countdown before the next event start // if greater than events hop, use event hop instead $event['up_limit'] = $events_hop > $show_countdown ? $events_hop - $show_countdown : $events_hop; } else { // negative value means time to show count up after the event start // if greater than events hop, use event hop instead $show_countup = $show_countdown * -1; $event['up_limit'] = $show_countup > $events_hop ? $events_hop : $show_countup; } } } } // up_limit can never be greater than duration $event['up_limit'] = min($event['up_limit'], $duration); } } // Concatenate titles for duplicate-time events. We add support for different titles // in countdown and count up modes. Plugins can e.g. configure event links according // to their settings // We presume that if $tevent['title'] is set we have equal titles for both modes, // otherwise we look in $tevent['title_down'] and $tevent['title_up'] properties $titles_down = array(); $titles_up = array(); foreach ($groups as $time => $tgroup) { foreach (array_reverse($tgroup, true) as $tevent) { if (isset($tevent['title'])) { // the same title for both countdown and count up modes if (isset($titles_down[$time])) { $titles_down[$time][''] = $tevent['title'] . ', ' . $titles_down[$time]['']; $titles_up[$time][''] = $tevent['title'] . ', ' . $titles_up[$time]['']; } else { $titles_down[$time][''] = $tevent['title']; $titles_up[$time][''] = $tevent['title']; } $titles_down[$time][$tevent['up_limit']] = $titles_down[$time]['']; $titles_up[$time][$tevent['up_limit']] = $titles_up[$time]['']; } else { // different titles for countdown and count up modes // titles down if (isset($titles_down[$time])) { $titles_down[$time][''] = $tevent['title_down'] . ', ' . $titles_down[$time]['']; } else { $titles_down[$time][''] = $tevent['title_down']; } $titles_down[$time][$tevent['up_limit']] = $titles_down[$time]['']; // titles up if (isset($titles_up[$time])) { $titles_up[$time][''] = $tevent['title_up'] . ', ' . $titles_up[$time]['']; } else { $titles_up[$time][''] = $tevent['title_up']; } $titles_up[$time][$tevent['up_limit']] = $titles_up[$time]['']; } } } // flatten the groups array and get events timeline // start the output array $events = array(); foreach ($groups as $time => $group) { foreach ($group as $e) { $events[] = $e; } } // filter out expired events $recent_past_event = null; foreach ($events as $i => $event) { if ($i == 0 && $show_countdown >= 0 && $events[$i]['start'] - $now_ts > $show_countdown) { // for the first event in the queue do not render counter at all // if show_countdown is set for a value smaller than event start - now return array(); } if ($show_countdown < -1 && $now_ts - $event['start'] > $show_countdown * -1) { // even if the event is current (not finished) but 'show countup' limit is // exeeded, remove event unset($events[$i]); } if ($show_countdown > 0 && isset($events[$i + 1]) && $events[$i + 1]['start'] - $now_ts < $show_countdown) { // if next event 'show countdown' already wins, remove event - it will not be // displayed anyway (1-second flicker workaround) unset($events[$i]); } } $events = array_values($events); $lang = JFactory::getLanguage(); $tag = strtolower($lang->getTag()); // Final pass through events: calculate diff_js, diff_php for first event and // setup event texts foreach ($events as $i => &$event) { if ($i == 0) { $event['diff_js'] = $events[$i]['start'] - $now_ts; // only first event in php format $seconds = $event['diff_js'] > 0 ? $event['diff_js'] : $event['diff_js'] * -1; $days_diff = floor($seconds / 86400); $diff_time = gmdate('H:i:s', $seconds); list($h_diff, $i_diff, $s_diff) = explode(':', $diff_time); $event['diff_php'] = array('days' => $days_diff, 'hours' => $h_diff, 'minutes' => $i_diff, 'seconds' => $s_diff); } else { $prev = $events[$i - 1]; $event['diff_js'] = $event['start'] - $prev['start'] - $prev['up_limit']; $event['diff_php'] = array(); } // construct event texts $text_down = $params->get('text_down_' . $tag, $params->get('text_down_def', JText::_('MOD_SMARTCDPRO_TEXT_DOWN_DEFAULT'))); $text_up = $params->get('text_up_' . $tag, $params->get('text_up_def', JText::_('MOD_SMARTCDPRO_TEXT_UP_DEFAULT'))); $replace = array("\n", "\r\n", "\r"); $text_down = str_replace($replace, '<br />', $text_down); $text_up = str_replace($replace, '<br />', $text_up); // plugins can define the order of the event text concatenation if (!empty($event['title_first'])) { // event title goes first $text_down = $titles_down[$event['start']][$event['up_limit']] . ' ' . $text_down; $text_up = $titles_up[$event['start']][$event['up_limit']] . ' ' . $text_up; } else { // generic text goes first, just append the title $text_down .= ' ' . $titles_down[$event['start']][$event['up_limit']]; $text_up .= ' ' . $titles_up[$event['start']][$event['up_limit']]; } $event['text_down'] = $text_down; $event['text_up'] = $text_up; $event['text'] = $events[$i]['diff_js'] > 0 ? $events[$i]['text_down'] : $events[$i]['text_up']; } return $events; }
/** * Tests the getInstance method. * * @return void * * @since 11.3 * @covers JDate::getInstance */ public function testGetInstance() { $this->assertThat(JDate::getInstance(), $this->isInstanceOf('JDate')); JDate::$format = 'Y-m-d H:i:s'; $this->assertThat((string) JDate::getInstance('2000-01-01 00:00:00'), $this->equalTo('2000-01-01 00:00:00')); }
/** * Generate and return the hidden fields. * * <code> * $keys = array( * "api_login_id" => "....", * "transaction_key" => "...." * ); * * $dpm = new Prism\Payment\AuthorizeNet\Service\Dpm($keys); * $hiddenFields = $dpm->getHiddenFields(); * </code> * * @return array */ public function getHiddenFields() { $date = \JDate::getInstance(); $this->setTimestamp($date->toUnix()); $this->generateFingerprint($this->transactionKey); // Exclude these params $excluded = array("transactionKey"); return $this->getHiddenFieldsArray($excluded); }
/** * Method to set the modified date. * * @param mixed $date The date as a string or JDate object. * * @return void * * @since 12.1 * @throws InvalidArgumentException */ protected function setModifiedDate($date) { // Convert the date if necessary. if (is_string($date)) { $date = JDate::getInstance($date); } // Verify the date is valid. if (!$date instanceof JDate) { throw new InvalidArgumentException(JText::_('JCONTENT_INVALID_DATE_TYPE')); } // Set the modified date. $this->setProperty('modified_date', $date->format($this->db->getDateFormat()), false); }
private function dateToSql($date) { $start_date = \JDate::getInstance(str_replace('/', '-', $date)); return $start_date->toSql(); }
/** * @param $name * @param null $description * @param int $weight * @return bool|int */ public function store($name, $description = null, $weight = 0) { $dbo = JFactory::getDbo(); $cedTagsHelper = new CedTagsHelper(); $name = $cedTagsHelper->isValidName($name); if (!$name) { return false; } $cedTagModelTag = new CedTagModelTag(); $tagAlreadyExisting = $cedTagModelTag->getTagId($name); if (isset($tagAlreadyExisting) & isset($tagAlreadyExisting->id)) { $needUpdate = false; $updateQuery = 'update #__cedtag_term set '; if (isset($description) && !empty($description)) { $needUpdate = true; $updateQuery .= "description='" . $description . "'"; } if (isset($weight)) { if ($needUpdate) { $updateQuery .= ', weight=' . $weight; } else { $updateQuery .= ' weight=' . $weight; $needUpdate = true; } } if ($needUpdate) { $updateQuery .= ' where id=' . $tagAlreadyExisting->id; $dbo->setQuery($updateQuery); $dbo->query(); } return $tagAlreadyExisting->id; } else { $insertQuery = "insert into #__cedtag_term (name"; $valuePart = " values('" . $name . "'"; if (isset($description) && !empty($description)) { $insertQuery .= ",description"; $valuePart .= ",'" . $description . "'"; } if (isset($weight)) { $insertQuery .= ",weight"; $valuePart .= "," . $weight; } $date = JFactory::getDate(); $now = JDate::getInstance()->toSql($date); $insertQuery .= ',created) '; $valuePart .= ',' . $dbo->Quote($now) . ')'; $dbo->setQuery($insertQuery . $valuePart); $dbo->query(); return $dbo->insertid(); } }
<?php defined('_JEXEC') or die; ?> <ul class="next-events"> <?php foreach ($events as $event) { ?> <li class="event" itemscope itemtype="http://schema.org/Event"> <meta itemprop="startDate" content="<?php echo JDate::getInstance($event->startDate)->toISO8601(true); ?> "> <meta itemprop="endDate" content="<?php echo JDate::getInstance($event->endDate)->toISO8601(true); ?> "> <div class="event-name"> <?php if ($params->get('show_link', true)) { ?> <a href="<?php echo $event->htmlLink; ?> " target="_blank"> <?php } ?> <span itemprop="name"><?php echo $event->summary; ?>
protected function getInput() { global $expose; // necessary Joomla! classes $uri = JURI::getInstance(); $db = JFactory::getDBO(); $app = JFactory::getApplication(); // variables from URL $tid = $uri->getVar('id', ''); $task = $uri->getVar('config_task', ''); $file = $uri->getVar('config_file', ''); if ($file !== '') { $file = $file . '.json'; } //if file name is given add its extension $path = JPATH_ROOT . '/templates/' . getTemplate($tid) . '/configs/'; // helping variables $redirectUrl = $uri->root() . 'administrator/index.php?option=com_templates&view=style&layout=edit&id=' . $tid; $saveUrl = $redirectUrl . '&config_task=save&config_file='; $loadUrl = $redirectUrl . '&config_task=load&config_file='; // if the URL contains proper variables if ($tid !== 'none' && is_numeric($tid) && $task !== '') { if ($task == 'load') { if (JFile::exists($path . $file)) { // Insert the params into DB $query = ' UPDATE #__template_styles SET params = ' . $db->quote(file_get_contents($path . $file)) . ' WHERE id = ' . $tid . ' LIMIT 1 '; // Executing SQL Query $db->setQuery($query); $result = $db->query(); // check the result if ($result) { // Redirect $app->redirect($redirectUrl, $file . JText::_('CONFIGURATOR_LOADED_AND_SAVED'), 'message'); } else { // Redirect $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SQL_ERROR'), 'error'); } } else { // Redirect $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SELECTED_FILE_DOESNT_EXIST'), 'error'); } } else { if ($task == 'save') { if ($file == '') { $date = JDate::getInstance(); $file = $date->format('Ymd-His') . '.json'; } // write it if (JFile::write($path . $file, $this->getParams($tid)->params)) { $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SAVED_AS') . $file . JText::_('CONFIGURATOR_SAVED_IN') . $path, 'message'); } else { $app->redirect($redirectUrl, JText::_('CONFIGURATOR_FAILED_CHECK_PERM'), 'error'); } } } } // generate the select list $options = (array) $this->getOptions($tid); $file_select = JHtml::_('select.genericlist', $options, 'name', '', 'value', 'text', '0', 'config-load-filename'); // return the standard formfield output $html = ''; $class = $this->element['class']; $wrapstart = '<div class="clearfix ' . $class . '">'; $wrapend = '</div>'; //button $html .= "<p class='mod-chrome-button config-btn gradient hasTip' rel='#configurator-form' title='::" . JText::_($this->description) . "'><span>" . JText::_('CONFIGURATOR_BTN_LABEL') . "</span></p>"; $html .= '<div id="configurator-form">'; $html .= '<h3>' . JText::_('CONFIGURATOR_TITLE') . '</h3>'; $html .= '<p class="alert-message">' . JText::_('CONFIGURATOR_MSG') . '</p>'; $html .= '<div><span class="label">' . JText::_('CONFIGURATOR_LOAD_LABEL') . '</span>' . $file_select . '<a id="configurator-load" class="gradient" href="#">' . JText::_('CONFIGURATOR_LOAD_BTN') . '</a> </div>'; $html .= '<div><span class="label">' . JText::_('CONFIGURATOR_SAVE_LABEL') . '</span> <input type="text" id="configurator-save-filename" /><span style="margin-top: 5px;">.json</span> <a id="configurator-save" class="gradient" href="#">' . JText::_('CONFIGURATOR_SAVE_BTN') . ' </a></div>'; $html .= '</div>'; // Js $js = "\n\n var file, url = '';\n\n \$('#configurator-save').on('click', function(e)\n {\n e.preventDefault();\n if ( file = \$('#configurator-save-filename').val() )\n {\n url = '{$saveUrl}' + file ;\n window.location = url;\n }else{\n\n alert('" . JText::_('CONFIGURATOR_FILENAME_EMPTY_ERROR') . "');\n return;\n }\n });\n\n \$('#configurator-load').on('click', function(e)\n {\n e.preventDefault();\n file = \$('#config-load-filename').val();\n url = '{$loadUrl}' + file ;\n\n window.location = url;\n });\n\n "; $expose->addjQDom($js); // finish the output return $wrapstart . $html . $wrapend; }
/** * Take the provided refresh token values and store them somewhere. * * This function should be the storage counterpart to getRefreshToken(). * * If storage fails for some reason, we're not currently checking for * any sort of success/failure, so you should bail out of the script * and provide a descriptive fail message. * * Required for OAuth2::GRANT_TYPE_REFRESH_TOKEN. * * @param $refresh_token * Refresh token to be stored. * @param $client_id * Client identifier to be stored. * @param $user_id * @param $expires * expires to be stored. * @param $scope * (optional) Scopes to be stored in space-separated string. * * @return void * @ingroup oauth2_section_6 */ public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = null) { /** @var $client RokOAuthClient */ $client = JTable::getInstance('Client', 'RokOauth'); $client->load($client->find(array('client_id' => $client_id))); /** @var $user RokUpdaterUser */ $user = JTable::getInstance('User', 'RokUpdater'); $user->load($user->find(array('username' => $user_id))); /** @var $token RokOAuthRefreshToken */ $token = JTable::getInstance('RefreshToken', 'RokOauth'); $token->refresh_token = $refresh_token; $token->user = $user->id; $token->client = $client->id; $token->expires = JDate::getInstance($expires)->toSql(); $token->store(); }
public function insertNewTag($name, $description = '', $weight = 0) { $dbo = JFactory::getDBO(); $query = $dbo->getQuery(true); $date = JFactory::getDate(); $now = JDate::getInstance()->toSql($date); if (!isset($weight)) { $weight = 0; } $values = '' . $dbo->quote($name) . ',' . $dbo->quote($description) . ',' . $weight . ',' . $dbo->quote($now); $query->insert('#__cedtag_term'); $query->columns(array($dbo->quoteName('name'), $dbo->quoteName('description'), $dbo->quoteName('weight'), $dbo->quoteName('created'))); $query->values($values); $dbo->setQuery($query); $sql = $query->dump(); $dbo->query(); $tid = $dbo->insertid(); return $tid; }
/** * Method is called before user data is stored in the database * * @param array $user Holds the old user data. * @param boolean $isnew True if a new user is stored. * @param array $data Holds the new user data. * * @return boolean * * @since 3.1 * @throws InvalidArgumentException on invalid date. */ public function onUserBeforeSave($user, $isnew, $data) { // Check that the date is valid. if (!empty($data['profile']['dob'])) { try { $date = new JDate($data['profile']['dob']); $this->date = $date->format('Y-m-d H:i:s'); } catch (Exception $e) { // Throw an exception if date is not valid. throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_ERROR_INVALID_DOB')); } if (JDate::getInstance('now') < $date) { // Throw an exception if dob is greather than now. throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_ERROR_INVALID_DOB')); } } // Check that the tos is checked if required ie only in registration from frontend. $task = JFactory::getApplication()->input->getCmd('task'); $option = JFactory::getApplication()->input->getCmd('option'); $tosarticle = $this->params->get('register_tos_article'); $tosenabled = $this->params->get('register-require_tos', 0) == 2 ? true : false; if ($task == 'register' && $tosenabled && $tosarticle && $option == 'com_users') { // Check that the tos is checked. if (!$data['profile']['tos']) { throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); } } return true; }
/*------------------------------------------------------------------------ Solidres - Hotel booking extension for Joomla ------------------------------------------------------------------------ @Author Solidres Team @Website http://www.solidres.com @Copyright Copyright (C) 2013 Solidres. All Rights Reserved. @License GNU General Public License version 3, or later ------------------------------------------------------------------------*/ defined('_JEXEC') or die; JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); $config = JFactory::getConfig(); $tzoffset = $config->get('offset'); $timezone = new DateTimeZone($tzoffset); $date = JDate::getInstance(); ?> <fieldset> <div class="control-group"> <?php echo $this->form->getLabel('coupon_name'); ?> <div class="controls"> <?php echo $this->form->getInput('coupon_name'); ?> </div> </div> <div class="control-group"> <?php echo $this->form->getLabel('coupon_code');
/** * Saves a comment entity. * * @param JInput $input Holds the data to be saved. * * @return int|boolean The ID of the inserted/updated comment on success, boolean false on failure. * * @throws Exception */ public function save($input) { $user = JFactory::getUser(); // Validate form data. $values = array("issue_id" => $input->getInt('issue_id'), "text" => $input->getString('text')); $values = $this->validate($values); if (!$values) { return false; } // Validate attachments. $params = $this->getParams(); $enableAttachments = $params->get('comment_enable_attachments', 1); if ($enableAttachments) { $modelAttachments = new MonitorModelAttachments(); $files = $input->files->get('file', null, 'raw'); if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) { return false; } } if ($values["issue_id"] == 0) { throw new Exception(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); } if ($user->authorise('comment.edit.status', 'com_monitor')) { $values["status"] = $input->getInt('issue_status'); if ($values["status"]) { $query = $this->db->getQuery(true); $query->update('#__monitor_issues')->where('id = ' . $values["issue_id"])->set('status = ' . $values["status"]); $this->db->setQuery($query); $this->db->execute(); } else { unset($values["status"]); } } $query = $this->db->getQuery(true); $id = $input->getInt('id'); if (!$this->canEdit($user, $id)) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } if ($id != 0) { $query->update('#__monitor_comments')->where('id = ' . $id); } else { $values["author_id"] = $user->id; $query->insert('#__monitor_comments'); } $values["created"] = JDate::getInstance()->toSql(); $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); $this->db->execute(); if ($id == 0) { $id = $this->db->insertid(); } // Upload attachments if ($enableAttachments) { $modelAttachments->upload($files, $values["issue_id"], $id); } return $id; }
private function getModifications($ts, $userid) { $offsetDate = JDate::getInstance(date("Y-m-d H:i:s", $ts), JFactory::getConfig()->get('offset')); $offset = $offsetDate->format('Y-m-d H:i:s'); //1. get issues $issuesModel = JModelLegacy::getInstance('Issues', 'ImcModel', array('ignore_request' => true)); $issuesModel->setState('filter.imcapi.ts', $offset); $issuesModel->setState('filter.imcapi.raw', true); //Do not unset anything in getItems() $data = $issuesModel->getItems(); $issues = ImcFrontendHelper::sanitizeIssues($data, $userid, true); //2. get categories $categories = ImcFrontendHelper::getModifiedCategories($offset); $categories = ImcFrontendHelper::sanitizeCategories($categories); //3. get steps $stepsModel = JModelLegacy::getInstance('Steps', 'ImcModel', array('ignore_request' => true)); $stepsModel->setState('filter.imcapi.ts', $offset); $stepsModel->setState('filter.imcapi.raw', true); $data = $stepsModel->getItems(); $steps = ImcFrontendHelper::sanitizeSteps($data, true); //4. get votes $data = ImcFrontendHelper::getModifiedVotes($offset); $votes = ImcFrontendHelper::sanitizeModifiedVotes($data); //5. full categories structure if modified categories are found $allCategories = array(); if (!empty($categories)) { $allCategories = ImcFrontendHelper::getCategories(false); } $info = array('count_issues' => sizeof($issues), 'count_categories' => sizeof($categories), 'count_steps' => sizeof($steps), 'count_votes' => sizeof($votes), 'count_allcategories' => sizeof($allCategories), 'given_ts' => $ts, 'given_date' => gmdate('Y-m-d H:i:s', $ts), 'offset' => $offsetDate); $updated = array('issues' => $issues, 'categories' => $categories, 'steps' => $steps, 'votes' => $votes, 'allcategories' => $allCategories); return array('info' => $info, 'updated' => $updated); }
/** * Tests the getInstance method. * * @return void * * @since 11.3 * @covers JDate::getInstance */ public function testGetInstance() { $this->assertInstanceOf('JDate', JDate::getInstance()); $this->assertEquals('2000-01-01 00:00:00', (string) JDate::getInstance('2000-01-01 00:00:00')); }