Пример #1
0
 public function loadByIP($ip, $mode = self::ACTIVE)
 {
     // Reset the table.
     $k = $this->_tbl_key;
     $this->{$k} = 0;
     $this->reset();
     // Check for a valid id to load.
     if ($ip === null || !is_string($ip)) {
         return false;
     }
     $now = new JDate();
     // Load the user data.
     $query = "SELECT * FROM {$this->_tbl}\n\t\t\tWHERE ip = {$this->_db->quote($ip)}\n\t\t\t" . ($mode == self::ACTIVE ? "AND (expiration = {$this->_db->quote($this->_db->getNullDate())} OR expiration > {$this->_db->quote($now->toSql())})" : '') . "\n\t\t\tORDER BY id DESC";
     $this->_db->setQuery($query, 0, 1);
     $data = $this->_db->loadAssoc();
     // Check for an error message.
     if ($this->_db->getErrorNum()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (empty($data)) {
         $this->ip = $ip;
         return false;
     }
     // Bind the data to the table.
     $this->bind($data);
     return true;
 }
Пример #2
0
 public static function getList(&$params)
 {
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     $timeframe = $params->get('timeframe', 'alltime');
     $maximum = $params->get('maximum', 5);
     $order_value = $params->get('order_value', 'count');
     if ($order_value == 'rand()') {
         $order_direction = '';
     } else {
         $order_value = $db->quoteName($order_value);
         $order_direction = $params->get('order_direction', 1) ? 'DESC' : 'ASC';
     }
     $query = $db->getQuery(true)->select(array('MAX(' . $db->quoteName('tag_id') . ') AS tag_id', ' COUNT(*) AS count', 'MAX(t.title) AS title', 'MAX(' . $db->quoteName('t.access') . ') AS access', 'MAX(' . $db->quoteName('t.alias') . ') AS alias'))->group($db->quoteName(array('tag_id', 'title', 'access', 'alias')))->from($db->quoteName('#__contentitem_tag_map'))->where($db->quoteName('t.access') . ' IN (' . $groups . ')');
     // Only return published tags
     $query->where($db->quoteName('t.published') . ' = 1 ');
     // Optionally filter on language
     $language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
     if ($language != 'all') {
         if ($language == 'current_language') {
             $language = JHelperContent::getCurrentLanguage();
         }
         $query->where($db->quoteName('t.language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
     }
     if ($timeframe != 'alltime') {
         $now = new JDate();
         $query->where($db->quoteName('tag_date') . ' > ' . $query->dateAdd($now->toSql('date'), '-1', strtoupper($timeframe)));
     }
     $query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('tag_id') . ' = t.id')->order($order_value . ' ' . $order_direction);
     $db->setQuery($query, 0, $maximum);
     $results = $db->loadObjectList();
     return $results;
 }
Пример #3
0
 function &getData()
 {
     if (empty($this->_data)) {
         $query = ' SELECT * FROM #__fst_comments ' . '  WHERE id = ' . FSTJ3Helper::getEscaped($this->_db, $this->_id);
         $this->_db->setQuery($query);
         $this->_data = $this->_db->loadObject();
     }
     if (!$this->_data) {
         $this->_data = new stdClass();
         $this->_data->id = 0;
         $this->_data->ident = 5;
         //
         $this->_data->itemid = 0;
         $this->_data->body = null;
         $this->_data->email = null;
         $this->_data->name = null;
         $this->_data->website = null;
         $this->_data->published = 1;
         $current_date = new JDate();
         if (FSTJ3Helper::IsJ3()) {
             $mySQL_conform_date = $current_date->toSql();
         } else {
             $mySQL_conform_date = $current_date->toMySQL();
         }
         $this->_data->created = $mySQL_conform_date;
     }
     return $this->_data;
 }
Пример #4
0
 protected function migrate($row)
 {
     $nd = $this->_db->getNullDate();
     $obj = new stdClass();
     $obj->id = $row->id;
     $obj->task_title = $row->title;
     $obj->description = $row->content;
     $obj->created_by = $row->user_id;
     $obj->state = $row->state;
     $obj->access = $row->access ? $row->access : $this->access;
     $obj->project_id = $row->project_id;
     $obj->task_id = $row->task_id;
     $obj->billable = 1;
     // Set creation date
     if ($row->cdate) {
         $date = new JDate($row->cdate);
         $obj->created = $date->toSql();
         $obj->log_date = $obj->created;
     }
     // Set attribs
     $obj->attribs = '{}';
     // Set log time
     $obj->log_time = $row->timelog > 0 ? $row->timelog * 60 : 1;
     // Store base item
     if (!$this->_db->insertObject('#__pf_timesheet', $obj)) {
         $this->success = false;
         $this->log[] = $this->_db->getError();
         return false;
     }
     // Create asset
     $nulls = false;
     $parent = $this->getParentAsset();
     $asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->_db));
     $asset->loadByName('com_pftime.time.' . $row->id);
     // Check for an error.
     if ($error = $asset->getError()) {
         $this->log[] = $error;
     } else {
         if (empty($asset->id)) {
             $asset->setLocation($parent, 'last-child');
         }
         // Prepare the asset to be stored.
         $asset->parent_id = $parent;
         $asset->name = 'com_pftime.time.' . $row->id;
         $asset->title = $row->title;
         $asset->rules = '{}';
         if (!$asset->check() || !$asset->store($nulls)) {
             $this->log[] = $asset->getError();
         } else {
             $query = $this->_db->getQuery(true);
             $query->update('#__pf_timesheet')->set('asset_id = ' . (int) $asset->id)->where('id = ' . (int) $row->id);
             $this->_db->setQuery($query);
             if (!$this->_db->execute()) {
                 $this->log[] = JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg());
             }
         }
     }
     return true;
 }
