Example #1
1
 function display($tpl = null)
 {
     global $mainframe, $option;
     $cid = JRequest::getVar('cid_user');
     if (!is_array($cid)) {
         $mainframe->redirect('index.php?option=' . $option);
         return;
     }
     $user_id = $cid[0];
     $model = $this->getModel('user');
     $model->load($user_id);
     $this->_setToolBar();
     $say = JText::sprintf('USER_RESOURCES_TITLE', $model->user->username);
     $root_node = JText::_('RESOURCES_TREE_ROOT_NODE');
     $nowdate = JFactory::getDate();
     $str_now = JHTML::_('date', $nowdate->toMySQL(), '%Y-%m-%d %H:%M:%S');
     $this->assign('nowdate', $str_now);
     $this->assign('say', $say);
     $this->assign('root_node', $root_node);
     $this->assignRef('uid', $user_id);
     $this->assignRef('option', $option);
     //hide the menu
     JRequest::setVar('hidemainmenu', 1);
     parent::display();
 }
Example #2
1
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     // Attempt to store the user data.
     return parent::store($updateNulls);
 }
Example #3
1
 public function store($updateNulls = true)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         $this->modified_time = $date->toSql();
         $this->modified_user_id = $user->get('id');
     } else {
         if (!(int) $this->created_time) {
             $this->created_time = $date->toSql();
         }
         if (empty($this->created_user_id)) {
             $this->created_user_id = $user->get('id');
         }
     }
     $table = JTable::getInstance('Page', 'SppagebuilderTable');
     $alias = JFilterOutput::stringURLSafe($this->alias);
     if ($alias == '') {
         $alias = JFilterOutput::stringURLSafe($this->title);
     }
     $this->alias = $alias;
     if ($table->load(array('alias' => $alias)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_SPPAGEBUILDER_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     return parent::store($updateNulls);
 }
 /**
  * Make sure the slug is unique
  *
  * This function checks if the slug already exists and if so appends a number to the slug to make it unique. The
  * slug will get the form of slug-x.
  *
  * If the slug is empty it returns the current date in the format Y-m-d-H-i-s
  *
  * @return void
  */
 protected function _canonicalizeSlug()
 {
     if (trim(str_replace($this->_separator, '', $this->slug)) == '') {
         $this->slug = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     parent::_canonicalizeSlug();
 }
 /**
  * @param XmapDisplayerInterface $xmap
  * @param stdClass $parent
  * @param array $params
  */
 public static function getTree($xmap, stdClass $parent, array &$params)
 {
     $uri = new JUri($parent->link);
     if ($xmap->isNews || !self::$enabled || !in_array($uri->getVar('view'), self::$views)) {
         return;
     }
     $params['include_topics'] = JArrayHelper::getValue($params, 'include_topics', 1);
     $params['include_topics'] = $params['include_topics'] == 1 || $params['include_topics'] == 2 && $xmap->view == 'xml' || $params['include_topics'] == 3 && $xmap->view == 'html';
     $params['include_pagination'] = JArrayHelper::getValue($params, 'include_pagination', 0);
     $params['include_pagination'] = $params['include_pagination'] == 1 || $params['include_pagination'] == 2 && $xmap->view == 'xml' || $params['include_pagination'] == 3 && $xmap->view == 'html';
     $params['cat_priority'] = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
     $params['cat_priority'] = $params['cat_priority'] == -1 ? $parent->priority : $params['cat_priority'];
     $params['cat_changefreq'] = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
     $params['cat_changefreq'] = $params['cat_changefreq'] == -1 ? $parent->changefreq : $params['cat_changefreq'];
     $params['topic_priority'] = JArrayHelper::getValue($params, 'topic_priority', $parent->changefreq);
     $params['topic_priority'] = $params['topic_priority'] == -1 ? $parent->priority : $params['topic_priority'];
     $params['topic_changefreq'] = JArrayHelper::getValue($params, 'topic_changefreq', $parent->changefreq);
     $params['topic_changefreq'] = $params['topic_changefreq'] == -1 ? $parent->changefreq : $params['topic_changefreq'];
     if ($params['include_topics']) {
         if ((int) ($limit = JArrayHelper::getValue($params, 'max_topics', 0))) {
             $params['limit'] = $limit;
         } else {
             $params['limit'] = 0;
         }
         if ((int) ($days = JArrayHelper::getValue($params, 'max_age', 0))) {
             $params['days'] = JFactory::getDate()->toUnix() - intval($days) * 86400;
         } else {
             $params['days'] = '';
         }
     }
     self::getCategoryTree($xmap, $parent, $params, $uri->getVar('catid', 0));
 }
Example #6
0
function update_cats_and_links_count($cat_id = 0, $updateOrder = true, $visible_links_only = false)
{
    $database =& JFactory::getDBO();
    $nullDate = $database->getNullDate();
    $sql = "SELECT cat_id FROM #__mt_cats WHERE cat_parent={$cat_id} ";
    if ($visible_links_only) {
        $sql .= "AND cat_published = '1' AND cat_approved = '1'";
    }
    $database->setQuery($sql);
    $retval["cats"] = 0;
    $retval["links"] = 0;
    //all children and their links
    $cat_ids = $database->loadResultArray();
    foreach ($cat_ids as $cid) {
        $val = update_cats_and_links_count($cid, $updateOrder, $visible_links_only);
        $retval["cats"] += $val["cats"] + 1;
        $retval["links"] += $val["links"];
        $database->setQuery("UPDATE #__mt_cats SET cat_cats=" . $val["cats"] . ", cat_links=" . $val["links"] . " WHERE cat_id = " . $cid);
        $database->query();
    }
    # Update its own links
    $jdate = JFactory::getDate();
    $now = $jdate->toMySQL();
    $sql2 = "SELECT count(l.link_id) FROM #__mt_links AS l, #__mt_cl AS cl WHERE l.link_id = cl.link_id AND cl.cat_id={$cat_id} ";
    if ($visible_links_only) {
        $sql2 .= "AND link_published = '1' AND link_approved = '1'" . " AND ( l.publish_up = " . $database->Quote($nullDate) . " OR l.publish_up <= '{$now}'  ) " . " AND ( l.publish_down = " . $database->Quote($nullDate) . " OR l.publish_down >= '{$now}' ) ";
    }
    $database->setQuery($sql2);
    $count_links = $database->loadResult();
    if ($count_links >= 0) {
        $retval["links"] += $count_links;
    }
    return $retval;
}
Example #7
0
 /**
  * Load properties from a given file properties
  * 
  * @param $file string The filename to scan
  * @param $contents boolean Load the contents
  * @param $loadId boolean Load id from database
  * @return boolean result
  */
 function loadFromFile($file, $contents = false, $loadId = false)
 {
     if (!JFile::exists($file) && !JFolder::exists($file . DS)) {
         return false;
     }
     $info = @stat($file);
     $this->scandate = $this->_db->getNullDate();
     $this->filename = basename($file);
     $this->fullpath = $file;
     $this->permission = fileperms($file) & 0777;
     $this->size = filesize($file);
     $ctime =& JFactory::getDate($info['ctime']);
     $mtime =& JFactory::getDate($info['mtime']);
     $this->ctime = $ctime->toMySQL();
     $this->mtime = $mtime->toMySQL();
     $this->uid = $info['uid'];
     $this->gid = $info['gid'];
     $this->type = '';
     if (is_file($file)) {
         $this->type = 'file';
         $this->hash_md = md5_file($file);
         if ($contents) {
             $f = new JD_File($file);
             $this->contents = $f->read();
         }
     } elseif (is_dir($file)) {
         $this->type = 'dir';
     }
     if ($loadId) {
         $this->_db->setQuery('SELECT id FROM #__jdefender_filesystem WHERE fullpath = ' . $this->fullpath . ' LIMIT 1');
         $this->id = $this->_db->loadResult();
     }
     return true;
 }
Example #8
0
 public function check()
 {
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_JUDOWNLOAD_TITLE_MUST_NOT_BE_EMPTY'));
         return false;
     }
     if (trim($this->alias) == '') {
         $this->alias = $this->title;
     }
     $this->alias = JApplication::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     if (trim(str_replace('&nbsp;', '', $this->description)) == '') {
         $this->description = '';
     }
     if (!empty($this->metakeyword)) {
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = JString::str_ireplace($bad_characters, "", $this->metakeyword);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         $this->metakeyword = implode(", ", $clean_keys);
     }
     return true;
 }
Example #9
0
 function save($data)
 {
     $oldData = array();
     if ($data['id'] > 0) {
         $table = $this->getTable();
         $table->load($data['id']);
         $oldData['id'] = $table->id;
         $oldData['provider'] = $table->provider;
         $oldData['type'] = $table->type;
         $oldData['attribs'] = (array) $table->attribs;
     }
     // Set the dates
     $date = JFactory::getDate();
     if ($data['id'] == 0) {
         $data['created'] = $date->toSql();
     }
     $data['modified'] = $date->toSql();
     if ($data['provider'] != '--' && $data['type'] != '--') {
         $channel = JFBCFactory::provider($data['provider'])->channel($data['type']);
         $data = $channel->onBeforeSave($data);
         // Manipulate the data however may be necessary
     }
     $return = parent::save($data);
     // Used to removed permissions from users that aren't associated with this channel (or anything else needed for cleanup)
     if ($return && $data['provider'] != '--' && $data['type'] != '--') {
         $data['id'] = $this->getState('channel.id');
         $channel->onAfterSave($data, $oldData);
     }
     return $return;
 }
Example #10
0
 protected function prepareTable($table)
 {
     jimport('joomla.filter.output');
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
     $table->alias = JApplication::stringURLSafe($table->alias);
     if (empty($table->alias)) {
         $table->alias = JApplication::stringURLSafe($table->title);
     }
     if (intval($table->date) == 0) {
         $table->date = JFactory::getDate()->toSql();
     }
     if (empty($table->id)) {
         // Set the values
         //$table->created	= $date->toSql();
         // Set ordering to the last item if not set
         if (empty($table->ordering)) {
             $db = JFactory::getDbo();
             $db->setQuery('SELECT MAX(ordering) FROM #__phocagallery_comments WHERE catid = ' . (int) $table->catid);
             $max = $db->loadResult();
             $table->ordering = $max + 1;
         }
     } else {
         // Set the values
         //$table->modified	= $date->toSql();
         //$table->modified_by	= $user->get('id');
     }
 }
Example #11
0
 /**
  * Overloaded check function
  *
  * @return  boolean  True on success
  *
  * @see     JTable::check
  * @since   11.1
  */
 public function check()
 {
     // If the alias field is empty, set it to the title.
     $this->alias = trim($this->alias);
     if (empty($this->alias) && ($this->type != 'alias' && $this->type != 'url')) {
         $this->alias = $this->title;
     }
     // Make the alias URL safe.
     $this->alias = JApplication::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     // Cast the home property to an int for checking.
     $this->home = (int) $this->home;
     // Verify that a first level menu item alias is not 'component'.
     if ($this->parent_id == 1 && $this->alias == 'component') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT'));
         return false;
     }
     // Verify that a first level menu item alias is not the name of a folder.
     jimport('joomla.filesystem.folder');
     if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) {
         $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias));
         return false;
     }
     // Verify that the home item a component.
     if ($this->home && $this->type != 'component') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
         return false;
     }
     return true;
 }
 /**
  * Method to get newsfeed data.
  *
  * @param   integer	The id of the newsfeed.
  *
  * @return  mixed  Menu item data object on success, false on failure.
  * @since   1.6
  */
 public function &getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState('newsfeed.id');
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             $db = $this->getDbo();
             $query = $db->getQuery(true)->select($this->getState('item.select', 'a.*'))->from('#__newsfeeds AS a');
             // Join on category table.
             $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')->join('LEFT', '#__categories AS c on c.id = a.catid');
             // Join on user table.
             $query->select('u.name AS author')->join('LEFT', '#__users AS u on u.id = a.created_by');
             // Join over the categories to get parent category titles
             $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')->join('LEFT', '#__categories as parent ON parent.id = c.parent_id')->where('a.id = ' . (int) $pk);
             // Filter by start and end dates.
             $nullDate = $db->quote($db->getNullDate());
             $nowDate = $db->quote(JFactory::getDate()->toSql());
             // Filter by published state.
             $published = $this->getState('filter.published');
             $archived = $this->getState('filter.archived');
             if (is_numeric($published)) {
                 $query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')')->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')')->where('(c.published = ' . (int) $published . ' OR c.published =' . (int) $archived . ')');
             }
             $db->setQuery($query);
             $data = $db->loadObject();
             if (empty($data)) {
                 JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
             }
             // Check for published state if filter set.
             if ((is_numeric($published) || is_numeric($archived)) && ($data->published != $published && $data->published != $archived)) {
                 JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
             }
             // Convert parameter fields to objects.
             $registry = new JRegistry();
             $registry->loadString($data->params);
             $data->params = clone $this->getState('params');
             $data->params->merge($registry);
             $registry = new JRegistry();
             $registry->loadString($data->metadata);
             $data->metadata = $registry;
             // Compute access permissions.
             if ($access = $this->getState('filter.access')) {
                 // If the access filter has been set, we already know this user can view.
                 $data->params->set('access-view', true);
             } else {
                 // If no access filter is set, the layout takes some responsibility for display of limited information.
                 $user = JFactory::getUser();
                 $groups = $user->getAuthorisedViewLevels();
                 $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
             }
             $this->_item[$pk] = $data;
         } catch (Exception $e) {
             $this->setError($e);
             $this->_item[$pk] = false;
         }
     }
     return $this->_item[$pk];
 }
