Ejemplo n.º 1
0
 public function __construct($siteID, $parameters)
 {
     /* Pager configuration. */
     $this->_tableWidth = 915;
     $this->_defaultAlphabeticalSortBy = 'lastName';
     $this->ajaxMode = false;
     $this->showExportCheckboxes = true;
     //BOXES WILL NOT APPEAR UNLESS SQL ROW exportID IS RETURNED!
     $this->showActionArea = true;
     $this->showChooseColumnsBox = true;
     $this->allowResizing = true;
     $this->dateCriterion = '';
     if (isset($parameters['period']) && !empty($parameters['period'])) {
         $this->dateCriterion .= ' AND activity.date_created >= ' . $parameters['period'] . ' ';
     } else {
         if (isset($parameters['startDate']) && !empty($parameters['startDate'])) {
             $this->dateCriterion .= ' AND activity.date_created >= \'' . $parameters['startDate'] . '\' ';
         }
         if (isset($parameters['endDate']) && !empty($parameters['endDate'])) {
             $this->dateCriterion .= ' AND activity.date_created <= \'' . $parameters['endDate'] . '\' ';
         }
     }
     $this->defaultSortBy = 'dateCreatedSort';
     $this->defaultSortDirection = 'DESC';
     $this->_defaultColumns = array(array('name' => 'Date', 'width' => 110), array('name' => 'First Name', 'width' => 85), array('name' => 'Last Name', 'width' => 75), array('name' => 'Regarding', 'width' => 125), array('name' => 'Activity', 'width' => 65), array('name' => 'Notes', 'width' => 240), array('name' => 'Entered By', 'width' => 60));
     $this->_db = DatabaseConnection::getInstance();
     $this->_siteID = $siteID;
     $this->_assignedCriterion = "";
     $this->_dataItemIDColumn = 'company.company_id';
     $this->_classColumns = array('Date' => array('pagerRender' => 'return $rsData[\'dateCreated\'];', 'sortableColumn' => 'dateCreatedSort', 'pagerWidth' => 110, 'pagerOptional' => true, 'alphaNavigation' => true, 'filterHaving' => 'dateCreated'), 'First Name' => array('pagerRender' => 'if ($rsData[\'dataItemType\']==' . DATA_ITEM_CANDIDATE . ') {$ret = \'<img src="images/mru/candidate.gif" height="12" alt="" />\';} else if ($rsData[\'dataItemType\']==' . DATA_ITEM_CONTACT . ') {$ret = \'<img src="images/mru/contact.gif" height="12">\';} else {$ret = \'<img src="images/mru/blank.gif">\';} if ($rsData[\'isHot\'] == 1) $className =  \'jobLinkHot\'; else $className = \'jobLinkCold\'; if ($rsData[\'dataItemType\']==' . DATA_ITEM_CANDIDATE . ') {return $ret.\'&nbsp;<a href="' . CATSUtility::getIndexName() . '?m=candidates&amp;a=show&amp;candidateID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.htmlspecialchars($rsData[\'firstName\']).\'</a>\';} else {return  $ret.\'&nbsp;<a href="' . CATSUtility::getIndexName() . '?m=contacts&amp;a=show&amp;contactID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.htmlspecialchars($rsData[\'firstName\']).\'</a>\';}', 'sortableColumn' => 'firstName', 'pagerWidth' => 85, 'pagerOptional' => false, 'alphaNavigation' => true, 'filterHaving' => 'firstName'), 'Last Name' => array('pagerRender' => 'if ($rsData[\'isHot\'] == 1) $className =  \'jobLinkHot\'; else $className = \'jobLinkCold\'; if ($rsData[\'dataItemType\']==' . DATA_ITEM_CANDIDATE . ') {return \'<a href="' . CATSUtility::getIndexName() . '?m=candidates&amp;a=show&amp;candidateID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'"> \'.htmlspecialchars($rsData[\'lastName\']).\'</a>\';} else {return \'<a href="' . CATSUtility::getIndexName() . '?m=contacts&amp;a=show&amp;contactID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'"> \'.htmlspecialchars($rsData[\'lastName\']).\'</a>\';}', 'sortableColumn' => 'lastName', 'pagerWidth' => 75, 'pagerOptional' => false, 'alphaNavigation' => true, 'filterHaving' => 'lastName'), 'Regarding' => array('pagerRender' => 'if ($rsData[\'jobIsHot\'] == 1) $className =  \'jobLinkHot\'; else $className = \'jobLinkCold\'; if ($rsData[\'companyIsHot\'] == 1) $companyClassName =  \'jobLinkHot\'; else $companyClassName = \'jobLinkCold\';  if ($rsData[\'regardingJobTitle\'] == \'\') {$ret = \'General\'; } else {$ret = \'<a href="' . CATSUtility::getIndexName() . '?m=joborders&amp;a=show&amp;jobOrderID=\'.$rsData[\'jobOrderID\'].\'" class="\'.$className.\'">\'.htmlspecialchars($rsData[\'regardingJobTitle\']).\'</a>\'; if($rsData[\'regardingCompanyName\'] != \'\') {$ret .= \' <a href="' . CATSUtility::getIndexName() . '?m=companies&amp;a=show&amp;companyID=\'.$rsData[\'companyID\'].\'" class="\'.$companyClassName.\'">(\'.htmlspecialchars($rsData[\'regardingCompanyName\']).\')\';}} return $ret;', 'sortableColumn' => 'regarding', 'pagerWidth' => 125, 'pagerOptional' => true, 'alphaNavigation' => true, 'filterHaving' => 'regarding'), 'Activity' => array('pagerRender' => '$ret = $rsData[\'typeDescription\']; return $ret;', 'sortableColumn' => 'typeDescription', 'pagerWidth' => 65, 'pagerOptional' => true, 'alphaNavigation' => true, 'filter' => 'activity_type.short_description'), 'Notes' => array('pagerRender' => 'return $rsData[\'notes\'];', 'sortableColumn' => 'notes', 'pagerWidth' => 240, 'pagerOptional' => true, 'alphaNavigation' => true, 'filterHaving' => 'notes'), 'Entered By' => array('pagerRender' => 'return StringUtility::makeInitialName($rsData[\'enteredByFirstName\'], $rsData[\'enteredByLastName\'], false, LAST_NAME_MAXLEN);', 'exportRender' => 'return $rsData[\'enteredByFirstName\'] . " " .$rsData[\'enteredByLastName\'];', 'sortableColumn' => 'enteredBySort', 'pagerWidth' => 60, 'alphaNavigation' => true, 'filter' => 'CONCAT(entered_by_user.last_name, entered_by_user.first_name)'));
     parent::__construct("activity:ActivityDataGrid", $parameters);
 }