Пример #5
0
 public function check()
 {
     $date = new JDate($this->date_from);
     $this->date_from = $date->toSql();
     $date1 = new JDate($this->date_to);
     $this->date_to = $date1->toSql();
     return parent::check();
 }
Пример #6
0
 private function PurgeExpiredSessions()
 {
     $lifetime = JFactory::getConfig()->get("lifetime", DEFAULT_SESSION_LIFETIME);
     $date = new JDate("-" . $lifetime . " minute");
     $sql = "DELETE FROM #__" . $GLOBALS["ext_name"] . "_sessions WHERE birth < '" . $date->toSql() . "';";
     $this->db->setQuery($sql);
     $this->db->query();
 }
Пример #7
0
 /**
  * Method to store the item
  *
  * @package MageBridge
  * @access public
  * @param array $data
  * @return bool
  */
 public function store($data)
 {
     // Prepare the data
     $now = new JDate('now');
     // Build the data
     $data['remote_addr'] = $_SERVER['REMOTE_ADDR'];
     $data['http_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $data['timestamp'] = $now->toSql();
     return parent::store($data);
 }
Пример #8
0
 public static function log($action, $user_id = null)
 {
     $table = JTable::getInstance('', 'CTableEngagement');
     $table->action = $action;
     $table->user_id = $user_id;
     $date = new JDate();
     $table->created = $date->toSql();
     $table->week = $date->format('W');
     $table->store();
 }
Пример #9
0
 /**
  * Load data about the most funded projects.
  *
  * <code>
  * $mostFunded = new Crowdfunding\Statistics\Projects\MostFunded(\JFactory::getDbo());
  * $mostFunded->load();
  *
  * foreach ($mostFunded as $project) {
  *      echo $project["title"];
  * }
  * </code>
  *
  * @param int $limit Number of result that will be loaded.
  */
 public function load($limit = 5)
 {
     // Get current date
     jimport('joomla.date.date');
     $date = new \JDate();
     $today = $date->toSql();
     $query = $this->getQuery();
     $query->where('( a.published = 1 AND a.approved = 1 )')->where('( a.funding_start <= ' . $this->db->quote($today) . ' AND a.funding_end >= ' . $this->db->quote($today) . ' )')->order('a.funded DESC');
     $this->db->setQuery($query, 0, (int) $limit);
     $this->items = (array) $this->db->loadAssocList();
 }
Пример #10
0
 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);
     }
 }
Пример #11
0
 /**
  * Load data about the most funded projects.
  *
  * <code>
  * $popular = new CrowdfundingStatisticsProjectsPopular(JFactory::getDbo());
  * $popular->load();
  *
  * foreach ($popular as $project) {
  *      echo $project["title"];
  *      echo $project["hits"];
  * }
  * </code>
  *
  * @param int $limit Number of result that will be loaded.
  */
 public function load($limit = 5)
 {
     // Get current date
     jimport("joomla.date.date");
     $date = new \JDate();
     $today = $date->toSql();
     $query = $this->getQuery();
     $query->where("( a.published = 1 AND a.approved = 1 )")->where("( a.funding_start <= " . $this->db->quote($today) . " AND a.funding_end >= " . $this->db->quote($today) . " )")->order("a.hits DESC");
     $this->db->setQuery($query, 0, (int) $limit);
     $this->items = (array) $this->db->loadAssocList();
 }
