Changeset 982 for trunk/bureau/class/m_admin.php
- Timestamp:
- 04/02/06 21:13:12 (7 years ago)
- File:
-
- 1 edited
-
trunk/bureau/class/m_admin.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bureau/class/m_admin.php
r973 r982 221 221 * @param $mail Adresse email du propriétaire du compte, permet de récupérer son mot de passe 222 222 * @param $type Type de compte pour les quotas 223 * @param $duration integer Durée du compte en mois 223 224 * @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. 224 225 * 225 226 */ 226 function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default' ) {227 function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0) { 227 228 global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN; 228 229 $err->log("admin","add_mem",$login."/".$mail); … … 268 269 } 269 270 // on le créé ensuite dans system.membres et system.local 270 $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type ) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type');");271 $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW());"); 271 272 $db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');"); 273 $this->renew_update($uid, $duration); 272 274 exec("/usr/lib/alternc/mem_add ".$login." ".$uid); 273 275 // Declenchons les autres classes. … … 316 318 * @param $enabled integer vaut 0 ou 1, active ou désactive l'accès au bureau virtuel de ce compte. 317 319 * @param $type string Nouveau type de compte 320 * @param $duration integer Durée du compte en mois 318 321 * @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. 319 322 * 320 323 */ 321 function update_mem($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type , $type='default') {324 function update_mem($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type='default', $duration=0) { 322 325 global $err,$db; 323 326 global $cuid, $quota; … … 341 344 if($_POST['reset_quotas'] == "on") 342 345 $quota->addquotas(); 346 $this->renew_update($uid, $duration); 343 347 return true; 344 348 } … … 459 463 /* ----------------------------------------------------------------- */ 460 464 /** 465 * Renew an account 466 * 467 * Renew an account for its duration 468 * 469 * @param $uid integer the uid number of the account we want to renew 470 * @param $periods integer the number of periods we renew for 471 * @return boolean Returns FALSE if an error occurs, TRUE if not. 472 */ 473 function renew_mem($uid, $periods=1) { 474 global $err,$db; 475 476 $query = 477 "UPDATE membres SET renewed = renewed + INTERVAL (duration * $periods) MONTH WHERE uid=${uid};"; 478 479 if ($db->query($query)) { 480 return true; 481 } else { 482 $err->raise("admin",2); 483 return false; 484 } 485 } 486 487 /* ----------------------------------------------------------------- */ 488 /** 489 * Update the duration information for an account 490 * 491 * @param $uid integer the uid number of the account we want to update 492 * @param $duration integer the new duration, in months, of the account 493 * @return boolean Returns FALSE if an error occurs, TRUE if not. 494 */ 495 function renew_update($uid, $duration) { 496 global $err,$db; 497 498 if($duration == 0) { 499 if($db->query("UPDATE membres SET duration = NULL, renewed = NULL WHERE uid=$uid;")) 500 return true; 501 } else { 502 if($db->query("UPDATE membres SET duration = $duration WHERE uid=$uid") && 503 $db->query("UPDATE membres SET renewed = NOW() WHERE uid=$uid and renewed is null;")) 504 return true; 505 } 506 507 $err->raise("admin",2); 508 return false; 509 } 510 511 /* ----------------------------------------------------------------- */ 512 /** 513 * 514 * Get the expiry date for an account 515 * 516 * @param $uid integer The uid number of the account 517 * @return string The expiry date, a string as printed by MySQL 518 */ 519 function renew_get_expiry($uid) { 520 global $db; 521 522 $db->query("SELECT renewed + INTERVAL duration MONTH 'expiry' FROM membres WHERE uid='$uid' ;"); 523 if ($db->num_rows()) { 524 $db->next_record(); 525 return $db->Record['expiry']; 526 } 527 528 return ''; 529 } 530 531 /* ----------------------------------------------------------------- */ 532 /** 533 * 534 * Get the expiry status for an account 535 * 536 * @param $uid integer The uid number of the account 537 * @return integer The expiry status: 538 * 0: account does not expire 539 * 1: expires in more than duration, 540 * 2: expires within the duration 541 * 3: has expired past the duration 542 */ 543 function renew_get_status($uid) { 544 global $db; 545 546 $db->query( 547 "SELECT CASE" . 548 " WHEN duration IS NULL THEN 0" . 549 " WHEN renewed + INTERVAL duration MONTH <= NOW() THEN 3" . 550 " WHEN renewed <= NOW() THEN 2" . 551 " ELSE 1 END 'status' FROM membres where uid=$uid;"); 552 553 if($db->num_rows()) { 554 $db->next_record(); 555 return $db->Record['status']; 556 } 557 558 return 0; 559 } 560 561 /* ----------------------------------------------------------------- */ 562 /** 461 563 * Turns a common account into a super-admin account 462 564 *
Note: See TracChangeset
for help on using the changeset viewer.
