Permalink
Browse files

Merge pull request #517 from mahagr/master

Fix #513, #515, #490 and broken javascript if using the old default template
  • Loading branch information...
2 parents 17cc2cd + 0c36b43 commit 37e4eb069551cd3d9fbc686185a5bd3b97309a56 @mahagr mahagr committed Apr 10, 2012
@@ -126,7 +126,7 @@ public function toTimezone() {
}
public function toSpan($mode = 'datetime_today', $title = 'ago', $offset=false) {
- return '<span class="kdate" title="'.$this->toKunena($title).'">'.$this->toKunena($mode).'</span>';
+ return '<span class="kdate" title="'.$this->toKunena($title, $offset).'">'.$this->toKunena($mode, $offset).'</span>';
}
public function toKunena($mode = 'datetime_today', $offset=false) {
@@ -178,7 +178,11 @@ public function toKunena($mode = 'datetime_today', $offset=false) {
$now->setOffset($offset);
} else {
// Joomla 1.6 support
- $offset = new DateTimeZone($offset);
+ try {
+ $offset = new DateTimeZone($offset);
+ } catch (Exception $e) {
+ $offset = new DateTimeZone('UTC');
+ }
$this->setTimezone($offset);
$now->setTimezone($offset);
}
@@ -94,7 +94,7 @@ function addScript($filename) {
$config = KunenaFactory::getConfig ();
$template = KunenaFactory::getTemplate();
- if ($template->name != 'default') $filename = preg_replace('#/template/default/#', '/template/blue_eagle/', $filename);
+ $filename = preg_replace('#/template/default/#', '/template/blue_eagle/', $filename);
$filename = preg_replace('#^.*/(mediaboxAdv(-min)?.js)$#', KUNENA_DIRECTURL.'template/blue_eagle/js/\1', $filename);
if (JDEBUG || $config->debug || KunenaForum::isDev()) {
// If we are in debug more, make sure we load the unpacked javascript
@@ -59,6 +59,7 @@ public function karmadown() {
}
public function save() {
+ // TODO: allow moderators to save another users profile (without account info)
if (! JRequest::checkToken ()) {
$this->app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$this->redirectBack ();
@@ -70,7 +71,9 @@ public function save() {
return;
}
- $this->saveUser();
+ // FIXME: $this->saveUser() doesn't work either in J!1.5 or J!2.5
+ $this->app->enqueueMessage('TODO: Save changes to user account!', 'error');
+ //$this->saveUser();
$this->saveProfile();
$this->saveAvatar();
@@ -360,7 +363,7 @@ protected function saveUser()
protected function saveProfile() {
$this->me->personalText = JRequest::getVar ( 'personaltext', '' );
- $this->me->birthdate = JRequest::getInt ( 'birthdate1', '' ).'-'.JRequest::getInt ( 'birthdate2', '' ).'-'.JRequest::getInt ( 'birthdate3', '' );
+ $this->me->birthdate = JRequest::getInt ( 'birthdate1', '0000' ).'-'.JRequest::getInt ( 'birthdate2', '00' ).'-'.JRequest::getInt ( 'birthdate3', '00' );
$this->me->location = trim(JRequest::getVar ( 'location', '' ));
$this->me->gender = JRequest::getInt ( 'gender', '' );
$this->me->icq = trim(JRequest::getString ( 'icq', '' ));
@@ -31,16 +31,17 @@ protected function populateState() {
}
// List state information
- $value = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_limit", 'limit', $config->get('userlist_rows'), 'int' );
- if ($value < 1 || $value > 100) $value = $config->get('userlist_rows');
- $this->setState ( 'list.limit', $value );
-
- $value = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_ordering", 'filter_order', 'id', 'cmd' );
- $this->setState ( 'list.ordering', $value );
+ $limit = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_limit", 'limit', $config->get('userlist_rows'), 'int' );
+ if ($limit < 1 || $limit > 100) $limit = $config->get('userlist_rows');
+ $this->setState ( 'list.limit', $limit );
$value = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_start", 'limitstart', 0, 'int' );
+ $value -= $value % $limit;
$this->setState ( 'list.start', $value );
+ $value = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_ordering", 'filter_order', 'id', 'cmd' );
+ $this->setState ( 'list.ordering', $value );
+
$value = $this->getUserStateFromRequest ( "com_kunena.users_{$active}_list_direction", 'filter_order_Dir', 'asc', 'word' );
if ($value != 'asc')
$value = 'desc';
@@ -68,8 +69,8 @@ public function getQuerySearch() {
$where = array();
if ($search) {
$db = JFactory::getDBO();
- if (!$this->config->username) $where[] = "u.name LIKE '%{$db->getEscaped($search)}%'";
- if ($this->config->username || !$where) $where[] = "u.username LIKE '%{$db->getEscaped($search)}%'";
+ if ($this->config->username) $where[] = "u.username LIKE '%{$db->getEscaped($search)}%'";
+ else $where[] = "u.name LIKE '%{$db->getEscaped($search)}%'";
$where = 'AND ('.implode(' OR ', $where).')';
} else {
$where = '';
@@ -96,7 +97,10 @@ public function getCount() {
$db = JFactory::getDBO();
$where = $this->getQueryWhere();
$search = $this->getQuerySearch();
- $query = "SELECT COUNT(*) FROM #__users AS u INNER JOIN #__kunena_users AS fu ON u.id=fu.userid WHERE {$where} {$search}";
+ $query = "SELECT COUNT(*)
+ FROM #__users AS u
+ INNER JOIN #__kunena_users AS ku ON ku.userid = u.id
+ WHERE {$where} {$search}";
$db->setQuery ( $query );
$total = $db->loadResult ();
KunenaError::checkDatabaseError();
@@ -105,8 +109,18 @@ public function getCount() {
}
public function getItems() {
+ // FIXME: use pagination object and redirect on illegal page (maybe in the view)
+ // TODO: should we reset to page 1 when user makes a new search?
static $items = false;
if ($items === false) {
+ $limitstart = $this->getState ( 'list.start');
+ $limit = $this->getState ( 'list.limit');
+ $count = $this->getCount();
+ if ($count < $limitstart) {
+ $limitstart = $count - ($count % $limit);
+ $this->setState ( 'list.start', $limitstart );
+ }
+
$db = JFactory::getDBO();
$where = $this->getQueryWhere();
$search = $this->getQuerySearch();
@@ -117,7 +131,7 @@ public function getItems() {
WHERE {$where} {$search}";
$query .= " ORDER BY {$db->nameQuote($this->getState ( 'list.ordering'))} {$this->getState ( 'list.direction')}";
- $db->setQuery ( $query, $this->getState ( 'list.start'), $this->getState ( 'list.limit') );
+ $db->setQuery ( $query, $limitstart, $limit );
$items = $db->loadObjectList ('id');
KunenaError::checkDatabaseError();
@@ -80,7 +80,7 @@
<ul>
<li><span class="kicon-profile kicon-profile-location"></span><strong><?php echo JText::_('COM_KUNENA_MYPROFILE_LOCATION') ?>:</strong> <?php echo $this->locationlink ?></li>
<li><span class="kicon-profile kicon-profile-gender-unknown"></span><strong><?php echo JText::_('COM_KUNENA_MYPROFILE_GENDER') ?>:</strong> <?php echo $this->gender ?></li>
- <li><span class="kicon-profile kicon-profile-birthdate"></span><strong><?php echo JText::_('COM_KUNENA_MYPROFILE_BIRTHDATE') ?>:</strong> <?php echo KunenaDate::getInstance($this->profile->birthdate)->toKunena('date', 'ago', 'utc') ?></li>
+ <li><span class="kicon-profile kicon-profile-birthdate"></span><strong><?php echo JText::_('COM_KUNENA_MYPROFILE_BIRTHDATE') ?>:</strong> <?php echo KunenaDate::getInstance($this->profile->birthdate)->toSpan('date', 'ago', 'utc') ?></li>
</ul>
</div>
</div>
@@ -690,7 +690,7 @@ function displayMessage($id, $message, $template=null) {
$this->mmm ++;
$this->message = $message;
$this->profile = $this->message->getAuthor();
- $this->replynum = $id;
+ $this->replynum = $id+1;
$usertype = $this->me->getType($this->category->id, true);
if ($usertype == 'user' && $this->message->userid == $this->profile->userid) $usertype = 'owner';

0 comments on commit 37e4eb0

Please sign in to comment.