Пример #12
0
 /**
  * Load data about the most funded projects.
  *
  * <code>
  * $popular = new Crowdfunding\Statistics\Projects\Popular(JFactory::getDbo());
  * $popular->load(['limit' => 5]);
  *
  * foreach ($popular as $project) {
  *      echo $project["title"];
  *      echo $project["hits"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     $limit = ArrayHelper::getValue($options, 'limit', 5, 'int');
     // Get current date
     jimport('joomla.date.date');
     $date = new \JDate();
     $today = $date->toSql();
     $query = $this->getQuery();
     $query->where('( a.published = 1 AND a.approved = 1 )')->where('( a.funding_start <= ' . $this->db->quote($today) . ' AND a.funding_end >= ' . $this->db->quote($today) . ' )')->order('a.hits DESC');
     $this->db->setQuery($query, 0, (int) $limit);
     $this->items = (array) $this->db->loadAssocList();
 }
Пример #13
0
 public function store($updateNulls = false)
 {
     $date = new JDate();
     $this->created = $date->toSql(true);
     $result = parent::store();
     if ($result) {
         // Update tag words count
         $word = JTable::getInstance('Tagword', 'CTable');
         $word->load($this->tag);
         $word->update();
     }
     return $result;
 }
Пример #14
0
 /**
  * Sort the published up/down times in case they are give out of order. If publish_up equals publish_down the
  * foreverDate will be used for publish_down.
  *
  * @param   string $publish_up   Publish Up date
  * @param   string $publish_down Publish Down date
  * @param   string $foreverDate  See above
  *
  * @return  array  (publish_up, publish_down)
  */
 protected function sortPublishDates($publish_up, $publish_down, $foreverDate = '2038-01-18 00:00:00')
 {
     \JLoader::import('joomla.utilities.date');
     $jUp = new \JDate($publish_up);
     $jDown = new \JDate($publish_down);
     if ($jDown->toUnix() < $jUp->toUnix()) {
         $temp = $publish_up;
         $publish_up = $publish_down;
         $publish_down = $temp;
     } elseif ($jDown->toUnix() == $jUp->toUnix()) {
         $jDown = new \JDate($foreverDate);
         $publish_down = $jDown->toSql();
     }
     return array($publish_up, $publish_down);
 }
