/**
  * @access public
  * @return void
  * @param int[] $a_ids
  * @desc Read from the db the comments for the supplied review item
  */
 public function ReadCommentsForReviewItem(ReviewItem $review_item)
 {
     $s_person = $this->GetSettings()->GetTable('User');
     $s_message = $this->GetSettings()->GetTable('ForumMessage');
     # prepare command
     $s_sql = 'SELECT ' . $s_person . '.user_id, ' . $s_person . '.known_as, ' . 'location, ' . $s_person . ".date_added AS sign_up_date, " . $s_person . '.total_messages, ' . $s_message . '.id, ' . $s_message . '.message, ' . $s_message . ".date_added AS message_date " . 'FROM ' . $s_message . ' INNER JOIN ' . $s_person . ' ON ' . $s_message . '.user_id = ' . $s_person . '.user_id ' . 'WHERE ' . $s_message . '.item_id = ' . Sql::ProtectNumeric($review_item->GetId(), false, false) . ' AND item_type = ' . Sql::ProtectNumeric($review_item->GetType(), false, false);
     if ($this->GetReverseOrder()) {
         $s_sql .= ' ORDER BY sort_override DESC, ' . $s_message . '.date_added DESC';
     } else {
         $s_sql .= ' ORDER BY sort_override, ' . $s_message . '.date_added ASC';
     }
     # get data
     $result = $this->GetDataConnection()->query($s_sql);
     $this->Clear();
     $o_topic = new ForumTopic($this->GetSettings());
     while ($o_row = $result->fetch()) {
         $o_person = new User();
         $o_person->SetId($o_row->user_id);
         $o_person->SetName($o_row->known_as);
         $o_person->SetSignUpdate($o_row->sign_up_date);
         $o_person->SetLocation($o_row->location);
         $o_person->SetTotalMessages($o_row->total_messages);
         $o_message = new ForumMessage($this->GetSettings(), AuthenticationManager::GetUser());
         $o_message->SetId($o_row->id);
         $o_message->SetDate($o_row->message_date);
         $o_message->SetBody($o_row->message);
         $o_message->SetUser($o_person);
         $o_message->SetReviewItem($review_item);
         $o_topic->Add($o_message);
     }
     $this->Add($o_topic);
     $result->closeCursor();
 }
 /**
  * @return void
  * @desc Re-build from data posted by this control the data object this control
  * is editing
  */
 function BuildPostedDataObject()
 {
     $user = new User();
     $user->SetId($_POST['item']);
     $user->SetFirstName($_POST['name_first']);
     $user->SetLastName($_POST['name_last']);
     $user->SetName($_POST['known_as']);
     $user->SetEmail($_POST['email']);
     $user->SetAccountDisabled(isset($_POST['disabled']));
     $roles = $this->roles_editor->DataObjects()->GetItems();
     foreach ($roles as $role) {
         $user->Roles()->Add($role);
     }
     $this->SetDataObject($user);
 }
 /**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 function BuildPostedDataObject()
 {
     $o_person = new User();
     if (isset($_POST['known_as'])) {
         $o_person->SetName($_POST['known_as']);
     }
     if (isset($_POST['email'])) {
         $o_person->SetEmail($_POST['email']);
     }
     if (isset($_POST['password1'])) {
         $o_person->SetPassword($_POST['password1']);
     }
     if (isset($_POST['password2'])) {
         $o_person->SetPasswordConfirmation($_POST['password2']);
     }
     $this->SetDataObject($o_person);
 }
Example #4
0
<?php

class User
{
    private $name;
    public function SetName($recievename)
    {
        $this->name = $recievename;
    }
    public function Displayname()
    {
        echo $this->name;
        echo '<br>';
    }
}
$q = new User();
$q->SetName("shahbaj");
$q->Displayname();
 /**
  * When a user's credentials have been validated, get more info on that user
  * @param int $user_id
  * @return User
  */
 public function ReadDataForValidUser($user_id)
 {
     $user = null;
     $sql = "SELECT user_id, known_as, name_first, name_last, email, \r\n        disabled, activated, requested_email\r\n        FROM nsa_user WHERE user_id = " . Sql::ProtectNumeric($user_id);
     $result = $this->GetDataConnection()->query($sql);
     $row = $result->fetch();
     if ($row) {
         $user = new User();
         $user->SetId($row->user_id);
         $user->SetName($row->known_as);
         $user->SetFirstName($row->name_first);
         $user->SetLastName($row->name_last);
         $user->SetEmail($row->email);
         $user->SetRequestedEmail($row->requested_email);
         $user->SetAccountActivated($row->activated);
         $user->SetAccountDisabled($row->disabled);
     }
     return $user;
 }