PHP User::GetName Examples

PHP User::GetName - 14 examples found. These are the top rated real world PHP examples of User::GetName extracted from open source projects. You can rate examples to help us improve the quality of examples.
 public function ContactsAction()
 {
     if (!Request::isPosted('adress')) {
         if ($this->company->web == '') {
             $this->company->web = 'http://';
         }
         $this->company->email = User::GetName();
         $this->render('contacts', ['company' => $this->company]);
     } else {
         $this->company->adress = Request::post('adress');
         $this->company->email = Request::post('email');
         $this->company->web = Request::post('web');
         $this->company->phone = Request::post('phone');
         if ($this->company->web == 'http://') {
             $this->company->web = '';
         }
         if ($this->company->adress == '' and $this->company->web == '') {
             Site::Message('Укажите Ваш почтовый адрес или хотя-бы Web-сайт');
             $this->render('contacts', ['company' => $this->company]);
         } else {
             $this->company->save();
             $this->GroupAction();
         }
     }
 }
Example #2
0
 public function marshal()
 {
     require_once 'models/user.php';
     $pdo = get_link_identifier()->getPdo();
     $marshaledNote = array();
     $user = new User();
     $user->Id = $this->UserId;
     $marshaledNote['user'] = $user->GetName();
     $timestamp = strtotime($this->TimeStamp . ' UTC');
     $marshaledNote['date'] = date('H:i:s T', $timestamp);
     $status = '';
     switch ($this->Status) {
         case 0:
             $status = '[note]';
             break;
         case 1:
             $status = '[fix in progress]';
             break;
         case 2:
             $status = '[fixed]';
             break;
     }
     $marshaledNote['status'] = $status;
     $marshaledNote['text'] = $this->Note;
     return $marshaledNote;
 }
Example #3
0
 public function AddUser(User $user)
 {
     try {
         $DB = $this->connection();
         $sql = "INSERT INTO {$this->DBTable} (" . self::$name . "," . self::$password . ") VALUES (?, ?)";
         $params = array($user->GetName(), $user->GetPassword());
         $query = $DB->prepare($sql);
         $query->execute($params);
     } catch (PDOException $e) {
         die("Error 2");
     }
 }
Example #4
0
 public function testUser()
 {
     $this->startCodeCoverage();
     $user = new User();
     $user->Id = 'non_numeric';
     if (!($user->SetPassword('blah') === false)) {
         $this->fail("User::SetPassword didn't return false for non-numeric user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::IsAdmin didn't return false for non-numeric user id");
         return 1;
     }
     $user->Id = '';
     $user->Email = '';
     if (!($user->GetName() === false)) {
         $this->fail("User::GetName didn't return false when given no user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::Exists didn't return false for no user id and no email");
         return 1;
     }
     $user->Email = 'simpletest@localhost';
     if ($user->Exists() === false) {
         $this->fail('User::Exists returned false even though user exists');
         return 1;
     }
     $id = $user->GetIdFromEmail('simpletest@localhost');
     if ($id === false) {
         $this->fail('User::GetIdFromEmail returned false for a valid user');
         return 1;
     }
     $user->Id = $id;
     $user->Admin = '1';
     $user->FirstName = 'administrator';
     $user->Institution = 'Kitware Inc.';
     if ($user->Exists() != true) {
         $this->fail('User::Exists failed given a valid user id');
         return 1;
     }
     $user->Password = md5('simpletest');
     // Coverage for update save
     $user->Save();
     // Coverage for SetPassword
     $user->SetPassword(md5('simpletest'));
     $this->stopCodeCoverage();
     return 0;
 }
Example #5
0
 function testUser()
 {
     $this->startCodeCoverage();
     $user = new User();
     $user->Id = "non_numeric";
     if (!($user->SetPassword("blah") === false)) {
         $this->fail("User::SetPassword didn't return false for non-numeric user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::IsAdmin didn't return false for non-numeric user id");
         return 1;
     }
     $user->Id = "";
     $user->Email = "";
     if (!($user->GetName() === false)) {
         $this->fail("User::GetName didn't return false when given no user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::Exists didn't return false for no user id and no email");
         return 1;
     }
     $user->Email = "simpletest@localhost";
     if ($user->Exists() === false) {
         $this->fail("User::Exists returned false even though user exists");
         return 1;
     }
     $id = $user->GetIdFromEmail("simpletest@localhost");
     if ($id === false) {
         $this->fail("User::GetIdFromEmail returned false for a valid user");
         return 1;
     }
     $user->Id = $id;
     $user->Admin = "1";
     $user->FirstName = "administrator";
     $user->Institution = "Kitware Inc.";
     if ($user->Exists() != true) {
         $this->fail("User::Exists failed given a valid user id");
         return 1;
     }
     $user->Password = md5("simpletest");
     // Coverage for update save
     $user->Save();
     // Coverage for SetPassword
     $user->SetPassword(md5("simpletest"));
     $this->stopCodeCoverage();
     return 0;
 }
