diff --git a/.hgignore b/.hgignore index 2c278c240..b368cc91d 100644 --- a/.hgignore +++ b/.hgignore @@ -248,3 +248,5 @@ code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg code/nel/tools/build_gamedata/processes/sheets/sheets_packer.cfg code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg +code/web/public_php/config.php +code/web/public_php/is_installed diff --git a/README.md b/README.md new file mode 100644 index 000000000..19e5bef3a --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code. + + + +Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. \ No newline at end of file diff --git a/code/web/docs/ams/doxygen/Doxyfile b/code/web/docs/ams/doxygen/Doxyfile index fc764ef01..61d3b042f 100644 --- a/code/web/docs/ams/doxygen/Doxyfile +++ b/code/web/docs/ams/doxygen/Doxyfile @@ -1353,7 +1353,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -DISABLE_INDEX = NO +DISABLE_INDEX = YES # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag @@ -1370,7 +1370,7 @@ DISABLE_INDEX = NO # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. diff --git a/code/web/private_php/ams/autoload/assigned.php b/code/web/private_php/ams/autoload/assigned.php index d9d730c8e..9c0c2da55 100644 --- a/code/web/private_php/ams/autoload/assigned.php +++ b/code/web/private_php/ams/autoload/assigned.php @@ -6,12 +6,12 @@ */ class Assigned{ - private $user; /**< The id of the user being assigned */ - private $ticket; /**< The id of the ticket being assigned */ - - + private $user; /**< The id of the user being assigned */ + private $ticket; /**< The id of the ticket being assigned */ + + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - + /** * Assigns a ticket to a user or returns an error message. * It will first check if the ticket isn't already assigned, if not, it will create a new 'assigned' entry. @@ -30,10 +30,10 @@ class Assigned{ }else{ return "ALREADY_ASSIGNED"; } - + } - - + + /** * Unassign a ticket being coupled to a user or return an error message. * It will first check if the ticket is assigned, if this is indeed the case it will delete the 'assigned' entry. @@ -52,9 +52,9 @@ class Assigned{ }else{ return "NOT_ASSIGNED"; } - + } - + /** * Get the (external) id of the user assigned to a ticket * @param $ticket_id the Id of the ticket that's being queried @@ -65,11 +65,11 @@ class Assigned{ $statement = $dbl->execute("SELECT ticket_user.ExternId FROM `assigned` JOIN `ticket_user` ON assigned.User = ticket_user.TUserId WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id)); $user_id = $statement->fetch(); return $user_id['ExternId']; - - - + + + } - + /** * Check if a ticket is already assigned (in case the user_id param is used, it will check if it's assigned to that user) * @param $ticket_id the Id of the ticket that's being queried @@ -79,26 +79,26 @@ class Assigned{ public static function isAssigned( $ticket_id, $user_id = 0) { $dbl = new DBLayer("lib"); //check if ticket is already assigned - + if($user_id == 0 && $dbl->select("`assigned`", array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id")->rowCount() ){ return true; }else if( $dbl->select("`assigned`", array('ticket_id' => $ticket_id, 'user_id' => $user_id), "`Ticket` = :ticket_id and `User` = :user_id")->rowCount() ){ return true; }else{ return false; - } + } } - + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - + /** * A constructor. * Empty constructor */ public function __construct() { } - - + + /** * sets the object's attributes. * @param $values should be an array of the form array('User' => user_id, 'Ticket' => ticket_id). @@ -107,25 +107,25 @@ class Assigned{ $this->setUser($values['User']); $this->setTicket($values['Ticket']); } - - + + /** * creates a new 'assigned' entry. * this method will use the object's attributes for creating a new 'assigned' entry in the database. */ public function create() { $dbl = new DBLayer("lib"); - $dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket()); + $dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket())); } - - + + /** * deletes an existing 'assigned' entry. * this method will use the object's attributes for deleting an existing 'assigned' entry in the database. */ public function delete() { $dbl = new DBLayer("lib"); - $dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket(), "`User` = :user_id and `Ticket` = :ticket_id"); + $dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket()), "`User` = :user_id and `Ticket` = :ticket_id"); } /** @@ -139,25 +139,25 @@ class Assigned{ $row = $statement->fetch(); $this->set($row); } - + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get user attribute of the object. */ public function getUser(){ return $this->user; } - - + + /** * get ticket attribute of the object. */ public function getTicket(){ return $this->ticket; } - + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// /** @@ -167,7 +167,7 @@ class Assigned{ public function setUser($u){ $this->user = $u; } - + /** * set ticket attribute of the object. * @param $t integer id of the ticket @@ -175,6 +175,6 @@ class Assigned{ public function setTicket($t){ $this->ticket = $t; } - - + + } diff --git a/code/web/private_php/ams/autoload/dblayer.php b/code/web/private_php/ams/autoload/dblayer.php index 7c4c5435c..1f361008b 100644 --- a/code/web/private_php/ams/autoload/dblayer.php +++ b/code/web/private_php/ams/autoload/dblayer.php @@ -1,274 +1,258 @@ First create an object of dblayer --> $db = new DBLayer('short database name used in config') - * - * --> Insert --> $db->insert( $tb_name, $data ) - * $tb_name = table name in which we want to insert data - * $data = array of data that needs to be inserted in format('fieldname' => $value) where fieldname must be a field in that table. - * - * --> select --> $db->select( $tb_name, $data, $where ) - * $tb_name = table name which we want to select - * $data = array of data which is then required in WHERE clause in format array('fieldname'=>$value) fieldname must be a field in that table. - * $where = string in format ('fieldname=:fieldname') where :fieldname takes it's value from $data array. - * - * --> update --> $db->update( $tb_name, $data, $where ) - * $tb_name = table name which we want to update - * $data = array of data which contains the filelds that need to be updated with their values in the format('fieldname' => $value,...) where fieldname must be a field in that table. - * $where = string contains the filename with a value at that field in the format ('fieldname = $value') where fieldname must be a field in that table and $value is value respect to that field. - * - * --> delete --> $db->delete( $tb_name, $data, $where ) - * $tb_name = table name where we want to delete. - * $data = array of data which is then required in WHERE clause in format array('fieldname'=> $value) where fieldname must be a field in that table. - * $where = string in format ('fieldname=:fieldname') where :fieldname takes it's value from $data array. - * - * - * @author Daan Janssens, mentored by Matthew Lagoe - * + * + * --> Insert --> $db->insert( $tb_name, $data ) + * $tb_name = table name in which we want to insert data + * $data = array of data that needs to be inserted in format('fieldname' => $value) where fieldname must be a field in that table. + * + * --> select --> $db->select( $tb_name, $data, $where ) + * $tb_name = table name which we want to select + * $data = array of data which is then required in WHERE clause in format array('fieldname'=>$value) fieldname must be a field in that table. + * $where = string in format ('fieldname=:fieldname') where :fieldname takes it's value from $data array. + * + * --> update --> $db->update( $tb_name, $data, $where ) + * $tb_name = table name which we want to update + * $data = array of data which contains the filelds that need to be updated with their values in the format('fieldname' => $value,...) where fieldname must be a field in that table. + * $where = string contains the filename with a value at that field in the format ('fieldname = $value') where fieldname must be a field in that table and $value is value respect to that field. + * + * --> delete --> $db->delete( $tb_name, $data, $where ) + * $tb_name = table name where we want to delete. + * $data = array of data which is then required in WHERE clause in format array('fieldname'=> $value) where fieldname must be a field in that table. + * $where = string in format ('fieldname=:fieldname') where :fieldname takes it's value from $data array. + * + * + * @author Daan Janssens, mentored by Matthew Lagoe + * */ + +// $PDOCache = array(); + class DBLayer { - - private $PDO; - /** - * The PDO object, instantiated by the constructor - */ - - /** - * The constructor. - * Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var) - * - * @param $db String, the name of the databases entry in the $cfg global var. - * @param $dbn String, the name of the databases entry in the $cfg global var if $db referenced to an action(install etc). - */ - function __construct( $db, $dbn = null ) - { - if ( $db != "install" ) { - - global $cfg; - $dsn = "mysql:"; - $dsn .= "host=" . $cfg['db'][$db]['host'] . ";"; - $dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";"; - $dsn .= "port=" . $cfg['db'][$db]['port'] . ";"; - - $opt = array( - PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION, - PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_ASSOC - ); - $this -> PDO = new PDO( $dsn, $cfg['db'][$db]['user'], $cfg['db'][$db]['pass'], $opt ); - } else { - global $cfg; - $dsn = "mysql:"; - $dsn .= "host=" . $cfg['db'][$dbn]['host'] . ";"; - $dsn .= "port=" . $cfg['db'][$dbn]['port'] . ";"; - - $opt = array( - PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION, - PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_ASSOC - ); - $this -> PDO = new PDO( $dsn, $_POST['Username'], $_POST['Password'], $opt ); - } - - } - - /** - * Execute a query that doesn't have any parameters. - * - * @param $query the mysql query. - * @return returns a PDOStatement object. - */ - public function executeWithoutParams( $query ) { - $statement = $this -> PDO -> prepare( $query ); - $statement -> execute(); - return $statement; - } - - /** - * Execute a query that has parameters. - * - * @param $query the mysql query. - * @param $params the parameters that are being used by the query. - * @return returns a PDOStatement object. - */ - public function execute( $query, $params ) { - $statement = $this -> PDO -> prepare( $query ); - $statement -> execute( $params ); - return $statement; - } - - /** - * Insert function which returns id of the inserting field. - * - * @param $tb_name table name where we want to insert data. - * @param $data the parameters that are being inserted into table. - * @return returns the id of the last inserted element. - */ - public function executeReturnId( $tb_name, $data ) { - $field_values = ':' . implode( ',:', array_keys( $data ) ); - $field_options = implode( ',', array_keys( $data ) ); - try { - $sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" ); - foreach ( $data as $key => $value ) - { - $sth -> bindValue( ":$key", $value ); - } - $this -> PDO -> beginTransaction(); - $sth -> execute(); - $lastId = $this -> PDO -> lastInsertId(); - $this -> PDO -> commit(); - } - catch ( Exception $e ) - { - // for rolling back the changes during transaction - $this -> PDO -> rollBack(); - throw new Exception( "error in inseting" ); - } - return $lastId; - } - - /** - * Select function using prepared statement. - * For selecting particular fields. - * - * @param string $param field to select, can be multiple fields. - * @param string $tb_name Table Name to Select. - * @param array $data array of data to be used in WHERE clause in format('fieldname'=>$value). 'fieldname' must be a field in that table. - * @param string $where where to select. - * @return statement object. - */ - public function selectWithParameter( $param, $tb_name, $data, $where ) - { - try { - $sth = $this -> PDO -> prepare( "SELECT $param FROM $tb_name WHERE $where" ); - $this -> PDO -> beginTransaction(); - $sth -> execute( $data ); - $this -> PDO -> commit(); - } - catch( Exception $e ) - { - $this -> PDO -> rollBack(); - throw new Exception( "error selection" ); - return false; - } - return $sth; - } - - /** - * Select function using prepared statement. - * For selecting all fields in a table. - * - * @param string $tb_name Table Name to Select. - * @param array $data array of data to be used with WHERE part in format('fieldname'=>$value,...). 'fieldname' must be a field in that table. - * @param string $where where to select in format('fieldname=:fieldname' AND ...). - * @return statement object. - */ - public function select( $tb_name, $data , $where ) - { - try { - $sth = $this -> PDO -> prepare( "SELECT * FROM $tb_name WHERE $where" ); - $this -> PDO -> beginTransaction(); - $sth -> execute( $data ); - $this -> PDO -> commit(); - } - catch( Exception $e ) - { - $this -> PDO -> rollBack(); - throw new Exception( "error selection" ); - return false; - } - return $sth; - } - - /** - * Update function with prepared statement. - * - * @param string $tb_name name of the table on which operation to be performed. - * @param array $data array of data in format('fieldname' => $value,...).Here, only those fields must be stored which needs to be updated. - * @param string $where where part in format ('fieldname'= $value AND ...). 'fieldname' must be a field in that table. - * @throws Exception error in updating. - */ - public function update( $tb_name, $data, $where ) - { - $field_option_values = null; - foreach ( $data as $key => $value ) - { - $field_option_values .= ",$key" . '=:' . $key; - } - $field_option_values = ltrim( $field_option_values, ',' ); - try { - $sth = $this -> PDO -> prepare( "UPDATE $tb_name SET $field_option_values WHERE $where " ); - - foreach ( $data as $key => $value ) - { - $sth -> bindValue( ":$key", $value ); - } - $this -> PDO -> beginTransaction(); - $sth -> execute(); - $this -> PDO -> commit(); - } - catch ( Exception $e ) - { - $this -> PDO -> rollBack(); - throw new Exception( 'error in updating' ); - return false; - } - return true; - } - - /** - * insert function using prepared statements. - * - * @param string $tb_name Name of the table on which operation to be performed. - * @param array $data array of data to insert in format('fieldname' => $value,....). 'fieldname' must be a field in that table. - * @throws error in inserting. - */ - public function insert( $tb_name, $data ) - { - $field_values = ':' . implode( ',:', array_keys( $data ) ); - $field_options = implode( ',', array_keys( $data ) ); - try { - $sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" ); - foreach ( $data as $key => $value ) - { - - $sth -> bindValue( ":$key", $value ); - } - $this -> PDO -> beginTransaction(); - // execution - $sth -> execute(); - $this -> PDO -> commit(); - - } - catch ( Exception $e ) - { - // for rolling back the changes during transaction - $this -> PDO -> rollBack(); - throw new Exception( "error in inserting" ); - } - } - - /** - * Delete database entery using prepared statement. - * - * @param string $tb_name table name on which operations to be performed. - * @param $data array with values in the format('fieldname'=> $value,...). 'fieldname' must be a field in that table. - * @param string $where condition based on $data array in the format('fieldname=:fieldname' AND ...). - * @throws error in deleting. - */ - public function delete( $tb_name, $data, $where ) - { - try { - $sth = $this -> PDO -> prepare( "DELETE FROM $tb_name WHERE $where" ); - $this -> PDO -> beginTransaction(); - $sth -> execute( $data ); - $this -> PDO -> commit(); - } - catch ( Exception $e ) - { - $this -> PDO -> rollBack(); - throw new Exception( "error in deleting" ); - } - - } - } + + private $PDO; + // private $host; + // private $dbname; + + /** + * The PDO object, instantiated by the constructor + */ + + /** + * The constructor. + * Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var) + * + * @param $db String, the name of the databases entry in the $cfg global var. + * @param $dbn String, the name of the databases entry in the $cfg global var if $db referenced to an action(install etc). + */ + function __construct($db, $dbn = null) + { + global $cfg; + // $this->host = $cfg['db'][$db]['host']; + // $this->dbname = $cfg['db'][$db]['name']; + /*global $PDOCache; + if (isset($PDOCache[$this->host])) { + $this->PDO = $PDOCache[$this->host]['pdo']; + } else {*/ + $dsn = "mysql:"; + $dsn .= "host=" . $cfg['db'][$db]['host'] . ";"; + $dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";"; // Comment this out when using the cache + $dsn .= "port=" . $cfg['db'][$db]['port'] . ";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_PERSISTENT => true + ); + $this->PDO = new PDO($dsn, $cfg['db'][$db]['user'], $cfg['db'][$db]['pass'], $opt); + /* $PDOCache[$this->host] = array(); + $PDOCache[$this->host]['pdo'] = $this->PDO; + $PDOCache[$this->host]['use'] = $this->dbname; + */ //$this->PDO->query('USE ' . $this->dbname . ';'); // FIXME safety + /*}*/ + } + + function __destruct() { + $this->PDO = NULL; + } + + function useDb() { + /*global $PDOCache; + if ($PDOCache[$this->host]['use'] != $this->dbname) { + $PDOCache[$this->host]['use'] = $this->dbname; + $this->PDO->query('USE ' . $this->dbname . ';'); // FIXME safety + }*/ + } + + /** + * Execute a query that doesn't have any parameters. + * + * @param $query the mysql query. + * @return returns a PDOStatement object. + */ + public function executeWithoutParams($query) { + $this->useDb(); + $statement = $this->PDO->prepare($query); + $statement->execute(); + return $statement; + } + + /** + * Execute a query that has parameters. + * + * @param $query the mysql query. + * @param $params the parameters that are being used by the query. + * @return returns a PDOStatement object. + */ + public function execute( $query, $params ) { + $this->useDb(); + $statement = $this -> PDO -> prepare( $query ); + $statement -> execute( $params ); + return $statement; + } + + /** + * Insert function which returns id of the inserting field. + * + * @param $tb_name table name where we want to insert data. + * @param $data the parameters that are being inserted into table. + * @return returns the id of the last inserted element. + */ + public function executeReturnId($tb_name, $data, $datafunc = array()) { + $this->useDb(); + $field_options = implode(',', array_merge(array_keys($data), array_keys($datafunc))); + $field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc))); + try { + $sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" ); + foreach ($data as $key => $value) { + $sth->bindValue( ":$key", $value ); + } + $sth->execute(); + $lastId = $this->PDO->lastInsertId(); + } + catch (Exception $e) { + throw $e; // new Exception( "error in inseting" ); + } + return $lastId; + } + + /** + * Select function using prepared statement. + * For selecting particular fields. + * + * @param string $param field to select, can be multiple fields. + * @param string $tb_name Table Name to Select. + * @param array $data array of data to be used in WHERE clause in format('fieldname'=>$value). 'fieldname' must be a field in that table. + * @param string $where where to select. + * @return statement object. + */ + public function selectWithParameter( $param, $tb_name, $data, $where ) { + $this->useDb(); + try { + $sth = $this->PDO->prepare("SELECT $param FROM $tb_name WHERE $where"); + $sth->execute($data); + } + catch (Exception $e) { + throw $e; // new Exception( "error selection" ); + return false; + } + return $sth; + } + + /** + * Select function using prepared statement. + * For selecting all fields in a table. + * + * @param string $tb_name Table Name to Select. + * @param array $data array of data to be used with WHERE part in format('fieldname'=>$value,...). 'fieldname' must be a field in that table. + * @param string $where where to select in format('fieldname=:fieldname' AND ...). + * @return statement object. + */ + public function select($tb_name, $data , $where) { + $this->useDb(); + try { + $sth = $this->PDO->prepare("SELECT * FROM $tb_name WHERE $where"); + $sth->execute( $data ); + } + catch (Exception $e) { + throw $e; // new Exception( "error selection" ); + return false; + } + return $sth; + } + + /** + * Update function with prepared statement. + * + * @param string $tb_name name of the table on which operation to be performed. + * @param array $data array of data in format('fieldname' => $value,...).Here, only those fields must be stored which needs to be updated. + * @param string $where where part in format ('fieldname'= $value AND ...). 'fieldname' must be a field in that table. + * @throws Exception error in updating. + */ + public function update($tb_name, $data, $where) { + $this->useDb(); + $field_option_values = null; + foreach ( $data as $key => $value ) { + $field_option_values .= ",$key" . '=:' . $key; + } + $field_option_values = ltrim($field_option_values, ','); + try { + $sth = $this->PDO->prepare("UPDATE $tb_name SET $field_option_values WHERE $where "); + + foreach ($data as $key => $value) { + $sth->bindValue(":$key", $value); + } + $sth->execute(); + } + catch (Exception $e) { + throw $e; // new Exception( 'error in updating' ); + return false; + } + return true; + } + + /** + * insert function using prepared statements. + * + * @param string $tb_name Name of the table on which operation to be performed. + * @param array $data array of data to insert in format('fieldname' => $value,....). 'fieldname' must be a field in that table. + * @throws error in inserting. + */ + public function insert($tb_name, $data, $datafunc = array()) { + $this->useDb(); + $field_options = '`'.implode('`,`', array_merge(array_keys($data), array_keys($datafunc))).'`'; + $field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc))); + try { + $sth = $this->PDO->prepare("INSERT INTO $tb_name ($field_options) VALUE ($field_values)"); + foreach ($data as $key => $value) { + $sth->bindValue(":$key", $value); + } + $sth->execute(); + } + catch (Exception $e) { + throw $e; // new Exception("error in inserting"); + } + } + + /** + * Delete database entery using prepared statement. + * + * @param string $tb_name table name on which operations to be performed. + * @param $data array with values in the format('fieldname'=> $value,...). 'fieldname' must be a field in that table. + * @param string $where condition based on $data array in the format('fieldname=:fieldname' AND ...). + * @throws error in deleting. + */ + public function delete( $tb_name, $data, $where ) { + $this->useDb(); + try { + $sth = $this->PDO->prepare("DELETE FROM $tb_name WHERE $where"); + $sth->execute($data); + } + catch (Exception $e) { + throw $e; // new Exception( "error in deleting" ); + } + } +} diff --git a/code/web/private_php/ams/autoload/forwarded.php b/code/web/private_php/ams/autoload/forwarded.php index ccba764e6..a49dbedcc 100644 --- a/code/web/private_php/ams/autoload/forwarded.php +++ b/code/web/private_php/ams/autoload/forwarded.php @@ -3,16 +3,16 @@ * Handles the forwarding of a ticket to a support_group. This is being used to transfer tickets to different groups (eg Developers, Website-Team, SupportGroup etc..) * The idea is that someone can easily forward a ticket to a group and by doing that, the moderators that are in that group will receive the ticket in their todo queue. * @author Daan Janssens, mentored by Matthew Lagoe -* +* */ class Forwarded{ - - private $group; /**< The id of the group to which the ticket is being forwarded */ - private $ticket; /**< The id of the ticket being forwarded */ - + + private $group; /**< The id of the group to which the ticket is being forwarded */ + private $ticket; /**< The id of the ticket being forwarded */ + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - - + + /** * Forward a ticket to a group, also removes the previous group where it was forwarded to. * It will first check if the ticket is already forwarded, if that's the case, it will delete that entry. @@ -32,10 +32,10 @@ class Forwarded{ $forward->set(array('Group' => $group_id, 'Ticket' => $ticket_id)); $forward->create(); return "SUCCESS_FORWARDED"; - + } - - + + /** * get the id of the group a ticket is forwarded to. * @param $ticket_id the id of the ticket. @@ -46,8 +46,8 @@ class Forwarded{ $forw->load($ticket_id); return $forw->getGroup(); } - - + + /** * check if the ticket is forwarded * @param $ticket_id the id of the ticket. @@ -59,21 +59,21 @@ class Forwarded{ return true; }else{ return false; - } - + } + } - + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - - + + /** * A constructor. * Empty constructor */ public function __construct() { } - - + + /** * sets the object's attributes. * @param $values should be an array of the form array('Group' => group_id, 'Ticket' => ticket_id). @@ -82,8 +82,8 @@ class Forwarded{ $this->setGroup($values['Group']); $this->setTicket($values['Ticket']); } - - + + /** * creates a new 'forwarded' entry. * this method will use the object's attributes for creating a new 'forwarded' entry in the database. @@ -92,15 +92,15 @@ class Forwarded{ $dbl = new DBLayer("lib"); $dbl->insert("`forwarded`", Array('Group' => $this->getGroup(), 'Ticket' => $this->getTicket())); } - - + + /** * deletes an existing 'forwarded' entry. * this method will use the object's attributes for deleting an existing 'forwarded' entry in the database. */ public function delete() { $dbl = new DBLayer("lib"); - $dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id"); + $dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id")); } @@ -115,24 +115,24 @@ class Forwarded{ $row = $statement->fetch(); $this->set($row); } - + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get group attribute of the object. */ public function getGroup(){ return $this->group; } - + /** * get ticket attribute of the object. */ public function getTicket(){ return $this->ticket; } - + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// /** @@ -142,7 +142,7 @@ class Forwarded{ public function setGroup($g){ $this->group = $g; } - + /** * set ticket attribute of the object. * @param $t integer id of the ticket @@ -150,6 +150,6 @@ class Forwarded{ public function setTicket($t){ $this->ticket = $t; } - - + + } diff --git a/code/web/private_php/ams/autoload/helpers.php b/code/web/private_php/ams/autoload/helpers.php index 0ac440800..0f7f8f659 100644 --- a/code/web/private_php/ams/autoload/helpers.php +++ b/code/web/private_php/ams/autoload/helpers.php @@ -1,16 +1,16 @@ setCompileDir( $SITEBASE . '/templates_c/' ); $smarty -> setCacheDir( $SITEBASE . '/cache/' ); @@ -35,11 +35,16 @@ class Helpers { // caching must be disabled for multi-language support $smarty -> caching = false; $smarty -> cache_lifetime = 5; - + + if (function_exists('apc_cache_info')) { + // production + $smarty->compile_check = false; + } + // needed by smarty. helpers :: create_folders (); global $FORCE_INGAME; - + // if ingame, then use the ingame templates if ( helpers :: check_if_game_client() or $FORCE_INGAME ) { $smarty -> template_dir = $AMS_LIB . '/ingame_templates/'; @@ -47,29 +52,29 @@ class Helpers { $variables = parse_ini_file( $AMS_LIB . '/configs/ingame_layout.ini', true ); foreach ( $variables[$INGAME_LAYOUT] as $key => $value ) { $smarty -> assign( $key, $value ); - } + } } else { $smarty -> template_dir = $SITEBASE . '/templates/'; $smarty -> setConfigDir( $SITEBASE . '/configs' ); - } - + } + foreach ( $vars as $key => $value ) { $smarty -> assign( $key, $value ); - } - + } + // load page specific variables that are language dependent $variables = Helpers :: handle_language(); if ( $template != 'layout_plugin' ) { foreach ( $variables[$template] as $key => $value ) { $smarty -> assign( $key, $value ); - } - } + } + } // load ams content variables that are language dependent foreach ( $variables['ams_content'] as $key => $value ) { $smarty -> assign( $key, $value ); - } - + } + //load ams content variables that are language dependent foreach ( $variables['ams_content'] as $key => $value){ $smarty -> assign( $key, $value); @@ -84,20 +89,20 @@ class Helpers { $inherited = "extends:layout_user.tpl|"; } else { $inherited = ""; - } - + } + // if $returnHTML is set to true, return the html by fetching the template else display the template. if ( $returnHTML == true ) { return $smarty -> fetch( $inherited . $template . '.tpl' ); } else { $smarty -> display( $inherited . $template . '.tpl' ); - } - } - - + } + } + + /** * creates the folders that are needed for smarty. - * + * * @todo for the drupal module it might be possible that drupal_mkdir needs to be used instead of mkdir, also this should be in the install.php instead. */ static public function create_folders() { @@ -112,19 +117,19 @@ class Helpers { $SITEBASE . '/configs' ); foreach ( $arr as &$value ) { - + if ( !file_exists( $value ) ) { print( $value ); mkdir( $value ); - } - } - - } - - + } + } + + } + + /** * check if the http request is sent ingame or not. - * + * * @return returns true in case it's sent ingame, else false is returned. */ static public function check_if_game_client() @@ -135,37 +140,37 @@ class Helpers { return true; } else { return false; - } - } - - + } + } + + /** * Handles the language specific aspect. * The language can be changed by setting the $_GET['Language'] & $_GET['setLang'] together. This will also change the language entry of the user in the db. * Cookies are also being used in case the user isn't logged in. - * + * * @return returns the parsed content of the language .ini file related to the users language setting. */ static public function handle_language() { global $DEFAULT_LANGUAGE; global $AMS_TRANS; - + // if user wants to change the language if ( isset( $_GET['Language'] ) && isset( $_GET['setLang'] ) ) { // The ingame client sometimes sends full words, derive those! switch ( $_GET['Language'] ) { - + case "English": $lang = "en"; break; - + case "French": $lang = "fr"; break; - + default: $lang = $_GET['Language']; - } + } // if the file exists en the setLang = true if ( file_exists( $AMS_TRANS . '/' . $lang . '.ini' ) && $_GET['setLang'] == "true" ) { // set a cookie & session var and incase logged in write it to the db! @@ -173,10 +178,10 @@ class Helpers { $_SESSION['Language'] = $lang; if ( WebUsers :: isLoggedIn() ) { WebUsers :: setLanguage( $_SESSION['id'], $lang ); - } + } } else { $_SESSION['Language'] = $DEFAULT_LANGUAGE; - } + } } else { // if the session var is not set yet if ( !isset( $_SESSION['Language'] ) ) { @@ -186,61 +191,68 @@ class Helpers { // else use the default language } else { $_SESSION['Language'] = $DEFAULT_LANGUAGE; - } - } - } + } + } + } if ( $_SESSION['Language'] == "" ) { $_SESSION['Language'] = $DEFAULT_LANGUAGE; - } + } return parse_ini_file( $AMS_TRANS . '/' . $_SESSION['Language'] . '.ini', true ); - } + } -/** - * Time output function for handling the time display. - * - * @return returns the time in the format specified in the $TIME_FORMAT global variable. - */ -static public function outputTime( $time, $str = 1 ) { -global $TIME_FORMAT; - if ( $str ) { - return date( $TIME_FORMAT, strtotime( $time ) ); - } else { - return date( $TIME_FORMAT, $time ); - } -} + /** + * Time output function for handling the time display. + * + * @return returns the time in the format specified in the $TIME_FORMAT global variable. + */ + static public function outputTime($time, $str = 1) { + global $TIME_FORMAT; + if ($str) { + return date($TIME_FORMAT, strtotime($time)); + } else { + return date($TIME_FORMAT, $time); + } + } + + /** + * Auto login function for ingame use. + * This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db. + * it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs. + * + * @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name. + */ + static public function check_login_ingame() { + return NULL; + + // FIXME + /* + if ( helpers :: check_if_game_client () or $forcelibrender = false ) { + $dbr = new DBLayer( "ring" ); + if ( isset( $_GET['UserId'] ) && isset( $_COOKIE['ryzomId'] ) ) { + $id = $_GET['UserId']; + + $statement = $dbr -> select( "ring_users", array( 'id' => $id, 'cookie' => $_COOKIE['ryzomId'] ), "user_id=:id AND cookie =:cookie" ); + + // $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId'])); + + if ( $statement -> rowCount() ) { + $entry = $statement -> fetch(); + // print_r($entry); + return array( 'id' => $entry['user_id'], 'name' => $entry['user_name'] ); + } else { + return "FALSE"; + } + } else { + return "FALSE"; + } + } else { + return "FALSE"; + } + } + */ + } -/** - * Auto login function for ingame use. - * This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db. - * it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs. - * - * @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name. - */ -static public function check_login_ingame() { -if ( helpers :: check_if_game_client () or $forcelibrender = false ) { - $dbr = new DBLayer( "ring" ); - if ( isset( $_GET['UserId'] ) && isset( $_COOKIE['ryzomId'] ) ) { - $id = $_GET['UserId']; - - $statement = $dbr -> select( "ring_users", array( 'id' => $id, 'cookie' => $_COOKIE['ryzomId'] ), "user_id=:id AND cookie =:cookie" ); - - // $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId'])); - - if ( $statement -> rowCount() ) { - $entry = $statement -> fetch(); - // print_r($entry); - return array( 'id' => $entry['user_id'], 'name' => $entry['user_name'] ); - } else { - return "FALSE"; - } - } else { - return "FALSE"; - } - } else { - return "FALSE"; - } -} } diff --git a/code/web/private_php/ams/autoload/in_support_group.php b/code/web/private_php/ams/autoload/in_support_group.php index 86c678cd3..73d075168 100644 --- a/code/web/private_php/ams/autoload/in_support_group.php +++ b/code/web/private_php/ams/autoload/in_support_group.php @@ -54,7 +54,7 @@ class In_Support_Group{ */ public function create() { $dbl = new DBLayer("lib"); - $dbl->insert("`in_support_group`", Array('User' => $this->user, 'Group' => $this->group); + $dbl->insert("`in_support_group`", Array('User' => $this->user, 'Group' => $this->group)); } @@ -64,7 +64,7 @@ class In_Support_Group{ */ public function delete() { $dbl = new DBLayer("lib"); - $dbl->delete("`in_support_group`", array('user_id' => $this->getUser() ,'group_id' => $this->getGroup(), "`User` = :user_id and `Group` = :group_id"); + $dbl->delete("`in_support_group`", array('user_id' => $this->getUser() ,'group_id' => $this->getGroup()), "`User` = :user_id and `Group` = :group_id"); } /* diff --git a/code/web/private_php/ams/autoload/plugincache.php b/code/web/private_php/ams/autoload/plugincache.php index 8ff258513..29a2172cb 100644 --- a/code/web/private_php/ams/autoload/plugincache.php +++ b/code/web/private_php/ams/autoload/plugincache.php @@ -3,8 +3,8 @@ /** * API for loading and interacting with plugins * contains getters and setters. - * - * @author shubham meena mentored by Matthew Lagoe + * + * @author shubham meena mentored by Matthew Lagoe */ class Plugincache { private $id; @@ -14,14 +14,14 @@ class Plugincache { private $plugin_status; private $plugin_info = array(); private $update_info = array(); - + /** * A constructor. * Empty constructor */ public function __construct() { - } - + } + public function set( $values ) { $this -> setId( $values['Id'] ); $this -> setPluginName( $values['Name'] ); @@ -30,146 +30,146 @@ class Plugincache { $this -> setPluginStatus( $values['Status'] ); $this -> setPluginInfo( json_decode( $values['Info'] ) ); @$this -> setUpdateInfo( json_decode( $values['UpdateInfo'] ) ); - } - + } + /** * loads the object's attributes. */ - + public function load_With_SID() { $dbl = new DBLayer( "lib" ); $statement = $dbl -> executeWithoutParams( "SELECT * FROM plugins" ); $row = $statement -> fetch(); $this -> set( $row ); - } - + } + /** * get plugin id attribute of the object. - * + * * @return integer id */ public function getId() { return $this -> Id; - } - + } + /** * get plugin permission attribute of the object. */ public function getPluginPermission() { return $this -> plugin_permission; - } - + } + /** * get plugin Type attribute of the object. */ public function getPluginType() { return $this -> plugin_version; - } - + } + /** * get plugin status attribute of the object. */ public function getPluginStatus() { return $this -> plugin_status; - } - + } + /** * get plugin name attribute of the object. */ public function getPluginName() { return $this -> plugin_name; - } - + } + /** * get plugin info array attribute of the object. */ public function getPluginInfo() { return $this -> plugin_info; - } - + } + /** * set plugin id attribute of the object. - * + * * @param $s integer id */ public function setId( $s ) { $this -> Id = $s; - } - + } + /** * set plugin permission attribute of the object. - * + * * @param $t type of the query, set permission */ public function setPluginPermission( $t ) { $this -> plugin_permission = $t; - } - + } + /** * set plugin version attribute of the object. - * + * * @param $q string to set plugin version */ public function setPluginType( $q ) { $this -> plugin_version = $q; - } - + } + /** * set plugin status attribute of the object. - * + * * @param $d status code type int */ public function setPluginStatus( $d ) { $this -> plugin_status = $d; - } - + } + /** * set plugin name attribute of the object. - * + * * @param $p_n string to set plugin name. */ public function setPluginName( $p_n ) { $this -> plugin_name = $p_n; - } - + } + /** * set plugin info attribute array of the object. - * + * * @param $p_n array */ public function setPluginInfo( $p_n ) { $this -> plugin_info = $p_n; - } - + } + /** * functionalities for plugin updates */ - + /** * set update info attribute array of the object. - * + * * @param $p_n array */ public function setUpdateInfo( $p_n ) { $this -> update_info = $p_n; - } - + } + /** * get plugin info array attribute of the object. */ public function getUpdateInfo() { return $this -> update_info; - } - + } + /** * some more plugin function that requires during plugin operations */ - + /** * function to remove a non empty directory - * + * * @param $dir directory address - * @return boolean + * @return boolean */ public static function rrmdir( $dir ) { $result = array_diff( scandir( $dir ), array( '.', '..' ) ); @@ -177,16 +177,16 @@ class Plugincache { { if ( !@unlink( $dir . '/' . $item ) ) Plugincache :: rrmdir( $dir . '/' . $item ); - } + } return rmdir( $dir ); - } - + } + /** * function to unzip the zipped files - * + * * @param $target_path path to the target zipped file * @param $destination path to the destination - * @return boolean + * @return boolean */ public static function zipExtraction( $target_path, $destination ) { @@ -197,21 +197,21 @@ class Plugincache { { $zip -> close(); return true; - } + } else { $zip -> close(); return false; - } - } - } - + } + } + } + /** * Returns plugin information with respect to the id. - * + * * @param $id plugin id. * @param $fieldName string plugin field to return - * + * * @return info field from the db. */ public static function pluginInfoUsingId( $id, $fieldName ) @@ -220,11 +220,11 @@ class Plugincache { $sth = $db -> selectWithParameter( $fieldName, 'plugins', array( 'id' => $id ), 'Id=:id' ); $row = $sth -> fetch(); return $row[$fieldName]; - } - + } + /** * Function provides list of active plugins - * + * * @return list of active plugins */ public static function activePlugins() @@ -233,45 +233,42 @@ class Plugincache { $sth = $db -> selectWithParameter( 'Id', 'plugins', array( 'status' => 1 ), 'Status=:status' ); $row = $sth -> fetchAll(); return $row; - } - + } + /** * function to load hooks for the active plugins * and return the contents get from them. - * + * * -->Get the list of active plugins then call the global * hooks exists in the plugins hook file ($pluginName.php). - * -->Collect the contents from the hooks and associate within - * array with key referenced plugin name. - * -->return the content to use with smarty template loader - * + * -->Collect the contents from the hooks and associate within + * array with key referenced plugin name. + * -->return the content to use with smarty template loader + * * @return $content content get from hooks */ - public static function loadHooks() - { + public static function loadHooks() { $content = array(); - $ac_arr = Plugincache :: activePlugins(); - foreach( $ac_arr as $key => $value ) - { - $plugin_path = Plugincache :: pluginInfoUsingId( $value['Id'], 'FileName' ); - $template_path = json_decode( Plugincache :: pluginInfoUsingId( $value['Id'], 'Info' ) ) -> TemplatePath; - $plugin_name = explode( '/', $plugin_path )[4]; - - // calling hooks in the $pluginName.php - include $plugin_path . '/' . $plugin_name . '.php'; - $arr = get_defined_functions(); - - foreach( $arr['user'] as $key => $value ) - { - if ( stristr( $value, $plugin_name ) == true ) - { - $content['hook_info'][$plugin_name] = call_user_func( $value ); - } - } + $ac_arr = Plugincache::activePlugins(); + foreach ($ac_arr as $key => $value) { + $plugin_path = Plugincache::pluginInfoUsingId($value['Id'], 'FileName'); + $template_path = json_decode(Plugincache::pluginInfoUsingId($value['Id'], 'Info'))->TemplatePath; + $plugin_name = $plugin_path; + + // calling hooks in the $pluginName.php + global $AMS_PLUGINS; + include $AMS_PLUGINS . '/' . $plugin_name . '/' . $plugin_name . '.php'; + $arr = get_defined_functions(); + + foreach ($arr['user'] as $key => $value) { + if (stristr( $value, $plugin_name) == true) { + $content['hook_info'][$plugin_name] = call_user_func($value); + } + } // path for the template $content['hook_info'][$plugin_name]['TemplatePath'] = $template_path; - } - + } + return $content; - } } +} diff --git a/code/web/private_php/ams/autoload/querycache.php b/code/web/private_php/ams/autoload/querycache.php index 6f0c0dca6..ef55085b4 100644 --- a/code/web/private_php/ams/autoload/querycache.php +++ b/code/web/private_php/ams/autoload/querycache.php @@ -58,7 +58,7 @@ class Querycache{ */ public function update(){ $dbl = new DBLayer("lib"); - $dbl->update("ams_querycache", Array('type' => $this->getType(), 'query' => $this->getQuery(), 'db' => $this->getDb(), "SID=$this->getSID()" ); + $dbl->update("ams_querycache", Array('type' => $this->getType(), 'query' => $this->getQuery(), 'db' => $this->getDb(), "SID=$this->getSID()" )); } ////////////////////////////////////////////Getters//////////////////////////////////////////////////// diff --git a/code/web/private_php/ams/autoload/support_group.php b/code/web/private_php/ams/autoload/support_group.php index d482a842f..ed3c5daf5 100644 --- a/code/web/private_php/ams/autoload/support_group.php +++ b/code/web/private_php/ams/autoload/support_group.php @@ -327,7 +327,7 @@ class Support_Group{ */ public function update(){ $dbl = new DBLayer("lib"); - $dbl->update("`support_group`", Array('Name' => $this->getName(), 'Tag' => $this->getTag(), 'GroupEmail' => $this->getGroupEmail(), 'IMAP_MailServer' => $this->getIMAP_MailServer(), 'IMAP_Username' => $this->getIMAP_Username(), 'IMAP_password' => $this->getIMAP_Password(), "`SGroupId` = $this->getSGroupId()")); + $dbl->update("`support_group`", Array('Name' => $this->getName(), 'Tag' => $this->getTag(), 'GroupEmail' => $this->getGroupEmail(), 'IMAP_MailServer' => $this->getIMAP_MailServer(), 'IMAP_Username' => $this->getIMAP_Username(), 'IMAP_password' => $this->getIMAP_Password()), "`SGroupId` = ".$this->getSGroupId()); } @@ -337,7 +337,7 @@ class Support_Group{ */ public function delete(){ $dbl = new DBLayer("lib"); - $dbl->delete("`support_group`", Array('id' => $this->getSGroupId(), "`SGroupId` = :id")); + $dbl->delete("`support_group`", Array('id' => $this->getSGroupId()), "`SGroupId` = :id"); } ////////////////////////////////////////////Getters//////////////////////////////////////////////////// diff --git a/code/web/private_php/ams/autoload/ticket.php b/code/web/private_php/ams/autoload/ticket.php index 51f987e5a..5ce9887ed 100644 --- a/code/web/private_php/ams/autoload/ticket.php +++ b/code/web/private_php/ams/autoload/ticket.php @@ -6,19 +6,19 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Ticket{ - - private $tId; /**< The id of ticket */ - private $timestamp; /**< Timestamp of the ticket */ - private $title; /**< Title of the ticket */ - private $status; /**< Status of the ticket (0 = waiting on user reply, 1 = waiting on support, (2= not used atm), 3 = closed */ - private $queue; /**< (not in use atm) */ - private $ticket_category; /**< the id of the category belonging to the ticket */ - private $author; /**< The ticket_users id */ - private $priority; /**< The priority of the ticket where 0 = low, 3= supadupahigh */ - + + private $tId; /**< The id of ticket */ + private $timestamp; /**< Timestamp of the ticket */ + private $title; /**< Title of the ticket */ + private $status; /**< Status of the ticket (0 = waiting on user reply, 1 = waiting on support, (2= not used atm), 3 = closed */ + private $queue; /**< (not in use atm) */ + private $ticket_category; /**< the id of the category belonging to the ticket */ + private $author; /**< The ticket_users id */ + private $priority; /**< The priority of the ticket where 0 = low, 3= supadupahigh */ + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - - + + /** * check if a ticket exists. * @param $id the id of the ticket to be checked. @@ -31,10 +31,10 @@ class Ticket{ return true; }else{ return false; - } + } } - - + + /** * return an array of the possible statuses * @return an array containing the string values that represent the different statuses. @@ -51,8 +51,8 @@ class Ticket{ public static function getPriorityArray() { return Array("Low","Normal","High","Super Dupa High"); } - - + + /** * return an entire ticket. * returns the ticket object and an array of all replies to that ticket. @@ -64,10 +64,10 @@ class Ticket{ $ticket = new Ticket(); $ticket->load_With_TId($id); $reply_array = Ticket_Reply::getRepliesOfTicket($id, $view_as_admin); - return Array('ticket_obj' => $ticket,'reply_array' => $reply_array); + return Array('ticket_obj' => $ticket,'reply_array' => $reply_array); } - - + + /** * return all tickets of a specific user. * an array of all tickets created by a specific user are returned by this function. @@ -90,11 +90,11 @@ class Ticket{ $instance->setAuthor($ticket['Author']); $result[] = $instance; } - return $result; + return $result; } - - - + + + /** * function that creates a new ticket. * A new ticket will be created, in case the extra_info != 0 and the http request came from ingame, then a ticket_info page will be created. @@ -117,13 +117,13 @@ class Ticket{ $ticket->set($values); $ticket->create(); $ticket_id = $ticket->getTId(); - + //if ingame then add an extra info if(Helpers::check_if_game_client() && $extra_info != 0){ $extra_info['Ticket'] = $ticket_id; Ticket_Info::create_Ticket_Info($extra_info); } - + //write a log entry if ( $author == $real_author){ Ticket_Log::createLogEntry( $ticket_id, $author, 1); @@ -131,18 +131,18 @@ class Ticket{ Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author); } Ticket_Reply::createReply($content, $author, $ticket_id, 0, $author); - + //forwards the ticket directly after creation to the supposed support group if($for_support_group){ Ticket::forwardTicket(0, $ticket_id, $for_support_group); } - + //send email that new ticket has been created Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "NEW", $ticket->getForwardedGroupId()); return $ticket_id; - + } - + /** * updates the ticket's status. @@ -152,7 +152,7 @@ class Ticket{ * @param $author the user (id) that performed the update status action */ public static function updateTicketStatus( $ticket_id, $newStatus, $author) { - + $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); if ($ticket->getStatus() != $newStatus){ @@ -160,10 +160,10 @@ class Ticket{ Ticket_Log::createLogEntry( $ticket_id, $author, 5, $newStatus); } $ticket->update(); - + } - - + + /** * updates the ticket's status & priority. * A log entry about this will be created only if the newStatus is different from the current status and also when the newPriority is different from the current priority. @@ -174,7 +174,7 @@ class Ticket{ * @param $author the user (id) that performed the update */ public static function updateTicketStatusAndPriority( $ticket_id, $newStatus, $newPriority, $author) { - + $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); if ($ticket->getStatus() != $newStatus){ @@ -186,10 +186,10 @@ class Ticket{ Ticket_Log::createLogEntry( $ticket_id, $author, 6, $newPriority); } $ticket->update(); - + } - - + + /** * return the latest reply of a ticket * @param $ticket_id the id of the ticket. @@ -202,8 +202,8 @@ class Ticket{ $reply->set($statement->fetch()); return $reply; } - - + + /** * create a new reply for a ticket. * A reply will only be added if the content isn't empty and if the ticket isn't closed. @@ -222,13 +222,13 @@ class Ticket{ //if status is not closed if($ticket->getStatus() != 3){ Ticket_Reply::createReply($content, $author, $ticket_id, $hidden, $ticket->getAuthor()); - + //notify ticket author that a new reply is added! if($ticket->getAuthor() != $author){ Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "REPLY", $ticket->getForwardedGroupId()); } - - + + }else{ //TODO: Show error message that ticket is closed } @@ -236,8 +236,8 @@ class Ticket{ //TODO: Show error content is empty } } - - + + /** * assign a ticket to a user. * Checks if the ticket exists, if so then it will try to assign the user to it, a log entry will be written about this. @@ -254,8 +254,8 @@ class Ticket{ return "TICKET_NOT_EXISTING"; } } - - + + /** * unassign a ticket of a user. * Checks if the ticket exists, if so then it will try to unassign the user of it, a log entry will be written about this. @@ -272,8 +272,8 @@ class Ticket{ return "TICKET_NOT_EXISTING"; } } - - + + /** * forward a ticket to a specific support group. * Checks if the ticket exists, if so then it will try to forward the ticket to the support group specified, a log entry will be written about this. @@ -288,7 +288,7 @@ class Ticket{ if(isset($group_id) && $group_id != ""){ //forward the ticket $returnvalue = Forwarded::forwardTicket($group_id, $ticket_id); - + if($user_id != 0){ //unassign the ticket incase the ticket is assined to yourself self::unAssignTicket($user_id, $ticket_id); @@ -303,12 +303,12 @@ class Ticket{ return "TICKET_NOT_EXISTING"; } } - - - - + + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - + /** * A constructor. * Empty constructor @@ -335,18 +335,18 @@ class Ticket{ $this->author = $values['Author']; $this->priority = $values['Priority']; } - - + + /** * creates a new 'ticket' entry. * this method will use the object's attributes for creating a new 'ticket' entry in the database. */ public function create(){ $dbl = new DBLayer("lib"); - $this->tId = $dbl->executeReturnId("ticket", Array('Timestamp'=>now(), 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority)); + $this->tId = $dbl->executeReturnId("ticket", Array('Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), array('Timestamp'=>'now()')); } - + /** * loads the object's attributes. * loads the object's attributes by giving a TId (ticket id). @@ -365,8 +365,8 @@ class Ticket{ $this->author = $row['Author']; $this->priority = $row['Priority']; } - - + + /** * update the objects attributes to the db. */ @@ -374,8 +374,8 @@ class Ticket{ $dbl = new DBLayer("lib"); $dbl->update("ticket", Array('Timestamp' => $this->timestamp, 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), "TId=$this->tId"); } - - + + /** * check if a ticket has a ticket_info page or not. * @return true or false @@ -383,38 +383,38 @@ class Ticket{ public function hasInfo(){ return Ticket_Info::TicketHasInfo($this->getTId()); } - - + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get tId attribute of the object. */ public function getTId(){ return $this->tId; } - + /** * get timestamp attribute of the object in the format defined in the outputTime function of the Helperclass. */ public function getTimestamp(){ return Helpers::outputTime($this->timestamp); } - + /** * get title attribute of the object. */ public function getTitle(){ return $this->title; } - + /** * get status attribute of the object. */ public function getStatus(){ return $this->status; } - + /** * get status attribute of the object in the form of text (string). */ @@ -422,43 +422,43 @@ class Ticket{ $statusArray = Ticket::getStatusArray(); return $statusArray[$this->getStatus()]; } - + /** * get category attribute of the object in the form of text (string). */ public function getCategoryName(){ $category = Ticket_Category::constr_TCategoryId($this->getTicket_Category()); - return $category->getName(); + return $category->getName(); } - + /** * get queue attribute of the object. */ public function getQueue(){ return $this->queue; } - + /** * get ticket_category attribute of the object (int). */ public function getTicket_Category(){ return $this->ticket_category; } - + /** * get author attribute of the object (int). */ public function getAuthor(){ return $this->author; } - + /** * get priority attribute of the object (int). */ public function getPriority(){ return $this->priority; } - + /** * get priority attribute of the object in the form of text (string). */ @@ -466,7 +466,7 @@ class Ticket{ $priorityArray = Ticket::getPriorityArray(); return $priorityArray[$this->getPriority()]; } - + /** * get the user assigned to the ticket. * or return 0 in case not assigned. @@ -479,7 +479,7 @@ class Ticket{ return $user_id; } } - + /** * get the name of the support group to whom the ticket is forwarded * or return 0 in case not forwarded. @@ -492,7 +492,7 @@ class Ticket{ return Support_Group::getGroup($group_id)->getName(); } } - + /** * get the id of the support group to whom the ticket is forwarded * or return 0 in case not forwarded. @@ -506,7 +506,7 @@ class Ticket{ } } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// - + /** * set tId attribute of the object. * @param $id integer id of the ticket @@ -514,7 +514,7 @@ class Ticket{ public function setTId($id){ $this->tId = $id; } - + /** * set timestamp attribute of the object. * @param $ts timestamp of the ticket @@ -522,7 +522,7 @@ class Ticket{ public function setTimestamp($ts){ $this->timestamp = $ts; } - + /** * set title attribute of the object. * @param $t title of the ticket @@ -530,7 +530,7 @@ class Ticket{ public function setTitle($t){ $this->title = $t; } - + /** * set status attribute of the object. * @param $s status of the ticket(int) @@ -538,7 +538,7 @@ class Ticket{ public function setStatus($s){ $this->status = $s; } - + /** * set queue attribute of the object. * @param $q queue of the ticket @@ -546,7 +546,7 @@ class Ticket{ public function setQueue($q){ $this->queue = $q; } - + /** * set ticket_category attribute of the object. * @param $tc ticket_category id of the ticket(int) @@ -554,7 +554,7 @@ class Ticket{ public function setTicket_Category($tc){ $this->ticket_category = $tc; } - + /** * set author attribute of the object. * @param $a author of the ticket @@ -562,7 +562,7 @@ class Ticket{ public function setAuthor($a){ $this->author = $a; } - + /** * set priority attribute of the object. * @param $p priority of the ticket @@ -570,5 +570,5 @@ class Ticket{ public function setPriority($p){ $this->priority = $p; } - + } diff --git a/code/web/private_php/ams/autoload/ticket_log.php b/code/web/private_php/ams/autoload/ticket_log.php index f83d4b29e..c6d88959b 100644 --- a/code/web/private_php/ams/autoload/ticket_log.php +++ b/code/web/private_php/ams/autoload/ticket_log.php @@ -2,7 +2,7 @@ /** * Class that handles the logging. The logging will be used when a ticket is created, a reply is added, if someone views a ticket, * if someone assigns a ticket to him or if someone forwards a ticket. This class provides functions to get retrieve those logs and also make them. -* +* *-the Action IDs being used are: * -# User X Created ticket * -# Admin X created ticket for arg @@ -18,13 +18,13 @@ */ class Ticket_Log{ - - private $tLogId; /**< The id of the log entry */ - private $timestamp; /**< The timestamp of the log entry */ - private $query; /**< The query (json encoded array containing action id & argument) */ - private $author; /**< author of the log */ - private $ticket; /**< the id of the ticket related to the log entry */ - + + private $tLogId; /**< The id of the log entry */ + private $timestamp; /**< The timestamp of the log entry */ + private $query; /**< The query (json encoded array containing action id & argument) */ + private $author; /**< author of the log */ + private $ticket; /**< the id of the ticket related to the log entry */ + /**************************************** *Action ID's: * 1: User X Created Ticket @@ -38,10 +38,10 @@ class Ticket_Log{ * 9: unassigned to the ticket * ****************************************/ - - + + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - + /** * return all log entries related to a ticket. * @param $ticket_id the id of the ticket of which we want all related log entries returned. @@ -65,10 +65,10 @@ class Ticket_Log{ $instanceLog->setQuery($log['Query']); $result[] = $instanceLog; } - return $result; + return $result; } - - + + /** * create a new log entry. * It will check if the $TICKET_LOGGING global var is true, this var is used to turn logging on and off. In case it's on, the log message will be stored. @@ -82,8 +82,8 @@ class Ticket_Log{ global $TICKET_LOGGING; if($TICKET_LOGGING){ $dbl = new DBLayer("lib"); - $values = Array('Timestamp'=>now(), 'Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id); - $dbl->insert("ticket_log", $values); + $values = Array('Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id); + $dbl->insert("ticket_log", $values, array('Timestamp'=>'now()')); } } @@ -98,7 +98,7 @@ class Ticket_Log{ $instance->setTLogId($id); return $instance; } - + /** * return all log entries related to a ticket. * @param $ticket_id the id of the ticket of which we want all related log entries returned. @@ -115,19 +115,19 @@ class Ticket_Log{ $instance->set($log); $result[] = $instance; } - return $result; + return $result; } - - + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - + /** * A constructor. * Empty constructor */ public function __construct() { } - + /** * sets the object's attributes. * @param $values should be an array. @@ -138,7 +138,7 @@ class Ticket_Log{ $this->setQuery($values['Query']); $this->setTicket($values['Ticket']); $this->setAuthor($values['Author']); - } + } /** * loads the object's attributes. @@ -151,56 +151,56 @@ class Ticket_Log{ $row = $statement->fetch(); $this->set($row); } - - + + /** * update attributes of the object to the DB. */ public function update(){ $dbl = new DBLayer("lib"); - + $values = Array('timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket() ); $dbl->update("ticket_log", $values, "TLogId = $this->getTLogId()"); - + } - + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get tLogId attribute of the object. */ public function getTLogId(){ return $this->tLogId; } - + /** * get timestamp attribute of the object. */ public function getTimestamp(){ return Helpers::outputTime($this->timestamp); } - + /** * get query attribute of the object. */ public function getQuery(){ return $this->query; } - + /** * get author attribute of the object. */ public function getAuthor(){ return $this->author; } - + /** * get ticket attribute of the object. */ public function getTicket(){ return $this->ticket; } - + /** * get the action id out of the query by decoding it. */ @@ -208,7 +208,7 @@ class Ticket_Log{ $decodedQuery = json_decode($this->query); return $decodedQuery[0]; } - + /** * get the argument out of the query by decoding it. */ @@ -216,7 +216,7 @@ class Ticket_Log{ $decodedQuery = json_decode($this->query); return $decodedQuery[1]; } - + /** * get the action text(string) array. * this is being read from the language .ini files. @@ -229,9 +229,9 @@ class Ticket_Log{ } return $result; } - + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// - + /** * set tLogId attribute of the object. * @param $id integer id of the log entry @@ -239,7 +239,7 @@ class Ticket_Log{ public function setTLogId($id){ $this->tLogId = $id; } - + /** * set timestamp attribute of the object. * @param $t timestamp of the log entry @@ -247,7 +247,7 @@ class Ticket_Log{ public function setTimestamp($t){ $this->timestamp = $t; } - + /** * set query attribute of the object. * @param $q the encoded query @@ -255,7 +255,7 @@ class Ticket_Log{ public function setQuery($q){ $this->query = $q; } - + /** * set author attribute of the object. * @param $a integer id of the user who created the log entry @@ -263,7 +263,7 @@ class Ticket_Log{ public function setAuthor($a){ $this->author = $a; } - + /** * set ticket attribute of the object. * @param $t integer id of ticket of which the log entry is related to. @@ -271,6 +271,6 @@ class Ticket_Log{ public function setTicket($t){ $this->ticket = $t; } - - + + } diff --git a/code/web/private_php/ams/autoload/ticket_reply.php b/code/web/private_php/ams/autoload/ticket_reply.php index 2675fcfbe..9d806d161 100644 --- a/code/web/private_php/ams/autoload/ticket_reply.php +++ b/code/web/private_php/ams/autoload/ticket_reply.php @@ -4,15 +4,15 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Ticket_Reply{ - private $tReplyId; /**< The id of the reply */ - private $ticket; /**< the ticket id related to the reply */ - private $content; /**< the content of the reply */ - private $author; /**< The id of the user that made the reply */ - private $timestamp; /**< The timestamp of the reply */ - private $hidden; /**< indicates if reply should be hidden for normal users or not */ - + private $tReplyId; /**< The id of the reply */ + private $ticket; /**< the ticket id related to the reply */ + private $content; /**< the content of the reply */ + private $author; /**< The id of the user that made the reply */ + private $timestamp; /**< The timestamp of the reply */ + private $hidden; /**< indicates if reply should be hidden for normal users or not */ + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - + /** * return constructed element based on TReplyId. * @param $id the Id the reply we want to load. @@ -23,8 +23,8 @@ class Ticket_Reply{ $instance->setTReplyId($id); return $instance; } - - + + /** * return all replies on a specific ticket. * @param $ticket_id the id of the ticket of which we want the replies. @@ -43,12 +43,12 @@ class Ticket_Reply{ $instanceAuthor = Ticket_User::constr_TUserId($tReply['Author']); $instanceAuthor->setExternId($tReply['ExternId']); $instanceAuthor->setPermission($tReply['Permission']); - + //load content $instanceContent = new Ticket_Content(); $instanceContent->setTContentId($tReply['TContentId']); $instanceContent->setContent($tReply['Content']); - + //load reply and add the author and content object in it. $instanceReply = new self(); $instanceReply->setTReplyId($tReply['TReplyId']); @@ -60,9 +60,9 @@ class Ticket_Reply{ $result[] = $instanceReply; } } - return $result; + return $result; } - + /** * creates a new reply on a ticket. * Creates a ticket_content entry and links it with a new created ticket_reply, a log entry will be written about this. @@ -78,19 +78,19 @@ class Ticket_Reply{ $ticket_content->setContent($content); $ticket_content->create(); $content_id = $ticket_content->getTContentId(); - + $ticket_reply = new Ticket_Reply(); $ticket_reply->set(Array('Ticket' => $ticket_id,'Content' => $content_id,'Author' => $author, 'Hidden' => $hidden)); $ticket_reply->create(); $reply_id = $ticket_reply->getTReplyId(); - + if($ticket_creator == $author){ Ticket::updateTicketStatus( $ticket_id, 1, $author); } - + Ticket_Log::createLogEntry( $ticket_id, $author, 4, $reply_id); } - + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// /** @@ -116,14 +116,14 @@ class Ticket_Reply{ $this->setHidden($values['Hidden']); } } - + /** * creates a new 'ticket_reply' entry. * this method will use the object's attributes for creating a new 'ticket_reply' entry in the database (the now() function will create the timestamp). */ public function create(){ $dbl = new DBLayer("lib"); - $this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author,'Timestamp'=>now(), 'Hidden' => $this->hidden)); + $this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Hidden' => $this->hidden), array('Timestamp'=>'now()')); } /** @@ -142,7 +142,7 @@ class Ticket_Reply{ $this->timestamp = $row['Timestamp']; $this->hidden = $row['Hidden']; } - + /** * updates a ticket_reply entry based on the objects attributes. */ @@ -150,16 +150,16 @@ class Ticket_Reply{ $dbl = new DBLayer("lib"); $dbl->update("ticket", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Timestamp' => $this->timestamp, 'Hidden' => $this->hidden), "TReplyId=$this->tReplyId, "); } - + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get ticket attribute of the object. */ public function getTicket(){ return $this->ticket; } - + /** * get content attribute of the object. */ @@ -173,7 +173,7 @@ class Ticket_Reply{ public function getAuthor(){ return $this->author; } - + /** * get timestamp attribute of the object. * The output format is defined by the Helpers class function, outputTime(). @@ -181,23 +181,23 @@ class Ticket_Reply{ public function getTimestamp(){ return Helpers::outputTime($this->timestamp); } - + /** * get tReplyId attribute of the object. */ public function getTReplyId(){ return $this->tReplyId; } - + /** * get hidden attribute of the object. */ public function getHidden(){ return $this->hidden; - } - + } + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// - + /** * set ticket attribute of the object. * @param $t integer id of the ticket @@ -205,7 +205,7 @@ class Ticket_Reply{ public function setTicket($t){ $this->ticket = $t; } - + /** * set content attribute of the object. * @param $c integer id of the ticket_content entry @@ -213,7 +213,7 @@ class Ticket_Reply{ public function setContent($c){ $this->content = $c; } - + /** * set author attribute of the object. * @param $a integer id of the user @@ -221,7 +221,7 @@ class Ticket_Reply{ public function setAuthor($a){ $this->author = $a; } - + /** * set timestamp attribute of the object. * @param $t timestamp of the reply @@ -229,7 +229,7 @@ class Ticket_Reply{ public function setTimestamp($t){ $this->timestamp = $t; } - + /** * set tReplyId attribute of the object. * @param $i integer id of the ticket_reply @@ -237,7 +237,7 @@ class Ticket_Reply{ public function setTReplyId($i){ $this->tReplyId = $i; } - + /** * set hidden attribute of the object. * @param $h should be 0 or 1 diff --git a/code/web/private_php/ams/autoload/ticket_user.php b/code/web/private_php/ams/autoload/ticket_user.php index 0937b48b0..6de69ccdd 100644 --- a/code/web/private_php/ams/autoload/ticket_user.php +++ b/code/web/private_php/ams/autoload/ticket_user.php @@ -7,13 +7,13 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Ticket_User{ - - private $tUserId; /**< The id of the user inside the ticket system*/ - private $permission; /**< The permission of the user */ - private $externId; /**< The id of the user account in the www (could be drupal,...) that is linked to the ticket_user */ - + + private $tUserId; /**< The id of the user inside the ticket system*/ + private $permission; /**< The permission of the user */ + private $externId; /**< The id of the user account in the www (could be drupal,...) that is linked to the ticket_user */ + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - + /** * create a new ticket user. * @param $extern_id the id of the user account in the www version (drupal,...) @@ -21,10 +21,10 @@ class Ticket_User{ */ public static function createTicketUser( $extern_id, $permission) { $dbl = new DBLayer("lib"); - $dbl->insert("ticket_user",array('Permission' => $permission, 'ExternId' => $extern_id)); + $dbl->insert("ticket_user",array('TUserId' => $extern_id, 'Permission' => $permission, 'ExternId' => $extern_id)); } - - + + /** * check if a ticket_user object is a mod or not. * @param $user the ticket_user object itself @@ -36,8 +36,8 @@ class Ticket_User{ } return false; } - - + + /** * check if a ticket_user object is an admin or not. * @param $user the ticket_user object itself @@ -49,8 +49,8 @@ class Ticket_User{ } return false; } - - + + /** * return constructed ticket_user object based on TUserId. * @param $id the TUserId of the entry. @@ -60,10 +60,10 @@ class Ticket_User{ $instance = new self(); $instance->setTUserId($id); return $instance; - + } - - + + /** * return a list of all mods/admins. * @return an array consisting of ticket_user objects that are mods & admins. @@ -78,10 +78,10 @@ class Ticket_User{ $instanceUser->set($user); $result[] = $instanceUser; } - return $result; + return $result; } - - + + /** * return constructed ticket_user object based on ExternId. * @param $id the ExternId of the entry. @@ -97,8 +97,8 @@ class Ticket_User{ $instance->externId = $row['ExternId']; return $instance; } - - + + /** * change the permission of a ticket_user. * @param $user_id the TUserId of the entry. @@ -110,8 +110,8 @@ class Ticket_User{ $user->setPermission($perm); $user->update(); } - - + + /** * return the email address of a ticket_user. * @param $id the TUserId of the entry. @@ -121,10 +121,10 @@ class Ticket_User{ $user = new Ticket_User(); $user->load_With_TUserId($id); $webUser = new WebUsers($user->getExternId()); - return $webUser->getEmail(); + return $webUser->getEmail(); } - - + + /** * return the username of a ticket_user. * @param $id the TUserId of the entry. @@ -134,10 +134,10 @@ class Ticket_User{ $user = new Ticket_User(); $user->load_With_TUserId($id); $webUser = new WebUsers($user->getExternId()); - return $webUser->getUsername(); + return $webUser->getUsername(); } - - + + /** * return the TUserId of a ticket_user by giving a username. * @param $username the username of a user. @@ -146,9 +146,9 @@ class Ticket_User{ public static function get_id_from_username($username){ $externId = WebUsers::getId($username); $user = Ticket_User::constr_ExternId($externId); - return $user->getTUserId(); + return $user->getTUserId(); } - + /** * return the ticket_user id from an email address. * @param $email the emailaddress of a user. @@ -163,18 +163,18 @@ class Ticket_User{ return "FALSE"; } } - - + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - + /** * A constructor. * Empty constructor */ public function __construct() { } - - + + /** * sets the object's attributes. * @param $values should be an array of the form array('TUserId' => id, 'Permission' => perm, 'ExternId' => ext_id). @@ -184,8 +184,8 @@ class Ticket_User{ $this->setPermission($values['Permission']); $this->setExternId($values['ExternId']); } - - + + /** * loads the object's attributes. * loads the object's attributes by giving a TUserId. @@ -198,9 +198,9 @@ class Ticket_User{ $this->tUserId = $row['TUserId']; $this->permission = $row['Permission']; $this->externId = $row['ExternId']; - } - - + } + + /** * update the object's attributes to the db. */ @@ -208,33 +208,33 @@ class Ticket_User{ $dbl = new DBLayer("lib"); $dbl->update("ticket_user" ,array('Permission' => $this->permission, 'ExternId' => $this->externId) ,"TUserId=$this->tUserId"); } - + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// - + /** * get permission attribute of the object. */ public function getPermission(){ return $this->permission; } - + /** * get externId attribute of the object. */ public function getExternId(){ return $this->externId; } - + /** * get tUserId attribute of the object. */ public function getTUserId(){ return $this->tUserId; } - - + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// - + /** * set permission attribute of the object. * @param $perm integer that indicates the permission level. (1= user, 2= mod, 3= admin) @@ -242,16 +242,16 @@ class Ticket_User{ public function setPermission($perm){ $this->permission = $perm; } - - + + /** * set externId attribute of the object. * @param $id the external id. - */ + */ public function setExternId($id){ $this->externId = $id; } - + /** * set tUserId attribute of the object. * @param $id the ticket_user id @@ -259,6 +259,6 @@ class Ticket_User{ public function setTUserId($id){ $this->tUserId= $id; } - - + + } diff --git a/code/web/private_php/ams/autoload/users.php b/code/web/private_php/ams/autoload/users.php index b398270e4..ea8d134d1 100644 --- a/code/web/private_php/ams/autoload/users.php +++ b/code/web/private_php/ams/autoload/users.php @@ -6,12 +6,12 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Users{ - + /** * checks if entered values before registering are valid. * @param $values array with Username,Password, ConfirmPass and Email. * @return string Info: Returns a string, if input data is valid then "success" is returned, else an array with errors - */ + */ public function check_Register($values){ // check values if ( isset( $values["Username"] ) and isset( $values["Password"] ) and isset( $values["ConfirmPass"] ) and isset( $values["Email"] ) ){ @@ -25,8 +25,16 @@ class Users{ $cpass = ""; $email = ""; } + + if ( helpers :: check_if_game_client() or isset($FORCE_INGAME) ) { + if ( isset( $_POST["TaC"] )) { + $tac="success"; + } + } else { + $tac="success"; + } - if ( ( $user == "success" ) and ( $pass == "success" ) and ( $cpass == "success" ) and ( $email == "success" ) and ( isset( $_POST["TaC"] ) ) ){ + if ( ( $user == "success" ) and ( $pass == "success" ) and ( $cpass == "success" ) and ( $email == "success" ) and ($tac=="success") ){ return "success"; }else{ global $TOS_URL; @@ -44,7 +52,7 @@ class Users{ }else{ $pageElements['USERNAME_ERROR'] = 'FALSE'; } - + if ( $pass != "success" ){ $pageElements['PASSWORD_ERROR'] = 'TRUE'; }else{ @@ -69,13 +77,13 @@ class Users{ } } - - + + /** * checks if entered username is valid. * @param $username the username that the user wants to use. * @return string Info: Returns a string based on if the username is valid, if valid then "success" is returned - */ + */ public function checkUser( $username ) { if ( isset( $username ) ){ @@ -95,7 +103,7 @@ class Users{ } return "fail"; } - + /** * check if username already exists. * This is the base function, it should be overwritten by the WebUsers class. @@ -105,10 +113,10 @@ class Users{ protected function checkUserNameExists($username){ //You should overwrite this method with your own version! print('this is the base class!'); - + } - - + + /** * checks if the password is valid. * @param $pass the password willing to be used. @@ -129,8 +137,8 @@ class Users{ } return "fail"; } - - + + /** * checks if the confirmPassword matches the original. * @param $pass_result the result of the previous password check. @@ -152,8 +160,8 @@ class Users{ } return "fail"; } - - + + /** * wrapper to check if the email address is valid. * @param $email the email address @@ -185,16 +193,16 @@ class Users{ protected function checkEmailExists($email){ //TODO: You should overwrite this method with your own version! print('this is the base class!'); - + } - - + + /** * check if the emailaddress structure is valid. * @param $email the email address * @return true or false */ - public function validEmail( $email ){ + public static function validEmail( $email ){ $isValid = true; $atIndex = strrpos( $email, "@" ); if ( is_bool( $atIndex ) && !$atIndex ){ @@ -276,7 +284,7 @@ class Users{ // done! return $salt; } - + /** @@ -286,42 +294,43 @@ class Users{ * @param $user_id the extern id of the user (the id given by the www/CMS) * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. */ - public static function createUser($values, $user_id){ + public static function createUser($values, $user_id) { + ticket_user::createTicketUser($user_id, 1); try { //make connection with and put into shard db + $values["UId"] = $user_id; $dbs = new DBLayer("shard"); $dbs->insert("user", $values); + /* $dbr = new DBLayer("ring"); $valuesRing['user_id'] =$user_id; $valuesRing['user_name'] = $values['Login']; $valuesRing['user_type'] = 'ut_pioneer'; - $dbr->insert("ring_users", $valuesRing); - ticket_user::createTicketUser( $user_id, 1); + $dbr->insert("ring_users", $valuesRing); + */ return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new DBLayer("lib"); + $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "createUser", - "query" => json_encode(array($values["Login"],$values["Password"],$values["Email"])), "db" => "shard")); - ticket_user::createTicketUser( $user_id , 1 ); + "query" => json_encode(array($values["Login"], $values["Password"], $values["Email"])), "db" => "shard")); return "shardoffline"; - }catch (PDOException $e) { + } catch (PDOException $e) { print_r($e); return "liboffline"; } - } - + } } - + /** * creates permissions in the shard db for a user. * incase the shard is offline it will place it in the ams_querycache. * @param $pvalues with username */ public static function createPermissions($pvalues) { - + try { $values = array('username' => $pvalues[0]); $dbs = new DBLayer("shard"); @@ -338,12 +347,12 @@ class Users{ //oh noooz, the shard is offline! Put it in query queue at ams_lib db! $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "createPermissions", - "query" => json_encode(array($pvalues[0])), "db" => "shard")); - } + "query" => json_encode(array($pvalues[0])), "db" => "shard")); + } return true; } - - + + /** * check if username and password matches. * This is the base function, it should be overwritten by the WebUsers class. @@ -353,7 +362,7 @@ class Users{ protected static function checkLoginMatch($user,$pass){ print('This is the base class!'); } - + /** * check if the changing of a password is valid. * a mod/admin doesn't has to fill in the previous password when he wants to change the password, however for changing his own password he has to fill it in. @@ -412,7 +421,7 @@ class Users{ return $pageElements; } } - + /** * sets the shards password. * in case the shard is offline, the entry will be stored in the ams_querycache. @@ -421,9 +430,9 @@ class Users{ * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline. */ protected static function setAmsPassword($user, $pass){ - + $values = Array('Password' => $pass); - + try { //make connection with and put into shard db $dbs = new DBLayer("shard"); @@ -435,14 +444,14 @@ class Users{ try { $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "change_pass", - "query" => json_encode(array($values["user"],$values["pass"])), "db" => "shard")); + "query" => json_encode(array($user,$pass)), "db" => "shard")); return "shardoffline"; }catch (PDOException $e) { return "liboffline"; } - } + } } - + /** * sets the shards email. * in case the shard is offline, the entry will be stored in the ams_querycache. @@ -451,25 +460,26 @@ class Users{ * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline. */ protected static function setAmsEmail($user, $mail){ - + $values = Array('Email' => $mail); - + try { //make connection with and put into shard db $dbs = new DBLayer("shard"); - $dbs->update("user", $values, "Login = $user"); + $dbs->update("user", $values, "Login = '$user'"); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { + error_log($e); $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "change_mail", - "query" => json_encode(array($values["user"],$values["mail"])), "db" => "shard")); + "query" => json_encode(array($user,$mail)), "db" => "shard")); return "shardoffline"; }catch (PDOException $e) { return "liboffline"; } - } + } } } diff --git a/code/web/private_php/ams/plugins/API_key_management/.info b/code/web/private_php/ams/plugins/API_key_management/.info index 1da25516e..d96e3ce1e 100644 --- a/code/web/private_php/ams/plugins/API_key_management/.info +++ b/code/web/private_php/ams/plugins/API_key_management/.info @@ -2,7 +2,7 @@ PluginName = API Key Management Description = Provides public access to the API's by generating access tokens. Version = 1.0.0 Type = Manual -TemplatePath = ../../../ams_lib/plugins/API_key_management/templates/index.tpl +TemplatePath = ../../../private_php/ams/plugins/API_key_management/templates/index.tpl diff --git a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php index 27613e18b..8f2e6158b 100644 --- a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php +++ b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php @@ -3,12 +3,12 @@ /** * Global and Local Hooks for the API key Management plugin * Global Hooks are defined with the prefix(name of the plugin) - * Local Hooks are defined with normal function name - * + * Local Hooks are defined with normal function name + * * All the Global Hooks are called during the page load * and Local Hooks are called according to conditions - * - * @author shubham meena mentored by Matthew Lagoe + * + * @author shubham meena mentored by Matthew Lagoe */ // Global variable to store the data which is @@ -27,7 +27,7 @@ function api_key_management_hook_display() global $return_set; // to display plugin name in menu bar $return_set['menu_display'] = 'API Key Management'; - } + } /** * Local Hook to validate the posted data @@ -37,12 +37,12 @@ function hook_validate( $var ) if ( isset( $var ) && !empty( $var ) ) { return true; - } + } else { return false; - } - } + } + } /** * Local Hook to set the POST variables and validate them @@ -51,7 +51,7 @@ function hook_variables() { global $var_set; global $return_set; - + if ( hook_validate( $_POST['expDate'] ) && hook_validate( $_POST['sp_name'] ) && hook_validate( $_POST['api_type'] ) && hook_validate( $_POST['character_name'] ) ) { @@ -63,12 +63,12 @@ function hook_variables() $var_set['AddedOn'] = date( "Y-m-d H:i:s" ); $var_set['Items'] = ''; $return_set['gen_key_validate'] = 'true'; - } + } else { $return_set['gen_key_validate'] = 'false'; - } - } + } + } /** * Global Hook to create table of the API_key_management @@ -108,12 +108,12 @@ function api_key_management_hook_create_tb() -- ALTER TABLE `ams_api_keys` ADD CONSTRAINT `ams_api_keys_ibfk_1` FOREIGN KEY (`User`) REFERENCES `ryzom_ams`.`ams_user` (`Login`);"; - + $dbl -> executeWithoutParams( $sql ); - } + } /** - * Hook to store data to database which is sent as post + * Hook to store data to database which is sent as post * method from the forms in this plugin * It also calls the local hook */ @@ -121,63 +121,67 @@ function api_key_management_hook_store_db() { global $var_set; global $return_set; - + // if the form been submited move forward if ( @hook_validate( $_POST['gen_key'] ) ) { - + // local hook to validate the POST variables hook_variables(); - + // if validation successfull move forward if ( $return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key' ) { // this part generated the access token include 'generate_key.php'; $var_set['AccessToken'] = generate_key :: randomToken( 56, false, true, false ); - + // database connection $db = new DBLayer( 'lib' ); // insert the form data to the database $db -> insert( 'ams_api_keys', $var_set ); - + // redirect to the the main page with success code // 1 refers to the successfull addition of key to the database header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=1" ); - exit; - } - } - } + throw new SystemExit(); + } + } + } /** - * Global Hook to load the data from db and set it + * Global Hook to load the data from db and set it * into the global array to return it to the template */ function api_key_management_hook_load_db() { global $var_set; global $return_set; - - $db = new DBLayer( 'lib' ); - + + $dbl = new DBLayer("lib"); + if ( isset( $_SESSION['user'] ) ) { // returns the registered keys - $sth = $db -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' ); + $sth = $dbl -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' ); $row = $sth -> fetchAll(); $return_set['api_keys'] = $row; - + // fetch the character from the array to compare $com = array_column( $return_set['api_keys'], 'UserCharacter' ); - + // returns the characters with respect to the user id in the ring_tool->characters - $db = new DBLayer( 'ring' ); - $sth = $db -> selectWithParameter( 'char_name', 'characters' , array(), '1' ); - $row = $sth -> fetch(); - - // loop through the character list and remove the character if already have an api key - $return_set['characters'] = array_diff( $row, $com ); - } - } + try { + $dbl = new DBLayer( 'ring' ); + $sth = $dbl -> selectWithParameter( 'char_name', 'characters' , array(), '1' ); + $row = $sth -> fetch(); + + // loop through the character list and remove the character if already have an api key + $return_set['characters'] = array_diff( $row, $com ); + }catch( PDOException $e ) { + error_log($e->getMessage()); +} + } + } /** * Global Hook to update or delete the data from db @@ -186,24 +190,24 @@ function api_key_management_hook_update_db() { global $var_set; global $return_set; - + $db = new DBLayer( 'lib' ); if ( isset( $_GET['delete_id'] ) ) { // removes the registered key using get variable which contains the id of the registered key $db -> delete( 'ams_api_keys', array( 'SNo' => $_GET['delete_id'] ), 'SNo = :SNo' ); - + // redirecting to the API_key_management plugins template with success code // 2 refers to the succssfull delete condition header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=2" ); - exit; - } - } + throw new SystemExit(); + } + } /** * Global Hook to return global variables which contains * the content to use in the smarty templates - * + * * @return $return_set global array returns the template data */ function api_key_management_hook_return_global() diff --git a/code/web/private_php/ams/plugins/API_key_management/templates/gen_key.tpl b/code/web/private_php/ams/plugins/API_key_management/templates/gen_key.tpl index 1ab283449..1aaaef1a9 100644 --- a/code/web/private_php/ams/plugins/API_key_management/templates/gen_key.tpl +++ b/code/web/private_php/ams/plugins/API_key_management/templates/gen_key.tpl @@ -1,5 +1,6 @@
{$hook_info.Achievements.no_char}
{$home_info}
@@ -61,12 +56,13 @@{$ip_file_nfnd}
{/if} - {if isset($smarty.get.result) and $smarty.get.result eq "2"}{$ip_info_nfound}
{/if} + {if isset($smarty.get.result) and $smarty.get.result eq "2"}{$ip_info_nfound}
{/if}{$ip_success}
{$dp_error}
SupportGroup | Actions | |||||
---|---|---|---|---|---|---|
{if $ticket.assignedText neq ""} {$ticket.assignedText} {else} {$not_assigned} {/if} | {$ticket.timestamp} | {$ticket.category} | -{if $ticket.status eq 0} {/if} {$ticket.statusText} | +{if $ticket.status eq 0} {/if} {$ticket.statusText} | - + {if $ticket.forwardedGroupName eq "0"} {$public_sgroup} {else} - {$ticket.forwardedGroupName} + {$ticket.forwardedGroupName} {/if} - - | + +{if $ticket.assigned eq 0} |
{if $hidden eq 1}{/if}{$reply_content}{if $hidden eq 1}{/if}- + -
{$id} | {$type} | - + {foreach from=$liblist item=element}
---|---|
{$element.id} | {$element.type} | - - + +
Permission | Action | - + {foreach from=$userlist item=element}
---|