Ejemplo n.º 2
0
 public function __construct($siteID, $profileLib, $profilePage)
 {
     $this->_siteID = $siteID;
     $this->_profileLib = $profileLib;
     $this->_profilePage = $profilePage;
     $this->_db = DatabaseConnection::getInstance();
 }
Ejemplo n.º 3
0
function fCallBack($fileInfo)
{
    $objDatabase = DatabaseConnection::getInstance();
    $ext=$fileInfo->getExtension();
    if($ext!="ini") return;
    $realPath=$fileInfo->getRealPath();
    $table=$fileInfo->getBasename(".ini");
    if(!$objDatabase->isTableExist($table))
    {
        $objDatabase->createTable($table);
    }
    $arrIniField=parse_ini_file($realPath, true);
    foreach($arrIniField as $field=>$arrData)
    {
        if(!$objDatabase->isFieldExist($table,$field))
        {
            $type=isset($arrData["type"])?$arrData["type"]:"VARCHAR";
            if(strtolower($type)=="varchar")
            {
                $size=isset($arrData["size"])?$arrData["size"]:255;
            }
            else
            {
                $size=isset($arrData["size"])?$arrData["size"]:11;
            }
            $objDatabase->addField($table,$field,$type,$size);
        }
    }
}
Ejemplo n.º 4
0
 public function __construct($siteID = null)
 {
     if (!is_null($siteID)) {
         $this->_siteID = $siteID;
     }
     $this->_db = DatabaseConnection::getInstance();
 }
Ejemplo n.º 5
0
 public function __construct($siteID)
 {
     $this->_siteID = $siteID;
     // FIXME: Remove dependency on Session here.
     $this->_userID = $_SESSION['CATS']->getUserID();
     $this->_db = DatabaseConnection::getInstance();
 }