Example #6
0
        }
    } elseif (isset($_POST['makenormaluser'])) {
        if ($postuserid > 1) {
            $update_array = pdo_fetch_array(pdo_query('SELECT firstname,lastname FROM ' . qid('user') . " WHERE id='" . $postuserid . "'"));
            pdo_query('UPDATE ' . qid('user') . " SET admin=0 WHERE id='" . $postuserid . "'");
            $xml .= '<warning>' . $update_array['firstname'] . ' ' . $update_array['lastname'] . ' is not administrator anymore.</warning>';
        } else {
            $xml .= '<error>Administrator should remain admin.</error>';
        }
    } elseif (isset($_POST['makeadmin'])) {
        $update_array = pdo_fetch_array(pdo_query('SELECT firstname,lastname FROM ' . qid('user') . " WHERE id='" . $postuserid . "'"));
        pdo_query('UPDATE ' . qid('user') . " SET admin=1 WHERE id='" . $postuserid . "'");
        $xml .= '<warning>' . $update_array['firstname'] . ' ' . $update_array['lastname'] . ' is now an administrator.</warning>';
    } elseif (isset($_POST['removeuser'])) {
        $user = new User();
        $user->Id = $postuserid;
        $user->Fill();
        $name = $user->GetName();
        $user->Delete();
        $xml .= "<warning>{$name} has been removed.</warning>";
    }
    if (isset($_POST['search'])) {
        $xml .= '<search>' . $_POST['search'] . '</search>';
    }
    if (isset($CDASH_FULL_EMAIL_WHEN_ADDING_USER) && $CDASH_FULL_EMAIL_WHEN_ADDING_USER == 1) {
        $xml .= add_XML_value('fullemail', '1');
    }
    $xml .= '</cdash>';
    // Now doing the xslt transition
    generate_XSLT($xml, 'manageUsers');
}
Example #7
0
         break;
     case 3:
         $priority = '<div class="error">High</div>';
         break;
     case 4:
         $priority = '<div class="error">Urgent</div>';
         break;
 }
 $row[] = $priority;
 // Sixth colum (Authors)
 if ($userid > 0) {
     $author = '';
     if (isset($covfile['user'])) {
         $User = new User();
         $User->Id = $covfile['user'];
         $author = $User->GetName();
     }
     $row[] = $author;
 }
 // Seventh colum (Label)
 if (isset($_GET['displaylabels']) && $_GET['displaylabels'] == 1) {
     $fileid = $covfile['fileid'];
     $labels = '';
     $coveragelabels = pdo_query('SELECT text FROM label, label2coveragefile WHERE ' . 'label.id=label2coveragefile.labelid AND ' . "label2coveragefile.coveragefileid='{$fileid}' AND " . "label2coveragefile.buildid='{$buildid}' " . 'ORDER BY text ASC');
     while ($coveragelabels_array = pdo_fetch_array($coveragelabels)) {
         if ($labels != '') {
             $labels .= ', ';
         }
         $labels .= $coveragelabels_array['text'];
     }
     $row[] = $labels;
Example #8
0
                    $xml .= add_XML_value("id", $authorid);
                    $xml .= "</author>";
                }
                $priority = $CoverageFile2User->GetPriority();
                if ($priority > 0) {
                    $xml .= add_XML_value("priority", $priority);
                }
                $xml .= "</file>";
            }
        }
        // end count(buildids)
        // List all the users of the project
        $UserProject = new UserProject();
        $UserProject->ProjectId = $Project->Id;
        $userIds = $UserProject->GetUsers();
        foreach ($userIds as $userid) {
            $User = new User();
            $User->Id = $userid;
            $xml .= "<user>";
            $xml .= add_XML_value("id", $userid);
            $xml .= add_XML_value("name", $User->GetName());
            $xml .= "</user>";
        }
        $xml .= "</project>";
    }
    $xml .= "</cdash>";
    // Now doing the xslt transition
    generate_XSLT($xml, "manageCoverage");
}
// end session OK
?>
 function OnPrePageLoad()
 {
     $this->SetPageTitle($this->user->GetName() . ': Edit user');
 }
Example #10
0
<?php

$username = User::GetName();
$company = CompanyModel::GetObj()->id(User::company());
if ($company->name != '') {
    $username = $company->name;
}
?>

