diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php index 4989767aa..8de17a9e2 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php @@ -3,7 +3,6 @@ * Handles the assigning of a ticket to a user. This is being used to make someone responsible for the handling and solving of a ticket. * The idea is that someone can easily assign a ticket to himself and by doing that, he makes aware to the other moderators that he will deal with the ticket in the future. * @author Daan Janssens, mentored by Matthew Lagoe -* */ class Assigned{ @@ -92,7 +91,6 @@ class Assigned{ ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - /** * A constructor. * Empty constructor diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php index e9748fc04..e09de1621 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php @@ -1,7 +1,21 @@ getTimestamp(); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php index 24bfc5abd..24aed5483 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php @@ -1,8 +1,20 @@ caching = false; $smarty -> cache_lifetime = 120; + //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/'; $smarty -> setConfigDir( $AMS_LIB . '/configs' ); @@ -41,12 +56,13 @@ class Helpers{ $smarty -> assign( $key, $value ); } - + //load page specific variables that are language dependent $variables = Helpers::handle_language(); foreach ( $variables[$template] as $key => $value ){ $smarty -> assign( $key, $value ); } + //smarty inheritance for loading the matching wrapper layout (with the matching menu bar) if( isset($vars['permission']) && $vars['permission'] == 3 ){ $inherited = "extends:layout_admin.tpl|"; }else if( isset($vars['permission']) && $vars['permission'] == 2){ @@ -57,8 +73,7 @@ class Helpers{ $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{ @@ -66,6 +81,11 @@ class Helpers{ } } + + /** + * 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(){ global $AMS_LIB; global $SITEBASE; @@ -78,8 +98,8 @@ class Helpers{ $SITEBASE . '/configs' ); foreach ( $arr as & $value ){ + if ( !file_exists( $value ) ){ - //echo $value; print($value); mkdir($value); } @@ -87,6 +107,11 @@ class Helpers{ } + + /** + * 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() { // if HTTP_USER_AGENT is not set then its ryzom core @@ -98,6 +123,13 @@ class Helpers{ } } + + /** + * 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; @@ -149,8 +181,11 @@ class Helpers{ } - - //Time output function for handling the time display function. + + /** + * 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){ @@ -160,6 +195,12 @@ class Helpers{ } } + /** + * 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"); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php index b01517db2..bf10d3d9a 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php @@ -1,13 +1,23 @@ user_id, 'Group' => support_groups_id). + */ public function set($values) { $this->setUser($values['User']); $this->setGroup($values['Group']); } + + /** + * creates a new 'in_support_group' entry. + * this method will use the object's attributes for creating a new 'in_support_group' entry in the database. + */ public function create() { $dbl = new DBLayer("lib"); $query = "INSERT INTO `in_support_group` (`User`,`Group`) VALUES (:user, :group)"; @@ -36,7 +59,11 @@ class In_Support_Group{ $dbl->execute($query, $values); } - //delete entry + + /** + * deletes an existing 'in_support_group' entry. + * this method will use the object's attributes for deleting an existing 'in_support_group' entry in the database. + */ public function delete() { $dbl = new DBLayer("lib"); $query = "DELETE FROM `in_support_group` WHERE `User` = :user_id and `Group` = :group_id"; @@ -44,31 +71,48 @@ class In_Support_Group{ $dbl->execute($query, $values); } - //Load with sGroupId - public function load( $user_id, $group_id) { + /* + public function load($group_id) { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `in_support_group` WHERE `Group` = :group_id", Array('group_id' => $group_id)); $row = $statement->fetch(); $this->set($row); } + */ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + /** + * get user attribute of the object. + */ public function getUser(){ return $this->user; } + + /** + * get group attribute of the object. + */ public function getGroup(){ return $this->group; } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + /** + * set user attribute of the object. + * @param $u integer id of the user + */ public function setUser($u){ $this->user = $u; } + + /** + * set group attribute of the object. + * @param $g integer id of the support group + */ public function setGroup($g){ $this->group = $g; } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php index 4434c62db..18422474f 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php @@ -1,23 +1,42 @@ config = $cryptinfo; } - + /** + * encrypts by using the given enc_method and hash_method. + * It will first check if the methods are supported, if not it will throw an error, if so it will encrypt the $data + * @param $data the string that we want to encrypt. + * @return the encrypted string. + */ public function encrypt($data) { self::check_methods($this->config['enc_method'], $this->config['hash_method']); @@ -17,6 +31,11 @@ class MyCrypt{ return $infostr . openssl_encrypt($data, $this->config['enc_method'], $this->config['key'], false, $iv); } + /** + * decrypts by using the given enc_method and hash_method. + * @param $edata the encrypted string that we want to decrypt + * @return the decrypted string. + */ public function decrypt($edata) { $e_arr = explode('$', $edata); if( count($e_arr) != 4 ) { @@ -29,6 +48,13 @@ class MyCrypt{ return openssl_decrypt($e_arr[3], $this->config['enc_method'], $this->config['key'], false, $iv); } + /** + * hashes the key by using a hash method specified. + * @param $key the key to be hashed + * @param $method the metho of hashing to be used + * @param $iv_size the size of the initialization vector. + * @return return the hashed key up till the size of the iv_size param. + */ private static function hashIV($key, $method, $iv_size) { $myhash = hash($method, $key, TRUE); while( strlen($myhash) < $iv_size ) { @@ -37,6 +63,12 @@ class MyCrypt{ return substr($myhash, 0, $iv_size); } + /** + * checks if the encryption and hash methods are supported + * @param $enc the encryption method. + * @param $hash the hash method. + * @throw Exception in case a method is not supported. + */ private static function check_methods($enc, $hash) { if( ! function_exists('openssl_encrypt') ) {