Пример #1
0
 /**
  * Retrieves the dropdown list for editors on the site
  *
  * @since   5.0
  * @access  public
  * @param   string
  * @return  
  */
 public static function editors($element, $selected = null, $composer = false)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT ' . $db->qn('element') . ' AS ' . $db->qn('value') . ',' . $db->qn('name') . ' AS ' . $db->qn('text');
     $query[] = 'FROM ' . $db->qn('#__extensions');
     $query[] = 'WHERE ' . $db->qn('folder') . '=' . $db->Quote('editors');
     $query[] = 'AND ' . $db->qn('type') . '=' . $db->Quote('plugin');
     $query[] = 'AND ' . $db->qn('enabled') . '=' . $db->Quote(1);
     $query[] = 'ORDER BY ' . $db->qn('ordering') . ',' . $db->qn('name');
     $query = implode(' ', $query);
     $db->setQuery($query);
     $editors = $db->loadObjectList();
     $lang = JFactory::getLanguage();
     for ($i = 0; $i < count($editors); $i++) {
         $editor = $editors[$i];
         $lang->load($editor->text . '.sys', JPATH_ADMINISTRATOR, null, false, false);
         $editor->text = JText::_($editor->text);
     }
     $theme = EB::template();
     $theme->set('composer', $composer);
     $theme->set('element', $element);
     $theme->set('selected', $selected);
     $theme->set('editors', $editors);
     $output = $theme->output('admin/html/form.editors');
     return $output;
 }
Пример #2
0
 public static function getGuestCount()
 {
     $id = JRequest::getVar('id');
     $view = JRequest::getVar('view');
     $db = EB::db();
     $query = '';
     if ($view == 'entry') {
         $query = 'select cont(1) from `#__easyblog_subscriptions` as a';
         $query .= ' where (';
         // entry
         $query .= ' (a.`uid` = ' . $db->Quote($id) . ' AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_ENTRY) . ') OR';
         // category
         $query .= ' (a.`uid` IN (select pc.`category_id` from `#__easyblog_post_category` as pc where pc.`post_id` = ' . $db->Quote($id) . ' ) AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY) . ') OR';
         // teamblog
         $query .= ' (a.`uid` IN (select pc.`source_id` from `#__easyblog_post` as p where p.`id` = ' . $db->Quote($id) . ' and p.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' ) AND a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_TEAMBLOG) . ')';
         $query .= ')';
         $query .= ' AND a.`user_id` = ' . $db->Quote('0');
     } else {
         if ($view == 'categories' && $id) {
             $query = 'select count(1) from `#__easyblog_subscriptions` as a';
             $query .= ' where a.`uid` = ' . $db->Quote($id);
             $query .= ' and a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY);
             $query .= ' AND a.`user_id` = ' . $db->Quote('0');
         } else {
             if ($view == 'teamblog') {
                 $query = 'select count(1) from `#__easyblog_subscriptions` as a';
                 $query .= ' where a.`uid` = ' . $db->Quote($id);
                 $query .= ' and a.`utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_TEAMBLOG);
                 $query .= ' AND a.`user_id` = ' . $db->Quote('0');
             }
         }
     }
     $db->setQuery($query);
     return (int) $db->loadResult();
 }
Пример #3
0
 public function main()
 {
     $state = true;
     $db = EB::db();
     // lets check if there is any default category assigned or not.
     $query = "select a.`id` from `#__easyblog_category` as a where a.`published` = 1 and a.`default` = 1";
     $db->setQuery($query);
     $result = $db->loadResult();
     if (!$result) {
         $query = "select a.`id`, count(b.`id`) as `cnt` from `#__easyblog_category` as a";
         $query .= " left join `#__easyblog_post_category` as b on a.`id` = b.`category_id`";
         $query .= " where a.`published` = 1";
         $query .= " group by a.`id`";
         $query .= " order by cnt desc";
         $query .= " limit 1";
         $db->setQuery($query);
         $id = $db->loadResult();
         // now we make sure no other categories which previously marked as default but its unpublished.
         $update = "update `#__easyblog_category` set `default` = 0";
         $db->setQuery($update);
         // now let update this category as default category
         $update = "update `#__easyblog_category` set `default` = 1 where `id` = " . $db->Quote($id);
         $db->setQuery($update);
         $state = $db->query();
     }
     return $state;
 }