Example #13
0
 public static function getAliasName($name)
 {
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $alias_iconv = $paramsC->get('alias_iconv', 0);
     $iconv = 0;
     if ($alias_iconv == 1) {
         if (function_exists('iconv')) {
             $name = preg_replace('~[^\\pL0-9_.]+~u', '-', $name);
             $name = trim($name, "-");
             $name = iconv("utf-8", "us-ascii//TRANSLIT", $name);
             $name = strtolower($name);
             $name = preg_replace('~[^-a-z0-9_.]+~', '', $name);
             $iconv = 1;
         } else {
             $iconv = 0;
         }
     }
     if ($iconv == 0) {
         $name = JFilterOutput::stringURLSafe($name);
     }
     if (trim(str_replace('-', '', $name)) == '') {
         JFactory::getDate()->format("Y-m-d-H-i-s");
     }
     return $name;
 }
Example #14
0
 /**
  * Sets last scan date
  * @param JDate $now
  */
 function setLastScanDate($now = false)
 {
     if (empty($now) || !@is_a($now, 'JDate')) {
         $now =& JFactory::getDate();
     }
     JD_Vars_Helper::setVar('last_scan_date', 'jdefender', $now->toMySQL());
 }
Example #15
0
 public function parseValue($value)
 {
     if (!$this->isPublished()) {
         return null;
     }
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $filter = strtoupper((string) $this->getFilter());
     switch ($filter) {
         case 'SERVER_UTC':
             if (intval($value)) {
                 $date = JFactory::getDate($value, 'UTC');
                 $date->setTimezone(new DateTimeZone($config->get('offset')));
                 $value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
         case 'USER_UTC':
             if (intval($value)) {
                 $date = JFactory::getDate($value, 'UTC');
                 $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
                 $value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
     }
     return $value;
 }
Example #16
0
 protected function _prepareTable(&$table)
 {
     jimport('joomla.filter.output');
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
 }
Example #17
0
	public static function getAliasName($alias) {	
		$alias = JApplication::stringURLSafe($alias);
		if (trim(str_replace('-', '', $alias)) == '') {
			$alias = JFactory::getDate()->format("Y-m-d-H-i-s");
		}
		return $alias;
	}
Example #18
0
 protected function getListQuery()
 {
     $tagId = (int) $this->getState('tag.id');
     $ordering = $this->getState('list.ordering', '');
     $direction = $this->getState('list.direction', 'ASC');
     $user = JFactory::getUser();
     $levels = $user->getAuthorisedViewLevels();
     $levelsStr = implode(',', $levels);
     $db = JFactory::getDbo();
     $nullDate = $db->getNullDate();
     $nowDate = JFactory::getDate()->toSql();
     $query = $db->getQuery(true);
     $query->select('listing.*');
     $query->from('#__judirectory_listings AS listing');
     JUDirectoryFrontHelper::optimizeListListingQuery($query);
     $query->join('', '#__judirectory_tags_xref AS txref ON txref.listing_id = listing.id');
     $query->where('listing.approved = 1');
     $query->where('listing.published = 1');
     $query->where('(listing.publish_up = ' . $db->quote($nullDate) . ' OR listing.publish_up <= ' . $db->quote($nowDate) . ')');
     $query->where('(listing.publish_down = ' . $db->quote($nullDate) . ' OR listing.publish_down >= ' . $db->quote($nowDate) . ')');
     if ($user->get('guest')) {
         $query->where('listing.access IN (' . $levelsStr . ')');
     } else {
         $query->where('(listing.access IN (' . $levelsStr . ') OR (listing.created_by = ' . $user->id . '))');
     }
     $query->where('txref.tag_id=' . $tagId);
     $app = JFactory::getApplication();
     $languageTag = JFactory::getLanguage()->getTag();
     if ($app->getLanguageFilter()) {
         $query->where('listing.language IN (' . $db->quote($languageTag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')');
     }
     JUDirectoryFrontHelperField::appendFieldOrderingPriority($query, null, $ordering, $direction);
     return $query;
 }
Example #19
0
 /**
  * Stores the object
  * @param object
  * @return boolean
  */
 function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $this->modified_date = $date->toSql();
     $store = parent::store($updateNulls);
     return $store;
 }
Example #20
0
 public static function init($name, $extension, $params)
 {
     // Init
     $name_date = $params->get('filename_date', '');
     $tmp_path = JFactory::getConfig()->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     // Set
     $output = new stdClass();
     $output->name = $name;
     $output->suffix = $name_date != '' ? '_' . JFactory::getDate()->format($name_date) : '';
     $output->path = $tmp_path . '/' . $tmp_dir;
     $output->root = $output->path . '/' . $extension;
     $output->output = $params->get('output', 0);
     $output->output_path = $params->get('output_path', '');
     $output->compression = $params->get('compression', 'zip');
     if ($output->output == 2 && $output->output_path != '' && JFolder::exists($output->output_path)) {
         $output->output_path = $output->output_path;
     } elseif ($output->output_path != '' && $output->output_path != 'tmp/') {
         $output->output_path = JPATH_SITE . '/' . $output->output_path;
         if (!JFolder::exists($output->output_path)) {
             jimport('cck.base.install.export');
             CCK_Export::createDir($output->output_path);
         }
     } else {
         $output->output_path = $tmp_path;
     }
     return $output;
 }
 public static function beforetodayincluding($day, $month, $year, $data = array())
 {
     $today = JFactory::getDate();
     $today->setTime(23, 59, 59);
     $selected = JFactory::getDate($year . '-' . self::padding($month) . '-' . self::padding($day) . ' 00:00:00');
     return $selected->toUnix() < $today->toUnix();
 }
Example #22
0
 public function Process()
 {
     // Negative values indicate that the id belongs to a module
     $prefix = JFactory::getApplication()->owner == "module" ? "-" : "";
     $oid = $prefix . JFactory::getApplication()->oid;
     $body = $this->body();
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->insert($db->quoteName("#__foxcontact_enquiries"));
     $query->set($db->quoteName("form_id") . "=" . $db->quote($oid));
     $query->set($db->quoteName("date") . "=" . $db->quote(JFactory::getDate()->toSql()));
     $query->set($db->quoteName("ip") . "=" . $db->quote($this->ClientIPaddress()));
     $query->set($db->quoteName("url") . "=" . $db->quote($this->CurrentURL()));
     $query->set($db->quoteName("fields") . "=" . $db->quote($body));
     $db->setQuery((string) $query);
     try {
         $db->execute();
     } catch (RuntimeException $e) {
         // Show a generic database error
         $this->MessageBoard->Add(JText::_("COM_FOXCONTACT_ERR_DATABASE"), FoxMessageBoard::error);
         // Log the details which may contain sensitive data
         $this->Logger->Write($e->getMessage());
         // Database problems. Return error.
         return false;
     }
     // Log the successful event to the database. Intentionally not in the user's language.
     $this->Logger->Write("Enquiry saved to the database.");
     return true;
 }
 public function exportData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if export is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('help_document.export', 'com_costbenefitprojection') && $user->authorise('core.export', 'com_costbenefitprojection')) {
         // Get the input
         $input = JFactory::getApplication()->input;
         $pks = $input->post->get('cid', array(), 'array');
         // Sanitize the input
         JArrayHelper::toInteger($pks);
         // Get the model
         $model = $this->getModel('Help_documents');
         // get the data to export
         $data = $model->getExportData($pks);
         if (CostbenefitprojectionHelper::checkArray($data)) {
             // now set the data to the spreadsheet
             $date = JFactory::getDate();
             CostbenefitprojectionHelper::xls($data, 'Help_documents_' . $date->format('jS_F_Y'), 'Help documents exported (' . $date->format('jS F, Y') . ')', 'help documents');
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_COSTBENEFITPROJECTION_EXPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error');
     return;
 }
 public function store($data)
 {
     $row =& $this->getTable($this->_table);
     // bind the form fields
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // save modified data
     $datenow =& JFactory::getDate();
     $row->modified = $datenow->toMySQL();
     $user =& JFactory::getUser();
     $row->modified_by = $user->get("id");
     // check if model item data is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // store model item to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->_data = $row;
     return true;
 }
Example #25
0
 public function Process()
 {
     $uid = $this->Params->get("jmessenger_user", NULL);
     // No user selected for Joomla messenger
     if (!$uid) {
         //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this));
         // It's not a problem. Maybe it's even wanted. Return succesful.
         return true;
     }
     $body = $this->body();
     $body .= $this->attachments();
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->insert("#__messages");
     $query->columns(array($db->quoteName('user_id_from'), $db->quoteName('user_id_to'), $db->quoteName('date_time'), $db->quoteName('subject'), $db->quoteName('message')));
     $query->values($uid . ", " . $uid . ", " . $db->Quote(JFactory::getDate()->toSql()) . ", " . $db->Quote($this->submittername() . " (" . $this->submitteraddress() . ")") . ', ' . $db->Quote(JMailHelper::cleanBody($body)));
     $db->setQuery((string) $query);
     if (!$db->query()) {
         $msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE");
         //JLog::add($msg, JLog::ERROR, get_class($this));
         $this->Messages[] = $msg;
         // Database problems. Return error.
         return false;
     }
     //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this));
     return true;
 }
Example #26
0
 public static function getModuleList()
 {
     $app = JFactory::getApplication();
     $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
     $lang = JFactory::getLanguage()->getTag();
     $clientId = (int) $app->getClientId();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params')->from('#__modules AS m')->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')->where('e.enabled = 1');
     $date = JFactory::getDate();
     $now = $date->toSql();
     $nullDate = $db->getNullDate();
     $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')')->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')')->where('m.access IN (' . $groups . ')')->where('m.published = 1')->where('m.client_id = ' . $clientId);
     // Filter by language
     if ($app->isSite() && $app->getLanguageFilter()) {
         $query->where('m.language IN (' . $db->quote($lang) . ',' . $db->quote('*') . ')');
     }
     $query->order('m.position, m.ordering');
     // Set the query
     $db->setQuery($query);
     try {
         $modules = $db->loadObjectList();
     } catch (RuntimeException $e) {
         return array();
     }
     return $modules;
 }
