/** * Filter by time, either on registration or last visit date. * * @param JDate $starting Starting date or null if older than ending date. * @param JDate $ending Ending date or null if newer than starting date. * @param bool $register True = registration date, False = last visit date. * * @return $this */ public function filterByTime(JDate $starting = null, JDate $ending = null, $register = true) { $name = $register ? 'registerDate' : 'lastvisitDate'; if ($starting && $ending) { $this->query->where("a.{$name} BETWEEN {$this->db->quote($starting->toUnix())} AND {$this->db->quote($ending->toUnix())}"); } elseif ($starting) { $this->query->where("a.{$name} > {$this->db->quote($starting->toUnix())}"); } elseif ($ending) { $this->query->where("a.{$name} <= {$this->db->quote($ending->toUnix())}"); } return $this; }
function XmapNav(&$config, &$sitemap) { $this->_list=array(); $this->view='navigator'; global $mainframe; jimport('joomla.utilities.date'); $user =& JFactory::getUser(); $access = new stdClass(); $access->canEdit = $user->authorize('com_content', 'edit', 'content', 'all'); $access->canEditOwn = $user->authorize('com_content', 'edit', 'content', 'own'); $access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all'); $this->access = &$access; $date = new JDate(); $this->noauth = $mainframe->getCfg( 'shownoauth' ); $this->gid = $user->get('gid'); $this->now = $date->toUnix(); $this->config = &$config; $this->sitemap = &$sitemap; $this->isNews = false; $this->_isAdmin = ($this->gid == "25"); }
/** * Returns date/time in short format. i.e. 6m, 6h, 6d, 6w, 6m, 6y etc * @param unknown $date * @return Ambigous <string, string, mixed, multitype:>|Ambigous <string, string, mixed> */ public static function getShortDate($date) { if (empty($date) || $date == '0000-00-00 00:00:00') { return JText::_('LBL_NA'); } jimport('joomla.utilities.date'); $user = JFactory::getUser(); // Given time $date = new JDate(JHtml::date($date, 'Y-m-d H:i:s')); $compareTo = new JDate(JHtml::date('now', 'Y-m-d H:i:s')); $diff = $compareTo->toUnix() - $date->toUnix(); $diff = abs($diff); $dayDiff = floor($diff / 86400); if ($dayDiff == 0) { if ($diff < 120) { return '1m'; } elseif ($diff < 3600) { return floor($diff / 60) . 'm'; } else { return floor($diff / 3600) . 'h'; } } elseif ($dayDiff < 7) { return $dayDiff . 'd'; } elseif ($dayDiff < 7 * 6) { return ceil($dayDiff / 7) . 'w'; } elseif ($dayDiff < 365) { return ceil($dayDiff / (365 / 12)) . 'm'; } else { return round($dayDiff / 365) . 'y'; } }
/** * Called whenever a subscription is modified. Namely, when its enabled status, * payment status or valid from/to dates are changed. */ public function onAKSubscriptionChange($row, $info) { if (is_null($info['modified']) || empty($info['modified'])) { return; } //if(!array_key_exists('enabled', (array)$info['modified'])) return; // Load the plugin's language files $lang = JFactory::getLanguage(); $lang->load('plg_akeebasubs_invoices', JPATH_ADMINISTRATOR, 'en-GB', true); $lang->load('plg_akeebasubs_invoices', JPATH_ADMINISTRATOR, null, true); // Akeeba Subscriptions language files $lang->load('com_akeebasubs', JPATH_SITE, 'en-GB', true); $lang->load('com_akeebasubs', JPATH_SITE, $lang->getDefault(), true); $lang->load('com_akeebasubs', JPATH_SITE, null, true); $lang->load('com_akeebasubs', JPATH_ADMINISTRATOR, 'en-GB', true); $lang->load('com_akeebasubs', JPATH_ADMINISTRATOR, $lang->getDefault(), true); $lang->load('com_akeebasubs', JPATH_ADMINISTRATOR, null, true); // Do not issue invoices for free subscriptions if ($row->gross_amount < 0.01) { return; } // Should we handle this subscription? $generateAnInvoice = $row->state == "C"; $whenToGenerate = $this->params->get('generatewhen', '0'); if ($whenToGenerate == 1) { // Handle new subscription, even if they are not yet enabled $specialCasePending = in_array($row->state, array('P', 'C')) && !$row->enabled; $generateAnInvoice = $generateAnInvoice || $specialCasePending; } // If the payment is over a week old do not generate an invoice. This // prevents accidentally creating an invoice for pas subscriptions not // handled by ccInvoices JLoader::import('joomla.utilities.date'); $jCreated = new JDate($row->created_on); $jNow = new JDate(); $dateDiff = $jNow->toUnix() - $jCreated->toUnix(); if ($dateDiff > 604800) { return; } // Only handle not expired subscriptions if ($generateAnInvoice && !defined('AKEEBA_INVOICE_GENERATED')) { define('AKEEBA_INVOICE_GENERATED', 1); $db = JFactory::getDBO(); // Check if there is an invoice for this subscription already $query = $db->getQuery(true)->select('*')->from('#__akeebasubs_invoices')->where($db->qn('akeebasubs_subscription_id') . ' = ' . $db->q($row->akeebasubs_subscription_id)); $db->setQuery($query); $oldInvoices = $db->loadObjectList('akeebasubs_subscription_id'); if (count($oldInvoices) > 0) { return; } // Create (and, optionally, send) a new invoice F0FModel::getAnInstance('Invoices', 'AkeebasubsModel')->createInvoice($row); } }
public function onAfterParseData($params) { $db = JFactory::getDbo(); $table = new JTableJed($db); $table->load(array('md5url' => md5($params->get('url')))); $lastUpdate = new JDate($params->get('data.last_update')); $dateAdded = new JDate($params->get('data.date_added')); $today = new JDate(); $table->url = $params->get('url'); $table->md5url = md5($table->url); $table->title = $params->get('data.title', ''); $table->alias = JApplication::stringURLSafe($table->title); $table->fulltext = $params->get('data.description', ''); $table->introtext = $this->getIntrotext($table->fulltext); $table->catid = $this->getCategory($params); $table->avatar = $this->getAvatar($params); $table->gallery = $this->getGallery($params); $table->featured = $params->get('data.feature', '') == '' ? false : true; $table->popular = $params->get('data.popular', '') == '' ? false : true; $table->component = $params->get('data.component', '') == '' ? false : true; $table->module = $params->get('data.module', '') == '' ? false : true; $table->plugin = $params->get('data.plugin', '') == '' ? false : true; $table->language = $params->get('data.language', '') == '' ? false : true; $table->specific = $params->get('data.specific', '') == '' ? false : true; $table->compat_15 = $params->get('data.compat_15', '') == '' ? false : true; $table->compat_25 = $params->get('data.compat_25', '') == '' ? false : true; $table->compat_30 = $params->get('data.compat_30', '') == '' ? false : true; $table->version = $params->get('data.version', ''); $table->date_added = $dateAdded->toSql(); $table->last_update = $lastUpdate->toSql(); $table->rating = $params->get('data.rating', 0); $table->rating_count = $params->get('data.rating_user', 0); $table->rating_sum = round($table->rating * $table->rating_count); $table->favorite = $params->get('data.favorite', 0); $table->license = $params->get('data.license', ''); $table->view = $params->get('data.view', 0); $table->developer = $params->get('data.developer', ''); $table->website = $this->getRedirectUrl($params->get('data.website')); $table->download_url = $params->get('data.download_link'); $table->demo_url = $params->get('data.demo_link'); $table->support_url = $params->get('data.support_link'); $table->document_url = $params->get('data.document_link'); $time = $today->toUnix() - $dateAdded->toUnix(); $days = $time / (60 * 60 * 24) + 1; $table->ordering = floor($table->view / $days); if (!$table->id) { $table->state = 1; } //print_r($params); //print_r($table);die(); if ($table->store()) { $params->set('success', true); } }
function loadChartData() { $db = $this->getDBO(); $type = JRequest::getCmd('type'); switch ($type) { case 'sales': jimport('joomla.utilities.date'); $date = JFactory::getDate(); $interval = JRequest::getInt('interval', '14'); $today = $date->toFormat('%Y-%m-%d'); $startDate = strtotime('-' . $interval . ' day', strtotime($today)); $startDate = new JDate($startDate); $query = "SELECT COUNT(virtuemart_order_id) AS sales, DATE(created_on) as `date` FROM #__virtuemart_orders WHERE created_on > " . $db->Quote($startDate->toMySQL()) . " GROUP BY `date` ORDER BY `date`"; $db->setQuery($query); $rows = $db->loadObjectList(); $data = array(); foreach ($rows as $row) { $data[$row->date] = (int) $row->sales; } $today = $date->toUnix(); for ($time = $startDate->toUnix(); $time <= $today; $time += 86400) { $date = date('Y', $time) . '-' . date('m', $time) . '-' . date('d', $time); if (!array_key_exists($date, $data)) { $data[$date] = 0; } } ksort($data); $startYear = $startDate->toFormat('%Y'); $startMonth = $startDate->toFormat('%m') - 1; $startDay = $startDate->toFormat('%d'); $script = "\r\n k2martSalesChartOptions.title.text = '" . JText::_('K2MART_TOTAL_SALES', true) . "';\r\n k2martSalesChartOptions.subtitle.text = '* " . JText::_('K2MART_CLICK_AND_DRAG_IN_THE_PLOT_AREA_TO_ZOOM_IN', true) . "';\r\n k2martSalesChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martSalesChartOptions.series[0].pointStart=Date.UTC(" . $startYear . ", " . $startMonth . ", " . $startDay . "); \r\n k2martSalesChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n "; break; case 'products': $limit = JRequest::getInt('limit', '20'); $query = "SELECT product.product_sales, productData.product_name FROM #__virtuemart_products AS product \r\n LEFT JOIN #__virtuemart_products_" . VMLANG . " AS productData ON product.virtuemart_product_id = productData.virtuemart_product_id\r\n WHERE product.product_sales > 0 ORDER BY product.product_sales DESC LIMIT 0, {$limit}"; $db->setQuery($query); $rows = $db->loadObjectList(); $data = array(); $categories = array(); foreach ($rows as $row) { $data[] = (int) $row->product_sales; $categories[] = "'" . $row->product_name . "'"; } $script = "\r\n k2martProductsChartOptions.title.text = '" . JText::_('K2MART_TOP_SELLING_PRODUCTS', true) . "';\r\n k2martProductsChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martProductsChartOptions.xAxis.categories =[" . implode(',', $categories) . "]; \r\n k2martProductsChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n "; break; } $script .= "k2martChartType = '{$type}';"; echo $script; }
/** * Run the session cleaner (garbage collector) on a schedule */ public function onAfterInitialise() { $minutes = (int) $this->params->get('ses_freq', 0); if ($minutes <= 0) { return; } $lastJob = $this->getTimestamp('session_clean'); $nextJob = $lastJob + $minutes * 60; JLoader::import('joomla.utilities.date'); $now = new JDate(); if ($now->toUnix() >= $nextJob) { $this->setTimestamp('session_clean'); $this->purgeSession(); } }
/** * * @param JDate $date * */ public static function timeLapse($date) { $now = new JDate(); $dateDiff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix()); if ($dateDiff['days'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['days']) ? 'CC LAPSED DAY MANY' : 'CC LAPSED DAY', $dateDiff['days']); } elseif ($dateDiff['hours'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['hours']) ? 'CC LAPSED HOUR MANY' : 'CC LAPSED HOUR', $dateDiff['hours']); } elseif ($dateDiff['minutes'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['minutes']) ? 'CC LAPSED MINUTE MANY' : 'CC LAPSED MINUTE', $dateDiff['minutes']); } else { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['seconds']) ? 'CC LAPSED SECOND MANY' : 'CC LAPSED SECOND', $dateDiff['seconds']); } return $lapse; }
public function onAfterInitialise() { $minutes = (int) $this->params->get('cleantemp_freq', 0); if ($minutes <= 0) { return; } $lastJob = $this->getTimestamp('clean_temp'); $nextJob = $lastJob + $minutes * 60; JLoader::import('joomla.utilities.date'); $now = new JDate(); if ($now->toUnix() >= $nextJob) { $this->setTimestamp('clean_temp'); $this->tempDirectoryCleanup(); } }
public function validate($data) { if (empty($data) or !is_array($data)) { throw new InvalidArgumentException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_REWARDS")); } $filter = JFilterInput::getInstance(); $params = JComponentHelper::getParams("com_crowdfunding"); /** @var $params Joomla\Registry\Registry */ // Create a currency object. $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $params->get("project_currency")); // Create the object "amount". $amount = new Crowdfunding\Amount($params); $amount->setCurrency($currency); foreach ($data as $key => $item) { $item["amount"] = $amount->setValue($item["amount"])->parse(); // Filter data if (!is_numeric($item["amount"])) { $item["amount"] = 0; } $item["title"] = $filter->clean($item["title"], "string"); $item["title"] = Joomla\String\String::trim($item["title"]); $item["title"] = Joomla\String\String::substr($item["title"], 0, 128); $item["description"] = $filter->clean($item["description"], "string"); $item["description"] = Joomla\String\String::trim($item["description"]); $item["description"] = Joomla\String\String::substr($item["description"], 0, 500); $item["number"] = (int) $item["number"]; $item["delivery"] = Joomla\String\String::trim($item["delivery"]); $item["delivery"] = $filter->clean($item["delivery"], "string"); if (!empty($item["delivery"])) { $date = new JDate($item["delivery"]); $unixTime = $date->toUnix(); if ($unixTime < 0) { $item["delivery"] = ""; } } if (!$item["title"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_TITLE")); } if (!$item["description"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_DESCRIPTION")); } if (!$item["amount"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT")); } $data[$key] = $item; } return $data; }
public function validate($data) { if (!is_array($data) or count($data) === 0) { throw new InvalidArgumentException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARDS')); } $filter = JFilterInput::getInstance(); $params = JComponentHelper::getParams('com_crowdfunding'); /** @var $params Joomla\Registry\Registry */ // Create a currency object. $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $params->get('project_currency')); // Create the object 'amount'. $amount = new Crowdfunding\Amount($params); $amount->setCurrency($currency); foreach ($data as $key => &$item) { $item['amount'] = $amount->setValue($item['amount'])->parse(); // Filter data if (!is_numeric($item['amount'])) { $item['amount'] = 0; } $item['title'] = $filter->clean($item['title'], 'string'); $item['title'] = JString::trim($item['title']); $item['title'] = JString::substr($item['title'], 0, 128); $item['description'] = $filter->clean($item['description'], 'string'); $item['description'] = JString::trim($item['description']); $item['description'] = JString::substr($item['description'], 0, 500); $item['number'] = (int) $item['number']; $item['delivery'] = JString::trim($item['delivery']); $item['delivery'] = $filter->clean($item['delivery'], 'string'); if (!empty($item['delivery'])) { $date = new JDate($item['delivery']); $unixTime = $date->toUnix(); if ($unixTime < 0) { $item['delivery'] = ''; } } if (!$item['title']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_TITLE')); } if (!$item['description']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DESCRIPTION')); } if (!$item['amount']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_AMOUNT')); } } unset($item); return $data; }
public function onProcessList(&$resultArray) { // Implement the coupon automatic expiration if (empty($resultArray)) { return; } if ($this->getState('skipOnProcessList', 0)) { return; } JLoader::import('joomla.utilities.date'); $jNow = new JDate(); $uNow = $jNow->toUnix(); $table = $this->getTable($this->table); $k = $table->getKeyName(); foreach ($resultArray as $index => &$row) { $triggered = false; if (!property_exists($row, 'publish_down')) { continue; } if (!property_exists($row, 'publish_up')) { continue; } if ($row->publish_down && $row->publish_down != '0000-00-00 00:00:00') { $regex = '/^\\d{1,4}(\\/|-)\\d{1,2}(\\/|-)\\d{2,4}[[:space:]]{0,}(\\d{1,2}:\\d{1,2}(:\\d{1,2}){0,1}){0,1}$/'; if (!preg_match($regex, $row->publish_down)) { $row->publish_down = '2037-01-01'; } if (!preg_match($regex, $row->publish_up)) { $row->publish_up = '2001-01-01'; } $jDown = new JDate($row->publish_down); $jUp = new JDate($row->publish_up); if ($uNow >= $jDown->toUnix() && $row->enabled) { $row->enabled = 0; $triggered = true; } elseif ($uNow >= $jUp->toUnix() && !$row->enabled && $uNow < $jDown->toUnix()) { $row->enabled = 1; $triggered = true; } } if ($triggered) { $table->reset(); $table->load($row->{$k}); $table->save($row); } } }
/** * Append the given comment to the particular content. * * @return, full-text of the content */ public function add($actor, $comment, $content) { $commentJson = ''; $json = new Services_JSON(); $comments = $this->getCommentsData($content); // Once we retrive the comment, we can remove them $content = preg_replace('/\\<comment\\>(.*?)\\<\\/comment\\>/i', '', $content); $newComment = new stdClass(); $date = new JDate(); $newComment->creator = $actor; $newComment->text = $comment; $newComment->date = $date->toUnix(); $comments[] = $newComment; $commentJson = $json->encode($comments); $content .= '<comment>' . $commentJson . '</comment>'; return $content; }
function __construct($config, $sitemap) { jimport('joomla.utilities.date'); jimport('joomla.user.helper'); $user = JFactory::getUser(); $groups = array_keys(JUserHelper::getUserGroups($user->get('id'))); $date = new JDate(); $this->userLevels = (array) $user->getAuthorisedViewLevels(); // Deprecated: should use userLevels from now on // $this->gid = $user->gid; $this->now = $date->toUnix(); $this->config = $config; $this->sitemap = $sitemap; $this->isNews = false; $this->count = 0; $this->canEdit = false; }
/** * Get the rendering of this field type for static display, e.g. in a single * item view (typically a "read" task). * * @since 2.0 */ public function getStatic() { // Initialize some field attributes. $format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d'; $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // Get some system objects. $config = JFactory::getConfig(); $user = JFactory::getUser(); // If a known filter is given use it. switch (strtoupper((string) $this->element['filter'])) { case 'SERVER_UTC': // Convert a date to UTC based on the server timezone. if ((int) $this->value) { // Get a date object based on the correct timezone. $date = JFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($config->get('offset'))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; case 'USER_UTC': // Convert a date to UTC based on the user timezone. if ((int) $this->value) { // Get a date object based on the correct timezone. $date = JFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset')))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; } jimport('joomla.utilities.date'); $jDue = new JDate($this->value); $jNow = new JDate(); $daysLeft = $jDue->toUnix() - $jNow->toUnix(); if ($daysLeft < 0) { $class = 'todo-due-overdue'; } elseif ($daysLeft < 7) { $class = 'todo-due-closing'; } else { $class = 'todo-due-enoughtime'; } $html = '<span class="' . $class . '">' . $jDue->format(JText::_('DATE_FORMAT_LC'), true, true) . '</span>'; return $html; }
/** * */ public static function getSelectList($group_id = null, $selected = '') { $streamModel = StreamFactory::getModel('stream'); $milestones = $streamModel->getStream(array('type' => 'milestone', 'group_id' => $group_id)); $html = ' <select name="milestone"><option value="">None</option>'; $now = new JDate(); foreach ($milestones as $mstone) { // Don't list overdue milestones $startDate = new JDate($mstone->start_date); $dateDiff = JXDate::timeDifference($startDate->toUnix(), $now->toUnix()); if (!empty($dateDiff['days']) && $dateDiff['days'] > 0) { continue; } $html .= '<option value="' . $mstone->id . '">' . $mstone->message . '</option>'; } $html .= '</select>'; return $html; }
/** * * @param JDate $date * */ public static function timeLapse($date) { $now = new JDate(); $dateDiff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix()); if ($dateDiff['days'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['days']) ? 'COM_COMMUNITY_LAPSED_DAY_MANY' : 'COM_COMMUNITY_LAPSED_DAY', $dateDiff['days']); } elseif ($dateDiff['hours'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['hours']) ? 'COM_COMMUNITY_LAPSED_HOUR_MANY' : 'COM_COMMUNITY_LAPSED_HOUR', $dateDiff['hours']); } elseif ($dateDiff['minutes'] > 0) { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['minutes']) ? 'COM_COMMUNITY_LAPSED_MINUTE_MANY' : 'COM_COMMUNITY_LAPSED_MINUTE', $dateDiff['minutes']); } else { if ($dateDiff['seconds'] == 0) { $lapse = JText::_("COM_COMMUNITY_ACTIVITIES_MOMENT_AGO"); } else { $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['seconds']) ? 'COM_COMMUNITY_LAPSED_SECOND_MANY' : 'COM_COMMUNITY_LAPSED_SECOND', $dateDiff['seconds']); } } return $lapse; }
/** * Add message */ public function add() { $user = JXFactory::getUser(); // Store stream $comment = JTable::getInstance('Comment', 'StreamTable'); $message = JTable::getInstance('Stream', 'StreamTable'); $message->load(JRequest::getVar('stream_id')); $user_id = JRequest::getVar('anon', false) ? JUserHelper::getUserId('anon') : $user->id; // People need to be able to read the message to add comment if (!$user->authorise('stream.message.read', $message)) { // No reason this code would ever get here! exit; } $comment->bind(JRequest::get('POST', JREQUEST_ALLOWRAW)); $comment->raw = json_encode(JRequest::get('POST', JREQUEST_ALLOWRAW)); $comment->user_id = $user_id; $comment->group_id = $message->group_id; $comment->store(); // Update group stats, if it is a group message if (!empty($comment->group_id)) { $group = JTable::getInstance('Group', 'StreamTable'); $group->load($comment->group_id); $group->setParam('last_comment', $comment->id); $group->store(); } // Trigger Notification StreamNotification::trigger('profile_post_comment', $comment); // If the updated date is set further than the current date, it is a pinned stream item and shouldn't be updated $now = new JDate(); $updated = new JDate($message->updated); $preventUpdate = $updated->toUnix() > $now->toUnix(); // Check pinned item status too? For now... naa // Update stream stats. Recalculate the count $this->_recalculateCommentCount($comment->stream_id, $preventUpdate); // Get the HTML code to append $tmpl = new StreamTemplate(); header('Content-Type: text/html; charset=UTF-8'); echo $tmpl->set('comment', $comment)->fetch('comment.item'); exit; }
public function validate($data) { if (empty($data) or !is_array($data)) { throw new InvalidArgumentException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_REWARDS")); } $filter = JFilterInput::getInstance(); foreach ($data as $key => $item) { // Filter data if (!is_numeric($item["amount"])) { $item["amount"] = 0; } $item["title"] = $filter->clean($item["title"], "string"); $item["title"] = JString::trim($item["title"]); $item["title"] = JString::substr($item["title"], 0, 128); $item["description"] = $filter->clean($item["description"], "string"); $item["description"] = JString::trim($item["description"]); $item["description"] = JString::substr($item["description"], 0, 500); $item["number"] = (int) $item["number"]; $item["delivery"] = JString::trim($item["delivery"]); $item["delivery"] = $filter->clean($item["delivery"], "string"); if (!empty($item["delivery"])) { $date = new JDate($item["delivery"]); $unixTime = $date->toUnix(); if ($unixTime < 0) { $item["delivery"] = ""; } } if (!$item["title"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_TITLE")); } if (!$item["description"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_DESCRIPTION")); } if (!$item["amount"]) { throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT")); } $data[$key] = $item; } return $data; }
function showTimeSince($older_date, $newer_date = false) { $chunks = array(array(60 * 60 * 24 * 365, JText::_('COM_KUNENA_DATE_YEAR'), JText::_('COM_KUNENA_DATE_YEARS')), array(60 * 60 * 24 * 30, JText::_('COM_KUNENA_DATE_MONTH'), JText::_('COM_KUNENA_DATE_MONTHS')), array(60 * 60 * 24 * 7, JText::_('COM_KUNENA_DATE_WEEK'), JText::_('COM_KUNENA_DATE_WEEKS')), array(60 * 60 * 24, JText::_('COM_KUNENA_DATE_DAY'), JText::_('COM_KUNENA_DATE_DAYS')), array(60 * 60, JText::_('COM_KUNENA_DATE_HOUR'), JText::_('COM_KUNENA_DATE_HOURS')), array(60, JText::_('COM_KUNENA_DATE_MINUTE'), JText::_('COM_KUNENA_DATE_MINUTES'))); $now = new JDate(); $newer_date = $newer_date === false ? $now->toUnix() : $newer_date; $since = $newer_date - $older_date; // no negatives! if ($since < 0) { return '???'; } // we only want to output two chunks of time here, eg: // x years, xx months // x days, xx hours // so there's only two bits of calculation below: // step one: the first chunk for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; $names = $chunks[$i][2]; // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } // set output var $output = $count == 1 ? '1 ' . $name : $count . ' ' . $names; // step two: the second chunk if ($i + 1 < $j) { $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1]; $names2 = $chunks[$i + 1][2]; if (($count2 = floor(($since - $seconds * $count) / $seconds2)) != 0) { // add to output var $output .= $count2 == 1 ? ', 1 ' . $name2 : ', ' . $count2 . ' ' . $names2; } } return str_replace('%time%', $output, JText::_('COM_KUNENA_TIME_SINCE')); }
public static function formatLapse($date) { $now = new JDate(); $dateDiff = JXDate::timeDifference($date->toUnix(), $now->toUnix()); if ($dateDiff['days'] > 0) { if ($dateDiff['days'] < 30) { $lapse = JText::sprintf(JXString::isPlural($dateDiff['days']) ? 'JXLIB_LAPSED_DAY_MANY' : 'JXLIB_LAPSED_DAY', $dateDiff['days']); } else { $lapse = self::formatDate($date, false); } } elseif ($dateDiff['hours'] > 0) { $lapse = JText::sprintf(JXString::isPlural($dateDiff['hours']) ? 'JXLIB_LAPSED_HOUR_MANY' : 'JXLIB_LAPSED_HOUR', $dateDiff['hours']); } elseif ($dateDiff['minutes'] > 0) { $lapse = JText::sprintf(JXString::isPlural($dateDiff['minutes']) ? 'JXLIB_LAPSED_MINUTE_MANY' : 'JXLIB_LAPSED_MINUTE', $dateDiff['minutes']); } else { if ($dateDiff['seconds'] == 0) { $lapse = JText::_("JXLIB_LAPSED_MOMENT_AGO"); } else { $lapse = JText::sprintf(JXString::isPlural($dateDiff['seconds']) ? 'JXLIB_LAPSED_SECOND_MANY' : 'JXLIB_LAPSED_SECOND', $dateDiff['seconds']); } } return $lapse; }
function installSampleData() { jimport('joomla.utilities.date'); $db = JFactory::getDBO(); $posttime = new JDate(); $my = JFactory::getUser(); $queries = array(); $query = "INSERT INTO `#__kunena_ranks`\n\t(`rank_id`, `rank_title`, `rank_min`, `rank_special`, `rank_image`) VALUES\n\t(1, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK1'))}, 0, 0, 'rank1.gif'),\n\t(2, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK2'))}, 20, 0, 'rank2.gif'),\n\t(3, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK3'))}, 40, 0, 'rank3.gif'),\n\t(4, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK4'))}, 80, 0, 'rank4.gif'),\n\t(5, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK5'))}, 160, 0, 'rank5.gif'),\n\t(6, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK6'))}, 320, 0, 'rank6.gif'),\n\t(7, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_ADMIN'))}, 0, 1, 'rankadmin.gif'),\n\t(8, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_MODERATOR'))}, 0, 1, 'rankmod.gif'),\n\t(9, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_SPAMMER'))}, 0, 1, 'rankspammer.gif'),\n\t(10, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_BANNED'))}, 0, 1, 'rankbanned.gif');"; $queries[] = array('kunena_ranks', $query); $query = "INSERT INTO `#__kunena_smileys`\n\t(`id`,`code`,`location`,`greylocation`,`emoticonbar`) VALUES\n\t(1, 'B)', 'cool.png', 'cool-grey.png', 1),\n\t(2, '8)', 'cool.png', 'cool-grey.png', 0),\n\t(3, '8-)', 'cool.png', 'cool-grey.png', 0),\n\t(4, ':-(', 'sad.png', 'sad-grey.png', 0),\n\t(5, ':(', 'sad.png', 'sad-grey.png', 1),\n\t(6, ':sad:', 'sad.png', 'sad-grey.png', 0),\n\t(7, ':cry:', 'sad.png', 'sad-grey.png', 0),\n\t(8, ':)', 'smile.png', 'smile-grey.png', 1),\n\t(9, ':-)', 'smile.png', 'smile-grey.png', 0),\n\t(10, ':cheer:', 'cheerful.png', 'cheerful-grey.png', 1),\n\t(11, ';)', 'wink.png', 'wink-grey.png', 1),\n\t(12, ';-)', 'wink.png', 'wink-grey.png', 0),\n\t(13, ':wink:', 'wink.png', 'wink-grey.png', 0),\n\t(14, ';-)', 'wink.png', 'wink-grey.png', 0),\n\t(15, ':P', 'tongue.png', 'tongue-grey.png', 1),\n\t(16, ':p', 'tongue.png', 'tongue-grey.png', 0),\n\t(17, ':-p', 'tongue.png', 'tongue-grey.png', 0),\n\t(18, ':-P', 'tongue.png', 'tongue-grey.png', 0),\n\t(19, ':razz:', 'tongue.png', 'tongue-grey.png', 0),\n\t(20, ':angry:', 'angry.png', 'angry-grey.png', 1),\n\t(21, ':mad:', 'angry.png', 'angry-grey.png', 0),\n\t(22, ':unsure:', 'unsure.png', 'unsure-grey.png', 1),\n\t(23, ':o', 'shocked.png', 'shocked-grey.png', 0),\n\t(24, ':-o', 'shocked.png', 'shocked-grey.png', 0),\n\t(25, ':O', 'shocked.png', 'shocked-grey.png', 0),\n\t(26, ':-O', 'shocked.png', 'shocked-grey.png', 0),\n\t(27, ':eek:', 'shocked.png', 'shocked-grey.png', 0),\n\t(28, ':ohmy:', 'shocked.png', 'shocked-grey.png', 1),\n\t(29, ':huh:', 'wassat.png', 'wassat-grey.png', 1),\n\t(30, ':?', 'confused.png', 'confused-grey.png', 0),\n\t(31, ':-?', 'confused.png', 'confused-grey.png', 0),\n\t(32, ':???', 'confused.png', 'confused-grey.png', 0),\n\t(33, ':dry:', 'ermm.png', 'ermm-grey.png', 1),\n\t(34, ':ermm:', 'ermm.png', 'ermm-grey.png', 0),\n\t(35, ':lol:', 'grin.png', 'grin-grey.png', 1),\n\t(36, ':X', 'sick.png', 'sick-grey.png', 0),\n\t(37, ':x', 'sick.png', 'sick-grey.png', 0),\n\t(38, ':sick:', 'sick.png', 'sick-grey.png', 1),\n\t(39, ':silly:', 'silly.png', 'silly-grey.png', 1),\n\t(40, ':y32b4:', 'silly.png', 'silly-grey.png', 0),\n\t(41, ':blink:', 'blink.png', 'blink-grey.png', 1),\n\t(42, ':blush:', 'blush.png', 'blush-grey.png', 1),\n\t(43, ':oops:', 'blush.png', 'blush-grey.png', 1),\n\t(44, ':kiss:', 'kissing.png', 'kissing-grey.png', 1),\n\t(45, ':rolleyes:', 'blink.png', 'blink-grey.png', 0),\n\t(46, ':roll:', 'blink.png', 'blink-grey.png', 0),\n\t(47, ':woohoo:', 'w00t.png', 'w00t-grey.png', 1),\n\t(48, ':side:', 'sideways.png', 'sideways-grey.png', 1),\n\t(49, ':S', 'dizzy.png', 'dizzy-grey.png', 1),\n\t(50, ':s', 'dizzy.png', 'dizzy-grey.png', 0),\n\t(51, ':evil:', 'devil.png', 'devil-grey.png', 1),\n\t(52, ':twisted:', 'devil.png', 'devil-grey.png', 0),\n\t(53, ':whistle:', 'whistling.png', 'whistling-grey.png', 1),\n\t(54, ':pinch:', 'pinch.png', 'pinch-grey.png', 1),\n\t(55, ':D', 'laughing.png', 'laughing-grey.png', 0),\n\t(56, ':-D', 'laughing.png', 'laughing-grey.png', 0),\n\t(57, ':grin:', 'laughing.png', 'laughing-grey.png', 0),\n\t(58, ':laugh:', 'laughing.png', 'laughing-grey.png', 0),\n\t(59, ':|', 'neutral.png', 'neutral-grey.png', 0),\n\t(60, ':-|', 'neutral.png', 'neutral-grey.png', 0),\n\t(61, ':neutral:', 'neutral.png', 'neutral-grey.png', 0),\n\t(62, ':mrgreen:', 'mrgreen.png', 'mrgreen-grey.png', 0),\n\t(63, ':?:', 'question.png', 'question-grey.png', 0),\n\t(64, ':!:', 'exclamation.png', 'exclamation-grey.png', 0),\n\t(65, ':arrow:', 'arrow.png', 'arrow-grey.png', 0),\n\t(66, ':idea:', 'idea.png', 'idea-grey.png', 0)"; $queries[] = array('kunena_smileys', $query); if (KUNENA_JOOMLA_COMPAT == '1.5') { $query = "INSERT INTO `#__kunena_categories`\n\t\t(`id`, `parent`, `name`, `pub_access`, `ordering`, `published`, `description`, `headerdesc`, `numTopics`, `numPosts`, `allow_polls`) VALUES\n\t\t(1, 0, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_TITLE')) . ", 0, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_HEADER')) . ", 0, 0, 0),\n\t\t(2, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_TITLE')) . ", 0, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_HEADER')) . ",1 ,1, 0),\n\t\t(3, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_TITLE')) . ", 0, 2, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_HEADER')) . ",0 ,0, 1);"; } else { $query = "INSERT INTO `#__kunena_categories`\n\t\t(`id`, `parent`, `name`, `pub_access`, `ordering`, `published`, `description`, `headerdesc`, `numTopics`, `numPosts`, `allow_polls`) VALUES\n\t\t(1, 0, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_TITLE')) . ", 1, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_HEADER')) . ", 0, 0, 0),\n\t\t(2, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_TITLE')) . ", 1, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_HEADER')) . ",1 ,1, 0),\n\t\t(3, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_TITLE')) . ", 1, 2, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_HEADER')) . ",0 ,0, 1);"; } $queries[] = array('kunena_categories', $query); $query = "INSERT INTO `#__kunena_messages`\n\t(`id`, `parent`, `thread`, `catid`, `userid`, `name`, `subject`, `time`, `ip`) VALUES\n\t(1, 0, 1, 2, " . $db->quote($my->id) . ", 'Kunena', " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST1_SUBJECT')) . ", " . $posttime->toUnix() . ", '127.0.0.1');"; $queries[] = array('kunena_messages', $query); $query = "INSERT INTO `#__kunena_messages_text`\n\t(`mesid`, `message`) VALUES\n\t(1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST1_TEXT')) . ");"; $queries[] = array('kunena_messages_text', $query); $counter = 0; foreach ($queries as $query) { // Only insert sample/default data if table is empty $db->setQuery("SELECT COUNT(*) FROM " . $db->nameQuote($db->getPrefix() . $query[0])); $count = $db->loadResult(); if (!$count) { $db->setQuery($query[1]); $db->query(); if ($db->getErrorNum()) { throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum()); } $counter++; } } return $counter; }
/** * * @param JDate $date * */ public static function timeLapse($date, $showFull = true) { $now = JFactory::getDate(); $html = ''; $diff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix()); if (!empty($diff['days'])) { $days = $diff['days']; $months = ceil($days / 30); switch ($days) { case $days == 1: // @rule: Something that happened yesterday $html .= JText::_('COM_COMMUNITY_LAPSED_YESTERDAY'); break; case $days > 1 && $days <= 7 && $days < 30: // @rule: Something that happened within the past 7 days $html .= JText::sprintf('COM_COMMUNITY_LAPSED_DAYS', $days) . ' '; break; case $days > 1 && $days > 7 && $days < 30: // @rule: Something that happened within the month but after a week $weeks = round($days / 7); $html .= JText::sprintf(CStringHelper::isPlural($weeks) ? 'COM_COMMUNITY_LAPSED_WEEK_MANY' : 'COM_COMMUNITY_LAPSED_WEEK', $weeks) . ' '; break; case $days >= 30 && $days < 365: // @rule: Something that happened months ago $months = round($days / 30); $html .= JText::sprintf(CStringHelper::isPlural($months) ? 'COM_COMMUNITY_LAPSED_MONTH_MANY' : 'COM_COMMUNITY_LAPSED_MONTH', $months) . ' '; break; case $days > 365: // @rule: Something that happened years ago $years = round($days / 365); $html .= JText::sprintf(CStringHelper::isPlural($years) ? 'COM_COMMUNITY_LAPSED_YEAR_MANY' : 'COM_COMMUNITY_LAPSED_YEAR', $years) . ' '; break; } } else { // We only show he hours if it is less than 1 day if (!empty($diff['hours'])) { if (!empty($diff['minutes'])) { if ($diff['hours'] == 1) { $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOUR', $diff['hours']) . ' '; } else { $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOURS', $diff['hours']) . ' '; } } else { $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOURS_AGO', $diff['hours']) . ' '; } } if ($showFull && !empty($diff['hours']) || empty($diff['hours'])) { if (!empty($diff['minutes'])) { if ($diff['minutes'] == 1) { $html .= JText::sprintf('COM_COMMUNITY_LAPSED_MINUTE', $diff['minutes']) . ' '; } else { $html .= JText::sprintf('COM_COMMUNITY_LAPSED_MINUTES', $diff['minutes']) . ' '; } } } } if (empty($html)) { $html .= JText::_('COM_COMMUNITY_LAPSED_LESS_THAN_A_MINUTE'); } return $html; }
private function _getFilters() { $filters = array(); if ($this->lists->fltDescription) { $filters[] = array('field' => 'description', 'operand' => 'LIKE', 'value' => $this->lists->fltDescription); } if ($this->lists->fltFrom && $this->lists->fltTo) { $filters[] = array('field' => 'backupstart', 'operand' => 'BETWEEN', 'value' => $this->lists->fltFrom, 'value2' => $this->lists->fltTo); } elseif ($this->lists->fltFrom) { $filters[] = array('field' => 'backupstart', 'operand' => '>=', 'value' => $this->lists->fltFrom); } elseif ($this->lists->fltTo) { JLoader::import('joomla.utilities.date'); $to = new JDate($this->lists->fltTo); $toUnix = $to->toUnix(); $to = date('Y-m-d') . ' 23:59:59'; $filters[] = array('field' => 'backupstart', 'operand' => '<=', 'value' => $to); } if ($this->lists->fltOrigin) { $filters[] = array('field' => 'origin', 'operand' => '=', 'value' => $this->lists->fltOrigin); } if ($this->lists->fltProfile) { $filters[] = array('field' => 'profile_id', 'operand' => '=', 'value' => (int) $this->lists->fltProfile); } $session = JFactory::getSession(); $task = $session->get('buadmin.task', 'browse', 'akeeba'); if ($task == 'restorepoint') { $filters[] = array('field' => 'tag', 'operand' => '=', 'value' => 'restorepoint'); } else { $filters[] = array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'); } if (empty($filters)) { $filters = null; } return $filters; }
/** * Prints an XML node for the sitemap * * @param stdclass $node */ function printNode($node) { $node->isExcluded = false; if ($this->isExcluded($node->id, $node->uid)) { if (!$this->showExcluded || !$this->canEdit) { return false; } $node->isExcluded = true; } if ($this->isNews && (!isset($node->newsItem) || !$node->newsItem)) { return true; } // For images sitemaps only display pages with images if ($this->isImages && (!isset($node->images) || !count($node->images))) { return true; } // Get the item's URL $link = JRoute::_($node->link, true, @$node->secure == 0 ? JFactory::getURI()->isSSL() ? 1 : -1 : $node->secure); if (!isset($node->browserNav)) { $node->browserNav = 0; } if ($node->browserNav != 3 && empty($this->_links[$link])) { // ignore links that have been added already $this->count++; $this->_links[$link] = 1; if (!isset($node->priority)) { $node->priority = "0.5"; } if (!isset($node->changefreq)) { $node->changefreq = 'daily'; } // Get the chancefrequency and priority for this item $changefreq = $this->getProperty('changefreq', $node->changefreq, $node->id, 'xml', $node->uid); $priority = $this->getProperty('priority', $node->priority, $node->id, 'xml', $node->uid); echo '<url>' . "\n"; echo '<loc>', $link, '</loc>' . "\n"; if ($this->canEdit) { if ($this->showTitle) { echo '<title><![CDATA[' . $node->name . ']]></title>' . "\n"; } if ($this->showExcluded) { echo '<rowclass>', $node->isExcluded ? 'excluded' : '', '</rowclass>'; } echo '<uid>', $node->uid, '</uid>' . "\n"; echo '<itemid>', $node->id, '</itemid>' . "\n"; } $modified = isset($node->modified) && $node->modified != FALSE && $node->modified != $this->nullDate && $node->modified != -1 ? $node->modified : NULL; if (!$modified && $this->isNews) { $modified = time(); } if ($modified && !is_numeric($modified)) { $date = new JDate($modified); $modified = $date->toUnix(); } if ($modified) { $modified = gmdate('Y-m-d\\TH:i:s\\Z', $modified); } // If this is not a news sitemap if (!$this->isNews) { if ($this->isImages) { foreach ($node->images as $image) { echo '<image:image>', "\n"; echo '<image:loc>', $image->src, '</image:loc>', "\n"; if ($image->title) { $image->title = str_replace('&', '&', html_entity_decode($image->title, ENT_NOQUOTES, 'UTF-8')); echo '<image:title>', $image->title, '</image:title>', "\n"; } else { echo '<image:title />'; } if (isset($image->license) && $image->license) { echo '<image:license>', str_replace('&', '&', html_entity_decode($image->license, ENT_NOQUOTES, 'UTF-8')), '</image:license>', "\n"; } echo '</image:image>', "\n"; } } else { if ($modified) { echo '<lastmod>', $modified, '</lastmod>' . "\n"; } echo '<changefreq>', $changefreq, '</changefreq>' . "\n"; echo '<priority>', $priority, '</priority>' . "\n"; } } else { if (isset($node->keywords)) { $keywords = htmlspecialchars($node->keywords); } else { $keywords = ''; } if (!isset($node->language) || $node->language == '*') { $node->language = $this->defaultLanguage; } echo "<news:news>\n"; echo '<news:publication>' . "\n"; echo ' <news:name>' . htmlspecialchars($this->sitemap->params->get('news_publication_name')) . '</news:name>' . "\n"; echo ' <news:language>' . $node->language . '</news:language>' . "\n"; echo '</news:publication>' . "\n"; echo '<news:publication_date>', $modified, '</news:publication_date>' . "\n"; echo '<news:title><![CDATA[' . $node->name . ']]></news:title>' . "\n"; if ($keywords) { echo '<news:keywords>', $keywords, '</news:keywords>' . "\n"; } echo "</news:news>\n"; } echo '</url>', "\n"; } else { return empty($this->_links[$link]); } return true; }
$origin = JText::_($origin_lbl); /* if($origin == $origin_lbl) { $origin = '–'; } /**/ if (array_key_exists($record['type'], $backup_types)) { $type = $backup_types[$record['type']]; } else { $type = '–'; } JLoader::import('joomla.utilities.date'); $startTime = new JDate($record['backupstart']); $endTime = new JDate($record['backupend']); $duration = $endTime->toUnix() - $startTime->toUnix(); if ($duration > 0) { $seconds = $duration % 60; $duration = $duration - $seconds; $minutes = $duration % 3600 / 60; $duration = $duration - $minutes * 60; $hours = $duration / 3600; $duration = sprintf('%02d', $hours) . ':' . sprintf('%02d', $minutes) . ':' . sprintf('%02d', $seconds); } else { $duration = '-'; } /* $user = JFactory::getUser(); $userTZ = $user->getParam('timezone',0); $startTime->setOffset($userTZ); */
/** * @return bool */ public function isBanned() { if (!$this->banned) { return false; } if ($this->blocked || $this->banned == $this->_db->getNullDate()) { return true; } $ban = new JDate($this->banned); $now = new JDate(); return $ban->toUnix() > $now->toUnix(); }
/** * A new message submitted via ajax */ public function ajaxSend($postVars) { //$postVars pending filtering $objResponse = new JAXResponse(); $config = CFactory::getConfig(); $my = CFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } //CFactory::load( 'helpers', 'time' ); $inboxModel = $this->getModel('inbox'); $lastSent = $inboxModel->getLastSentTime($my->id); $dateNow = new JDate(); // We need to make sure that this guy are not spamming other people inbox // by checking against his last message time. Make sure it doesn't exceed // pmFloodLimit config (in seconds). if ($dateNow->toUnix() - $lastSent->toUnix() < $config->get('floodLimit') && !COwnerHelper::isCommunityAdmin()) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::sprintf('COM_COMMUNITY_PLEASE_WAIT_BEFORE_SENDING_MESSAGE', $config->get('floodLimit')); die(json_encode($json)); } // Prevent users to send message to themselves. if ($postVars['to'] == $my->id) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_SEND_TO_SELF'); die(json_encode($json)); } $postVars = CAjaxHelper::toArray($postVars); $doCont = true; $errMsg = ""; $resizeH = 0; if ($this->_isSpam($my, $postVars['subject'] . ' ' . $postVars['body'])) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM'); die(json_encode($json)); } if (empty($postVars['subject']) || JString::trim($postVars['subject']) == '') { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_SUBJECT_MISSING'); $json['samestep'] = true; die(json_encode($json)); } if (empty($postVars['body']) || JString::trim($postVars['body']) == '') { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MISSING'); $json['samestep'] = true; die(json_encode($json)); } $data = $postVars; $model = $this->getModel('inbox'); $pattern = "/<br \\/>/i"; $replacement = "\r\n"; $data['body'] = preg_replace($pattern, $replacement, $data['body']); $data['photo'] = isset($data['photo']) ? $data['photo'] : ''; $msgid = $model->send($data); // Add user points. CUserPoints::assignPoint('inbox.message.send'); // Add notification. $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid); $params->set('message', $data['body']); $params->set('title', $data['subject']); $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid); $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE')); CNotificationLibrary::add('inbox_create_message', $my->id, $data['to'], JText::sprintf('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params); // Send response. $json = array(); $json['message'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_SENT'); die(json_encode($json)); }
private function _getFilters() { $filters = array(); if($this->lists->fltDescription) { $filters[] = array( 'field' => 'description', 'operand' => 'LIKE', 'value' => $this->lists->fltDescription ); } if($this->lists->fltFrom && $this->lists->fltTo) { $filters[] = array( 'field' => 'backupstart', 'operand' => 'BETWEEN', 'value' => $this->lists->fltFrom, 'value2' => $this->lists->fltTo ); } elseif ($this->lists->fltFrom) { $filters[] = array( 'field' => 'backupstart', 'operand' => '>=', 'value' => $this->lists->fltFrom, ); } elseif($this->lists->fltTo) { jimport('joomla.utilities.date'); $to = new JDate($this->lists->fltTo); $toUnix = $to->toUnix(); $to = date('Y-m-d').' 23:59:59'; $filters[] = array( 'field' => 'backupstart', 'operand' => '<=', 'value' => $to, ); } if($this->lists->fltOrigin) { $filters[] = array( 'field' => 'origin', 'operand' => '=', 'value' => $this->lists->fltOrigin ); } if($this->lists->fltProfile) { $filters[] = array( 'field' => 'profile_id', 'operand' => '=', 'value' => (int)$this->lists->fltProfile ); } $task = JRequest::getCmd('task','default'); if($task == 'restorepoint') { $filters[] = array( 'field' => 'tag', 'operand' => '=', 'value' => 'restorepoint' ); } else { $filters[] = array( 'field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint' ); } if(empty($filters)) $filters = null; return $filters; }
private function getLastSend() { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select($db->qn('lastupdate'))->from($db->qn('#__ak_storage'))->where($db->qn('tag') . ' = ' . $db->q('akeeba_autoupdate_lastsend')); $result = $db->setQuery($query)->loadResult(); if (!$result) { return 0; } else { $date = new JDate($result); return $date->toUnix(); } }