Пример #4
0
 /**
  * Synchronizes database tables
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     // Load foundry
     $this->engine();
     // Get this installation version
     $version = $this->getInstalledVersion();
     // Get previous version installed
     $previous = $this->getPreviousVersion('dbversion');
     $affected = '';
     if ($previous !== false) {
         // lets run the db scripts sync if needed.
         $db = EB::db();
         $affected = $db->sync($previous);
     }
     // Update the version in the database to the latest now
     $config = EB::table('Configs');
     $config->load(array('name' => 'dbversion'));
     $config->name = 'dbversion';
     $config->params = $version;
     // Save the configuration
     $config->store($config->name);
     // If the previous version is empty, we can skip this altogether as we know this is a fresh installation
     if (!empty($affected)) {
         $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_MAINTENANCE_DB_SYNCED', $version));
     } else {
         $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_MAINTENANCE_DB_NOTHING_TO_SYNC', $version));
     }
     return $this->output();
 }
Пример #5
0
 /**
  * Clear any existing post reject messages
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function clear($postId)
 {
     $db = EB::db();
     $query = 'DELETE FROM ' . $db->quoteName('#__easyblog_post_rejected') . ' WHERE ' . $db->quoteName('post_id') . '=' . $db->Quote($postId);
     $db->setQuery($query);
     return $db->Query();
 }
Пример #6
0
 public function purge()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('migrator');
     $layout = $this->input->get('layout', '', 'cmd');
     $db = EB::db();
     $sql = $db->sql();
     $mapping = array('joomla' => 'com_content', 'wordpressjoomla' => 'com_wordpress', 'wordpress' => 'xml_wordpress', 'k2' => 'com_k2', 'zoo' => 'com_zoo', 'blogger' => 'xml_blogger');
     $component = '';
     if ($layout) {
         //let map the layout with component.
         if (isset($mapping[$layout]) && $mapping[$layout]) {
             $component = $mapping[$layout];
         }
     }
     if ($component) {
         // delete only associated records from the component.
         $query = 'delete from ' . $db->nameQuote('#__easyblog_migrate_content') . ' where ' . $db->nameQuote('component') . ' = ' . $db->Quote($component);
     } else {
         // truncate all
         $query = 'TRUNCATE TABLE ' . $db->nameQuote('#__easyblog_migrate_content');
     }
     $db->setQuery($query);
     $db->Query();
     $link = 'index.php?option=com_easyblog&view=migrators';
     if ($layout) {
         $link .= '&layout=' . $layout;
     }
     if ($db->getError()) {
         JFactory::getApplication()->redirect($link, JText::_('COM_EASYBLOG_PURGE_ERROR'), 'error');
     }
     JFactory::getApplication()->redirect($link, JText::_('COM_EASYBLOG_PURGE_SUCCESS'));
 }
Пример #7
0
 /**
  * Removes any pending messages for post rejects
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function clearPendingMessages($id)
 {
     $db = EB::db();
     $query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_post_rejected') . ' WHERE ' . $db->quoteName('post_id') . '=' . $db->Quote($draft_id);
     $db->setQuery($query);
     return $db->Query();
 }
Пример #8
0
 public function main()
 {
     $db = EB::db();
     $query = "DROP TABLE IF EXISTS `#__easyblog_stream`";
     $db->setQuery($query);
     $state = $db->query();
     return $state;
 }
 public function isTableDraftsExists()
 {
     $db = EB::db();
     $query = "SHOW TABLES LIKE '%_easyblog_site_subscription'";
     $db->setQuery($query);
     $result = $db->loadResult();
     return $result ? true : false;
 }
Пример #10
0
 public static function getChildCategories(&$result, $params, &$categories, $level = 1)
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $order = $params->get('order', 'popular');
     $sort = $params->get('sort', 'desc');
     $count = (int) trim($params->get('count', 0));
     $hideEmptyPost = $params->get('hideemptypost', '0');
     $language = EB::getCurrentLanguage();
     foreach ($result as $row) {
         if ($row->parent_id == 0) {
             $categories[$row->id] = $row;
             $categories[$row->id]->childs = array();
         } else {
             $categories[$row->id] = $row;
             $categories[$row->id]->childs = array();
         }
         $query = 'SELECT ' . $db->qn('a.id') . ', ' . $db->qn('a.title') . ', ' . $db->qn('a.parent_id') . ', ' . $db->qn('a.alias') . ', ' . $db->qn('a.avatar') . ', COUNT(b.`id`) AS `cnt`' . ' , ' . $db->quote($level) . ' AS level' . ' FROM ' . $db->qn('#__easyblog_category') . ' AS `a`' . ' LEFT JOIN ' . $db->qn('#__easyblog_post_category') . ' AS pc' . ' ON a.`id` = pc.`category_id`' . ' LEFT JOIN ' . $db->qn('#__easyblog_post') . ' AS b' . ' ON b.`id` = pc.`post_id`' . ' AND b.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' AND b.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL);
         $query .= ' WHERE a.`published` = 1';
         $query .= ' AND a.`parent_id`=' . $db->Quote($row->id);
         if ($language) {
             $query .= 'AND(';
             $query .= ' a.' . $db->quoteName('language') . '=' . $db->Quote($language);
             $query .= ' OR';
             $query .= ' a.' . $db->quoteName('language') . '=' . $db->Quote('');
             $query .= ' OR';
             $query .= ' a.' . $db->quoteName('language') . '=' . $db->Quote('*');
             $query .= ')';
         }
         if (!$hideEmptyPost) {
             $query .= ' GROUP BY a.`id` ';
         } else {
             $query .= ' GROUP BY a.`id` HAVING (COUNT(b.`id`) > 0)';
         }
         if ($order == 'ordering') {
             $orderBy = ' ORDER BY `lft` ' . $sort;
         }
         if ($order == 'popular') {
             $orderBy = ' ORDER BY `cnt` ' . $sort;
         }
         if ($order == 'alphabet') {
             $orderBy = ' ORDER BY a.`title` ' . $sort;
         }
         if ($order == 'latest') {
             $orderBy = ' ORDER BY a.`created` ' . $sort;
         }
         $query .= $orderBy;
         $db->setQuery($query);
         $records = $db->loadObjectList();
         if ($records) {
             modEasyBlogCategoriesHelper::getChildCategories($records, $params, $categories[$row->id]->childs, ++$level);
             // foreach ($records as $childrec) {
             // 	$categories[$row->id]->cnt += $childrec->cnt;
             // }
         }
     }
 }
Пример #11
0
 public function main()
 {
     $db = EB::db();
     $query = array();
     $query[] = 'UPDATE ' . $db->qn('#__easyblog_post') . ' SET ' . $db->qn('doctype') . '=' . $db->Quote('legacy');
     $query[] = 'WHERE ' . $db->qn('doctype') . '=' . $db->Quote('');
     $db->setQuery($query);
     $state = $db->query();
     return $state;
 }
Пример #12
0
 public function main()
 {
     $db = EB::db();
     $query = array();
     $query[] = 'UPDATE ' . $db->qn('#__easyblog_post') . ' SET ' . $db->qn('published') . '=' . $db->Quote('0');
     $query[] = ',' . $db->qn('state') . '=' . $db->Quote('1');
     $query[] = 'WHERE ' . $db->qn('published') . '=' . $db->Quote('5');
     $db->setQuery($query);
     $state = $db->query();
     return $state;
 }
Пример #13
0
 private static function getGroups()
 {
     $db = EB::db();
     $query = 'SELECT a.*, COUNT(DISTINCT(b.`id`)) AS `level` FROM ' . $db->quoteName('#__usergroups') . ' AS a';
     $query .= ' LEFT JOIN ' . $db->quoteName('#__usergroups') . ' AS b';
     $query .= ' ON a.`lft` > b.`lft` AND a.`rgt` < b.`rgt`';
     $query .= ' GROUP BY a.`id`, a.`title`, a.`lft`, a.`rgt`, a.`parent_id`';
     $query .= ' ORDER BY a.`lft` ASC';
     $db->setQuery($query);
     $groups = $db->loadObjectList();
     return $groups;
 }
Пример #14
0
 /**
  * generate sql used for blogger retrieval
  *
  * @since	5.0
  * @access	public
  * @param
  * @return string
  */
 public static function genIsbloggerSQL($column = 'a.id')
 {
     $db = EB::db();
     $aclQuery = '1 <= (select count(1) from `#__easyblog_acl_group` as ag';
     $aclQuery .= '			inner join `#__easyblog_acl` as acl on ag.`acl_id` = acl.`id`';
     $aclQuery .= '			inner join `#__user_usergroup_map` as up on ag.`content_id` = up.`group_id`';
     $aclQuery .= '		 	where up.`user_id` = ' . $db->qn($column);
     $aclQuery .= '			and acl.`action` = ' . $db->Quote('add_entry');
     $aclQuery .= '			and ag.`type` = ' . $db->Quote('group');
     $aclQuery .= '			and ag.`status` = 1)';
     return $aclQuery;
 }
