Author: marten Date: Wed Oct 21 12:02:19 2009 New Revision: 1243 Log: Added documentation to management website Modified: trunk/pairing/pisaum/include/management.php Modified: trunk/pairing/pisaum/include/management.php ============================================================================== --- trunk/pairing/pisaum/include/management.php Wed Oct 21 11:39:14 2009 (r1242) +++ trunk/pairing/pisaum/include/management.php Wed Oct 21 12:02:19 2009 (r1243) @@ -15,6 +15,15 @@ private $relay_cfg_path = NULL; private $pisaconf_path = NULL; + /** + * Initializes the management class + * + * @param authorized Path of the authorized_hosts.conf file + * @param users Path of the users.conf file + * @param management Path of the management tool + * @param relay Path of the relay_config.cfg file + * @param pisaconf Path of the pisasdconf tool + */ public function Management($authorized=NULL,$users=NULL,$management=NULL,$relay=NULL,$pisaconf=NULL) { if(!is_null($authorized)) @@ -39,6 +48,11 @@ } } + /** + * Lists all user and HIT entries of the configuration files + * + * @return An array of all Entries + */ public function getAllUserAndHitEntries() { $exec = $this->getExecPrefix(); @@ -69,6 +83,13 @@ return $arrayresult; } + /** + * Returns the user with the given name + * + * @param username The name of the user + * @return An array of the user + * @return or an empty array + */ public function getUserByUsername($username) { $exec = $this->getExecPrefix(); @@ -91,6 +112,13 @@ return $arrayresult; } + /** + * Returns HIT-entry with the given HIT + * + * @param hit The HIT of the entry + * @return An array of the HIT-entry + * @return or an empty array + */ public function getHitEntry($hit) { $exec = $this->getExecPrefix(); @@ -118,6 +146,19 @@ return $arrayresult; } + /** + * Adds a new entry to the configuration file + * + * @param hit The HIT of the new entry + * @param username The name of the user + * (can be NULL if only a HIT-entry should be added) + * @param active The active status of the user + * 0: inactive + * 1: active + * 2: default status (active) + * @param creditcard Payment information of the user + * (can be NULL if only a HIT-entry should be added) + */ public function addEntry($hit,$expires=1,$username=NULL,$active=2,$creditcard=NULL) { if(is_null($hit)||$hit=="") @@ -185,6 +226,16 @@ } } + /** + * Changes the expiration date of a HIT-entry or a user + * @param username The name of the user + * for which the expiration date should be changed + * (can be NULL if hit is given) + * @param hit The HIT of the entry + * for which the expiration date should be changed + * (can be NULL if username is given) + * @param expires The new expiration date or 1 for default expiration date + */ public function changeExpirationDate($username=NULL,$hit=NULL,$expires=1) { if(is_null($username) && is_null($hit)) @@ -237,6 +288,20 @@ } } + /** + * Changes the active status of a user + * @param username The name of the user + * for which the active status should be changed + * (can be NULL if hit is given) + * @param hit The HIT of the entry + * for which the active status should be changed + * (can be NULL if username is given) + * @param active The new active status of the user + * 0: inactive + * 1: active + * 2: no change + * @param expires The new expiration date or 1 for default expiration date + */ public function changeActive($username=NULL,$hit=NULL,$active=2,$expiration=1) { if(is_null($username) && is_null($hit)) @@ -296,6 +361,14 @@ } } + /** + * Removes a HIT-entry or a user completely + * @param username The name of the user + * which should be removed + * (can be NULL if hit is given) + * @param hit The HIT of the entry + * which should be removed + * (can be NULL if username is given) public function removeEntry($hit=NULL,$username=NULL) { if(is_null($username) && is_null($hit)) @@ -350,6 +423,10 @@ } } + /** + * Prints out debug statements + * @param output The output that should be printed + */ private function print_debug($output) { if(self::$debug) @@ -359,6 +436,11 @@ } } + /** + * Returns the execution prefix for the management tool + * with the corresponding paths + * @return execution prefix + */ private function getExecPrefix() { $exec = "./management "; @@ -385,6 +467,10 @@ return $exec; } + /** + * Returns the expiration date for a given HIT + * @return expiration date + */ public function getExpirationForHit($hit) { $entry = $this->getHitEntry($hit); @@ -396,6 +482,9 @@ return $result; } + /** + * Requests PISASD to reload the configuration + */ private function reloadPisaSD() { if(!is_null($this->pisaconf_path)) @@ -405,21 +494,39 @@ } } + /** + * Returns if the given hit exists + * @param hit The HIT + * @return if HIT exists -> true, otherwise -> false + */ private function existsHit($hit) { return count($this->getHitEntry($hit))!=0; } - + + /** + * Returns if a user with the given name exists + * @param username The name of the user + * @return if user exists -> true, otherwise -> false + */ private function existsUsername($username) { return count($this->getUserByUsername($username))!=0; } + /** + * Returns if the given credit card number is valid + *@return If card is valid -> true; otherwise -> false public static function isValidCreditCard($number) { return $number!=""; } + /** + * Tries to return the HIT of the server + * @param hipconfpath Path to the hipconf tool + * @return The HIT of the server + */ public static function getServerHit($hipconfpath=NULL) { if(is_null($hipconfpath))