Пример #15
0
 function check()
 {
     // make published by default and get a new order no
     if (!$this->id) {
         if ($this->created == "") {
             $current_date = new JDate();
             if (FSSJ3Helper::IsJ3()) {
                 $mySQL_conform_date = $current_date->toSql();
             } else {
                 $mySQL_conform_date = $current_date->toMySQL();
             }
             $this->set('created', $mySQL_conform_date);
         }
     }
     return true;
 }
 /**
  * Store a notification to database.
  *
  * <code>
  * $userId = 1;
  * $content = "....";
  *
  * $notification = new Prism\Integration\Notification\EasySocial($userId, $content);
  * $notification->setDb(JFactory::getDbo());
  *
  * $notification->send();
  * </code>
  *
  * @param string $content
  */
 public function send($content = '')
 {
     if ($content !== '') {
         $this->content = $content;
     }
     $query = $this->db->getQuery(true);
     $date = new \JDate();
     $query->insert($this->db->quoteName('#__social_notifications'))->set($this->db->quoteName('uid') . '=' . (int) $this->uid)->set($this->db->quoteName('actor_id') . '=' . (int) $this->actorId)->set($this->db->quoteName('actor_type') . '=' . $this->db->quote($this->actorType))->set($this->db->quoteName('target_id') . '=' . (int) $this->targetId)->set($this->db->quoteName('target_type') . '=' . $this->db->quote($this->targetType))->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('cmd') . '=' . $this->db->quote($this->cmd))->set($this->db->quoteName('type') . '=' . $this->db->quote($this->type))->set($this->db->quoteName('url') . '=' . $this->db->quote($this->url))->set($this->db->quoteName('state') . '=' . (int) $this->state)->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
     if ($this->image !== null) {
         $query->set($this->db->quoteName('image') . '=' . $this->db->quote($this->image));
     }
     if ($this->title !== null) {
         $query->set($this->db->quoteName('title') . '=' . $this->db->quote($this->title));
     }
     $this->db->setQuery($query);
     $this->db->execute();
     $this->id = $this->db->insertid();
 }
 /**
  * This method store a post by user.
  */
 public function storePost()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $content = $this->input->getString('content');
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $content = JString::trim(strip_tags($content));
     $content = JHtmlString::truncate($content, 140);
     if (!$userId) {
         $app->close();
     }
     $userTimeZone = !$user->getParam('timezone') ? null : $user->getParam('timezone');
     try {
         $date = new JDate('now', $userTimeZone);
         $entity = new Socialcommunity\Wall\User\Post(JFactory::getDbo());
         $entity->setUserId($userId);
         $entity->setContent($content);
         $entity->setCreated($date->toSql(true));
         $entity->store();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $params = JComponentHelper::getParams('com_socialcommunity');
     $filesystemHelper = new Prism\Filesystem\Helper($params);
     $mediaFolder = $filesystemHelper->getMediaFolderUri($userId);
     $profile = new Socialcommunity\Profile\Profile(JFactory::getDbo());
     $profile->load(['user_id' => $userId]);
     $displayData = new stdClass();
     $displayData->id = $entity->getId();
     $displayData->profileLink = JRoute::_(SocialCommunityHelperRoute::getProfileRoute($profile->getSlug()), false);
     $displayData->name = htmlentities($profile->getName(), ENT_QUOTES, 'utf-8');
     $displayData->alias = htmlentities($profile->getAlias(), ENT_QUOTES, 'utf-8');
     $displayData->imageSquare = $mediaFolder . '/' . $profile->getImageSquare();
     $displayData->imageAlt = $displayData->name;
     $displayData->content = $entity->getContent();
     $displayData->created = JHtml::_('socialcommunity.created', $entity->getCreated(), $userTimeZone);
     $layout = new JLayoutFile('wall_post');
     echo $layout->render($displayData);
     $app->close();
 }
 /**
  * Change user achievement to higher one.
  *
  * <code>
  * $context = "com_user.registration";
  *
  * $keys = array(
  *     "id" => 1,
  *     "group_id" => 2
  * );
  *
  * // Create user achievement object based.
  * $achievement  = new Gamification\Achievement\Achievement(\JFactory::getDbo());
  * $achievement->load($keys);
  *
  * $achievementManager = new Gamification\User\Achievement\AchievementManager(\JFactory::getDbo());
  * $achievementManager->setAchievement($achievement);
  *
  * if ($achievementManager->accomplish($context, $userId, $options)) {
  * // ...
  * }
  * </code>
  *
  * @param string $context
  * @param int $userId
  * @param array $options
  *
  * @throws \UnexpectedValueException
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  *
  * @return null|Achievement
  */
 public function accomplish($context, $userId, array $options = array())
 {
     if (!$this->achievement instanceof BasicAchievement) {
         throw new \UnexpectedValueException('It is missing user achievement object.');
     }
     // Check if this achievement already exists in user profile.
     $userProfile = new Profile($this->db);
     $achievementAccomplished = $userProfile->isAchievementAccomplished($this->achievement, $userId);
     if (!$achievementAccomplished) {
         $date = new \JDate();
         $data = array('user_id' => $userId, 'achievement_id' => $this->achievement->getId(), 'accomplished' => 1, 'accomplished_at' => $date->toSql());
         // Create user achievement.
         $userAchievement = new Achievement(\JFactory::getDbo());
         $userAchievement->bind($data);
         // Implement JObservableInterface: Pre-processing by observers
         $this->observers->update('onBeforeAccomplishAchievement', array($context, &$userAchievement, &$options));
         $userAchievement->store();
         // Implement JObservableInterface: Post-processing by observers
         $this->observers->update('onAfterAccomplishAchievement', array($context, &$userAchievement, &$options));
         return $userAchievement;
     }
     return null;
 }
Пример #19
0
 /**
  * Store a notification to database.
  *
  * <code>
  * $userId = 1;
  * $content = "....";
  *
  * $notification = new Prism\Integration\Notification\JomSocial($userId, $content);
  * $notification->setDb(\JFactory::getDbo());
  *
  * $notification->send();
  * </code>
  *
  * @param string $content
  */
 public function send($content = '')
 {
     if ($content !== '') {
         $this->content = $content;
     }
     $query = $this->db->getQuery(true);
     $params = array();
     if ($this->image !== null) {
         $params['image'] = $this->image;
     }
     if ($this->url !== null) {
         $params['url'] = $this->url;
     }
     $date = new \JDate();
     $query->insert($this->db->quoteName('#__community_notifications'))->set($this->db->quoteName('actor') . '=' . (int) $this->actorId)->set($this->db->quoteName('target') . '=' . (int) $this->targetId)->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('cmd_type') . '=' . $this->db->quote($this->cmdType))->set($this->db->quoteName('type') . '=' . $this->db->quote($this->type))->set($this->db->quoteName('status') . '=' . (int) $this->status)->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
     if (count($params) > 0) {
         $params = json_encode($params);
         $query->set($this->db->quoteName('params') . '=' . $this->db->quote($params));
     }
     $this->db->setQuery($query);
     $this->db->execute();
     $this->id = $this->db->insertid();
 }
