/**
  * Retrieved list of objects base on a given parameters - dynamic method: list_PaForumPost()
  *
  *
  * Generated with the DalClassGenerator created by: 
  * Zoran Hron <*****@*****.**> 
  *
  * @param conditionalStatement = null
  * @param orderby = null
  * @param sort = null
  * @param limit = 0
  * @param fetchmode = DB_FETCHMODE_OBJECT
  * @result array of objects: PaForumPost
  **/
 public function list_PaForumPost($conditionalStatement = null, $orderby = null, $sort = null, $limit = 0, $fetchmode = DB_FETCHMODE_OBJECT)
 {
     $this->initialize($conditionalStatement, $orderby, $sort);
     // build MySQL query
     $sql = "SELECT * FROM { pa_forum_post } ";
     if ($conditionalStatement) {
         $sql .= "WHERE {$conditionalStatement}";
     }
     if ($orderby) {
         $sql .= " ORDER BY {$orderby}";
     }
     if ($sort) {
         $sql .= " {$sort}";
     }
     if ($limit) {
         $sql .= " LIMIT {$limit}";
     }
     $sql .= ";";
     // execute query
     $res = Dal::query($sql);
     $objects = array();
     // data found?
     if ($res->numRows() > 0) {
         // retrieve data objects
         while ($row = $res->fetchRow($fetchmode)) {
             if ($fetchmode == DB_FETCHMODE_OBJECT) {
                 $obj = new PaForumPost();
                 $obj->populateFromObject($row);
                 $objects[] = $obj;
             } else {
                 $objects[] = $row;
             }
         }
     }
     return $objects;
 }
 /**
  * Delete an existing record - dynamic method: delete_PaForumsUsers()
  *
  *
  * Generated with the DalClassGenerator created by: 
  * Zoran Hron <*****@*****.**> 
  *
  * @param user_id
  * @result void
  **/
 public function delete_PaForumsUsers($user_id)
 {
     PaForumBoard::delete_UserBoards($user_id);
     PaForumThread::delete_ThreadsForUser($user_id);
     PaForumPost::delete_PostsForUser($user_id);
     // sql query
     $sql = "UPDATE { pa_forums_users } SET is_active = 0 WHERE user_id = ?;";
     $params = array($user_id);
     // performs deletion of data
     $res = Dal::query($sql, $params);
 }
 public function getThreadStatistics()
 {
     $statistic = array();
     $posts = array();
     $conditionalStatement = "thread_id = {$this->id} AND is_active = 1";
     $orderby = "created_at";
     $sort = "DESC";
     $limit = 1;
     $posts = PaForumPost::listPaForumPost($conditionalStatement, $orderby, $sort, $limit);
     $nb_posts = PaForumPost::countPaForumPost($conditionalStatement);
     $user = new User();
     $user->load((int) $this->get_user_id());
     $statistics['user'] = $user;
     $statistics['posts'] = $nb_posts;
     $last_post = null;
     if (!empty($posts[0])) {
         $last_post = $posts[0];
         $last_post->user = $last_post->getAuthor();
     }
     $statistics['last_post'] = $last_post;
     // (!empty($posts[0])) ? $posts[0] : null;
     return $statistics;
 }
                      <div class="forum_avatar">
                          <a href="<?php 
echo PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $created_by->login_name;
?>
">
                            <?php 
echo uihelper_resize_mk_user_img($created_by->picture, $avatar_size['width'], $avatar_size['height'], 'alt="' . $created_by->login_name . '"');
?>
                          </a>
                        </div>
                        <div class="smallfont">
                          <div><?php 
echo __('Posts');
?>
: <?php 
echo PaForumPost::countPaForumPost("user_id = {$created_by->user_id}");
?>
 </div>
                          <div><?php 
echo __('Last login');
?>
: <?php 
echo PA::date($created_by->last_login, 'short');
?>
 </div>
                          <div><?php 
echo __('Status');
?>
: <?php 
echo PaForumsUsers::getStatusString($created_by->user_id);
?>
 private function handlePOST_updatePost($request_data, $mode = 'post')
 {
     $err = null;
     $form_data = $request_data['form_data'];
     if (empty($form_data['edit_title'])) {
         $err .= "* " . __("Title field can't be empty") . ".<br />";
     }
     if (empty($form_data['edit_content'])) {
         $err .= "* " . __("Content field can't be empty") . ".<br />";
     }
     if ($err) {
         $request_data['action'] = 'edit';
         $this->redirectWithMessage($err, $request_data);
         exit;
     }
     $edited_by = new User();
     $edited_by->load((int) $this->forum_user->get_user_id());
     $content = $form_data['edit_content'];
     /*
         $content .= "<div class=\"edited_by\">\n" .
                     __("Edited by") .": " . $edited_by->login_name .
                     ", " . PA::datetime(time(), 'long', 'short') . "\n</div>";
     */
     $params = array("title" => $form_data['edit_title'], "content" => $content, "updated_at" => date("Y-m-d H:i:s"), "modified_by" => $edited_by->login_name);
     unset($request_data['mode']);
     unset($request_data['action']);
     try {
         if ($mode == 'post') {
             PaForumPost::updatePaForumPost($request_data['post_id'], $params);
             $msg = __("Post sucessfully saved");
         } else {
             if ($mode == 'thread') {
                 PaForumThread::updatePaForumThread($request_data['thread_id'], $params);
                 $msg = __("Thread sucessfully saved");
             }
         }
         $this->redirectWithMessage($msg, $request_data, 'info_message');
     } catch (Exception $e) {
         $this->redirectWithMessage($e->getMessage(), $request_data);
     }
 }
              <div class="forum_avatar">
                <a href="<?php 
echo PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $post->user->login_name;
?>
">
                  <?php 
echo uihelper_resize_mk_user_img($post->user->picture, $avatar_size['width'], $avatar_size['height'], 'alt="' . $post->user->login_name . '"');
?>
                </a>
              </div>
              <div class="smallfont">
                <div><?php 
echo __('Posts');
?>
: <?php 
echo $post->user->user_id != -1 ? PaForumPost::countPaForumPost("user_id = " . $post->user->user_id) : '';
?>
 </div>
                <div><?php 
echo __('Last login');
?>
: <?php 
echo $post->user->user_id != -1 ? PA::date($post->user->last_login, 'short') : '';
?>
 </div>
                <div><?php 
echo __('Status');
?>
: <?php 
echo $post->user->user_id != -1 ? PaForumsUsers::getStatusString($post->user->user_id) : '';
?>