Ejemplo n.º 6
0
 public function run($siteID, $args)
 {
     Task::setName('CleanExceptions');
     Task::setDescription('Clean up the exceptions log.');
     $db = DatabaseConnection::getInstance();
     $sql = sprintf("DELETE FROM\n                exceptions\n             WHERE\n                DATEDIFF(NOW(), exceptions.date) > %s", EXCEPTIONS_TTL_DAYS);
     if (!($rs = $db->query($sql))) {
         $message = 'Query "' . $sql . '" failed!';
         $ret = TASKRET_ERROR;
     } else {
         $num = $db->getAffectedRows();
         if ($num > 0) {
             $message = 'Cleaned up ' . number_format($num, 0) . ' exception logs.';
             $ret = TASKRET_SUCCESS;
         } else {
             // Do not log if nothing was done
             $message = 'No logs were cleaned.';
             $ret = TASKRET_SUCCESS_NOLOG;
         }
     }
     // Set the response the task wants logged
     $this->setResponse($message);
     // Return one of the above TASKRET_ constants.
     return $ret;
 }
Ejemplo n.º 7
0
 public function __construct($siteID)
 {
     $this->_siteID = $siteID;
     $this->_db = DatabaseConnection::getInstance();
     // FIXME: Session coupling...
     $this->_timeZoneOffset = $_SESSION['CATS']->getTimeZoneOffset();
 }
Ejemplo n.º 8
0
 function AUIEO_SEND_HOOK_EMAIL($record)
 {
     $recruiter = $record["recruiter"];
     $sql = "select * from user where user_id='{$recruiter}'";
     $db = DatabaseConnection::getInstance();
     $arrAssoc = $db->getAllAssoc($sql);
     $emailAddress = $arrAssoc[0]["email"];
     $site_id = $arrAssoc[0]["site_id"];
     if ($emailAddress) {
         $obj = new JobOrders($site_id);
         $obj->load($record["id"]);
         $obj->sendTemplateEMail("My Joborder 2", $emailAddress);
     }
     $owner = $record["owner"];
     $sql = "select * from user where user_id='{$owner}'";
     $db = DatabaseConnection::getInstance();
     $arrAssoc = $db->getAllAssoc($sql);
     $emailAddress = $arrAssoc[0]["email"];
     $site_id = $arrAssoc[0]["site_id"];
     if ($emailAddress) {
         $obj = new JobOrders($site_id);
         $obj->load($record["id"]);
         $obj->sendTemplateEMail("My Joborder 2", $emailAddress);
     }
 }
Ejemplo n.º 9
0
function read_events($user_id)
{
    DatabaseConnection::getInstance();
    $statement = DatabaseConnection::$pdo->prepare("UPDATE events SET unread = 0 WHERE send_to = :to");
    $statement->bindValue(':to', $user_id);
    $statement->execute();
}
Ejemplo n.º 10
0
 public function __construct($siteID, $profileID = false)
 {
     $this->_siteID = $siteID;
     $this->_db = DatabaseConnection::getInstance();
     $this->_savedProfileID = $profileID;
     $this->_savedProfile = false;
     $this->_titleCache = false;
 }
Ejemplo n.º 11
0
function update_profile($char_id, $new_profile)
{
    DatabaseConnection::getInstance();
    $statement = DatabaseConnection::$pdo->prepare('UPDATE players SET messages = :profile WHERE player_id = :char_id');
    $statement->bindValue(':profile', $new_profile);
    $statement->bindValue(':char_id', $char_id);
    $statement->execute();
    return true;
}
Ejemplo n.º 12
0
/**
 * Attack function library.
 * @package combat
 * @subpackage lib_attack
**/
function update_last_attack_time($player_id)
{
    DatabaseConnection::getInstance();
    $update_last_attacked = "UPDATE players SET last_started_attack = now() WHERE player_id = :user";
    $statement = DatabaseConnection::$pdo->prepare($update_last_attacked);
    $statement->bindValue(':user', intval($player_id));
    $statement->execute();
    // updates the timestamp of the last_attacked column to slow excessive attacks.
}
Ejemplo n.º 13
0
function check_for_resurrection($echo = FALSE)
{
    DatabaseConnection::getInstance();
    $query = DatabaseConnection::$pdo->query("UPDATE players\n                    SET status = 0,\n                    health = (CASE WHEN _class_id = 4 THEN (150+(level*3)) ELSE 100 END)\n                    WHERE active = 1\n                    AND health < 0\n                    AND resurrection_time = (SELECT amount from time where time_label='hours')\n                    AND\n                    ( days < 31 OR\n        \t\t\t\t(\n        \t\t\t\t\t((days % cast(floor(days / 10) AS integer)) = 0)\n        \t\t\t\t)\n        \t\t\t)\n                  ");
    // *** Resurrect and heal all players at this countdown spot.
    if ($echo) {
        $healedPlayers = $query->rowCount();
        echo "Number of healed/resurrected players: " . $healedPlayers;
    }
}
Ejemplo n.º 14
0
 /**
  * Returns an HTTP log type ID from a specified type name.
  *
  * @param string HTTP log type name.
  * @return integer HTTP log type ID or -1 if not found.
  */
 public static function getHTTPLogTypeIDByName($logTypeName)
 {
     $db = DatabaseConnection::getInstance();
     $sql = sprintf("SELECT\n                log_type_id\n            FROM\n                http_log_types\n            WHERE\n            (\n                name = %s\n                OR default_log_type = 1\n            )\n            ORDER BY\n                default_log_type DESC", $db->makeQueryString($logTypeName));
     $result = $db->getColumn($sql, 0, 0);
     if ($result === false) {
         return -1;
     }
     return $result;
 }