Пример #20
0
 /**
  * Onload, we try to load existing data, if any. If not, query from Google
  */
 public function load($address = null, $resets = null)
 {
     // lowercase the incoming address
     $address = JString::strtolower($address);
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . $db->quoteName('#__community_location_cache');
     $query .= ' WHERE ';
     $query .= $db->quoteName('address') . '= ' . $db->quote($address);
     $query .= ' LIMIT 1';
     $db->setQuery($query);
     $obj = $db->loadObject();
     if ($obj) {
         $this->bind($obj);
     } else {
         $data = CMapping::getAddressData($address);
         $this->address = $address;
         $this->latitude = COMMUNITY_LOCATION_NULL;
         $this->longitude = COMMUNITY_LOCATION_NULL;
         $this->data = '';
         $this->status = 'ZERO_RESULTS';
         if ($data != null) {
             require_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php';
             $json = new Services_JSON();
             $content = $json->encode($data);
             if ($data->status == 'OK') {
                 $this->latitude = $data->results[0]->geometry->location->lat;
                 $this->longitude = $data->results[0]->geometry->location->lng;
                 $this->data = $content;
                 $this->status = $data->status;
             }
         }
         $date = new JDate();
         $this->created = $date->toSql(true);
         $this->store();
     }
     return true;
 }
Пример #21
0
 /**
  * Prepare filter by funding state.
  *
  * @param JDatabaseQuery $query
  */
 protected function prepareFilterFundingState(&$query)
 {
     $db = JFactory::getDbo();
     // Filter by funding state.
     $filter = (int) $this->getState($this->context . '.filter_funding_state');
     switch ($filter) {
         case 1:
             // Successfully funded.
             jimport('joomla.date.date');
             $date = new JDate();
             $today = $date->toSql();
             $query->where('a.funding_end < ' . $db->quote($today) . ' AND a.funded >= a.goal');
             break;
     }
 }
Пример #22
0
 public function process()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Check for request forgeries.
     $requestMethod = $app->input->getMethod();
     if (strcmp("POST", $requestMethod) == 0) {
         JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     } else {
         JSession::checkToken("get") or jexit(JText::_('JINVALID_TOKEN'));
     }
     // Get params
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form
     $itemId = $this->input->getInt('id', 0);
     $rewardId = $this->input->getInt('rid', 0);
     // Get amount
     $amount = $this->input->get("amount", 0, "float");
     // Get user ID
     $user = JFactory::getUser();
     $userId = (int) $user->get("id");
     // Anonymous user ID
     $aUserId = "";
     $model = $this->getModel();
     /** @var $model CrowdFundingModelBacking */
     // Get the item
     $item = $model->getItem($itemId);
     $returnUrl = CrowdFundingHelperRoute::getBackingRoute($item->slug, $item->catslug);
     // Authorise the user
     if (!$user->authorise("crowdfunding.donate", "com_crowdfunding")) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_('COM_CROWDFUNDING_ERROR_NO_PERMISSIONS'), "notice");
         return;
     }
     // Check for valid project
     if (empty($item->id)) {
         $this->setRedirect(JRoute::_(CrowdFundingHelperRoute::getDiscoverRoute()), JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), "notice");
         return;
     }
     // Check for maintenance (debug) state
     if ($params->get("debug_payment_disabled", 0)) {
         $msg = JString::trim($params->get("debug_disabled_functionality_msg"));
         if (!$msg) {
             $msg = JText::_("COM_CROWDFUNDING_DEBUG_MODE_DEFAULT_MSG");
         }
         $this->setRedirect(JRoute::_($returnUrl, false), $msg, "notice");
         return;
     }
     // Check for agreed conditions from the user
     if ($params->get("backing_terms", 0)) {
         $terms = $this->input->get("terms", 0, "int");
         if (!$terms) {
             $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_TERMS_NOT_ACCEPTED"), "notice");
             return;
         }
     }
     // Check for valid amount
     if (!$amount) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT"), "notice");
         return;
     }
     // Store payment process data
     // Get the payment process object and
     // store the selected data from the user.
     $paymentSessionContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSession = $app->getUserState($paymentSessionContext);
     $paymentSession->step1 = true;
     $paymentSession->amount = $amount;
     $paymentSession->rewardId = $rewardId;
     $app->setUserState($paymentSessionContext, $paymentSession);
     // Create an intention.
     // Generate hash user ID used for anonymous payment.
     if (!$userId) {
         $aUserId = $app->getUserState("auser_id");
         if (!$aUserId) {
             // Generate a hash ID for anonymous user.
             jimport("itprism.string");
             $anonymousUserId = new ITPrismString();
             $anonymousUserId->generateRandomString(32);
             $aUserId = (string) $anonymousUserId;
             $app->setUserState("auser_id", $aUserId);
         }
         $intentionKeys = array("auser_id" => $aUserId, "project_id" => $item->id);
     } else {
         $intentionKeys = array("user_id" => $userId, "project_id" => $item->id);
     }
     jimport("crowdfunding.intention");
     $intention = new CrowdFundingIntention(JFactory::getDbo());
     $intention->load($intentionKeys);
     $date = new JDate();
     $custom = array("user_id" => $userId, "auser_id" => $aUserId, "project_id" => $item->id, "reward_id" => $rewardId, "record_date" => $date->toSql(), "session_id" => $paymentSession->session_id);
     $intention->bind($custom);
     $intention->store();
     // Redirect to next page
     $link = CrowdFundingHelperRoute::getBackingRoute($item->slug, $item->catslug, "payment");
     $this->setRedirect(JRoute::_($link, false));
 }
