Ejemplo n.º 1
0
 /**
  * delete a temp user
  * @param int $idst_single the idst of the temporary user
  * @param string $random_code the random_code of the temporary user
  * @param time $time delete request oldest than
  * @param time $del_field if is true delete also the field related to the user
  * @return TRUE if success, FALSE otherwise
  */
 function deleteTempUser($idst_single = false, $random_code = false, $time = false, $del_field = true)
 {
     require_once _adm_ . '/lib/lib.field.php';
     $idst_del = array();
     $result = true;
     if ($idst_single !== false) {
         $idst_del[] = $idst_single;
     } elseif ($random_code !== false) {
         $query_sel = "SELECT idst " . " FROM " . $this->_getTableTempUser() . " WHERE random_code = '" . $random_code . "'";
         $re = $this->_executeQuery($query_sel);
         while (list($id) = sql_fetch_row($re)) {
             $idst_del[] = $id;
         }
     } elseif ($time !== false) {
         $query_sel = "SELECT idst" . " FROM " . $this->_getTableTempUser() . " WHERE UNIX_TIMESTAMP(request_on) <= '" . $time . "'" . " AND confirmed = 0";
         $re = $this->_executeQuery($query_sel);
         while (list($id) = sql_fetch_row($re)) {
             $idst_del[] = $id;
         }
     }
     // Remove all the finded entry
     while (list(, $idst) = each($idst_del)) {
         if ($del_field === true) {
             $this->_removeAllFromGroup($idst);
             $this->_removeAllFromRole($idst);
             $extra_field = new FieldList();
             $extra_field->quickRemoveUserEntry($idst);
             //remove also from courseuser if neeeded
             DbConn::getInstance()->query("DELETE FROM %lms_courseuser WHERE idUser = "******" ");
         }
         $query = "DELETE FROM " . $this->_getTableTempUser() . " WHERE idst = '" . $idst . "'";
         $result &= $this->_executeQuery($query);
     }
     // Remove all the associated codes
     foreach ($idst_del as $idst) {
         require_once $GLOBALS['where_framework'] . '/lib/lib.code.php';
         $code_manager = new CodeManager();
         $code_manager->resetUserCode($idst);
     }
     return $result;
 }