<?php 
if (User::isLogged()) {
    ?>
	<a href="<?php 
    echo Site::link('profile');
    ?>
" class="username"><?php 
    echo $username;
    ?>
</a>
<div class="button_bar">
    <a href="<?php 
    echo Site::link('logout');
    ?>
" class="green">Выход</a>
<?php 
} else {
    ?>
 
	<a href="<?php 
    echo Site::link('registration');
    ?>
Example #11
0
                    $User = new User();
                    $User->Id = $authorid;
                    $xml .= add_XML_value('name', $User->GetName());
                    $xml .= add_XML_value('id', $authorid);
                    $xml .= '</author>';
                }
                $priority = $CoverageFile2User->GetPriority();
                if ($priority > 0) {
                    $xml .= add_XML_value('priority', $priority);
                }
                $xml .= '</file>';
            }
        }
        // List all the users of the project
        $UserProject = new UserProject();
        $UserProject->ProjectId = $Project->Id;
        $userIds = $UserProject->GetUsers();
        foreach ($userIds as $userid) {
            $User = new User();
            $User->Id = $userid;
            $xml .= '<user>';
            $xml .= add_XML_value('id', $userid);
            $xml .= add_XML_value('name', $User->GetName());
            $xml .= '</user>';
        }
        $xml .= '</project>';
    }
    $xml .= '</cdash>';
    // Now doing the xslt transition
    generate_XSLT($xml, 'manageCoverage');
}
    /**
     * Helper to build and send the email when a match has been added by a public user
     *
     * @param Match $o_match
     * @param User $o_user
     * @param bool $b_is_new_match
     * @param bool $b_is_deleted_match
     * @param string $s_email
     * @param Season[] $seasons
     */
    private function SendMatchUpdatedEmail(Match $o_match, User $o_user, $b_is_new_match, $b_is_deleted_match, $s_email, $seasons = null)
    {
        # text of email
        $s_season_list = '';
        if (is_array($seasons)) {
            $i_total_seasons = count($seasons);
            for ($i = 0; $i < $i_total_seasons; $i++) {
                if ($i == 0) {
                    $s_season_list = "'" . $seasons[$i]->GetCompetitionName() . "'";
                } else {
                    if ($i == $i_total_seasons - 1) {
                        $s_season_list .= " and '" . $seasons[$i]->GetCompetitionName() . "'";
                    } else {
                        $s_season_list .= ", '" . $seasons[$i]->GetCompetitionName() . "'";
                    }
                }
            }
        }
        $s_season = $s_season_list ? " in the {$s_season_list}" : '';
        $s_why = $s_season_list ? $s_season_list : 'matches';
        $new = $b_is_new_match ? 'new ' : '';
        $verb = $b_is_new_match ? 'added' : 'updated';
        if ($b_is_deleted_match) {
            $verb = 'deleted';
        }
        $match_text = $o_match->GetMatchType() == MatchType::TOURNAMENT ? 'tournament' : 'match';
        $s_title = html_entity_decode($o_match->GetTitle());
        $s_date = ucfirst($o_match->GetStartTimeFormatted());
        $s_ground = is_object($o_match->GetGround()) ? $o_match->GetGround()->GetNameAndTown() : '';
        $s_notes = $o_match->GetNotes();
        $s_domain = $this->settings->GetDomain();
        $s_url = 'https://' . $s_domain . $o_match->GetNavigateUrl();
        $s_contact_url = 'https://' . $s_domain . $this->settings->GetFolder('Contact');
        $s_home_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetHomeTeam()->GetName());
        $s_away_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetAwayTeam()->GetName());
        $s_bat_first = is_null($o_match->Result()->GetHomeBattedFirst()) ? 'Not known which team batted first' : ($o_match->Result()->GetHomeBattedFirst() ? $s_home_name : $s_away_name) . ' batted first';
        $s_home_runs = is_null($o_match->Result()->GetHomeRuns()) ? '(not known)' : $o_match->Result()->GetHomeRuns();
        $s_home_wickets = is_null($o_match->Result()->GetHomeWickets()) ? '(not known)' : $o_match->Result()->GetHomeWickets();
        if ($s_home_wickets == -1) {
            $s_home_wickets = 'all out';
        } else {
            $s_home_wickets = 'for ' . $s_home_wickets . ' wickets';
        }
        $s_away_runs = is_null($o_match->Result()->GetAwayRuns()) ? '(not known)' : $o_match->Result()->GetAwayRuns();
        $s_away_wickets = is_null($o_match->Result()->GetAwayWickets()) ? '(not known)' : $o_match->Result()->GetAwayWickets();
        if ($s_away_wickets == -1) {
            $s_away_wickets = 'all out';
        } else {
            $s_away_wickets = 'for ' . $s_away_wickets . ' wickets';
        }
        $s_user = $o_user->GetName();
        $s_body = wordwrap("A {$new}{$match_text} has been {$verb} on the Stoolball England website at {$s_domain}{$s_season}.\n\n" . "The {$match_text} was {$verb} by {$s_user}.\n\n" . "The {$match_text} details are as follows:\n\n" . "    {$s_title}\n" . "    {$s_date}\n" . "    {$s_ground}");
        if ($s_notes) {
            $s_notes = "\n\n" . wordwrap($s_notes, 70);
            $s_notes = str_replace("\n", "\n    ", $s_notes);
            $s_body .= $s_notes;
        }
        if ($o_match->GetStartTime() <= gmdate('U') and !$b_is_new_match and $o_match->GetMatchType() != MatchType::TOURNAMENT) {
            $s_body .= <<<EMAILBODY


\t{$s_bat_first}
EMAILBODY;
            if ($o_match->Result()->GetHomeBattedFirst() === false) {
                $s_body .= <<<EMAILBODY

\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
EMAILBODY;
            } else {
                $s_body .= <<<EMAILBODY

\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
EMAILBODY;
            }
        }
        $s_body .= "\n\n";
        if (!$b_is_deleted_match) {
            $s_body .= wordwrap("You can view the {$match_text} at {$s_url}\n\n");
        }
        $s_body .= wordwrap("You have received this email because you are the administrative contact for {$s_why} on {$s_domain}.\n\n" . "We let you know when a {$match_text} is {$verb} by a member of the public, so that you can check there's nothing wrong.\n\n" . "If this email has been sent to the wrong address, or if the {$match_text} details are wrong, please let us know using the contact form at {$s_contact_url}.\n\n");
        # send email, copy to me
        require_once 'Zend/Mail.php';
        $o_email = new Zend_Mail('UTF-8');
        $o_email->addTo($s_email);
        $o_email->setFrom('alerts@stoolball.org.uk', 'Stoolball England alerts');
        $o_email->setSubject(ucfirst($match_text) . " {$verb}: {$s_title}, {$s_date}");
        $o_email->setBodyText($s_body);
        try {
            $o_email->send();
        } catch (Zend_Mail_Transport_Exception $e) {
            # Do nothing - failure to send this email should not be a fatal error
        }
    }
 /**
  * @return int or false
  * @param User $user
  * @desc Save the supplied object to the database, and return the id
  */
 public function SaveUser($user)
 {
     # check parameters
     if (!$user instanceof User) {
         throw new Exception('Unable to save person');
     }
     # build query
     $table = $this->GetSettings()->GetTable('User');
     $this->Lock($table);
     $s_sql = "UPDATE {$table} SET " . "known_as = " . Sql::ProtectString($this->GetDataConnection(), $user->GetName()) . ", " . "name_first = " . Sql::ProtectString($this->GetDataConnection(), $user->GetFirstName()) . ", " . "name_last = " . Sql::ProtectString($this->GetDataConnection(), $user->GetLastName()) . ", " . "name_sort = " . Sql::ProtectString($this->GetDataConnection(), $user->GetSortName()) . ", " . "email = " . Sql::ProtectString($this->GetDataConnection(), $user->GetEmail()) . ", " . 'date_changed = ' . gmdate('U') . ' ' . 'WHERE user_id = ' . Sql::ProtectNumeric($user->GetId());
     $result = $this->GetDataConnection()->query($s_sql);
     $this->Unlock();
     $success = !$this->GetDataConnection()->isError();
     return $success ? $user->GetId() : false;
 }