Пример #23
0
 public function register($temp, $skipActivation = false, $language = 'en-GB')
 {
     $config = JFactory::getConfig();
     $db = $this->getDbo();
     $params = JComponentHelper::getParams('com_users');
     // Initialise the table with JUser.
     $user = new JUser();
     //$data = (array)$this->getData();
     $data['groups'] = array();
     // Get the default new user group, Registered if not specified.
     $system = $params->get('new_usertype', 2);
     $data['groups'][] = $system;
     // Merge in the registration data.
     foreach ($temp as $k => $v) {
         $data[$k] = $v;
     }
     // Prepare the data for the user object.
     $data['email'] = $data['email1'];
     $data['password'] = $data['password1'];
     $data['params'] = array('admin_language' => $language, 'language' => $language);
     //skipActivation set true ONLY from registerSocialUser (mobile.json.php)
     $useractivation = $skipActivation ? 0 : $params->get('useractivation');
     $sendpassword = $params->get('sendpassword', 1);
     // Check if the user needs to activate their account.
     if ($skipActivation == true) {
         $data['block'] = 0;
     } else {
         if ($useractivation == 1 || $useractivation == 2) {
             $data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
             $data['block'] = 1;
         }
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
         //return false;
         return JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError());
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Store the data.
     if (!$user->save()) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
         return $user->getError();
         //return JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError());
     }
     // Compile the notification mail values.
     $data = $user->getProperties();
     $data['fromname'] = $config->get('fromname');
     $data['mailfrom'] = $config->get('mailfrom');
     $data['sitename'] = $config->get('sitename');
     $data['siteurl'] = JUri::root();
     // Handle account activation/confirmation emails.
     if ($useractivation == 2) {
         // Set the link to confirm the user email.
         $uri = JURI::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username']);
         }
     } elseif ($useractivation == 1) {
         // Set the link to activate the user account.
         $uri = JURI::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username']);
         }
     } else {
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_BODY', $data['name'], $data['sitename'], $data['siteurl']);
     }
     // DO NOT Send registration email if called from registerSocial.
     if ($skipActivation == true) {
         return true;
     } else {
         // Send the registration email.
         $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
     }
     //Send Notification mail to administrators
     if ($params->get('useractivation') < 2 && $params->get('mail_to_admin') == 1) {
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         $emailBodyAdmin = JText::sprintf('COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY', $data['name'], $data['username'], $data['siteurl']);
         // get all admin users
         $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE sendEmail=1';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         // Send mail to all superadministrators id
         foreach ($rows as $row) {
             $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin);
             // Check for an error.
             if ($return !== true) {
                 $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                 //return false;
                 return JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED');
             }
         }
     }
     // Check for an error.
     if ($return !== true) {
         $this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
         // Send a system message to administrators receiving system mails
         $db = JFactory::getDBO();
         $q = "SELECT id\n\t\t\tFROM #__users\n\t\t\tWHERE block = 0\n\t\t\tAND sendEmail = 1";
         $db->setQuery($q);
         $sendEmail = $db->loadColumn();
         if (count($sendEmail) > 0) {
             $jdate = new JDate();
             // Build the query to add the messages
             $q = "INSERT INTO " . $db->quoteName('#__messages') . " (" . $db->quoteName('user_id_from') . ", " . $db->quoteName('user_id_to') . ", " . $db->quoteName('date_time') . ", " . $db->quoteName('subject') . ", " . $db->quoteName('message') . ") VALUES ";
             $messages = array();
             foreach ($sendEmail as $userid) {
                 $messages[] = "(" . $userid . ", " . $userid . ", '" . $jdate->toSql() . "', '" . JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT') . "', '" . JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username']) . "')";
             }
             $q .= implode(',', $messages);
             $db->setQuery($q);
             $db->query();
         }
         //return false;
         return JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED');
     }
     if ($useractivation == 1) {
         return "useractivate";
     } elseif ($useractivation == 2) {
         return "adminactivate";
     } else {
         return $user->id;
     }
 }