Пример #15
0
 /**
  * Loads a micro posting from twitter given the post id
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function loadByPostId($id)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->qn($this->_tbl);
     $query[] = 'WHERE ' . $db->qn('post_id') . '=' . $db->Quote($id);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObject();
     $state = parent::bind($result);
     return $state;
 }
Пример #16
0
 /**
  * Retrieves a list of emails that needs to be dispatched
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function getPendingEmails($limit)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName('#__easyblog_mailq');
     $query[] = 'WHERE ' . $db->quoteName('status') . '=' . $db->Quote(0);
     $query[] = 'ORDER BY ' . $db->quoteName('created') . ' ASC';
     $query[] = 'LIMIT ' . $limit;
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
Пример #17
0
 public function main()
 {
     $db = EB::db();
     $query = 'insert into ' . $db->qn('#__easyblog_post_category') . '(';
     $query .= $db->qn('post_id') . ', ' . $db->qn('category_id') . ', ' . $db->qn('primary') . ')';
     $query .= ' select ' . $db->qn('a.id') . ', ' . $db->qn('a.category_id') . ', ' . $db->Quote('1') . ' from ' . $db->qn('#__easyblog_post') . ' as a';
     $query .= ' where ' . $db->qn('a.category_id') . ' > ' . $db->Quote('0');
     $query .= ' and not exists (select ' . $db->qn('pc.post_id') . ' from ' . $db->qn('#__easyblog_post_category') . ' as pc';
     $query .= '                     where ' . $db->qn('pc.post_id') . ' = ' . $db->qn('a.id') . ' and ' . $db->qn('pc.category_id') . ' = ' . $db->qn('a.category_id') . ')';
     $db->setQuery($query);
     $state = $db->query();
     return $state;
 }
Пример #18
0
 public function store($key = 'config')
 {
     $db = EB::db();
     $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__easyblog_configs') . ' ' . 'WHERE ' . $db->nameQuote('name') . '=' . $db->Quote($key);
     $db->setQuery($query);
     $exists = $db->loadResult() > 0 ? true : false;
     $data = new stdClass();
     $data->name = empty($this->name) ? $key : $this->name;
     $data->params = trim($this->params);
     if ($exists) {
         return $db->updateObject('#__easyblog_configs', $data, 'name');
     }
     return $db->insertObject('#__easyblog_configs', $data);
 }
Пример #19
0
 public function getAvatar($profile)
 {
     if (!$this->exists()) {
         return false;
     }
     $db = EB::db();
     $query = 'SELECT * FROM ' . $db->quoteName('#__k2_users') . ' ' . 'WHERE ' . $db->nameQuote('userID') . '=' . $db->Quote($profile->id);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result || !$result->image) {
         return false;
     }
     $avatar = JURI::root() . 'media/k2/users/' . $result->image;
     return $avatar;
 }
Пример #20
0
 /**
  * Retrieves the comment count for disqus
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function getCount(EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return false;
     }
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT COUNT(1) FROM ' . $db->qn('#__jcomments');
     $query[] = 'WHERE ' . $db->qn('object_id') . '=' . $db->Quote($post->id);
     $query[] = 'AND ' . $db->qn('object_group') . '=' . $db->Quote('com_easyblog');
     $query[] = 'AND ' . $db->qn('published') . '=' . $db->Quote(1);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $count = $db->loadResult();
     return $count;
 }
Пример #21
0
 /**
  * Determines if there are any values in the fields within this group.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function hasValues($postId, $groupId)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT COUNT(1) FROM ' . $db->qn('#__easyblog_fields_values') . ' AS a';
     $query[] = 'INNER JOIN ' . $db->qn('#__easyblog_fields') . ' AS b';
     $query[] = 'ON a.' . $db->qn('field_id') . ' = b.' . $db->qn('id');
     $query[] = 'INNER JOIN ' . $db->qn('#__easyblog_fields_groups') . ' AS c';
     $query[] = 'ON b.' . $db->qn('group_id') . '= c.' . $db->qn('id');
     $query[] = 'WHERE c.' . $db->qn('id') . '=' . $db->Quote($groupId);
     $query[] = 'AND a.' . $db->qn('post_id') . '=' . $db->Quote($postId);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $hasValues = $db->loadResult() > 0 ? true : false;
     return $hasValues;
 }
Пример #22
0
 /**
  * Get the assets based on blog id
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPostAssets($id)
 {
     static $_cache = array();
     if (!isset($_cache[$id])) {
         $db = EB::db();
         // Try to look for the permalink
         $query = array();
         $query[] = 'SELECT ' . $db->quoteName('key') . ',' . $db->quoteName('value') . ' FROM ' . $db->quoteName('#__easyblog_post_assets');
         $query[] = 'WHERE ' . $db->quoteName('post_id') . '=' . $db->Quote($id);
         // Join the query now
         $query = implode(' ', $query);
         $db->setQuery($query);
         $assets = $db->loadObjectList();
         $_cache[$id] = $assets;
     }
     return $_cache[$id];
 }
Пример #23
0
 /**
  * Retrieves a list of articles on the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPosts($userId = null)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->quoteName('#__easyblog_post');
     $query[] = 'WHERE ' . $db->quoteName('published') . '!=' . $db->Quote(EASYBLOG_POST_BLANK);
     $query[] = 'and ' . $db->quoteName('state') . '!=' . $db->Quote(EASYBLOG_POST_NORMAL);
     // If user is a site admin, we want to show everything
     if (!EB::isSiteAdmin()) {
         $user = JFactory::getUser($userId);
         $query[] = 'AND ' . $db->quoteName('created_by') . '=' . $db->Quote($user->id);
     }
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
Пример #24
0
 /**
  * Determines if the user has already voted
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function hasVoted($userId, $postId, $type, $hash = '')
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->quoteName($this->_tbl);
     $query[] = 'WHERE ' . $db->quoteName('created_by') . '=' . $db->Quote($userId);
     $query[] = 'AND ' . $db->quoteName('uid') . '=' . $db->Quote($postId);
     if (!empty($hash)) {
         $query[] = 'AND ' . $db->quoteName('sessionid') . '=' . $db->Quote($hash);
     }
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return $result;
 }
Пример #25
0
 public function setAsAdmin($teamId, $userId, $isAdmin)
 {
     // Check for request forgeries
     EB::checkToken();
     // @task: Check for acl rules.
     $this->checkAccess('easyblog.manage.teamblog');
     $db = EB::db();
     $query = 'UPDATE `#__easyblog_team_users` SET ';
     if ($isAdmin) {
         $query .= ' `isadmin` = ' . $db->Quote('1');
     } else {
         $query .= ' `isadmin` = ' . $db->Quote('0');
     }
     $query .= ' WHERE `team_id` = ' . $db->Quote($teamId);
     $query .= ' AND `user_id` = ' . $db->Quote($userId);
     $db->setQuery($query);
     $db->query();
     return true;
 }
Пример #26
0
 /**
  * Delete a url from the cache
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function deleteFromCache($id)
 {
     if (!$this->exists()) {
         return;
     }
     $db = EB::db();
     $sql = $db->sql();
     $query = array();
     $query[] = 'SELECT ' . $db->qn('link_id') . ' FROM ' . $db->qn('#__finder_links');
     $query[] = 'WHERE ' . $db->qn('url') . ' LIKE ' . $db->Quote('%option=com_easyblog&view=entry&id=' . $id . '%');
     $query = implode(' ', $query);
     $db->setQuery($query);
     $item = $db->loadResult();
     if (EB::isJoomla30()) {
         $state = $this->indexer->remove($item);
     } else {
         $state = FinderIndexer::remove($item);
     }
     return $state;
 }
Пример #27
0
 private function getId($userId)
 {
     $db = EB::db();
     // Get columns
     $columns = $db->getTableColumns('#__jfbconnect_user_map');
     // Set the default column
     $query = 'SELECT ' . $db->quoteName('fb_user_id') . ' AS ' . $db->quoteName('id');
     // If it is new version
     if (in_array('provider_user_id', $columns)) {
         $query = 'SELECT ' . $db->quoteName('provider_user_id') . ' AS ' . $db->quoteName('id');
     }
     $query .= ' FROM ' . $db->quoteName('#__jfbconnect_user_map');
     $query .= ' WHERE ' . $db->quoteName('j_user_id') . '=' . $db->Quote($userId);
     $db->setQuery($query);
     $id = $db->loadResult();
     if (!$id) {
         return false;
     }
     return $id;
 }
Пример #28
0
 public function searchTag()
 {
     $app = JFactory::getApplication();
     $limitstart = $app->input->get('limitstart', 0, 'INT');
     $limit = $app->input->get('limit', 20, 'INT');
     $Tagmodel = EasyBlogHelper::getModel('Tags');
     $input = JFactory::getApplication()->input;
     $keyword = $input->get('title', '', 'STRING');
     $wordSearch = true;
     $db = EB::db();
     $query = array();
     $search = $wordSearch ? '%' . $keyword . '%' : $keyword . '%';
     $query[] = 'SELECT * FROM ' . $db->quoteName('#__easyblog_tag');
     $query[] = 'WHERE ' . $db->quoteName('title') . ' LIKE ' . $db->Quote($search);
     $query[] = 'AND ' . $db->quoteName('published') . '=' . $db->Quote(1);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $output = array_slice($result, $limitstart, $limit);
     return $output;
 }
Пример #29
0
 static function getJComment(&$params)
 {
     $db = EB::db();
     $query = 'SELECT * FROM ' . $db->nameQuote('#__jcomments') . ' ' . 'WHERE ' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . 'AND ' . $db->nameQuote('object_group') . '=' . $db->Quote('com_easyblog') . ' ' . 'ORDER BY `date` ' . 'LIMIT 0,' . $params->get('count');
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $comments = array();
     if ($rows) {
         foreach ($rows as $row) {
             $row->author = EB::user($row->userid);
             $row->created_by = $row->userid;
             $row->post_id = $row->object_id;
             $blog = EB::table('Blog');
             $blog->load($row->object_id);
             $row->blog_title = $blog->title;
             $row->created = $row->date;
             $comments[] = $row;
         }
     }
     return $comments;
 }
Пример #30
0
 public function install($element, $path)
 {
     // Get Joomla's installer instance
     $installer = new JInstaller();
     // Allow overwriting existing modules
     $installer->setOverwrite(true);
     // Install the module
     $state = $installer->install($path);
     if (!$state) {
         return false;
     }
     $db = EB::db();
     $query = array();
     $query[] = 'UPDATE ' . $db->qn('#__extensions') . ' SET ' . $db->qn('access') . '=' . $db->Quote(1);
     $query[] = 'WHERE ' . $db->qn('type') . '=' . $db->Quote('module');
     $query[] = 'AND ' . $db->qn('element') . '=' . $db->Quote($element);
     $query[] = 'AND ' . $db->qn('access') . '=' . $db->Quote(0);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $db->Query();
     // Check if this module already exists on module_menu
     $query = array();
     $query[] = 'SELECT a.' . $db->qn('id') . ', b.' . $db->qn('moduleid') . ' FROM ' . $db->qn('#__modules') . ' AS a';
     $query[] = 'LEFT JOIN ' . $db->qn('#__modules_menu') . ' AS b ON a.' . $db->qn('id') . ' = b.' . $db->qn('moduleid');
     $query[] = 'WHERE a.' . $db->qn('module') . ' = ' . $db->Quote($element);
     $query[] = 'AND b.' . $db->qn('moduleid') . ' IS NULL';
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         return false;
     }
     foreach ($result as $row) {
         $mod = new stdClass();
         $mod->moduleid = $row->id;
         $mod->menuid = 0;
         $db->insertObject('#__modules_menu', $mod);
     }
     return true;
 }