Ejemplo n.º 15
0
 public function __construct($profileid)
 {
     $this->id = $profileid;
     $objDB = DatabaseConnection::getInstance();
     $site_id = $_SESSION["CATS"]->getSiteID();
     $sql = "select * from auieo_profiles where id={$profileid} and site_id=" . $_SESSION["CATS"]->getSiteID();
     $record = $objDB->getAssoc($sql);
     $this->name = $record["profilename"];
     $this->objPermission = new PRGPermissions($profileid);
 }
Ejemplo n.º 16
0
 private function processChildren($roleid)
 {
     $db = DatabaseConnection::getInstance();
     $site_id = $_SESSION["CATS"]->getSiteID();
     $query = "SELECT id,parentid FROM auieo_roles where parentid={$roleid} and site_id={$site_id}";
     $records = $db->getAllAssoc($query);
     foreach ($records as $record) {
         $this->arrChildRole[$record["id"]] = "";
         $this->processChildren($record["id"]);
     }
 }
Ejemplo n.º 17
0
 public function __construct($profileid)
 {
     $objDB = DatabaseConnection::getInstance();
     $site_id = $_SESSION["CATS"]->getSiteID();
     $sql = "select * from auieo_profiles2permissions where profileid={$profileid} and site_id=" . $site_id;
     $arrAssoc = $objDB->getAllAssoc($sql);
     //trace($arrAssoc);
     foreach ($arrAssoc as $record) {
         $this->arrPermission[$record["data_item_type"]][$record["operation"]] = $record["permissions"];
     }
 }
Ejemplo n.º 18
0
 public static function getLastMovs($cantidad)
 {
     $consulta = "SELECT * FROM " . self::TABLE_NAME . " ORDER BY idmov DESC LIMIT " . $cantidad;
     try {
         $comando = DatabaseConnection::getInstance()->getDb()->prepare($consulta);
         $comando->execute();
         return $comando->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         return false;
     }
 }
Ejemplo n.º 19
0
 public function __construct($siteID = 1, $dataOverwrite = true)
 {
     $siteID = $_SESSION['CATS']->getSiteID();
     $this->_db = DatabaseConnection::getInstance();
     $this->_structure = array();
     $this->_keys = array();
     $this->_siteID = $siteID;
     $this->_GUID = 0;
     $this->_GUIDs = array();
     $this->_GUIDRestores = array();
     $this->_dataOverwrite = $dataOverwrite;
 }
Ejemplo n.º 20
0
 public function __construct()
 {
     $this->m_dbconn = DatabaseConnection::getInstance();
     $this->_vo_obj_name = 'SkillVO';
     $this->_vo_fields = array();
     $vo = new ReflectionClass(new SkillVO());
     $vo = $vo->getProperties();
     foreach ($vo as $reflectionProperty) {
         $this->_vo_fields[] = $reflectionProperty->name;
     }
     $this->_id_field = 'skill_id';
     $this->_table = 'skill';
 }
Ejemplo n.º 21
0
/**
 * This determines how the clans get ranked and tagged, and how to only show non-empty clans.
**/
function player_size()
{
    $res = array();
    DatabaseConnection::getInstance();
    $sel = "SELECT (level-3-round(days/5)) AS sum, player_id, uname FROM players WHERE active = 1 AND health > 0 ORDER BY sum DESC";
    $statement = DatabaseConnection::$pdo->query($sel);
    $player_info = $statement->fetch();
    $max = $player_info['sum'];
    do {
        // make percentage of highest, multiply by 10 and round to give a 1-10 size
        $res[$player_info['uname']] = array('player_id' => $player_info['player_id'], 'size' => floor(($player_info['sum'] - 1 < 1 ? 0 : $player_info['sum'] - 1) / $max * 10) + 1);
    } while ($player_info = $statement->fetch());
    return $res;
}
Ejemplo n.º 22
0
 public function __construct()
 {
     $this->m_dbconn = DatabaseConnection::getInstance();
     $this->_vo_obj_name = 'PlayerVO';
     $this->_vo_fields = array();
     $vo = new PlayerVO();
     $vo = new ReflectionClass(new PlayerVO());
     foreach ($vo->getProperties() as $reflectionProperty) {
         $this->_vo_fields[] = $reflectionProperty->name;
     }
     $this->_id_field = 'player_id';
     $this->_table = 'players JOIN class ON class_id = _class_id';
     $this->_table_for_saving = 'players';
 }