Example #14
0
    $user['nfixedwarnings'] += $row['nfixedwarnings'];
    $user['nfailederrors'] += $row['nfailederrors'];
    $user['nfixederrors'] += $row['nfixederrors'];
    $user['nfailedtests'] += $row['nfailedtests'];
    $user['nfixedtests'] += $row['nfixedtests'];
    $user['totalbuilds'] += $row['totalbuilds'];
    $user['totalupdatedfiles'] += $row['totalupdatedfiles'];
    $users[$row['userid']] = $user;
}
// Generate the response used to render the main table of this page.
$users_response = array();
foreach ($users as $key => $user) {
    $user_response = array();
    $user_obj = new User();
    $user_obj->Id = $key;
    $user_obj->Fill();
    $user_response['name'] = $user_obj->GetName();
    $user_response['id'] = $key;
    $user_response['failed_errors'] = $user['nfailederrors'];
    $user_response['fixed_errors'] = $user['nfixederrors'];
    $user_response['failed_warnings'] = $user['nfailedwarnings'];
    $user_response['fixed_warnings'] = $user['nfixedwarnings'];
    $user_response['failed_tests'] = $user['nfailedtests'];
    $user_response['fixed_tests'] = $user['nfixedtests'];
    $user_response['totalupdatedfiles'] = $user['totalupdatedfiles'];
    $users_response[] = $user_response;
}
$response['users'] = $users_response;
$end = microtime_float();
$response['generationtime'] = round($end - $start, 3);
echo json_encode(cast_data_for_JSON($response));