Example #27
0
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     if (!$this->id) {
         if (!intval($this->created)) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     $table = JTable::getInstance('Producers', 'Djcatalog2Table');
     if ($app->isSite() || $app->input->get('task') == 'import') {
         if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) {
             $db->setQuery('select alias from #__djc2_producers where id != ' . $this->id . ' and alias like ' . $db->quote($db->escape($this->alias) . '%') . ' order by alias asc');
             $aliases = $db->loadColumn();
             $suffix = 2;
             while (in_array($this->alias . '-' . $suffix, $aliases)) {
                 $suffix++;
             }
             $this->alias = $this->alias . '-' . $suffix;
         }
     } else {
         if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) {
             $this->setError(JText::_('COM_DJCATALOG2_ERROR_UNIQUE_ALIAS'));
             return false;
         }
     }
     return parent::store($updateNulls);
 }
Example #28
0
 /**
  * Render the feed
  *
  * @access public
  * @return string
  */
 function render()
 {
     $now =& JFactory::getDate();
     $data =& $this->_doc;
     $uri =& JFactory::getURI();
     $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
     $syndicationURL =& JRoute::_('&format=feed&type=atom');
     $feed = "<feed xmlns=\"http://www.w3.org/2005/Atom\" ";
     if ($data->language != "") {
         $feed .= " xml:lang=\"" . $data->language . "\"";
     }
     $feed .= ">\n";
     $feed .= "\t<title type=\"text\">" . htmlspecialchars($data->title, ENT_COMPAT, 'UTF-8') . "</title>\n";
     $feed .= "\t<subtitle type=\"text\">" . htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8') . "</subtitle>\n";
     $feed .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"" . $url . "\"/>\n";
     $feed .= "\t<id>" . str_replace(' ', '%20', $data->getBase()) . "</id>\n";
     $feed .= "\t<updated>" . htmlspecialchars($now->toISO8601(), ENT_COMPAT, 'UTF-8') . "</updated>\n";
     if ($data->editor != "") {
         $feed .= "\t<author>\n";
         $feed .= "\t\t<name>" . $data->editor . "</name>\n";
         if ($data->editorEmail != "") {
             $feed .= "\t\t<email>" . htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
         }
         $feed .= "\t</author>\n";
     }
     $feed .= "\t<generator uri=\"http://joomla.org\" version=\"1.5\">" . $data->getGenerator() . "</generator>\n";
     $feed .= '<link rel="self" type="application/atom+xml" href="' . str_replace(' ', '%20', $url . $syndicationURL) . "\" />\n";
     for ($i = 0; $i < count($data->items); $i++) {
         $feed .= "\t<entry>\n";
         $feed .= "\t\t<title>" . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8') . "</title>\n";
         $feed .= '		<link rel="alternate" type="text/html" href="' . $url . $data->items[$i]->link . "\"/>\n";
         if ($data->items[$i]->date == "") {
             $data->items[$i]->date = $now->toUnix();
         }
         $itemDate =& JFactory::getDate($data->items[$i]->date);
         $feed .= "\t\t<published>" . htmlspecialchars($itemDate->toISO8601(), ENT_COMPAT, 'UTF-8') . "</published>\n";
         $feed .= "\t\t<updated>" . htmlspecialchars($itemDate->toISO8601(), ENT_COMPAT, 'UTF-8') . "</updated>\n";
         $feed .= "\t\t<id>" . str_replace(' ', '%20', $url . $data->items[$i]->link) . "</id>\n";
         if ($data->items[$i]->author != "") {
             $feed .= "\t\t<author>\n";
             $feed .= "\t\t\t<name>" . htmlspecialchars($data->items[$i]->author, ENT_COMPAT, 'UTF-8') . "</name>\n";
             if ($data->items[$i]->authorEmail != "") {
                 $feed .= "\t\t<email>" . htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
             }
             $feed .= "\t\t</author>\n";
         }
         if ($data->items[$i]->description != "") {
             //$feed.= "		<summary type=\"html\">".htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8')."</summary>\n";
             //$feed.= "		<content type=\"html\">".htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8')."</content>\n";
             $feed .= "\t\t<summary type=\"html\">" . htmlspecialchars($this->_relToAbs($data->items[$i]->description)) . "</summary>\n";
             $feed .= "\t\t<content type=\"html\">" . htmlspecialchars($this->_relToAbs($data->items[$i]->description)) . "</content>\n";
         }
         if ($data->items[$i]->enclosure != NULL) {
             $feed .= "\t\t<link rel=\"enclosure\" href=\"" . $data->items[$i]->enclosure->url . "\" type=\"" . $data->items[$i]->enclosure->type . "\"  length=\"" . $data->items[$i]->enclosure->length . "\" />\n";
         }
         $feed .= "\t</entry>\n";
     }
     $feed .= "</feed>\n";
     return $feed;
 }