Ejemplo n.º 23
0
 public function __construct($rowsPerPage, $currentPage, $siteID, $successful = true)
 {
     $this->_db = DatabaseConnection::getInstance();
     $this->_siteID = $siteID;
     $this->_successful = $successful;
     $this->_sortByFields = array('firstName', 'lastName', 'ip', 'shortUserAgent', 'dateSort');
     /* How many entries do we have? */
     $sql = sprintf("SELECT\n                COUNT(*) AS count\n            FROM\n                user_login\n            LEFT JOIN user\n                ON user_login.user_id = user.user_id\n            WHERE\n                user_login.successful = %s\n            AND\n                user.is_test_user = 0\n            AND\n                user_login.site_id = %s", $this->_successful ? '1' : '0', $siteID);
     $rs = $this->_db->getAssoc($sql);
     /* Pass "Login Activity By Most Recent"-specific parameters to Pager
      * constructor.
      */
     parent::__construct($rs['count'], $rowsPerPage, $currentPage);
 }
Ejemplo n.º 24
0
 public function __construct()
 {
     parent::__construct("joborder",6);
     $this->_db = DatabaseConnection::getInstance();
     
     $this->_userID = $_SESSION['CATS']->getUserID();
     $this->objSQL = new ClsAuieoSQL();
     $objFrom=$this->objSQL->addFrom("joborder");
     $joinContactCompanyID=$objFrom->addJoinField("company_id");
     
     $objFromCompany=$this->objSQL->addFrom("company");
     $companyJoinID=$objFromCompany->addJoinField("company_id");
     $objFromCompany->setJoinWith($objFrom,$joinContactCompanyID,$companyJoinID);
     
     $joinID=$objFrom->addJoinField("owner");
     $objFromUser=$this->objSQL->addFrom("user","owner_user");
     $userJoinID=$objFromUser->addJoinField("user_id");
     $objFromUser->setJoinWith($objFrom,$joinID,$userJoinID);
     
     $joinID=$objFrom->addJoinField("recruiter");
     $objFromUserR=$this->objSQL->addFrom("user","recruiter_user");
     $userJoinID=$objFromUserR->addJoinField("user_id");
     $objFromUserR->setJoinWith($objFrom,$joinID,$userJoinID);
     
     $this->objSQL->addSelect($objFrom, "joborder_id","jobOrderID");
     $this->objSQL->addSelect($objFrom, "company_id","companyID");
     $this->objSQL->addSelect($objFrom, "title","title");
     $this->objSQL->addSelect($objFrom, "type","type");
     $this->objSQL->addSelect($objFrom, "is_hot","isHot");
     $this->objSQL->addSelect($objFrom, "duration","duration");
     $this->objSQL->addSelect($objFrom, "rate_max","maxRate");
     $this->objSQL->addSelect($objFrom, "salary","salary");
     $this->objSQL->addSelect($objFrom, "status","status");
     
     $this->objSQL->addSelect($objFromCompany, "name","companyName");
     
     $this->objSQL->addSelect($objFromUserR, "first_name","recruiterFirstName");
     $this->objSQL->addSelect($objFromUserR, "last_name","recruiterLastName");
     
     $this->objSQL->addSelect($objFromUser, "first_name","ownerFirstName");
     $this->objSQL->addSelect($objFromUser, "last_name","ownerLastName");
     
     $this->objSQL->addSelectCustom("DATE_FORMAT(
                 joborder.date_created, '%%m-%%d-%%y'
             )","dateCreated");
     $this->objSQL->addSelectCustom("DATE_FORMAT(
                 joborder.date_modified, '%%m-%%d-%%y'
             )","dateModified");
     $objWhereCandidate=$this->objSQL->addWhere($objFrom, "site_id", $this->_siteID);
 }