Пример #24
0
 /**
  * Returns the number of modified publishers between the given timeframe.
  * @param JDate $begin begin date
  * @param JDate $end end date
  * @return ObjectList number of modified publishers grouped by year and
  * month
  */
 public function getModifiedPublisherCountByDates($begin, $end)
 {
     // Initialize variables.
     $query = $this->_db->getQuery(true);
     // Conditions
     $conditions = array($this->_db->quoteName('modified') . ' >= ' . $this->_db->quote($begin->toSql()), $this->_db->quoteName('modified') . ' <= ' . $this->_db->quote($end->toSql()));
     // Create the query
     $query->select('YEAR(modified) as year, MONTH(modified) as month, count(distinct id) as count');
     $query->from($this->_db->quoteName($this->_tbl));
     $query->where($conditions);
     // Group by year and month
     $query->group('YEAR(modified), MONTH(modified)');
     $this->_db->setQuery($query);
     // Execute query
     return $this->_db->loadObjectList();
 }
Пример #25
0
 /**
  * Generate a media version string for assets
  * Public to allow third party developers to use it
  *
  * @return  string
  *
  * @since   3.2
  */
 public function generateMediaVersion()
 {
     $date = new JDate();
     $config = JFactory::getConfig();
     return md5($this->getLongVersion() . $config->get('secret') . $date->toSql());
 }
Пример #26
0
 /**
  * Method to get a category.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed    Category data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('category.parent_id');
             $result->extension = $this->getState('category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new Registry();
         $registry->loadString($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         $tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
         if ((int) $result->created_time) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if ((int) $result->modified_time) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
         if (!empty($result->id)) {
             $result->tags = new JHelperTags();
             $result->tags->getTagIds($result->id, $result->extension . '.category');
         }
     }
     $assoc = $this->getAssoc();
     if ($assoc) {
         if ($result->id != null) {
             $result->associations = CategoriesHelper::getAssociations($result->id, $result->extension);
             JArrayHelper::toInteger($result->associations);
         } else {
             $result->associations = array();
         }
     }
     return $result;
 }
Пример #27
0
 /**
  * Method to get a category.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed  Category data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('category.parent_id');
             $result->extension = $this->getState('category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new JRegistry();
         $registry->loadString($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         jimport('joomla.utilities.date');
         $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
         if (intval($result->created_time)) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if (intval($result->modified_time)) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
     }
     return $result;
 }
Пример #28
0
 /**
  * Store information about activity.
  *
  * <code>
  * $userId = 1;
  * $content = "...";
  *
  * $activity = new Prism\Integration\Activity\JomSocial($userId, $content);
  * $activity->setDb(JFactory::getDbo());
  * $activity->store();
  * </code>
  *
  * @throws \RuntimeException
  */
 public function store()
 {
     if (!$this->app) {
         throw new \RuntimeException(\JText::_('LIB_PRISM_ERROR_INVALID_JOMSOCIAL_APP'));
     }
     $query = $this->db->getQuery(true);
     $date = new \JDate();
     $query->insert($this->db->quoteName('#__community_activities'))->set($this->db->quoteName('actor') . '=' . (int) $this->actorId)->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('archived') . '=' . $this->db->quote($this->archived))->set($this->db->quoteName('app') . '=' . $this->db->quote($this->app))->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
     $this->db->setQuery($query);
     $this->db->execute();
     // Get the ID of the record.
     $this->id = $this->db->insertid();
 }
Пример #29
0
 /**
  * Returns the number of received identifier applications between the given 
  * timeframe.
  * @param JDate $begin begin date
  * @param JDate $end end date
  * @param boolean $music if true the number of sheet music applications
  * is returned, otherwise the number of all the other applications is
  * returned
  * @return ObjectList number of received identifier applications grouped by 
  * year and month
  */
 public function getIdentifierApplicationCountByDates($begin, $end, $music = false)
 {
     // Initialize variables.
     $query = $this->_db->getQuery(true);
     // Conditions
     $conditions = array($this->_db->quoteName('p.created') . ' >= ' . $this->_db->quote($begin->toSql()), $this->_db->quoteName('p.created') . ' <= ' . $this->_db->quote($end->toSql()), $this->_db->quoteName('p.created_by') . ' = ' . $this->_db->quote('WWW'));
     //
     if ($music) {
         array_push($conditions, $this->_db->quoteName('p.publication_type') . ' = ' . $this->_db->quote('SHEET_MUSIC'));
     } else {
         array_push($conditions, $this->_db->quoteName('p.publication_type') . ' != ' . $this->_db->quote('SHEET_MUSIC'));
     }
     // Create the query
     $query->select('YEAR(p.created) as year, MONTH(p.created) as month, count(distinct p.id) as count');
     $query->from($this->_db->quoteName($this->_tbl) . ' as p');
     $query->where($conditions);
     // Group by year and month
     $query->group('YEAR(p.created), MONTH(p.created)');
     $this->_db->setQuery($query);
     // Execute query
     return $this->_db->loadObjectList();
 }