Example #29
0
 static function getList(&$params)
 {
     //get database
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
     $query->from('#__content');
     $query->where('state = 2 AND checked_out = 0');
     $query->group('created_year DESC, created_month DESC');
     // Filter by language
     if (JFactory::getApplication()->getLanguageFilter()) {
         $query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
     }
     $db->setQuery($query, 0, intval($params->get('count')));
     $rows = (array) $db->loadObjectList();
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
     $itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : '';
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         $date = JFactory::getDate($row->created);
         $created_month = $date->format('n');
         $created_year = $date->format('Y');
         $created_year_cal = JHTML::_('date', $row->created, 'Y');
         $month_name_cal = JHTML::_('date', $row->created, 'F');
         $lists[$i] = new stdClass();
         $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
         $lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal);
         $i++;
     }
     return $lists;
 }
Example #30
0
 protected function createList($listModel, $adminListModel)
 {
     $params = $this->getParams();
     $table = $params->get('create_list');
     if ($table == '') {
         return;
     }
     $db = FabrikWorker::getDbo();
     //see if we have a list that already points to the table
     $query = $db->getQuery(true);
     $query->select('id')->from('jos_{package}_lists')->where('db_table_name = ' . $db->nameQuote($table));
     $db->setQuery($query);
     $res = (int) $db->loadResult();
     $now = JFactory::getDate()->toMySQL();
     $user = JFactory::getUser();
     $data = array();
     //fill in some default data
     $data['filter_action'] = 'onchange';
     $data['access'] = 1;
     $data['id'] = $res;
     $data['label'] = $table;
     $data['connection_id'] = 1;
     $data['db_table_name'] = $table;
     $data['published'] = 1;
     $data['created'] = $now;
     $data['created_by'] = $user->get('id');
     JRequest::setVar('jform', $data);
     $adminListModel->save($data);
 }