Ejemplo n.º 25
0
 /**
  * Finds City and State names via United States Zip code. The Zip code
  * should be specified as an integer with no leading 0s.
  *
  * @param integer United States Zip code
  * @return array city / state data (empty strings if not found)
  */
 public function getCityStateByZip($zip)
 {
     /* Make sure we have an integer. */
     $zip = (int) $zip;
     if ($zip === 0) {
         return array('city' => '', 'state' => '');
     }
     $db = DatabaseConnection::getInstance();
     $sql = sprintf("SELECT\n                city AS city,\n                state AS state\n            FROM\n                zipcodes\n            WHERE\n                zipcode = %s", $zip);
     $data = $db->getAssoc($sql);
     if (empty($data)) {
         return array('city' => '', 'state' => '');
     }
     return $data;
 }
Ejemplo n.º 26
0
 private function __construct()
 {
     $this->connection = DatabaseConnection::getInstance();
     $this->session = SessionController::getInstance();
     $this->session->start();
     $this->appSettings = new ApplicationSettings(APPLICATION_SETTINGS_FILE, ENVIRONMENT);
     $username = '';
     $this->messages = array(ERROR_MESSAGES => array(), WARNING_MESSAGES => array(), INFORMATIONAL_MESSAGES => array());
     if (isset($_SESSION['username'])) {
         $username = $_SESSION['username'];
     }
     $this->user = new User($username, '');
     if ($this->session->isSessionAuthenticated()) {
         $this->user->restoreUserFromUsername($this->connection);
     }
 }
Ejemplo n.º 27
0
function test_player_obj()
{
    // in: player_id, out: valid db save
    DatabaseConnection::getInstance();
    $player_id_sel = DatabaseConnection::$pdo->query("SELECT player_id FROM players WHERE uname = 'glassbox'");
    $player_id = $player_id_sel->fetchColumn();
    $player = new Player($player_id);
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player uname, out: valid db save
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player status check, out: no errors
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player, out: vo of player data
    $player = new Player('glassbox');
    $vo = $player->as_vo();
    assert($vo instanceof PlayerVO);
    // in: player, out: array of player data
    $player = new Player('glassbox');
    $arr = $player->as_array();
    assert(count($arr) > 0);
    var_dump($arr);
}
Ejemplo n.º 28
0
function get_recent_attackers($self = null)
{
    // If a self Player object is passed in, exclude them from the "recent attackers" list
    $id = $self instanceof Player ? $self->id() : null;
    $exclude_id = '';
    if ($id > 0) {
        $exclude_id = ' AND player_id != :id ';
    }
    DatabaseConnection::getInstance();
    $statement = DatabaseConnection::$pdo->prepare('SELECT DISTINCT player_id, send_from, uname, level, health 
		FROM events JOIN players ON send_from = player_id WHERE send_to = :user AND active = 1 ' . $exclude_id . ' LIMIT 20');
    $statement->bindValue(':user', self_char_id());
    if ($id > 0) {
        $statement->bindValue(':id', $id, PDO::PARAM_INT);
    }
    $statement->execute();
    return $statement;
}
Ejemplo n.º 29
0
    /**
     * Returns specific information about a template, which is a website
     * that receives XML feeds for job submissions.
     *
     * @param string Name of the template which corresponds to xml_template_name
     *               in the xml_feeds table.
     * @return unknown
     */
    public static function getTemplate($templateName)
    {
        $db = DatabaseConnection::getInstance();

        $sql = sprintf(
            "SELECT
                xml_feed_id,
                name,
                description,
                website,
                post_url,
                success_string,
                xml_template_name
             FROM xml_feeds
             WHERE xml_template_name = %s",
            $db->makeQueryString($templateName)
        );

        return $db->getAssoc($sql);
    }
Ejemplo n.º 30
0
function send_chat($user_id, $msg)
{
    DatabaseConnection::getInstance();
    $msg = trim($msg);
    if ($msg) {
        $statement = DatabaseConnection::$pdo->prepare("SELECT message FROM chat WHERE sender_id = :sender ORDER BY date DESC LIMIT 1");
        $statement->bindValue(':sender', $user_id);
        $statement->execute();
        $prevMsg = trim($statement->fetchColumn());
        if ($prevMsg != $msg) {
            $statement = DatabaseConnection::$pdo->prepare("INSERT INTO chat (chat_id, sender_id, message, date) VALUES (default, :sender, :message, now())");
            $statement->bindValue(':sender', $user_id);
            $statement->bindValue(':message', $msg);
            $statement->execute();
            return true;
        }
    }
    return false;
    // could add channels later.
}