Пример #30
0
 function sendJoomlaEmail($data)
 {
     $lang = JFactory::getLanguage();
     $extension = 'com_users';
     $base_dir = JPATH_SITE;
     $language_tag = 'en-GB';
     $lang->load($extension, $base_dir, $language_tag, true);
     $data = (array) $data;
     $user = $data;
     $params = JComponentHelper::getParams('com_users');
     // Prepare the data for the user object.
     //$data['email'] = JStringPunycode::emailToPunycode($data['email1']);
     $data['password'] = $data['password1'];
     $useractivation = $params->get('useractivation');
     $sendpassword = $params->get('sendpassword', 1);
     $config = JFactory::getConfig();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Compile the notification mail values.
     $data['fromname'] = $config->get('fromname');
     $data['mailfrom'] = $config->get('mailfrom');
     $data['sitename'] = $config->get('sitename');
     $data['siteurl'] = JUri::root();
     // Handle account activation/confirmation emails.
     if ($useractivation == 2) {
         // Set the link to confirm the user email.
         $uri = JUri::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'] . "&g=1", false);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username']);
         }
         $emailBody = str_replace("\n\r", "<br/>", $emailBody);
         $emailBody = str_replace("\n", "<br/>", $emailBody);
         $emailBody = str_replace("\r", "<br/>", $emailBody);
     } elseif ($useractivation == 1) {
         // Set the link to activate the user account.
         $uri = JUri::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'] . "&g=1", false);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username']);
         }
         $emailBody = str_replace("\n\r", "<br/>", $emailBody);
         $emailBody = str_replace("\n", "<br/>", $emailBody);
         $emailBody = str_replace("\r", "<br/>", $emailBody);
     }
     // Send the registration email.
     $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody, true);
     // Send Notification mail to administrators
     if ($params->get('useractivation') < 2 && $params->get('mail_to_admin') == 1) {
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         $emailBodyAdmin = JText::sprintf('COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY', $data['name'], $data['username'], $data['siteurl']);
         // Get all admin users
         $query->clear()->select($db->quoteName(array('name', 'email', 'sendEmail')))->from($db->quoteName('#__users'))->where($db->quoteName('sendEmail') . ' = ' . 1);
         $db->setQuery($query);
         try {
             $rows = $db->loadObjectList();
         } catch (RuntimeException $e) {
             $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
             return false;
         }
         // Send mail to all superadministrators id
         foreach ($rows as $row) {
             $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin, 1);
             // Check for an error.
             if ($return !== true) {
                 $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                 return false;
             }
         }
     }
     // Check for an error.
     if ($return !== true) {
         $this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
         // Send a system message to administrators receiving system mails
         $db = JFactory::getDbo();
         $query->clear()->select($db->quoteName(array('name', 'email', 'sendEmail', 'id')))->from($db->quoteName('#__users'))->where($db->quoteName('block') . ' = ' . (int) 0)->where($db->quoteName('sendEmail') . ' = ' . (int) 1);
         $db->setQuery($query);
         try {
             $sendEmail = $db->loadColumn();
         } catch (RuntimeException $e) {
             $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
             return false;
         }
         if (count($sendEmail) > 0) {
             $jdate = new JDate();
             // Build the query to add the messages
             foreach ($sendEmail as $userid) {
                 $values = array($db->quote($userid), $db->quote($userid), $db->quote($jdate->toSql()), $db->quote(JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT')), $db->quote(JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username'])));
                 $query->clear()->insert($db->quoteName('#__messages'))->columns($db->quoteName(array('user_id_from', 'user_id_to', 'date_time', 'subject', 'message')))->values(implode(',', $values));
                 $db->setQuery($query);
                 try {
                     $db->execute();
                 } catch (RuntimeException $e) {
                     $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
                     return false;
                 }
             }
         }
         return false;
     }
     if ($useractivation == 1) {
         return "useractivate";
     } elseif ($useractivation == 2) {
         return "adminactivate";
     } else {
         return $user["id"];
     }
 }